@webstudio-is/react-sdk 0.95.0 → 0.97.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.
Files changed (44) hide show
  1. package/lib/css/normalize.js +127 -53
  2. package/lib/index.js +1850 -32
  3. package/lib/types/component-renderer.d.ts +3 -1
  4. package/lib/types/context.d.ts +2 -0
  5. package/lib/types/index.d.ts +0 -1
  6. package/lib/types/tree/create-elements-tree.d.ts +3 -1
  7. package/lib/types/tree/root.d.ts +3 -1
  8. package/package.json +7 -7
  9. package/lib/app/index.js +0 -2
  10. package/lib/app/root.js +0 -18
  11. package/lib/component-renderer.js +0 -130
  12. package/lib/components/component-meta.js +0 -62
  13. package/lib/components/components-utils.js +0 -2
  14. package/lib/context.js +0 -21
  15. package/lib/css/css.js +0 -59
  16. package/lib/css/global-rules.js +0 -15
  17. package/lib/css/index.js +0 -4
  18. package/lib/css/normalize-type-check.js +0 -4
  19. package/lib/css/presets.js +0 -25
  20. package/lib/css/style-rules.js +0 -63
  21. package/lib/css/style-rules.test.js +0 -149
  22. package/lib/embed-template.js +0 -341
  23. package/lib/embed-template.test.js +0 -648
  24. package/lib/expression.js +0 -330
  25. package/lib/expression.test.js +0 -281
  26. package/lib/generator.js +0 -112
  27. package/lib/generator.test.js +0 -166
  28. package/lib/hook.js +0 -12
  29. package/lib/hook.test.js +0 -15
  30. package/lib/instance-utils.js +0 -43
  31. package/lib/instance-utils.test.js +0 -65
  32. package/lib/prop-meta.js +0 -150
  33. package/lib/props.js +0 -176
  34. package/lib/props.test.js +0 -159
  35. package/lib/pubsub/create.js +0 -56
  36. package/lib/pubsub/index.js +0 -2
  37. package/lib/pubsub/raf-queue.js +0 -20
  38. package/lib/tree/create-elements-tree.js +0 -134
  39. package/lib/tree/index.js +0 -4
  40. package/lib/tree/root.js +0 -85
  41. package/lib/tree/webstudio-component.js +0 -61
  42. package/lib/types/pubsub/create.d.ts +0 -28
  43. package/lib/types/pubsub/index.d.ts +0 -1
  44. package/lib/types/pubsub/raf-queue.d.ts +0 -1
