@webstudio-is/react-sdk 0.60.0 → 0.62.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/custom-components/__generated__/form.props.js +412 -0
- package/lib/app/custom-components/__generated__/image.props.js +442 -0
- package/lib/app/custom-components/__generated__/link-block.props.js +432 -0
- package/lib/app/custom-components/__generated__/link.props.js +432 -0
- package/lib/app/custom-components/__generated__/rich-text-link.props.js +432 -0
- package/lib/app/custom-components/form.js +54 -0
- package/lib/app/custom-components/form.ws.js +81 -0
- package/lib/app/custom-components/index.js +10 -4
- package/lib/cjs/app/custom-components/__generated__/form.props.js +432 -0
- package/lib/cjs/app/custom-components/__generated__/image.props.js +462 -0
- package/lib/cjs/app/custom-components/__generated__/link-block.props.js +452 -0
- package/lib/cjs/app/custom-components/__generated__/link.props.js +452 -0
- package/lib/cjs/app/custom-components/__generated__/rich-text-link.props.js +452 -0
- package/lib/cjs/app/custom-components/form.js +70 -0
- package/lib/cjs/app/custom-components/form.ws.js +101 -0
- package/lib/cjs/app/custom-components/index.js +12 -6
- package/lib/cjs/components/__generated__/checkbox-field.props.js +419 -0
- package/lib/cjs/components/__generated__/checkbox.props.js +459 -0
- package/lib/cjs/components/__generated__/error-message.props.js +418 -0
- package/lib/cjs/components/__generated__/input.props.js +8 -3
- package/lib/cjs/components/__generated__/label.props.js +420 -0
- package/lib/cjs/components/__generated__/radio-button-field.props.js +419 -0
- package/lib/cjs/components/__generated__/radio-button.props.js +459 -0
- package/lib/cjs/components/__generated__/success-message.props.js +418 -0
- package/lib/cjs/components/__generated__/textarea.props.js +432 -0
- 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 +8 -3
- package/lib/cjs/components/checkbox-field.js +29 -0
- package/lib/cjs/components/checkbox-field.ws.js +53 -0
- package/lib/cjs/components/checkbox.js +29 -0
- package/lib/cjs/components/checkbox.ws.js +55 -0
- package/lib/cjs/components/code.ws.js +20 -28
- package/lib/cjs/components/component-meta.js +3 -1
- package/lib/cjs/components/components-utils.js +9 -1
- package/lib/cjs/components/components.js +17 -1
- package/lib/cjs/components/error-message.js +29 -0
- package/lib/cjs/components/error-message.ws.js +40 -0
- package/lib/cjs/components/form.js +1 -1
- package/lib/cjs/components/form.ws.js +35 -9
- package/lib/cjs/components/heading.ws.js +1 -1
- package/lib/cjs/components/image.ws.js +8 -9
- package/lib/cjs/components/index.js +43 -2
- package/lib/cjs/components/input.ws.js +15 -3
- package/lib/cjs/components/italic.ws.js +5 -5
- package/lib/cjs/components/label.js +29 -0
- package/lib/cjs/components/label.ws.js +54 -0
- package/lib/cjs/components/link-block.ws.js +6 -6
- package/lib/cjs/components/link.ws.js +9 -10
- package/lib/cjs/components/list-item.ws.js +2 -1
- package/lib/cjs/components/list.ws.js +22 -22
- package/lib/cjs/components/paragraph.ws.js +1 -1
- package/lib/cjs/components/radio-button-field.js +29 -0
- package/lib/cjs/components/radio-button-field.ws.js +53 -0
- package/lib/cjs/components/radio-button.js +29 -0
- package/lib/cjs/components/radio-button.ws.js +55 -0
- package/lib/cjs/components/separator.ws.js +20 -20
- package/lib/cjs/components/success-message.js +29 -0
- package/lib/cjs/components/success-message.ws.js +40 -0
- package/lib/cjs/components/text-block.ws.js +6 -7
- package/lib/cjs/components/textarea.js +29 -0
- package/lib/cjs/components/textarea.ws.js +56 -0
- package/lib/cjs/css/css.js +6 -9
- package/lib/cjs/css/normalize.js +168 -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/__generated__/checkbox-field.props.js +399 -0
- package/lib/components/__generated__/checkbox.props.js +439 -0
- package/lib/components/__generated__/error-message.props.js +398 -0
- package/lib/components/__generated__/input.props.js +8 -3
- package/lib/components/__generated__/label.props.js +400 -0
- package/lib/components/__generated__/radio-button-field.props.js +399 -0
- package/lib/components/__generated__/radio-button.props.js +439 -0
- package/lib/components/__generated__/success-message.props.js +398 -0
- package/lib/components/__generated__/textarea.props.js +412 -0
- package/lib/components/blockquote.ws.js +36 -48
- package/lib/components/body.ws.js +20 -17
- package/lib/components/button.ws.js +8 -3
- package/lib/components/checkbox-field.js +9 -0
- package/lib/components/checkbox-field.ws.js +33 -0
- package/lib/components/checkbox.js +9 -0
- package/lib/components/checkbox.ws.js +35 -0
- package/lib/components/code.ws.js +20 -28
- package/lib/components/component-meta.js +3 -1
- package/lib/components/components-utils.js +9 -1
- package/lib/components/components.js +17 -1
- package/lib/components/error-message.js +9 -0
- package/lib/components/error-message.ws.js +20 -0
- package/lib/components/form.js +1 -1
- package/lib/components/form.ws.js +35 -9
- package/lib/components/heading.ws.js +1 -1
- package/lib/components/image.ws.js +8 -9
- package/lib/components/index.js +43 -2
- package/lib/components/input.ws.js +15 -3
- package/lib/components/italic.ws.js +5 -5
- package/lib/components/label.js +9 -0
- package/lib/components/label.ws.js +34 -0
- package/lib/components/link-block.ws.js +7 -7
- package/lib/components/link.ws.js +9 -10
- package/lib/components/list-item.ws.js +2 -1
- package/lib/components/list.ws.js +22 -22
- package/lib/components/paragraph.ws.js +1 -1
- package/lib/components/radio-button-field.js +9 -0
- package/lib/components/radio-button-field.ws.js +33 -0
- package/lib/components/radio-button.js +9 -0
- package/lib/components/radio-button.ws.js +35 -0
- package/lib/components/separator.ws.js +20 -20
- package/lib/components/success-message.js +9 -0
- package/lib/components/success-message.ws.js +20 -0
- package/lib/components/text-block.ws.js +6 -7
- package/lib/components/textarea.js +9 -0
- package/lib/components/textarea.ws.js +36 -0
- package/lib/css/css.js +8 -11
- package/lib/css/normalize.js +168 -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/app/custom-components/__generated__/form.props.d.ts +2 -0
- package/lib/types/app/custom-components/__generated__/image.props.d.ts +2 -0
- package/lib/types/app/custom-components/__generated__/link-block.props.d.ts +2 -0
- package/lib/types/app/custom-components/__generated__/link.props.d.ts +2 -0
- package/lib/types/app/custom-components/__generated__/rich-text-link.props.d.ts +2 -0
- package/lib/types/app/custom-components/form.d.ts +5 -0
- package/lib/types/app/custom-components/form.ws.d.ts +3 -0
- package/lib/types/app/custom-components/index.d.ts +6 -1
- package/lib/types/components/__generated__/checkbox-field.props.d.ts +2 -0
- package/lib/types/components/__generated__/checkbox.props.d.ts +2 -0
- package/lib/types/components/__generated__/error-message.props.d.ts +2 -0
- package/lib/types/components/__generated__/label.props.d.ts +2 -0
- package/lib/types/components/__generated__/radio-button-field.props.d.ts +2 -0
- package/lib/types/components/__generated__/radio-button.props.d.ts +2 -0
- package/lib/types/components/__generated__/success-message.props.d.ts +2 -0
- package/lib/types/components/__generated__/textarea.props.d.ts +2 -0
- package/lib/types/components/box.stories.d.ts +2 -2
- package/lib/types/components/checkbox-field.d.ts +3 -0
- package/lib/types/components/checkbox-field.ws.d.ts +3 -0
- package/lib/types/components/checkbox.d.ts +3 -0
- package/lib/types/components/checkbox.ws.d.ts +3 -0
- package/lib/types/components/component-meta.d.ts +23 -5
- package/lib/types/components/components-utils.d.ts +5 -20
- package/lib/types/components/components.d.ts +8 -0
- package/lib/types/components/error-message.d.ts +3 -0
- package/lib/types/components/error-message.ws.d.ts +3 -0
- package/lib/types/components/index.d.ts +1 -0
- package/lib/types/components/input.d.ts +3 -1
- package/lib/types/components/input.stories.d.ts +6 -2
- package/lib/types/components/label.d.ts +3 -0
- package/lib/types/components/label.ws.d.ts +3 -0
- package/lib/types/components/radio-button-field.d.ts +3 -0
- package/lib/types/components/radio-button-field.ws.d.ts +3 -0
- package/lib/types/components/radio-button.d.ts +3 -0
- package/lib/types/components/radio-button.ws.d.ts +3 -0
- package/lib/types/components/success-message.d.ts +3 -0
- package/lib/types/components/success-message.ws.d.ts +3 -0
- package/lib/types/components/textarea.d.ts +3 -0
- package/lib/types/components/textarea.ws.d.ts +3 -0
- package/lib/types/css/normalize.d.ts +8977 -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 +15 -14
- package/src/app/custom-components/__generated__/form.props.ts +457 -0
- package/src/app/custom-components/__generated__/image.props.ts +487 -0
- package/src/app/custom-components/__generated__/link-block.props.ts +477 -0
- package/src/app/custom-components/__generated__/link.props.ts +477 -0
- package/src/app/custom-components/__generated__/rich-text-link.props.ts +477 -0
- package/src/app/custom-components/form.tsx +94 -0
- package/src/app/custom-components/form.ws.tsx +86 -0
- package/src/app/custom-components/index.ts +9 -4
- package/src/components/__generated__/checkbox-field.props.ts +444 -0
- package/src/components/__generated__/checkbox.props.ts +484 -0
- package/src/components/__generated__/error-message.props.ts +443 -0
- package/src/components/__generated__/input.props.ts +8 -3
- package/src/components/__generated__/label.props.ts +445 -0
- package/src/components/__generated__/radio-button-field.props.ts +444 -0
- package/src/components/__generated__/radio-button.props.ts +484 -0
- package/src/components/__generated__/success-message.props.ts +443 -0
- package/src/components/__generated__/textarea.props.ts +457 -0
- 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 +13 -5
- package/src/components/checkbox-field.tsx +10 -0
- package/src/components/checkbox-field.ws.tsx +38 -0
- package/src/components/checkbox.tsx +13 -0
- package/src/components/checkbox.ws.tsx +40 -0
- package/src/components/code.ws.tsx +26 -32
- package/src/components/component-meta.ts +6 -3
- package/src/components/components-utils.ts +16 -10
- package/src/components/components.ts +8 -0
- package/src/components/error-message.tsx +10 -0
- package/src/components/error-message.ws.tsx +24 -0
- package/src/components/form.tsx +5 -1
- package/src/components/form.ws.tsx +39 -10
- package/src/components/heading.ws.tsx +7 -4
- package/src/components/image.ws.tsx +14 -12
- package/src/components/index.ts +47 -0
- package/src/components/input.tsx +3 -1
- package/src/components/input.ws.tsx +19 -4
- package/src/components/italic.ws.tsx +11 -8
- package/src/components/label.tsx +10 -0
- package/src/components/label.ws.tsx +39 -0
- package/src/components/link-block.ws.tsx +13 -10
- package/src/components/link.ws.tsx +15 -13
- package/src/components/list-item.ws.tsx +8 -4
- package/src/components/list.ws.tsx +28 -25
- package/src/components/paragraph.ws.tsx +7 -4
- package/src/components/radio-button-field.tsx +10 -0
- package/src/components/radio-button-field.ws.tsx +38 -0
- package/src/components/radio-button.tsx +13 -0
- package/src/components/radio-button.ws.tsx +40 -0
- 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/success-message.tsx +10 -0
- package/src/components/success-message.ws.tsx +24 -0
- package/src/components/superscript.ws.tsx +6 -3
- package/src/components/text-block.ws.tsx +12 -11
- package/src/components/textarea.tsx +13 -0
- package/src/components/textarea.ws.tsx +41 -0
- package/src/css/css.ts +8 -11
- package/src/css/normalize.ts +166 -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/css/normalize.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { borders } from "./presets";
|
|
2
2
|
const boxSizing = {
|
|
3
|
-
|
|
4
|
-
value: "border-box"
|
|
5
|
-
};
|
|
6
|
-
const baseStyle = {
|
|
7
|
-
boxSizing,
|
|
8
|
-
...borders
|
|
3
|
+
property: "boxSizing",
|
|
4
|
+
value: { type: "keyword", value: "border-box" }
|
|
9
5
|
};
|
|
6
|
+
const baseStyle = [boxSizing, ...borders];
|
|
10
7
|
const div = baseStyle;
|
|
11
8
|
const address = baseStyle;
|
|
12
9
|
const article = baseStyle;
|
|
@@ -18,6 +15,7 @@ const main = baseStyle;
|
|
|
18
15
|
const nav = baseStyle;
|
|
19
16
|
const section = baseStyle;
|
|
20
17
|
const form = baseStyle;
|
|
18
|
+
const label = baseStyle;
|
|
21
19
|
const h1 = baseStyle;
|
|
22
20
|
const h2 = baseStyle;
|
|
23
21
|
const h3 = baseStyle;
|
|
@@ -32,262 +30,246 @@ const ul = baseStyle;
|
|
|
32
30
|
const ol = baseStyle;
|
|
33
31
|
const p = baseStyle;
|
|
34
32
|
const span = baseStyle;
|
|
35
|
-
const html =
|
|
33
|
+
const html = [
|
|
36
34
|
/* 1 */
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
value: 1.15,
|
|
40
|
-
unit: "number"
|
|
35
|
+
{
|
|
36
|
+
property: "lineHeight",
|
|
37
|
+
value: { type: "unit", value: 1.15, unit: "number" }
|
|
41
38
|
},
|
|
42
39
|
/* 2 */
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
value: 100,
|
|
46
|
-
unit: "%"
|
|
40
|
+
{
|
|
41
|
+
property: "textSizeAdjust",
|
|
42
|
+
value: { type: "unit", value: 100, unit: "%" }
|
|
47
43
|
},
|
|
48
44
|
/* 3 */
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
value: 4,
|
|
52
|
-
unit: "number"
|
|
45
|
+
{
|
|
46
|
+
property: "tabSize",
|
|
47
|
+
value: { type: "unit", value: 4, unit: "number" }
|
|
53
48
|
},
|
|
54
49
|
boxSizing,
|
|
55
50
|
...borders
|
|
56
|
-
|
|
57
|
-
const body =
|
|
51
|
+
];
|
|
52
|
+
const body = [
|
|
58
53
|
/* 1 */
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
value: 0,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type: "unit",
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
marginLeft: {
|
|
75
|
-
type: "unit",
|
|
76
|
-
value: 0,
|
|
77
|
-
unit: "number"
|
|
54
|
+
{
|
|
55
|
+
property: "marginTop",
|
|
56
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
property: "marginRight",
|
|
60
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
property: "marginBottom",
|
|
64
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
property: "marginLeft",
|
|
68
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
78
69
|
},
|
|
79
70
|
/* 2 */
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
value:
|
|
71
|
+
{
|
|
72
|
+
property: "fontFamily",
|
|
73
|
+
value: {
|
|
74
|
+
type: "keyword",
|
|
75
|
+
value: `system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'`
|
|
76
|
+
}
|
|
83
77
|
},
|
|
84
78
|
boxSizing,
|
|
85
79
|
...borders
|
|
86
|
-
|
|
87
|
-
const hr =
|
|
80
|
+
];
|
|
81
|
+
const hr = [
|
|
88
82
|
/* 1 */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
value: 0,
|
|
92
|
-
unit: "number"
|
|
83
|
+
{
|
|
84
|
+
property: "height",
|
|
85
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
93
86
|
},
|
|
94
87
|
/* 2 */
|
|
95
|
-
|
|
88
|
+
{
|
|
89
|
+
property: "color",
|
|
90
|
+
value: { type: "keyword", value: "inherit" }
|
|
91
|
+
},
|
|
96
92
|
boxSizing,
|
|
97
93
|
...borders
|
|
98
|
-
|
|
99
|
-
const b =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
value: "
|
|
94
|
+
];
|
|
95
|
+
const b = [
|
|
96
|
+
{
|
|
97
|
+
property: "fontWeight",
|
|
98
|
+
value: { type: "keyword", value: "700" }
|
|
103
99
|
},
|
|
104
100
|
boxSizing,
|
|
105
101
|
...borders
|
|
106
|
-
|
|
102
|
+
];
|
|
107
103
|
const strong = b;
|
|
108
|
-
const code =
|
|
104
|
+
const code = [
|
|
109
105
|
/* 1 */
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
value:
|
|
106
|
+
{
|
|
107
|
+
property: "fontFamily",
|
|
108
|
+
value: {
|
|
109
|
+
type: "keyword",
|
|
110
|
+
value: `ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace`
|
|
111
|
+
}
|
|
113
112
|
},
|
|
114
113
|
/* 2 */
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
value: 1,
|
|
118
|
-
unit: "em"
|
|
114
|
+
{
|
|
115
|
+
property: "fontSize",
|
|
116
|
+
value: { type: "unit", value: 1, unit: "em" }
|
|
119
117
|
},
|
|
120
118
|
boxSizing,
|
|
121
119
|
...borders
|
|
122
|
-
|
|
120
|
+
];
|
|
123
121
|
const kbd = code;
|
|
124
122
|
const samp = code;
|
|
125
123
|
const pre = code;
|
|
126
|
-
const small =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
value: 80,
|
|
130
|
-
unit: "%"
|
|
124
|
+
const small = [
|
|
125
|
+
{
|
|
126
|
+
property: "fontSize",
|
|
127
|
+
value: { type: "unit", value: 80, unit: "%" }
|
|
131
128
|
},
|
|
132
129
|
boxSizing,
|
|
133
130
|
...borders
|
|
134
|
-
|
|
135
|
-
const subSupBase =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
value: 75,
|
|
139
|
-
unit: "%"
|
|
131
|
+
];
|
|
132
|
+
const subSupBase = [
|
|
133
|
+
{
|
|
134
|
+
property: "fontSize",
|
|
135
|
+
value: { type: "unit", value: 75, unit: "%" }
|
|
140
136
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
value: 0,
|
|
144
|
-
unit: "number"
|
|
137
|
+
{
|
|
138
|
+
property: "lineHeight",
|
|
139
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
145
140
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
value: "relative"
|
|
141
|
+
{
|
|
142
|
+
property: "position",
|
|
143
|
+
value: { type: "keyword", value: "relative" }
|
|
149
144
|
},
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
value: "baseline"
|
|
145
|
+
{
|
|
146
|
+
property: "verticalAlign",
|
|
147
|
+
value: { type: "keyword", value: "baseline" }
|
|
153
148
|
},
|
|
154
149
|
boxSizing,
|
|
155
150
|
...borders
|
|
156
|
-
|
|
157
|
-
const sub =
|
|
151
|
+
];
|
|
152
|
+
const sub = [
|
|
158
153
|
...subSupBase,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
value: -0.25,
|
|
162
|
-
unit: "em"
|
|
154
|
+
{
|
|
155
|
+
property: "bottom",
|
|
156
|
+
value: { type: "unit", value: -0.25, unit: "em" }
|
|
163
157
|
}
|
|
164
|
-
|
|
165
|
-
const sup =
|
|
158
|
+
];
|
|
159
|
+
const sup = [
|
|
166
160
|
...subSupBase,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
value: -0.5,
|
|
170
|
-
unit: "em"
|
|
161
|
+
{
|
|
162
|
+
property: "top",
|
|
163
|
+
value: { type: "unit", value: -0.5, unit: "em" }
|
|
171
164
|
}
|
|
172
|
-
|
|
173
|
-
const table =
|
|
165
|
+
];
|
|
166
|
+
const table = [
|
|
174
167
|
/* 1 */
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
value: 0,
|
|
178
|
-
unit: "number"
|
|
168
|
+
{
|
|
169
|
+
property: "textIndent",
|
|
170
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
179
171
|
},
|
|
180
172
|
...borders,
|
|
181
173
|
/* 2 */
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
value: "inherit"
|
|
174
|
+
{
|
|
175
|
+
property: "borderTopColor",
|
|
176
|
+
value: { type: "keyword", value: "inherit" }
|
|
185
177
|
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
value: "inherit"
|
|
178
|
+
{
|
|
179
|
+
property: "borderRightColor",
|
|
180
|
+
value: { type: "keyword", value: "inherit" }
|
|
189
181
|
},
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
value: "inherit"
|
|
182
|
+
{
|
|
183
|
+
property: "borderBottomColor",
|
|
184
|
+
value: { type: "keyword", value: "inherit" }
|
|
193
185
|
},
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
value: "inherit"
|
|
186
|
+
{
|
|
187
|
+
property: "borderLeftColor",
|
|
188
|
+
value: { type: "keyword", value: "inherit" }
|
|
197
189
|
},
|
|
198
190
|
boxSizing
|
|
199
|
-
|
|
200
|
-
const buttonBase =
|
|
191
|
+
];
|
|
192
|
+
const buttonBase = [
|
|
201
193
|
/* 1 */
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
value: "inherit"
|
|
194
|
+
{
|
|
195
|
+
property: "fontFamily",
|
|
196
|
+
value: { type: "keyword", value: "inherit" }
|
|
205
197
|
},
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
value: 100,
|
|
209
|
-
unit: "%"
|
|
198
|
+
{
|
|
199
|
+
property: "fontSize",
|
|
200
|
+
value: { type: "unit", value: 100, unit: "%" }
|
|
210
201
|
},
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
value: 1.15,
|
|
214
|
-
unit: "number"
|
|
202
|
+
{
|
|
203
|
+
property: "lineHeight",
|
|
204
|
+
value: { type: "unit", value: 1.15, unit: "number" }
|
|
215
205
|
},
|
|
216
206
|
/* 2 */
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
value: 0,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
type: "unit",
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
marginLeft: {
|
|
233
|
-
type: "unit",
|
|
234
|
-
value: 0,
|
|
235
|
-
unit: "number"
|
|
207
|
+
{
|
|
208
|
+
property: "marginTop",
|
|
209
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
property: "marginRight",
|
|
213
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
property: "marginBottom",
|
|
217
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
property: "marginLeft",
|
|
221
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
236
222
|
},
|
|
237
223
|
boxSizing,
|
|
238
224
|
...borders
|
|
239
|
-
|
|
225
|
+
];
|
|
240
226
|
const input = buttonBase;
|
|
241
227
|
const optgroup = buttonBase;
|
|
242
228
|
const textarea = buttonBase;
|
|
243
|
-
const button =
|
|
229
|
+
const button = [
|
|
244
230
|
...buttonBase,
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
value: "none"
|
|
231
|
+
{
|
|
232
|
+
property: "textTransform",
|
|
233
|
+
value: { type: "keyword", value: "none" }
|
|
248
234
|
}
|
|
249
|
-
|
|
235
|
+
];
|
|
250
236
|
const select = button;
|
|
251
|
-
const legend =
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
value: 0,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
type: "unit",
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
paddingLeft: {
|
|
268
|
-
type: "unit",
|
|
269
|
-
value: 0,
|
|
270
|
-
unit: "number"
|
|
237
|
+
const legend = [
|
|
238
|
+
{
|
|
239
|
+
property: "paddingTop",
|
|
240
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
property: "paddingRight",
|
|
244
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
property: "paddingBottom",
|
|
248
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
property: "paddingLeft",
|
|
252
|
+
value: { type: "unit", value: 0, unit: "number" }
|
|
271
253
|
},
|
|
272
254
|
boxSizing,
|
|
273
255
|
...borders
|
|
274
|
-
|
|
275
|
-
const progress =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
value: "baseline"
|
|
256
|
+
];
|
|
257
|
+
const progress = [
|
|
258
|
+
{
|
|
259
|
+
property: "verticalAlign",
|
|
260
|
+
value: { type: "keyword", value: "baseline" }
|
|
279
261
|
},
|
|
280
262
|
boxSizing,
|
|
281
263
|
...borders
|
|
282
|
-
|
|
283
|
-
const summary =
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
value: "list-item"
|
|
264
|
+
];
|
|
265
|
+
const summary = [
|
|
266
|
+
{
|
|
267
|
+
property: "display",
|
|
268
|
+
value: { type: "keyword", value: "list-item" }
|
|
287
269
|
},
|
|
288
270
|
boxSizing,
|
|
289
271
|
...borders
|
|
290
|
-
|
|
272
|
+
];
|
|
291
273
|
export {
|
|
292
274
|
a,
|
|
293
275
|
address,
|
|
@@ -314,6 +296,7 @@ export {
|
|
|
314
296
|
img,
|
|
315
297
|
input,
|
|
316
298
|
kbd,
|
|
299
|
+
label,
|
|
317
300
|
legend,
|
|
318
301
|
li,
|
|
319
302
|
main,
|
package/lib/css/presets.js
CHANGED
|
@@ -1,41 +1,21 @@
|
|
|
1
|
-
const borders =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: "
|
|
1
|
+
const borders = [
|
|
2
|
+
{
|
|
3
|
+
property: "borderTopWidth",
|
|
4
|
+
value: { type: "unit", value: 1, unit: "px" }
|
|
5
5
|
},
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
value: "
|
|
6
|
+
{
|
|
7
|
+
property: "borderRightWidth",
|
|
8
|
+
value: { type: "unit", value: 1, unit: "px" }
|
|
9
9
|
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
value: "
|
|
10
|
+
{
|
|
11
|
+
property: "borderBottomWidth",
|
|
12
|
+
value: { type: "unit", value: 1, unit: "px" }
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
value: "
|
|
17
|
-
},
|
|
18
|
-
borderTopWidth: {
|
|
19
|
-
type: "unit",
|
|
20
|
-
value: 1,
|
|
21
|
-
unit: "px"
|
|
22
|
-
},
|
|
23
|
-
borderRightWidth: {
|
|
24
|
-
type: "unit",
|
|
25
|
-
value: 1,
|
|
26
|
-
unit: "px"
|
|
27
|
-
},
|
|
28
|
-
borderBottomWidth: {
|
|
29
|
-
type: "unit",
|
|
30
|
-
value: 1,
|
|
31
|
-
unit: "px"
|
|
32
|
-
},
|
|
33
|
-
borderLeftWidth: {
|
|
34
|
-
type: "unit",
|
|
35
|
-
value: 1,
|
|
36
|
-
unit: "px"
|
|
14
|
+
{
|
|
15
|
+
property: "borderLeftWidth",
|
|
16
|
+
value: { type: "unit", value: 1, unit: "px" }
|
|
37
17
|
}
|
|
38
|
-
|
|
18
|
+
];
|
|
39
19
|
export {
|
|
40
20
|
borders
|
|
41
21
|
};
|
package/lib/css/style-rules.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { componentAttribute } from "../tree";
|
|
1
2
|
const getStyleRules = (styles, styleSourceSelections) => {
|
|
2
3
|
if (styles === void 0 || styleSourceSelections === void 0) {
|
|
3
4
|
return [];
|
|
@@ -44,6 +45,22 @@ const getStyleRules = (styles, styleSourceSelections) => {
|
|
|
44
45
|
}
|
|
45
46
|
return styleRules;
|
|
46
47
|
};
|
|
48
|
+
const getPresetStyleRules = (component, presetStyle) => {
|
|
49
|
+
const presetStyleRules = /* @__PURE__ */ new Map();
|
|
50
|
+
for (const [tag, styles] of Object.entries(presetStyle)) {
|
|
51
|
+
for (const styleDecl of styles) {
|
|
52
|
+
const selector = `${tag}:where([${componentAttribute}=${component}])${styleDecl.state ?? ""}`;
|
|
53
|
+
let rule = presetStyleRules.get(selector);
|
|
54
|
+
if (rule === void 0) {
|
|
55
|
+
rule = {};
|
|
56
|
+
presetStyleRules.set(selector, rule);
|
|
57
|
+
}
|
|
58
|
+
rule[styleDecl.property] = styleDecl.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return presetStyleRules;
|
|
62
|
+
};
|
|
47
63
|
export {
|
|
64
|
+
getPresetStyleRules,
|
|
48
65
|
getStyleRules
|
|
49
66
|
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { nanoid } from "nanoid";
|
|
3
|
+
import { StyleValue } from "@webstudio-is/css-data";
|
|
4
|
+
const EmbedTemplateText = z.object({
|
|
5
|
+
type: z.literal("text"),
|
|
6
|
+
value: z.string()
|
|
7
|
+
});
|
|
8
|
+
const EmbedTemplateProp = z.union([
|
|
9
|
+
z.object({
|
|
10
|
+
type: z.literal("number"),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
value: z.number()
|
|
13
|
+
}),
|
|
14
|
+
z.object({
|
|
15
|
+
type: z.literal("string"),
|
|
16
|
+
name: z.string(),
|
|
17
|
+
value: z.string()
|
|
18
|
+
}),
|
|
19
|
+
z.object({
|
|
20
|
+
type: z.literal("boolean"),
|
|
21
|
+
name: z.string(),
|
|
22
|
+
value: z.boolean()
|
|
23
|
+
}),
|
|
24
|
+
z.object({
|
|
25
|
+
type: z.literal("string[]"),
|
|
26
|
+
name: z.string(),
|
|
27
|
+
value: z.array(z.string())
|
|
28
|
+
})
|
|
29
|
+
]);
|
|
30
|
+
const EmbedTemplateStyleDecl = z.object({
|
|
31
|
+
state: z.optional(z.string()),
|
|
32
|
+
property: z.string(),
|
|
33
|
+
value: StyleValue
|
|
34
|
+
});
|
|
35
|
+
const EmbedTemplateInstance = z.lazy(
|
|
36
|
+
() => z.object({
|
|
37
|
+
type: z.literal("instance"),
|
|
38
|
+
component: z.string(),
|
|
39
|
+
props: z.optional(z.array(EmbedTemplateProp)),
|
|
40
|
+
styles: z.optional(z.array(EmbedTemplateStyleDecl)),
|
|
41
|
+
children: WsEmbedTemplate
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
const WsEmbedTemplate = z.lazy(
|
|
45
|
+
() => z.array(z.union([EmbedTemplateInstance, EmbedTemplateText]))
|
|
46
|
+
);
|
|
47
|
+
const createInstancesFromTemplate = (treeTemplate, instances, props, styleSourceSelections, styleSources, styles, defaultBreakpointId) => {
|
|
48
|
+
const parentChildren = [];
|
|
49
|
+
for (const item of treeTemplate) {
|
|
50
|
+
if (item.type === "instance") {
|
|
51
|
+
const instanceId = nanoid();
|
|
52
|
+
if (item.props) {
|
|
53
|
+
for (const prop of item.props) {
|
|
54
|
+
props.push({
|
|
55
|
+
id: nanoid(),
|
|
56
|
+
instanceId,
|
|
57
|
+
...prop
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (item.styles) {
|
|
62
|
+
const styleSourceId = nanoid();
|
|
63
|
+
styleSources.push({
|
|
64
|
+
type: "local",
|
|
65
|
+
id: styleSourceId
|
|
66
|
+
});
|
|
67
|
+
styleSourceSelections.push({
|
|
68
|
+
instanceId,
|
|
69
|
+
values: [styleSourceId]
|
|
70
|
+
});
|
|
71
|
+
for (const styleDecl of item.styles) {
|
|
72
|
+
styles.push({
|
|
73
|
+
breakpointId: defaultBreakpointId,
|
|
74
|
+
styleSourceId,
|
|
75
|
+
state: styleDecl.state,
|
|
76
|
+
property: styleDecl.property,
|
|
77
|
+
value: styleDecl.value
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const instance = {
|
|
82
|
+
type: "instance",
|
|
83
|
+
id: instanceId,
|
|
84
|
+
component: item.component,
|
|
85
|
+
children: []
|
|
86
|
+
};
|
|
87
|
+
instances.push(instance);
|
|
88
|
+
instance.children = createInstancesFromTemplate(
|
|
89
|
+
item.children,
|
|
90
|
+
instances,
|
|
91
|
+
props,
|
|
92
|
+
styleSourceSelections,
|
|
93
|
+
styleSources,
|
|
94
|
+
styles,
|
|
95
|
+
defaultBreakpointId
|
|
96
|
+
);
|
|
97
|
+
parentChildren.push({
|
|
98
|
+
type: "id",
|
|
99
|
+
value: instanceId
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (item.type === "text") {
|
|
103
|
+
parentChildren.push({
|
|
104
|
+
type: "text",
|
|
105
|
+
value: item.value
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return parentChildren;
|
|
110
|
+
};
|
|
111
|
+
const generateDataFromEmbedTemplate = (treeTemplate, defaultBreakpointId) => {
|
|
112
|
+
const instances = [];
|
|
113
|
+
const props = [];
|
|
114
|
+
const styleSourceSelections = [];
|
|
115
|
+
const styleSources = [];
|
|
116
|
+
const styles = [];
|
|
117
|
+
const children = createInstancesFromTemplate(
|
|
118
|
+
treeTemplate,
|
|
119
|
+
instances,
|
|
120
|
+
props,
|
|
121
|
+
styleSourceSelections,
|
|
122
|
+
styleSources,
|
|
123
|
+
styles,
|
|
124
|
+
defaultBreakpointId
|
|
125
|
+
);
|
|
126
|
+
return {
|
|
127
|
+
children,
|
|
128
|
+
instances,
|
|
129
|
+
props,
|
|
130
|
+
styleSourceSelections,
|
|
131
|
+
styleSources,
|
|
132
|
+
styles
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export {
|
|
136
|
+
EmbedTemplateInstance,
|
|
137
|
+
EmbedTemplateStyleDecl,
|
|
138
|
+
WsEmbedTemplate,
|
|
139
|
+
generateDataFromEmbedTemplate
|
|
140
|
+
};
|
package/lib/index.js
CHANGED