@webstudio-is/react-sdk 0.209.0 → 0.212.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
@@ -153,7 +153,6 @@ var idAttribute = "data-ws-id";
153
153
  var selectorIdAttribute = "data-ws-selector";
154
154
  var componentAttribute = "data-ws-component";
155
155
  var showAttribute = "data-ws-show";
156
- var indexAttribute = "data-ws-index";
157
156
  var collapsedAttribute = "data-ws-collapsed";
158
157
  var textContentAttribute = "data-ws-text-content";
159
158
  var animationCanPlayOnCanvasAttribute = "data-ws-animation-can-play-on-canvas";
@@ -400,42 +399,6 @@ var generateDataFromEmbedTemplate = (treeTemplate, metas, generateId = nanoid) =
400
399
  resources: []
401
400
  };
402
401
  };
403
- var namespaceMatcher = (namespace, matcher) => {
404
- const newMatcher = structuredClone(matcher);
405
- if (newMatcher.component?.$eq) {
406
- newMatcher.component.$eq = `${namespace}:${newMatcher.component.$eq}`;
407
- }
408
- if (newMatcher.component?.$neq) {
409
- newMatcher.component.$neq = `${namespace}:${newMatcher.component.$neq}`;
410
- }
411
- if (newMatcher.component?.$in) {
412
- newMatcher.component.$in = newMatcher.component.$in.map(
413
- (component) => `${namespace}:${component}`
414
- );
415
- }
416
- if (newMatcher.component?.$nin) {
417
- newMatcher.component.$nin = newMatcher.component.$nin.map(
418
- (component) => `${namespace}:${component}`
419
- );
420
- }
421
- return newMatcher;
422
- };
423
- var namespaceMeta = (meta, namespace, components) => {
424
- const newMeta = { ...meta };
425
- if (newMeta.constraints) {
426
- if (Array.isArray(newMeta.constraints)) {
427
- newMeta.constraints = newMeta.constraints.map(
428
- (matcher) => namespaceMatcher(namespace, matcher)
429
- );
430
- } else {
431
- newMeta.constraints = namespaceMatcher(namespace, newMeta.constraints);
432
- }
433
- }
434
- if (newMeta.indexWithinAncestor) {
435
- newMeta.indexWithinAncestor = components.has(newMeta.indexWithinAncestor) ? `${namespace}:${newMeta.indexWithinAncestor}` : newMeta.indexWithinAncestor;
436
- }
437
- return newMeta;
438
- };
439
402
 
440
403
  // src/component-generator.ts
