@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
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
*
|
|
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
|
+
import type { EmbedTemplateStyleDecl } from "../embed-template";
|
|
18
|
+
export type Styles = EmbedTemplateStyleDecl[];
|
|
17
19
|
export declare const div: ({
|
|
18
20
|
state?: string | undefined;
|
|
19
21
|
value: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const borders:
|
|
1
|
+
import type { Styles } from "./normalize";
|
|
2
|
+
export declare const borders: Styles;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export * from "./app";
|
|
|
6
6
|
export * from "./components/components";
|
|
7
7
|
export * from "./components/components-utils";
|
|
8
8
|
export { customComponents, customComponentMetas, customComponentPropsMetas, } from "./app/custom-components";
|
|
9
|
-
export { type WsComponentPropsMeta, type WsComponentMeta, type ComponentState, componentCategories, } from "./components/component-meta";
|
|
9
|
+
export { type WsComponentPropsMeta, type WsComponentMeta, type ComponentState, componentCategories, stateCategories, } from "./components/component-meta";
|
|
10
10
|
export * from "./embed-template";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -35,16 +35,17 @@
|
|
|
35
35
|
"nanoevents": "^7.0.1",
|
|
36
36
|
"nanoid": "^3.2.0",
|
|
37
37
|
"nanostores": "^0.7.1",
|
|
38
|
-
"@webstudio-is/asset-uploader": "^0.
|
|
39
|
-
"@webstudio-is/css-data": "^0.
|
|
40
|
-
"@webstudio-is/css-engine": "^0.
|
|
41
|
-
"@webstudio-is/css-vars": "^0.
|
|
42
|
-
"@webstudio-is/fonts": "^0.
|
|
43
|
-
"@webstudio-is/generate-arg-types": "^0.
|
|
44
|
-
"@webstudio-is/icons": "^0.
|
|
45
|
-
"@webstudio-is/image": "^0.
|
|
46
|
-
"@webstudio-is/prisma-client": "^0.
|
|
47
|
-
"@webstudio-is/project-build": "^0.
|
|
38
|
+
"@webstudio-is/asset-uploader": "^0.64.0",
|
|
39
|
+
"@webstudio-is/css-data": "^0.64.0",
|
|
40
|
+
"@webstudio-is/css-engine": "^0.64.0",
|
|
41
|
+
"@webstudio-is/css-vars": "^0.64.0",
|
|
42
|
+
"@webstudio-is/fonts": "^0.64.0",
|
|
43
|
+
"@webstudio-is/generate-arg-types": "^0.64.0",
|
|
44
|
+
"@webstudio-is/icons": "^0.64.0",
|
|
45
|
+
"@webstudio-is/image": "^0.64.0",
|
|
46
|
+
"@webstudio-is/prisma-client": "^0.64.0",
|
|
47
|
+
"@webstudio-is/project-build": "^0.64.0",
|
|
48
|
+
"@webstudio-is/form-handlers": "^0.64.0"
|
|
48
49
|
},
|
|
49
50
|
"exports": {
|
|
50
51
|
".": {
|
|
@@ -5,10 +5,8 @@ export const props: Record<string, PropMeta> = {
|
|
|
5
5
|
style: { required: false, control: "text", type: "string" },
|
|
6
6
|
title: { required: false, control: "text", type: "string" },
|
|
7
7
|
acceptCharset: { required: false, control: "text", type: "string" },
|
|
8
|
-
action: { required: false, control: "text", type: "string" },
|
|
9
8
|
autoComplete: { required: false, control: "text", type: "string" },
|
|
10
9
|
encType: { required: false, control: "text", type: "string" },
|
|
11
|
-
method: { required: false, control: "text", type: "string" },
|
|
12
10
|
name: { required: false, control: "text", type: "string" },
|
|
13
11
|
noValidate: { required: false, control: "boolean", type: "boolean" },
|
|
14
12
|
target: { required: false, control: "text", type: "string" },
|
|
@@ -452,6 +450,7 @@ export const props: Record<string, PropMeta> = {
|
|
|
452
450
|
required: false,
|
|
453
451
|
control: "radio",
|
|
454
452
|
type: "string",
|
|
453
|
+
defaultValue: "initial",
|
|
455
454
|
options: ["initial", "success", "error"],
|
|
456
455
|
},
|
|
457
456
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useFetcher } from "@remix-run/react";
|
|
2
|
+
import { formIdFieldName } from "@webstudio-is/form-handlers";
|
|
1
3
|
import {
|
|
2
4
|
Children,
|
|
3
5
|
cloneElement,
|
|
@@ -6,6 +8,7 @@ import {
|
|
|
6
8
|
type ElementRef,
|
|
7
9
|
type ComponentProps,
|
|
8
10
|
} from "react";
|
|
11
|
+
import { getInstanceIdFromComponentProps } from "../../props";
|
|
9
12
|
|
|
10
13
|
export const defaultTag = "form";
|
|
11
14
|
|
|
@@ -78,17 +81,31 @@ const withoutMessages = (children: ReactNode) =>
|
|
|
78
81
|
|
|
79
82
|
export const Form = forwardRef<
|
|
80
83
|
ElementRef<typeof defaultTag>,
|
|
81
|
-
ComponentProps<typeof defaultTag> & {
|
|
84
|
+
Omit<ComponentProps<typeof defaultTag>, "method" | "action"> & {
|
|
82
85
|
initialState?: "initial" | "success" | "error";
|
|
83
86
|
}
|
|
84
|
-
>(({ children, initialState = "initial", ...props }, ref) =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
?
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
>(({ children, initialState = "initial", ...props }, ref) => {
|
|
88
|
+
const fetcher = useFetcher();
|
|
89
|
+
|
|
90
|
+
const state =
|
|
91
|
+
fetcher.type === "done"
|
|
92
|
+
? fetcher.data?.success === true
|
|
93
|
+
? "success"
|
|
94
|
+
: "error"
|
|
95
|
+
: initialState;
|
|
96
|
+
|
|
97
|
+
const instanceId = getInstanceIdFromComponentProps(props);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<fetcher.Form {...props} method="post" data-state={state} ref={ref}>
|
|
101
|
+
<input type="hidden" name={formIdFieldName} value={instanceId} />
|
|
102
|
+
{state === "success"
|
|
103
|
+
? onlySuccessMessage(children)
|
|
104
|
+
: state === "error"
|
|
105
|
+
? onlyErrorMessage(children)
|
|
106
|
+
: withoutMessages(children)}
|
|
107
|
+
</fetcher.Form>
|
|
108
|
+
);
|
|
109
|
+
});
|
|
93
110
|
|
|
94
111
|
Form.displayName = "Form";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BlockquoteIcon } from "@webstudio-is/icons";
|
|
2
2
|
import type { defaultTag } from "./blockquote";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
defaultStates,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
type WsComponentMeta,
|
|
7
|
+
type WsComponentPropsMeta,
|
|
7
8
|
} from "./component-meta";
|
|
8
9
|
import { props } from "./__generated__/blockquote.props";
|
|
9
10
|
|
|
@@ -63,6 +64,7 @@ export const meta: WsComponentMeta = {
|
|
|
63
64
|
type: "rich-text",
|
|
64
65
|
label: "Blockquote",
|
|
65
66
|
Icon: BlockquoteIcon,
|
|
67
|
+
states: defaultStates,
|
|
66
68
|
presetStyle,
|
|
67
69
|
children: [{ type: "text", value: "Blockquote you can edit" }],
|
|
68
70
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BodyIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { body } from "../css/normalize";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
defaultStates,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
type WsComponentMeta,
|
|
7
|
+
type WsComponentPropsMeta,
|
|
7
8
|
} from "./component-meta";
|
|
8
9
|
import { props } from "./__generated__/body.props";
|
|
9
10
|
import type { defaultTag } from "./body";
|
|
@@ -41,6 +42,7 @@ export const meta: WsComponentMeta = {
|
|
|
41
42
|
type: "container",
|
|
42
43
|
label: "Body",
|
|
43
44
|
Icon: BodyIcon,
|
|
45
|
+
states: defaultStates,
|
|
44
46
|
presetStyle,
|
|
45
47
|
};
|
|
46
48
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BoldIcon } from "@webstudio-is/icons";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
defaultStates,
|
|
4
|
+
type PresetStyle,
|
|
5
|
+
type WsComponentMeta,
|
|
6
|
+
type WsComponentPropsMeta,
|
|
6
7
|
} from "./component-meta";
|
|
7
8
|
import { props } from "./__generated__/bold.props";
|
|
8
9
|
import { b } from "../css/normalize";
|
|
@@ -16,6 +17,7 @@ export const meta: WsComponentMeta = {
|
|
|
16
17
|
type: "rich-text-child",
|
|
17
18
|
label: "Bold Text",
|
|
18
19
|
Icon: BoldIcon,
|
|
20
|
+
states: defaultStates,
|
|
19
21
|
presetStyle,
|
|
20
22
|
};
|
|
21
23
|
|
package/src/components/box.ws.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BoxIcon } from "@webstudio-is/icons";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
defaultStates,
|
|
4
|
+
type PresetStyle,
|
|
5
|
+
type WsComponentMeta,
|
|
6
|
+
type WsComponentPropsMeta,
|
|
6
7
|
} from "./component-meta";
|
|
7
8
|
import { props } from "./__generated__/box.props";
|
|
8
9
|
import type { Box } from "./box";
|
|
@@ -40,6 +41,7 @@ export const meta: WsComponentMeta = {
|
|
|
40
41
|
type: "container",
|
|
41
42
|
label: "Box",
|
|
42
43
|
Icon: BoxIcon,
|
|
44
|
+
states: defaultStates,
|
|
43
45
|
presetStyle,
|
|
44
46
|
};
|
|
45
47
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ButtonElementIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { button } from "../css/normalize";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
defaultStates,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
type WsComponentMeta,
|
|
7
|
+
type WsComponentPropsMeta,
|
|
7
8
|
} from "./component-meta";
|
|
8
9
|
import { props } from "./__generated__/button.props";
|
|
9
10
|
import type { defaultTag } from "./button";
|
|
@@ -19,7 +20,7 @@ export const meta: WsComponentMeta = {
|
|
|
19
20
|
Icon: ButtonElementIcon,
|
|
20
21
|
presetStyle,
|
|
21
22
|
states: [
|
|
22
|
-
|
|
23
|
+
...defaultStates,
|
|
23
24
|
{ selector: ":disabled", label: "Disabled" },
|
|
24
25
|
{ selector: ":enabled", label: "Enabled" },
|
|
25
26
|
],
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CheckboxCheckedIcon } from "@webstudio-is/icons";
|
|
2
|
-
import
|
|
3
|
-
WsComponentMeta,
|
|
4
|
-
WsComponentPropsMeta,
|
|
5
|
-
PresetStyle,
|
|
2
|
+
import {
|
|
3
|
+
type WsComponentMeta,
|
|
4
|
+
type WsComponentPropsMeta,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
defaultStates,
|
|
6
7
|
} from "./component-meta";
|
|
7
8
|
import { props } from "./__generated__/checkbox-field.props";
|
|
8
9
|
import type { defaultTag } from "./checkbox-field";
|
|
@@ -20,6 +21,7 @@ export const meta: WsComponentMeta = {
|
|
|
20
21
|
type: "container",
|
|
21
22
|
label: "Checkbox Field",
|
|
22
23
|
Icon: CheckboxCheckedIcon,
|
|
24
|
+
states: defaultStates,
|
|
23
25
|
presetStyle,
|
|
24
26
|
children: [
|
|
25
27
|
{ type: "instance", component: "Checkbox", props: [], children: [] },
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CheckboxCheckedIcon } from "@webstudio-is/icons";
|
|
2
|
-
import
|
|
3
|
-
WsComponentMeta,
|
|
4
|
-
WsComponentPropsMeta,
|
|
5
|
-
PresetStyle,
|
|
2
|
+
import {
|
|
3
|
+
type WsComponentMeta,
|
|
4
|
+
type WsComponentPropsMeta,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
defaultStates,
|
|
6
7
|
} from "./component-meta";
|
|
7
8
|
import type { defaultTag } from "./checkbox";
|
|
8
9
|
import { input } from "../css/normalize";
|
|
@@ -24,6 +25,7 @@ export const meta: WsComponentMeta = {
|
|
|
24
25
|
Icon: CheckboxCheckedIcon,
|
|
25
26
|
presetStyle,
|
|
26
27
|
states: [
|
|
28
|
+
...defaultStates,
|
|
27
29
|
{ selector: ":checked", label: "Checked" },
|
|
28
30
|
{ selector: ":required", label: "Required" },
|
|
29
31
|
{ selector: ":optional", label: "Optional" },
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CodeIcon } from "@webstudio-is/icons";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
defaultStates,
|
|
4
|
+
type PresetStyle,
|
|
5
|
+
type WsComponentMeta,
|
|
6
|
+
type WsComponentPropsMeta,
|
|
6
7
|
} from "./component-meta";
|
|
7
8
|
import { type defaultTag, displayVarNamespace } from "./code";
|
|
8
9
|
import { props } from "./__generated__/code.props";
|
|
@@ -39,6 +40,7 @@ export const meta: WsComponentMeta = {
|
|
|
39
40
|
type: "rich-text",
|
|
40
41
|
label: "Code",
|
|
41
42
|
Icon: CodeIcon,
|
|
43
|
+
states: defaultStates,
|
|
42
44
|
presetStyle,
|
|
43
45
|
children: [{ type: "text", value: "Code you can edit" }],
|
|
44
46
|
};
|
|
@@ -25,13 +25,24 @@ export const componentCategories = [
|
|
|
25
25
|
"forms",
|
|
26
26
|
] as const;
|
|
27
27
|
|
|
28
|
+
export const stateCategories = ["states", "component-states"] as const;
|
|
29
|
+
|
|
28
30
|
export const ComponentState = z.object({
|
|
31
|
+
category: z.enum(stateCategories).optional(),
|
|
29
32
|
selector: z.string(),
|
|
30
33
|
label: z.string(),
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
export type ComponentState = z.infer<typeof ComponentState>;
|
|
34
37
|
|
|
38
|
+
export const defaultStates: ComponentState[] = [
|
|
39
|
+
{ selector: ":hover", label: "Hover" },
|
|
40
|
+
{ selector: ":active", label: "Active" },
|
|
41
|
+
{ selector: ":focus", label: "Focus" },
|
|
42
|
+
{ selector: ":focus-visible", label: "Focus Visible" },
|
|
43
|
+
{ selector: ":focus-within", label: "Focus Within" },
|
|
44
|
+
];
|
|
45
|
+
|
|
35
46
|
const WsComponentMeta = z.object({
|
|
36
47
|
category: z.enum(componentCategories).optional(),
|
|
37
48
|
// container - can accept other components with dnd
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FormIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { form } from "../css/normalize";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
defaultStates,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
type WsComponentMeta,
|
|
7
|
+
type WsComponentPropsMeta,
|
|
7
8
|
} from "./component-meta";
|
|
8
9
|
import type { defaultTag } from "./form";
|
|
9
10
|
import { props } from "./__generated__/form.props";
|
|
@@ -20,6 +21,7 @@ export const meta: WsComponentMeta = {
|
|
|
20
21
|
type: "container",
|
|
21
22
|
label: "Form",
|
|
22
23
|
Icon: FormIcon,
|
|
24
|
+
states: defaultStates,
|
|
23
25
|
presetStyle,
|
|
24
26
|
children: [
|
|
25
27
|
{
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { HeadingIcon } from "@webstudio-is/icons";
|
|
2
2
|
import type { ComponentProps } from "react";
|
|
3
3
|
import { h1, h2, h3, h4, h5, h6 } from "../css/normalize";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import {
|
|
5
|
+
defaultStates,
|
|
6
|
+
type PresetStyle,
|
|
7
|
+
type WsComponentMeta,
|
|
8
|
+
type WsComponentPropsMeta,
|
|
8
9
|
} from "./component-meta";
|
|
9
10
|
import type { Heading } from "./heading";
|
|
10
11
|
import { props } from "./__generated__/heading.props";
|
|
@@ -26,6 +27,7 @@ export const meta: WsComponentMeta = {
|
|
|
26
27
|
label: "Heading",
|
|
27
28
|
Icon: HeadingIcon,
|
|
28
29
|
children: [{ type: "text", value: "Heading you can edit" }],
|
|
30
|
+
states: defaultStates,
|
|
29
31
|
presetStyle,
|
|
30
32
|
};
|
|
31
33
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ImageIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { img } from "../css/normalize";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
defaultStates,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
type WsComponentMeta,
|
|
7
|
+
type WsComponentPropsMeta,
|
|
7
8
|
} from "./component-meta";
|
|
8
9
|
import type { defaultTag } from "./image";
|
|
9
10
|
import { props } from "./__generated__/image.props";
|
|
@@ -31,6 +32,7 @@ export const meta: WsComponentMeta = {
|
|
|
31
32
|
type: "embed",
|
|
32
33
|
label: "Image",
|
|
33
34
|
Icon: ImageIcon,
|
|
35
|
+
states: defaultStates,
|
|
34
36
|
presetStyle,
|
|
35
37
|
};
|
|
36
38
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FormTextFieldIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { input } from "../css/normalize";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
defaultStates,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
type WsComponentMeta,
|
|
7
|
+
type WsComponentPropsMeta,
|
|
7
8
|
} from "./component-meta";
|
|
8
9
|
import type { defaultTag } from "./input";
|
|
9
10
|
import { props } from "./__generated__/input.props";
|
|
@@ -19,6 +20,7 @@ export const meta: WsComponentMeta = {
|
|
|
19
20
|
Icon: FormTextFieldIcon,
|
|
20
21
|
presetStyle,
|
|
21
22
|
states: [
|
|
23
|
+
...defaultStates,
|
|
22
24
|
{ selector: "::placeholder", label: "Placeholder" },
|
|
23
25
|
{ selector: ":valid", label: "Valid" },
|
|
24
26
|
{ selector: ":invalid", label: "Invalid" },
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { TextItalicIcon } from "@webstudio-is/icons";
|
|
2
2
|
import type { defaultTag } from "./italic";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
defaultStates,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
type WsComponentMeta,
|
|
7
|
+
type WsComponentPropsMeta,
|
|
7
8
|
} from "./component-meta";
|
|
8
9
|
import { props } from "./__generated__/italic.props";
|
|
9
10
|
import { i } from "../css/normalize";
|
|
@@ -22,6 +23,7 @@ export const meta: WsComponentMeta = {
|
|
|
22
23
|
type: "rich-text-child",
|
|
23
24
|
label: "Italic Text",
|
|
24
25
|
Icon: TextItalicIcon,
|
|
26
|
+
states: defaultStates,
|
|
25
27
|
presetStyle,
|
|
26
28
|
};
|
|
27
29
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TextBlockIcon } from "@webstudio-is/icons";
|
|
2
|
-
import
|
|
3
|
-
WsComponentMeta,
|
|
4
|
-
WsComponentPropsMeta,
|
|
5
|
-
PresetStyle,
|
|
2
|
+
import {
|
|
3
|
+
type WsComponentMeta,
|
|
4
|
+
type WsComponentPropsMeta,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
defaultStates,
|
|
6
7
|
} from "./component-meta";
|
|
7
8
|
import { props } from "./__generated__/label.props";
|
|
8
9
|
import type { defaultTag } from "./label";
|
|
@@ -20,6 +21,7 @@ export const meta: WsComponentMeta = {
|
|
|
20
21
|
type: "rich-text",
|
|
21
22
|
label: "Input Label",
|
|
22
23
|
Icon: TextBlockIcon,
|
|
24
|
+
states: defaultStates,
|
|
23
25
|
presetStyle,
|
|
24
26
|
children: [{ type: "text", value: "Form Label" }],
|
|
25
27
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { LinkIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { a } from "../css/normalize";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
defaultStates,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
type WsComponentMeta,
|
|
7
|
+
type WsComponentPropsMeta,
|
|
7
8
|
} from "./component-meta";
|
|
8
9
|
import type { defaultTag } from "./link";
|
|
9
10
|
import { props } from "./__generated__/link.props";
|
|
@@ -28,7 +29,18 @@ export const meta: WsComponentMeta = {
|
|
|
28
29
|
label: "Link Text",
|
|
29
30
|
Icon: LinkIcon,
|
|
30
31
|
presetStyle,
|
|
31
|
-
states: [
|
|
32
|
+
states: [
|
|
33
|
+
...defaultStates,
|
|
34
|
+
{
|
|
35
|
+
selector: ":visited",
|
|
36
|
+
label: "Visited",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
category: "component-states",
|
|
40
|
+
selector: "[aria-current=page]",
|
|
41
|
+
label: "Current page",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
32
44
|
children: [{ type: "text", value: "Link text you can edit" }],
|
|
33
45
|
};
|
|
34
46
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ListItemIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { li } from "../css/normalize";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
defaultStates,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
type WsComponentMeta,
|
|
7
|
+
type WsComponentPropsMeta,
|
|
7
8
|
} from "./component-meta";
|
|
8
9
|
import type { defaultTag } from "./list-item";
|
|
9
10
|
import { props } from "./__generated__/list-item.props";
|
|
@@ -19,6 +20,7 @@ export const meta: WsComponentMeta = {
|
|
|
19
20
|
label: "List Item",
|
|
20
21
|
Icon: ListItemIcon,
|
|
21
22
|
children: [{ type: "text", value: "List Item you can edit" }],
|
|
23
|
+
states: defaultStates,
|
|
22
24
|
presetStyle,
|
|
23
25
|
};
|
|
24
26
|
|