@webstudio-is/react-sdk 0.60.0 → 0.61.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/cjs/components/blockquote.ws.js +36 -48
- package/lib/cjs/components/body.ws.js +20 -17
- package/lib/cjs/components/button.ws.js +1 -1
- package/lib/cjs/components/code.ws.js +20 -28
- package/lib/cjs/components/component-meta.js +2 -1
- package/lib/cjs/components/form.ws.js +14 -7
- package/lib/cjs/components/heading.ws.js +1 -1
- package/lib/cjs/components/image.ws.js +8 -9
- package/lib/cjs/components/italic.ws.js +5 -5
- package/lib/cjs/components/link-block.ws.js +5 -5
- package/lib/cjs/components/link.ws.js +9 -10
- package/lib/cjs/components/list-item.ws.js +1 -1
- package/lib/cjs/components/list.ws.js +22 -22
- package/lib/cjs/components/paragraph.ws.js +1 -1
- package/lib/cjs/components/separator.ws.js +20 -20
- package/lib/cjs/components/text-block.ws.js +6 -7
- package/lib/cjs/css/css.js +6 -9
- package/lib/cjs/css/normalize.js +166 -185
- package/lib/cjs/css/presets.js +14 -34
- package/lib/cjs/css/style-rules.js +17 -0
- package/lib/cjs/embed-template.js +160 -0
- package/lib/cjs/index.js +1 -0
- package/lib/components/blockquote.ws.js +36 -48
- package/lib/components/body.ws.js +20 -17
- package/lib/components/button.ws.js +1 -1
- package/lib/components/code.ws.js +20 -28
- package/lib/components/component-meta.js +2 -1
- package/lib/components/form.ws.js +14 -7
- package/lib/components/heading.ws.js +1 -1
- package/lib/components/image.ws.js +8 -9
- package/lib/components/italic.ws.js +5 -5
- package/lib/components/link-block.ws.js +5 -5
- package/lib/components/link.ws.js +9 -10
- package/lib/components/list-item.ws.js +1 -1
- package/lib/components/list.ws.js +22 -22
- package/lib/components/paragraph.ws.js +1 -1
- package/lib/components/separator.ws.js +20 -20
- package/lib/components/text-block.ws.js +6 -7
- package/lib/css/css.js +8 -11
- package/lib/css/normalize.js +166 -185
- package/lib/css/presets.js +14 -34
- package/lib/css/style-rules.js +17 -0
- package/lib/embed-template.js +140 -0
- package/lib/index.js +1 -0
- package/lib/types/components/box.stories.d.ts +2 -2
- package/lib/types/components/component-meta.d.ts +20 -5
- package/lib/types/components/components-utils.d.ts +1 -1
- package/lib/types/css/normalize.d.ts +8786 -2286
- package/lib/types/css/presets.d.ts +2 -38
- package/lib/types/css/style-rules.d.ts +11 -9
- package/lib/types/embed-template.d.ts +1725 -0
- package/lib/types/embed-template.test.d.ts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +14 -13
- package/src/components/blockquote.ws.tsx +42 -52
- package/src/components/body.ws.tsx +26 -23
- package/src/components/bold.ws.tsx +6 -3
- package/src/components/box.ws.ts +6 -3
- package/src/components/button.ws.tsx +7 -4
- package/src/components/code.ws.tsx +26 -32
- package/src/components/component-meta.ts +5 -3
- package/src/components/form.ws.tsx +19 -9
- package/src/components/heading.ws.tsx +7 -4
- package/src/components/image.ws.tsx +14 -12
- package/src/components/input.ws.tsx +6 -3
- package/src/components/italic.ws.tsx +11 -8
- package/src/components/link-block.ws.tsx +11 -8
- package/src/components/link.ws.tsx +15 -13
- package/src/components/list-item.ws.tsx +7 -4
- package/src/components/list.ws.tsx +28 -25
- package/src/components/paragraph.ws.tsx +7 -4
- package/src/components/separator.ws.tsx +26 -25
- package/src/components/span.ws.tsx +6 -3
- package/src/components/subscript.ws.tsx +6 -3
- package/src/components/superscript.ws.tsx +6 -3
- package/src/components/text-block.ws.tsx +12 -11
- package/src/css/css.ts +8 -11
- package/src/css/normalize.ts +165 -188
- package/src/css/presets.ts +15 -37
- package/src/css/style-rules.ts +24 -0
- package/src/embed-template.test.ts +210 -0
- package/src/embed-template.ts +187 -0
- package/src/index.ts +1 -0
package/lib/cjs/css/normalize.js
CHANGED
|
@@ -68,13 +68,10 @@ __export(normalize_exports, {
|
|
|
68
68
|
module.exports = __toCommonJS(normalize_exports);
|
|
69
69
|
var import_presets = require("./presets");
|
|
70
70
|
const boxSizing = {
|
|
71
|
-
|
|
72
|
-
value: "border-box"
|
|
73
|
-
};
|
|
74
|
-
const baseStyle = {
|
|
75
|
-
boxSizing,
|
|
76
|
-
...import_presets.borders
|
|
71
|
+
property: "boxSizing",
|
|
72
|
+
value: { type: "keyword", value: "border-box" }
|
|
77
73
|
};
|
|
74
|
+
const baseStyle = [boxSizing, ...import_presets.borders];
|
|
78
75
|
const div = baseStyle;
|
|
79
76
|
const address = baseStyle;
|
|
80
77
|
const article = baseStyle;
|
|
@@ -100,259 +97,243 @@ const ul = baseStyle;
|
|
|
100
97
|
const ol = baseStyle;
|
|
101
98
|
const p = baseStyle;
|
|
102
99
|
const span = baseStyle;
|
|
103
|
-
const html =
|
|
100
|
+
const html = [
|
|
104
101
|
/* 1 */
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
value: 1.15,
|
|
108
|
-
unit: "number"
|
|
102
|
+
{
|
|
103
|
+
property: "lineHeight",
|
|
104
|
+
value: { type: "unit", value: 1.15, unit: "number" }
|
|
109
105
|
},
|
|
110
106
|
/* 2 */
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
value: 100,
|
|
114
|
-
unit: "%"
|
|
107
|
+
{
|
|
108
|
+
property: "textSizeAdjust",
|
|
109
|
+
value: { type: "unit", value: 100, unit: "%" }
|
|
115
110
|
},
|
|
116
111
|
/* 3 */
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
value: 4,
|
|
120
|
-
unit: "number"
|
|
112
|
+
{
|
|
113
|
+
property: "tabSize",
|
|
114
|
+
value: { type: "unit", value: 4, unit: "number" }
|
|
121
115
|
},
|
|
122
116
|
boxSizing,
|
|
123
117
|
...import_presets.borders
|
|
124
|
-
|
|
125
|
-
const body =
|
|
118
|
+
];
|
|
119
|
+
const body = [
|
|
126
120
|
/* 1 */
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
value: 0,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
type: "unit",
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
marginLeft: {
|
|
143
|
-
type: "unit",
|
|
144
|
-
value: 0,
|
|
145
|
-
unit: "number"
|
|
121
|
+
{
|
|
122
|
+
property: "marginTop",
|
|
123
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
property: "marginRight",
|
|
127
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
property: "marginBottom",
|
|
131
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
property: "marginLeft",
|
|
135
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
146
136
|
},
|
|
147
137
|
/* 2 */
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
value:
|
|
138
|
+
{
|
|
139
|
+
property: "fontFamily",
|
|
140
|
+
value: {
|
|
141
|
+
type: "keyword",
|
|
142
|
+
value: `system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'`
|
|
143
|
+
}
|
|
151
144
|
},
|
|
152
145
|
boxSizing,
|
|
153
146
|
...import_presets.borders
|
|
154
|
-
|
|
155
|
-
const hr =
|
|
147
|
+
];
|
|
148
|
+
const hr = [
|
|
156
149
|
/* 1 */
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
value: 0,
|
|
160
|
-
unit: "number"
|
|
150
|
+
{
|
|
151
|
+
property: "height",
|
|
152
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
161
153
|
},
|
|
162
154
|
/* 2 */
|
|
163
|
-
|
|
155
|
+
{
|
|
156
|
+
property: "color",
|
|
157
|
+
value: { type: "keyword", value: "inherit" }
|
|
158
|
+
},
|
|
164
159
|
boxSizing,
|
|
165
160
|
...import_presets.borders
|
|
166
|
-
|
|
167
|
-
const b =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
value: "
|
|
161
|
+
];
|
|
162
|
+
const b = [
|
|
163
|
+
{
|
|
164
|
+
property: "fontWeight",
|
|
165
|
+
value: { type: "keyword", value: "700" }
|
|
171
166
|
},
|
|
172
167
|
boxSizing,
|
|
173
168
|
...import_presets.borders
|
|
174
|
-
|
|
169
|
+
];
|
|
175
170
|
const strong = b;
|
|
176
|
-
const code =
|
|
171
|
+
const code = [
|
|
177
172
|
/* 1 */
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
value:
|
|
173
|
+
{
|
|
174
|
+
property: "fontFamily",
|
|
175
|
+
value: {
|
|
176
|
+
type: "keyword",
|
|
177
|
+
value: `ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace`
|
|
178
|
+
}
|
|
181
179
|
},
|
|
182
180
|
/* 2 */
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
value: 1,
|
|
186
|
-
unit: "em"
|
|
181
|
+
{
|
|
182
|
+
property: "fontSize",
|
|
183
|
+
value: { type: "unit", value: 1, unit: "em" }
|
|
187
184
|
},
|
|
188
185
|
boxSizing,
|
|
189
186
|
...import_presets.borders
|
|
190
|
-
|
|
187
|
+
];
|
|
191
188
|
const kbd = code;
|
|
192
189
|
const samp = code;
|
|
193
190
|
const pre = code;
|
|
194
|
-
const small =
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
value: 80,
|
|
198
|
-
unit: "%"
|
|
191
|
+
const small = [
|
|
192
|
+
{
|
|
193
|
+
property: "fontSize",
|
|
194
|
+
value: { type: "unit", value: 80, unit: "%" }
|
|
199
195
|
},
|
|
200
196
|
boxSizing,
|
|
201
197
|
...import_presets.borders
|
|
202
|
-
|
|
203
|
-
const subSupBase =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
value: 75,
|
|
207
|
-
unit: "%"
|
|
198
|
+
];
|
|
199
|
+
const subSupBase = [
|
|
200
|
+
{
|
|
201
|
+
property: "fontSize",
|
|
202
|
+
value: { type: "unit", value: 75, unit: "%" }
|
|
208
203
|
},
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
value: 0,
|
|
212
|
-
unit: "number"
|
|
204
|
+
{
|
|
205
|
+
property: "lineHeight",
|
|
206
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
213
207
|
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
value: "relative"
|
|
208
|
+
{
|
|
209
|
+
property: "position",
|
|
210
|
+
value: { type: "keyword", value: "relative" }
|
|
217
211
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
value: "baseline"
|
|
212
|
+
{
|
|
213
|
+
property: "verticalAlign",
|
|
214
|
+
value: { type: "keyword", value: "baseline" }
|
|
221
215
|
},
|
|
222
216
|
boxSizing,
|
|
223
217
|
...import_presets.borders
|
|
224
|
-
|
|
225
|
-
const sub =
|
|
218
|
+
];
|
|
219
|
+
const sub = [
|
|
226
220
|
...subSupBase,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
value: -0.25,
|
|
230
|
-
unit: "em"
|
|
221
|
+
{
|
|
222
|
+
property: "bottom",
|
|
223
|
+
value: { type: "unit", value: -0.25, unit: "em" }
|
|
231
224
|
}
|
|
232
|
-
|
|
233
|
-
const sup =
|
|
225
|
+
];
|
|
226
|
+
const sup = [
|
|
234
227
|
...subSupBase,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
value: -0.5,
|
|
238
|
-
unit: "em"
|
|
228
|
+
{
|
|
229
|
+
property: "top",
|
|
230
|
+
value: { type: "unit", value: -0.5, unit: "em" }
|
|
239
231
|
}
|
|
240
|
-
|
|
241
|
-
const table =
|
|
232
|
+
];
|
|
233
|
+
const table = [
|
|
242
234
|
/* 1 */
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
value: 0,
|
|
246
|
-
unit: "number"
|
|
235
|
+
{
|
|
236
|
+
property: "textIndent",
|
|
237
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
247
238
|
},
|
|
248
239
|
...import_presets.borders,
|
|
249
240
|
/* 2 */
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
value: "inherit"
|
|
241
|
+
{
|
|
242
|
+
property: "borderTopColor",
|
|
243
|
+
value: { type: "keyword", value: "inherit" }
|
|
253
244
|
},
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
value: "inherit"
|
|
245
|
+
{
|
|
246
|
+
property: "borderRightColor",
|
|
247
|
+
value: { type: "keyword", value: "inherit" }
|
|
257
248
|
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
value: "inherit"
|
|
249
|
+
{
|
|
250
|
+
property: "borderBottomColor",
|
|
251
|
+
value: { type: "keyword", value: "inherit" }
|
|
261
252
|
},
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
value: "inherit"
|
|
253
|
+
{
|
|
254
|
+
property: "borderLeftColor",
|
|
255
|
+
value: { type: "keyword", value: "inherit" }
|
|
265
256
|
},
|
|
266
257
|
boxSizing
|
|
267
|
-
|
|
268
|
-
const buttonBase =
|
|
258
|
+
];
|
|
259
|
+
const buttonBase = [
|
|
269
260
|
/* 1 */
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
value: "inherit"
|
|
261
|
+
{
|
|
262
|
+
property: "fontFamily",
|
|
263
|
+
value: { type: "keyword", value: "inherit" }
|
|
273
264
|
},
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
value: 100,
|
|
277
|
-
unit: "%"
|
|
265
|
+
{
|
|
266
|
+
property: "fontSize",
|
|
267
|
+
value: { type: "unit", value: 100, unit: "%" }
|
|
278
268
|
},
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
value: 1.15,
|
|
282
|
-
unit: "number"
|
|
269
|
+
{
|
|
270
|
+
property: "lineHeight",
|
|
271
|
+
value: { type: "unit", value: 1.15, unit: "number" }
|
|
283
272
|
},
|
|
284
273
|
/* 2 */
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
value: 0,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
type: "unit",
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
marginLeft: {
|
|
301
|
-
type: "unit",
|
|
302
|
-
value: 0,
|
|
303
|
-
unit: "number"
|
|
274
|
+
{
|
|
275
|
+
property: "marginTop",
|
|
276
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
property: "marginRight",
|
|
280
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
property: "marginBottom",
|
|
284
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
property: "marginLeft",
|
|
288
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
304
289
|
},
|
|
305
290
|
boxSizing,
|
|
306
291
|
...import_presets.borders
|
|
307
|
-
|
|
292
|
+
];
|
|
308
293
|
const input = buttonBase;
|
|
309
294
|
const optgroup = buttonBase;
|
|
310
295
|
const textarea = buttonBase;
|
|
311
|
-
const button =
|
|
296
|
+
const button = [
|
|
312
297
|
...buttonBase,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
value: "none"
|
|
298
|
+
{
|
|
299
|
+
property: "textTransform",
|
|
300
|
+
value: { type: "keyword", value: "none" }
|
|
316
301
|
}
|
|
317
|
-
|
|
302
|
+
];
|
|
318
303
|
const select = button;
|
|
319
|
-
const legend =
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
value: 0,
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
type: "unit",
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
paddingLeft: {
|
|
336
|
-
type: "unit",
|
|
337
|
-
value: 0,
|
|
338
|
-
unit: "number"
|
|
304
|
+
const legend = [
|
|
305
|
+
{
|
|
306
|
+
property: "paddingTop",
|
|
307
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
property: "paddingRight",
|
|
311
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
property: "paddingBottom",
|
|
315
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
property: "paddingLeft",
|
|
319
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
339
320
|
},
|
|
340
321
|
boxSizing,
|
|
341
322
|
...import_presets.borders
|
|
342
|
-
|
|
343
|
-
const progress =
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
value: "baseline"
|
|
323
|
+
];
|
|
324
|
+
const progress = [
|
|
325
|
+
{
|
|
326
|
+
property: "verticalAlign",
|
|
327
|
+
value: { type: "keyword", value: "baseline" }
|
|
347
328
|
},
|
|
348
329
|
boxSizing,
|
|
349
330
|
...import_presets.borders
|
|
350
|
-
|
|
351
|
-
const summary =
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
value: "list-item"
|
|
331
|
+
];
|
|
332
|
+
const summary = [
|
|
333
|
+
{
|
|
334
|
+
property: "display",
|
|
335
|
+
value: { type: "keyword", value: "list-item" }
|
|
355
336
|
},
|
|
356
337
|
boxSizing,
|
|
357
338
|
...import_presets.borders
|
|
358
|
-
|
|
339
|
+
];
|
package/lib/cjs/css/presets.js
CHANGED
|
@@ -21,41 +21,21 @@ __export(presets_exports, {
|
|
|
21
21
|
borders: () => borders
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(presets_exports);
|
|
24
|
-
const borders =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
value: "
|
|
24
|
+
const borders = [
|
|
25
|
+
{
|
|
26
|
+
property: "borderTopWidth",
|
|
27
|
+
value: { type: "unit", value: 1, unit: "px" }
|
|
28
28
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
value: "
|
|
29
|
+
{
|
|
30
|
+
property: "borderRightWidth",
|
|
31
|
+
value: { type: "unit", value: 1, unit: "px" }
|
|
32
32
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
value: "
|
|
33
|
+
{
|
|
34
|
+
property: "borderBottomWidth",
|
|
35
|
+
value: { type: "unit", value: 1, unit: "px" }
|
|
36
36
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
value: "
|
|
40
|
-
},
|
|
41
|
-
borderTopWidth: {
|
|
42
|
-
type: "unit",
|
|
43
|
-
value: 1,
|
|
44
|
-
unit: "px"
|
|
45
|
-
},
|
|
46
|
-
borderRightWidth: {
|
|
47
|
-
type: "unit",
|
|
48
|
-
value: 1,
|
|
49
|
-
unit: "px"
|
|
50
|
-
},
|
|
51
|
-
borderBottomWidth: {
|
|
52
|
-
type: "unit",
|
|
53
|
-
value: 1,
|
|
54
|
-
unit: "px"
|
|
55
|
-
},
|
|
56
|
-
borderLeftWidth: {
|
|
57
|
-
type: "unit",
|
|
58
|
-
value: 1,
|
|
59
|
-
unit: "px"
|
|
37
|
+
{
|
|
38
|
+
property: "borderLeftWidth",
|
|
39
|
+
value: { type: "unit", value: 1, unit: "px" }
|
|
60
40
|
}
|
|
61
|
-
|
|
41
|
+
];
|
|
@@ -18,9 +18,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var style_rules_exports = {};
|
|
20
20
|
__export(style_rules_exports, {
|
|
21
|
+
getPresetStyleRules: () => getPresetStyleRules,
|
|
21
22
|
getStyleRules: () => getStyleRules
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(style_rules_exports);
|
|
25
|
+
var import_tree = require("../tree");
|
|
24
26
|
const getStyleRules = (styles, styleSourceSelections) => {
|
|
25
27
|
if (styles === void 0 || styleSourceSelections === void 0) {
|
|
26
28
|
return [];
|
|
@@ -67,3 +69,18 @@ const getStyleRules = (styles, styleSourceSelections) => {
|
|
|
67
69
|
}
|
|
68
70
|
return styleRules;
|
|
69
71
|
};
|
|
72
|
+
const getPresetStyleRules = (component, presetStyle) => {
|
|
73
|
+
const presetStyleRules = /* @__PURE__ */ new Map();
|
|
74
|
+
for (const [tag, styles] of Object.entries(presetStyle)) {
|
|
75
|
+
for (const styleDecl of styles) {
|
|
76
|
+
const selector = `${tag}:where([${import_tree.componentAttribute}=${component}])${styleDecl.state ?? ""}`;
|
|
77
|
+
let rule = presetStyleRules.get(selector);
|
|
78
|
+
if (rule === void 0) {
|
|
79
|
+
rule = {};
|
|
80
|
+
presetStyleRules.set(selector, rule);
|
|
81
|
+
}
|
|
82
|
+
rule[styleDecl.property] = styleDecl.value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return presetStyleRules;
|
|
86
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var embed_template_exports = {};
|
|
20
|
+
__export(embed_template_exports, {
|
|
21
|
+
EmbedTemplateInstance: () => EmbedTemplateInstance,
|
|
22
|
+
EmbedTemplateStyleDecl: () => EmbedTemplateStyleDecl,
|
|
23
|
+
WsEmbedTemplate: () => WsEmbedTemplate,
|
|
24
|
+
generateDataFromEmbedTemplate: () => generateDataFromEmbedTemplate
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(embed_template_exports);
|
|
27
|
+
var import_zod = require("zod");
|
|
28
|
+
var import_nanoid = require("nanoid");
|
|
29
|
+
var import_css_data = require("@webstudio-is/css-data");
|
|
30
|
+
const EmbedTemplateText = import_zod.z.object({
|
|
31
|
+
type: import_zod.z.literal("text"),
|
|
32
|
+
value: import_zod.z.string()
|
|
33
|
+
});
|
|
34
|
+
const EmbedTemplateProp = import_zod.z.union([
|
|
35
|
+
import_zod.z.object({
|
|
36
|
+
type: import_zod.z.literal("number"),
|
|
37
|
+
name: import_zod.z.string(),
|
|
38
|
+
value: import_zod.z.number()
|
|
39
|
+
}),
|
|
40
|
+
import_zod.z.object({
|
|
41
|
+
type: import_zod.z.literal("string"),
|
|
42
|
+
name: import_zod.z.string(),
|
|
43
|
+
value: import_zod.z.string()
|
|
44
|
+
}),
|
|
45
|
+
import_zod.z.object({
|
|
46
|
+
type: import_zod.z.literal("boolean"),
|
|
47
|
+
name: import_zod.z.string(),
|
|
48
|
+
value: import_zod.z.boolean()
|
|
49
|
+
}),
|
|
50
|
+
import_zod.z.object({
|
|
51
|
+
type: import_zod.z.literal("string[]"),
|
|
52
|
+
name: import_zod.z.string(),
|
|
53
|
+
value: import_zod.z.array(import_zod.z.string())
|
|
54
|
+
})
|
|
55
|
+
]);
|
|
56
|
+
const EmbedTemplateStyleDecl = import_zod.z.object({
|
|
57
|
+
state: import_zod.z.optional(import_zod.z.string()),
|
|
58
|
+
property: import_zod.z.string(),
|
|
59
|
+
value: import_css_data.StyleValue
|
|
60
|
+
});
|
|
61
|
+
const EmbedTemplateInstance = import_zod.z.lazy(
|
|
62
|
+
() => import_zod.z.object({
|
|
63
|
+
type: import_zod.z.literal("instance"),
|
|
64
|
+
component: import_zod.z.string(),
|
|
65
|
+
props: import_zod.z.optional(import_zod.z.array(EmbedTemplateProp)),
|
|
66
|
+
styles: import_zod.z.optional(import_zod.z.array(EmbedTemplateStyleDecl)),
|
|
67
|
+
children: WsEmbedTemplate
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
const WsEmbedTemplate = import_zod.z.lazy(
|
|
71
|
+
() => import_zod.z.array(import_zod.z.union([EmbedTemplateInstance, EmbedTemplateText]))
|
|
72
|
+
);
|
|
73
|
+
const createInstancesFromTemplate = (treeTemplate, instances, props, styleSourceSelections, styleSources, styles, defaultBreakpointId) => {
|
|
74
|
+
const parentChildren = [];
|
|
75
|
+
for (const item of treeTemplate) {
|
|
76
|
+
if (item.type === "instance") {
|
|
77
|
+
const instanceId = (0, import_nanoid.nanoid)();
|
|
78
|
+
if (item.props) {
|
|
79
|
+
for (const prop of item.props) {
|
|
80
|
+
props.push({
|
|
81
|
+
id: (0, import_nanoid.nanoid)(),
|
|
82
|
+
instanceId,
|
|
83
|
+
...prop
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (item.styles) {
|
|
88
|
+
const styleSourceId = (0, import_nanoid.nanoid)();
|
|
89
|
+
styleSources.push({
|
|
90
|
+
type: "local",
|
|
91
|
+
id: styleSourceId
|
|
92
|
+
});
|
|
93
|
+
styleSourceSelections.push({
|
|
94
|
+
instanceId,
|
|
95
|
+
values: [styleSourceId]
|
|
96
|
+
});
|
|
97
|
+
for (const styleDecl of item.styles) {
|
|
98
|
+
styles.push({
|
|
99
|
+
breakpointId: defaultBreakpointId,
|
|
100
|
+
styleSourceId,
|
|
101
|
+
state: styleDecl.state,
|
|
102
|
+
property: styleDecl.property,
|
|
103
|
+
value: styleDecl.value
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const instance = {
|
|
108
|
+
type: "instance",
|
|
109
|
+
id: instanceId,
|
|
110
|
+
component: item.component,
|
|
111
|
+
children: []
|
|
112
|
+
};
|
|
113
|
+
instances.push(instance);
|
|
114
|
+
instance.children = createInstancesFromTemplate(
|
|
115
|
+
item.children,
|
|
116
|
+
instances,
|
|
117
|
+
props,
|
|
118
|
+
styleSourceSelections,
|
|
119
|
+
styleSources,
|
|
120
|
+
styles,
|
|
121
|
+
defaultBreakpointId
|
|
122
|
+
);
|
|
123
|
+
parentChildren.push({
|
|
124
|
+
type: "id",
|
|
125
|
+
value: instanceId
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (item.type === "text") {
|
|
129
|
+
parentChildren.push({
|
|
130
|
+
type: "text",
|
|
131
|
+
value: item.value
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return parentChildren;
|
|
136
|
+
};
|
|
137
|
+
const generateDataFromEmbedTemplate = (treeTemplate, defaultBreakpointId) => {
|
|
138
|
+
const instances = [];
|
|
139
|
+
const props = [];
|
|
140
|
+
const styleSourceSelections = [];
|
|
141
|
+
const styleSources = [];
|
|
142
|
+
const styles = [];
|
|
143
|
+
const children = createInstancesFromTemplate(
|
|
144
|
+
treeTemplate,
|
|
145
|
+
instances,
|
|
146
|
+
props,
|
|
147
|
+
styleSourceSelections,
|
|
148
|
+
styleSources,
|
|
149
|
+
styles,
|
|
150
|
+
defaultBreakpointId
|
|
151
|
+
);
|
|
152
|
+
return {
|
|
153
|
+
children,
|
|
154
|
+
instances,
|
|
155
|
+
props,
|
|
156
|
+
styleSourceSelections,
|
|
157
|
+
styleSources,
|
|
158
|
+
styles
|
|
159
|
+
};
|
|
160
|
+
};
|
package/lib/cjs/index.js
CHANGED
|
@@ -34,3 +34,4 @@ __reExport(src_exports, require("./components/components"), module.exports);
|
|
|
34
34
|
__reExport(src_exports, require("./components/components-utils"), module.exports);
|
|
35
35
|
var import_custom_components = require("./app/custom-components");
|
|
36
36
|
var import_component_meta = require("./components/component-meta");
|
|
37
|
+
__reExport(src_exports, require("./embed-template"), module.exports);
|