@webstudio-is/react-sdk 0.91.0 → 0.92.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/app/index.js +1 -0
- package/lib/app/root.js +2 -4
- package/lib/component-renderer.js +3 -5
- package/lib/components/component-meta.js +6 -11
- package/lib/components/components-utils.js +1 -0
- package/lib/context.js +2 -4
- package/lib/css/css.js +4 -9
- package/lib/css/global-rules.js +3 -5
- package/lib/css/index.js +1 -0
- package/lib/css/normalize-type-check.js +1 -0
- package/lib/css/normalize.js +48 -96
- package/lib/css/presets.js +3 -6
- package/lib/css/style-rules.js +3 -6
- package/{src/css/style-rules.test.ts → lib/css/style-rules.test.js} +23 -28
- package/lib/embed-template.js +7 -22
- package/{src/embed-template.test.ts → lib/embed-template.test.js} +165 -176
- package/lib/expression.js +11 -22
- package/{src/expression.test.ts → lib/expression.test.js} +55 -83
- package/lib/generator.js +2 -4
- package/{src/generator.test.ts → lib/generator.test.js} +28 -31
- package/lib/hook.js +2 -4
- package/{src/hook.test.ts → lib/hook.test.js} +4 -4
- package/lib/index.js +9 -31
- package/lib/instance-utils.js +2 -4
- package/{src/instance-utils.test.ts → lib/instance-utils.test.js} +19 -43
- package/lib/prop-meta.js +150 -0
- package/lib/props.js +8 -16
- package/{src/props.test.ts → lib/props.test.js} +39 -68
- package/lib/pubsub/create.js +2 -4
- package/lib/pubsub/index.js +1 -0
- package/lib/pubsub/raf-queue.js +2 -4
- package/lib/tree/create-elements-tree.js +2 -4
- package/lib/tree/index.js +1 -0
- package/lib/tree/root.js +2 -5
- package/lib/tree/webstudio-component.js +10 -20
- package/lib/types/component-renderer.d.ts +1 -1
- package/lib/types/components/component-meta.d.ts +526 -526
- package/lib/types/context.d.ts +1 -2
- package/lib/types/css/css.d.ts +22 -23
- package/lib/types/css/global-rules.d.ts +19 -19
- package/lib/types/css/normalize.d.ts +2444 -2444
- package/lib/types/css/style-rules.d.ts +2 -2
- package/lib/types/embed-template.d.ts +648 -648
- package/lib/types/generator.d.ts +1 -1
- package/lib/types/hook.d.ts +3 -3
- package/lib/types/index.d.ts +1 -0
- package/lib/types/instance-utils.d.ts +3 -3
- package/lib/types/prop-meta.d.ts +396 -0
- package/lib/types/props.d.ts +52 -53
- package/lib/types/tree/create-elements-tree.d.ts +3 -4
- package/lib/types/tree/root.d.ts +8 -8
- package/lib/types/tree/webstudio-component.d.ts +1 -1
- package/package.json +14 -22
- package/lib/cjs/app/index.js +0 -18
- package/lib/cjs/app/root.js +0 -40
- package/lib/cjs/component-renderer.js +0 -143
- package/lib/cjs/components/component-meta.js +0 -87
- package/lib/cjs/components/components-utils.js +0 -17
- package/lib/cjs/context.js +0 -43
- package/lib/cjs/css/css.js +0 -84
- package/lib/cjs/css/global-rules.js +0 -37
- package/lib/cjs/css/index.js +0 -20
- package/lib/cjs/css/normalize-type-check.js +0 -26
- package/lib/cjs/css/normalize.js +0 -349
- package/lib/cjs/css/presets.js +0 -48
- package/lib/cjs/css/style-rules.js +0 -86
- package/lib/cjs/embed-template.js +0 -368
- package/lib/cjs/expression.js +0 -371
- package/lib/cjs/generator.js +0 -128
- package/lib/cjs/hook.js +0 -34
- package/lib/cjs/index.js +0 -59
- package/lib/cjs/instance-utils.js +0 -65
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/props.js +0 -204
- package/lib/cjs/pubsub/create.js +0 -78
- package/lib/cjs/pubsub/index.js +0 -18
- package/lib/cjs/pubsub/raf-queue.js +0 -42
- package/lib/cjs/tree/create-elements-tree.js +0 -152
- package/lib/cjs/tree/index.js +0 -20
- package/lib/cjs/tree/root.js +0 -100
- package/lib/cjs/tree/webstudio-component.js +0 -91
- package/src/app/index.ts +0 -1
- package/src/app/root.tsx +0 -25
- package/src/component-renderer.tsx +0 -146
- package/src/components/component-meta.ts +0 -86
- package/src/components/components-utils.ts +0 -13
- package/src/context.tsx +0 -73
- package/src/css/css.ts +0 -88
- package/src/css/global-rules.ts +0 -26
- package/src/css/index.ts +0 -3
- package/src/css/normalize-type-check.ts +0 -13
- package/src/css/normalize.ts +0 -507
- package/src/css/presets.ts +0 -27
- package/src/css/style-rules.ts +0 -101
- package/src/embed-template.ts +0 -438
- package/src/expression.ts +0 -401
- package/src/generator.ts +0 -147
- package/src/hook.ts +0 -52
- package/src/index.ts +0 -39
- package/src/instance-utils.ts +0 -65
- package/src/props.ts +0 -231
- package/src/pubsub/create.ts +0 -77
- package/src/pubsub/index.ts +0 -1
- package/src/pubsub/raf-queue.ts +0 -25
- package/src/tree/create-elements-tree.tsx +0 -186
- package/src/tree/index.ts +0 -3
- package/src/tree/root.ts +0 -131
- package/src/tree/webstudio-component.tsx +0 -97
|
@@ -1,12 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
import { expect, test } from "@jest/globals";
|
|
2
3
|
import { generateDataFromEmbedTemplate, namespaceMeta } from "./embed-template";
|
|
3
4
|
import { showAttribute } from "./tree";
|
|
4
|
-
import type { WsComponentMeta } from "./components/component-meta";
|
|
5
|
-
|
|
6
5
|
const expectString = expect.any(String);
|
|
7
|
-
|
|
8
6
|
const defaultBreakpointId = "base";
|
|
9
|
-
|
|
10
7
|
test("generate data for embedding from instances and text", () => {
|
|
11
8
|
expect(
|
|
12
9
|
generateDataFromEmbedTemplate(
|
|
@@ -17,17 +14,17 @@ test("generate data for embedding from instances and text", () => {
|
|
|
17
14
|
component: "Box1",
|
|
18
15
|
children: [
|
|
19
16
|
{ type: "instance", component: "Box2", children: [] },
|
|
20
|
-
{ type: "text", value: "world" }
|
|
21
|
-
]
|
|
22
|
-
}
|
|
17
|
+
{ type: "text", value: "world" }
|
|
18
|
+
]
|
|
19
|
+
}
|
|
23
20
|
],
|
|
24
|
-
new Map(),
|
|
21
|
+
/* @__PURE__ */ new Map(),
|
|
25
22
|
defaultBreakpointId
|
|
26
23
|
)
|
|
27
24
|
).toEqual({
|
|
28
25
|
children: [
|
|
29
26
|
{ type: "text", value: "hello" },
|
|
30
|
-
{ type: "id", value: expectString }
|
|
27
|
+
{ type: "id", value: expectString }
|
|
31
28
|
],
|
|
32
29
|
instances: [
|
|
33
30
|
{
|
|
@@ -36,24 +33,23 @@ test("generate data for embedding from instances and text", () => {
|
|
|
36
33
|
component: "Box1",
|
|
37
34
|
children: [
|
|
38
35
|
{ type: "id", value: expectString },
|
|
39
|
-
{ type: "text", value: "world" }
|
|
40
|
-
]
|
|
36
|
+
{ type: "text", value: "world" }
|
|
37
|
+
]
|
|
41
38
|
},
|
|
42
39
|
{
|
|
43
40
|
type: "instance",
|
|
44
41
|
id: expectString,
|
|
45
42
|
component: "Box2",
|
|
46
|
-
children: []
|
|
47
|
-
}
|
|
43
|
+
children: []
|
|
44
|
+
}
|
|
48
45
|
],
|
|
49
46
|
props: [],
|
|
50
47
|
dataSources: [],
|
|
51
48
|
styleSourceSelections: [],
|
|
52
49
|
styleSources: [],
|
|
53
|
-
styles: []
|
|
50
|
+
styles: []
|
|
54
51
|
});
|
|
55
52
|
});
|
|
56
|
-
|
|
57
53
|
test("generate data for embedding from props", () => {
|
|
58
54
|
expect(
|
|
59
55
|
generateDataFromEmbedTemplate(
|
|
@@ -63,19 +59,19 @@ test("generate data for embedding from props", () => {
|
|
|
63
59
|
component: "Box1",
|
|
64
60
|
props: [
|
|
65
61
|
{ type: "string", name: "data-prop1", value: "value1" },
|
|
66
|
-
{ type: "string", name: "data-prop2", value: "value2" }
|
|
62
|
+
{ type: "string", name: "data-prop2", value: "value2" }
|
|
67
63
|
],
|
|
68
64
|
children: [
|
|
69
65
|
{
|
|
70
66
|
type: "instance",
|
|
71
67
|
component: "Box2",
|
|
72
68
|
props: [{ type: "string", name: "data-prop3", value: "value3" }],
|
|
73
|
-
children: []
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
}
|
|
69
|
+
children: []
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
77
73
|
],
|
|
78
|
-
new Map(),
|
|
74
|
+
/* @__PURE__ */ new Map(),
|
|
79
75
|
defaultBreakpointId
|
|
80
76
|
)
|
|
81
77
|
).toEqual({
|
|
@@ -85,14 +81,14 @@ test("generate data for embedding from props", () => {
|
|
|
85
81
|
type: "instance",
|
|
86
82
|
id: expectString,
|
|
87
83
|
component: "Box1",
|
|
88
|
-
children: [{ type: "id", value: expectString }]
|
|
84
|
+
children: [{ type: "id", value: expectString }]
|
|
89
85
|
},
|
|
90
86
|
{
|
|
91
87
|
type: "instance",
|
|
92
88
|
id: expectString,
|
|
93
89
|
component: "Box2",
|
|
94
|
-
children: []
|
|
95
|
-
}
|
|
90
|
+
children: []
|
|
91
|
+
}
|
|
96
92
|
],
|
|
97
93
|
props: [
|
|
98
94
|
{
|
|
@@ -100,30 +96,29 @@ test("generate data for embedding from props", () => {
|
|
|
100
96
|
id: expectString,
|
|
101
97
|
instanceId: expectString,
|
|
102
98
|
name: "data-prop1",
|
|
103
|
-
value: "value1"
|
|
99
|
+
value: "value1"
|
|
104
100
|
},
|
|
105
101
|
{
|
|
106
102
|
type: "string",
|
|
107
103
|
id: expectString,
|
|
108
104
|
instanceId: expectString,
|
|
109
105
|
name: "data-prop2",
|
|
110
|
-
value: "value2"
|
|
106
|
+
value: "value2"
|
|
111
107
|
},
|
|
112
108
|
{
|
|
113
109
|
type: "string",
|
|
114
110
|
id: expectString,
|
|
115
111
|
instanceId: expectString,
|
|
116
112
|
name: "data-prop3",
|
|
117
|
-
value: "value3"
|
|
118
|
-
}
|
|
113
|
+
value: "value3"
|
|
114
|
+
}
|
|
119
115
|
],
|
|
120
116
|
dataSources: [],
|
|
121
117
|
styleSourceSelections: [],
|
|
122
118
|
styleSources: [],
|
|
123
|
-
styles: []
|
|
119
|
+
styles: []
|
|
124
120
|
});
|
|
125
121
|
});
|
|
126
|
-
|
|
127
122
|
test("generate data for embedding from styles", () => {
|
|
128
123
|
expect(
|
|
129
124
|
generateDataFromEmbedTemplate(
|
|
@@ -133,7 +128,7 @@ test("generate data for embedding from styles", () => {
|
|
|
133
128
|
component: "Box1",
|
|
134
129
|
styles: [
|
|
135
130
|
{ property: "width", value: { type: "keyword", value: "auto" } },
|
|
136
|
-
{ property: "height", value: { type: "keyword", value: "auto" } }
|
|
131
|
+
{ property: "height", value: { type: "keyword", value: "auto" } }
|
|
137
132
|
],
|
|
138
133
|
children: [
|
|
139
134
|
{
|
|
@@ -142,15 +137,15 @@ test("generate data for embedding from styles", () => {
|
|
|
142
137
|
styles: [
|
|
143
138
|
{
|
|
144
139
|
property: "color",
|
|
145
|
-
value: { type: "keyword", value: "black" }
|
|
146
|
-
}
|
|
140
|
+
value: { type: "keyword", value: "black" }
|
|
141
|
+
}
|
|
147
142
|
],
|
|
148
|
-
children: []
|
|
149
|
-
}
|
|
150
|
-
]
|
|
151
|
-
}
|
|
143
|
+
children: []
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}
|
|
152
147
|
],
|
|
153
|
-
new Map(),
|
|
148
|
+
/* @__PURE__ */ new Map(),
|
|
154
149
|
defaultBreakpointId
|
|
155
150
|
)
|
|
156
151
|
).toEqual({
|
|
@@ -160,63 +155,62 @@ test("generate data for embedding from styles", () => {
|
|
|
160
155
|
type: "instance",
|
|
161
156
|
id: expectString,
|
|
162
157
|
component: "Box1",
|
|
163
|
-
children: [{ type: "id", value: expectString }]
|
|
158
|
+
children: [{ type: "id", value: expectString }]
|
|
164
159
|
},
|
|
165
160
|
{
|
|
166
161
|
type: "instance",
|
|
167
162
|
id: expectString,
|
|
168
163
|
component: "Box2",
|
|
169
|
-
children: []
|
|
170
|
-
}
|
|
164
|
+
children: []
|
|
165
|
+
}
|
|
171
166
|
],
|
|
172
167
|
props: [],
|
|
173
168
|
dataSources: [],
|
|
174
169
|
styleSourceSelections: [
|
|
175
170
|
{
|
|
176
171
|
instanceId: expectString,
|
|
177
|
-
values: [expectString]
|
|
172
|
+
values: [expectString]
|
|
178
173
|
},
|
|
179
174
|
{
|
|
180
175
|
instanceId: expectString,
|
|
181
|
-
values: [expectString]
|
|
182
|
-
}
|
|
176
|
+
values: [expectString]
|
|
177
|
+
}
|
|
183
178
|
],
|
|
184
179
|
styleSources: [
|
|
185
180
|
{
|
|
186
181
|
type: "local",
|
|
187
|
-
id: expectString
|
|
182
|
+
id: expectString
|
|
188
183
|
},
|
|
189
184
|
{
|
|
190
185
|
type: "local",
|
|
191
|
-
id: expectString
|
|
192
|
-
}
|
|
186
|
+
id: expectString
|
|
187
|
+
}
|
|
193
188
|
],
|
|
194
189
|
styles: [
|
|
195
190
|
{
|
|
196
191
|
breakpointId: "base",
|
|
197
192
|
styleSourceId: expectString,
|
|
198
|
-
state:
|
|
193
|
+
state: void 0,
|
|
199
194
|
property: "width",
|
|
200
|
-
value: { type: "keyword", value: "auto" }
|
|
195
|
+
value: { type: "keyword", value: "auto" }
|
|
201
196
|
},
|
|
202
197
|
{
|
|
203
198
|
breakpointId: "base",
|
|
204
199
|
styleSourceId: expectString,
|
|
205
|
-
state:
|
|
200
|
+
state: void 0,
|
|
206
201
|
property: "height",
|
|
207
|
-
value: { type: "keyword", value: "auto" }
|
|
202
|
+
value: { type: "keyword", value: "auto" }
|
|
208
203
|
},
|
|
209
204
|
{
|
|
210
205
|
breakpointId: "base",
|
|
211
206
|
styleSourceId: expectString,
|
|
212
|
-
state:
|
|
207
|
+
state: void 0,
|
|
213
208
|
property: "color",
|
|
214
|
-
value: { type: "keyword", value: "black" }
|
|
215
|
-
}
|
|
216
|
-
]
|
|
209
|
+
value: { type: "keyword", value: "black" }
|
|
210
|
+
}
|
|
211
|
+
]
|
|
217
212
|
});
|
|
218
213
|
});
|
|
219
|
-
|
|
220
214
|
test("generate data for embedding from props bound to data source variables", () => {
|
|
221
215
|
expect(
|
|
222
216
|
generateDataFromEmbedTemplate(
|
|
@@ -225,16 +219,16 @@ test("generate data for embedding from props bound to data source variables", ()
|
|
|
225
219
|
type: "instance",
|
|
226
220
|
component: "Box1",
|
|
227
221
|
dataSources: {
|
|
228
|
-
showOtherBoxDataSource: { type: "variable", initialValue: false }
|
|
222
|
+
showOtherBoxDataSource: { type: "variable", initialValue: false }
|
|
229
223
|
},
|
|
230
224
|
props: [
|
|
231
225
|
{
|
|
232
226
|
type: "dataSource",
|
|
233
227
|
name: "showOtherBox",
|
|
234
|
-
dataSourceName: "showOtherBoxDataSource"
|
|
235
|
-
}
|
|
228
|
+
dataSourceName: "showOtherBoxDataSource"
|
|
229
|
+
}
|
|
236
230
|
],
|
|
237
|
-
children: []
|
|
231
|
+
children: []
|
|
238
232
|
},
|
|
239
233
|
{
|
|
240
234
|
type: "instance",
|
|
@@ -243,23 +237,23 @@ test("generate data for embedding from props bound to data source variables", ()
|
|
|
243
237
|
{
|
|
244
238
|
type: "dataSource",
|
|
245
239
|
name: showAttribute,
|
|
246
|
-
dataSourceName: "showOtherBoxDataSource"
|
|
247
|
-
}
|
|
240
|
+
dataSourceName: "showOtherBoxDataSource"
|
|
241
|
+
}
|
|
248
242
|
],
|
|
249
|
-
children: []
|
|
250
|
-
}
|
|
243
|
+
children: []
|
|
244
|
+
}
|
|
251
245
|
],
|
|
252
|
-
new Map(),
|
|
246
|
+
/* @__PURE__ */ new Map(),
|
|
253
247
|
defaultBreakpointId
|
|
254
248
|
)
|
|
255
249
|
).toEqual({
|
|
256
250
|
children: [
|
|
257
251
|
{ type: "id", value: expectString },
|
|
258
|
-
{ type: "id", value: expectString }
|
|
252
|
+
{ type: "id", value: expectString }
|
|
259
253
|
],
|
|
260
254
|
instances: [
|
|
261
255
|
{ type: "instance", id: expectString, component: "Box1", children: [] },
|
|
262
|
-
{ type: "instance", id: expectString, component: "Box2", children: [] }
|
|
256
|
+
{ type: "instance", id: expectString, component: "Box2", children: [] }
|
|
263
257
|
],
|
|
264
258
|
props: [
|
|
265
259
|
{
|
|
@@ -267,15 +261,15 @@ test("generate data for embedding from props bound to data source variables", ()
|
|
|
267
261
|
instanceId: expectString,
|
|
268
262
|
type: "dataSource",
|
|
269
263
|
name: "showOtherBox",
|
|
270
|
-
value: expectString
|
|
264
|
+
value: expectString
|
|
271
265
|
},
|
|
272
266
|
{
|
|
273
267
|
id: expectString,
|
|
274
268
|
instanceId: expectString,
|
|
275
269
|
type: "dataSource",
|
|
276
270
|
name: showAttribute,
|
|
277
|
-
value: expectString
|
|
278
|
-
}
|
|
271
|
+
value: expectString
|
|
272
|
+
}
|
|
279
273
|
],
|
|
280
274
|
dataSources: [
|
|
281
275
|
{
|
|
@@ -285,16 +279,15 @@ test("generate data for embedding from props bound to data source variables", ()
|
|
|
285
279
|
name: "showOtherBoxDataSource",
|
|
286
280
|
value: {
|
|
287
281
|
type: "boolean",
|
|
288
|
-
value: false
|
|
289
|
-
}
|
|
290
|
-
}
|
|
282
|
+
value: false
|
|
283
|
+
}
|
|
284
|
+
}
|
|
291
285
|
],
|
|
292
286
|
styleSourceSelections: [],
|
|
293
287
|
styleSources: [],
|
|
294
|
-
styles: []
|
|
288
|
+
styles: []
|
|
295
289
|
});
|
|
296
290
|
});
|
|
297
|
-
|
|
298
291
|
test("generate data for embedding from props bound to data source expressions", () => {
|
|
299
292
|
expect(
|
|
300
293
|
generateDataFromEmbedTemplate(
|
|
@@ -306,17 +299,17 @@ test("generate data for embedding from props bound to data source expressions",
|
|
|
306
299
|
boxState: { type: "variable", initialValue: "initial" },
|
|
307
300
|
boxStateSuccess: {
|
|
308
301
|
type: "expression",
|
|
309
|
-
code: `boxState === 'success'
|
|
310
|
-
}
|
|
302
|
+
code: `boxState === 'success'`
|
|
303
|
+
}
|
|
311
304
|
},
|
|
312
305
|
props: [
|
|
313
306
|
{
|
|
314
307
|
type: "dataSource",
|
|
315
308
|
name: "state",
|
|
316
|
-
dataSourceName: "boxState"
|
|
317
|
-
}
|
|
309
|
+
dataSourceName: "boxState"
|
|
310
|
+
}
|
|
318
311
|
],
|
|
319
|
-
children: []
|
|
312
|
+
children: []
|
|
320
313
|
},
|
|
321
314
|
{
|
|
322
315
|
type: "instance",
|
|
@@ -325,23 +318,23 @@ test("generate data for embedding from props bound to data source expressions",
|
|
|
325
318
|
{
|
|
326
319
|
type: "dataSource",
|
|
327
320
|
name: showAttribute,
|
|
328
|
-
dataSourceName: "boxStateSuccess"
|
|
329
|
-
}
|
|
321
|
+
dataSourceName: "boxStateSuccess"
|
|
322
|
+
}
|
|
330
323
|
],
|
|
331
|
-
children: []
|
|
332
|
-
}
|
|
324
|
+
children: []
|
|
325
|
+
}
|
|
333
326
|
],
|
|
334
|
-
new Map(),
|
|
327
|
+
/* @__PURE__ */ new Map(),
|
|
335
328
|
defaultBreakpointId
|
|
336
329
|
)
|
|
337
330
|
).toEqual({
|
|
338
331
|
children: [
|
|
339
332
|
{ type: "id", value: expectString },
|
|
340
|
-
{ type: "id", value: expectString }
|
|
333
|
+
{ type: "id", value: expectString }
|
|
341
334
|
],
|
|
342
335
|
instances: [
|
|
343
336
|
{ type: "instance", id: expectString, component: "Box1", children: [] },
|
|
344
|
-
{ type: "instance", id: expectString, component: "Box2", children: [] }
|
|
337
|
+
{ type: "instance", id: expectString, component: "Box2", children: [] }
|
|
345
338
|
],
|
|
346
339
|
props: [
|
|
347
340
|
{
|
|
@@ -349,15 +342,15 @@ test("generate data for embedding from props bound to data source expressions",
|
|
|
349
342
|
instanceId: expectString,
|
|
350
343
|
type: "dataSource",
|
|
351
344
|
name: "state",
|
|
352
|
-
value: expectString
|
|
345
|
+
value: expectString
|
|
353
346
|
},
|
|
354
347
|
{
|
|
355
348
|
id: expectString,
|
|
356
349
|
instanceId: expectString,
|
|
357
350
|
type: "dataSource",
|
|
358
351
|
name: showAttribute,
|
|
359
|
-
value: expectString
|
|
360
|
-
}
|
|
352
|
+
value: expectString
|
|
353
|
+
}
|
|
361
354
|
],
|
|
362
355
|
dataSources: [
|
|
363
356
|
{
|
|
@@ -367,23 +360,22 @@ test("generate data for embedding from props bound to data source expressions",
|
|
|
367
360
|
name: "boxState",
|
|
368
361
|
value: {
|
|
369
362
|
type: "string",
|
|
370
|
-
value: "initial"
|
|
371
|
-
}
|
|
363
|
+
value: "initial"
|
|
364
|
+
}
|
|
372
365
|
},
|
|
373
366
|
{
|
|
374
367
|
type: "expression",
|
|
375
368
|
id: expectString,
|
|
376
369
|
scopeInstanceId: expectString,
|
|
377
370
|
name: "boxStateSuccess",
|
|
378
|
-
code: expect.stringMatching(/\$ws\$dataSource\$\w+ === 'success'/)
|
|
379
|
-
}
|
|
371
|
+
code: expect.stringMatching(/\$ws\$dataSource\$\w+ === 'success'/)
|
|
372
|
+
}
|
|
380
373
|
],
|
|
381
374
|
styleSourceSelections: [],
|
|
382
375
|
styleSources: [],
|
|
383
|
-
styles: []
|
|
376
|
+
styles: []
|
|
384
377
|
});
|
|
385
378
|
});
|
|
386
|
-
|
|
387
379
|
test("generate data for embedding from action props", () => {
|
|
388
380
|
expect(
|
|
389
381
|
generateDataFromEmbedTemplate(
|
|
@@ -392,14 +384,14 @@ test("generate data for embedding from action props", () => {
|
|
|
392
384
|
type: "instance",
|
|
393
385
|
component: "Box1",
|
|
394
386
|
dataSources: {
|
|
395
|
-
boxState: { type: "variable", initialValue: "initial" }
|
|
387
|
+
boxState: { type: "variable", initialValue: "initial" }
|
|
396
388
|
},
|
|
397
389
|
props: [
|
|
398
390
|
{
|
|
399
391
|
type: "dataSource",
|
|
400
392
|
name: "state",
|
|
401
|
-
dataSourceName: "boxState"
|
|
402
|
-
}
|
|
393
|
+
dataSourceName: "boxState"
|
|
394
|
+
}
|
|
403
395
|
],
|
|
404
396
|
children: [
|
|
405
397
|
{
|
|
@@ -409,7 +401,7 @@ test("generate data for embedding from action props", () => {
|
|
|
409
401
|
{
|
|
410
402
|
type: "action",
|
|
411
403
|
name: "onClick",
|
|
412
|
-
value: [{ type: "execute", code: `boxState = 'success'` }]
|
|
404
|
+
value: [{ type: "execute", code: `boxState = 'success'` }]
|
|
413
405
|
},
|
|
414
406
|
{
|
|
415
407
|
type: "action",
|
|
@@ -418,17 +410,17 @@ test("generate data for embedding from action props", () => {
|
|
|
418
410
|
{
|
|
419
411
|
type: "execute",
|
|
420
412
|
args: ["value"],
|
|
421
|
-
code: `boxState = value
|
|
422
|
-
}
|
|
423
|
-
]
|
|
424
|
-
}
|
|
413
|
+
code: `boxState = value`
|
|
414
|
+
}
|
|
415
|
+
]
|
|
416
|
+
}
|
|
425
417
|
],
|
|
426
|
-
children: []
|
|
427
|
-
}
|
|
428
|
-
]
|
|
429
|
-
}
|
|
418
|
+
children: []
|
|
419
|
+
}
|
|
420
|
+
]
|
|
421
|
+
}
|
|
430
422
|
],
|
|
431
|
-
new Map(),
|
|
423
|
+
/* @__PURE__ */ new Map(),
|
|
432
424
|
defaultBreakpointId
|
|
433
425
|
)
|
|
434
426
|
).toEqual({
|
|
@@ -438,9 +430,9 @@ test("generate data for embedding from action props", () => {
|
|
|
438
430
|
type: "instance",
|
|
439
431
|
id: expectString,
|
|
440
432
|
component: "Box1",
|
|
441
|
-
children: [{ type: "id", value: expectString }]
|
|
433
|
+
children: [{ type: "id", value: expectString }]
|
|
442
434
|
},
|
|
443
|
-
{ type: "instance", id: expectString, component: "Box2", children: [] }
|
|
435
|
+
{ type: "instance", id: expectString, component: "Box2", children: [] }
|
|
444
436
|
],
|
|
445
437
|
props: [
|
|
446
438
|
{
|
|
@@ -448,7 +440,7 @@ test("generate data for embedding from action props", () => {
|
|
|
448
440
|
instanceId: expectString,
|
|
449
441
|
type: "dataSource",
|
|
450
442
|
name: "state",
|
|
451
|
-
value: expectString
|
|
443
|
+
value: expectString
|
|
452
444
|
},
|
|
453
445
|
{
|
|
454
446
|
id: expectString,
|
|
@@ -459,9 +451,9 @@ test("generate data for embedding from action props", () => {
|
|
|
459
451
|
{
|
|
460
452
|
type: "execute",
|
|
461
453
|
args: [],
|
|
462
|
-
code: expect.stringMatching(/\$ws\$dataSource\$\w+ = 'success'/)
|
|
463
|
-
}
|
|
464
|
-
]
|
|
454
|
+
code: expect.stringMatching(/\$ws\$dataSource\$\w+ = 'success'/)
|
|
455
|
+
}
|
|
456
|
+
]
|
|
465
457
|
},
|
|
466
458
|
{
|
|
467
459
|
id: expectString,
|
|
@@ -472,10 +464,10 @@ test("generate data for embedding from action props", () => {
|
|
|
472
464
|
{
|
|
473
465
|
type: "execute",
|
|
474
466
|
args: ["value"],
|
|
475
|
-
code: expect.stringMatching(/\$ws\$dataSource\$\w+ = value/)
|
|
476
|
-
}
|
|
477
|
-
]
|
|
478
|
-
}
|
|
467
|
+
code: expect.stringMatching(/\$ws\$dataSource\$\w+ = value/)
|
|
468
|
+
}
|
|
469
|
+
]
|
|
470
|
+
}
|
|
479
471
|
],
|
|
480
472
|
dataSources: [
|
|
481
473
|
{
|
|
@@ -485,103 +477,100 @@ test("generate data for embedding from action props", () => {
|
|
|
485
477
|
name: "boxState",
|
|
486
478
|
value: {
|
|
487
479
|
type: "string",
|
|
488
|
-
value: "initial"
|
|
489
|
-
}
|
|
490
|
-
}
|
|
480
|
+
value: "initial"
|
|
481
|
+
}
|
|
482
|
+
}
|
|
491
483
|
],
|
|
492
484
|
styleSourceSelections: [],
|
|
493
485
|
styleSources: [],
|
|
494
|
-
styles: []
|
|
486
|
+
styles: []
|
|
495
487
|
});
|
|
496
488
|
});
|
|
497
|
-
|
|
498
489
|
test("generate styles from tokens", () => {
|
|
499
|
-
const presetTokens
|
|
490
|
+
const presetTokens = {
|
|
500
491
|
box: {
|
|
501
492
|
styles: [
|
|
502
493
|
{
|
|
503
494
|
property: "width",
|
|
504
|
-
value: { type: "keyword", value: "max-content" }
|
|
495
|
+
value: { type: "keyword", value: "max-content" }
|
|
505
496
|
},
|
|
506
497
|
{
|
|
507
498
|
property: "height",
|
|
508
|
-
value: { type: "keyword", value: "max-content" }
|
|
509
|
-
}
|
|
510
|
-
]
|
|
499
|
+
value: { type: "keyword", value: "max-content" }
|
|
500
|
+
}
|
|
501
|
+
]
|
|
511
502
|
},
|
|
512
503
|
boxBright: {
|
|
513
504
|
styles: [
|
|
514
505
|
{
|
|
515
506
|
property: "color",
|
|
516
|
-
value: { type: "keyword", value: "red" }
|
|
507
|
+
value: { type: "keyword", value: "red" }
|
|
517
508
|
},
|
|
518
509
|
{
|
|
519
510
|
property: "backgroundColor",
|
|
520
|
-
value: { type: "keyword", value: "pink" }
|
|
521
|
-
}
|
|
522
|
-
]
|
|
511
|
+
value: { type: "keyword", value: "pink" }
|
|
512
|
+
}
|
|
513
|
+
]
|
|
523
514
|
},
|
|
524
515
|
boxNone: {
|
|
525
516
|
styles: [
|
|
526
517
|
{
|
|
527
518
|
property: "color",
|
|
528
|
-
value: { type: "keyword", value: "transparent" }
|
|
519
|
+
value: { type: "keyword", value: "transparent" }
|
|
529
520
|
},
|
|
530
521
|
{
|
|
531
522
|
property: "backgroundColor",
|
|
532
|
-
value: { type: "keyword", value: "transparent" }
|
|
533
|
-
}
|
|
534
|
-
]
|
|
535
|
-
}
|
|
523
|
+
value: { type: "keyword", value: "transparent" }
|
|
524
|
+
}
|
|
525
|
+
]
|
|
526
|
+
}
|
|
536
527
|
};
|
|
537
|
-
const { styleSourceSelections, styleSources, styles } =
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
);
|
|
528
|
+
const { styleSourceSelections, styleSources, styles } = generateDataFromEmbedTemplate(
|
|
529
|
+
[
|
|
530
|
+
{
|
|
531
|
+
type: "instance",
|
|
532
|
+
component: "Box",
|
|
533
|
+
tokens: ["box", "boxBright"],
|
|
534
|
+
children: []
|
|
535
|
+
}
|
|
536
|
+
],
|
|
537
|
+
/* @__PURE__ */ new Map([["Box", { type: "container", icon: "", presetTokens }]]),
|
|
538
|
+
defaultBreakpointId
|
|
539
|
+
);
|
|
550
540
|
expect(styleSources).toEqual([
|
|
551
541
|
{ id: "Box:box", name: "Box", type: "token" },
|
|
552
|
-
{ id: "Box:boxBright", name: "Box Bright", type: "token" }
|
|
542
|
+
{ id: "Box:boxBright", name: "Box Bright", type: "token" }
|
|
553
543
|
]);
|
|
554
544
|
expect(styleSourceSelections).toEqual([
|
|
555
|
-
{ instanceId: expectString, values: ["Box:box", "Box:boxBright"] }
|
|
545
|
+
{ instanceId: expectString, values: ["Box:box", "Box:boxBright"] }
|
|
556
546
|
]);
|
|
557
547
|
expect(styles).toEqual([
|
|
558
548
|
{
|
|
559
549
|
breakpointId: "base",
|
|
560
550
|
property: "width",
|
|
561
551
|
styleSourceId: "Box:box",
|
|
562
|
-
value: { type: "keyword", value: "max-content" }
|
|
552
|
+
value: { type: "keyword", value: "max-content" }
|
|
563
553
|
},
|
|
564
554
|
{
|
|
565
555
|
breakpointId: "base",
|
|
566
556
|
property: "height",
|
|
567
557
|
styleSourceId: "Box:box",
|
|
568
|
-
value: { type: "keyword", value: "max-content" }
|
|
558
|
+
value: { type: "keyword", value: "max-content" }
|
|
569
559
|
},
|
|
570
560
|
{
|
|
571
561
|
breakpointId: "base",
|
|
572
562
|
property: "color",
|
|
573
563
|
styleSourceId: "Box:boxBright",
|
|
574
|
-
value: { type: "keyword", value: "red" }
|
|
564
|
+
value: { type: "keyword", value: "red" }
|
|
575
565
|
},
|
|
576
566
|
{
|
|
577
567
|
breakpointId: "base",
|
|
578
568
|
property: "backgroundColor",
|
|
579
569
|
styleSourceId: "Box:boxBright",
|
|
580
|
-
value: { type: "keyword", value: "pink" }
|
|
581
|
-
}
|
|
570
|
+
value: { type: "keyword", value: "pink" }
|
|
571
|
+
}
|
|
582
572
|
]);
|
|
583
573
|
});
|
|
584
|
-
|
|
585
574
|
test("add namespace to selected components in embed template", () => {
|
|
586
575
|
expect(
|
|
587
576
|
namespaceMeta(
|
|
@@ -595,7 +584,7 @@ test("add namespace to selected components in embed template", () => {
|
|
|
595
584
|
presetTokens: {
|
|
596
585
|
base: { styles: [] },
|
|
597
586
|
small: { styles: [] },
|
|
598
|
-
large: { styles: [] }
|
|
587
|
+
large: { styles: [] }
|
|
599
588
|
},
|
|
600
589
|
template: [
|
|
601
590
|
{
|
|
@@ -611,16 +600,16 @@ test("add namespace to selected components in embed template", () => {
|
|
|
611
600
|
{
|
|
612
601
|
type: "instance",
|
|
613
602
|
component: "Button",
|
|
614
|
-
children: []
|
|
615
|
-
}
|
|
616
|
-
]
|
|
617
|
-
}
|
|
618
|
-
]
|
|
619
|
-
}
|
|
620
|
-
]
|
|
603
|
+
children: []
|
|
604
|
+
}
|
|
605
|
+
]
|
|
606
|
+
}
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
]
|
|
621
610
|
},
|
|
622
611
|
"my-namespace",
|
|
623
|
-
new Set(["Tooltip", "Button"])
|
|
612
|
+
/* @__PURE__ */ new Set(["Tooltip", "Button"])
|
|
624
613
|
)
|
|
625
614
|
).toEqual({
|
|
626
615
|
type: "container",
|
|
@@ -632,7 +621,7 @@ test("add namespace to selected components in embed template", () => {
|
|
|
632
621
|
presetTokens: {
|
|
633
622
|
base: { styles: [] },
|
|
634
623
|
small: { styles: [] },
|
|
635
|
-
large: { styles: [] }
|
|
624
|
+
large: { styles: [] }
|
|
636
625
|
},
|
|
637
626
|
template: [
|
|
638
627
|
{
|
|
@@ -648,12 +637,12 @@ test("add namespace to selected components in embed template", () => {
|
|
|
648
637
|
{
|
|
649
638
|
type: "instance",
|
|
650
639
|
component: "my-namespace:Button",
|
|
651
|
-
children: []
|
|
652
|
-
}
|
|
653
|
-
]
|
|
654
|
-
}
|
|
655
|
-
]
|
|
656
|
-
}
|
|
657
|
-
]
|
|
640
|
+
children: []
|
|
641
|
+
}
|
|
642
|
+
]
|
|
643
|
+
}
|
|
644
|
+
]
|
|
645
|
+
}
|
|
646
|
+
]
|
|
658
647
|
});
|
|
659
648
|
});
|