441
404
  import {
@@ -447,8 +410,510 @@ import {
447
410
  blockTemplateComponent,
448
411
  collectionComponent,
449
412
  descendantComponent,
450
- getIndexesWithinAncestors
413
+ getIndexesWithinAncestors,
414
+ elementComponent
451
415
  } from "@webstudio-is/sdk";
416
+ import { indexProperty, tagProperty } from "@webstudio-is/sdk/runtime";
417
+
418
+ // src/standard-attributes.ts
419
+ var standardAttributesToReactProps = {
420
+ // HTML
421
+ accept: "accept",
422
+ acceptcharset: "acceptCharset",
423
+ "accept-charset": "acceptCharset",
424
+ accesskey: "accessKey",
425
+ action: "action",
426
+ allowfullscreen: "allowFullScreen",
427
+ alt: "alt",
428
+ as: "as",
429
+ async: "async",
430
+ autocapitalize: "autoCapitalize",
431
+ autocomplete: "autoComplete",
432
+ autocorrect: "autoCorrect",
433
+ autofocus: "autoFocus",
434
+ autoplay: "autoPlay",
435
+ autosave: "autoSave",
436
+ capture: "capture",
437
+ cellpadding: "cellPadding",
438
+ cellspacing: "cellSpacing",
439
+ challenge: "challenge",
440
+ charset: "charSet",
441
+ checked: "checked",
442
+ children: "children",
443
+ cite: "cite",
444
+ class: "className",
445
+ classid: "classID",
446
+ classname: "className",
447
+ cols: "cols",
448
+ colspan: "colSpan",
449
+ content: "content",
450
+ contenteditable: "contentEditable",
451
+ contextmenu: "contextMenu",
452
+ controls: "controls",
453
+ controlslist: "controlsList",
454
+ coords: "coords",
455
+ crossorigin: "crossOrigin",
456
+ dangerouslysetinnerhtml: "dangerouslySetInnerHTML",
457
+ data: "data",
458
+ datetime: "dateTime",
459
+ default: "default",
460
+ defaultchecked: "defaultChecked",
461
+ defaultvalue: "defaultValue",
462
+ defer: "defer",
463
+ dir: "dir",
464
+ disabled: "disabled",
465
+ disablepictureinpicture: "disablePictureInPicture",
466
+ disableremoteplayback: "disableRemotePlayback",
467
+ download: "download",
468
+ draggable: "draggable",
469
+ enctype: "encType",
470
+ enterkeyhint: "enterKeyHint",
471
+ fetchpriority: "fetchPriority",
472
+ for: "htmlFor",
473
+ form: "form",
474
+ formmethod: "formMethod",
475
+ formaction: "formAction",
476
+ formenctype: "formEncType",
477
+ formnovalidate: "formNoValidate",
478
+ formtarget: "formTarget",
479
+ frameborder: "frameBorder",
480
+ headers: "headers",
481
+ height: "height",
482
+ hidden: "hidden",
483
+ high: "high",
484
+ href: "href",
485
+ hreflang: "hrefLang",
486
+ htmlfor: "htmlFor",
487
+ httpequiv: "httpEquiv",
488
+ "http-equiv": "httpEquiv",
489
+ icon: "icon",
490
+ id: "id",
491
+ imagesizes: "imageSizes",
492
+ imagesrcset: "imageSrcSet",
493
+ inert: "inert",
494
+ innerhtml: "innerHTML",
495
+ inputmode: "inputMode",
496
+ integrity: "integrity",
497
+ is: "is",
498
+ itemid: "itemID",
499
+ itemprop: "itemProp",
500
+ itemref: "itemRef",
501
+ itemscope: "itemScope",
502
+ itemtype: "itemType",
503
+ keyparams: "keyParams",
504
+ keytype: "keyType",
505
+ kind: "kind",
506
+ label: "label",
507
+ lang: "lang",
508
+ list: "list",
509
+ loop: "loop",
510
+ low: "low",
511
+ manifest: "manifest",
512
+ marginwidth: "marginWidth",
513
+ marginheight: "marginHeight",
514
+ max: "max",
515
+ maxlength: "maxLength",
516
+ media: "media",
517
+ mediagroup: "mediaGroup",
518
+ method: "method",
519
+ min: "min",
520
+ minlength: "minLength",
521
+ multiple: "multiple",
522
+ muted: "muted",
523
+ name: "name",
524
+ nomodule: "noModule",
525
+ nonce: "nonce",
526
+ novalidate: "noValidate",
527
+ open: "open",
528
+ optimum: "optimum",
529
+ pattern: "pattern",
530
+ placeholder: "placeholder",
531
+ playsinline: "playsInline",
532
+ poster: "poster",
533
+ preload: "preload",
534
+ profile: "profile",
535
+ radiogroup: "radioGroup",
536
+ readonly: "readOnly",
537
+ referrerpolicy: "referrerPolicy",
538
+ rel: "rel",
539
+ required: "required",
540
+ reversed: "reversed",
541
+ role: "role",
542
+ rows: "rows",
543
+ rowspan: "rowSpan",
544
+ sandbox: "sandbox",
545
+ scope: "scope",
546
+ scoped: "scoped",
547
+ scrolling: "scrolling",
548
+ seamless: "seamless",
549
+ selected: "selected",
550
+ shape: "shape",
551
+ size: "size",
552
+ sizes: "sizes",
553
+ span: "span",
554
+ spellcheck: "spellCheck",
555
+ src: "src",
556
+ srcdoc: "srcDoc",
557
+ srclang: "srcLang",
558
+ srcset: "srcSet",
559
+ start: "start",
560
+ step: "step",
561
+ style: "style",
562
+ summary: "summary",
563
+ tabindex: "tabIndex",
564
+ target: "target",
565
+ title: "title",
566
+ type: "type",
567
+ usemap: "useMap",
568
+ value: "value",
569
+ width: "width",
570
+ wmode: "wmode",
571
+ wrap: "wrap",
572
+ // SVG
573
+ about: "about",
574
+ accentheight: "accentHeight",
575
+ "accent-height": "accentHeight",
576
+ accumulate: "accumulate",
577
+ additive: "additive",
578
+ alignmentbaseline: "alignmentBaseline",
579
+ "alignment-baseline": "alignmentBaseline",
580
+ allowreorder: "allowReorder",
581
+ alphabetic: "alphabetic",
582
+ amplitude: "amplitude",
583
+ arabicform: "arabicForm",
584
+ "arabic-form": "arabicForm",
585
+ ascent: "ascent",
586
+ attributename: "attributeName",
587
+ attributetype: "attributeType",
588
+ autoreverse: "autoReverse",
589
+ azimuth: "azimuth",
590
+ basefrequency: "baseFrequency",
591
+ baselineshift: "baselineShift",
592
+ "baseline-shift": "baselineShift",
593
+ baseprofile: "baseProfile",
594
+ bbox: "bbox",
595
+ begin: "begin",
596
+ bias: "bias",
597
+ by: "by",
598
+ calcmode: "calcMode",
599
+ capheight: "capHeight",
600
+ "cap-height": "capHeight",
601
+ clip: "clip",
602
+ clippath: "clipPath",
603
+ "clip-path": "clipPath",
604
+ clippathunits: "clipPathUnits",
605
+ cliprule: "clipRule",
606
+ "clip-rule": "clipRule",
607
+ color: "color",
608
+ colorinterpolation: "colorInterpolation",
609
+ "color-interpolation": "colorInterpolation",
610
+ colorinterpolationfilters: "colorInterpolationFilters",
611
+ "color-interpolation-filters": "colorInterpolationFilters",
612
+ colorprofile: "colorProfile",
613
+ "color-profile": "colorProfile",
614
+ colorrendering: "colorRendering",
615
+ "color-rendering": "colorRendering",
616
+ contentscripttype: "contentScriptType",
617
+ contentstyletype: "contentStyleType",
618
+ cursor: "cursor",
619
+ cx: "cx",
620
+ cy: "cy",
621
+ d: "d",
622
+ datatype: "datatype",
623
+ decelerate: "decelerate",
624
+ descent: "descent",
625
+ diffuseconstant: "diffuseConstant",
626
+ direction: "direction",
627
+ display: "display",
628
+ divisor: "divisor",
629
+ dominantbaseline: "dominantBaseline",
630
+ "dominant-baseline": "dominantBaseline",
631
+ dur: "dur",
632
+ dx: "dx",
633
+ dy: "dy",
634
+ edgemode: "edgeMode",
635
+ elevation: "elevation",
636
+ enablebackground: "enableBackground",
637
+ "enable-background": "enableBackground",
638
+ end: "end",
639
+ exponent: "exponent",
640
+ externalresourcesrequired: "externalResourcesRequired",
641
+ fill: "fill",
642
+ fillopacity: "fillOpacity",
643
+ "fill-opacity": "fillOpacity",
644
+ fillrule: "fillRule",
645
+ "fill-rule": "fillRule",
646
+ filter: "filter",
647
+ filterres: "filterRes",
648
+ filterunits: "filterUnits",
649
+ floodopacity: "floodOpacity",
650
+ "flood-opacity": "floodOpacity",
651
+ floodcolor: "floodColor",
652
+ "flood-color": "floodColor",
653
+ focusable: "focusable",
654
+ fontfamily: "fontFamily",
655
+ "font-family": "fontFamily",
656
+ fontsize: "fontSize",
657
+ "font-size": "fontSize",
658
+ fontsizeadjust: "fontSizeAdjust",
659
+ "font-size-adjust": "fontSizeAdjust",
660
+ fontstretch: "fontStretch",
661
+ "font-stretch": "fontStretch",
662
+ fontstyle: "fontStyle",
663
+ "font-style": "fontStyle",
664
+ fontvariant: "fontVariant",
665
+ "font-variant": "fontVariant",
666
+ fontweight: "fontWeight",
667
+ "font-weight": "fontWeight",
668
+ format: "format",
669
+ from: "from",
670
+ fx: "fx",
671
+ fy: "fy",
672
+ g1: "g1",
673
+ g2: "g2",
674
+ glyphname: "glyphName",
675
+ "glyph-name": "glyphName",
676
+ glyphorientationhorizontal: "glyphOrientationHorizontal",
677
+ "glyph-orientation-horizontal": "glyphOrientationHorizontal",
678
+ glyphorientationvertical: "glyphOrientationVertical",
679
+ "glyph-orientation-vertical": "glyphOrientationVertical",
680
+ glyphref: "glyphRef",
681
+ gradienttransform: "gradientTransform",
682
+ gradientunits: "gradientUnits",
683
+ hanging: "hanging",
684
+ horizadvx: "horizAdvX",
685
+ "horiz-adv-x": "horizAdvX",
686
+ horizoriginx: "horizOriginX",
687
+ "horiz-origin-x": "horizOriginX",
688
+ ideographic: "ideographic",
689
+ imagerendering: "imageRendering",
690
+ "image-rendering": "imageRendering",
691
+ in2: "in2",
692
+ in: "in",
693
+ inlist: "inlist",
694
+ intercept: "intercept",
695
+ k1: "k1",
696
+ k2: "k2",
697
+ k3: "k3",
698
+ k4: "k4",
699
+ k: "k",
700
+ kernelmatrix: "kernelMatrix",
701
+ kernelunitlength: "kernelUnitLength",
702
+ kerning: "kerning",
703
+ keypoints: "keyPoints",
704
+ keysplines: "keySplines",
705
+ keytimes: "keyTimes",
706
+ lengthadjust: "lengthAdjust",
707
+ letterspacing: "letterSpacing",
708
+ "letter-spacing": "letterSpacing",
709
+ lightingcolor: "lightingColor",
710
+ "lighting-color": "lightingColor",
711
+ limitingconeangle: "limitingConeAngle",
712
+ local: "local",
713
+ markerend: "markerEnd",
714
+ "marker-end": "markerEnd",
715
+ markerheight: "markerHeight",
716
+ markermid: "markerMid",
717
+ "marker-mid": "markerMid",
718
+ markerstart: "markerStart",
719
+ "marker-start": "markerStart",
720
+ markerunits: "markerUnits",
721
+ markerwidth: "markerWidth",
722
+ mask: "mask",
723
+ maskcontentunits: "maskContentUnits",
724
+ maskunits: "maskUnits",
725
+ mathematical: "mathematical",
726
+ mode: "mode",
727
+ numoctaves: "numOctaves",
728
+ offset: "offset",
729
+ opacity: "opacity",
730
+ operator: "operator",
731
+ order: "order",
732
+ orient: "orient",
733
+ orientation: "orientation",
734
+ origin: "origin",
735
+ overflow: "overflow",
736
+ overlineposition: "overlinePosition",
737
+ "overline-position": "overlinePosition",
738
+ overlinethickness: "overlineThickness",
739
+ "overline-thickness": "overlineThickness",
740
+ paintorder: "paintOrder",
741
+ "paint-order": "paintOrder",
742
+ panose1: "panose1",
743
+ "panose-1": "panose1",
744
+ pathlength: "pathLength",
745
+ patterncontentunits: "patternContentUnits",
746
+ patterntransform: "patternTransform",
747
+ patternunits: "patternUnits",
748
+ pointerevents: "pointerEvents",
749
+ "pointer-events": "pointerEvents",
750
+ points: "points",
751
+ pointsatx: "pointsAtX",
752
+ pointsaty: "pointsAtY",
753
+ pointsatz: "pointsAtZ",
754
+ popover: "popover",
755
+ popovertarget: "popoverTarget",
756
+ popovertargetaction: "popoverTargetAction",
757
+ prefix: "prefix",
758
+ preservealpha: "preserveAlpha",
759
+ preserveaspectratio: "preserveAspectRatio",
760
+ primitiveunits: "primitiveUnits",
761
+ property: "property",
762
+ r: "r",
763
+ radius: "radius",
764
+ refx: "refX",
765
+ refy: "refY",
766
+ renderingintent: "renderingIntent",
767
+ "rendering-intent": "renderingIntent",
768
+ repeatcount: "repeatCount",
769
+ repeatdur: "repeatDur",
770
+ requiredextensions: "requiredExtensions",
771
+ requiredfeatures: "requiredFeatures",
772
+ resource: "resource",
773
+ restart: "restart",
774
+ result: "result",
775
+ results: "results",
776
+ rotate: "rotate",
777
+ rx: "rx",
778
+ ry: "ry",
779
+ scale: "scale",
780
+ security: "security",
781
+ seed: "seed",
782
+ shaperendering: "shapeRendering",
783
+ "shape-rendering": "shapeRendering",
784
+ slope: "slope",
785
+ spacing: "spacing",
786
+ specularconstant: "specularConstant",
787
+ specularexponent: "specularExponent",
788
+ speed: "speed",
789
+ spreadmethod: "spreadMethod",
790
+ startoffset: "startOffset",
791
+ stddeviation: "stdDeviation",
792
+ stemh: "stemh",
793
+ stemv: "stemv",
794
+ stitchtiles: "stitchTiles",
795
+ stopcolor: "stopColor",
796
+ "stop-color": "stopColor",
797
+ stopopacity: "stopOpacity",
798
+ "stop-opacity": "stopOpacity",
799
+ strikethroughposition: "strikethroughPosition",
800
+ "strikethrough-position": "strikethroughPosition",
801
+ strikethroughthickness: "strikethroughThickness",
802
+ "strikethrough-thickness": "strikethroughThickness",
803
+ string: "string",
804
+ stroke: "stroke",
805
+ strokedasharray: "strokeDasharray",
806
+ "stroke-dasharray": "strokeDasharray",
807
+ strokedashoffset: "strokeDashoffset",
808
+ "stroke-dashoffset": "strokeDashoffset",
809
+ strokelinecap: "strokeLinecap",
810
+ "stroke-linecap": "strokeLinecap",
811
+ strokelinejoin: "strokeLinejoin",
812
+ "stroke-linejoin": "strokeLinejoin",
813
+ strokemiterlimit: "strokeMiterlimit",
814
+ "stroke-miterlimit": "strokeMiterlimit",
815
+ strokewidth: "strokeWidth",
816
+ "stroke-width": "strokeWidth",
817
+ strokeopacity: "strokeOpacity",
818
+ "stroke-opacity": "strokeOpacity",
819
+ suppresscontenteditablewarning: "suppressContentEditableWarning",
820
+ suppresshydrationwarning: "suppressHydrationWarning",
821
+ surfacescale: "surfaceScale",
822
+ systemlanguage: "systemLanguage",
823
+ tablevalues: "tableValues",
824
+ targetx: "targetX",
825
+ targety: "targetY",
826
+ textanchor: "textAnchor",
827
+ "text-anchor": "textAnchor",
828
+ textdecoration: "textDecoration",
829
+ "text-decoration": "textDecoration",
830
+ textlength: "textLength",
831
+ textrendering: "textRendering",
832
+ "text-rendering": "textRendering",
833
+ to: "to",
834
+ transform: "transform",
835
+ transformorigin: "transformOrigin",
836
+ "transform-origin": "transformOrigin",
837
+ typeof: "typeof",
838
+ u1: "u1",
839
+ u2: "u2",
840
+ underlineposition: "underlinePosition",
841
+ "underline-position": "underlinePosition",
842
+ underlinethickness: "underlineThickness",
843
+ "underline-thickness": "underlineThickness",
844
+ unicode: "unicode",
845
+ unicodebidi: "unicodeBidi",
846
+ "unicode-bidi": "unicodeBidi",
847
+ unicoderange: "unicodeRange",
848
+ "unicode-range": "unicodeRange",
849
+ unitsperem: "unitsPerEm",
850
+ "units-per-em": "unitsPerEm",
851
+ unselectable: "unselectable",
852
+ valphabetic: "vAlphabetic",
853
+ "v-alphabetic": "vAlphabetic",
854
+ values: "values",
855
+ vectoreffect: "vectorEffect",
856
+ "vector-effect": "vectorEffect",
857
+ version: "version",
858
+ vertadvy: "vertAdvY",
859
+ "vert-adv-y": "vertAdvY",
860
+ vertoriginx: "vertOriginX",
861
+ "vert-origin-x": "vertOriginX",
862
+ vertoriginy: "vertOriginY",
863
+ "vert-origin-y": "vertOriginY",
864
+ vhanging: "vHanging",
865
+ "v-hanging": "vHanging",
866
+ videographic: "vIdeographic",
867
+ "v-ideographic": "vIdeographic",
868
+ viewbox: "viewBox",
869
+ viewtarget: "viewTarget",
870
+ visibility: "visibility",
871
+ vmathematical: "vMathematical",
872
+ "v-mathematical": "vMathematical",
873
+ vocab: "vocab",
874
+ widths: "widths",
875
+ wordspacing: "wordSpacing",
876
+ "word-spacing": "wordSpacing",
877
+ writingmode: "writingMode",
878
+ "writing-mode": "writingMode",
879
+ x1: "x1",
880
+ x2: "x2",
881
+ x: "x",
882
+ xchannelselector: "xChannelSelector",
883
+ xheight: "xHeight",
884
+ "x-height": "xHeight",
885
+ xlinkactuate: "xlinkActuate",
886
+ "xlink:actuate": "xlinkActuate",
887
+ xlinkarcrole: "xlinkArcrole",
888
+ "xlink:arcrole": "xlinkArcrole",
889
+ xlinkhref: "xlinkHref",
890
+ "xlink:href": "xlinkHref",
891
+ xlinkrole: "xlinkRole",
892
+ "xlink:role": "xlinkRole",
893
+ xlinkshow: "xlinkShow",
894
+ "xlink:show": "xlinkShow",
895
+ xlinktitle: "xlinkTitle",
896
+ "xlink:title": "xlinkTitle",
897
+ xlinktype: "xlinkType",
898
+ "xlink:type": "xlinkType",
899
+ xmlbase: "xmlBase",
900
+ "xml:base": "xmlBase",
901
+ xmllang: "xmlLang",
902
+ "xml:lang": "xmlLang",
903
+ xmlns: "xmlns",
904
+ "xml:space": "xmlSpace",
905
+ xmlnsxlink: "xmlnsXlink",
906
+ "xmlns:xlink": "xmlnsXlink",
907
+ xmlspace: "xmlSpace",
908
+ y1: "y1",
909
+ y2: "y2",
910
+ y: "y",
911
+ ychannelselector: "yChannelSelector",
912
+ z: "z",
913
+ zoomandpan: "zoomAndPan"
914
+ };
915
+
916
+ // src/component-generator.ts
452
917
  var generateAction = ({
453
918
  scope,
454
919
  prop,
@@ -556,7 +1021,11 @@ var generateJsxElement = ({
556
1021
  const index = indexesWithinAncestors.get(instance.id);
557
1022
  if (index !== void 0) {
558
1023
  generatedProps += `
559
- ${indexAttribute}="${index}"`;
1024
+ ${indexProperty}="${index}"`;
1025
+ }
1026
+ if (instance.tag !== void 0 && instance.component !== elementComponent) {
1027
+ generatedProps += `
1028
+ ${tagProperty}=${JSON.stringify(instance.tag)}`;
560
1029
  }
561
1030
  let conditionValue;
562
1031
  let collectionDataValue;
@@ -575,6 +1044,10 @@ ${indexAttribute}="${index}"`;
575
1044
  if (isAttributeNameSafe(prop.name) === false) {
576
1045
  continue;
577
1046
  }
1047
+ let name = prop.name;
1048
+ if (instance.component === elementComponent) {
1049
+ name = standardAttributesToReactProps[prop.name] ?? prop.name;
1050
+ }
578
1051
  if (prop.name === showAttribute) {
579
1052
  if (propValue === "true") {
580
1053
  continue;
@@ -594,13 +1067,13 @@ ${indexAttribute}="${index}"`;
594
1067
  }
595
1068
  continue;
596
1069
  }
597
- if (prop.name === "className" && propValue !== void 0) {
1070
+ if (name === "className" && propValue !== void 0) {
598
1071
  classNameValue = propValue;
599
1072
  continue;
600
1073
  }
601
1074
  if (propValue !== void 0) {
602
1075
  generatedProps += `
603
- ${prop.name}={${propValue}}`;
1076
+ ${name}={${propValue}}`;
604
1077
  }
605
1078
  }
606
1079
  const classMapArray = classesMap?.get(instance.id);
@@ -634,6 +1107,18 @@ ${prop.name}={${propValue}}`;
634
1107
  `;
635
1108
  } else if (instance.component === blockComponent) {
636
1109
  generatedElement += children;
1110
+ } else if (instance.component === elementComponent) {
1111
+ const tagName = instance.tag ?? "div";
1112
+ if (instance.children.length === 0) {
1113
+ generatedElement += `<${tagName}${generatedProps} />
1114
+ `;
1115
+ } else {
1116
+ generatedElement += `<${tagName}${generatedProps}>
1117
+ `;
1118
+ generatedElement += children;
1119
+ generatedElement += `</${tagName}>
1120
+ `;
1121
+ }
637
1122
  } else {
638
1123
  const [_namespace, shortName] = parseComponentName(instance.component);
639
1124
  const componentVariable = scope.getName(instance.component, shortName);
@@ -841,9 +1326,7 @@ export {
841
1326
  generateRemixRoute,
842
1327
  generateWebstudioComponent,
843
1328
  idAttribute,
844
- indexAttribute,
845
1329
  isAttributeNameSafe,
846
- namespaceMeta,
847
1330
  normalizeProps,
848
1331
  selectorIdAttribute,
849
1332
  showAttribute,
package/lib/runtime.js CHANGED
@@ -198,16 +198,12 @@ var PageSettingsCanonicalLink = (props) => {
198
198
 
199
199
  // src/runtime.ts
200
200
  var xmlNodeTagSuffix = "-ws-xml-node-fb77f896-8e96-40b9-b8f8-90a4e70d724a";
201
- var getIndexWithinAncestorFromComponentProps = (props) => {
202
- return props["data-ws-index"];
203
- };
204
201
  export {
205
202
  PageSettingsCanonicalLink,
206
203
  PageSettingsMeta,
207
204
  PageSettingsTitle,
208
205
  ReactSdkContext,
209
206
  getClosestInstance,
210
- getIndexWithinAncestorFromComponentProps,
211
207
  useResource,
212
208
  useVariableState,
213
209
  xmlNodeTagSuffix
@@ -1,49 +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?: "xml" | "hidden" | "data" | "media" | "general" | "typography" | "forms" | "localization" | "radix" | "internal" | undefined;
7
- placeholder?: string | undefined;
8
- label?: string | undefined;
9
- order?: number | undefined;
10
- states?: {
11
- label: string;
12
- selector: string;
13
- category?: "states" | "component-states" | undefined;
14
- }[] | undefined;
15
- constraints?: {
16
- relation: "ancestor" | "parent" | "self" | "child" | "descendant";
17
- text?: false | undefined;
18
- component?: {
19
- $eq?: string | undefined;
20
- $neq?: string | undefined;
21
- $in?: string[] | undefined;
22
- $nin?: string[] | undefined;
23
- } | undefined;
24
- tag?: {
25
- $eq?: string | undefined;
26
- $neq?: string | undefined;
27
- $in?: string[] | undefined;
28
- $nin?: string[] | undefined;
29
- } | undefined;
30
- } | {
31
- relation: "ancestor" | "parent" | "self" | "child" | "descendant";
32
- text?: false | undefined;
33
- component?: {
34
- $eq?: string | undefined;
35
- $neq?: string | undefined;
36
- $in?: string[] | undefined;
37
- $nin?: string[] | undefined;
38
- } | undefined;
39
- tag?: {
40
- $eq?: string | undefined;
41
- $neq?: string | undefined;
42
- $in?: string[] | undefined;
43
- $nin?: string[] | undefined;
44
- } | undefined;
45
- }[] | undefined;
46
- indexWithinAncestor?: string | undefined;
47
- icon: string;
48
- presetStyle?: import("@webstudio-is/sdk").PresetStyle;
49
- };
@@ -702,6 +702,14 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
702
702
  timing: {
703
703
  fill?: "none" | "forwards" | "backwards" | "both" | undefined;
704
704
  easing?: string | undefined;
705
+ duration?: {
706
+ value: number;
707
+ type: "unit";
708
+ unit: "s" | "ms";
709
+ } | {
710
+ value: string;
711
+ type: "var";
712
+ } | undefined;
705
713
  rangeStart?: ["start" | "end", {
706
714
  value: number;
707
715
  type: "unit";
@@ -709,6 +717,9 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
709
717
  } | {
710
718
  value: string;
711
719
  type: "unparsed";
720
+ } | {
721
+ value: string;
722
+ type: "var";
712
723
  }] | undefined;
713
724
  rangeEnd?: ["start" | "end", {
714
725
  value: number;
@@ -717,6 +728,9 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
717
728
  } | {
718
729
  value: string;
719
730
  type: "unparsed";
731
+ } | {
732
+ value: string;
733
+ type: "var";
720
734
  }] | undefined;
721
735
  };
722
736
  name?: string | undefined;
@@ -1338,6 +1352,14 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
1338
1352
  timing: {
1339
1353
  fill?: "none" | "forwards" | "backwards" | "both" | undefined;
1340
1354
  easing?: string | undefined;
1355
+ duration?: {
1356
+ value: number;
1357
+ type: "unit";
1358
+ unit: "s" | "ms";
1359
+ } | {
1360
+ value: string;
1361
+ type: "var";
1362
+ } | undefined;
1341
1363
  rangeStart?: ["contain" | "cover" | "entry" | "exit" | "entry-crossing" | "exit-crossing", {
1342
1364
  value: number;
1343
1365
  type: "unit";
@@ -1345,6 +1367,9 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
1345
1367
  } | {
1346
1368
  value: string;
1347
1369
  type: "unparsed";
1370
+ } | {
1371
+ value: string;
1372
+ type: "var";
1348
1373
  }] | undefined;
1349
1374
  rangeEnd?: ["contain" | "cover" | "entry" | "exit" | "entry-crossing" | "exit-crossing", {
1350
1375
  value: number;
@@ -1353,6 +1378,9 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
1353
1378
  } | {
1354
1379
  value: string;
1355
1380
  type: "unparsed";
1381
+ } | {
1382
+ value: string;
1383
+ type: "var";
1356
1384
  }] | undefined;
1357
1385
  };
1358
1386
  name?: string | undefined;
@@ -1370,6 +1398,9 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
1370
1398
  } | {
1371
1399
  value: string;
1372
1400
  type: "unparsed";
1401
+ } | {
1402
+ value: string;
1403
+ type: "var";
1373
1404
  } | {
1374
1405
  value: "auto";
1375
1406
  type: "keyword";
@@ -1381,6 +1412,9 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
1381
1412
  } | {
1382
1413
  value: string;
1383
1414
  type: "unparsed";
1415
+ } | {
1416
+ value: string;
1417
+ type: "var";
1384
1418
  } | {
1385
1419
  value: "auto";
1386
1420
  type: "keyword";
@@ -1396,7 +1430,6 @@ export declare const idAttribute: "data-ws-id";
1396
1430
  export declare const selectorIdAttribute: "data-ws-selector";
1397
1431
  export declare const componentAttribute: "data-ws-component";
1398
1432
  export declare const showAttribute: "data-ws-show";
1399
- export declare const indexAttribute: "data-ws-index";
1400
1433
  export declare const collapsedAttribute: "data-ws-collapsed";
1401
1434
  export declare const textContentAttribute: "data-ws-text-content";
1402
1435
  export declare const animationCanPlayOnCanvasAttribute = "data-ws-animation-can-play-on-canvas";
@@ -9,4 +9,3 @@ export { PageSettingsCanonicalLink } from "./page-settings-canonical-link";
9
9
  * To render XML, we wrap it with an <svg> tag and add a suffix to avoid React's default behavior on these elements.
10
10
  */
11
11
  export declare const xmlNodeTagSuffix = "-ws-xml-node-fb77f896-8e96-40b9-b8f8-90a4e70d724a";
12
- export declare const getIndexWithinAncestorFromComponentProps: (props: Record<string, unknown>) => string | undefined;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export declare const standardAttributesToReactProps: Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/react-sdk",
3
- "version": "0.209.0",
3
+ "version": "0.212.0",
4
4
  "description": "Webstudio JavaScript / TypeScript API",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -14,7 +14,7 @@
14
14
  "type-fest": "^4.37.0",
15
15
  "vitest": "^3.0.8",
16
16
  "zod": "^3.24.2",
17
- "@webstudio-is/template": "0.209.0",
17
+ "@webstudio-is/template": "0.212.0",
18
18
  "@webstudio-is/tsconfig": "1.0.7"
19
19
  },
20
20
  "peerDependencies": {
@@ -26,11 +26,11 @@
26
26
  "change-case": "^5.4.4",
27
27
  "html-tags": "^4.0.0",
28
28
  "nanoid": "^5.0.9",
29
- "@webstudio-is/css-engine": "0.209.0",
30
- "@webstudio-is/fonts": "0.209.0",
31
- "@webstudio-is/icons": "^0.209.0",
32
- "@webstudio-is/image": "0.209.0",
33
- "@webstudio-is/sdk": "0.209.0"
29
+ "@webstudio-is/fonts": "0.212.0",
30
+ "@webstudio-is/css-engine": "0.212.0",
31
+ "@webstudio-is/icons": "^0.212.0",
32
+ "@webstudio-is/image": "0.212.0",
33
+ "@webstudio-is/sdk": "0.212.0"
34
34
  },
35
35
  "exports": {
36
36
  ".": {