@webstudio-is/react-sdk 0.62.0 → 0.64.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 +1 -2
- package/lib/app/custom-components/form.js +13 -2
- package/lib/cjs/app/custom-components/__generated__/form.props.js +1 -2
- package/lib/cjs/app/custom-components/form.js +19 -8
- package/lib/cjs/components/blockquote.ws.js +2 -0
- package/lib/cjs/components/body.ws.js +2 -0
- package/lib/cjs/components/bold.ws.js +2 -0
- package/lib/cjs/components/box.ws.js +2 -0
- package/lib/cjs/components/button.ws.js +2 -1
- package/lib/cjs/components/checkbox-field.ws.js +2 -0
- package/lib/cjs/components/checkbox.ws.js +2 -0
- package/lib/cjs/components/code.ws.js +2 -0
- package/lib/cjs/components/component-meta.js +12 -1
- package/lib/cjs/components/form.ws.js +2 -0
- package/lib/cjs/components/heading.ws.js +2 -0
- package/lib/cjs/components/image.ws.js +2 -0
- package/lib/cjs/components/input.ws.js +2 -0
- package/lib/cjs/components/italic.ws.js +2 -0
- package/lib/cjs/components/label.ws.js +2 -0
- package/lib/cjs/components/link.ws.js +13 -1
- package/lib/cjs/components/list-item.ws.js +2 -0
- package/lib/cjs/components/list.ws.js +2 -0
- package/lib/cjs/components/paragraph.ws.js +2 -0
- package/lib/cjs/components/radio-button-field.ws.js +2 -0
- package/lib/cjs/components/radio-button.ws.js +2 -0
- package/lib/cjs/components/separator.ws.js +2 -0
- package/lib/cjs/components/span.ws.js +2 -0
- package/lib/cjs/components/subscript.ws.js +2 -0
- package/lib/cjs/components/superscript.ws.js +2 -0
- package/lib/cjs/components/text-block.ws.js +2 -0
- package/lib/cjs/components/textarea.ws.js +2 -0
- package/lib/cjs/index.js +2 -1
- package/lib/components/blockquote.ws.js +4 -0
- package/lib/components/body.ws.js +4 -0
- package/lib/components/bold.ws.js +4 -0
- package/lib/components/box.ws.js +4 -0
- package/lib/components/button.ws.js +4 -1
- package/lib/components/checkbox-field.ws.js +4 -0
- package/lib/components/checkbox.ws.js +4 -0
- package/lib/components/code.ws.js +4 -0
- package/lib/components/component-meta.js +12 -1
- package/lib/components/form.ws.js +4 -0
- package/lib/components/heading.ws.js +4 -0
- package/lib/components/image.ws.js +4 -0
- package/lib/components/input.ws.js +4 -0
- package/lib/components/italic.ws.js +4 -0
- package/lib/components/label.ws.js +4 -0
- package/lib/components/link.ws.js +15 -1
- package/lib/components/list-item.ws.js +4 -0
- package/lib/components/list.ws.js +4 -0
- package/lib/components/paragraph.ws.js +4 -0
- package/lib/components/radio-button-field.ws.js +4 -0
- package/lib/components/radio-button.ws.js +4 -0
- package/lib/components/separator.ws.js +4 -0
- package/lib/components/span.ws.js +4 -0
- package/lib/components/subscript.ws.js +4 -0
- package/lib/components/superscript.ws.js +4 -0
- package/lib/components/text-block.ws.js +4 -0
- package/lib/components/textarea.ws.js +4 -0
- package/lib/index.js +4 -2
- package/lib/types/app/custom-components/form.d.ts +1 -1
- package/lib/types/app/custom-components/index.d.ts +1 -1
- package/lib/types/components/blockquote.ws.d.ts +1 -1
- package/lib/types/components/body.ws.d.ts +1 -1
- package/lib/types/components/bold.ws.d.ts +1 -1
- package/lib/types/components/box.ws.d.ts +1 -1
- package/lib/types/components/button.ws.d.ts +1 -1
- package/lib/types/components/checkbox-field.ws.d.ts +1 -1
- package/lib/types/components/checkbox.ws.d.ts +1 -1
- package/lib/types/components/code.ws.d.ts +1 -1
- package/lib/types/components/component-meta.d.ts +16 -6
- package/lib/types/components/form.ws.d.ts +1 -1
- package/lib/types/components/heading.ws.d.ts +1 -1
- package/lib/types/components/image.ws.d.ts +1 -1
- package/lib/types/components/input.ws.d.ts +1 -1
- package/lib/types/components/italic.ws.d.ts +1 -1
- package/lib/types/components/label.ws.d.ts +1 -1
- package/lib/types/components/link.ws.d.ts +1 -1
- package/lib/types/components/list-item.ws.d.ts +1 -1
- package/lib/types/components/list.ws.d.ts +1 -1
- package/lib/types/components/paragraph.ws.d.ts +1 -1
- package/lib/types/components/radio-button-field.ws.d.ts +1 -1
- package/lib/types/components/radio-button.ws.d.ts +1 -1
- package/lib/types/components/separator.ws.d.ts +1 -1
- package/lib/types/components/span.ws.d.ts +1 -1
- package/lib/types/components/subscript.ws.d.ts +1 -1
- package/lib/types/components/superscript.ws.d.ts +1 -1
- package/lib/types/components/text-block.ws.d.ts +1 -1
- package/lib/types/components/textarea.ws.d.ts +1 -1
- package/lib/types/css/normalize.d.ts +2 -0
- package/lib/types/css/presets.d.ts +2 -2
- package/lib/types/index.d.ts +1 -1
- package/package.json +12 -11
- package/src/app/custom-components/__generated__/form.props.ts +1 -2
- package/src/app/custom-components/form.tsx +27 -10
- package/src/components/blockquote.ws.tsx +6 -4
- package/src/components/body.ws.tsx +6 -4
- package/src/components/bold.ws.tsx +6 -4
- package/src/components/box.ws.ts +6 -4
- package/src/components/button.ws.tsx +6 -5
- package/src/components/checkbox-field.ws.tsx +6 -4
- package/src/components/checkbox.ws.tsx +6 -4
- package/src/components/code.ws.tsx +6 -4
- package/src/components/component-meta.ts +11 -0
- package/src/components/form.ws.tsx +6 -4
- package/src/components/heading.ws.tsx +6 -4
- package/src/components/image.ws.tsx +6 -4
- package/src/components/input.ws.tsx +6 -4
- package/src/components/italic.ws.tsx +6 -4
- package/src/components/label.ws.tsx +6 -4
- package/src/components/link.ws.tsx +17 -5
- package/src/components/list-item.ws.tsx +6 -4
- package/src/components/list.ws.tsx +6 -4
- package/src/components/paragraph.ws.tsx +6 -4
- package/src/components/radio-button-field.ws.tsx +6 -4
- package/src/components/radio-button.ws.tsx +6 -4
- package/src/components/separator.ws.tsx +6 -4
- package/src/components/span.ws.tsx +6 -4
- package/src/components/subscript.ws.tsx +6 -4
- package/src/components/superscript.ws.tsx +6 -4
- package/src/components/text-block.ws.tsx +6 -4
- package/src/components/textarea.ws.tsx +6 -4
- package/src/css/normalize.ts +18 -16
- package/src/css/presets.ts +2 -2
- package/src/index.ts +1 -0
|
@@ -3,10 +3,8 @@ const props = {
|
|
|
3
3
|
style: { required: false, control: "text", type: "string" },
|
|
4
4
|
title: { required: false, control: "text", type: "string" },
|
|
5
5
|
acceptCharset: { required: false, control: "text", type: "string" },
|
|
6
|
-
action: { required: false, control: "text", type: "string" },
|
|
7
6
|
autoComplete: { required: false, control: "text", type: "string" },
|
|
8
7
|
encType: { required: false, control: "text", type: "string" },
|
|
9
|
-
method: { required: false, control: "text", type: "string" },
|
|
10
8
|
name: { required: false, control: "text", type: "string" },
|
|
11
9
|
noValidate: { required: false, control: "boolean", type: "boolean" },
|
|
12
10
|
target: { required: false, control: "text", type: "string" },
|
|
@@ -404,6 +402,7 @@ const props = {
|
|
|
404
402
|
required: false,
|
|
405
403
|
control: "radio",
|
|
406
404
|
type: "string",
|
|
405
|
+
defaultValue: "initial",
|
|
407
406
|
options: ["initial", "success", "error"]
|
|
408
407
|
}
|
|
409
408
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFetcher } from "@remix-run/react";
|
|
3
|
+
import { formIdFieldName } from "@webstudio-is/form-handlers";
|
|
2
4
|
import {
|
|
3
5
|
Children,
|
|
4
6
|
cloneElement,
|
|
5
7
|
forwardRef
|
|
6
8
|
} from "react";
|
|
9
|
+
import { getInstanceIdFromComponentProps } from "../../props";
|
|
7
10
|
const defaultTag = "form";
|
|
8
11
|
const isComponentNode = (component, node) => "props" in node && node.props.instance?.component === component;
|
|
9
12
|
const onlyErrorMessage = (children) => Children.map(children, (child) => {
|
|
@@ -46,7 +49,15 @@ const withoutMessages = (children) => Children.map(children, (child) => {
|
|
|
46
49
|
}
|
|
47
50
|
return withoutMessages(child);
|
|
48
51
|
});
|
|
49
|
-
const Form = forwardRef(({ children, initialState = "initial", ...props }, ref) =>
|
|
52
|
+
const Form = forwardRef(({ children, initialState = "initial", ...props }, ref) => {
|
|
53
|
+
const fetcher = useFetcher();
|
|
54
|
+
const state = fetcher.type === "done" ? fetcher.data?.success === true ? "success" : "error" : initialState;
|
|
55
|
+
const instanceId = getInstanceIdFromComponentProps(props);
|
|
56
|
+
return /* @__PURE__ */ jsxs(fetcher.Form, { ...props, method: "post", "data-state": state, ref, children: [
|
|
57
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", name: formIdFieldName, value: instanceId }),
|
|
58
|
+
state === "success" ? onlySuccessMessage(children) : state === "error" ? onlyErrorMessage(children) : withoutMessages(children)
|
|
59
|
+
] });
|
|
60
|
+
});
|
|
50
61
|
Form.displayName = "Form";
|
|
51
62
|
export {
|
|
52
63
|
Form,
|
|
@@ -26,10 +26,8 @@ const props = {
|
|
|
26
26
|
style: { required: false, control: "text", type: "string" },
|
|
27
27
|
title: { required: false, control: "text", type: "string" },
|
|
28
28
|
acceptCharset: { required: false, control: "text", type: "string" },
|
|
29
|
-
action: { required: false, control: "text", type: "string" },
|
|
30
29
|
autoComplete: { required: false, control: "text", type: "string" },
|
|
31
30
|
encType: { required: false, control: "text", type: "string" },
|
|
32
|
-
method: { required: false, control: "text", type: "string" },
|
|
33
31
|
name: { required: false, control: "text", type: "string" },
|
|
34
32
|
noValidate: { required: false, control: "boolean", type: "boolean" },
|
|
35
33
|
target: { required: false, control: "text", type: "string" },
|
|
@@ -427,6 +425,7 @@ const props = {
|
|
|
427
425
|
required: false,
|
|
428
426
|
control: "radio",
|
|
429
427
|
type: "string",
|
|
428
|
+
defaultValue: "initial",
|
|
430
429
|
options: ["initial", "success", "error"]
|
|
431
430
|
}
|
|
432
431
|
};
|
|
@@ -23,10 +23,13 @@ __export(form_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(form_exports);
|
|
25
25
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
-
var import_react = require("react");
|
|
26
|
+
var import_react = require("@remix-run/react");
|
|
27
|
+
var import_form_handlers = require("@webstudio-is/form-handlers");
|
|
28
|
+
var import_react2 = require("react");
|
|
29
|
+
var import_props = require("../../props");
|
|
27
30
|
const defaultTag = "form";
|
|
28
31
|
const isComponentNode = (component, node) => "props" in node && node.props.instance?.component === component;
|
|
29
|
-
const onlyErrorMessage = (children) =>
|
|
32
|
+
const onlyErrorMessage = (children) => import_react2.Children.map(children, (child) => {
|
|
30
33
|
if (typeof child !== "object" || child === null) {
|
|
31
34
|
return null;
|
|
32
35
|
}
|
|
@@ -35,11 +38,11 @@ const onlyErrorMessage = (children) => import_react.Children.map(children, (chil
|
|
|
35
38
|
}
|
|
36
39
|
if ("props" in child) {
|
|
37
40
|
const newChildren = onlyErrorMessage(child.props.children);
|
|
38
|
-
return
|
|
41
|
+
return import_react2.Children.toArray(newChildren).some((child2) => child2 !== null) ? (0, import_react2.cloneElement)(child, { children: newChildren }) : null;
|
|
39
42
|
}
|
|
40
43
|
return onlyErrorMessage(child);
|
|
41
44
|
});
|
|
42
|
-
const onlySuccessMessage = (children) =>
|
|
45
|
+
const onlySuccessMessage = (children) => import_react2.Children.map(children, (child) => {
|
|
43
46
|
if (typeof child !== "object" || child === null) {
|
|
44
47
|
return null;
|
|
45
48
|
}
|
|
@@ -48,11 +51,11 @@ const onlySuccessMessage = (children) => import_react.Children.map(children, (ch
|
|
|
48
51
|
}
|
|
49
52
|
if ("props" in child) {
|
|
50
53
|
const newChildren = onlySuccessMessage(child.props.children);
|
|
51
|
-
return
|
|
54
|
+
return import_react2.Children.toArray(newChildren).some((child2) => child2 !== null) ? (0, import_react2.cloneElement)(child, { children: newChildren }) : null;
|
|
52
55
|
}
|
|
53
56
|
return onlySuccessMessage(child);
|
|
54
57
|
});
|
|
55
|
-
const withoutMessages = (children) =>
|
|
58
|
+
const withoutMessages = (children) => import_react2.Children.map(children, (child) => {
|
|
56
59
|
if (typeof child !== "object" || child === null) {
|
|
57
60
|
return child;
|
|
58
61
|
}
|
|
@@ -60,11 +63,19 @@ const withoutMessages = (children) => import_react.Children.map(children, (child
|
|
|
60
63
|
return null;
|
|
61
64
|
}
|
|
62
65
|
if ("props" in child) {
|
|
63
|
-
return (0,
|
|
66
|
+
return (0, import_react2.cloneElement)(child, {
|
|
64
67
|
children: withoutMessages(child.props.children)
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
return withoutMessages(child);
|
|
68
71
|
});
|
|
69
|
-
const Form = (0,
|
|
72
|
+
const Form = (0, import_react2.forwardRef)(({ children, initialState = "initial", ...props }, ref) => {
|
|
73
|
+
const fetcher = (0, import_react.useFetcher)();
|
|
74
|
+
const state = fetcher.type === "done" ? fetcher.data?.success === true ? "success" : "error" : initialState;
|
|
75
|
+
const instanceId = (0, import_props.getInstanceIdFromComponentProps)(props);
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(fetcher.Form, { ...props, method: "post", "data-state": state, ref, children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "hidden", name: import_form_handlers.formIdFieldName, value: instanceId }),
|
|
78
|
+
state === "success" ? onlySuccessMessage(children) : state === "error" ? onlyErrorMessage(children) : withoutMessages(children)
|
|
79
|
+
] });
|
|
80
|
+
});
|
|
70
81
|
Form.displayName = "Form";
|
|
@@ -23,6 +23,7 @@ __export(blockquote_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(blockquote_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_blockquote = require("./__generated__/blockquote.props");
|
|
27
28
|
const presetStyle = {
|
|
28
29
|
blockquote: [
|
|
@@ -77,6 +78,7 @@ const meta = {
|
|
|
77
78
|
type: "rich-text",
|
|
78
79
|
label: "Blockquote",
|
|
79
80
|
Icon: import_icons.BlockquoteIcon,
|
|
81
|
+
states: import_component_meta.defaultStates,
|
|
80
82
|
presetStyle,
|
|
81
83
|
children: [{ type: "text", value: "Blockquote you can edit" }]
|
|
82
84
|
};
|
|
@@ -24,6 +24,7 @@ __export(body_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(body_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_body = require("./__generated__/body.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
body: [
|
|
@@ -56,6 +57,7 @@ const meta = {
|
|
|
56
57
|
type: "container",
|
|
57
58
|
label: "Body",
|
|
58
59
|
Icon: import_icons.BodyIcon,
|
|
60
|
+
states: import_component_meta.defaultStates,
|
|
59
61
|
presetStyle
|
|
60
62
|
};
|
|
61
63
|
const propsMeta = {
|
|
@@ -23,6 +23,7 @@ __export(bold_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(bold_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_bold = require("./__generated__/bold.props");
|
|
27
28
|
var import_normalize = require("../css/normalize");
|
|
28
29
|
const presetStyle = {
|
|
@@ -32,6 +33,7 @@ const meta = {
|
|
|
32
33
|
type: "rich-text-child",
|
|
33
34
|
label: "Bold Text",
|
|
34
35
|
Icon: import_icons.BoldIcon,
|
|
36
|
+
states: import_component_meta.defaultStates,
|
|
35
37
|
presetStyle
|
|
36
38
|
};
|
|
37
39
|
const propsMeta = {
|
|
@@ -23,6 +23,7 @@ __export(box_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(box_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_box = require("./__generated__/box.props");
|
|
27
28
|
var import_normalize = require("../css/normalize");
|
|
28
29
|
const presetStyle = {
|
|
@@ -42,6 +43,7 @@ const meta = {
|
|
|
42
43
|
type: "container",
|
|
43
44
|
label: "Box",
|
|
44
45
|
Icon: import_icons.BoxIcon,
|
|
46
|
+
states: import_component_meta.defaultStates,
|
|
45
47
|
presetStyle
|
|
46
48
|
};
|
|
47
49
|
const propsMeta = {
|
|
@@ -24,6 +24,7 @@ __export(button_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(button_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_button = require("./__generated__/button.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
button: import_normalize.button
|
|
@@ -35,7 +36,7 @@ const meta = {
|
|
|
35
36
|
Icon: import_icons.ButtonElementIcon,
|
|
36
37
|
presetStyle,
|
|
37
38
|
states: [
|
|
38
|
-
|
|
39
|
+
...import_component_meta.defaultStates,
|
|
39
40
|
{ selector: ":disabled", label: "Disabled" },
|
|
40
41
|
{ selector: ":enabled", label: "Enabled" }
|
|
41
42
|
]
|
|
@@ -23,6 +23,7 @@ __export(checkbox_field_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(checkbox_field_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_checkbox_field = require("./__generated__/checkbox-field.props");
|
|
27
28
|
var import_normalize = require("../css/normalize");
|
|
28
29
|
const presetStyle = {
|
|
@@ -36,6 +37,7 @@ const meta = {
|
|
|
36
37
|
type: "container",
|
|
37
38
|
label: "Checkbox Field",
|
|
38
39
|
Icon: import_icons.CheckboxCheckedIcon,
|
|
40
|
+
states: import_component_meta.defaultStates,
|
|
39
41
|
presetStyle,
|
|
40
42
|
children: [
|
|
41
43
|
{ type: "instance", component: "Checkbox", props: [], children: [] },
|
|
@@ -23,6 +23,7 @@ __export(checkbox_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(checkbox_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_normalize = require("../css/normalize");
|
|
27
28
|
var import_checkbox = require("./__generated__/checkbox.props");
|
|
28
29
|
const presetStyle = {
|
|
@@ -40,6 +41,7 @@ const meta = {
|
|
|
40
41
|
Icon: import_icons.CheckboxCheckedIcon,
|
|
41
42
|
presetStyle,
|
|
42
43
|
states: [
|
|
44
|
+
...import_component_meta.defaultStates,
|
|
43
45
|
{ selector: ":checked", label: "Checked" },
|
|
44
46
|
{ selector: ":required", label: "Required" },
|
|
45
47
|
{ selector: ":optional", label: "Optional" },
|
|
@@ -23,6 +23,7 @@ __export(code_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(code_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_code = require("./code");
|
|
27
28
|
var import_code2 = require("./__generated__/code.props");
|
|
28
29
|
var import_normalize = require("../css/normalize");
|
|
@@ -56,6 +57,7 @@ const meta = {
|
|
|
56
57
|
type: "rich-text",
|
|
57
58
|
label: "Code",
|
|
58
59
|
Icon: import_icons.CodeIcon,
|
|
60
|
+
states: import_component_meta.defaultStates,
|
|
59
61
|
presetStyle,
|
|
60
62
|
children: [{ type: "text", value: "Code you can edit" }]
|
|
61
63
|
};
|
|
@@ -19,7 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var component_meta_exports = {};
|
|
20
20
|
__export(component_meta_exports, {
|
|
21
21
|
ComponentState: () => ComponentState,
|
|
22
|
-
componentCategories: () => componentCategories
|
|
22
|
+
componentCategories: () => componentCategories,
|
|
23
|
+
defaultStates: () => defaultStates,
|
|
24
|
+
stateCategories: () => stateCategories
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(component_meta_exports);
|
|
25
27
|
var import_zod = require("zod");
|
|
@@ -35,10 +37,19 @@ const componentCategories = [
|
|
|
35
37
|
"media",
|
|
36
38
|
"forms"
|
|
37
39
|
];
|
|
40
|
+
const stateCategories = ["states", "component-states"];
|
|
38
41
|
const ComponentState = import_zod.z.object({
|
|
42
|
+
category: import_zod.z.enum(stateCategories).optional(),
|
|
39
43
|
selector: import_zod.z.string(),
|
|
40
44
|
label: import_zod.z.string()
|
|
41
45
|
});
|
|
46
|
+
const defaultStates = [
|
|
47
|
+
{ selector: ":hover", label: "Hover" },
|
|
48
|
+
{ selector: ":active", label: "Active" },
|
|
49
|
+
{ selector: ":focus", label: "Focus" },
|
|
50
|
+
{ selector: ":focus-visible", label: "Focus Visible" },
|
|
51
|
+
{ selector: ":focus-within", label: "Focus Within" }
|
|
52
|
+
];
|
|
42
53
|
const WsComponentMeta = import_zod.z.object({
|
|
43
54
|
category: import_zod.z.enum(componentCategories).optional(),
|
|
44
55
|
// container - can accept other components with dnd
|
|
@@ -24,6 +24,7 @@ __export(form_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(form_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_form = require("./__generated__/form.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
form: [
|
|
@@ -36,6 +37,7 @@ const meta = {
|
|
|
36
37
|
type: "container",
|
|
37
38
|
label: "Form",
|
|
38
39
|
Icon: import_icons.FormIcon,
|
|
40
|
+
states: import_component_meta.defaultStates,
|
|
39
41
|
presetStyle,
|
|
40
42
|
children: [
|
|
41
43
|
{
|
|
@@ -24,6 +24,7 @@ __export(heading_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(heading_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_heading = require("./__generated__/heading.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
h1: import_normalize.h1,
|
|
@@ -39,6 +40,7 @@ const meta = {
|
|
|
39
40
|
label: "Heading",
|
|
40
41
|
Icon: import_icons.HeadingIcon,
|
|
41
42
|
children: [{ type: "text", value: "Heading you can edit" }],
|
|
43
|
+
states: import_component_meta.defaultStates,
|
|
42
44
|
presetStyle
|
|
43
45
|
};
|
|
44
46
|
const propsMeta = {
|
|
@@ -24,6 +24,7 @@ __export(image_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(image_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_image = require("./__generated__/image.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
img: [
|
|
@@ -46,6 +47,7 @@ const meta = {
|
|
|
46
47
|
type: "embed",
|
|
47
48
|
label: "Image",
|
|
48
49
|
Icon: import_icons.ImageIcon,
|
|
50
|
+
states: import_component_meta.defaultStates,
|
|
49
51
|
presetStyle
|
|
50
52
|
};
|
|
51
53
|
const propsMeta = {
|
|
@@ -24,6 +24,7 @@ __export(input_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(input_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_input = require("./__generated__/input.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
input: import_normalize.input
|
|
@@ -35,6 +36,7 @@ const meta = {
|
|
|
35
36
|
Icon: import_icons.FormTextFieldIcon,
|
|
36
37
|
presetStyle,
|
|
37
38
|
states: [
|
|
39
|
+
...import_component_meta.defaultStates,
|
|
38
40
|
{ selector: "::placeholder", label: "Placeholder" },
|
|
39
41
|
{ selector: ":valid", label: "Valid" },
|
|
40
42
|
{ selector: ":invalid", label: "Invalid" },
|
|
@@ -23,6 +23,7 @@ __export(italic_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(italic_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_italic = require("./__generated__/italic.props");
|
|
27
28
|
var import_normalize = require("../css/normalize");
|
|
28
29
|
const presetStyle = {
|
|
@@ -38,6 +39,7 @@ const meta = {
|
|
|
38
39
|
type: "rich-text-child",
|
|
39
40
|
label: "Italic Text",
|
|
40
41
|
Icon: import_icons.TextItalicIcon,
|
|
42
|
+
states: import_component_meta.defaultStates,
|
|
41
43
|
presetStyle
|
|
42
44
|
};
|
|
43
45
|
const propsMeta = {
|
|
@@ -23,6 +23,7 @@ __export(label_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(label_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_label = require("./__generated__/label.props");
|
|
27
28
|
var import_normalize = require("../css/normalize");
|
|
28
29
|
const presetStyle = {
|
|
@@ -36,6 +37,7 @@ const meta = {
|
|
|
36
37
|
type: "rich-text",
|
|
37
38
|
label: "Input Label",
|
|
38
39
|
Icon: import_icons.TextBlockIcon,
|
|
40
|
+
states: import_component_meta.defaultStates,
|
|
39
41
|
presetStyle,
|
|
40
42
|
children: [{ type: "text", value: "Form Label" }]
|
|
41
43
|
};
|
|
@@ -24,6 +24,7 @@ __export(link_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(link_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_link = require("./__generated__/link.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
a: [
|
|
@@ -44,7 +45,18 @@ const meta = {
|
|
|
44
45
|
label: "Link Text",
|
|
45
46
|
Icon: import_icons.LinkIcon,
|
|
46
47
|
presetStyle,
|
|
47
|
-
states: [
|
|
48
|
+
states: [
|
|
49
|
+
...import_component_meta.defaultStates,
|
|
50
|
+
{
|
|
51
|
+
selector: ":visited",
|
|
52
|
+
label: "Visited"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
category: "component-states",
|
|
56
|
+
selector: "[aria-current=page]",
|
|
57
|
+
label: "Current page"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
48
60
|
children: [{ type: "text", value: "Link text you can edit" }]
|
|
49
61
|
};
|
|
50
62
|
const propsMeta = {
|
|
@@ -24,6 +24,7 @@ __export(list_item_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(list_item_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_list_item = require("./__generated__/list-item.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
li: import_normalize.li
|
|
@@ -35,6 +36,7 @@ const meta = {
|
|
|
35
36
|
label: "List Item",
|
|
36
37
|
Icon: import_icons.ListItemIcon,
|
|
37
38
|
children: [{ type: "text", value: "List Item you can edit" }],
|
|
39
|
+
states: import_component_meta.defaultStates,
|
|
38
40
|
presetStyle
|
|
39
41
|
};
|
|
40
42
|
const propsMeta = {
|
|
@@ -23,6 +23,7 @@ __export(list_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(list_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_list = require("./__generated__/list.props");
|
|
27
28
|
var import_normalize = require("../css/normalize");
|
|
28
29
|
const presetStyle = {
|
|
@@ -62,6 +63,7 @@ const meta = {
|
|
|
62
63
|
type: "container",
|
|
63
64
|
label: "List",
|
|
64
65
|
Icon: import_icons.ListIcon,
|
|
66
|
+
states: import_component_meta.defaultStates,
|
|
65
67
|
presetStyle,
|
|
66
68
|
children: []
|
|
67
69
|
};
|
|
@@ -24,6 +24,7 @@ __export(paragraph_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(paragraph_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_paragraph = require("./__generated__/paragraph.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
p: import_normalize.p
|
|
@@ -34,6 +35,7 @@ const meta = {
|
|
|
34
35
|
label: "Paragraph",
|
|
35
36
|
Icon: import_icons.TextAlignLeftIcon,
|
|
36
37
|
children: [{ type: "text", value: "Pragraph you can edit" }],
|
|
38
|
+
states: import_component_meta.defaultStates,
|
|
37
39
|
presetStyle
|
|
38
40
|
};
|
|
39
41
|
const propsMeta = {
|
|
@@ -23,6 +23,7 @@ __export(radio_button_field_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(radio_button_field_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_radio_button_field = require("./__generated__/radio-button-field.props");
|
|
27
28
|
var import_normalize = require("../css/normalize");
|
|
28
29
|
const presetStyle = {
|
|
@@ -36,6 +37,7 @@ const meta = {
|
|
|
36
37
|
type: "container",
|
|
37
38
|
label: "Radio Button Field",
|
|
38
39
|
Icon: import_icons.RadioCheckedIcon,
|
|
40
|
+
states: import_component_meta.defaultStates,
|
|
39
41
|
presetStyle,
|
|
40
42
|
children: [
|
|
41
43
|
{ type: "instance", component: "RadioButton", props: [], children: [] },
|
|
@@ -23,6 +23,7 @@ __export(radio_button_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(radio_button_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_normalize = require("../css/normalize");
|
|
27
28
|
var import_radio_button = require("./__generated__/radio-button.props");
|
|
28
29
|
const presetStyle = {
|
|
@@ -40,6 +41,7 @@ const meta = {
|
|
|
40
41
|
Icon: import_icons.RadioCheckedIcon,
|
|
41
42
|
presetStyle,
|
|
42
43
|
states: [
|
|
44
|
+
...import_component_meta.defaultStates,
|
|
43
45
|
{ selector: ":checked", label: "Checked" },
|
|
44
46
|
{ selector: ":required", label: "Required" },
|
|
45
47
|
{ selector: ":optional", label: "Optional" },
|
|
@@ -23,6 +23,7 @@ __export(separator_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(separator_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_separator = require("./__generated__/separator.props");
|
|
27
28
|
var import_normalize = require("../css/normalize");
|
|
28
29
|
const presetStyle = {
|
|
@@ -59,6 +60,7 @@ const meta = {
|
|
|
59
60
|
type: "embed",
|
|
60
61
|
label: "Separator",
|
|
61
62
|
Icon: import_icons.DashIcon,
|
|
63
|
+
states: import_component_meta.defaultStates,
|
|
62
64
|
presetStyle,
|
|
63
65
|
children: []
|
|
64
66
|
};
|
|
@@ -24,6 +24,7 @@ __export(span_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(span_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_span = require("./__generated__/span.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
span: import_normalize.span
|
|
@@ -32,6 +33,7 @@ const meta = {
|
|
|
32
33
|
type: "rich-text-child",
|
|
33
34
|
label: "Styled Text",
|
|
34
35
|
Icon: import_icons.PaintBrushIcon,
|
|
36
|
+
states: import_component_meta.defaultStates,
|
|
35
37
|
presetStyle
|
|
36
38
|
};
|
|
37
39
|
const propsMeta = {
|
|
@@ -24,6 +24,7 @@ __export(subscript_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(subscript_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_subscript = require("./__generated__/subscript.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
sub: import_normalize.sub
|
|
@@ -32,6 +33,7 @@ const meta = {
|
|
|
32
33
|
type: "rich-text-child",
|
|
33
34
|
label: "Subscript Text",
|
|
34
35
|
Icon: import_icons.SubscriptIcon,
|
|
36
|
+
states: import_component_meta.defaultStates,
|
|
35
37
|
presetStyle
|
|
36
38
|
};
|
|
37
39
|
const propsMeta = {
|
|
@@ -24,6 +24,7 @@ __export(superscript_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(superscript_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_superscript = require("./__generated__/superscript.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
sup: import_normalize.sup
|
|
@@ -32,6 +33,7 @@ const meta = {
|
|
|
32
33
|
type: "rich-text-child",
|
|
33
34
|
label: "Superscript Text",
|
|
34
35
|
Icon: import_icons.SuperscriptIcon,
|
|
36
|
+
states: import_component_meta.defaultStates,
|
|
35
37
|
presetStyle
|
|
36
38
|
};
|
|
37
39
|
const propsMeta = {
|
|
@@ -23,6 +23,7 @@ __export(text_block_ws_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(text_block_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
|
+
var import_component_meta = require("./component-meta");
|
|
26
27
|
var import_text_block = require("./__generated__/text-block.props");
|
|
27
28
|
var import_normalize = require("../css/normalize");
|
|
28
29
|
const presetStyle = {
|
|
@@ -39,6 +40,7 @@ const meta = {
|
|
|
39
40
|
type: "rich-text",
|
|
40
41
|
label: "Text Block",
|
|
41
42
|
Icon: import_icons.TextBlockIcon,
|
|
43
|
+
states: import_component_meta.defaultStates,
|
|
42
44
|
presetStyle,
|
|
43
45
|
children: [{ type: "text", value: "Block of text you can edit" }]
|
|
44
46
|
};
|
|
@@ -24,6 +24,7 @@ __export(textarea_ws_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(textarea_ws_exports);
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
|
+
var import_component_meta = require("./component-meta");
|
|
27
28
|
var import_textarea = require("./__generated__/textarea.props");
|
|
28
29
|
const presetStyle = {
|
|
29
30
|
textarea: [
|
|
@@ -39,6 +40,7 @@ const meta = {
|
|
|
39
40
|
Icon: import_icons.FormTextAreaIcon,
|
|
40
41
|
presetStyle,
|
|
41
42
|
states: [
|
|
43
|
+
...import_component_meta.defaultStates,
|
|
42
44
|
{ selector: "::placeholder", label: "Placeholder" },
|
|
43
45
|
{ selector: ":valid", label: "Valid" },
|
|
44
46
|
{ selector: ":invalid", label: "Invalid" },
|
package/lib/cjs/index.js
CHANGED
|
@@ -22,7 +22,8 @@ __export(src_exports, {
|
|
|
22
22
|
componentCategories: () => import_component_meta.componentCategories,
|
|
23
23
|
customComponentMetas: () => import_custom_components.customComponentMetas,
|
|
24
24
|
customComponentPropsMetas: () => import_custom_components.customComponentPropsMetas,
|
|
25
|
-
customComponents: () => import_custom_components.customComponents
|
|
25
|
+
customComponents: () => import_custom_components.customComponents,
|
|
26
|
+
stateCategories: () => import_component_meta.stateCategories
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(src_exports);
|
|
28
29
|
__reExport(src_exports, require("./css"), module.exports);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { BlockquoteIcon } from "@webstudio-is/icons";
|
|
2
|
+
import {
|
|
3
|
+
defaultStates
|
|
4
|
+
} from "./component-meta";
|
|
2
5
|
import { props } from "./__generated__/blockquote.props";
|
|
3
6
|
const presetStyle = {
|
|
4
7
|
blockquote: [
|
|
@@ -53,6 +56,7 @@ const meta = {
|
|
|
53
56
|
type: "rich-text",
|
|
54
57
|
label: "Blockquote",
|
|
55
58
|
Icon: BlockquoteIcon,
|
|
59
|
+
states: defaultStates,
|
|
56
60
|
presetStyle,
|
|
57
61
|
children: [{ type: "text", value: "Blockquote you can edit" }]
|
|
58
62
|
};
|