diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e9a7ee35f0f4..05db16fee848 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -83,8 +83,8 @@ jobs: } } const results = [ - await assertSize('./fixtures/ssg/dist/client', 288), - await assertSize('./fixtures/webstudio-remix-netlify-functions/build/client', 376), + await assertSize('./fixtures/ssg/dist/client', 352), + await assertSize('./fixtures/webstudio-remix-netlify-functions/build/client', 440), await assertSize('./fixtures/webstudio-remix-vercel/build/client', 908), ] for (const result of results) { diff --git a/apps/builder/app/builder/features/command-panel/command-panel.tsx b/apps/builder/app/builder/features/command-panel/command-panel.tsx index 57ad57af18cd..de33f6af4d50 100644 --- a/apps/builder/app/builder/features/command-panel/command-panel.tsx +++ b/apps/builder/app/builder/features/command-panel/command-panel.tsx @@ -35,10 +35,14 @@ import { $selectedBreakpoint, $selectedBreakpointId, } from "~/shared/nano-states"; -import { getInstanceLabel } from "~/shared/instance-utils"; +import { + findClosestInsertable, + getComponentTemplateData, + getInstanceLabel, + insertTemplateData, +} from "~/shared/instance-utils"; import { humanizeString } from "~/shared/string-utils"; import { setCanvasWidth } from "~/builder/features/breakpoints"; -import { insert as insertComponent } from "~/builder/features/components/insert"; import { $selectedPage, selectPage } from "~/shared/awareness"; import { mapGroupBy } from "~/shared/shim"; import { setActiveSidebarPanel } from "~/builder/shared/nano-states"; @@ -146,7 +150,13 @@ const ComponentOptionsGroup = ({ options }: { options: ComponentOption[] }) => { value={component} onSelect={() => { closeCommandPanel(); - insertComponent(component); + const fragment = getComponentTemplateData(component); + if (fragment) { + const insertable = findClosestInsertable(fragment); + if (insertable) { + insertTemplateData(fragment, insertable); + } + } }} > diff --git a/apps/builder/app/builder/features/components/components.tsx b/apps/builder/app/builder/features/components/components.tsx index 9d7a45ae9d36..d040bb6e8911 100644 --- a/apps/builder/app/builder/features/components/components.tsx +++ b/apps/builder/app/builder/features/components/components.tsx @@ -34,9 +34,13 @@ import { type MetaByCategory, type ComponentNamesByMeta, } from "./get-meta-maps"; -import { getInstanceLabel } from "~/shared/instance-utils"; +import { + findClosestInsertable, + getComponentTemplateData, + getInstanceLabel, + insertTemplateData, +} from "~/shared/instance-utils"; import { isFeatureEnabled } from "@webstudio-is/feature-flags"; -import { insert } from "./insert"; import { matchSorter } from "match-sorter"; import { parseComponentName } from "@webstudio-is/sdk"; import type { Publish } from "~/shared/pubsub"; @@ -183,7 +187,13 @@ export const ComponentsPanel = ({ const handleInsert = (component: string) => { onClose(); - insert(component); + const fragment = getComponentTemplateData(component); + if (fragment) { + const insertable = findClosestInsertable(fragment); + if (insertable) { + insertTemplateData(fragment, insertable); + } + } }; const resetSelectedComponent = () => { diff --git a/apps/builder/app/builder/features/components/insert.ts b/apps/builder/app/builder/features/components/insert.ts deleted file mode 100644 index a31383990ded..000000000000 --- a/apps/builder/app/builder/features/components/insert.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { WsComponentMeta } from "@webstudio-is/react-sdk"; -import { toast } from "@webstudio-is/design-system"; -import { $registeredComponentMetas } from "~/shared/nano-states"; -import { - findClosestInsertable, - getComponentTemplateData, - insertTemplateData, -} from "~/shared/instance-utils"; - -const formatInsertionError = (component: string, meta: WsComponentMeta) => { - const or = new Intl.ListFormat("en", { - type: "disjunction", - }); - const and = new Intl.ListFormat("en", { - type: "conjunction", - }); - const messages: string[] = []; - if (meta.requiredAncestors) { - const listString = or.format(meta.requiredAncestors); - messages.push(`can be added only inside of ${listString}`); - } - if (meta.invalidAncestors) { - const listString = and.format(meta.invalidAncestors); - messages.push(`cannot be added inside of ${listString}`); - } - return `${component} ${and.format(messages)}`; -}; - -// Insert a component depending on currently selected instance. -// Used for 1-click insert from the components panel. -export const insert = (component: string) => { - const fragment = getComponentTemplateData(component); - if (fragment === undefined) { - return; - } - const insertable = findClosestInsertable(fragment); - if (insertable === undefined) { - const metas = $registeredComponentMetas.get(); - const meta = metas.get(component); - if (meta) { - toast.error(formatInsertionError(component, meta)); - } - return; - } - insertTemplateData(fragment, insertable); -}; diff --git a/apps/builder/app/shared/instance-utils.ts b/apps/builder/app/shared/instance-utils.ts index d9a83b972666..e587d88381b3 100644 --- a/apps/builder/app/shared/instance-utils.ts +++ b/apps/builder/app/shared/instance-utils.ts @@ -1459,6 +1459,7 @@ export const findClosestInsertable = ( instances, instanceSelector: instanceSelector.slice(closestContainerIndex), fragment, + onError: (message) => toast.error(message), }); if (insertableIndex === -1) { return; diff --git a/apps/builder/app/shared/matcher.test.tsx b/apps/builder/app/shared/matcher.test.tsx index 7516380292ff..d5dcf6ec9171 100644 --- a/apps/builder/app/shared/matcher.test.tsx +++ b/apps/builder/app/shared/matcher.test.tsx @@ -1,4 +1,4 @@ -import { describe, expect, test } from "vitest"; +import { describe, expect, test, vi } from "vitest"; import { renderJsx, $, ExpressionValue } from "@webstudio-is/sdk/testing"; import { coreMetas } from "@webstudio-is/react-sdk"; import * as baseMetas from "@webstudio-is/sdk-components-react/metas"; @@ -563,6 +563,72 @@ describe("is instance matching", () => { }) ).toBeFalsy(); }); + + test("provide error message when negated matcher is failed", () => { + const onError = vi.fn(); + isInstanceMatching({ + ...renderJsx( + <$.Body ws:id="body"> + <$.Box ws:id="box"> + + ), + instanceSelector: ["box", "body"], + query: { + relation: "self", + component: { $nin: ["Box", "Text"] }, + }, + onError, + }); + expect(onError).toHaveBeenLastCalledWith("Box or Text is not acceptable"); + isInstanceMatching({ + ...renderJsx( + <$.Body ws:id="body"> + <$.Box ws:id="box"> + <$.ListItem ws:id="listitem"> + + + ), + instanceSelector: ["listitem", "box", "body"], + query: { + relation: "ancestor", + component: { $nin: ["Box", "Text"] }, + }, + onError, + }); + expect(onError).toHaveBeenLastCalledWith("Box or Text is not acceptable"); + }); + + test("provide error message when positive matcher is failed", () => { + const onError = vi.fn(); + isInstanceMatching({ + ...renderJsx( + <$.Body ws:id="body"> + <$.ListItem ws:id="listitem"> + + ), + instanceSelector: ["box", "body"], + query: { + relation: "self", + component: { $in: ["Box", "Text"] }, + }, + onError, + }); + expect(onError).toHaveBeenLastCalledWith("Box or Text is missing"); + isInstanceMatching({ + ...renderJsx( + <$.Body ws:id="body"> + <$.ListItem ws:id="listitem"> + + ), + instanceSelector: ["box", "body"], + query: { + relation: "ancestor", + component: { $in: ["Box", "Text"] }, + }, + onError, + }); + expect(onError).toHaveBeenLastCalledWith("Box or Text is missing"); + }); }); describe("is tree matching", () => { @@ -781,6 +847,25 @@ describe("find closest instance matching fragment", () => { }) ).toEqual(1); }); + + test("report first error", () => { + const onError = vi.fn(); + const { instances } = renderJsx(<$.Body ws:id="body">); + const fragment = createFragment( + // only children are tested + <> + <$.ListItem ws:id="listitem"> + + ); + findClosestInstanceMatchingFragment({ + metas, + instances, + instanceSelector: ["body"], + fragment, + onError, + }); + expect(onError).toHaveBeenLastCalledWith("List is missing"); + }); }); describe("find closest container", () => { diff --git a/apps/builder/app/shared/matcher.ts b/apps/builder/app/shared/matcher.ts index a987d2bb21fd..521f417daae9 100644 --- a/apps/builder/app/shared/matcher.ts +++ b/apps/builder/app/shared/matcher.ts @@ -48,6 +48,26 @@ const isLevelMatchingRelation = (level: number, relation: MatcherRelation) => { ); }; +const formatList = (operation: MatcherOperation) => { + const listFormat = new Intl.ListFormat("en", { + type: "disjunction", + }); + const list: string[] = []; + if (operation.$eq) { + list.push(operation.$eq); + } + if (operation.$in) { + list.push(...operation.$in); + } + if (operation.$neq) { + list.push(operation.$neq); + } + if (operation.$nin) { + list.push(...operation.$nin); + } + return listFormat.format(list); +}; + /** * @todo following features are missing * - tag matcher @@ -56,10 +76,12 @@ export const isInstanceMatching = ({ instances, instanceSelector, query, + onError, }: { instances: Instances; instanceSelector: InstanceSelector; query: undefined | Matcher | Matcher[]; + onError?: (message: string) => void; }): boolean => { // fast path to the lack of constraints if (query === undefined) { @@ -73,6 +95,9 @@ export const isInstanceMatching = ({ if (isNegated(matcher.component)) { if (matches) { aborted = true; + if (matcher.component) { + onError?.(`${formatList(matcher.component)} is not acceptable`); + } return; } // inverse negated match @@ -124,18 +149,29 @@ export const isInstanceMatching = ({ if (aborted) { return false; } - return queries.every((matcher) => matchesByMatcher.get(matcher)); + for (const matcher of queries) { + const matches = matchesByMatcher.get(matcher) ?? false; + if (matches === false) { + if (matcher.component) { + onError?.(`${formatList(matcher.component)} is missing`); + } + return false; + } + } + return true; }; export const isTreeMatching = ({ instances, metas, instanceSelector, + onError, level = 0, }: { instances: Instances; metas: Map; instanceSelector: InstanceSelector; + onError?: (message: string) => void; level?: number; }): boolean => { const [instanceId] = instanceSelector; @@ -150,6 +186,7 @@ export const isTreeMatching = ({ instances, instanceSelector, query: meta?.constraints, + onError, }); // check ancestors only on the first run if (level === 0) { @@ -164,6 +201,7 @@ export const isTreeMatching = ({ instances, instanceSelector: instanceSelector.slice(index), query: meta?.constraints, + onError, }); if (matches === false) { return false; @@ -180,6 +218,7 @@ export const isTreeMatching = ({ metas, instanceSelector: [child.value, ...instanceSelector], level: level + 1, + onError, }); if (matches === false) { return false; @@ -194,16 +233,19 @@ export const findClosestInstanceMatchingFragment = ({ metas, instanceSelector, fragment, + onError, }: { instances: Instances; metas: Map; instanceSelector: InstanceSelector; fragment: WebstudioFragment; + onError?: (message: string) => void; }) => { const mergedInstances = new Map(instances); for (const instance of fragment.instances) { mergedInstances.set(instance.id, instance); } + let firstError = ""; for (let index = 0; index < instanceSelector.length; index += 1) { const instanceId = instanceSelector[index]; const instance = instances.get(instanceId); @@ -222,6 +264,11 @@ export const findClosestInstanceMatchingFragment = ({ instances: mergedInstances, metas, instanceSelector: [child.value, ...instanceSelector.slice(index)], + onError: (message) => { + if (firstError === "") { + firstError = message; + } + }, }); } } @@ -229,6 +276,7 @@ export const findClosestInstanceMatchingFragment = ({ return index; } } + onError?.(firstError); return -1; }; diff --git a/fixtures/ssg/.webstudio/data.json b/fixtures/ssg/.webstudio/data.json index 055165a01fc6..b7c01b0448aa 100644 --- a/fixtures/ssg/.webstudio/data.json +++ b/fixtures/ssg/.webstudio/data.json @@ -473,6 +473,20 @@ "width": 14, "height": 16 } + }, + { + "id": "d0974db9300c1a3b0fb8b291dd9fabd45ad136478908394280af2f7087e3aecd", + "name": "147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg", + "description": null, + "projectId": "d845c167-ea07-4875-b08d-83e97c09dcce", + "size": 64701, + "type": "image", + "format": "jpg", + "createdAt": "2024-12-06T14:36:07.046+00:00", + "meta": { + "width": 820, + "height": 985 + } } ], "user": { diff --git a/fixtures/ssg/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg b/fixtures/ssg/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg new file mode 100644 index 000000000000..9d5e2b88439a Binary files /dev/null and b/fixtures/ssg/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg differ diff --git a/fixtures/webstudio-cloudflare-template/.webstudio/data.json b/fixtures/webstudio-cloudflare-template/.webstudio/data.json index 055165a01fc6..b7c01b0448aa 100644 --- a/fixtures/webstudio-cloudflare-template/.webstudio/data.json +++ b/fixtures/webstudio-cloudflare-template/.webstudio/data.json @@ -473,6 +473,20 @@ "width": 14, "height": 16 } + }, + { + "id": "d0974db9300c1a3b0fb8b291dd9fabd45ad136478908394280af2f7087e3aecd", + "name": "147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg", + "description": null, + "projectId": "d845c167-ea07-4875-b08d-83e97c09dcce", + "size": 64701, + "type": "image", + "format": "jpg", + "createdAt": "2024-12-06T14:36:07.046+00:00", + "meta": { + "width": 820, + "height": 985 + } } ], "user": { diff --git a/fixtures/webstudio-cloudflare-template/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg b/fixtures/webstudio-cloudflare-template/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg new file mode 100644 index 000000000000..9d5e2b88439a Binary files /dev/null and b/fixtures/webstudio-cloudflare-template/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg differ diff --git a/fixtures/webstudio-remix-netlify-edge-functions/.webstudio/data.json b/fixtures/webstudio-remix-netlify-edge-functions/.webstudio/data.json index 055165a01fc6..b7c01b0448aa 100644 --- a/fixtures/webstudio-remix-netlify-edge-functions/.webstudio/data.json +++ b/fixtures/webstudio-remix-netlify-edge-functions/.webstudio/data.json @@ -473,6 +473,20 @@ "width": 14, "height": 16 } + }, + { + "id": "d0974db9300c1a3b0fb8b291dd9fabd45ad136478908394280af2f7087e3aecd", + "name": "147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg", + "description": null, + "projectId": "d845c167-ea07-4875-b08d-83e97c09dcce", + "size": 64701, + "type": "image", + "format": "jpg", + "createdAt": "2024-12-06T14:36:07.046+00:00", + "meta": { + "width": 820, + "height": 985 + } } ], "user": { diff --git a/fixtures/webstudio-remix-netlify-edge-functions/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg b/fixtures/webstudio-remix-netlify-edge-functions/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg new file mode 100644 index 000000000000..9d5e2b88439a Binary files /dev/null and b/fixtures/webstudio-remix-netlify-edge-functions/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg differ diff --git a/fixtures/webstudio-remix-netlify-functions/.webstudio/data.json b/fixtures/webstudio-remix-netlify-functions/.webstudio/data.json index 055165a01fc6..b7c01b0448aa 100644 --- a/fixtures/webstudio-remix-netlify-functions/.webstudio/data.json +++ b/fixtures/webstudio-remix-netlify-functions/.webstudio/data.json @@ -473,6 +473,20 @@ "width": 14, "height": 16 } + }, + { + "id": "d0974db9300c1a3b0fb8b291dd9fabd45ad136478908394280af2f7087e3aecd", + "name": "147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg", + "description": null, + "projectId": "d845c167-ea07-4875-b08d-83e97c09dcce", + "size": 64701, + "type": "image", + "format": "jpg", + "createdAt": "2024-12-06T14:36:07.046+00:00", + "meta": { + "width": 820, + "height": 985 + } } ], "user": { diff --git a/fixtures/webstudio-remix-netlify-functions/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg b/fixtures/webstudio-remix-netlify-functions/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg new file mode 100644 index 000000000000..9d5e2b88439a Binary files /dev/null and b/fixtures/webstudio-remix-netlify-functions/public/assets/147-1478573_cat-icon-png-black-cat-png-icon.png_ZJ6-qJjk1RlFzuYwyCXdp.jpeg differ diff --git a/packages/react-sdk/src/components/component-meta.ts b/packages/react-sdk/src/components/component-meta.ts index 282f0e9b756a..f192b2e62734 100644 --- a/packages/react-sdk/src/components/component-meta.ts +++ b/packages/react-sdk/src/components/component-meta.ts @@ -60,8 +60,6 @@ export const WsComponentMeta = z.object({ // embed - images, videos or other embeddable components, without children // rich-text-child - formatted text fragment, not listed in components list type: z.enum(["container", "control", "embed", "rich-text-child"]), - requiredAncestors: z.optional(z.array(z.string())), - invalidAncestors: z.optional(z.array(z.string())), constraints: Matchers.optional(), // when this field is specified component receives // prop with index of same components withiin specified ancestor diff --git a/packages/react-sdk/src/embed-template.test.tsx b/packages/react-sdk/src/embed-template.test.tsx index 9a0a06f3a014..296c68330682 100644 --- a/packages/react-sdk/src/embed-template.test.tsx +++ b/packages/react-sdk/src/embed-template.test.tsx @@ -766,8 +766,6 @@ test("add namespace to selected components in embed template", () => { type: "container", label: "", icon: "", - requiredAncestors: ["Button", "Box"], - invalidAncestors: ["Tooltip"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Box"] }, @@ -807,8 +805,6 @@ test("add namespace to selected components in embed template", () => { type: "container", label: "", icon: "", - requiredAncestors: ["my-namespace:Button", "Box"], - invalidAncestors: ["my-namespace:Tooltip"], constraints: { relation: "ancestor", component: { $nin: ["my-namespace:Button", "my-namespace:Box"] }, diff --git a/packages/react-sdk/src/embed-template.ts b/packages/react-sdk/src/embed-template.ts index 68dfb1735ec7..63098715777f 100644 --- a/packages/react-sdk/src/embed-template.ts +++ b/packages/react-sdk/src/embed-template.ts @@ -479,16 +479,6 @@ export const namespaceMeta = ( components: Set ) => { const newMeta = { ...meta }; - if (newMeta.requiredAncestors) { - newMeta.requiredAncestors = newMeta.requiredAncestors.map((component) => - components.has(component) ? `${namespace}:${component}` : component - ); - } - if (newMeta.invalidAncestors) { - newMeta.invalidAncestors = newMeta.invalidAncestors.map((component) => - components.has(component) ? `${namespace}:${component}` : component - ); - } if (newMeta.constraints) { if (Array.isArray(newMeta.constraints)) { newMeta.constraints = newMeta.constraints.map((matcher) => diff --git a/packages/sdk-components-react-radix/src/accordion.ws.ts b/packages/sdk-components-react-radix/src/accordion.ws.ts index 8cd1e4e69cb4..09c0ced4d591 100644 --- a/packages/sdk-components-react-radix/src/accordion.ws.ts +++ b/packages/sdk-components-react-radix/src/accordion.ws.ts @@ -222,7 +222,6 @@ export const metaAccordionItem: WsComponentMeta = { type: "container", label: "Item", icon: ItemIcon, - requiredAncestors: ["Accordion"], constraints: { relation: "ancestor", component: { $eq: "Accordion" }, @@ -236,7 +235,6 @@ export const metaAccordionHeader: WsComponentMeta = { type: "container", label: "Item Header", icon: HeaderIcon, - requiredAncestors: ["AccordionItem"], constraints: { relation: "ancestor", component: { $eq: "AccordionItem" }, @@ -252,7 +250,6 @@ export const metaAccordionTrigger: WsComponentMeta = { type: "container", label: "Item Trigger", icon: TriggerIcon, - requiredAncestors: ["AccordionHeader"], constraints: { relation: "ancestor", component: { $eq: "AccordionHeader" }, @@ -276,7 +273,6 @@ export const metaAccordionContent: WsComponentMeta = { type: "container", label: "Item Content", icon: ContentIcon, - requiredAncestors: ["AccordionItem"], constraints: { relation: "ancestor", component: { $eq: "AccordionItem" }, diff --git a/packages/sdk-components-react-radix/src/navigation-menu.ws.ts b/packages/sdk-components-react-radix/src/navigation-menu.ws.ts index f7386e27a2ff..b9ff52cc7401 100644 --- a/packages/sdk-components-react-radix/src/navigation-menu.ws.ts +++ b/packages/sdk-components-react-radix/src/navigation-menu.ws.ts @@ -431,7 +431,6 @@ export const metaNavigationMenuList: WsComponentMeta = { detachable: false, type: "container", icon: ListIcon, - requiredAncestors: ["NavigationMenu"], constraints: { relation: "ancestor", component: { $eq: "NavigationMenu" }, @@ -444,7 +443,6 @@ export const metaNavigationMenuItem: WsComponentMeta = { category: "hidden", type: "container", icon: ListItemIcon, - requiredAncestors: ["NavigationMenu"], constraints: { relation: "ancestor", component: { $eq: "NavigationMenu" }, @@ -459,7 +457,6 @@ export const metaNavigationMenuTrigger: WsComponentMeta = { stylable: false, type: "container", icon: TriggerIcon, - requiredAncestors: ["NavigationMenuItem"], constraints: { relation: "ancestor", component: { $eq: "NavigationMenuItem" }, @@ -472,7 +469,6 @@ export const metaNavigationMenuContent: WsComponentMeta = { detachable: false, type: "container", icon: ContentIcon, - requiredAncestors: ["NavigationMenuItem"], constraints: { relation: "ancestor", component: { $eq: "NavigationMenuItem" }, @@ -488,7 +484,6 @@ export const metaNavigationMenuLink: WsComponentMeta = { type: "container", stylable: false, icon: BoxIcon, - requiredAncestors: ["NavigationMenu"], constraints: [ { relation: "ancestor", @@ -508,7 +503,6 @@ export const metaNavigationMenuViewport: WsComponentMeta = { detachable: true, type: "container", icon: ViewportIcon, - requiredAncestors: ["NavigationMenu"], constraints: { relation: "ancestor", component: { $eq: "NavigationMenu" }, diff --git a/packages/sdk-components-react-radix/src/radio-group.ws.ts b/packages/sdk-components-react-radix/src/radio-group.ws.ts index 42275dbd44bd..96a776ade14c 100644 --- a/packages/sdk-components-react-radix/src/radio-group.ws.ts +++ b/packages/sdk-components-react-radix/src/radio-group.ws.ts @@ -144,7 +144,6 @@ export const metaRadioGroup: WsComponentMeta = { export const metaRadioGroupItem: WsComponentMeta = { category: "hidden", type: "container", - requiredAncestors: ["RadioGroup"], constraints: { relation: "ancestor", component: { $eq: "RadioGroup" }, diff --git a/packages/sdk-components-react-radix/src/select.ws.ts b/packages/sdk-components-react-radix/src/select.ws.ts index bc3af110b1d9..b5edae50b842 100644 --- a/packages/sdk-components-react-radix/src/select.ws.ts +++ b/packages/sdk-components-react-radix/src/select.ws.ts @@ -278,7 +278,6 @@ export const metaSelectItem: WsComponentMeta = { category: "hidden", type: "container", icon: ItemIcon, - requiredAncestors: ["SelectViewport"], constraints: { relation: "ancestor", component: { $eq: "SelectViewport" }, @@ -292,7 +291,6 @@ export const metaSelectItemIndicator: WsComponentMeta = { label: "Indicator", icon: CheckMarkIcon, detachable: false, - requiredAncestors: ["SelectItem"], constraints: { relation: "ancestor", component: { $eq: "SelectItem" }, @@ -308,7 +306,6 @@ export const metaSelectItemText: WsComponentMeta = { label: "Item Text", icon: TextIcon, detachable: false, - requiredAncestors: ["SelectItem"], constraints: { relation: "ancestor", component: { $eq: "SelectItem" }, diff --git a/packages/sdk-components-react-radix/src/tabs.ws.ts b/packages/sdk-components-react-radix/src/tabs.ws.ts index 79ec3ed26f8e..37c07d3c408d 100644 --- a/packages/sdk-components-react-radix/src/tabs.ws.ts +++ b/packages/sdk-components-react-radix/src/tabs.ws.ts @@ -159,7 +159,6 @@ export const metaTabsList: WsComponentMeta = { category: "hidden", type: "container", icon: HeaderIcon, - requiredAncestors: ["Tabs"], constraints: { relation: "ancestor", component: { $eq: "Tabs" }, @@ -171,8 +170,6 @@ export const metaTabsTrigger: WsComponentMeta = { category: "hidden", type: "container", icon: TriggerIcon, - requiredAncestors: ["TabsList"], - invalidAncestors: ["TabsTrigger"], constraints: [ { relation: "ancestor", @@ -203,7 +200,6 @@ export const metaTabsContent: WsComponentMeta = { type: "container", label: "Tab Content", icon: ContentIcon, - requiredAncestors: ["Tabs"], constraints: { relation: "ancestor", component: { $eq: "Tabs" }, diff --git a/packages/sdk-components-react/src/button.ws.ts b/packages/sdk-components-react/src/button.ws.ts index d9d2ae0b285f..abb537ca30e0 100644 --- a/packages/sdk-components-react/src/button.ws.ts +++ b/packages/sdk-components-react/src/button.ws.ts @@ -16,7 +16,6 @@ const presetStyle = { export const meta: WsComponentMeta = { category: "forms", type: "container", - invalidAncestors: ["Button", "Link"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Link"] }, diff --git a/packages/sdk-components-react/src/checkbox.ws.ts b/packages/sdk-components-react/src/checkbox.ws.ts index 44851ec111fb..48bc12b0b020 100644 --- a/packages/sdk-components-react/src/checkbox.ws.ts +++ b/packages/sdk-components-react/src/checkbox.ws.ts @@ -21,7 +21,6 @@ const presetStyle = { export const meta: WsComponentMeta = { category: "forms", - invalidAncestors: ["Button", "Link"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Link"] }, diff --git a/packages/sdk-components-react/src/code-text.ws.ts b/packages/sdk-components-react/src/code-text.ws.ts index 51de62a24c31..2101a99b009c 100644 --- a/packages/sdk-components-react/src/code-text.ws.ts +++ b/packages/sdk-components-react/src/code-text.ws.ts @@ -45,7 +45,6 @@ export const meta: WsComponentMeta = { description: "Use this component when you want to display code as text on the page.", icon: CodeTextIcon, - invalidAncestors: ["CodeText"], constraints: { relation: "ancestor", component: { $neq: "CodeText" }, diff --git a/packages/sdk-components-react/src/form.ws.ts b/packages/sdk-components-react/src/form.ws.ts index d89215411a1d..8facb8f808dd 100644 --- a/packages/sdk-components-react/src/form.ws.ts +++ b/packages/sdk-components-react/src/form.ws.ts @@ -20,7 +20,6 @@ export const meta: WsComponentMeta = { category: "forms", type: "container", label: "Form", - invalidAncestors: ["Form", "Button", "Link"], constraints: { relation: "ancestor", component: { $nin: ["Form", "Button", "Link"] }, diff --git a/packages/sdk-components-react/src/heading.ws.ts b/packages/sdk-components-react/src/heading.ws.ts index 976be3858fe1..0e44b3f68629 100644 --- a/packages/sdk-components-react/src/heading.ws.ts +++ b/packages/sdk-components-react/src/heading.ws.ts @@ -27,7 +27,6 @@ export const meta: WsComponentMeta = { description: "Use HTML headings to structure and organize content. Use the Tag property in settings to change the heading level (h1-h6).", icon: HeadingIcon, - invalidAncestors: ["Heading"], constraints: { relation: "ancestor", component: { $neq: "Heading" }, diff --git a/packages/sdk-components-react/src/input.ws.ts b/packages/sdk-components-react/src/input.ws.ts index 21442029fdf4..fac70ba78742 100644 --- a/packages/sdk-components-react/src/input.ws.ts +++ b/packages/sdk-components-react/src/input.ws.ts @@ -21,7 +21,6 @@ const presetStyle = { export const meta: WsComponentMeta = { category: "forms", - invalidAncestors: ["Button", "Link"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Link"] }, diff --git a/packages/sdk-components-react/src/label.ws.ts b/packages/sdk-components-react/src/label.ws.ts index 8b5aa8f4f749..ba8102f9502c 100644 --- a/packages/sdk-components-react/src/label.ws.ts +++ b/packages/sdk-components-react/src/label.ws.ts @@ -18,7 +18,6 @@ const presetStyle = { export const meta: WsComponentMeta = { category: "forms", - invalidAncestors: ["Button", "Label"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Link"] }, diff --git a/packages/sdk-components-react/src/link.ws.ts b/packages/sdk-components-react/src/link.ws.ts index fdb39d3a2c92..6cb1829357bc 100644 --- a/packages/sdk-components-react/src/link.ws.ts +++ b/packages/sdk-components-react/src/link.ws.ts @@ -29,7 +29,6 @@ export const meta: WsComponentMeta = { description: "Use a link to send your users to another page, section, or resource. Configure links in the Settings panel.", icon: LinkIcon, - invalidAncestors: ["Link", "Button"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Link"] }, diff --git a/packages/sdk-components-react/src/list-item.ws.ts b/packages/sdk-components-react/src/list-item.ws.ts index a46037ee9773..683c32a3b276 100644 --- a/packages/sdk-components-react/src/list-item.ws.ts +++ b/packages/sdk-components-react/src/list-item.ws.ts @@ -16,7 +16,6 @@ const presetStyle = { export const meta: WsComponentMeta = { category: "general", type: "container", - requiredAncestors: ["List"], constraints: { relation: "parent", component: { $eq: "List" }, diff --git a/packages/sdk-components-react/src/option.ws.ts b/packages/sdk-components-react/src/option.ws.ts index dc2e2688c062..c88dc2de3fd9 100644 --- a/packages/sdk-components-react/src/option.ws.ts +++ b/packages/sdk-components-react/src/option.ws.ts @@ -26,8 +26,6 @@ const presetStyle = { export const meta: WsComponentMeta = { category: "hidden", - // @todo: requiredAncestors should be ["Select", "Optgroup", "Datalist"] but that gives unreadable error when adding Select onto Canvas - requiredAncestors: ["Select"], constraints: { relation: "parent", component: { $eq: "Select" }, diff --git a/packages/sdk-components-react/src/paragraph.ws.ts b/packages/sdk-components-react/src/paragraph.ws.ts index eb2e938ccfd5..80e97d543aaf 100644 --- a/packages/sdk-components-react/src/paragraph.ws.ts +++ b/packages/sdk-components-react/src/paragraph.ws.ts @@ -18,7 +18,6 @@ export const meta: WsComponentMeta = { type: "container", description: "A container for multi-line text.", icon: TextAlignLeftIcon, - invalidAncestors: ["Paragraph"], constraints: { relation: "ancestor", component: { $neq: "Paragraph" }, diff --git a/packages/sdk-components-react/src/radio-button.ws.ts b/packages/sdk-components-react/src/radio-button.ws.ts index 890b4a0e0287..673dfd45cd21 100644 --- a/packages/sdk-components-react/src/radio-button.ws.ts +++ b/packages/sdk-components-react/src/radio-button.ws.ts @@ -21,7 +21,6 @@ const presetStyle = { export const meta: WsComponentMeta = { category: "forms", - invalidAncestors: ["Button", "Link"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Link"] }, diff --git a/packages/sdk-components-react/src/select.ws.ts b/packages/sdk-components-react/src/select.ws.ts index a7d488d462f1..88e286f2cce2 100644 --- a/packages/sdk-components-react/src/select.ws.ts +++ b/packages/sdk-components-react/src/select.ws.ts @@ -21,7 +21,6 @@ const presetStyle = { export const meta: WsComponentMeta = { category: "forms", - invalidAncestors: ["Button", "Link"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Link"] }, diff --git a/packages/sdk-components-react/src/textarea.ws.ts b/packages/sdk-components-react/src/textarea.ws.ts index 79ab1f7e7652..1ec5caf9b70f 100644 --- a/packages/sdk-components-react/src/textarea.ws.ts +++ b/packages/sdk-components-react/src/textarea.ws.ts @@ -30,7 +30,6 @@ export const meta: WsComponentMeta = { icon: FormTextAreaIcon, presetStyle, order: 4, - invalidAncestors: ["Button", "Link"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Link"] }, diff --git a/packages/sdk-components-react/src/vimeo-play-button.ws.ts b/packages/sdk-components-react/src/vimeo-play-button.ws.ts index 74efd960d62b..36a278fe7e19 100644 --- a/packages/sdk-components-react/src/vimeo-play-button.ws.ts +++ b/packages/sdk-components-react/src/vimeo-play-button.ws.ts @@ -16,8 +16,6 @@ const presetStyle = { export const meta: WsComponentMeta = { category: "hidden", type: "container", - invalidAncestors: ["Button"], - requiredAncestors: ["Vimeo"], constraints: [ { relation: "ancestor", diff --git a/packages/sdk-components-react/src/vimeo-preview-image.ws.ts b/packages/sdk-components-react/src/vimeo-preview-image.ws.ts index 5329bf9d3a56..966a828315d1 100644 --- a/packages/sdk-components-react/src/vimeo-preview-image.ws.ts +++ b/packages/sdk-components-react/src/vimeo-preview-image.ws.ts @@ -13,7 +13,6 @@ export const meta: WsComponentMeta = { ...imageMeta, category: "hidden", label: "Preview Image", - requiredAncestors: ["Vimeo"], constraints: { relation: "ancestor", component: { $eq: "Vimeo" }, diff --git a/packages/sdk-components-react/src/vimeo-spinner.ws.ts b/packages/sdk-components-react/src/vimeo-spinner.ws.ts index 05890884df9d..a91c8fd7d7e8 100644 --- a/packages/sdk-components-react/src/vimeo-spinner.ws.ts +++ b/packages/sdk-components-react/src/vimeo-spinner.ws.ts @@ -14,7 +14,6 @@ const presetStyle = { export const meta: WsComponentMeta = { type: "container", - requiredAncestors: ["Vimeo"], constraints: { relation: "ancestor", component: { $eq: "Vimeo" }, diff --git a/packages/sdk-components-react/src/vimeo.ws.ts b/packages/sdk-components-react/src/vimeo.ws.ts index d938a59b17b9..a8b15bc4c2bd 100644 --- a/packages/sdk-components-react/src/vimeo.ws.ts +++ b/packages/sdk-components-react/src/vimeo.ws.ts @@ -23,7 +23,6 @@ export const meta: WsComponentMeta = { icon: VimeoIcon, states: defaultStates, presetStyle, - invalidAncestors: ["Button", "Heading", "Link"], constraints: { relation: "ancestor", component: { $nin: ["Button", "Link", "Heading"] },