@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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FormTextAreaIcon } from "@webstudio-is/icons";
|
|
2
|
+
import { textarea } from "../css/normalize";
|
|
3
|
+
import type {
|
|
4
|
+
WsComponentMeta,
|
|
5
|
+
WsComponentPropsMeta,
|
|
6
|
+
PresetStyle,
|
|
7
|
+
} from "./component-meta";
|
|
8
|
+
import type { defaultTag } from "./textarea";
|
|
9
|
+
import { props } from "./__generated__/textarea.props";
|
|
10
|
+
|
|
11
|
+
const presetStyle = {
|
|
12
|
+
textarea: [
|
|
13
|
+
...textarea,
|
|
14
|
+
// resize doesn't work well while on canvas
|
|
15
|
+
{ property: "resize", value: { type: "keyword", value: "none" } },
|
|
16
|
+
],
|
|
17
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
18
|
+
|
|
19
|
+
export const meta: WsComponentMeta = {
|
|
20
|
+
category: "forms",
|
|
21
|
+
type: "control",
|
|
22
|
+
label: "Text Area",
|
|
23
|
+
Icon: FormTextAreaIcon,
|
|
24
|
+
presetStyle,
|
|
25
|
+
states: [
|
|
26
|
+
{ selector: "::placeholder", label: "Placeholder" },
|
|
27
|
+
{ selector: ":valid", label: "Valid" },
|
|
28
|
+
{ selector: ":invalid", label: "Invalid" },
|
|
29
|
+
{ selector: ":required", label: "Required" },
|
|
30
|
+
{ selector: ":optional", label: "Optional" },
|
|
31
|
+
{ selector: ":disabled", label: "Disabled" },
|
|
32
|
+
{ selector: ":enabled", label: "Enabled" },
|
|
33
|
+
{ selector: ":read-only", label: "Read Only" },
|
|
34
|
+
{ selector: ":read-write", label: "Read Write" },
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const propsMeta: WsComponentPropsMeta = {
|
|
39
|
+
props,
|
|
40
|
+
initialProps: ["name", "placeholder", "required", "autoFocus"],
|
|
41
|
+
};
|
package/src/css/css.ts
CHANGED
|
@@ -3,9 +3,9 @@ import type { Asset, Assets } from "@webstudio-is/asset-uploader";
|
|
|
3
3
|
import type { Build } from "@webstudio-is/project-build";
|
|
4
4
|
import { getComponentNames } from "../components/components-utils";
|
|
5
5
|
import { getComponentMeta } from "../components";
|
|
6
|
-
import {
|
|
6
|
+
import { idAttribute } from "../tree";
|
|
7
7
|
import { addGlobalRules } from "./global-rules";
|
|
8
|
-
import { getStyleRules } from "./style-rules";
|
|
8
|
+
import { getPresetStyleRules, getStyleRules } from "./style-rules";
|
|
9
9
|
|
|
10
10
|
type Data = {
|
|
11
11
|
assets: Asset[];
|
|
@@ -64,15 +64,12 @@ export const generateCssText = (data: Data, options: CssOptions) => {
|
|
|
64
64
|
for (const component of getComponentNames()) {
|
|
65
65
|
const meta = getComponentMeta(component);
|
|
66
66
|
const presetStyle = meta?.presetStyle;
|
|
67
|
-
if (presetStyle
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
}
|
|
67
|
+
if (presetStyle === undefined) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const rules = getPresetStyleRules(component, presetStyle);
|
|
71
|
+
for (const [selector, style] of rules) {
|
|
72
|
+
engine.addStyleRule(selector, { style });
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
|
package/src/css/normalize.ts
CHANGED
|
@@ -15,18 +15,17 @@
|
|
|
15
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
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
19
|
-
|
|
20
18
|
// webstudio custom opinionated presets
|
|
21
19
|
import { borders } from "./presets";
|
|
20
|
+
import type { EmbedTemplateStyleDecl } from "../embed-template";
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
Use a better box model (opinionated).
|
|
25
24
|
*/
|
|
26
25
|
const boxSizing = {
|
|
27
|
-
|
|
28
|
-
value: "border-box",
|
|
29
|
-
}
|
|
26
|
+
property: "boxSizing",
|
|
27
|
+
value: { type: "keyword", value: "border-box" },
|
|
28
|
+
} satisfies EmbedTemplateStyleDecl;
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* We dont support rules like this now, implement boxSizing for each used element
|
|
@@ -36,10 +35,7 @@ const boxSizing = {
|
|
|
36
35
|
* box-sizing: border-box;
|
|
37
36
|
}
|
|
38
37
|
*/
|
|
39
|
-
const baseStyle =
|
|
40
|
-
boxSizing,
|
|
41
|
-
...borders,
|
|
42
|
-
} as const satisfies Style;
|
|
38
|
+
const baseStyle = [boxSizing, ...borders] satisfies EmbedTemplateStyleDecl[];
|
|
43
39
|
|
|
44
40
|
export const div = baseStyle;
|
|
45
41
|
export const address = baseStyle;
|
|
@@ -52,6 +48,7 @@ export const main = baseStyle;
|
|
|
52
48
|
export const nav = baseStyle;
|
|
53
49
|
export const section = baseStyle;
|
|
54
50
|
export const form = baseStyle;
|
|
51
|
+
export const label = baseStyle;
|
|
55
52
|
|
|
56
53
|
export const h1 = baseStyle;
|
|
57
54
|
export const h2 = baseStyle;
|
|
@@ -78,83 +75,78 @@ export const span = baseStyle;
|
|
|
78
75
|
2. Prevent adjustments of font size after orientation changes in iOS.
|
|
79
76
|
3. Use a more readable tab size (opinionated).
|
|
80
77
|
*/
|
|
81
|
-
export const html =
|
|
78
|
+
export const html = [
|
|
82
79
|
/* 1 */
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
value: 1.15,
|
|
86
|
-
unit: "number",
|
|
80
|
+
{
|
|
81
|
+
property: "lineHeight",
|
|
82
|
+
value: { type: "unit", value: 1.15, unit: "number" },
|
|
87
83
|
},
|
|
88
|
-
|
|
89
84
|
/* 2 */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
value: 100,
|
|
93
|
-
unit: "%",
|
|
85
|
+
{
|
|
86
|
+
property: "textSizeAdjust",
|
|
87
|
+
value: { type: "unit", value: 100, unit: "%" },
|
|
94
88
|
},
|
|
95
|
-
|
|
96
89
|
/* 3 */
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
value: 4,
|
|
100
|
-
unit: "number",
|
|
90
|
+
{
|
|
91
|
+
property: "tabSize",
|
|
92
|
+
value: { type: "unit", value: 4, unit: "number" },
|
|
101
93
|
},
|
|
102
|
-
|
|
103
94
|
boxSizing,
|
|
104
95
|
...borders,
|
|
105
|
-
|
|
96
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
106
97
|
|
|
107
98
|
/**
|
|
108
99
|
1. Remove the margin in all browsers.
|
|
109
100
|
2. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
|
|
110
101
|
*/
|
|
111
|
-
export const body =
|
|
102
|
+
export const body = [
|
|
112
103
|
/* 1 */
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
value: 0,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
type: "unit",
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
marginLeft: {
|
|
129
|
-
type: "unit",
|
|
130
|
-
value: 0,
|
|
131
|
-
unit: "number",
|
|
104
|
+
{
|
|
105
|
+
property: "marginTop",
|
|
106
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
property: "marginRight",
|
|
110
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
property: "marginBottom",
|
|
114
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
property: "marginLeft",
|
|
118
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
132
119
|
},
|
|
133
120
|
/* 2 */
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
value:
|
|
121
|
+
{
|
|
122
|
+
property: "fontFamily",
|
|
123
|
+
value: {
|
|
124
|
+
type: "keyword",
|
|
125
|
+
value: `system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'`,
|
|
126
|
+
},
|
|
137
127
|
},
|
|
138
128
|
boxSizing,
|
|
139
129
|
...borders,
|
|
140
|
-
|
|
130
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
141
131
|
|
|
142
132
|
/**
|
|
143
133
|
1. Add the correct height in Firefox.
|
|
144
134
|
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
|
|
145
135
|
*/
|
|
146
|
-
export const hr =
|
|
136
|
+
export const hr = [
|
|
147
137
|
/* 1 */
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
value: 0,
|
|
151
|
-
unit: "number",
|
|
138
|
+
{
|
|
139
|
+
property: "height",
|
|
140
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
152
141
|
},
|
|
153
142
|
/* 2 */
|
|
154
|
-
|
|
143
|
+
{
|
|
144
|
+
property: "color",
|
|
145
|
+
value: { type: "keyword", value: "inherit" },
|
|
146
|
+
},
|
|
155
147
|
boxSizing,
|
|
156
148
|
...borders,
|
|
157
|
-
|
|
149
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
158
150
|
|
|
159
151
|
/**
|
|
160
152
|
Add the correct text decoration in Chrome, Edge, and Safari.
|
|
@@ -169,35 +161,37 @@ abbr[title] {
|
|
|
169
161
|
/**
|
|
170
162
|
Add the correct font weight in Edge and Safari.
|
|
171
163
|
*/
|
|
172
|
-
export const b =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
value: "
|
|
164
|
+
export const b = [
|
|
165
|
+
{
|
|
166
|
+
property: "fontWeight",
|
|
167
|
+
value: { type: "keyword", value: "700" },
|
|
176
168
|
},
|
|
177
169
|
boxSizing,
|
|
178
170
|
...borders,
|
|
179
|
-
|
|
171
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
180
172
|
export const strong = b;
|
|
181
173
|
|
|
182
174
|
/**
|
|
183
175
|
1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
|
|
184
176
|
2. Correct the odd 'em' font sizing in all browsers.
|
|
185
177
|
*/
|
|
186
|
-
export const code =
|
|
178
|
+
export const code = [
|
|
187
179
|
/* 1 */
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
value:
|
|
180
|
+
{
|
|
181
|
+
property: "fontFamily",
|
|
182
|
+
value: {
|
|
183
|
+
type: "keyword",
|
|
184
|
+
value: `ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace`,
|
|
185
|
+
},
|
|
191
186
|
},
|
|
192
187
|
/* 2 */
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
value: 1,
|
|
196
|
-
unit: "em",
|
|
188
|
+
{
|
|
189
|
+
property: "fontSize",
|
|
190
|
+
value: { type: "unit", value: 1, unit: "em" },
|
|
197
191
|
},
|
|
198
192
|
boxSizing,
|
|
199
193
|
...borders,
|
|
200
|
-
|
|
194
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
201
195
|
|
|
202
196
|
export const kbd = code;
|
|
203
197
|
export const samp = code;
|
|
@@ -207,60 +201,55 @@ export const pre = code;
|
|
|
207
201
|
Add the correct font size in all browsers.
|
|
208
202
|
*/
|
|
209
203
|
|
|
210
|
-
export const small =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
value: 80,
|
|
214
|
-
unit: "%",
|
|
204
|
+
export const small = [
|
|
205
|
+
{
|
|
206
|
+
property: "fontSize",
|
|
207
|
+
value: { type: "unit", value: 80, unit: "%" },
|
|
215
208
|
},
|
|
216
209
|
boxSizing,
|
|
217
210
|
...borders,
|
|
218
|
-
|
|
211
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
219
212
|
|
|
220
213
|
/**
|
|
221
214
|
Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
|
|
222
215
|
*/
|
|
223
216
|
|
|
224
|
-
const subSupBase =
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
value: 75,
|
|
228
|
-
unit: "%",
|
|
217
|
+
const subSupBase = [
|
|
218
|
+
{
|
|
219
|
+
property: "fontSize",
|
|
220
|
+
value: { type: "unit", value: 75, unit: "%" },
|
|
229
221
|
},
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
value: 0,
|
|
233
|
-
unit: "number",
|
|
222
|
+
{
|
|
223
|
+
property: "lineHeight",
|
|
224
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
234
225
|
},
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
value: "relative",
|
|
226
|
+
{
|
|
227
|
+
property: "position",
|
|
228
|
+
value: { type: "keyword", value: "relative" },
|
|
238
229
|
},
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
value: "baseline",
|
|
230
|
+
{
|
|
231
|
+
property: "verticalAlign",
|
|
232
|
+
value: { type: "keyword", value: "baseline" },
|
|
242
233
|
},
|
|
243
234
|
boxSizing,
|
|
244
235
|
...borders,
|
|
245
|
-
|
|
236
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
246
237
|
|
|
247
|
-
export const sub =
|
|
238
|
+
export const sub = [
|
|
248
239
|
...subSupBase,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
value: -0.25,
|
|
252
|
-
unit: "em",
|
|
240
|
+
{
|
|
241
|
+
property: "bottom",
|
|
242
|
+
value: { type: "unit", value: -0.25, unit: "em" },
|
|
253
243
|
},
|
|
254
|
-
|
|
244
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
255
245
|
|
|
256
|
-
export const sup =
|
|
246
|
+
export const sup = [
|
|
257
247
|
...subSupBase,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
value: -0.5,
|
|
261
|
-
unit: "em",
|
|
248
|
+
{
|
|
249
|
+
property: "top",
|
|
250
|
+
value: { type: "unit", value: -0.5, unit: "em" },
|
|
262
251
|
},
|
|
263
|
-
|
|
252
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
264
253
|
|
|
265
254
|
/*
|
|
266
255
|
Tabular data
|
|
@@ -272,33 +261,32 @@ Tabular data
|
|
|
272
261
|
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)
|
|
273
262
|
*/
|
|
274
263
|
|
|
275
|
-
export const table =
|
|
264
|
+
export const table = [
|
|
276
265
|
/* 1 */
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
value: 0,
|
|
280
|
-
unit: "number",
|
|
266
|
+
{
|
|
267
|
+
property: "textIndent",
|
|
268
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
281
269
|
},
|
|
282
270
|
...borders,
|
|
283
271
|
/* 2 */
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
value: "inherit",
|
|
272
|
+
{
|
|
273
|
+
property: "borderTopColor",
|
|
274
|
+
value: { type: "keyword", value: "inherit" },
|
|
287
275
|
},
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
value: "inherit",
|
|
276
|
+
{
|
|
277
|
+
property: "borderRightColor",
|
|
278
|
+
value: { type: "keyword", value: "inherit" },
|
|
291
279
|
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
value: "inherit",
|
|
280
|
+
{
|
|
281
|
+
property: "borderBottomColor",
|
|
282
|
+
value: { type: "keyword", value: "inherit" },
|
|
295
283
|
},
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
value: "inherit",
|
|
284
|
+
{
|
|
285
|
+
property: "borderLeftColor",
|
|
286
|
+
value: { type: "keyword", value: "inherit" },
|
|
299
287
|
},
|
|
300
288
|
boxSizing,
|
|
301
|
-
|
|
289
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
302
290
|
|
|
303
291
|
/*
|
|
304
292
|
Forms
|
|
@@ -310,46 +298,40 @@ Forms
|
|
|
310
298
|
2. Remove the margin in Firefox and Safari.
|
|
311
299
|
*/
|
|
312
300
|
|
|
313
|
-
const buttonBase =
|
|
301
|
+
const buttonBase = [
|
|
314
302
|
/* 1 */
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
value: "inherit",
|
|
303
|
+
{
|
|
304
|
+
property: "fontFamily",
|
|
305
|
+
value: { type: "keyword", value: "inherit" },
|
|
318
306
|
},
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
value: 100,
|
|
322
|
-
unit: "%",
|
|
307
|
+
{
|
|
308
|
+
property: "fontSize",
|
|
309
|
+
value: { type: "unit", value: 100, unit: "%" },
|
|
323
310
|
},
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
value: 1.15,
|
|
327
|
-
unit: "number",
|
|
311
|
+
{
|
|
312
|
+
property: "lineHeight",
|
|
313
|
+
value: { type: "unit", value: 1.15, unit: "number" },
|
|
328
314
|
},
|
|
329
315
|
/* 2 */
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
value: 0,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
type: "unit",
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
marginLeft: {
|
|
346
|
-
type: "unit",
|
|
347
|
-
value: 0,
|
|
348
|
-
unit: "number",
|
|
316
|
+
{
|
|
317
|
+
property: "marginTop",
|
|
318
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
property: "marginRight",
|
|
322
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
property: "marginBottom",
|
|
326
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
property: "marginLeft",
|
|
330
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
349
331
|
},
|
|
350
332
|
boxSizing,
|
|
351
333
|
...borders,
|
|
352
|
-
|
|
334
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
353
335
|
|
|
354
336
|
export const input = buttonBase;
|
|
355
337
|
export const optgroup = buttonBase;
|
|
@@ -358,13 +340,13 @@ export const textarea = buttonBase;
|
|
|
358
340
|
/**
|
|
359
341
|
Remove the inheritance of text transform in Edge and Firefox.
|
|
360
342
|
*/
|
|
361
|
-
export const button =
|
|
343
|
+
export const button = [
|
|
362
344
|
...buttonBase,
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
value: "none",
|
|
345
|
+
{
|
|
346
|
+
property: "textTransform",
|
|
347
|
+
value: { type: "keyword", value: "none" },
|
|
366
348
|
},
|
|
367
|
-
|
|
349
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
368
350
|
|
|
369
351
|
export const select = button;
|
|
370
352
|
|
|
@@ -417,43 +399,39 @@ See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d4
|
|
|
417
399
|
Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
|
|
418
400
|
*/
|
|
419
401
|
|
|
420
|
-
export const legend =
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
value: 0,
|
|
424
|
-
unit: "number",
|
|
402
|
+
export const legend = [
|
|
403
|
+
{
|
|
404
|
+
property: "paddingTop",
|
|
405
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
425
406
|
},
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
value: 0,
|
|
429
|
-
unit: "number",
|
|
407
|
+
{
|
|
408
|
+
property: "paddingRight",
|
|
409
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
430
410
|
},
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
value: 0,
|
|
434
|
-
unit: "number",
|
|
411
|
+
{
|
|
412
|
+
property: "paddingBottom",
|
|
413
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
435
414
|
},
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
value: 0,
|
|
439
|
-
unit: "number",
|
|
415
|
+
{
|
|
416
|
+
property: "paddingLeft",
|
|
417
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
440
418
|
},
|
|
441
419
|
boxSizing,
|
|
442
420
|
...borders,
|
|
443
|
-
|
|
421
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
444
422
|
|
|
445
423
|
/**
|
|
446
424
|
Add the correct vertical alignment in Chrome and Firefox.
|
|
447
425
|
*/
|
|
448
426
|
|
|
449
|
-
export const progress =
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
value: "baseline",
|
|
427
|
+
export const progress = [
|
|
428
|
+
{
|
|
429
|
+
property: "verticalAlign",
|
|
430
|
+
value: { type: "keyword", value: "baseline" },
|
|
453
431
|
},
|
|
454
432
|
boxSizing,
|
|
455
433
|
...borders,
|
|
456
|
-
|
|
434
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
457
435
|
|
|
458
436
|
/**
|
|
459
437
|
Correct the cursor style of increment and decrement buttons in Safari.
|
|
@@ -509,11 +487,11 @@ Interactive
|
|
|
509
487
|
Add the correct display in Chrome and Safari.
|
|
510
488
|
*/
|
|
511
489
|
|
|
512
|
-
export const summary =
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
value: "list-item",
|
|
490
|
+
export const summary = [
|
|
491
|
+
{
|
|
492
|
+
property: "display",
|
|
493
|
+
value: { type: "keyword", value: "list-item" },
|
|
516
494
|
},
|
|
517
495
|
boxSizing,
|
|
518
496
|
...borders,
|
|
519
|
-
|
|
497
|
+
] satisfies EmbedTemplateStyleDecl[];
|
package/src/css/presets.ts
CHANGED
|
@@ -1,42 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EmbedTemplateStyleDecl } from "../embed-template";
|
|
2
2
|
|
|
3
|
-
export const borders =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: "
|
|
3
|
+
export const borders: EmbedTemplateStyleDecl[] = [
|
|
4
|
+
{
|
|
5
|
+
property: "borderTopWidth",
|
|
6
|
+
value: { type: "unit", value: 1, unit: "px" },
|
|
7
7
|
},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
value: "
|
|
8
|
+
{
|
|
9
|
+
property: "borderRightWidth",
|
|
10
|
+
value: { type: "unit", value: 1, unit: "px" },
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
value: "
|
|
12
|
+
{
|
|
13
|
+
property: "borderBottomWidth",
|
|
14
|
+
value: { type: "unit", value: 1, unit: "px" },
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
value: "
|
|
16
|
+
{
|
|
17
|
+
property: "borderLeftWidth",
|
|
18
|
+
value: { type: "unit", value: 1, unit: "px" },
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
borderTopWidth: {
|
|
22
|
-
type: "unit",
|
|
23
|
-
value: 1,
|
|
24
|
-
unit: "px",
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
borderRightWidth: {
|
|
28
|
-
type: "unit",
|
|
29
|
-
value: 1,
|
|
30
|
-
unit: "px",
|
|
31
|
-
},
|
|
32
|
-
borderBottomWidth: {
|
|
33
|
-
type: "unit",
|
|
34
|
-
value: 1,
|
|
35
|
-
unit: "px",
|
|
36
|
-
},
|
|
37
|
-
borderLeftWidth: {
|
|
38
|
-
type: "unit",
|
|
39
|
-
value: 1,
|
|
40
|
-
unit: "px",
|
|
41
|
-
},
|
|
42
|
-
} as const satisfies Style;
|
|
20
|
+
];
|