@webstudio-is/react-sdk 0.60.0 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/blockquote.ws.js +36 -48
- package/lib/cjs/components/body.ws.js +20 -17
- package/lib/cjs/components/button.ws.js +1 -1
- package/lib/cjs/components/code.ws.js +20 -28
- package/lib/cjs/components/component-meta.js +2 -1
- package/lib/cjs/components/form.ws.js +14 -7
- package/lib/cjs/components/heading.ws.js +1 -1
- package/lib/cjs/components/image.ws.js +8 -9
- package/lib/cjs/components/italic.ws.js +5 -5
- package/lib/cjs/components/link-block.ws.js +5 -5
- package/lib/cjs/components/link.ws.js +9 -10
- package/lib/cjs/components/list-item.ws.js +1 -1
- package/lib/cjs/components/list.ws.js +22 -22
- package/lib/cjs/components/paragraph.ws.js +1 -1
- package/lib/cjs/components/separator.ws.js +20 -20
- package/lib/cjs/components/text-block.ws.js +6 -7
- package/lib/cjs/css/css.js +6 -9
- package/lib/cjs/css/normalize.js +166 -185
- package/lib/cjs/css/presets.js +14 -34
- package/lib/cjs/css/style-rules.js +17 -0
- package/lib/cjs/embed-template.js +160 -0
- package/lib/cjs/index.js +1 -0
- package/lib/components/blockquote.ws.js +36 -48
- package/lib/components/body.ws.js +20 -17
- package/lib/components/button.ws.js +1 -1
- package/lib/components/code.ws.js +20 -28
- package/lib/components/component-meta.js +2 -1
- package/lib/components/form.ws.js +14 -7
- package/lib/components/heading.ws.js +1 -1
- package/lib/components/image.ws.js +8 -9
- package/lib/components/italic.ws.js +5 -5
- package/lib/components/link-block.ws.js +5 -5
- package/lib/components/link.ws.js +9 -10
- package/lib/components/list-item.ws.js +1 -1
- package/lib/components/list.ws.js +22 -22
- package/lib/components/paragraph.ws.js +1 -1
- package/lib/components/separator.ws.js +20 -20
- package/lib/components/text-block.ws.js +6 -7
- package/lib/css/css.js +8 -11
- package/lib/css/normalize.js +166 -185
- package/lib/css/presets.js +14 -34
- package/lib/css/style-rules.js +17 -0
- package/lib/embed-template.js +140 -0
- package/lib/index.js +1 -0
- package/lib/types/components/box.stories.d.ts +2 -2
- package/lib/types/components/component-meta.d.ts +20 -5
- package/lib/types/components/components-utils.d.ts +1 -1
- package/lib/types/css/normalize.d.ts +8786 -2286
- package/lib/types/css/presets.d.ts +2 -38
- package/lib/types/css/style-rules.d.ts +11 -9
- package/lib/types/embed-template.d.ts +1725 -0
- package/lib/types/embed-template.test.d.ts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +14 -13
- package/src/components/blockquote.ws.tsx +42 -52
- package/src/components/body.ws.tsx +26 -23
- package/src/components/bold.ws.tsx +6 -3
- package/src/components/box.ws.ts +6 -3
- package/src/components/button.ws.tsx +7 -4
- package/src/components/code.ws.tsx +26 -32
- package/src/components/component-meta.ts +5 -3
- package/src/components/form.ws.tsx +19 -9
- package/src/components/heading.ws.tsx +7 -4
- package/src/components/image.ws.tsx +14 -12
- package/src/components/input.ws.tsx +6 -3
- package/src/components/italic.ws.tsx +11 -8
- package/src/components/link-block.ws.tsx +11 -8
- package/src/components/link.ws.tsx +15 -13
- package/src/components/list-item.ws.tsx +7 -4
- package/src/components/list.ws.tsx +28 -25
- package/src/components/paragraph.ws.tsx +7 -4
- package/src/components/separator.ws.tsx +26 -25
- package/src/components/span.ws.tsx +6 -3
- package/src/components/subscript.ws.tsx +6 -3
- package/src/components/superscript.ws.tsx +6 -3
- package/src/components/text-block.ws.tsx +12 -11
- package/src/css/css.ts +8 -11
- package/src/css/normalize.ts +165 -188
- package/src/css/presets.ts +15 -37
- package/src/css/style-rules.ts +24 -0
- package/src/embed-template.test.ts +210 -0
- package/src/embed-template.ts +187 -0
- package/src/index.ts +1 -0
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
2
1
|
import { LinkIcon } from "@webstudio-is/icons";
|
|
3
2
|
import { a } from "../css/normalize";
|
|
4
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
PresetStyle,
|
|
5
|
+
WsComponentMeta,
|
|
6
|
+
WsComponentPropsMeta,
|
|
7
|
+
} from "./component-meta";
|
|
5
8
|
import type { defaultTag } from "./link";
|
|
6
9
|
import { props } from "./__generated__/link.props";
|
|
7
10
|
|
|
8
11
|
const presetStyle = {
|
|
9
|
-
a:
|
|
12
|
+
a: [
|
|
10
13
|
...a,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
unit: "em",
|
|
14
|
-
value: 1,
|
|
14
|
+
{
|
|
15
|
+
property: "minHeight",
|
|
16
|
+
value: { type: "unit", unit: "em", value: 1 },
|
|
15
17
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
value: "inline-block",
|
|
18
|
+
{
|
|
19
|
+
property: "display",
|
|
20
|
+
value: { type: "keyword", value: "inline-block" },
|
|
19
21
|
},
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
+
],
|
|
23
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
22
24
|
|
|
23
25
|
export const meta: WsComponentMeta = {
|
|
24
26
|
category: "general",
|
|
@@ -27,7 +29,7 @@ export const meta: WsComponentMeta = {
|
|
|
27
29
|
Icon: LinkIcon,
|
|
28
30
|
presetStyle,
|
|
29
31
|
states: [{ selector: "[aria-current=page]", label: "Current page" }],
|
|
30
|
-
children: ["Link text you can edit"],
|
|
32
|
+
children: [{ type: "text", value: "Link text you can edit" }],
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
export const propsMeta: WsComponentPropsMeta = {
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
2
1
|
import { ListItemIcon } from "@webstudio-is/icons";
|
|
3
2
|
import { li } from "../css/normalize";
|
|
4
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
PresetStyle,
|
|
5
|
+
WsComponentMeta,
|
|
6
|
+
WsComponentPropsMeta,
|
|
7
|
+
} from "./component-meta";
|
|
5
8
|
import type { defaultTag } from "./list-item";
|
|
6
9
|
import { props } from "./__generated__/list-item.props";
|
|
7
10
|
|
|
8
11
|
const presetStyle = {
|
|
9
12
|
li,
|
|
10
|
-
}
|
|
13
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
11
14
|
|
|
12
15
|
export const meta: WsComponentMeta = {
|
|
13
16
|
category: "typography",
|
|
14
17
|
type: "rich-text",
|
|
15
18
|
label: "List Item",
|
|
16
19
|
Icon: ListItemIcon,
|
|
17
|
-
children: ["List Item you can edit"],
|
|
20
|
+
children: [{ type: "text", value: "List Item you can edit" }],
|
|
18
21
|
presetStyle,
|
|
19
22
|
};
|
|
20
23
|
|
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
import { ListIcon } from "@webstudio-is/icons";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
PresetStyle,
|
|
4
|
+
WsComponentMeta,
|
|
5
|
+
WsComponentPropsMeta,
|
|
6
|
+
} from "./component-meta";
|
|
3
7
|
import { props } from "./__generated__/list.props";
|
|
4
8
|
import type { ListTag } from "./list";
|
|
5
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
6
9
|
import { ol, ul } from "../css/normalize";
|
|
7
10
|
|
|
8
11
|
const presetStyle = {
|
|
9
|
-
ol:
|
|
12
|
+
ol: [
|
|
10
13
|
...ol,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
value: "0",
|
|
14
|
+
{
|
|
15
|
+
property: "marginTop",
|
|
16
|
+
value: { type: "keyword", value: "0" },
|
|
14
17
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
value: "10px",
|
|
18
|
+
{
|
|
19
|
+
property: "marginBottom",
|
|
20
|
+
value: { type: "keyword", value: "10px" },
|
|
18
21
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
value: "40px",
|
|
22
|
+
{
|
|
23
|
+
property: "paddingLeft",
|
|
24
|
+
value: { type: "keyword", value: "40px" },
|
|
22
25
|
},
|
|
23
|
-
|
|
24
|
-
ul:
|
|
26
|
+
],
|
|
27
|
+
ul: [
|
|
25
28
|
...ul,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
value: "0",
|
|
29
|
+
{
|
|
30
|
+
property: "marginTop",
|
|
31
|
+
value: { type: "keyword", value: "0" },
|
|
29
32
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
value: "10px",
|
|
33
|
+
{
|
|
34
|
+
property: "marginBottom",
|
|
35
|
+
value: { type: "keyword", value: "10px" },
|
|
33
36
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
value: "40px",
|
|
37
|
+
{
|
|
38
|
+
property: "paddingLeft",
|
|
39
|
+
value: { type: "keyword", value: "40px" },
|
|
37
40
|
},
|
|
38
|
-
|
|
39
|
-
}
|
|
41
|
+
],
|
|
42
|
+
} satisfies PresetStyle<ListTag>;
|
|
40
43
|
|
|
41
44
|
export const meta: WsComponentMeta = {
|
|
42
45
|
category: "typography",
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
2
1
|
import { TextAlignLeftIcon } from "@webstudio-is/icons";
|
|
3
2
|
import { p } from "../css/normalize";
|
|
4
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
PresetStyle,
|
|
5
|
+
WsComponentMeta,
|
|
6
|
+
WsComponentPropsMeta,
|
|
7
|
+
} from "./component-meta";
|
|
5
8
|
import type { defaultTag } from "./paragraph";
|
|
6
9
|
import { props } from "./__generated__/paragraph.props";
|
|
7
10
|
|
|
8
11
|
const presetStyle = {
|
|
9
12
|
p,
|
|
10
|
-
}
|
|
13
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
11
14
|
|
|
12
15
|
export const meta: WsComponentMeta = {
|
|
13
16
|
category: "typography",
|
|
14
17
|
type: "rich-text",
|
|
15
18
|
label: "Paragraph",
|
|
16
19
|
Icon: TextAlignLeftIcon,
|
|
17
|
-
children: ["Pragraph you can edit"],
|
|
20
|
+
children: [{ type: "text", value: "Pragraph you can edit" }],
|
|
18
21
|
presetStyle,
|
|
19
22
|
};
|
|
20
23
|
|
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
import { DashIcon } from "@webstudio-is/icons";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
PresetStyle,
|
|
4
|
+
WsComponentMeta,
|
|
5
|
+
WsComponentPropsMeta,
|
|
6
|
+
} from "./component-meta";
|
|
3
7
|
import { props } from "./__generated__/separator.props";
|
|
4
8
|
import type { defaultTag } from "./separator";
|
|
5
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
6
9
|
import { hr } from "../css/normalize";
|
|
7
10
|
|
|
8
11
|
const presetStyle = {
|
|
9
|
-
hr:
|
|
12
|
+
hr: [
|
|
10
13
|
...hr,
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
value: "1px",
|
|
15
|
+
{
|
|
16
|
+
property: "height",
|
|
17
|
+
value: { type: "keyword", value: "1px" },
|
|
15
18
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type: "keyword",
|
|
19
|
-
value: "gray",
|
|
19
|
+
{
|
|
20
|
+
property: "backgroundColor",
|
|
21
|
+
value: { type: "keyword", value: "gray" },
|
|
20
22
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type: "keyword",
|
|
24
|
-
value: "none",
|
|
23
|
+
{
|
|
24
|
+
property: "borderTopStyle",
|
|
25
|
+
value: { type: "keyword", value: "none" },
|
|
25
26
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
value: "none",
|
|
27
|
+
{
|
|
28
|
+
property: "borderRightStyle",
|
|
29
|
+
value: { type: "keyword", value: "none" },
|
|
29
30
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
value: "none",
|
|
31
|
+
{
|
|
32
|
+
property: "borderLeftStyle",
|
|
33
|
+
value: { type: "keyword", value: "none" },
|
|
33
34
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
value: "none",
|
|
35
|
+
{
|
|
36
|
+
property: "borderBottomStyle",
|
|
37
|
+
value: { type: "keyword", value: "none" },
|
|
37
38
|
},
|
|
38
|
-
|
|
39
|
-
}
|
|
39
|
+
],
|
|
40
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
40
41
|
|
|
41
42
|
export const meta: WsComponentMeta = {
|
|
42
43
|
category: "general",
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
2
1
|
import { PaintBrushIcon } from "@webstudio-is/icons";
|
|
3
2
|
import { span } from "../css/normalize";
|
|
4
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
PresetStyle,
|
|
5
|
+
WsComponentMeta,
|
|
6
|
+
WsComponentPropsMeta,
|
|
7
|
+
} from "./component-meta";
|
|
5
8
|
import type { defaultTag } from "./span";
|
|
6
9
|
import { props } from "./__generated__/span.props";
|
|
7
10
|
|
|
8
11
|
const presetStyle = {
|
|
9
12
|
span,
|
|
10
|
-
}
|
|
13
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
11
14
|
|
|
12
15
|
export const meta: WsComponentMeta = {
|
|
13
16
|
type: "rich-text-child",
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
2
1
|
import { SubscriptIcon } from "@webstudio-is/icons";
|
|
3
2
|
import { sub } from "../css/normalize";
|
|
4
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
PresetStyle,
|
|
5
|
+
WsComponentMeta,
|
|
6
|
+
WsComponentPropsMeta,
|
|
7
|
+
} from "./component-meta";
|
|
5
8
|
import type { defaultTag } from "./subscript";
|
|
6
9
|
import { props } from "./__generated__/subscript.props";
|
|
7
10
|
|
|
8
11
|
const presetStyle = {
|
|
9
12
|
sub,
|
|
10
|
-
}
|
|
13
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
11
14
|
|
|
12
15
|
export const meta: WsComponentMeta = {
|
|
13
16
|
type: "rich-text-child",
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
2
1
|
import { SuperscriptIcon } from "@webstudio-is/icons";
|
|
3
2
|
import { sup } from "../css/normalize";
|
|
4
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
PresetStyle,
|
|
5
|
+
WsComponentMeta,
|
|
6
|
+
WsComponentPropsMeta,
|
|
7
|
+
} from "./component-meta";
|
|
5
8
|
import type { defaultTag } from "./superscript";
|
|
6
9
|
import { props } from "./__generated__/superscript.props";
|
|
7
10
|
|
|
8
11
|
const presetStyle = {
|
|
9
12
|
sup,
|
|
10
|
-
}
|
|
13
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
11
14
|
|
|
12
15
|
export const meta: WsComponentMeta = {
|
|
13
16
|
type: "rich-text-child",
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { TextBlockIcon } from "@webstudio-is/icons";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
PresetStyle,
|
|
4
|
+
WsComponentMeta,
|
|
5
|
+
WsComponentPropsMeta,
|
|
6
|
+
} from "./component-meta";
|
|
3
7
|
import { props } from "./__generated__/text-block.props";
|
|
4
8
|
import type { defaultTag } from "./text-block";
|
|
5
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
6
9
|
import { div } from "../css/normalize";
|
|
7
10
|
|
|
8
11
|
const presetStyle = {
|
|
9
|
-
div:
|
|
12
|
+
div: [
|
|
10
13
|
...div,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type: "unit",
|
|
14
|
-
unit: "em",
|
|
15
|
-
value: 1,
|
|
14
|
+
{
|
|
15
|
+
property: "minHeight",
|
|
16
|
+
value: { type: "unit", unit: "em", value: 1 },
|
|
16
17
|
},
|
|
17
|
-
|
|
18
|
-
}
|
|
18
|
+
],
|
|
19
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
19
20
|
|
|
20
21
|
export const meta: WsComponentMeta = {
|
|
21
22
|
category: "typography",
|
|
@@ -23,7 +24,7 @@ export const meta: WsComponentMeta = {
|
|
|
23
24
|
label: "Text Block",
|
|
24
25
|
Icon: TextBlockIcon,
|
|
25
26
|
presetStyle,
|
|
26
|
-
children: ["Block of text you can edit"],
|
|
27
|
+
children: [{ type: "text", value: "Block of text you can edit" }],
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export const propsMeta: WsComponentPropsMeta = {
|
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
|
|