@webstudio-is/react-sdk 0.61.0 → 0.63.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 +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 +8 -2
- package/lib/cjs/components/checkbox-field.js +29 -0
- package/lib/cjs/components/checkbox-field.ws.js +55 -0
- package/lib/cjs/components/checkbox.js +29 -0
- package/lib/cjs/components/checkbox.ws.js +57 -0
- package/lib/cjs/components/code.ws.js +2 -0
- package/lib/cjs/components/component-meta.js +13 -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 +27 -6
- package/lib/cjs/components/heading.ws.js +2 -0
- package/lib/cjs/components/image.ws.js +2 -0
- package/lib/cjs/components/index.js +43 -2
- package/lib/cjs/components/input.ws.js +17 -3
- package/lib/cjs/components/italic.ws.js +2 -0
- package/lib/cjs/components/label.js +29 -0
- package/lib/cjs/components/label.ws.js +56 -0
- package/lib/cjs/components/link-block.ws.js +1 -1
- package/lib/cjs/components/link.ws.js +13 -1
- package/lib/cjs/components/list-item.ws.js +3 -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.js +29 -0
- package/lib/cjs/components/radio-button-field.ws.js +55 -0
- package/lib/cjs/components/radio-button.js +29 -0
- package/lib/cjs/components/radio-button.ws.js +57 -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/success-message.js +29 -0
- package/lib/cjs/components/success-message.ws.js +40 -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.js +29 -0
- package/lib/cjs/components/textarea.ws.js +58 -0
- package/lib/cjs/css/normalize.js +3 -1
- package/lib/cjs/css/presets.js +19 -1
- package/lib/cjs/index.js +2 -1
- 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 +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 +10 -2
- package/lib/components/checkbox-field.js +9 -0
- package/lib/components/checkbox-field.ws.js +37 -0
- package/lib/components/checkbox.js +9 -0
- package/lib/components/checkbox.ws.js +39 -0
- package/lib/components/code.ws.js +4 -0
- package/lib/components/component-meta.js +13 -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 +29 -6
- package/lib/components/heading.ws.js +4 -0
- package/lib/components/image.ws.js +4 -0
- package/lib/components/index.js +43 -2
- package/lib/components/input.ws.js +19 -3
- package/lib/components/italic.ws.js +4 -0
- package/lib/components/label.js +9 -0
- package/lib/components/label.ws.js +38 -0
- package/lib/components/link-block.ws.js +2 -2
- package/lib/components/link.ws.js +15 -1
- package/lib/components/list-item.ws.js +5 -0
- package/lib/components/list.ws.js +4 -0
- package/lib/components/paragraph.ws.js +4 -0
- package/lib/components/radio-button-field.js +9 -0
- package/lib/components/radio-button-field.ws.js +37 -0
- package/lib/components/radio-button.js +9 -0
- package/lib/components/radio-button.ws.js +39 -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/success-message.js +9 -0
- package/lib/components/success-message.ws.js +20 -0
- package/lib/components/superscript.ws.js +4 -0
- package/lib/components/text-block.ws.js +4 -0
- package/lib/components/textarea.js +9 -0
- package/lib/components/textarea.ws.js +40 -0
- package/lib/css/normalize.js +4 -2
- package/lib/css/presets.js +19 -1
- package/lib/index.js +4 -2
- 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/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.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/code.ws.d.ts +1 -1
- package/lib/types/components/component-meta.d.ts +17 -4
- 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/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/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/input.ws.d.ts +1 -1
- package/lib/types/components/italic.ws.d.ts +1 -1
- package/lib/types/components/label.d.ts +3 -0
- package/lib/types/components/label.ws.d.ts +3 -0
- 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.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/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/success-message.d.ts +3 -0
- package/lib/types/components/success-message.ws.d.ts +3 -0
- 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.d.ts +3 -0
- package/lib/types/components/textarea.ws.d.ts +3 -0
- package/lib/types/css/normalize.d.ts +239 -46
- package/lib/types/css/presets.d.ts +3 -2
- package/lib/types/css/style-rules.d.ts +1 -1
- package/lib/types/embed-template.d.ts +4 -4
- package/lib/types/index.d.ts +1 -1
- 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/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 +11 -5
- package/src/components/checkbox-field.tsx +10 -0
- package/src/components/checkbox-field.ws.tsx +40 -0
- package/src/components/checkbox.tsx +13 -0
- package/src/components/checkbox.ws.tsx +42 -0
- package/src/components/code.ws.tsx +6 -4
- package/src/components/component-meta.ts +12 -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 +30 -9
- package/src/components/heading.ws.tsx +6 -4
- package/src/components/image.ws.tsx +6 -4
- package/src/components/index.ts +47 -0
- package/src/components/input.tsx +3 -1
- package/src/components/input.ws.tsx +19 -5
- package/src/components/italic.ws.tsx +6 -4
- package/src/components/label.tsx +10 -0
- package/src/components/label.ws.tsx +41 -0
- package/src/components/link-block.ws.tsx +2 -2
- package/src/components/link.ws.tsx +17 -5
- package/src/components/list-item.ws.tsx +7 -4
- package/src/components/list.ws.tsx +6 -4
- package/src/components/paragraph.ws.tsx +6 -4
- package/src/components/radio-button-field.tsx +10 -0
- package/src/components/radio-button-field.ws.tsx +40 -0
- package/src/components/radio-button.tsx +13 -0
- package/src/components/radio-button.ws.tsx +42 -0
- 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/success-message.tsx +10 -0
- package/src/components/success-message.ws.tsx +24 -0
- package/src/components/superscript.ws.tsx +6 -4
- package/src/components/text-block.ws.tsx +6 -4
- package/src/components/textarea.tsx +13 -0
- package/src/components/textarea.ws.tsx +43 -0
- package/src/css/normalize.ts +21 -18
- package/src/css/presets.ts +20 -2
- package/src/index.ts +1 -0
|
@@ -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,42 @@
|
|
|
1
|
+
import { RadioCheckedIcon } from "@webstudio-is/icons";
|
|
2
|
+
import {
|
|
3
|
+
type WsComponentMeta,
|
|
4
|
+
type WsComponentPropsMeta,
|
|
5
|
+
type PresetStyle,
|
|
6
|
+
defaultStates,
|
|
7
|
+
} from "./component-meta";
|
|
8
|
+
import type { defaultTag } from "./radio-button";
|
|
9
|
+
import { input } from "../css/normalize";
|
|
10
|
+
import { props } from "./__generated__/radio-button.props";
|
|
11
|
+
|
|
12
|
+
const presetStyle = {
|
|
13
|
+
input: [
|
|
14
|
+
...input,
|
|
15
|
+
{
|
|
16
|
+
property: "marginRight",
|
|
17
|
+
value: { type: "unit", unit: "em", value: 0.5 },
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
21
|
+
|
|
22
|
+
export const meta: WsComponentMeta = {
|
|
23
|
+
type: "control",
|
|
24
|
+
label: "Radio Button",
|
|
25
|
+
Icon: RadioCheckedIcon,
|
|
26
|
+
presetStyle,
|
|
27
|
+
states: [
|
|
28
|
+
...defaultStates,
|
|
29
|
+
{ selector: ":checked", label: "Checked" },
|
|
30
|
+
{ selector: ":required", label: "Required" },
|
|
31
|
+
{ selector: ":optional", label: "Optional" },
|
|
32
|
+
{ selector: ":disabled", label: "Disabled" },
|
|
33
|
+
{ selector: ":enabled", label: "Enabled" },
|
|
34
|
+
{ selector: ":read-only", label: "Read Only" },
|
|
35
|
+
{ selector: ":read-write", label: "Read Write" },
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const propsMeta: WsComponentPropsMeta = {
|
|
40
|
+
props,
|
|
41
|
+
initialProps: ["name"],
|
|
42
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DashIcon } 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__/separator.props";
|
|
8
9
|
import type { defaultTag } from "./separator";
|
|
@@ -44,6 +45,7 @@ export const meta: WsComponentMeta = {
|
|
|
44
45
|
type: "embed",
|
|
45
46
|
label: "Separator",
|
|
46
47
|
Icon: DashIcon,
|
|
48
|
+
states: defaultStates,
|
|
47
49
|
presetStyle,
|
|
48
50
|
children: [],
|
|
49
51
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { PaintBrushIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { span } 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 "./span";
|
|
9
10
|
import { props } from "./__generated__/span.props";
|
|
@@ -16,6 +17,7 @@ export const meta: WsComponentMeta = {
|
|
|
16
17
|
type: "rich-text-child",
|
|
17
18
|
label: "Styled Text",
|
|
18
19
|
Icon: PaintBrushIcon,
|
|
20
|
+
states: defaultStates,
|
|
19
21
|
presetStyle,
|
|
20
22
|
};
|
|
21
23
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SubscriptIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { sub } 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 "./subscript";
|
|
9
10
|
import { props } from "./__generated__/subscript.props";
|
|
@@ -16,6 +17,7 @@ export const meta: WsComponentMeta = {
|
|
|
16
17
|
type: "rich-text-child",
|
|
17
18
|
label: "Subscript Text",
|
|
18
19
|
Icon: SubscriptIcon,
|
|
20
|
+
states: defaultStates,
|
|
19
21
|
presetStyle,
|
|
20
22
|
};
|
|
21
23
|
|
|
@@ -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
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SuperscriptIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { sup } 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 "./superscript";
|
|
9
10
|
import { props } from "./__generated__/superscript.props";
|
|
@@ -16,6 +17,7 @@ export const meta: WsComponentMeta = {
|
|
|
16
17
|
type: "rich-text-child",
|
|
17
18
|
label: "Superscript Text",
|
|
18
19
|
Icon: SuperscriptIcon,
|
|
20
|
+
states: defaultStates,
|
|
19
21
|
presetStyle,
|
|
20
22
|
};
|
|
21
23
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TextBlockIcon } 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__/text-block.props";
|
|
8
9
|
import type { defaultTag } from "./text-block";
|
|
@@ -23,6 +24,7 @@ export const meta: WsComponentMeta = {
|
|
|
23
24
|
type: "rich-text",
|
|
24
25
|
label: "Text Block",
|
|
25
26
|
Icon: TextBlockIcon,
|
|
27
|
+
states: defaultStates,
|
|
26
28
|
presetStyle,
|
|
27
29
|
children: [{ type: "text", value: "Block of text you can edit" }],
|
|
28
30
|
};
|
|
@@ -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,43 @@
|
|
|
1
|
+
import { FormTextAreaIcon } from "@webstudio-is/icons";
|
|
2
|
+
import { textarea } from "../css/normalize";
|
|
3
|
+
import {
|
|
4
|
+
type WsComponentMeta,
|
|
5
|
+
type WsComponentPropsMeta,
|
|
6
|
+
type PresetStyle,
|
|
7
|
+
defaultStates,
|
|
8
|
+
} from "./component-meta";
|
|
9
|
+
import type { defaultTag } from "./textarea";
|
|
10
|
+
import { props } from "./__generated__/textarea.props";
|
|
11
|
+
|
|
12
|
+
const presetStyle = {
|
|
13
|
+
textarea: [
|
|
14
|
+
...textarea,
|
|
15
|
+
// resize doesn't work well while on canvas
|
|
16
|
+
{ property: "resize", value: { type: "keyword", value: "none" } },
|
|
17
|
+
],
|
|
18
|
+
} satisfies PresetStyle<typeof defaultTag>;
|
|
19
|
+
|
|
20
|
+
export const meta: WsComponentMeta = {
|
|
21
|
+
category: "forms",
|
|
22
|
+
type: "control",
|
|
23
|
+
label: "Text Area",
|
|
24
|
+
Icon: FormTextAreaIcon,
|
|
25
|
+
presetStyle,
|
|
26
|
+
states: [
|
|
27
|
+
...defaultStates,
|
|
28
|
+
{ selector: "::placeholder", label: "Placeholder" },
|
|
29
|
+
{ selector: ":valid", label: "Valid" },
|
|
30
|
+
{ selector: ":invalid", label: "Invalid" },
|
|
31
|
+
{ selector: ":required", label: "Required" },
|
|
32
|
+
{ selector: ":optional", label: "Optional" },
|
|
33
|
+
{ selector: ":disabled", label: "Disabled" },
|
|
34
|
+
{ selector: ":enabled", label: "Enabled" },
|
|
35
|
+
{ selector: ":read-only", label: "Read Only" },
|
|
36
|
+
{ selector: ":read-write", label: "Read Write" },
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const propsMeta: WsComponentPropsMeta = {
|
|
41
|
+
props,
|
|
42
|
+
initialProps: ["name", "placeholder", "required", "autoFocus"],
|
|
43
|
+
};
|
package/src/css/normalize.ts
CHANGED
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
// webstudio custom opinionated presets
|
|
19
|
-
import { borders } from "./presets";
|
|
19
|
+
import { borders, linkColors } from "./presets";
|
|
20
20
|
import type { EmbedTemplateStyleDecl } from "../embed-template";
|
|
21
21
|
|
|
22
|
+
export type Styles = EmbedTemplateStyleDecl[];
|
|
23
|
+
|
|
22
24
|
/**
|
|
23
25
|
Use a better box model (opinionated).
|
|
24
26
|
*/
|
|
@@ -35,7 +37,7 @@ const boxSizing = {
|
|
|
35
37
|
* box-sizing: border-box;
|
|
36
38
|
}
|
|
37
39
|
*/
|
|
38
|
-
const baseStyle = [boxSizing, ...borders] satisfies
|
|
40
|
+
const baseStyle = [boxSizing, ...borders] satisfies Styles;
|
|
39
41
|
|
|
40
42
|
export const div = baseStyle;
|
|
41
43
|
export const address = baseStyle;
|
|
@@ -48,6 +50,7 @@ export const main = baseStyle;
|
|
|
48
50
|
export const nav = baseStyle;
|
|
49
51
|
export const section = baseStyle;
|
|
50
52
|
export const form = baseStyle;
|
|
53
|
+
export const label = baseStyle;
|
|
51
54
|
|
|
52
55
|
export const h1 = baseStyle;
|
|
53
56
|
export const h2 = baseStyle;
|
|
@@ -60,7 +63,7 @@ export const i = baseStyle;
|
|
|
60
63
|
|
|
61
64
|
export const img = baseStyle;
|
|
62
65
|
|
|
63
|
-
export const a =
|
|
66
|
+
export const a = [boxSizing, ...borders, ...linkColors];
|
|
64
67
|
export const li = baseStyle;
|
|
65
68
|
export const ul = baseStyle;
|
|
66
69
|
export const ol = baseStyle;
|
|
@@ -92,7 +95,7 @@ export const html = [
|
|
|
92
95
|
},
|
|
93
96
|
boxSizing,
|
|
94
97
|
...borders,
|
|
95
|
-
] satisfies
|
|
98
|
+
] satisfies Styles;
|
|
96
99
|
|
|
97
100
|
/**
|
|
98
101
|
1. Remove the margin in all browsers.
|
|
@@ -126,7 +129,7 @@ export const body = [
|
|
|
126
129
|
},
|
|
127
130
|
boxSizing,
|
|
128
131
|
...borders,
|
|
129
|
-
] satisfies
|
|
132
|
+
] satisfies Styles;
|
|
130
133
|
|
|
131
134
|
/**
|
|
132
135
|
1. Add the correct height in Firefox.
|
|
@@ -145,7 +148,7 @@ export const hr = [
|
|
|
145
148
|
},
|
|
146
149
|
boxSizing,
|
|
147
150
|
...borders,
|
|
148
|
-
] satisfies
|
|
151
|
+
] satisfies Styles;
|
|
149
152
|
|
|
150
153
|
/**
|
|
151
154
|
Add the correct text decoration in Chrome, Edge, and Safari.
|
|
@@ -167,7 +170,7 @@ export const b = [
|
|
|
167
170
|
},
|
|
168
171
|
boxSizing,
|
|
169
172
|
...borders,
|
|
170
|
-
] satisfies
|
|
173
|
+
] satisfies Styles;
|
|
171
174
|
export const strong = b;
|
|
172
175
|
|
|
173
176
|
/**
|
|
@@ -190,7 +193,7 @@ export const code = [
|
|
|
190
193
|
},
|
|
191
194
|
boxSizing,
|
|
192
195
|
...borders,
|
|
193
|
-
] satisfies
|
|
196
|
+
] satisfies Styles;
|
|
194
197
|
|
|
195
198
|
export const kbd = code;
|
|
196
199
|
export const samp = code;
|
|
@@ -207,7 +210,7 @@ export const small = [
|
|
|
207
210
|
},
|
|
208
211
|
boxSizing,
|
|
209
212
|
...borders,
|
|
210
|
-
] satisfies
|
|
213
|
+
] satisfies Styles;
|
|
211
214
|
|
|
212
215
|
/**
|
|
213
216
|
Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
|
|
@@ -232,7 +235,7 @@ const subSupBase = [
|
|
|
232
235
|
},
|
|
233
236
|
boxSizing,
|
|
234
237
|
...borders,
|
|
235
|
-
] satisfies
|
|
238
|
+
] satisfies Styles;
|
|
236
239
|
|
|
237
240
|
export const sub = [
|
|
238
241
|
...subSupBase,
|
|
@@ -240,7 +243,7 @@ export const sub = [
|
|
|
240
243
|
property: "bottom",
|
|
241
244
|
value: { type: "unit", value: -0.25, unit: "em" },
|
|
242
245
|
},
|
|
243
|
-
] satisfies
|
|
246
|
+
] satisfies Styles;
|
|
244
247
|
|
|
245
248
|
export const sup = [
|
|
246
249
|
...subSupBase,
|
|
@@ -248,7 +251,7 @@ export const sup = [
|
|
|
248
251
|
property: "top",
|
|
249
252
|
value: { type: "unit", value: -0.5, unit: "em" },
|
|
250
253
|
},
|
|
251
|
-
] satisfies
|
|
254
|
+
] satisfies Styles;
|
|
252
255
|
|
|
253
256
|
/*
|
|
254
257
|
Tabular data
|
|
@@ -285,7 +288,7 @@ export const table = [
|
|
|
285
288
|
value: { type: "keyword", value: "inherit" },
|
|
286
289
|
},
|
|
287
290
|
boxSizing,
|
|
288
|
-
] satisfies
|
|
291
|
+
] satisfies Styles;
|
|
289
292
|
|
|
290
293
|
/*
|
|
291
294
|
Forms
|
|
@@ -330,7 +333,7 @@ const buttonBase = [
|
|
|
330
333
|
},
|
|
331
334
|
boxSizing,
|
|
332
335
|
...borders,
|
|
333
|
-
] satisfies
|
|
336
|
+
] satisfies Styles;
|
|
334
337
|
|
|
335
338
|
export const input = buttonBase;
|
|
336
339
|
export const optgroup = buttonBase;
|
|
@@ -345,7 +348,7 @@ export const button = [
|
|
|
345
348
|
property: "textTransform",
|
|
346
349
|
value: { type: "keyword", value: "none" },
|
|
347
350
|
},
|
|
348
|
-
] satisfies
|
|
351
|
+
] satisfies Styles;
|
|
349
352
|
|
|
350
353
|
export const select = button;
|
|
351
354
|
|
|
@@ -417,7 +420,7 @@ export const legend = [
|
|
|
417
420
|
},
|
|
418
421
|
boxSizing,
|
|
419
422
|
...borders,
|
|
420
|
-
] satisfies
|
|
423
|
+
] satisfies Styles;
|
|
421
424
|
|
|
422
425
|
/**
|
|
423
426
|
Add the correct vertical alignment in Chrome and Firefox.
|
|
@@ -430,7 +433,7 @@ export const progress = [
|
|
|
430
433
|
},
|
|
431
434
|
boxSizing,
|
|
432
435
|
...borders,
|
|
433
|
-
] satisfies
|
|
436
|
+
] satisfies Styles;
|
|
434
437
|
|
|
435
438
|
/**
|
|
436
439
|
Correct the cursor style of increment and decrement buttons in Safari.
|
|
@@ -493,4 +496,4 @@ export const summary = [
|
|
|
493
496
|
},
|
|
494
497
|
boxSizing,
|
|
495
498
|
...borders,
|
|
496
|
-
] satisfies
|
|
499
|
+
] satisfies Styles;
|
package/src/css/presets.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Styles } from "./normalize";
|
|
2
2
|
|
|
3
|
-
export const borders:
|
|
3
|
+
export const borders: Styles = [
|
|
4
4
|
{
|
|
5
5
|
property: "borderTopWidth",
|
|
6
6
|
value: { type: "unit", value: 1, unit: "px" },
|
|
@@ -18,3 +18,21 @@ export const borders: EmbedTemplateStyleDecl[] = [
|
|
|
18
18
|
value: { type: "unit", value: 1, unit: "px" },
|
|
19
19
|
},
|
|
20
20
|
];
|
|
21
|
+
|
|
22
|
+
export const linkColors: Styles = [
|
|
23
|
+
{
|
|
24
|
+
property: "color",
|
|
25
|
+
value: { type: "rgb", r: 0, g: 0, b: 238, alpha: 1 },
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
state: ":active",
|
|
29
|
+
property: "color",
|
|
30
|
+
// chrome and safari use rgb(255, 0, 0)
|
|
31
|
+
value: { type: "rgb", r: 238, g: 0, b: 0, alpha: 1 },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
state: ":visited",
|
|
35
|
+
property: "color",
|
|
36
|
+
value: { type: "rgb", r: 85, g: 26, b: 139, alpha: 1 },
|
|
37
|
+
},
|
|
38
|
+
];
|