@webstudio-is/react-sdk 0.76.0 → 0.78.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/css/normalize.js +42 -22
- package/lib/cjs/css/presets.js +111 -1
- package/lib/cjs/expression.js +43 -21
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/tree/root.js +18 -35
- package/lib/css/normalize.js +32 -22
- package/lib/css/presets.js +111 -1
- package/lib/expression.js +43 -21
- package/lib/index.js +2 -0
- package/lib/tree/root.js +18 -39
- package/lib/types/css/normalize.d.ts +520 -0
- package/lib/types/css/presets.d.ts +282 -0
- package/lib/types/expression.d.ts +5 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/tree/root.d.ts +4 -2
- package/package.json +7 -7
- package/src/css/normalize.ts +31 -22
- package/src/css/presets.ts +110 -0
- package/src/expression.test.ts +27 -2
- package/src/expression.ts +58 -24
- package/src/index.ts +1 -0
- package/src/tree/root.ts +29 -49
package/lib/cjs/css/normalize.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var normalize_exports = {};
|
|
20
30
|
__export(normalize_exports, {
|
|
@@ -23,6 +33,7 @@ __export(normalize_exports, {
|
|
|
23
33
|
article: () => article,
|
|
24
34
|
aside: () => aside,
|
|
25
35
|
b: () => b,
|
|
36
|
+
blockquote: () => blockquote,
|
|
26
37
|
body: () => body,
|
|
27
38
|
button: () => button,
|
|
28
39
|
code: () => code,
|
|
@@ -67,17 +78,25 @@ __export(normalize_exports, {
|
|
|
67
78
|
ul: () => ul
|
|
68
79
|
});
|
|
69
80
|
module.exports = __toCommonJS(normalize_exports);
|
|
70
|
-
var
|
|
81
|
+
var presets = __toESM(require("./presets"), 1);
|
|
71
82
|
const boxSizing = {
|
|
72
83
|
property: "boxSizing",
|
|
73
84
|
value: { type: "keyword", value: "border-box" }
|
|
74
85
|
};
|
|
75
|
-
const baseStyle = [
|
|
86
|
+
const baseStyle = [
|
|
87
|
+
boxSizing,
|
|
88
|
+
...presets.borders,
|
|
89
|
+
...presets.outline
|
|
90
|
+
];
|
|
76
91
|
const div = baseStyle;
|
|
77
92
|
const address = baseStyle;
|
|
78
93
|
const article = baseStyle;
|
|
79
94
|
const aside = baseStyle;
|
|
80
|
-
const
|
|
95
|
+
const blockquote = [
|
|
96
|
+
...baseStyle,
|
|
97
|
+
...presets.blockquote
|
|
98
|
+
];
|
|
99
|
+
const figure = [...baseStyle, ...presets.margins];
|
|
81
100
|
const footer = baseStyle;
|
|
82
101
|
const header = baseStyle;
|
|
83
102
|
const main = baseStyle;
|
|
@@ -85,19 +104,19 @@ const nav = baseStyle;
|
|
|
85
104
|
const section = baseStyle;
|
|
86
105
|
const form = baseStyle;
|
|
87
106
|
const label = baseStyle;
|
|
88
|
-
const h1 = baseStyle;
|
|
89
|
-
const h2 = baseStyle;
|
|
90
|
-
const h3 = baseStyle;
|
|
91
|
-
const h4 = baseStyle;
|
|
92
|
-
const h5 = baseStyle;
|
|
93
|
-
const h6 = baseStyle;
|
|
107
|
+
const h1 = [...baseStyle, ...presets.h1];
|
|
108
|
+
const h2 = [...baseStyle, ...presets.h2];
|
|
109
|
+
const h3 = [...baseStyle, ...presets.h3];
|
|
110
|
+
const h4 = [...baseStyle, ...presets.h4];
|
|
111
|
+
const h5 = [...baseStyle, ...presets.h5];
|
|
112
|
+
const h6 = [...baseStyle, ...presets.h6];
|
|
94
113
|
const i = baseStyle;
|
|
95
114
|
const img = baseStyle;
|
|
96
115
|
const a = baseStyle;
|
|
97
116
|
const li = baseStyle;
|
|
98
117
|
const ul = baseStyle;
|
|
99
118
|
const ol = baseStyle;
|
|
100
|
-
const p = baseStyle;
|
|
119
|
+
const p = [...baseStyle, ...presets.verticalMargins];
|
|
101
120
|
const span = baseStyle;
|
|
102
121
|
const html = [
|
|
103
122
|
/* 1 */
|
|
@@ -116,7 +135,7 @@ const html = [
|
|
|
116
135
|
value: { type: "unit", value: 4, unit: "number" }
|
|
117
136
|
},
|
|
118
137
|
boxSizing,
|
|
119
|
-
...
|
|
138
|
+
...presets.borders
|
|
120
139
|
];
|
|
121
140
|
const body = [
|
|
122
141
|
/* 1 */
|
|
@@ -153,7 +172,7 @@ const body = [
|
|
|
153
172
|
value: { type: "unit", unit: "number", value: 1.2 }
|
|
154
173
|
},
|
|
155
174
|
boxSizing,
|
|
156
|
-
...
|
|
175
|
+
...presets.borders
|
|
157
176
|
];
|
|
158
177
|
const hr = [
|
|
159
178
|
/* 1 */
|
|
@@ -167,7 +186,8 @@ const hr = [
|
|
|
167
186
|
value: { type: "keyword", value: "inherit" }
|
|
168
187
|
},
|
|
169
188
|
boxSizing,
|
|
170
|
-
...
|
|
189
|
+
...presets.borders,
|
|
190
|
+
...presets.margins
|
|
171
191
|
];
|
|
172
192
|
const b = [
|
|
173
193
|
{
|
|
@@ -175,7 +195,7 @@ const b = [
|
|
|
175
195
|
value: { type: "keyword", value: "700" }
|
|
176
196
|
},
|
|
177
197
|
boxSizing,
|
|
178
|
-
...
|
|
198
|
+
...presets.borders
|
|
179
199
|
];
|
|
180
200
|
const strong = b;
|
|
181
201
|
const code = [
|
|
@@ -193,7 +213,7 @@ const code = [
|
|
|
193
213
|
value: { type: "unit", value: 1, unit: "em" }
|
|
194
214
|
},
|
|
195
215
|
boxSizing,
|
|
196
|
-
...
|
|
216
|
+
...presets.borders
|
|
197
217
|
];
|
|
198
218
|
const kbd = code;
|
|
199
219
|
const samp = code;
|
|
@@ -204,7 +224,7 @@ const small = [
|
|
|
204
224
|
value: { type: "unit", value: 80, unit: "%" }
|
|
205
225
|
},
|
|
206
226
|
boxSizing,
|
|
207
|
-
...
|
|
227
|
+
...presets.borders
|
|
208
228
|
];
|
|
209
229
|
const subSupBase = [
|
|
210
230
|
{
|
|
@@ -224,7 +244,7 @@ const subSupBase = [
|
|
|
224
244
|
value: { type: "keyword", value: "baseline" }
|
|
225
245
|
},
|
|
226
246
|
boxSizing,
|
|
227
|
-
...
|
|
247
|
+
...presets.borders
|
|
228
248
|
];
|
|
229
249
|
const sub = [
|
|
230
250
|
...subSupBase,
|
|
@@ -246,7 +266,7 @@ const table = [
|
|
|
246
266
|
property: "textIndent",
|
|
247
267
|
value: { type: "unit", value: 0, unit: "number" }
|
|
248
268
|
},
|
|
249
|
-
...
|
|
269
|
+
...presets.borders,
|
|
250
270
|
/* 2 */
|
|
251
271
|
{
|
|
252
272
|
property: "borderTopColor",
|
|
@@ -298,7 +318,7 @@ const buttonBase = [
|
|
|
298
318
|
value: { type: "unit", value: 0, unit: "number" }
|
|
299
319
|
},
|
|
300
320
|
boxSizing,
|
|
301
|
-
...
|
|
321
|
+
...presets.borders
|
|
302
322
|
];
|
|
303
323
|
const input = buttonBase;
|
|
304
324
|
const optgroup = buttonBase;
|
|
@@ -329,7 +349,7 @@ const legend = [
|
|
|
329
349
|
value: { type: "unit", value: 0, unit: "number" }
|
|
330
350
|
},
|
|
331
351
|
boxSizing,
|
|
332
|
-
...
|
|
352
|
+
...presets.borders
|
|
333
353
|
];
|
|
334
354
|
const progress = [
|
|
335
355
|
{
|
|
@@ -337,7 +357,7 @@ const progress = [
|
|
|
337
357
|
value: { type: "keyword", value: "baseline" }
|
|
338
358
|
},
|
|
339
359
|
boxSizing,
|
|
340
|
-
...
|
|
360
|
+
...presets.borders
|
|
341
361
|
];
|
|
342
362
|
const summary = [
|
|
343
363
|
{
|
|
@@ -345,5 +365,5 @@ const summary = [
|
|
|
345
365
|
value: { type: "keyword", value: "list-item" }
|
|
346
366
|
},
|
|
347
367
|
boxSizing,
|
|
348
|
-
...
|
|
368
|
+
...presets.borders
|
|
349
369
|
];
|
package/lib/cjs/css/presets.js
CHANGED
|
@@ -18,8 +18,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var presets_exports = {};
|
|
20
20
|
__export(presets_exports, {
|
|
21
|
+
blockquote: () => blockquote,
|
|
21
22
|
borders: () => borders,
|
|
22
|
-
|
|
23
|
+
h1: () => h1,
|
|
24
|
+
h2: () => h2,
|
|
25
|
+
h3: () => h3,
|
|
26
|
+
h4: () => h4,
|
|
27
|
+
h5: () => h5,
|
|
28
|
+
h6: () => h6,
|
|
29
|
+
margins: () => margins,
|
|
30
|
+
outline: () => outline,
|
|
31
|
+
verticalMargins: () => verticalMargins
|
|
23
32
|
});
|
|
24
33
|
module.exports = __toCommonJS(presets_exports);
|
|
25
34
|
const borders = [
|
|
@@ -46,3 +55,104 @@ const outline = [
|
|
|
46
55
|
value: { type: "unit", value: 1, unit: "px" }
|
|
47
56
|
}
|
|
48
57
|
];
|
|
58
|
+
const margins = [
|
|
59
|
+
{
|
|
60
|
+
property: "marginTop",
|
|
61
|
+
value: { type: "unit", value: 0, unit: "px" }
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
property: "marginRight",
|
|
65
|
+
value: { type: "unit", value: 0, unit: "px" }
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
property: "marginBottom",
|
|
69
|
+
value: { type: "unit", value: 0, unit: "px" }
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
property: "marginLeft",
|
|
73
|
+
value: { type: "unit", value: 0, unit: "px" }
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
const verticalMargins = [
|
|
77
|
+
{
|
|
78
|
+
property: "marginTop",
|
|
79
|
+
value: { type: "unit", value: 0, unit: "px" }
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
property: "marginBottom",
|
|
83
|
+
value: { type: "unit", value: 0, unit: "px" }
|
|
84
|
+
}
|
|
85
|
+
];
|
|
86
|
+
const blockquote = [
|
|
87
|
+
...margins,
|
|
88
|
+
{
|
|
89
|
+
property: "paddingTop",
|
|
90
|
+
value: { type: "unit", value: 10, unit: "px" }
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
property: "paddingBottom",
|
|
94
|
+
value: { type: "unit", value: 10, unit: "px" }
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
property: "paddingLeft",
|
|
98
|
+
value: { type: "unit", value: 20, unit: "px" }
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
property: "paddingRight",
|
|
102
|
+
value: { type: "unit", value: 20, unit: "px" }
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
property: "borderLeftWidth",
|
|
106
|
+
value: { type: "unit", value: 5, unit: "px" }
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
property: "borderLeftStyle",
|
|
110
|
+
value: { type: "keyword", value: "solid" }
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
property: "borderLeftColor",
|
|
114
|
+
value: { type: "rgb", r: 226, g: 226, b: 226, alpha: 1 }
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
const h1 = [
|
|
118
|
+
...verticalMargins,
|
|
119
|
+
{
|
|
120
|
+
property: "fontSize",
|
|
121
|
+
value: { type: "unit", value: 38, unit: "px" }
|
|
122
|
+
}
|
|
123
|
+
];
|
|
124
|
+
const h2 = [
|
|
125
|
+
...verticalMargins,
|
|
126
|
+
{
|
|
127
|
+
property: "fontSize",
|
|
128
|
+
value: { type: "unit", value: 32, unit: "px" }
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
const h3 = [
|
|
132
|
+
...verticalMargins,
|
|
133
|
+
{
|
|
134
|
+
property: "fontSize",
|
|
135
|
+
value: { type: "unit", value: 24, unit: "px" }
|
|
136
|
+
}
|
|
137
|
+
];
|
|
138
|
+
const h4 = [
|
|
139
|
+
...verticalMargins,
|
|
140
|
+
{
|
|
141
|
+
property: "fontSize",
|
|
142
|
+
value: { type: "unit", value: 18, unit: "px" }
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
const h5 = [
|
|
146
|
+
...verticalMargins,
|
|
147
|
+
{
|
|
148
|
+
property: "fontSize",
|
|
149
|
+
value: { type: "unit", value: 14, unit: "px" }
|
|
150
|
+
}
|
|
151
|
+
];
|
|
152
|
+
const h6 = [
|
|
153
|
+
...verticalMargins,
|
|
154
|
+
{
|
|
155
|
+
property: "fontSize",
|
|
156
|
+
value: { type: "unit", value: 12, unit: "px" }
|
|
157
|
+
}
|
|
158
|
+
];
|
package/lib/cjs/expression.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(expression_exports, {
|
|
|
31
31
|
decodeDataSourceVariable: () => decodeDataSourceVariable,
|
|
32
32
|
encodeDataSourceVariable: () => encodeDataSourceVariable,
|
|
33
33
|
executeExpressions: () => executeExpressions,
|
|
34
|
+
generateExpressionsComputation: () => generateExpressionsComputation,
|
|
34
35
|
validateExpression: () => validateExpression
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(expression_exports);
|
|
@@ -133,12 +134,29 @@ const validateExpression = (code, transformIdentifier = (id) => id) => {
|
|
|
133
134
|
const expression = (0, import_jsep.default)(code);
|
|
134
135
|
return generateCode(expression, true, transformIdentifier);
|
|
135
136
|
};
|
|
136
|
-
const
|
|
137
|
+
const sortTopologically = (list, depsById, explored = /* @__PURE__ */ new Set(), sorted = []) => {
|
|
138
|
+
for (const id of list) {
|
|
139
|
+
if (explored.has(id)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
explored.add(id);
|
|
143
|
+
const deps = depsById.get(id);
|
|
144
|
+
if (deps) {
|
|
145
|
+
sortTopologically(deps, depsById, explored, sorted);
|
|
146
|
+
}
|
|
147
|
+
sorted.push(id);
|
|
148
|
+
}
|
|
149
|
+
return sorted;
|
|
150
|
+
};
|
|
151
|
+
const generateExpressionsComputation = (variables, expressions) => {
|
|
137
152
|
const depsById = /* @__PURE__ */ new Map();
|
|
138
153
|
for (const [id, code] of expressions) {
|
|
139
154
|
const deps = /* @__PURE__ */ new Set();
|
|
140
155
|
validateExpression(code, (identifier) => {
|
|
141
|
-
if (variables.has(identifier)
|
|
156
|
+
if (variables.has(identifier)) {
|
|
157
|
+
return identifier;
|
|
158
|
+
}
|
|
159
|
+
if (expressions.has(identifier)) {
|
|
142
160
|
deps.add(identifier);
|
|
143
161
|
return identifier;
|
|
144
162
|
}
|
|
@@ -146,35 +164,39 @@ const executeExpressions = (variables, expressions) => {
|
|
|
146
164
|
});
|
|
147
165
|
depsById.set(id, deps);
|
|
148
166
|
}
|
|
149
|
-
const sortedExpressions =
|
|
150
|
-
(
|
|
151
|
-
|
|
152
|
-
return 1;
|
|
153
|
-
}
|
|
154
|
-
if (depsById.get(right)?.has(left)) {
|
|
155
|
-
return -1;
|
|
156
|
-
}
|
|
157
|
-
return 0;
|
|
158
|
-
}
|
|
167
|
+
const sortedExpressions = sortTopologically(
|
|
168
|
+
new Set(expressions.keys()),
|
|
169
|
+
depsById
|
|
159
170
|
);
|
|
160
|
-
let
|
|
161
|
-
for (const
|
|
162
|
-
|
|
171
|
+
let generatedCode = "";
|
|
172
|
+
for (const id of variables) {
|
|
173
|
+
generatedCode += `const ${id} = _variables.get('${id}');
|
|
163
174
|
`;
|
|
164
175
|
}
|
|
165
|
-
const values = /* @__PURE__ */ new Map();
|
|
166
176
|
for (const id of sortedExpressions) {
|
|
167
177
|
const code = expressions.get(id);
|
|
168
178
|
if (code === void 0) {
|
|
169
179
|
continue;
|
|
170
180
|
}
|
|
171
|
-
const
|
|
172
|
-
return (${code});`);
|
|
173
|
-
const value = executeFn();
|
|
174
|
-
header += `const ${id} = ${JSON.stringify(value)};
|
|
181
|
+
generatedCode += `const ${id} = (${code});
|
|
175
182
|
`;
|
|
176
|
-
values.set(id, value);
|
|
177
183
|
}
|
|
184
|
+
generatedCode += `return new Map([
|
|
185
|
+
`;
|
|
186
|
+
for (const id of sortedExpressions) {
|
|
187
|
+
generatedCode += ` ['${id}', ${id}],
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
generatedCode += `]);`;
|
|
191
|
+
return generatedCode;
|
|
192
|
+
};
|
|
193
|
+
const executeExpressions = (variables, expressions) => {
|
|
194
|
+
const generatedCode = generateExpressionsComputation(
|
|
195
|
+
new Set(variables.keys()),
|
|
196
|
+
expressions
|
|
197
|
+
);
|
|
198
|
+
const executeFn = new Function("_variables", generatedCode);
|
|
199
|
+
const values = executeFn(variables);
|
|
178
200
|
return values;
|
|
179
201
|
};
|
|
180
202
|
const dataSourceVariablePrefix = "$ws$dataSource$";
|
package/lib/cjs/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(src_exports, {
|
|
|
25
25
|
defaultStates: () => import_component_meta.defaultStates,
|
|
26
26
|
encodeDataSourceVariable: () => import_expression.encodeDataSourceVariable,
|
|
27
27
|
executeExpressions: () => import_expression.executeExpressions,
|
|
28
|
+
generateExpressionsComputation: () => import_expression.generateExpressionsComputation,
|
|
28
29
|
getInstanceIdFromComponentProps: () => import_props.getInstanceIdFromComponentProps,
|
|
29
30
|
stateCategories: () => import_component_meta.stateCategories,
|
|
30
31
|
useInstanceProps: () => import_props.useInstanceProps,
|
package/lib/cjs/tree/root.js
CHANGED
|
@@ -26,47 +26,15 @@ var import_nanostores = require("nanostores");
|
|
|
26
26
|
var import_create_elements_tree = require("./create-elements-tree");
|
|
27
27
|
var import_webstudio_component = require("./webstudio-component");
|
|
28
28
|
var import_props = require("../props");
|
|
29
|
-
var import_expression = require("../expression");
|
|
30
|
-
const computeExpressions = (dataSources, dataSourceValues) => {
|
|
31
|
-
const outputValues = /* @__PURE__ */ new Map();
|
|
32
|
-
const variables = /* @__PURE__ */ new Map();
|
|
33
|
-
const expressions = /* @__PURE__ */ new Map();
|
|
34
|
-
for (const [dataSourceId, dataSource] of dataSources) {
|
|
35
|
-
const name = (0, import_expression.encodeDataSourceVariable)(dataSourceId);
|
|
36
|
-
if (dataSource.type === "variable") {
|
|
37
|
-
const value = dataSourceValues.get(dataSourceId) ?? dataSource.value.value;
|
|
38
|
-
variables.set(name, value);
|
|
39
|
-
outputValues.set(dataSourceId, value);
|
|
40
|
-
}
|
|
41
|
-
if (dataSource.type === "expression") {
|
|
42
|
-
expressions.set(name, dataSource.code);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
const outputVariables = (0, import_expression.executeExpressions)(variables, expressions);
|
|
47
|
-
for (const [name, value] of outputVariables) {
|
|
48
|
-
const id = (0, import_expression.decodeDataSourceVariable)(name);
|
|
49
|
-
if (id !== void 0) {
|
|
50
|
-
outputValues.set(id, value);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.error(error);
|
|
55
|
-
}
|
|
56
|
-
return outputValues;
|
|
57
|
-
};
|
|
58
29
|
const InstanceRoot = ({
|
|
59
30
|
data,
|
|
31
|
+
computeExpressions,
|
|
60
32
|
Component,
|
|
61
33
|
components
|
|
62
34
|
}) => {
|
|
63
35
|
const dataSourceVariablesStoreRef = (0, import_react.useRef)(void 0);
|
|
64
36
|
if (dataSourceVariablesStoreRef.current === void 0) {
|
|
65
|
-
|
|
66
|
-
for (const [dataSourceId, dataSource] of data.build.dataSources) {
|
|
67
|
-
dataSourceVariables.set(dataSourceId, dataSource);
|
|
68
|
-
}
|
|
69
|
-
dataSourceVariablesStoreRef.current = (0, import_nanostores.atom)(dataSourceVariables);
|
|
37
|
+
dataSourceVariablesStoreRef.current = (0, import_nanostores.atom)(/* @__PURE__ */ new Map());
|
|
70
38
|
}
|
|
71
39
|
const dataSourceVariablesStore = dataSourceVariablesStoreRef.current;
|
|
72
40
|
const dataSourceValuesStoreRef = (0, import_react.useRef)(void 0);
|
|
@@ -74,7 +42,22 @@ const InstanceRoot = ({
|
|
|
74
42
|
dataSourceValuesStoreRef.current = (0, import_nanostores.computed)(
|
|
75
43
|
dataSourceVariablesStore,
|
|
76
44
|
(dataSourceVariables) => {
|
|
77
|
-
|
|
45
|
+
const dataSourceValues = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const [dataSourceId, dataSource] of data.build.dataSources) {
|
|
47
|
+
if (dataSource.type === "variable") {
|
|
48
|
+
const value = dataSourceVariables.get(dataSourceId) ?? dataSource.value.value;
|
|
49
|
+
dataSourceValues.set(dataSourceId, value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const result = computeExpressions(dataSourceValues);
|
|
54
|
+
for (const [id, value] of result) {
|
|
55
|
+
dataSourceValues.set(id, value);
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error(error);
|
|
59
|
+
}
|
|
60
|
+
return dataSourceValues;
|
|
78
61
|
}
|
|
79
62
|
);
|
|
80
63
|
}
|
package/lib/css/normalize.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as presets from "./presets";
|
|
2
2
|
const boxSizing = {
|
|
3
3
|
property: "boxSizing",
|
|
4
4
|
value: { type: "keyword", value: "border-box" }
|
|
5
5
|
};
|
|
6
|
-
const baseStyle = [
|
|
6
|
+
const baseStyle = [
|
|
7
|
+
boxSizing,
|
|
8
|
+
...presets.borders,
|
|
9
|
+
...presets.outline
|
|
10
|
+
];
|
|
7
11
|
const div = baseStyle;
|
|
8
12
|
const address = baseStyle;
|
|
9
13
|
const article = baseStyle;
|
|
10
14
|
const aside = baseStyle;
|
|
11
|
-
const
|
|
15
|
+
const blockquote = [
|
|
16
|
+
...baseStyle,
|
|
17
|
+
...presets.blockquote
|
|
18
|
+
];
|
|
19
|
+
const figure = [...baseStyle, ...presets.margins];
|
|
12
20
|
const footer = baseStyle;
|
|
13
21
|
const header = baseStyle;
|
|
14
22
|
const main = baseStyle;
|
|
@@ -16,19 +24,19 @@ const nav = baseStyle;
|
|
|
16
24
|
const section = baseStyle;
|
|
17
25
|
const form = baseStyle;
|
|
18
26
|
const label = baseStyle;
|
|
19
|
-
const h1 = baseStyle;
|
|
20
|
-
const h2 = baseStyle;
|
|
21
|
-
const h3 = baseStyle;
|
|
22
|
-
const h4 = baseStyle;
|
|
23
|
-
const h5 = baseStyle;
|
|
24
|
-
const h6 = baseStyle;
|
|
27
|
+
const h1 = [...baseStyle, ...presets.h1];
|
|
28
|
+
const h2 = [...baseStyle, ...presets.h2];
|
|
29
|
+
const h3 = [...baseStyle, ...presets.h3];
|
|
30
|
+
const h4 = [...baseStyle, ...presets.h4];
|
|
31
|
+
const h5 = [...baseStyle, ...presets.h5];
|
|
32
|
+
const h6 = [...baseStyle, ...presets.h6];
|
|
25
33
|
const i = baseStyle;
|
|
26
34
|
const img = baseStyle;
|
|
27
35
|
const a = baseStyle;
|
|
28
36
|
const li = baseStyle;
|
|
29
37
|
const ul = baseStyle;
|
|
30
38
|
const ol = baseStyle;
|
|
31
|
-
const p = baseStyle;
|
|
39
|
+
const p = [...baseStyle, ...presets.verticalMargins];
|
|
32
40
|
const span = baseStyle;
|
|
33
41
|
const html = [
|
|
34
42
|
/* 1 */
|
|
@@ -47,7 +55,7 @@ const html = [
|
|
|
47
55
|
value: { type: "unit", value: 4, unit: "number" }
|
|
48
56
|
},
|
|
49
57
|
boxSizing,
|
|
50
|
-
...borders
|
|
58
|
+
...presets.borders
|
|
51
59
|
];
|
|
52
60
|
const body = [
|
|
53
61
|
/* 1 */
|
|
@@ -84,7 +92,7 @@ const body = [
|
|
|
84
92
|
value: { type: "unit", unit: "number", value: 1.2 }
|
|
85
93
|
},
|
|
86
94
|
boxSizing,
|
|
87
|
-
...borders
|
|
95
|
+
...presets.borders
|
|
88
96
|
];
|
|
89
97
|
const hr = [
|
|
90
98
|
/* 1 */
|
|
@@ -98,7 +106,8 @@ const hr = [
|
|
|
98
106
|
value: { type: "keyword", value: "inherit" }
|
|
99
107
|
},
|
|
100
108
|
boxSizing,
|
|
101
|
-
...borders
|
|
109
|
+
...presets.borders,
|
|
110
|
+
...presets.margins
|
|
102
111
|
];
|
|
103
112
|
const b = [
|
|
104
113
|
{
|
|
@@ -106,7 +115,7 @@ const b = [
|
|
|
106
115
|
value: { type: "keyword", value: "700" }
|
|
107
116
|
},
|
|
108
117
|
boxSizing,
|
|
109
|
-
...borders
|
|
118
|
+
...presets.borders
|
|
110
119
|
];
|
|
111
120
|
const strong = b;
|
|
112
121
|
const code = [
|
|
@@ -124,7 +133,7 @@ const code = [
|
|
|
124
133
|
value: { type: "unit", value: 1, unit: "em" }
|
|
125
134
|
},
|
|
126
135
|
boxSizing,
|
|
127
|
-
...borders
|
|
136
|
+
...presets.borders
|
|
128
137
|
];
|
|
129
138
|
const kbd = code;
|
|
130
139
|
const samp = code;
|
|
@@ -135,7 +144,7 @@ const small = [
|
|
|
135
144
|
value: { type: "unit", value: 80, unit: "%" }
|
|
136
145
|
},
|
|
137
146
|
boxSizing,
|
|
138
|
-
...borders
|
|
147
|
+
...presets.borders
|
|
139
148
|
];
|
|
140
149
|
const subSupBase = [
|
|
141
150
|
{
|
|
@@ -155,7 +164,7 @@ const subSupBase = [
|
|
|
155
164
|
value: { type: "keyword", value: "baseline" }
|
|
156
165
|
},
|
|
157
166
|
boxSizing,
|
|
158
|
-
...borders
|
|
167
|
+
...presets.borders
|
|
159
168
|
];
|
|
160
169
|
const sub = [
|
|
161
170
|
...subSupBase,
|
|
@@ -177,7 +186,7 @@ const table = [
|
|
|
177
186
|
property: "textIndent",
|
|
178
187
|
value: { type: "unit", value: 0, unit: "number" }
|
|
179
188
|
},
|
|
180
|
-
...borders,
|
|
189
|
+
...presets.borders,
|
|
181
190
|
/* 2 */
|
|
182
191
|
{
|
|
183
192
|
property: "borderTopColor",
|
|
@@ -229,7 +238,7 @@ const buttonBase = [
|
|
|
229
238
|
value: { type: "unit", value: 0, unit: "number" }
|
|
230
239
|
},
|
|
231
240
|
boxSizing,
|
|
232
|
-
...borders
|
|
241
|
+
...presets.borders
|
|
233
242
|
];
|
|
234
243
|
const input = buttonBase;
|
|
235
244
|
const optgroup = buttonBase;
|
|
@@ -260,7 +269,7 @@ const legend = [
|
|
|
260
269
|
value: { type: "unit", value: 0, unit: "number" }
|
|
261
270
|
},
|
|
262
271
|
boxSizing,
|
|
263
|
-
...borders
|
|
272
|
+
...presets.borders
|
|
264
273
|
];
|
|
265
274
|
const progress = [
|
|
266
275
|
{
|
|
@@ -268,7 +277,7 @@ const progress = [
|
|
|
268
277
|
value: { type: "keyword", value: "baseline" }
|
|
269
278
|
},
|
|
270
279
|
boxSizing,
|
|
271
|
-
...borders
|
|
280
|
+
...presets.borders
|
|
272
281
|
];
|
|
273
282
|
const summary = [
|
|
274
283
|
{
|
|
@@ -276,7 +285,7 @@ const summary = [
|
|
|
276
285
|
value: { type: "keyword", value: "list-item" }
|
|
277
286
|
},
|
|
278
287
|
boxSizing,
|
|
279
|
-
...borders
|
|
288
|
+
...presets.borders
|
|
280
289
|
];
|
|
281
290
|
export {
|
|
282
291
|
a,
|
|
@@ -284,6 +293,7 @@ export {
|
|
|
284
293
|
article,
|
|
285
294
|
aside,
|
|
286
295
|
b,
|
|
296
|
+
blockquote,
|
|
287
297
|
body,
|
|
288
298
|
button,
|
|
289
299
|
code,
|