package/lib/props.js DELETED
@@ -1,176 +0,0 @@
1
- "use strict";
2
- import { useContext, useMemo } from "react";
3
- import { computed } from "nanostores";
4
- import { useStore } from "@nanostores/react";
5
- import { ReactSdkContext } from "./context";
6
- import { idAttribute, indexAttribute } from "./tree/webstudio-component";
7
- export const getPropsByInstanceId = (props) => {
8
- const propsByInstanceId = /* @__PURE__ */ new Map();
9
- for (const prop of props.values()) {
10
- let instanceProps = propsByInstanceId.get(prop.instanceId);
11
- if (instanceProps === void 0) {
12
- instanceProps = [];
13
- propsByInstanceId.set(prop.instanceId, instanceProps);
14
- }
15
- instanceProps.push(prop);
16
- }
17
- return propsByInstanceId;
18
- };
19
- export const useInstanceProps = (instanceId) => {
20
- const {
21
- propsByInstanceIdStore,
22
- dataSourceValuesStore,
23
- executeEffectfulExpression,
24
- setDataSourceValues,
25
- indexesWithinAncestors
26
- } = useContext(ReactSdkContext);
27
- const index = indexesWithinAncestors.get(instanceId);
28
- const instancePropsObjectStore = useMemo(() => {
29
- return computed(
30
- [propsByInstanceIdStore, dataSourceValuesStore],
31
- (propsByInstanceId, dataSourceValues) => {
32
- const instancePropsObject2 = {};
33
- if (index !== void 0) {
34
- instancePropsObject2[indexAttribute] = index.toString();
35
- }
36
- const instanceProps = propsByInstanceId.get(instanceId);
37
- if (instanceProps === void 0) {
38
- return instancePropsObject2;
39
- }
40
- for (const prop of instanceProps) {
41
- if (prop.type === "asset" || prop.type === "page") {
42
- continue;
43
- }
44
- if (prop.type === "dataSource") {
45
- const dataSourceId = prop.value;
46
- const value = dataSourceValues.get(dataSourceId);
47
- if (value !== void 0) {
48
- instancePropsObject2[prop.name] = value;
49
- }
50
- continue;
51
- }
52
- if (prop.type === "action") {
53
- instancePropsObject2[prop.name] = (...args) => {
54
- for (const value of prop.value) {
55
- if (value.type === "execute") {
56
- const argsMap = /* @__PURE__ */ new Map();
57
- for (const [i, name] of value.args.entries()) {
58
- argsMap.set(name, args[i]);
59
- }
60
- const newValues = executeEffectfulExpression(
61
- value.code,
62
- argsMap,
63
- dataSourceValues
64
- );
65
- setDataSourceValues(newValues);
66
- }
67
- }
68
- };
69
- continue;
70
- }
71
- instancePropsObject2[prop.name] = prop.value;
72
- }
73
- return instancePropsObject2;
74
- }
75
- );
76
- }, [
77
- propsByInstanceIdStore,
78
- dataSourceValuesStore,
79
- instanceId,
80
- executeEffectfulExpression,
81
- setDataSourceValues,
82
- index
83
- ]);
84
- const instancePropsObject = useStore(instancePropsObjectStore);
85
- return instancePropsObject;
86
- };
87
- export const usePropAsset = (instanceId, name) => {
88
- const { propsByInstanceIdStore, assetsStore } = useContext(ReactSdkContext);
89
- const assetStore = useMemo(() => {
90
- return computed(
91
- [propsByInstanceIdStore, assetsStore],
92
- (propsByInstanceId, assets) => {
93
- const instanceProps = propsByInstanceId.get(instanceId);
94
- if (instanceProps === void 0) {
95
- return;
96
- }
97
- for (const prop of instanceProps) {
98
- if (prop.type === "asset" && prop.name === name) {
99
- const assetId = prop.value;
100
- return assets.get(assetId);
101
- }
102
- }
103
- }
104
- );
105
- }, [propsByInstanceIdStore, assetsStore, instanceId, name]);
106
- const asset = useStore(assetStore);
107
- return asset;
108
- };
109
- export const resolveUrlProp = (instanceId, name, {
110
- props,
111
- pages,
112
- assets
113
- }) => {
114
- const instanceProps = props.get(instanceId);
115
- if (instanceProps === void 0) {
116
- return;
117
- }
118
- let prop = void 0;
119
- for (const intanceProp of instanceProps) {
120
- if (intanceProp.name !== name) {
121
- continue;
122
- }
123
- prop = intanceProp;
124
- }
125
- if (prop === void 0) {
126
- return;
127
- }
128
- if (prop.type === "page") {
129
- if (typeof prop.value === "string") {
130
- const page2 = pages.get(prop.value);
131
- return page2 && { type: "page", page: page2 };
132
- }
133
- const { instanceId: instanceId2, pageId } = prop.value;
134
- const page = pages.get(pageId);
135
- if (page === void 0) {
136
- return;
137
- }
138
- const idProp = props.get(instanceId2)?.find((prop2) => prop2.name === "id");
139
- return {
140
- type: "page",
141
- page,
142
- instanceId: instanceId2,
143
- hash: idProp === void 0 || idProp.type !== "string" ? void 0 : idProp.value
144
- };
145
- }
146
- if (prop.type === "string") {
147
- for (const page of pages.values()) {
148
- if (page.path === prop.value) {
149
- return { type: "page", page };
150
- }
151
- }
152
- return { type: "string", url: prop.value };
153
- }
154
- if (prop.type === "asset") {
155
- const asset = assets.get(prop.value);
156
- return asset && { type: "asset", asset };
157
- }
158
- return;
159
- };
160
- export const usePropUrl = (instanceId, name) => {
161
- const { propsByInstanceIdStore, pagesStore, assetsStore } = useContext(ReactSdkContext);
162
- const store = useMemo(
163
- () => computed(
164
- [propsByInstanceIdStore, pagesStore, assetsStore],
165
- (props, pages, assets) => resolveUrlProp(instanceId, name, { props, pages, assets })
166
- ),
167
- [propsByInstanceIdStore, pagesStore, assetsStore, instanceId, name]
168
- );
169
- return useStore(store);
170
- };
171
- export const getInstanceIdFromComponentProps = (props) => {
172
- return props[idAttribute];
173
- };
174
- export const getIndexWithinAncestorFromComponentProps = (props) => {
175
- return props[indexAttribute];
176
- };
package/lib/props.test.js DELETED
@@ -1,159 +0,0 @@
1
- "use strict";
2
- import { describe, test, expect } from "@jest/globals";
3
- import { resolveUrlProp } from "./props";
4
- const unique = () => Math.random().toString();
5
- describe("resolveUrlProp", () => {
6
- const instanceId = unique();
7
- const projectId = unique();
8
- const page1 = {
9
- id: unique(),
10
- path: `/${unique()}`,
11
- name: "",
12
- title: "",
13
- meta: {},
14
- rootInstanceId: "0"
15
- };
16
- const page2 = {
17
- id: unique(),
18
- path: `/${unique()}`,
19
- name: "",
20
- title: "",
21
- meta: {},
22
- rootInstanceId: "0"
23
- };
24
- const asset1 = {
25
- id: unique(),
26
- name: unique(),
27
- type: "image",
28
- projectId,
29
- format: "png",
30
- size: 1e5,
31
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
32
- description: null,
33
- meta: { width: 128, height: 180 }
34
- };
35
- const assetProp = {
36
- type: "asset",
37
- id: unique(),
38
- instanceId,
39
- name: unique(),
40
- value: asset1.id
41
- };
42
- const pageByIdProp = {
43
- type: "page",
44
- id: unique(),
45
- instanceId,
46
- name: unique(),
47
- value: page1.id
48
- };
49
- const instnaceIdProp = {
50
- type: "string",
51
- id: unique(),
52
- instanceId: unique(),
53
- name: "id",
54
- value: unique()
55
- };
56
- const pageSectionProp = {
57
- type: "page",
58
- id: unique(),
59
- instanceId,
60
- name: unique(),
61
- value: { pageId: page1.id, instanceId: instnaceIdProp.instanceId }
62
- };
63
- const pageByPathProp = {
64
- type: "string",
65
- id: unique(),
66
- instanceId,
67
- name: unique(),
68
- value: page2.path
69
- };
70
- const arbitraryUrlProp = {
71
- type: "string",
72
- id: unique(),
73
- instanceId,
74
- name: unique(),
75
- value: unique()
76
- };
77
- const duplicatePropName = unique();
78
- const duplicateUrlPropFirst = {
79
- type: "string",
80
- id: unique(),
81
- instanceId,
82
- name: duplicatePropName,
83
- value: unique()
84
- };
85
- const duplicateUrlPropSecond = {
86
- type: "string",
87
- id: unique(),
88
- instanceId,
89
- name: duplicatePropName,
90
- value: unique()
91
- };
92
- const props = /* @__PURE__ */ new Map([
93
- [
94
- instanceId,
95
- [
96
- pageByIdProp,
97
- pageByPathProp,
98
- arbitraryUrlProp,
99
- assetProp,
100
- pageSectionProp,
101
- duplicateUrlPropFirst,
102
- duplicateUrlPropSecond
103
- ]
104
- ],
105
- [instnaceIdProp.instanceId, [instnaceIdProp]]
106
- ]);
107
- const pages = /* @__PURE__ */ new Map([
108
- [page1.id, page1],
109
- [page2.id, page2]
110
- ]);
111
- const assets = /* @__PURE__ */ new Map([[asset1.id, asset1]]);
112
- const stores = { props, pages, assets };
113
- test("if instanceId is unknown returns undefined", () => {
114
- expect(
115
- resolveUrlProp("unknown", pageByIdProp.name, stores)
116
- ).toBeUndefined();
117
- });
118
- test("if prop name is unknown returns undefined", () => {
119
- expect(resolveUrlProp(instanceId, "unknown", stores)).toBeUndefined();
120
- });
121
- test("asset by id", () => {
122
- expect(resolveUrlProp(instanceId, assetProp.name, stores)).toEqual({
123
- type: "asset",
124
- asset: asset1
125
- });
126
- });
127
- test("page by id", () => {
128
- expect(resolveUrlProp(instanceId, pageByIdProp.name, stores)).toEqual({
129
- type: "page",
130
- page: page1
131
- });
132
- });
133
- test("page by path", () => {
134
- expect(resolveUrlProp(instanceId, pageByPathProp.name, stores)).toEqual({
135
- type: "page",
136
- page: page2
137
- });
138
- });
139
- test("section on a page", () => {
140
- expect(resolveUrlProp(instanceId, pageSectionProp.name, stores)).toEqual({
141
- type: "page",
142
- page: page1,
143
- instanceId: instnaceIdProp.instanceId,
144
- hash: instnaceIdProp.value
145
- });
146
- });
147
- test("arbitrary url", () => {
148
- expect(resolveUrlProp(instanceId, arbitraryUrlProp.name, stores)).toEqual({
149
- type: "string",
150
- url: arbitraryUrlProp.value
151
- });
152
- });
153
- test("duplicate prop name", () => {
154
- expect(resolveUrlProp(instanceId, duplicatePropName, stores)).toEqual({
155
- type: "string",
156
- url: duplicateUrlPropSecond.value
157
- });
158
- });
159
- });
@@ -1,56 +0,0 @@
1
- "use strict";
2
- import { createNanoEvents } from "nanoevents";
3
- import { useCallback, useEffect, useRef } from "react";
4
- import { batchUpdate } from "./raf-queue";
5
- export const createPubsub = () => {
6
- const emitter = createNanoEvents();
7
- if (typeof window === "object") {
8
- window.addEventListener(
9
- "message",
10
- (event) => {
11
- if (typeof event.data?.type === "string") {
12
- batchUpdate(() => emitter.emit(event.data.type, event.data.payload));
13
- }
14
- },
15
- false
16
- );
17
- }
18
- return {
19
- /**
20
- * To publish a postMessage event on the current window and parent window from the iframe.
21
- */
22
- publish(action) {
23
- window.parent.postMessage(action, "*");
24
- window.postMessage(action, "*");
25
- },
26
- /**
27
- * To publish a postMessage event on the iframe and parent window from the parent window.
28
- */
29
- usePublish() {
30
- const iframeRef = useRef(null);
31
- const publishCallback = useCallback(
32
- (action) => {
33
- const element = iframeRef.current;
34
- if (element?.contentWindow == null) {
35
- return;
36
- }
37
- element.contentWindow.postMessage(action, "*");
38
- window.postMessage(action, "*");
39
- },
40
- [iframeRef]
41
- );
42
- return [publishCallback, iframeRef];
43
- },
44
- /**
45
- * To subscribe a message event on the current window.
46
- */
47
- useSubscribe(type, onAction) {
48
- useEffect(() => {
49
- return emitter.on(type, onAction);
50
- }, [type, onAction]);
51
- },
52
- subscribe(type, onAction) {
53
- return emitter.on(type, onAction);
54
- }
55
- };
56
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- export * from "./create";
@@ -1,20 +0,0 @@
1
- "use strict";
2
- let handle;
3
- let updateQueue = [];
4
- const processUpdates = (updates) => {
5
- for (const update of updates) {
6
- update();
7
- }
8
- };
9
- export const batchUpdate = (update) => {
10
- updateQueue.push(update);
11
- if (handle !== void 0) {
12
- return;
13
- }
14
- handle = requestAnimationFrame(() => {
15
- const updates = updateQueue;
16
- updateQueue = [];
17
- handle = void 0;
18
- processUpdates(updates);
19
- });
20
- };
@@ -1,134 +0,0 @@
1
- "use strict";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import {
4
- Fragment
5
- } from "react";
6
- import {
7
- ReactSdkContext
8
- } from "../context";
9
- export const createElementsTree = ({
10
- renderer,
11
- imageBaseUrl,
12
- assetBaseUrl,
13
- instances,
14
- rootInstanceId,
15
- propsByInstanceIdStore,
16
- assetsStore,
17
- pagesStore,
18
- dataSourceValuesStore,
19
- executeEffectfulExpression,
20
- onDataSourceUpdate,
21
- indexesWithinAncestors,
22
- Component,
23
- components,
24
- scripts
25
- }) => {
26
- const rootInstance = instances.get(rootInstanceId);
27
- if (rootInstance === void 0) {
28
- return null;
29
- }
30
- const rootInstanceSelector = [rootInstanceId];
31
- const children = createInstanceChildrenElements({
32
- instances,
33
- instanceSelector: rootInstanceSelector,
34
- Component,
35
- children: rootInstance.children,
36
- components
37
- });
38
- const root = createInstanceElement({
39
- Component,
40
- instance: rootInstance,
41
- instanceSelector: rootInstanceSelector,
42
- children: [
43
- /* @__PURE__ */ jsxs(Fragment, { children: [
44
- children,
45
- scripts
46
- ] }, "children")
47
- ],
48
- components
49
- });
50
- return /* @__PURE__ */ jsx(
51
- ReactSdkContext.Provider,
52
- {
53
- value: {
54
- propsByInstanceIdStore,
55
- assetsStore,
56
- pagesStore,
57
- dataSourceValuesStore,
58
- renderer,
59
- imageBaseUrl,
60
- assetBaseUrl,
61
- indexesWithinAncestors,
62
- executeEffectfulExpression,
63
- setDataSourceValues: onDataSourceUpdate,
64
- setBoundDataSourceValue: (instanceId, propName, value) => {
65
- const propsByInstanceId = propsByInstanceIdStore.get();
66
- const props = propsByInstanceId.get(instanceId);
67
- const prop = props?.find((prop2) => prop2.name === propName);
68
- if (prop?.type !== "dataSource") {
69
- throw Error(`${propName} is not data source`);
70
- }
71
- const dataSourceId = prop.value;
72
- const newValues = /* @__PURE__ */ new Map();
73
- newValues.set(dataSourceId, value);
74
- onDataSourceUpdate(newValues);
75
- }
76
- },
77
- children: root
78
- }
79
- );
80
- };
81
- const createInstanceChildrenElements = ({
82
- instances,
83
- instanceSelector,
84
- children,
85
- Component,
86
- components
87
- }) => {
88
- const elements = [];
89
- for (const child of children) {
90
- if (child.type === "text") {
91
- elements.push(child.value);
92
- continue;
93
- }
94
- const childInstance = instances.get(child.value);
95
- if (childInstance === void 0) {
96
- continue;
97
- }
98
- const childInstanceSelector = [child.value, ...instanceSelector];
99
- const children2 = createInstanceChildrenElements({
100
- instances,
101
- instanceSelector: childInstanceSelector,
102
- children: childInstance.children,
103
- Component,
104
- components
105
- });
106
- const element = createInstanceElement({
107
- instance: childInstance,
108
- instanceSelector: childInstanceSelector,
109
- Component,
110
- children: children2,
111
- components
112
- });
113
- elements.push(element);
114
- }
115
- return elements;
116
- };
117
- const createInstanceElement = ({
118
- Component,
119
- instance,
120
- instanceSelector,
121
- children = [],
122
- components
123
- }) => {
124
- return /* @__PURE__ */ jsx(
125
- Component,
126
- {
127
- instance,
128
- instanceSelector,
129
- components,
130
- children
131
- },
132
- instance.id
133
- );
134
- };
package/lib/tree/index.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- export * from "./create-elements-tree";
3
- export * from "./root";
4
- export * from "./webstudio-component";
package/lib/tree/root.js DELETED
@@ -1,85 +0,0 @@
1
- "use strict";
2
- import {
3
- useRef,
4
- useCallback
5
- } from "react";
6
- import {
7
- atom,
8
- computed
9
- } from "nanostores";
10
- import { createElementsTree } from "./create-elements-tree";
11
- import {
12
- WebstudioComponent
13
- } from "./webstudio-component";
14
- import { getPropsByInstanceId } from "../props";
15
- export const InstanceRoot = ({
16
- data,
17
- utils,
18
- Component,
19
- components,
20
- scripts
21
- }) => {
22
- const {
23
- indexesWithinAncestors,
24
- executeComputingExpressions,
25
- executeEffectfulExpression
26
- } = utils;
27
- const dataSourceVariablesStoreRef = useRef(void 0);
28
- if (dataSourceVariablesStoreRef.current === void 0) {
29
- dataSourceVariablesStoreRef.current = atom(/* @__PURE__ */ new Map());
30
- }
31
- const dataSourceVariablesStore = dataSourceVariablesStoreRef.current;
32
- const dataSourceValuesStoreRef = useRef(void 0);
33
- if (dataSourceValuesStoreRef.current === void 0) {
34
- dataSourceValuesStoreRef.current = computed(
35
- dataSourceVariablesStore,
36
- (dataSourceVariables) => {
37
- const dataSourceValues = /* @__PURE__ */ new Map();
38
- for (const [dataSourceId, dataSource] of data.build.dataSources) {
39
- if (dataSource.type === "variable") {
40
- const value = dataSourceVariables.get(dataSourceId) ?? dataSource.value.value;
41
- dataSourceValues.set(dataSourceId, value);
42
- }
43
- }
44
- try {
45
- const result = executeComputingExpressions(dataSourceValues);
46
- for (const [id, value] of result) {
47
- dataSourceValues.set(id, value);
48
- }
49
- } catch (error) {
50
- console.error(error);
51
- }
52
- return dataSourceValues;
53
- }
54
- );
55
- }
56
- const dataSourceValuesStore = dataSourceValuesStoreRef.current;
57
- const onDataSourceUpdate = useCallback(
58
- (newValues) => {
59
- const dataSourceVariables = new Map(dataSourceVariablesStore.get());
60
- for (const [dataSourceId, value] of newValues) {
61
- dataSourceVariables.set(dataSourceId, value);
62
- }
63
- dataSourceVariablesStore.set(dataSourceVariables);
64
- },
65
- [dataSourceVariablesStore]
66
- );
67
- return createElementsTree({
68
- imageBaseUrl: data.params?.imageBaseUrl ?? "/",
69
- assetBaseUrl: data.params?.assetBaseUrl ?? "/",
70
- instances: new Map(data.build.instances),
71
- rootInstanceId: data.page.rootInstanceId,
72
- propsByInstanceIdStore: atom(
73
- getPropsByInstanceId(new Map(data.build.props))
74
- ),
75
- assetsStore: atom(new Map(data.assets.map((asset) => [asset.id, asset]))),
76
- pagesStore: atom(new Map(data.pages.map((page) => [page.id, page]))),
77
- indexesWithinAncestors,
78
- executeEffectfulExpression,
79
- dataSourceValuesStore,
80
- onDataSourceUpdate,
81
- Component: Component ?? WebstudioComponent,
82
- components,
83
- scripts
84
- });
85
- };
@@ -1,61 +0,0 @@
1
- "use strict";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { Fragment as Fragment2, forwardRef } from "react";
4
- import { useInstanceProps } from "../props";
5
- const renderText = (text) => {
6
- const lines = text.split("\n");
7
- return lines.map((line, index) => /* @__PURE__ */ jsxs(Fragment2, { children: [
8
- line,
9
- index < lines.length - 1 ? /* @__PURE__ */ jsx("br", {}) : null
10
- ] }, index));
11
- };
12
- export const renderWebstudioComponentChildren = (children) => {
13
- if (children === void 0 || children.length === 0) {
14
- return;
15
- }
16
- return children.map((child) => {
17
- return typeof child === "string" ? renderText(child) : child;
18
- });
19
- };
20
- export const WebstudioComponent = forwardRef(({ instance, instanceSelector, children, components, ...rest }, ref) => {
21
- const { [showAttribute]: show = true, ...instanceProps } = useInstanceProps(
22
- instance.id
23
- );
24
- const props = {
25
- ...instanceProps,
26
- ...rest,
27
- [idAttribute]: instance.id,
28
- [componentAttribute]: instance.component
29
- };
30
- if (show === false) {
31
- return /* @__PURE__ */ jsx(Fragment, {});
32
- }
33
- const Component = components.get(instance.component);
34
- if (Component === void 0) {
35
- return /* @__PURE__ */ jsx(Fragment, {});
36
- }
37
- return /* @__PURE__ */ jsx(Component, { ...props, ref, children: renderWebstudioComponentChildren(children) });
38
- });
39
- export const idAttribute = "data-ws-id";
40
- export const selectorIdAttribute = "data-ws-selector";
41
- export const componentAttribute = "data-ws-component";
42
- export const showAttribute = "data-ws-show";
43
- export const indexAttribute = "data-ws-index";
44
- export const collapsedAttribute = "data-ws-collapsed";
45
- export const splitPropsWithWebstudioAttributes = ({
46
- [idAttribute]: idAttributeValue,
47
- [componentAttribute]: componentAttributeValue,
48
- [showAttribute]: showAttributeValue,
49
- [collapsedAttribute]: collapsedAttributeValue,
50
- [selectorIdAttribute]: parentIdAttributeValue,
51
- ...props
52
- }) => [
53
- {
54
- [idAttribute]: idAttributeValue,
55
- [componentAttribute]: componentAttributeValue,
56
- [showAttribute]: showAttributeValue,
57
- [collapsedAttribute]: collapsedAttributeValue,
58
- [selectorIdAttribute]: parentIdAttributeValue
59
- },
60
- props
61
- ];