@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
package/src/css/normalize.ts
DELETED
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Based on https://github.com/sindresorhus/modern-normalize
|
|
3
|
-
*
|
|
4
|
-
* Attributions
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) Nicolas Gallagher
|
|
8
|
-
* Copyright (c) Jonathan Neal
|
|
9
|
-
* Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
10
|
-
*
|
|
11
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
14
|
-
*
|
|
15
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
// webstudio custom opinionated presets
|
|
19
|
-
import { borders, outline } from "./presets";
|
|
20
|
-
import type { EmbedTemplateStyleDecl } from "../embed-template";
|
|
21
|
-
|
|
22
|
-
export type Styles = EmbedTemplateStyleDecl[];
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
Use a better box model (opinionated).
|
|
26
|
-
*/
|
|
27
|
-
const boxSizing = {
|
|
28
|
-
property: "boxSizing",
|
|
29
|
-
value: { type: "keyword", value: "border-box" },
|
|
30
|
-
} satisfies EmbedTemplateStyleDecl;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* We dont support rules like this now, implement boxSizing for each used element
|
|
34
|
-
* *,
|
|
35
|
-
* ::before,
|
|
36
|
-
* ::after {
|
|
37
|
-
* box-sizing: border-box;
|
|
38
|
-
}
|
|
39
|
-
*/
|
|
40
|
-
const baseStyle = [boxSizing, ...borders, ...outline] satisfies Styles;
|
|
41
|
-
|
|
42
|
-
export const div = baseStyle;
|
|
43
|
-
export const address = baseStyle;
|
|
44
|
-
export const article = baseStyle;
|
|
45
|
-
export const aside = baseStyle;
|
|
46
|
-
export const figure = baseStyle;
|
|
47
|
-
export const footer = baseStyle;
|
|
48
|
-
export const header = baseStyle;
|
|
49
|
-
export const main = baseStyle;
|
|
50
|
-
export const nav = baseStyle;
|
|
51
|
-
export const section = baseStyle;
|
|
52
|
-
export const form = baseStyle;
|
|
53
|
-
export const label = baseStyle;
|
|
54
|
-
|
|
55
|
-
export const h1 = baseStyle;
|
|
56
|
-
export const h2 = baseStyle;
|
|
57
|
-
export const h3 = baseStyle;
|
|
58
|
-
export const h4 = baseStyle;
|
|
59
|
-
export const h5 = baseStyle;
|
|
60
|
-
export const h6 = baseStyle;
|
|
61
|
-
|
|
62
|
-
export const i = baseStyle;
|
|
63
|
-
|
|
64
|
-
export const img = baseStyle;
|
|
65
|
-
|
|
66
|
-
export const a = baseStyle;
|
|
67
|
-
export const li = baseStyle;
|
|
68
|
-
export const ul = baseStyle;
|
|
69
|
-
export const ol = baseStyle;
|
|
70
|
-
|
|
71
|
-
export const p = baseStyle;
|
|
72
|
-
export const span = baseStyle;
|
|
73
|
-
|
|
74
|
-
// @todo for now not applied to html, as we don't have html element
|
|
75
|
-
/**
|
|
76
|
-
1. Correct the line height in all browsers.
|
|
77
|
-
2. Prevent adjustments of font size after orientation changes in iOS.
|
|
78
|
-
3. Use a more readable tab size (opinionated).
|
|
79
|
-
*/
|
|
80
|
-
export const html = [
|
|
81
|
-
/* 1 */
|
|
82
|
-
{
|
|
83
|
-
property: "lineHeight",
|
|
84
|
-
value: { type: "unit", value: 1.15, unit: "number" },
|
|
85
|
-
},
|
|
86
|
-
/* 2 */
|
|
87
|
-
{
|
|
88
|
-
property: "textSizeAdjust",
|
|
89
|
-
value: { type: "unit", value: 100, unit: "%" },
|
|
90
|
-
},
|
|
91
|
-
/* 3 */
|
|
92
|
-
{
|
|
93
|
-
property: "tabSize",
|
|
94
|
-
value: { type: "unit", value: 4, unit: "number" },
|
|
95
|
-
},
|
|
96
|
-
boxSizing,
|
|
97
|
-
...borders,
|
|
98
|
-
] satisfies Styles;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
1. Remove the margin in all browsers.
|
|
102
|
-
2. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
|
|
103
|
-
*/
|
|
104
|
-
export const body = [
|
|
105
|
-
/* 1 */
|
|
106
|
-
{
|
|
107
|
-
property: "marginTop",
|
|
108
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
property: "marginRight",
|
|
112
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
property: "marginBottom",
|
|
116
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
property: "marginLeft",
|
|
120
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
121
|
-
},
|
|
122
|
-
/* 2 */
|
|
123
|
-
{
|
|
124
|
-
property: "fontFamily",
|
|
125
|
-
value: {
|
|
126
|
-
type: "keyword",
|
|
127
|
-
value: "Arial, Roboto, sans-serif",
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
property: "fontSize",
|
|
132
|
-
value: { type: "unit", unit: "px", value: 16 },
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
property: "lineHeight",
|
|
136
|
-
value: { type: "unit", unit: "number", value: 1.2 },
|
|
137
|
-
},
|
|
138
|
-
boxSizing,
|
|
139
|
-
...borders,
|
|
140
|
-
] satisfies Styles;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
1. Add the correct height in Firefox.
|
|
144
|
-
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
|
|
145
|
-
*/
|
|
146
|
-
export const hr = [
|
|
147
|
-
/* 1 */
|
|
148
|
-
{
|
|
149
|
-
property: "height",
|
|
150
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
151
|
-
},
|
|
152
|
-
/* 2 */
|
|
153
|
-
{
|
|
154
|
-
property: "color",
|
|
155
|
-
value: { type: "keyword", value: "inherit" },
|
|
156
|
-
},
|
|
157
|
-
boxSizing,
|
|
158
|
-
...borders,
|
|
159
|
-
] satisfies Styles;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
Add the correct text decoration in Chrome, Edge, and Safari.
|
|
163
|
-
|
|
164
|
-
!!!Skipped as we don't support this logic!!!
|
|
165
|
-
|
|
166
|
-
abbr[title] {
|
|
167
|
-
text-decoration: underline dotted;
|
|
168
|
-
}
|
|
169
|
-
*/
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
Add the correct font weight in Edge and Safari.
|
|
173
|
-
*/
|
|
174
|
-
export const b = [
|
|
175
|
-
{
|
|
176
|
-
property: "fontWeight",
|
|
177
|
-
value: { type: "keyword", value: "700" },
|
|
178
|
-
},
|
|
179
|
-
boxSizing,
|
|
180
|
-
...borders,
|
|
181
|
-
] satisfies Styles;
|
|
182
|
-
export const strong = b;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
|
|
186
|
-
2. Correct the odd 'em' font sizing in all browsers.
|
|
187
|
-
*/
|
|
188
|
-
export const code = [
|
|
189
|
-
/* 1 */
|
|
190
|
-
{
|
|
191
|
-
property: "fontFamily",
|
|
192
|
-
value: {
|
|
193
|
-
type: "keyword",
|
|
194
|
-
value: `ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace`,
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
/* 2 */
|
|
198
|
-
{
|
|
199
|
-
property: "fontSize",
|
|
200
|
-
value: { type: "unit", value: 1, unit: "em" },
|
|
201
|
-
},
|
|
202
|
-
boxSizing,
|
|
203
|
-
...borders,
|
|
204
|
-
] satisfies Styles;
|
|
205
|
-
|
|
206
|
-
export const kbd = code;
|
|
207
|
-
export const samp = code;
|
|
208
|
-
export const pre = code;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
Add the correct font size in all browsers.
|
|
212
|
-
*/
|
|
213
|
-
|
|
214
|
-
export const small = [
|
|
215
|
-
{
|
|
216
|
-
property: "fontSize",
|
|
217
|
-
value: { type: "unit", value: 80, unit: "%" },
|
|
218
|
-
},
|
|
219
|
-
boxSizing,
|
|
220
|
-
...borders,
|
|
221
|
-
] satisfies Styles;
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
|
|
225
|
-
*/
|
|
226
|
-
|
|
227
|
-
const subSupBase = [
|
|
228
|
-
{
|
|
229
|
-
property: "fontSize",
|
|
230
|
-
value: { type: "unit", value: 75, unit: "%" },
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
property: "lineHeight",
|
|
234
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
property: "position",
|
|
238
|
-
value: { type: "keyword", value: "relative" },
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
property: "verticalAlign",
|
|
242
|
-
value: { type: "keyword", value: "baseline" },
|
|
243
|
-
},
|
|
244
|
-
boxSizing,
|
|
245
|
-
...borders,
|
|
246
|
-
] satisfies Styles;
|
|
247
|
-
|
|
248
|
-
export const sub = [
|
|
249
|
-
...subSupBase,
|
|
250
|
-
{
|
|
251
|
-
property: "bottom",
|
|
252
|
-
value: { type: "unit", value: -0.25, unit: "em" },
|
|
253
|
-
},
|
|
254
|
-
] satisfies Styles;
|
|
255
|
-
|
|
256
|
-
export const sup = [
|
|
257
|
-
...subSupBase,
|
|
258
|
-
{
|
|
259
|
-
property: "top",
|
|
260
|
-
value: { type: "unit", value: -0.5, unit: "em" },
|
|
261
|
-
},
|
|
262
|
-
] satisfies Styles;
|
|
263
|
-
|
|
264
|
-
/*
|
|
265
|
-
Tabular data
|
|
266
|
-
============
|
|
267
|
-
*/
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
|
|
271
|
-
2. Correct table border color inheritance in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
|
|
272
|
-
*/
|
|
273
|
-
|
|
274
|
-
export const table = [
|
|
275
|
-
/* 1 */
|
|
276
|
-
{
|
|
277
|
-
property: "textIndent",
|
|
278
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
279
|
-
},
|
|
280
|
-
...borders,
|
|
281
|
-
/* 2 */
|
|
282
|
-
{
|
|
283
|
-
property: "borderTopColor",
|
|
284
|
-
value: { type: "keyword", value: "inherit" },
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
property: "borderRightColor",
|
|
288
|
-
value: { type: "keyword", value: "inherit" },
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
property: "borderBottomColor",
|
|
292
|
-
value: { type: "keyword", value: "inherit" },
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
property: "borderLeftColor",
|
|
296
|
-
value: { type: "keyword", value: "inherit" },
|
|
297
|
-
},
|
|
298
|
-
boxSizing,
|
|
299
|
-
] satisfies Styles;
|
|
300
|
-
|
|
301
|
-
/*
|
|
302
|
-
Forms
|
|
303
|
-
=====
|
|
304
|
-
*/
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
1. Change the font styles in all browsers.
|
|
308
|
-
2. Remove the margin in Firefox and Safari.
|
|
309
|
-
*/
|
|
310
|
-
|
|
311
|
-
const buttonBase = [
|
|
312
|
-
/* 1 */
|
|
313
|
-
{
|
|
314
|
-
property: "fontFamily",
|
|
315
|
-
value: { type: "keyword", value: "inherit" },
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
property: "fontSize",
|
|
319
|
-
value: { type: "unit", value: 100, unit: "%" },
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
property: "lineHeight",
|
|
323
|
-
value: { type: "unit", value: 1.15, unit: "number" },
|
|
324
|
-
},
|
|
325
|
-
/* 2 */
|
|
326
|
-
{
|
|
327
|
-
property: "marginTop",
|
|
328
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
property: "marginRight",
|
|
332
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
property: "marginBottom",
|
|
336
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
property: "marginLeft",
|
|
340
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
341
|
-
},
|
|
342
|
-
boxSizing,
|
|
343
|
-
...borders,
|
|
344
|
-
] satisfies Styles;
|
|
345
|
-
|
|
346
|
-
export const input = buttonBase;
|
|
347
|
-
export const optgroup = buttonBase;
|
|
348
|
-
export const textarea = buttonBase;
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
Remove the inheritance of text transform in Edge and Firefox.
|
|
352
|
-
*/
|
|
353
|
-
export const button = [
|
|
354
|
-
...buttonBase,
|
|
355
|
-
{
|
|
356
|
-
property: "textTransform",
|
|
357
|
-
value: { type: "keyword", value: "none" },
|
|
358
|
-
},
|
|
359
|
-
] satisfies Styles;
|
|
360
|
-
|
|
361
|
-
export const select = button;
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
Correct the inability to style clickable types in iOS and Safari.
|
|
365
|
-
|
|
366
|
-
!!!Skipped as we don't support this logic!!!
|
|
367
|
-
|
|
368
|
-
buttonBase,
|
|
369
|
-
[type='button'],
|
|
370
|
-
[type='reset'],
|
|
371
|
-
[type='submit'] {
|
|
372
|
-
-webkit-appearance: buttonBase;
|
|
373
|
-
}
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
Remove the inner border and padding in Firefox.
|
|
378
|
-
|
|
379
|
-
!!!Skipped as we don't support this logic!!!
|
|
380
|
-
|
|
381
|
-
::-moz-focus-inner {
|
|
382
|
-
border-style: none;
|
|
383
|
-
padding: 0;
|
|
384
|
-
}
|
|
385
|
-
*/
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
Restore the focus styles unset by the previous rule.
|
|
389
|
-
|
|
390
|
-
!!!Skipped as we don't support this logic!!!
|
|
391
|
-
|
|
392
|
-
:-moz-focusring {
|
|
393
|
-
outline: 1px dotted ButtonText;
|
|
394
|
-
}
|
|
395
|
-
*/
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
Remove the additional ':invalid' styles in Firefox.
|
|
399
|
-
See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737
|
|
400
|
-
|
|
401
|
-
!!!Skipped as we don't support this logic!!!
|
|
402
|
-
|
|
403
|
-
:-moz-ui-invalid {
|
|
404
|
-
box-shadow: none;
|
|
405
|
-
}
|
|
406
|
-
*/
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
|
|
410
|
-
*/
|
|
411
|
-
|
|
412
|
-
export const legend = [
|
|
413
|
-
{
|
|
414
|
-
property: "paddingTop",
|
|
415
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
property: "paddingRight",
|
|
419
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
property: "paddingBottom",
|
|
423
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
property: "paddingLeft",
|
|
427
|
-
value: { type: "unit", value: 0, unit: "number" },
|
|
428
|
-
},
|
|
429
|
-
boxSizing,
|
|
430
|
-
...borders,
|
|
431
|
-
] satisfies Styles;
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
Add the correct vertical alignment in Chrome and Firefox.
|
|
435
|
-
*/
|
|
436
|
-
|
|
437
|
-
export const progress = [
|
|
438
|
-
{
|
|
439
|
-
property: "verticalAlign",
|
|
440
|
-
value: { type: "keyword", value: "baseline" },
|
|
441
|
-
},
|
|
442
|
-
boxSizing,
|
|
443
|
-
...borders,
|
|
444
|
-
] satisfies Styles;
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
Correct the cursor style of increment and decrement buttons in Safari.
|
|
448
|
-
|
|
449
|
-
!!!Skipped as we don't support this logic!!!
|
|
450
|
-
|
|
451
|
-
::-webkit-inner-spin-buttonBase,
|
|
452
|
-
::-webkit-outer-spin-buttonBase {
|
|
453
|
-
height: auto;
|
|
454
|
-
}
|
|
455
|
-
*/
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
1. Correct the odd appearance in Chrome and Safari.
|
|
459
|
-
2. Correct the outline style in Safari.
|
|
460
|
-
|
|
461
|
-
!!!Skipped as we don't support this logic!!!
|
|
462
|
-
|
|
463
|
-
[type='search'] {
|
|
464
|
-
-webkit-appearance: textfield;
|
|
465
|
-
outline-offset: -2px;
|
|
466
|
-
}
|
|
467
|
-
*/
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
Remove the inner padding in Chrome and Safari on macOS.
|
|
471
|
-
|
|
472
|
-
!!!Skipped as we don't support this logic!!!
|
|
473
|
-
|
|
474
|
-
::-webkit-search-decoration {
|
|
475
|
-
-webkit-appearance: none;
|
|
476
|
-
}
|
|
477
|
-
*/
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
1. Correct the inability to style clickable types in iOS and Safari.
|
|
481
|
-
2. Change font properties to 'inherit' in Safari.
|
|
482
|
-
|
|
483
|
-
!!!Skipped as we don't support this logic!!!
|
|
484
|
-
|
|
485
|
-
::-webkit-file-upload-buttonBase {
|
|
486
|
-
-webkit-appearance: buttonBase;
|
|
487
|
-
font: inherit;
|
|
488
|
-
}
|
|
489
|
-
*/
|
|
490
|
-
|
|
491
|
-
/*
|
|
492
|
-
Interactive
|
|
493
|
-
===========
|
|
494
|
-
*/
|
|
495
|
-
|
|
496
|
-
/*
|
|
497
|
-
Add the correct display in Chrome and Safari.
|
|
498
|
-
*/
|
|
499
|
-
|
|
500
|
-
export const summary = [
|
|
501
|
-
{
|
|
502
|
-
property: "display",
|
|
503
|
-
value: { type: "keyword", value: "list-item" },
|
|
504
|
-
},
|
|
505
|
-
boxSizing,
|
|
506
|
-
...borders,
|
|
507
|
-
] satisfies Styles;
|
package/src/css/presets.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Styles } from "./normalize";
|
|
2
|
-
|
|
3
|
-
export const borders: Styles = [
|
|
4
|
-
{
|
|
5
|
-
property: "borderTopWidth",
|
|
6
|
-
value: { type: "unit", value: 1, unit: "px" },
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
property: "borderRightWidth",
|
|
10
|
-
value: { type: "unit", value: 1, unit: "px" },
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
property: "borderBottomWidth",
|
|
14
|
-
value: { type: "unit", value: 1, unit: "px" },
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
property: "borderLeftWidth",
|
|
18
|
-
value: { type: "unit", value: 1, unit: "px" },
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
export const outline: Styles = [
|
|
23
|
-
{
|
|
24
|
-
property: "outlineWidth",
|
|
25
|
-
value: { type: "unit", value: 1, unit: "px" },
|
|
26
|
-
},
|
|
27
|
-
];
|
package/src/css/style-rules.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
2
|
-
import type {
|
|
3
|
-
Breakpoint,
|
|
4
|
-
StyleDecl,
|
|
5
|
-
Styles,
|
|
6
|
-
StyleSource,
|
|
7
|
-
StyleSourceSelections,
|
|
8
|
-
} from "@webstudio-is/project-build";
|
|
9
|
-
import type { PresetStyle } from "../components/component-meta";
|
|
10
|
-
import { componentAttribute } from "../tree";
|
|
11
|
-
|
|
12
|
-
type StyleRule = {
|
|
13
|
-
instanceId: string;
|
|
14
|
-
breakpointId: string;
|
|
15
|
-
state: undefined | string;
|
|
16
|
-
style: Style;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Merge styles from different style sources
|
|
21
|
-
* and group by instance and breakpoint
|
|
22
|
-
*/
|
|
23
|
-
export const getStyleRules = (
|
|
24
|
-
styles: Styles,
|
|
25
|
-
styleSourceSelections: StyleSourceSelections
|
|
26
|
-
) => {
|
|
27
|
-
if (styles === undefined || styleSourceSelections === undefined) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
const stylesByStyleSourceId = new Map<StyleSource["id"], StyleDecl[]>();
|
|
31
|
-
for (const styleDecl of styles.values()) {
|
|
32
|
-
const { styleSourceId } = styleDecl;
|
|
33
|
-
let styleSourceStyles = stylesByStyleSourceId.get(styleSourceId);
|
|
34
|
-
// instance can be undefined when style is from other tree
|
|
35
|
-
if (styleSourceStyles === undefined) {
|
|
36
|
-
styleSourceStyles = [];
|
|
37
|
-
stylesByStyleSourceId.set(styleSourceId, styleSourceStyles);
|
|
38
|
-
}
|
|
39
|
-
styleSourceStyles.push(styleDecl);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const styleRules: StyleRule[] = [];
|
|
43
|
-
for (const { instanceId, values } of styleSourceSelections.values()) {
|
|
44
|
-
const styleRuleByBreakpointId = new Map<
|
|
45
|
-
`${Breakpoint["id"]}:${string}`,
|
|
46
|
-
StyleRule
|
|
47
|
-
>();
|
|
48
|
-
|
|
49
|
-
for (const styleSourceId of values) {
|
|
50
|
-
const styleSourceStyles = stylesByStyleSourceId.get(styleSourceId);
|
|
51
|
-
// instance can be undefined when style is from other tree
|
|
52
|
-
if (styleSourceStyles === undefined) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
for (const {
|
|
56
|
-
breakpointId,
|
|
57
|
-
state,
|
|
58
|
-
property,
|
|
59
|
-
value,
|
|
60
|
-
} of styleSourceStyles) {
|
|
61
|
-
const key = `${breakpointId}:${state ?? ""}` as const;
|
|
62
|
-
let styleRule = styleRuleByBreakpointId.get(key);
|
|
63
|
-
if (styleRule === undefined) {
|
|
64
|
-
styleRule = {
|
|
65
|
-
instanceId,
|
|
66
|
-
breakpointId,
|
|
67
|
-
state,
|
|
68
|
-
style: {},
|
|
69
|
-
};
|
|
70
|
-
styleRuleByBreakpointId.set(key, styleRule);
|
|
71
|
-
}
|
|
72
|
-
styleRule.style[property] = value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
styleRules.push(...styleRuleByBreakpointId.values());
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return styleRules;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const getPresetStyleRules = (
|
|
82
|
-
component: string,
|
|
83
|
-
presetStyle: PresetStyle
|
|
84
|
-
) => {
|
|
85
|
-
// group style declarations by selector to render as separate rules
|
|
86
|
-
const presetStyleRules = new Map<string, Style>();
|
|
87
|
-
for (const [tag, styles] of Object.entries(presetStyle)) {
|
|
88
|
-
for (const styleDecl of styles) {
|
|
89
|
-
const selector = `${tag}:where([${componentAttribute}="${component}"])${
|
|
90
|
-
styleDecl.state ?? ""
|
|
91
|
-
}`;
|
|
92
|
-
let rule = presetStyleRules.get(selector);
|
|
93
|
-
if (rule === undefined) {
|
|
94
|
-
rule = {};
|
|
95
|
-
presetStyleRules.set(selector, rule);
|
|
96
|
-
}
|
|
97
|
-
rule[styleDecl.property] = styleDecl.value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return presetStyleRules;
|
|
101
|
-
};
|