@webstudio-is/react-sdk 0.61.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/button.ws.js +7 -2
- 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/component-meta.js +1 -0
- 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 +25 -6
- package/lib/cjs/components/index.js +43 -2
- package/lib/cjs/components/input.ws.js +15 -3
- 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 +1 -1
- package/lib/cjs/components/list-item.ws.js +1 -0
- 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/success-message.js +29 -0
- package/lib/cjs/components/success-message.ws.js +40 -0
- package/lib/cjs/components/textarea.js +29 -0
- package/lib/cjs/components/textarea.ws.js +56 -0
- package/lib/cjs/css/normalize.js +2 -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/button.ws.js +7 -2
- 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/component-meta.js +1 -0
- 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 +25 -6
- package/lib/components/index.js +43 -2
- package/lib/components/input.ws.js +15 -3
- package/lib/components/label.js +9 -0
- package/lib/components/label.ws.js +34 -0
- package/lib/components/link-block.ws.js +2 -2
- package/lib/components/list-item.ws.js +1 -0
- 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/success-message.js +9 -0
- package/lib/components/success-message.ws.js +20 -0
- package/lib/components/textarea.js +9 -0
- package/lib/components/textarea.ws.js +36 -0
- package/lib/css/normalize.js +2 -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/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 +3 -0
- 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 +237 -46
- package/lib/types/css/style-rules.d.ts +1 -1
- package/lib/types/embed-template.d.ts +4 -4
- package/package.json +12 -12
- 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/button.ws.tsx +6 -1
- 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/component-meta.ts +1 -0
- 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 +24 -5
- package/src/components/index.ts +47 -0
- package/src/components/input.tsx +3 -1
- package/src/components/input.ws.tsx +13 -1
- package/src/components/label.tsx +10 -0
- package/src/components/label.ws.tsx +39 -0
- package/src/components/link-block.ws.tsx +2 -2
- package/src/components/list-item.ws.tsx +1 -0
- 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/success-message.tsx +10 -0
- package/src/components/success-message.ws.tsx +24 -0
- package/src/components/textarea.tsx +13 -0
- package/src/components/textarea.ws.tsx +41 -0
- package/src/css/normalize.ts +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BoxIcon } from "@webstudio-is/icons";
|
|
2
|
+
import type {
|
|
3
|
+
WsComponentMeta,
|
|
4
|
+
WsComponentPropsMeta,
|
|
5
|
+
PresetStyle,
|
|
6
|
+
} from "./component-meta";
|
|
7
|
+
import { props } from "./__generated__/error-message.props";
|
|
8
|
+
import { div } from "../css/normalize";
|
|
9
|
+
|
|
10
|
+
const presetStyle = {
|
|
11
|
+
div,
|
|
12
|
+
} satisfies PresetStyle<"div">;
|
|
13
|
+
|
|
14
|
+
export const meta: WsComponentMeta = {
|
|
15
|
+
type: "container",
|
|
16
|
+
label: "Error Message",
|
|
17
|
+
Icon: BoxIcon,
|
|
18
|
+
presetStyle,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const propsMeta: WsComponentPropsMeta = {
|
|
22
|
+
props,
|
|
23
|
+
initialProps: [],
|
|
24
|
+
};
|
package/src/components/form.tsx
CHANGED
|
@@ -5,6 +5,10 @@ export const defaultTag = "form";
|
|
|
5
5
|
export const Form = forwardRef<
|
|
6
6
|
ElementRef<typeof defaultTag>,
|
|
7
7
|
ComponentProps<typeof defaultTag>
|
|
8
|
-
>((props, ref) =>
|
|
8
|
+
>(({ children, ...props }, ref) => (
|
|
9
|
+
<form {...props} ref={ref}>
|
|
10
|
+
{children}
|
|
11
|
+
</form>
|
|
12
|
+
));
|
|
9
13
|
|
|
10
14
|
Form.displayName = "Form";
|
|
@@ -11,10 +11,7 @@ import { props } from "./__generated__/form.props";
|
|
|
11
11
|
const presetStyle = {
|
|
12
12
|
form: [
|
|
13
13
|
...form,
|
|
14
|
-
{
|
|
15
|
-
property: "minHeight",
|
|
16
|
-
value: { type: "unit", unit: "px", value: 20 },
|
|
17
|
-
},
|
|
14
|
+
{ property: "minHeight", value: { type: "unit", unit: "px", value: 20 } },
|
|
18
15
|
],
|
|
19
16
|
} satisfies PresetStyle<typeof defaultTag>;
|
|
20
17
|
|
|
@@ -25,7 +22,28 @@ export const meta: WsComponentMeta = {
|
|
|
25
22
|
Icon: FormIcon,
|
|
26
23
|
presetStyle,
|
|
27
24
|
children: [
|
|
28
|
-
{
|
|
25
|
+
{
|
|
26
|
+
type: "instance",
|
|
27
|
+
component: "Label",
|
|
28
|
+
children: [{ type: "text", value: "Name" }],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "instance",
|
|
32
|
+
component: "Input",
|
|
33
|
+
props: [{ type: "string", name: "name", value: "name" }],
|
|
34
|
+
children: [],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: "instance",
|
|
38
|
+
component: "Label",
|
|
39
|
+
children: [{ type: "text", value: "Email" }],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "instance",
|
|
43
|
+
component: "Input",
|
|
44
|
+
props: [{ type: "string", name: "email", value: "email" }],
|
|
45
|
+
children: [],
|
|
46
|
+
},
|
|
29
47
|
{
|
|
30
48
|
type: "instance",
|
|
31
49
|
component: "Button",
|
|
@@ -36,4 +54,5 @@ export const meta: WsComponentMeta = {
|
|
|
36
54
|
|
|
37
55
|
export const propsMeta: WsComponentPropsMeta = {
|
|
38
56
|
props,
|
|
57
|
+
initialProps: [],
|
|
39
58
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -25,6 +25,14 @@ import { meta as ListMeta } from "./list.ws";
|
|
|
25
25
|
import { meta as ListItemMeta } from "./list-item.ws";
|
|
26
26
|
import { meta as SeparatorMeta } from "./separator.ws";
|
|
27
27
|
import { meta as CodeMeta } from "./code.ws";
|
|
28
|
+
import { meta as LabelMeta } from "./label.ws";
|
|
29
|
+
import { meta as SuccessMessageMeta } from "./success-message.ws";
|
|
30
|
+
import { meta as ErrorMessageMeta } from "./error-message.ws";
|
|
31
|
+
import { meta as TextareaMeta } from "./textarea.ws";
|
|
32
|
+
import { meta as RadioButtonFieldMeta } from "./radio-button-field.ws";
|
|
33
|
+
import { meta as RadioButtonMeta } from "./radio-button.ws";
|
|
34
|
+
import { meta as CheckboxFieldMeta } from "./checkbox-field.ws";
|
|
35
|
+
import { meta as CheckboxMeta } from "./checkbox.ws";
|
|
28
36
|
|
|
29
37
|
// these are huge JSON objects that we want to be tree-shaken when not used!
|
|
30
38
|
import { propsMeta as SlotMetaPropsMeta } from "./slot.ws";
|
|
@@ -51,6 +59,14 @@ import { propsMeta as ListPropsMeta } from "./list.ws";
|
|
|
51
59
|
import { propsMeta as ListItemPropsMeta } from "./list-item.ws";
|
|
52
60
|
import { propsMeta as SeparatorPropsMeta } from "./separator.ws";
|
|
53
61
|
import { propsMeta as CodePropsMeta } from "./code.ws";
|
|
62
|
+
import { propsMeta as LabelPropsMeta } from "./label.ws";
|
|
63
|
+
import { propsMeta as SuccessMessagePropsMeta } from "./success-message.ws";
|
|
64
|
+
import { propsMeta as ErrorMessagePropsMeta } from "./error-message.ws";
|
|
65
|
+
import { propsMeta as TextareaPropsMeta } from "./textarea.ws";
|
|
66
|
+
import { propsMeta as RadioButtonFieldPropsMeta } from "./radio-button-field.ws";
|
|
67
|
+
import { propsMeta as RadioButtonPropsMeta } from "./radio-button.ws";
|
|
68
|
+
import { propsMeta as CheckboxFieldPropsMeta } from "./checkbox-field.ws";
|
|
69
|
+
import { propsMeta as CheckboxPropsMeta } from "./checkbox.ws";
|
|
54
70
|
|
|
55
71
|
// @todo this list should not be hardcoded!
|
|
56
72
|
const defaultMetas: Record<string, WsComponentMeta> = {
|
|
@@ -78,6 +94,14 @@ const defaultMetas: Record<string, WsComponentMeta> = {
|
|
|
78
94
|
ListItem: ListItemMeta,
|
|
79
95
|
Separator: SeparatorMeta,
|
|
80
96
|
Code: CodeMeta,
|
|
97
|
+
Label: LabelMeta,
|
|
98
|
+
SuccessMessage: SuccessMessageMeta,
|
|
99
|
+
ErrorMessage: ErrorMessageMeta,
|
|
100
|
+
Textarea: TextareaMeta,
|
|
101
|
+
RadioButtonField: RadioButtonFieldMeta,
|
|
102
|
+
RadioButton: RadioButtonMeta,
|
|
103
|
+
CheckboxField: CheckboxFieldMeta,
|
|
104
|
+
Checkbox: CheckboxMeta,
|
|
81
105
|
};
|
|
82
106
|
|
|
83
107
|
let currentMetas = defaultMetas;
|
|
@@ -122,6 +146,14 @@ const defaultPropsMetasRaw = {
|
|
|
122
146
|
ListItem: ListItemPropsMeta,
|
|
123
147
|
Separator: SeparatorPropsMeta,
|
|
124
148
|
Code: CodePropsMeta,
|
|
149
|
+
Label: LabelPropsMeta,
|
|
150
|
+
SuccessMessage: SuccessMessagePropsMeta,
|
|
151
|
+
ErrorMessage: ErrorMessagePropsMeta,
|
|
152
|
+
Textarea: TextareaPropsMeta,
|
|
153
|
+
RadioButtonField: RadioButtonFieldPropsMeta,
|
|
154
|
+
RadioButton: RadioButtonPropsMeta,
|
|
155
|
+
CheckboxField: CheckboxFieldPropsMeta,
|
|
156
|
+
Checkbox: CheckboxPropsMeta,
|
|
125
157
|
} as const;
|
|
126
158
|
|
|
127
159
|
const defaultPropsMetas: Record<string, WsComponentPropsMeta> =
|
|
@@ -219,3 +251,18 @@ const computeInitialProps = (
|
|
|
219
251
|
// order of initialProps must be preserved
|
|
220
252
|
return [...initialProps, ...requiredProps];
|
|
221
253
|
};
|
|
254
|
+
|
|
255
|
+
export const canAcceptComponent = (
|
|
256
|
+
parentComponent: string,
|
|
257
|
+
childComponent: string
|
|
258
|
+
) => {
|
|
259
|
+
const parentMeta = getComponentMeta(parentComponent);
|
|
260
|
+
const childMeta = getComponentMeta(childComponent);
|
|
261
|
+
if (parentMeta?.type !== "container" || childMeta === undefined) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
return (
|
|
265
|
+
childMeta.acceptedParents === undefined ||
|
|
266
|
+
childMeta.acceptedParents.includes(parentComponent)
|
|
267
|
+
);
|
|
268
|
+
};
|
package/src/components/input.tsx
CHANGED
|
@@ -4,7 +4,9 @@ export const defaultTag = "input";
|
|
|
4
4
|
|
|
5
5
|
export const Input = forwardRef<
|
|
6
6
|
ElementRef<typeof defaultTag>,
|
|
7
|
-
ComponentProps<typeof defaultTag>
|
|
7
|
+
ComponentProps<typeof defaultTag> & {
|
|
8
|
+
type?: "text" | "email" | "password" | "number" | "tel" | "url";
|
|
9
|
+
}
|
|
8
10
|
// Make sure children are not passed down to an input, because this will result in error.
|
|
9
11
|
>(({ children: _children, ...props }, ref) => <input {...props} ref={ref} />);
|
|
10
12
|
|
|
@@ -15,11 +15,23 @@ const presetStyle = {
|
|
|
15
15
|
export const meta: WsComponentMeta = {
|
|
16
16
|
category: "forms",
|
|
17
17
|
type: "control",
|
|
18
|
-
label: "
|
|
18
|
+
label: "Text Field",
|
|
19
19
|
Icon: FormTextFieldIcon,
|
|
20
20
|
presetStyle,
|
|
21
|
+
states: [
|
|
22
|
+
{ selector: "::placeholder", label: "Placeholder" },
|
|
23
|
+
{ selector: ":valid", label: "Valid" },
|
|
24
|
+
{ selector: ":invalid", label: "Invalid" },
|
|
25
|
+
{ selector: ":required", label: "Required" },
|
|
26
|
+
{ selector: ":optional", label: "Optional" },
|
|
27
|
+
{ selector: ":disabled", label: "Disabled" },
|
|
28
|
+
{ selector: ":enabled", label: "Enabled" },
|
|
29
|
+
{ selector: ":read-only", label: "Read Only" },
|
|
30
|
+
{ selector: ":read-write", label: "Read Write" },
|
|
31
|
+
],
|
|
21
32
|
};
|
|
22
33
|
|
|
23
34
|
export const propsMeta: WsComponentPropsMeta = {
|
|
24
35
|
props,
|
|
36
|
+
initialProps: ["name", "type", "placeholder", "required", "autoFocus"],
|
|
25
37
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { forwardRef, type ElementRef, type ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const defaultTag = "label";
|
|
4
|
+
|
|
5
|
+
export const Label = forwardRef<
|
|
6
|
+
ElementRef<typeof defaultTag>,
|
|
7
|
+
ComponentProps<typeof defaultTag>
|
|
8
|
+
>((props, ref) => <label {...props} ref={ref} />);
|
|
9
|
+
|
|
10
|
+
Label.displayName = "Label";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TextBlockIcon } from "@webstudio-is/icons";
|
|
2
|
+
import type {
|
|
3
|
+
WsComponentMeta,
|
|
4
|
+
WsComponentPropsMeta,
|
|
5
|
+
PresetStyle,
|
|
6
|
+
} from "./component-meta";
|
|
7
|
+
import { props } from "./__generated__/label.props";
|
|
8
|
+
import type { defaultTag } from "./label";
|
|
9
|
+
import { label } from "../css/normalize";
|
|
10
|
+
|
|
11
|
+
const presetStyle = {
|
|
12
|
+
label: [
|
|
13
|
+
...label,
|
|
14
|
+
{ property: "display", value: { type: "keyword", value: "block" } },
|
|
15
|
+
],
|
|
16
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
17
|
+
|
|
18
|
+
export const meta: WsComponentMeta = {
|
|
19
|
+
category: "forms",
|
|
20
|
+
type: "rich-text",
|
|
21
|
+
label: "Input Label",
|
|
22
|
+
Icon: TextBlockIcon,
|
|
23
|
+
presetStyle,
|
|
24
|
+
children: [{ type: "text", value: "Form Label" }],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const propsMeta: WsComponentPropsMeta = {
|
|
28
|
+
props: {
|
|
29
|
+
...props,
|
|
30
|
+
htmlFor: {
|
|
31
|
+
required: false,
|
|
32
|
+
control: "text",
|
|
33
|
+
type: "string",
|
|
34
|
+
rows: 0,
|
|
35
|
+
label: "For",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
initialProps: ["htmlFor"],
|
|
39
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinkBlockIcon } from "@webstudio-is/icons";
|
|
2
2
|
import type {
|
|
3
3
|
PresetStyle,
|
|
4
4
|
WsComponentMeta,
|
|
@@ -23,7 +23,7 @@ export const meta: WsComponentMeta = {
|
|
|
23
23
|
category: "general",
|
|
24
24
|
type: "container",
|
|
25
25
|
label: "Link Block",
|
|
26
|
-
Icon:
|
|
26
|
+
Icon: LinkBlockIcon,
|
|
27
27
|
states: linkMeta.states,
|
|
28
28
|
presetStyle,
|
|
29
29
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { forwardRef, type ElementRef, type ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const defaultTag = "label";
|
|
4
|
+
|
|
5
|
+
export const RadioButtonField = forwardRef<
|
|
6
|
+
ElementRef<typeof defaultTag>,
|
|
7
|
+
Omit<ComponentProps<typeof defaultTag>, "htmlFor">
|
|
8
|
+
>((props, ref) => <label {...props} ref={ref} />);
|
|
9
|
+
|
|
10
|
+
RadioButtonField.displayName = "RadioButtonField";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RadioCheckedIcon } from "@webstudio-is/icons";
|
|
2
|
+
import type {
|
|
3
|
+
WsComponentMeta,
|
|
4
|
+
WsComponentPropsMeta,
|
|
5
|
+
PresetStyle,
|
|
6
|
+
} from "./component-meta";
|
|
7
|
+
import { props } from "./__generated__/radio-button-field.props";
|
|
8
|
+
import type { defaultTag } from "./radio-button-field";
|
|
9
|
+
import { label } from "../css/normalize";
|
|
10
|
+
|
|
11
|
+
const presetStyle = {
|
|
12
|
+
label: [
|
|
13
|
+
...label,
|
|
14
|
+
{ property: "display", value: { type: "keyword", value: "flex" } },
|
|
15
|
+
],
|
|
16
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
17
|
+
|
|
18
|
+
export const meta: WsComponentMeta = {
|
|
19
|
+
category: "forms",
|
|
20
|
+
type: "container",
|
|
21
|
+
label: "Radio Button Field",
|
|
22
|
+
Icon: RadioCheckedIcon,
|
|
23
|
+
presetStyle,
|
|
24
|
+
children: [
|
|
25
|
+
{ type: "instance", component: "RadioButton", props: [], children: [] },
|
|
26
|
+
{
|
|
27
|
+
type: "instance",
|
|
28
|
+
component: "TextBlock",
|
|
29
|
+
props: [],
|
|
30
|
+
children: [{ type: "text", value: "Radio" }],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const propsMeta: WsComponentPropsMeta = {
|
|
36
|
+
props,
|
|
37
|
+
initialProps: [],
|
|
38
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { forwardRef, type ElementRef, type ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const defaultTag = "input";
|
|
4
|
+
|
|
5
|
+
export const RadioButton = forwardRef<
|
|
6
|
+
ElementRef<typeof defaultTag>,
|
|
7
|
+
Omit<ComponentProps<typeof defaultTag>, "type">
|
|
8
|
+
// Make sure children are not passed down to an input, because this will result in error.
|
|
9
|
+
>(({ children: _children, ...props }, ref) => (
|
|
10
|
+
<input {...props} type="radio" ref={ref} />
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
RadioButton.displayName = "RadioButton";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RadioCheckedIcon } from "@webstudio-is/icons";
|
|
2
|
+
import type {
|
|
3
|
+
WsComponentMeta,
|
|
4
|
+
WsComponentPropsMeta,
|
|
5
|
+
PresetStyle,
|
|
6
|
+
} from "./component-meta";
|
|
7
|
+
import type { defaultTag } from "./radio-button";
|
|
8
|
+
import { input } from "../css/normalize";
|
|
9
|
+
import { props } from "./__generated__/radio-button.props";
|
|
10
|
+
|
|
11
|
+
const presetStyle = {
|
|
12
|
+
input: [
|
|
13
|
+
...input,
|
|
14
|
+
{
|
|
15
|
+
property: "marginRight",
|
|
16
|
+
value: { type: "unit", unit: "em", value: 0.5 },
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
20
|
+
|
|
21
|
+
export const meta: WsComponentMeta = {
|
|
22
|
+
type: "control",
|
|
23
|
+
label: "Radio Button",
|
|
24
|
+
Icon: RadioCheckedIcon,
|
|
25
|
+
presetStyle,
|
|
26
|
+
states: [
|
|
27
|
+
{ selector: ":checked", label: "Checked" },
|
|
28
|
+
{ selector: ":required", label: "Required" },
|
|
29
|
+
{ selector: ":optional", label: "Optional" },
|
|
30
|
+
{ selector: ":disabled", label: "Disabled" },
|
|
31
|
+
{ selector: ":enabled", label: "Enabled" },
|
|
32
|
+
{ selector: ":read-only", label: "Read Only" },
|
|
33
|
+
{ selector: ":read-write", label: "Read Write" },
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const propsMeta: WsComponentPropsMeta = {
|
|
38
|
+
props,
|
|
39
|
+
initialProps: ["name"],
|
|
40
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { forwardRef, type ElementRef, type ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const defaultTag = "div";
|
|
4
|
+
|
|
5
|
+
export const SuccessMessage = forwardRef<
|
|
6
|
+
ElementRef<typeof defaultTag>,
|
|
7
|
+
ComponentProps<typeof defaultTag>
|
|
8
|
+
>((props, ref) => <div {...props} ref={ref} />);
|
|
9
|
+
|
|
10
|
+
SuccessMessage.displayName = "SuccessMessage";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BoxIcon } from "@webstudio-is/icons";
|
|
2
|
+
import type {
|
|
3
|
+
WsComponentMeta,
|
|
4
|
+
WsComponentPropsMeta,
|
|
5
|
+
PresetStyle,
|
|
6
|
+
} from "./component-meta";
|
|
7
|
+
import { props } from "./__generated__/success-message.props";
|
|
8
|
+
import { div } from "../css/normalize";
|
|
9
|
+
|
|
10
|
+
const presetStyle = {
|
|
11
|
+
div,
|
|
12
|
+
} satisfies PresetStyle<"div">;
|
|
13
|
+
|
|
14
|
+
export const meta: WsComponentMeta = {
|
|
15
|
+
type: "container",
|
|
16
|
+
label: "Success Message",
|
|
17
|
+
Icon: BoxIcon,
|
|
18
|
+
presetStyle,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const propsMeta: WsComponentPropsMeta = {
|
|
22
|
+
props,
|
|
23
|
+
initialProps: [],
|
|
24
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { forwardRef, type ElementRef, type ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const defaultTag = "textarea";
|
|
4
|
+
|
|
5
|
+
export const Textarea = forwardRef<
|
|
6
|
+
ElementRef<typeof defaultTag>,
|
|
7
|
+
ComponentProps<typeof defaultTag>
|
|
8
|
+
// Make sure children are not passed down to an textarea, because this will result in error.
|
|
9
|
+
>(({ children: _children, ...props }, ref) => (
|
|
10
|
+
<textarea {...props} ref={ref} />
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
Textarea.displayName = "Textarea";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FormTextAreaIcon } from "@webstudio-is/icons";
|
|
2
|
+
import { textarea } from "../css/normalize";
|
|
3
|
+
import type {
|
|
4
|
+
WsComponentMeta,
|
|
5
|
+
WsComponentPropsMeta,
|
|
6
|
+
PresetStyle,
|
|
7
|
+
} from "./component-meta";
|
|
8
|
+
import type { defaultTag } from "./textarea";
|
|
9
|
+
import { props } from "./__generated__/textarea.props";
|
|
10
|
+
|
|
11
|
+
const presetStyle = {
|
|
12
|
+
textarea: [
|
|
13
|
+
...textarea,
|
|
14
|
+
// resize doesn't work well while on canvas
|
|
15
|
+
{ property: "resize", value: { type: "keyword", value: "none" } },
|
|
16
|
+
],
|
|
17
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
18
|
+
|
|
19
|
+
export const meta: WsComponentMeta = {
|
|
20
|
+
category: "forms",
|
|
21
|
+
type: "control",
|
|
22
|
+
label: "Text Area",
|
|
23
|
+
Icon: FormTextAreaIcon,
|
|
24
|
+
presetStyle,
|
|
25
|
+
states: [
|
|
26
|
+
{ selector: "::placeholder", label: "Placeholder" },
|
|
27
|
+
{ selector: ":valid", label: "Valid" },
|
|
28
|
+
{ selector: ":invalid", label: "Invalid" },
|
|
29
|
+
{ selector: ":required", label: "Required" },
|
|
30
|
+
{ selector: ":optional", label: "Optional" },
|
|
31
|
+
{ selector: ":disabled", label: "Disabled" },
|
|
32
|
+
{ selector: ":enabled", label: "Enabled" },
|
|
33
|
+
{ selector: ":read-only", label: "Read Only" },
|
|
34
|
+
{ selector: ":read-write", label: "Read Write" },
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const propsMeta: WsComponentPropsMeta = {
|
|
39
|
+
props,
|
|
40
|
+
initialProps: ["name", "placeholder", "required", "autoFocus"],
|
|
41
|
+
};
|
package/src/css/normalize.ts
CHANGED