@webstudio-is/react-sdk 0.208.0 → 0.210.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -400,73 +400,6 @@ var generateDataFromEmbedTemplate = (treeTemplate, metas, generateId = nanoid) =
400
400
  resources: []
401
401
  };
402
402
  };
403
- var namespaceEmbedTemplateComponents = (template, namespace, components) => {
404
- return template.map((item) => {
405
- if (item.type === "text") {
406
- return item;
407
- }
408
- if (item.type === "expression") {
409
- return item;
410
- }
411
- if (item.type === "instance") {
412
- const prefix = components.has(item.component) ? `${namespace}:` : "";
413
- return {
414
- ...item,
415
- component: `${prefix}${item.component}`,
416
- children: namespaceEmbedTemplateComponents(
417
- item.children,
418
- namespace,
419
- components
420
- )
421
- };
422
- }
423
- item;
424
- throw Error("Impossible case");
425
- });
426
- };
427
- var namespaceMatcher = (namespace, matcher) => {
428
- const newMatcher = structuredClone(matcher);
429
- if (newMatcher.component?.$eq) {
430
- newMatcher.component.$eq = `${namespace}:${newMatcher.component.$eq}`;
431
- }
432
- if (newMatcher.component?.$neq) {
433
- newMatcher.component.$neq = `${namespace}:${newMatcher.component.$neq}`;
434
- }
435
- if (newMatcher.component?.$in) {
436
- newMatcher.component.$in = newMatcher.component.$in.map(
437
- (component) => `${namespace}:${component}`
438
- );
439
- }
440
- if (newMatcher.component?.$nin) {
441
- newMatcher.component.$nin = newMatcher.component.$nin.map(
442
- (component) => `${namespace}:${component}`
443
- );
444
- }
445
- return newMatcher;
446
- };
447
- var namespaceMeta = (meta, namespace, components) => {
448
- const newMeta = { ...meta };
449
- if (newMeta.constraints) {
450
- if (Array.isArray(newMeta.constraints)) {
451
- newMeta.constraints = newMeta.constraints.map(
452
- (matcher) => namespaceMatcher(namespace, matcher)
453
- );
454
- } else {
455
- newMeta.constraints = namespaceMatcher(namespace, newMeta.constraints);
456
- }
457
- }
458
- if (newMeta.indexWithinAncestor) {
459
- newMeta.indexWithinAncestor = components.has(newMeta.indexWithinAncestor) ? `${namespace}:${newMeta.indexWithinAncestor}` : newMeta.indexWithinAncestor;
460
- }
461
- if (newMeta.template) {
462
- newMeta.template = namespaceEmbedTemplateComponents(
463
- newMeta.template,
464
- namespace,
465
- components
466
- );
467
- }
468
- return newMeta;
469
- };
470
403
 
471
404
  // src/component-generator.ts
472
405
  import {
@@ -874,7 +807,6 @@ export {
874
807
  idAttribute,
875
808
  indexAttribute,
876
809
  isAttributeNameSafe,
877
- namespaceMeta,
878
810
  normalizeProps,
879
811
  selectorIdAttribute,
880
812
  showAttribute,
@@ -1,55 +1,2 @@
1
- import type { Instance, WebstudioFragment, WsEmbedTemplate, EmbedTemplateInstance, WsComponentMeta } from "@webstudio-is/sdk";
1
+ import type { Instance, WebstudioFragment, WsEmbedTemplate, WsComponentMeta } from "@webstudio-is/sdk";
2
2
  export declare const generateDataFromEmbedTemplate: (treeTemplate: WsEmbedTemplate, metas: Map<Instance["component"], WsComponentMeta>, generateId?: () => string) => WebstudioFragment;
3
- export declare const namespaceMeta: (meta: WsComponentMeta, namespace: string, components: Set<EmbedTemplateInstance["component"]>) => {
4
- type: "control" | "embed" | "container" | "rich-text-child";
5
- description?: string | undefined;
6
- category?: "data" | "xml" | "hidden" | "media" | "general" | "typography" | "forms" | "localization" | "radix" | "internal" | undefined;
7
- placeholder?: string | undefined;
8
- label?: string | undefined;
9
- order?: number | undefined;
10
- template?: ({
11
- value: string;
12
- type: "text";
13
- placeholder?: boolean | undefined;
14
- } | {
15
- value: string;
16
- type: "expression";
17
- } | EmbedTemplateInstance)[] | undefined;
18
- states?: {
19
- label: string;
20
- selector: string;
21
- category?: "states" | "component-states" | undefined;
22
- }[] | undefined;
23
- constraints?: {
24
- relation: "ancestor" | "parent" | "self" | "child" | "descendant";
25
- component?: {
26
- $eq?: string | undefined;
27
- $neq?: string | undefined;
28
- $in?: string[] | undefined;
29
- $nin?: string[] | undefined;
30
- } | undefined;
31
- tag?: {
32
- $eq?: string | undefined;
33
- $neq?: string | undefined;
34
- $in?: string[] | undefined;
35
- $nin?: string[] | undefined;
36
- } | undefined;
37
- } | {
38
- relation: "ancestor" | "parent" | "self" | "child" | "descendant";
39
- component?: {
40
- $eq?: string | undefined;
41
- $neq?: string | undefined;
42
- $in?: string[] | undefined;
43
- $nin?: string[] | undefined;
44
- } | undefined;
45
- tag?: {
46
- $eq?: string | undefined;
47
- $neq?: string | undefined;
48
- $in?: string[] | undefined;
49
- $nin?: string[] | undefined;
50
- } | undefined;
51
- }[] | undefined;
52
- indexWithinAncestor?: string | undefined;
53
- icon: string;
54
- presetStyle?: import("@webstudio-is/sdk").PresetStyle;
55
- };