@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
|
@@ -2,38 +2,30 @@ import { CodeIcon } from "@webstudio-is/icons";
|
|
|
2
2
|
import { displayVarNamespace } from "./code";
|
|
3
3
|
import { props } from "./__generated__/code.props";
|
|
4
4
|
import { code } from "../css/normalize";
|
|
5
|
-
const display = {
|
|
6
|
-
type: "var",
|
|
7
|
-
value: displayVarNamespace,
|
|
8
|
-
fallbacks: [
|
|
9
|
-
{
|
|
10
|
-
type: "keyword",
|
|
11
|
-
value: "inline-block"
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
};
|
|
15
5
|
const presetStyle = {
|
|
16
|
-
code:
|
|
6
|
+
code: [
|
|
17
7
|
...code,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
{
|
|
9
|
+
property: "display",
|
|
10
|
+
value: {
|
|
11
|
+
type: "var",
|
|
12
|
+
value: displayVarNamespace,
|
|
13
|
+
fallbacks: [{ type: "keyword", value: "inline-block" }]
|
|
14
|
+
}
|
|
23
15
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
value: 0.2,
|
|
27
|
-
|
|
16
|
+
{
|
|
17
|
+
property: "paddingLeft",
|
|
18
|
+
value: { type: "unit", value: 0.2, unit: "em" }
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
property: "paddingRight",
|
|
22
|
+
value: { type: "unit", value: 0.2, unit: "em" }
|
|
28
23
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
r: 238,
|
|
32
|
-
g: 238,
|
|
33
|
-
b: 238,
|
|
34
|
-
alpha: 1
|
|
24
|
+
{
|
|
25
|
+
property: "backgroundColor",
|
|
26
|
+
value: { type: "rgb", r: 238, g: 238, b: 238, alpha: 1 }
|
|
35
27
|
}
|
|
36
|
-
|
|
28
|
+
]
|
|
37
29
|
};
|
|
38
30
|
const meta = {
|
|
39
31
|
category: "general",
|
|
@@ -41,7 +33,7 @@ const meta = {
|
|
|
41
33
|
label: "Code",
|
|
42
34
|
Icon: CodeIcon,
|
|
43
35
|
presetStyle,
|
|
44
|
-
children: ["Code you can edit"]
|
|
36
|
+
children: [{ type: "text", value: "Code you can edit" }]
|
|
45
37
|
};
|
|
46
38
|
const propsMeta = {
|
|
47
39
|
props,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { PropMeta } from "@webstudio-is/generate-arg-types";
|
|
3
|
+
import { WsEmbedTemplate } from "../embed-template";
|
|
3
4
|
const WsComponentPropsMeta = z.object({
|
|
4
5
|
props: z.record(PropMeta),
|
|
5
6
|
initialProps: z.array(z.string()).optional()
|
|
@@ -28,11 +29,12 @@ const WsComponentMeta = z.object({
|
|
|
28
29
|
"rich-text",
|
|
29
30
|
"rich-text-child"
|
|
30
31
|
]),
|
|
32
|
+
acceptedParents: z.optional(z.array(z.string())),
|
|
31
33
|
label: z.string(),
|
|
32
34
|
Icon: z.function(),
|
|
33
35
|
presetStyle: z.optional(z.any()),
|
|
34
36
|
states: z.optional(z.array(ComponentState)),
|
|
35
|
-
children: z.optional(
|
|
37
|
+
children: z.optional(WsEmbedTemplate)
|
|
36
38
|
});
|
|
37
39
|
export {
|
|
38
40
|
ComponentState,
|
|
@@ -24,7 +24,15 @@ const componentNames = Object.keys({
|
|
|
24
24
|
List: 1,
|
|
25
25
|
ListItem: 1,
|
|
26
26
|
Separator: 1,
|
|
27
|
-
Code: 1
|
|
27
|
+
Code: 1,
|
|
28
|
+
Label: 1,
|
|
29
|
+
SuccessMessage: 1,
|
|
30
|
+
ErrorMessage: 1,
|
|
31
|
+
Textarea: 1,
|
|
32
|
+
RadioButtonField: 1,
|
|
33
|
+
RadioButton: 1,
|
|
34
|
+
CheckboxField: 1,
|
|
35
|
+
Checkbox: 1
|
|
28
36
|
});
|
|
29
37
|
const getComponentNames = () => {
|
|
30
38
|
const uniqueNames = /* @__PURE__ */ new Set([
|
|
@@ -22,29 +22,45 @@ import { List } from "./list";
|
|
|
22
22
|
import { ListItem } from "./list-item";
|
|
23
23
|
import { Separator } from "./separator";
|
|
24
24
|
import { Code } from "./code";
|
|
25
|
+
import { Label } from "./label";
|
|
26
|
+
import { SuccessMessage } from "./success-message";
|
|
27
|
+
import { ErrorMessage } from "./error-message";
|
|
28
|
+
import { Textarea } from "./textarea";
|
|
29
|
+
import { RadioButtonField } from "./radio-button-field";
|
|
30
|
+
import { RadioButton } from "./radio-button";
|
|
31
|
+
import { CheckboxField } from "./checkbox-field";
|
|
32
|
+
import { Checkbox } from "./checkbox";
|
|
25
33
|
export {
|
|
26
34
|
Blockquote,
|
|
27
35
|
Body,
|
|
28
36
|
Bold,
|
|
29
37
|
Box,
|
|
30
38
|
Button,
|
|
39
|
+
Checkbox,
|
|
40
|
+
CheckboxField,
|
|
31
41
|
Code,
|
|
42
|
+
ErrorMessage,
|
|
32
43
|
Form,
|
|
33
44
|
Fragment,
|
|
34
45
|
Heading,
|
|
35
46
|
Image,
|
|
36
47
|
Input,
|
|
37
48
|
Italic,
|
|
49
|
+
Label,
|
|
38
50
|
Link,
|
|
39
51
|
LinkBlock,
|
|
40
52
|
List,
|
|
41
53
|
ListItem,
|
|
42
54
|
Paragraph,
|
|
55
|
+
RadioButton,
|
|
56
|
+
RadioButtonField,
|
|
43
57
|
RichTextLink,
|
|
44
58
|
Separator,
|
|
45
59
|
Slot,
|
|
46
60
|
Span,
|
|
47
61
|
Subscript,
|
|
62
|
+
SuccessMessage,
|
|
48
63
|
Superscript,
|
|
49
|
-
TextBlock
|
|
64
|
+
TextBlock,
|
|
65
|
+
Textarea
|
|
50
66
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
const defaultTag = "div";
|
|
4
|
+
const ErrorMessage = forwardRef((props, ref) => /* @__PURE__ */ jsx("div", { ...props, ref }));
|
|
5
|
+
ErrorMessage.displayName = "ErrorMessage";
|
|
6
|
+
export {
|
|
7
|
+
ErrorMessage,
|
|
8
|
+
defaultTag
|
|
9
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BoxIcon } from "@webstudio-is/icons";
|
|
2
|
+
import { props } from "./__generated__/error-message.props";
|
|
3
|
+
import { div } from "../css/normalize";
|
|
4
|
+
const presetStyle = {
|
|
5
|
+
div
|
|
6
|
+
};
|
|
7
|
+
const meta = {
|
|
8
|
+
type: "container",
|
|
9
|
+
label: "Error Message",
|
|
10
|
+
Icon: BoxIcon,
|
|
11
|
+
presetStyle
|
|
12
|
+
};
|
|
13
|
+
const propsMeta = {
|
|
14
|
+
props,
|
|
15
|
+
initialProps: []
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
meta,
|
|
19
|
+
propsMeta
|
|
20
|
+
};
|
package/lib/components/form.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "form";
|
|
4
|
-
const Form = forwardRef((props, ref) => /* @__PURE__ */ jsx("form", { ...props, ref }));
|
|
4
|
+
const Form = forwardRef(({ children, ...props }, ref) => /* @__PURE__ */ jsx("form", { ...props, ref, children }));
|
|
5
5
|
Form.displayName = "Form";
|
|
6
6
|
export {
|
|
7
7
|
Form,
|
|
@@ -2,24 +2,50 @@ import { FormIcon } from "@webstudio-is/icons";
|
|
|
2
2
|
import { form } from "../css/normalize";
|
|
3
3
|
import { props } from "./__generated__/form.props";
|
|
4
4
|
const presetStyle = {
|
|
5
|
-
form:
|
|
5
|
+
form: [
|
|
6
6
|
...form,
|
|
7
|
-
minHeight: {
|
|
8
|
-
|
|
9
|
-
unit: "px",
|
|
10
|
-
value: 20
|
|
11
|
-
}
|
|
12
|
-
}
|
|
7
|
+
{ property: "minHeight", value: { type: "unit", unit: "px", value: 20 } }
|
|
8
|
+
]
|
|
13
9
|
};
|
|
14
10
|
const meta = {
|
|
15
11
|
category: "forms",
|
|
16
12
|
type: "container",
|
|
17
13
|
label: "Form",
|
|
18
14
|
Icon: FormIcon,
|
|
19
|
-
presetStyle
|
|
15
|
+
presetStyle,
|
|
16
|
+
children: [
|
|
17
|
+
{
|
|
18
|
+
type: "instance",
|
|
19
|
+
component: "Label",
|
|
20
|
+
children: [{ type: "text", value: "Name" }]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "instance",
|
|
24
|
+
component: "Input",
|
|
25
|
+
props: [{ type: "string", name: "name", value: "name" }],
|
|
26
|
+
children: []
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: "instance",
|
|
30
|
+
component: "Label",
|
|
31
|
+
children: [{ type: "text", value: "Email" }]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "instance",
|
|
35
|
+
component: "Input",
|
|
36
|
+
props: [{ type: "string", name: "email", value: "email" }],
|
|
37
|
+
children: []
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: "instance",
|
|
41
|
+
component: "Button",
|
|
42
|
+
children: [{ type: "text", value: "Submit" }]
|
|
43
|
+
}
|
|
44
|
+
]
|
|
20
45
|
};
|
|
21
46
|
const propsMeta = {
|
|
22
|
-
props
|
|
47
|
+
props,
|
|
48
|
+
initialProps: []
|
|
23
49
|
};
|
|
24
50
|
export {
|
|
25
51
|
meta,
|
|
@@ -2,21 +2,20 @@ import { ImageIcon } from "@webstudio-is/icons";
|
|
|
2
2
|
import { img } from "../css/normalize";
|
|
3
3
|
import { props } from "./__generated__/image.props";
|
|
4
4
|
const presetStyle = {
|
|
5
|
-
img:
|
|
5
|
+
img: [
|
|
6
6
|
...img,
|
|
7
7
|
// Otherwise on new image insert onto canvas it can overfit screen size multiple times
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
unit: "%",
|
|
11
|
-
value: 100
|
|
8
|
+
{
|
|
9
|
+
property: "maxWidth",
|
|
10
|
+
value: { type: "unit", unit: "%", value: 100 }
|
|
12
11
|
},
|
|
13
12
|
// inline | inline-block is not suitable because without line-height: 0 on the parent you get unsuitable spaces/margins
|
|
14
13
|
// see https://stackoverflow.com/questions/24771194/is-the-margin-of-inline-block-4px-is-static-for-all-browsers
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
value: "block"
|
|
14
|
+
{
|
|
15
|
+
property: "display",
|
|
16
|
+
value: { type: "keyword", value: "block" }
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
]
|
|
20
19
|
};
|
|
21
20
|
const meta = {
|
|
22
21
|
category: "media",
|
package/lib/components/index.js
CHANGED
|
@@ -23,6 +23,14 @@ import { meta as ListMeta } from "./list.ws";
|
|
|
23
23
|
import { meta as ListItemMeta } from "./list-item.ws";
|
|
24
24
|
import { meta as SeparatorMeta } from "./separator.ws";
|
|
25
25
|
import { meta as CodeMeta } from "./code.ws";
|
|
26
|
+
import { meta as LabelMeta } from "./label.ws";
|
|
27
|
+
import { meta as SuccessMessageMeta } from "./success-message.ws";
|
|
28
|
+
import { meta as ErrorMessageMeta } from "./error-message.ws";
|
|
29
|
+
import { meta as TextareaMeta } from "./textarea.ws";
|
|
30
|
+
import { meta as RadioButtonFieldMeta } from "./radio-button-field.ws";
|
|
31
|
+
import { meta as RadioButtonMeta } from "./radio-button.ws";
|
|
32
|
+
import { meta as CheckboxFieldMeta } from "./checkbox-field.ws";
|
|
33
|
+
import { meta as CheckboxMeta } from "./checkbox.ws";
|
|
26
34
|
import { propsMeta as SlotMetaPropsMeta } from "./slot.ws";
|
|
27
35
|
import { propsMeta as FragmentMetaPropsMeta } from "./fragment.ws";
|
|
28
36
|
import { propsMeta as BodyMetaPropsMeta } from "./body.ws";
|
|
@@ -47,6 +55,14 @@ import { propsMeta as ListPropsMeta } from "./list.ws";
|
|
|
47
55
|
import { propsMeta as ListItemPropsMeta } from "./list-item.ws";
|
|
48
56
|
import { propsMeta as SeparatorPropsMeta } from "./separator.ws";
|
|
49
57
|
import { propsMeta as CodePropsMeta } from "./code.ws";
|
|
58
|
+
import { propsMeta as LabelPropsMeta } from "./label.ws";
|
|
59
|
+
import { propsMeta as SuccessMessagePropsMeta } from "./success-message.ws";
|
|
60
|
+
import { propsMeta as ErrorMessagePropsMeta } from "./error-message.ws";
|
|
61
|
+
import { propsMeta as TextareaPropsMeta } from "./textarea.ws";
|
|
62
|
+
import { propsMeta as RadioButtonFieldPropsMeta } from "./radio-button-field.ws";
|
|
63
|
+
import { propsMeta as RadioButtonPropsMeta } from "./radio-button.ws";
|
|
64
|
+
import { propsMeta as CheckboxFieldPropsMeta } from "./checkbox-field.ws";
|
|
65
|
+
import { propsMeta as CheckboxPropsMeta } from "./checkbox.ws";
|
|
50
66
|
const defaultMetas = {
|
|
51
67
|
Slot: SlotMeta,
|
|
52
68
|
Fragment: FragmentMeta,
|
|
@@ -71,7 +87,15 @@ const defaultMetas = {
|
|
|
71
87
|
List: ListMeta,
|
|
72
88
|
ListItem: ListItemMeta,
|
|
73
89
|
Separator: SeparatorMeta,
|
|
74
|
-
Code: CodeMeta
|
|
90
|
+
Code: CodeMeta,
|
|
91
|
+
Label: LabelMeta,
|
|
92
|
+
SuccessMessage: SuccessMessageMeta,
|
|
93
|
+
ErrorMessage: ErrorMessageMeta,
|
|
94
|
+
Textarea: TextareaMeta,
|
|
95
|
+
RadioButtonField: RadioButtonFieldMeta,
|
|
96
|
+
RadioButton: RadioButtonMeta,
|
|
97
|
+
CheckboxField: CheckboxFieldMeta,
|
|
98
|
+
Checkbox: CheckboxMeta
|
|
75
99
|
};
|
|
76
100
|
let currentMetas = defaultMetas;
|
|
77
101
|
const getComponentMeta = (name) => {
|
|
@@ -108,7 +132,15 @@ const defaultPropsMetasRaw = {
|
|
|
108
132
|
List: ListPropsMeta,
|
|
109
133
|
ListItem: ListItemPropsMeta,
|
|
110
134
|
Separator: SeparatorPropsMeta,
|
|
111
|
-
Code: CodePropsMeta
|
|
135
|
+
Code: CodePropsMeta,
|
|
136
|
+
Label: LabelPropsMeta,
|
|
137
|
+
SuccessMessage: SuccessMessagePropsMeta,
|
|
138
|
+
ErrorMessage: ErrorMessagePropsMeta,
|
|
139
|
+
Textarea: TextareaPropsMeta,
|
|
140
|
+
RadioButtonField: RadioButtonFieldPropsMeta,
|
|
141
|
+
RadioButton: RadioButtonPropsMeta,
|
|
142
|
+
CheckboxField: CheckboxFieldPropsMeta,
|
|
143
|
+
Checkbox: CheckboxPropsMeta
|
|
112
144
|
};
|
|
113
145
|
const defaultPropsMetas = defaultPropsMetasRaw;
|
|
114
146
|
let registeredPropsMetas = {};
|
|
@@ -163,7 +195,16 @@ const computeInitialProps = (props, defaults, overrides) => {
|
|
|
163
195
|
).map(([name]) => name) : [];
|
|
164
196
|
return [...initialProps, ...requiredProps];
|
|
165
197
|
};
|
|
198
|
+
const canAcceptComponent = (parentComponent, childComponent) => {
|
|
199
|
+
const parentMeta = getComponentMeta(parentComponent);
|
|
200
|
+
const childMeta = getComponentMeta(childComponent);
|
|
201
|
+
if (parentMeta?.type !== "container" || childMeta === void 0) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
return childMeta.acceptedParents === void 0 || childMeta.acceptedParents.includes(parentComponent);
|
|
205
|
+
};
|
|
166
206
|
export {
|
|
207
|
+
canAcceptComponent,
|
|
167
208
|
getComponentMeta,
|
|
168
209
|
getComponentPropsMeta,
|
|
169
210
|
registerComponentMetas,
|
|
@@ -7,12 +7,24 @@ const presetStyle = {
|
|
|
7
7
|
const meta = {
|
|
8
8
|
category: "forms",
|
|
9
9
|
type: "control",
|
|
10
|
-
label: "
|
|
10
|
+
label: "Text Field",
|
|
11
11
|
Icon: FormTextFieldIcon,
|
|
12
|
-
presetStyle
|
|
12
|
+
presetStyle,
|
|
13
|
+
states: [
|
|
14
|
+
{ selector: "::placeholder", label: "Placeholder" },
|
|
15
|
+
{ selector: ":valid", label: "Valid" },
|
|
16
|
+
{ selector: ":invalid", label: "Invalid" },
|
|
17
|
+
{ selector: ":required", label: "Required" },
|
|
18
|
+
{ selector: ":optional", label: "Optional" },
|
|
19
|
+
{ selector: ":disabled", label: "Disabled" },
|
|
20
|
+
{ selector: ":enabled", label: "Enabled" },
|
|
21
|
+
{ selector: ":read-only", label: "Read Only" },
|
|
22
|
+
{ selector: ":read-write", label: "Read Write" }
|
|
23
|
+
]
|
|
13
24
|
};
|
|
14
25
|
const propsMeta = {
|
|
15
|
-
props
|
|
26
|
+
props,
|
|
27
|
+
initialProps: ["name", "type", "placeholder", "required", "autoFocus"]
|
|
16
28
|
};
|
|
17
29
|
export {
|
|
18
30
|
meta,
|
|
@@ -2,13 +2,13 @@ import { TextItalicIcon } from "@webstudio-is/icons";
|
|
|
2
2
|
import { props } from "./__generated__/italic.props";
|
|
3
3
|
import { i } from "../css/normalize";
|
|
4
4
|
const presetStyle = {
|
|
5
|
-
i:
|
|
5
|
+
i: [
|
|
6
6
|
...i,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
value: "italic"
|
|
7
|
+
{
|
|
8
|
+
property: "fontStyle",
|
|
9
|
+
value: { type: "keyword", value: "italic" }
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
]
|
|
12
12
|
};
|
|
13
13
|
const meta = {
|
|
14
14
|
type: "rich-text-child",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
const defaultTag = "label";
|
|
4
|
+
const Label = forwardRef((props, ref) => /* @__PURE__ */ jsx("label", { ...props, ref }));
|
|
5
|
+
Label.displayName = "Label";
|
|
6
|
+
export {
|
|
7
|
+
Label,
|
|
8
|
+
defaultTag
|
|
9
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TextBlockIcon } from "@webstudio-is/icons";
|
|
2
|
+
import { props } from "./__generated__/label.props";
|
|
3
|
+
import { label } from "../css/normalize";
|
|
4
|
+
const presetStyle = {
|
|
5
|
+
label: [
|
|
6
|
+
...label,
|
|
7
|
+
{ property: "display", value: { type: "keyword", value: "block" } }
|
|
8
|
+
]
|
|
9
|
+
};
|
|
10
|
+
const meta = {
|
|
11
|
+
category: "forms",
|
|
12
|
+
type: "rich-text",
|
|
13
|
+
label: "Input Label",
|
|
14
|
+
Icon: TextBlockIcon,
|
|
15
|
+
presetStyle,
|
|
16
|
+
children: [{ type: "text", value: "Form Label" }]
|
|
17
|
+
};
|
|
18
|
+
const propsMeta = {
|
|
19
|
+
props: {
|
|
20
|
+
...props,
|
|
21
|
+
htmlFor: {
|
|
22
|
+
required: false,
|
|
23
|
+
control: "text",
|
|
24
|
+
type: "string",
|
|
25
|
+
rows: 0,
|
|
26
|
+
label: "For"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
initialProps: ["htmlFor"]
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
meta,
|
|
33
|
+
propsMeta
|
|
34
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinkBlockIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { props } from "./__generated__/link-block.props";
|
|
3
3
|
import { meta as linkMeta, propsMeta as linkPropsMeta } from "./link.ws";
|
|
4
4
|
import { a } from "../css/normalize";
|
|
5
5
|
const presetStyle = {
|
|
6
|
-
a:
|
|
6
|
+
a: [
|
|
7
7
|
...a,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
value: "inline-block"
|
|
8
|
+
{
|
|
9
|
+
property: "display",
|
|
10
|
+
value: { type: "keyword", value: "inline-block" }
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
]
|
|
13
13
|
};
|
|
14
14
|
const meta = {
|
|
15
15
|
category: "general",
|
|
16
16
|
type: "container",
|
|
17
17
|
label: "Link Block",
|
|
18
|
-
Icon:
|
|
18
|
+
Icon: LinkBlockIcon,
|
|
19
19
|
states: linkMeta.states,
|
|
20
20
|
presetStyle
|
|
21
21
|
};
|
|
@@ -2,18 +2,17 @@ import { LinkIcon } from "@webstudio-is/icons";
|
|
|
2
2
|
import { a } from "../css/normalize";
|
|
3
3
|
import { props } from "./__generated__/link.props";
|
|
4
4
|
const presetStyle = {
|
|
5
|
-
a:
|
|
5
|
+
a: [
|
|
6
6
|
...a,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
unit: "em",
|
|
10
|
-
value: 1
|
|
7
|
+
{
|
|
8
|
+
property: "minHeight",
|
|
9
|
+
value: { type: "unit", unit: "em", value: 1 }
|
|
11
10
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
value: "inline-block"
|
|
11
|
+
{
|
|
12
|
+
property: "display",
|
|
13
|
+
value: { type: "keyword", value: "inline-block" }
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
]
|
|
17
16
|
};
|
|
18
17
|
const meta = {
|
|
19
18
|
category: "general",
|
|
@@ -22,7 +21,7 @@ const meta = {
|
|
|
22
21
|
Icon: LinkIcon,
|
|
23
22
|
presetStyle,
|
|
24
23
|
states: [{ selector: "[aria-current=page]", label: "Current page" }],
|
|
25
|
-
children: ["Link text you can edit"]
|
|
24
|
+
children: [{ type: "text", value: "Link text you can edit" }]
|
|
26
25
|
};
|
|
27
26
|
const propsMeta = {
|
|
28
27
|
props: {
|
|
@@ -7,9 +7,10 @@ const presetStyle = {
|
|
|
7
7
|
const meta = {
|
|
8
8
|
category: "typography",
|
|
9
9
|
type: "rich-text",
|
|
10
|
+
acceptedParents: ["List"],
|
|
10
11
|
label: "List Item",
|
|
11
12
|
Icon: ListItemIcon,
|
|
12
|
-
children: ["List Item you can edit"],
|
|
13
|
+
children: [{ type: "text", value: "List Item you can edit" }],
|
|
13
14
|
presetStyle
|
|
14
15
|
};
|
|
15
16
|
const propsMeta = {
|
|
@@ -2,36 +2,36 @@ import { ListIcon } from "@webstudio-is/icons";
|
|
|
2
2
|
import { props } from "./__generated__/list.props";
|
|
3
3
|
import { ol, ul } from "../css/normalize";
|
|
4
4
|
const presetStyle = {
|
|
5
|
-
ol:
|
|
5
|
+
ol: [
|
|
6
6
|
...ol,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
value: "0"
|
|
7
|
+
{
|
|
8
|
+
property: "marginTop",
|
|
9
|
+
value: { type: "keyword", value: "0" }
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
value: "10px"
|
|
11
|
+
{
|
|
12
|
+
property: "marginBottom",
|
|
13
|
+
value: { type: "keyword", value: "10px" }
|
|
14
14
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
value: "40px"
|
|
15
|
+
{
|
|
16
|
+
property: "paddingLeft",
|
|
17
|
+
value: { type: "keyword", value: "40px" }
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
ul:
|
|
19
|
+
],
|
|
20
|
+
ul: [
|
|
21
21
|
...ul,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
value: "0"
|
|
22
|
+
{
|
|
23
|
+
property: "marginTop",
|
|
24
|
+
value: { type: "keyword", value: "0" }
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
value: "10px"
|
|
26
|
+
{
|
|
27
|
+
property: "marginBottom",
|
|
28
|
+
value: { type: "keyword", value: "10px" }
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
value: "40px"
|
|
30
|
+
{
|
|
31
|
+
property: "paddingLeft",
|
|
32
|
+
value: { type: "keyword", value: "40px" }
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
]
|
|
35
35
|
};
|
|
36
36
|
const meta = {
|
|
37
37
|
category: "typography",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
const defaultTag = "label";
|
|
4
|
+
const RadioButtonField = forwardRef((props, ref) => /* @__PURE__ */ jsx("label", { ...props, ref }));
|
|
5
|
+
RadioButtonField.displayName = "RadioButtonField";
|
|
6
|
+
export {
|
|
7
|
+
RadioButtonField,
|
|
8
|
+
defaultTag
|
|
9
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { RadioCheckedIcon } from "@webstudio-is/icons";
|
|
2
|
+
import { props } from "./__generated__/radio-button-field.props";
|
|
3
|
+
import { label } from "../css/normalize";
|
|
4
|
+
const presetStyle = {
|
|
5
|
+
label: [
|
|
6
|
+
...label,
|
|
7
|
+
{ property: "display", value: { type: "keyword", value: "flex" } }
|
|
8
|
+
]
|
|
9
|
+
};
|
|
10
|
+
const meta = {
|
|
11
|
+
category: "forms",
|
|
12
|
+
type: "container",
|
|
13
|
+
label: "Radio Button Field",
|
|
14
|
+
Icon: RadioCheckedIcon,
|
|
15
|
+
presetStyle,
|
|
16
|
+
children: [
|
|
17
|
+
{ type: "instance", component: "RadioButton", props: [], children: [] },
|
|
18
|
+
{
|
|
19
|
+
type: "instance",
|
|
20
|
+
component: "TextBlock",
|
|
21
|
+
props: [],
|
|
22
|
+
children: [{ type: "text", value: "Radio" }]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
const propsMeta = {
|
|
27
|
+
props,
|
|
28
|
+
initialProps: []
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
meta,
|
|
32
|
+
propsMeta
|
|
33
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
const defaultTag = "input";
|
|
4
|
+
const RadioButton = forwardRef(({ children: _children, ...props }, ref) => /* @__PURE__ */ jsx("input", { ...props, type: "radio", ref }));
|
|
5
|
+
RadioButton.displayName = "RadioButton";
|
|
6
|
+
export {
|
|
7
|
+
RadioButton,
|
|
8
|
+
defaultTag
|
|
9
|
+
};
|