@webstudio-is/sdk-components-react 0.95.0 → 0.97.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.
Files changed (128) hide show
  1. package/lib/components.js +747 -33
  2. package/lib/metas.js +3635 -33
  3. package/lib/props.js +16274 -33
  4. package/lib/types/vimeo-preview-image.d.ts +2 -2
  5. package/package.json +8 -8
  6. package/lib/__generated__/blockquote.props.js +0 -514
  7. package/lib/__generated__/body.props.js +0 -508
  8. package/lib/__generated__/bold.props.js +0 -508
  9. package/lib/__generated__/box.props.js +0 -527
  10. package/lib/__generated__/button.props.js +0 -564
  11. package/lib/__generated__/checkbox.props.js +0 -666
  12. package/lib/__generated__/code-text.props.js +0 -508
  13. package/lib/__generated__/form.props.js +0 -556
  14. package/lib/__generated__/fragment.props.js +0 -2
  15. package/lib/__generated__/heading.props.js +0 -516
  16. package/lib/__generated__/html-embed.props.js +0 -9
  17. package/lib/__generated__/image.props.js +0 -581
  18. package/lib/__generated__/input.props.js +0 -673
  19. package/lib/__generated__/italic.props.js +0 -508
  20. package/lib/__generated__/label.props.js +0 -520
  21. package/lib/__generated__/link.props.js +0 -562
  22. package/lib/__generated__/list-item.props.js +0 -508
  23. package/lib/__generated__/list.props.js +0 -534
  24. package/lib/__generated__/paragraph.props.js +0 -508
  25. package/lib/__generated__/radio-button.props.js +0 -666
  26. package/lib/__generated__/rich-text-link.props.js +0 -562
  27. package/lib/__generated__/separator.props.js +0 -508
  28. package/lib/__generated__/slot.props.js +0 -2
  29. package/lib/__generated__/span.props.js +0 -508
  30. package/lib/__generated__/subscript.props.js +0 -508
  31. package/lib/__generated__/superscript.props.js +0 -508
  32. package/lib/__generated__/text.props.js +0 -516
  33. package/lib/__generated__/textarea.props.js +0 -575
  34. package/lib/__generated__/vimeo-play-button.props.js +0 -563
  35. package/lib/__generated__/vimeo-preview-image.props.js +0 -580
  36. package/lib/__generated__/vimeo-spinner.props.js +0 -508
  37. package/lib/__generated__/vimeo.props.js +0 -665
  38. package/lib/blockquote.js +0 -12
  39. package/lib/blockquote.stories.js +0 -11
  40. package/lib/blockquote.ws.js +0 -75
  41. package/lib/body.js +0 -6
  42. package/lib/body.stories.js +0 -11
  43. package/lib/body.ws.js +0 -31
  44. package/lib/bold.js +0 -6
  45. package/lib/bold.stories.js +0 -11
  46. package/lib/bold.ws.js +0 -21
  47. package/lib/box.js +0 -12
  48. package/lib/box.stories.js +0 -11
  49. package/lib/box.ws.js +0 -44
  50. package/lib/button.js +0 -8
  51. package/lib/button.stories.js +0 -11
  52. package/lib/button.ws.js +0 -36
  53. package/lib/checkbox.js +0 -6
  54. package/lib/checkbox.ws.js +0 -57
  55. package/lib/code-text.js +0 -10
  56. package/lib/code-text.stories.js +0 -11
  57. package/lib/code-text.ws.js +0 -54
  58. package/lib/form.js +0 -6
  59. package/lib/form.stories.js +0 -11
  60. package/lib/form.ws.js +0 -63
  61. package/lib/fragment.js +0 -7
  62. package/lib/fragment.ws.js +0 -10
  63. package/lib/heading.js +0 -12
  64. package/lib/heading.stories.js +0 -11
  65. package/lib/heading.ws.js +0 -37
  66. package/lib/html-embed.js +0 -63
  67. package/lib/html-embed.stories.js +0 -11
  68. package/lib/html-embed.ws.js +0 -28
  69. package/lib/image.js +0 -74
  70. package/lib/image.stories.js +0 -7
  71. package/lib/image.ws.js +0 -48
  72. package/lib/input.js +0 -6
  73. package/lib/input.stories.js +0 -9
  74. package/lib/input.ws.js +0 -43
  75. package/lib/italic.js +0 -6
  76. package/lib/italic.stories.js +0 -11
  77. package/lib/italic.ws.js +0 -27
  78. package/lib/label.js +0 -6
  79. package/lib/label.ws.js +0 -40
  80. package/lib/link.js +0 -33
  81. package/lib/link.stories.js +0 -11
  82. package/lib/link.ws.js +0 -60
  83. package/lib/list-item.js +0 -12
  84. package/lib/list-item.stories.js +0 -11
  85. package/lib/list-item.ws.js +0 -32
  86. package/lib/list.js +0 -12
  87. package/lib/list.stories.js +0 -13
  88. package/lib/list.ws.js +0 -53
  89. package/lib/paragraph.js +0 -6
  90. package/lib/paragraph.stories.js +0 -11
  91. package/lib/paragraph.ws.js +0 -32
  92. package/lib/radio-button.js +0 -6
  93. package/lib/radio-button.ws.js +0 -58
  94. package/lib/rich-text-link.js +0 -6
  95. package/lib/rich-text-link.stories.js +0 -11
  96. package/lib/rich-text-link.ws.js +0 -9
  97. package/lib/separator.js +0 -12
  98. package/lib/separator.stories.js +0 -7
  99. package/lib/separator.ws.js +0 -50
  100. package/lib/slot.js +0 -14
  101. package/lib/slot.stories.js +0 -11
  102. package/lib/slot.ws.js +0 -14
  103. package/lib/span.js +0 -6
  104. package/lib/span.stories.js +0 -11
  105. package/lib/span.ws.js +0 -21
  106. package/lib/subscript.js +0 -6
  107. package/lib/subscript.stories.js +0 -11
  108. package/lib/subscript.ws.js +0 -21
  109. package/lib/superscript.js +0 -6
  110. package/lib/superscript.stories.js +0 -11
  111. package/lib/superscript.ws.js +0 -21
  112. package/lib/text.js +0 -12
  113. package/lib/text.stories.js +0 -11
  114. package/lib/text.ws.js +0 -37
  115. package/lib/textarea.js +0 -6
  116. package/lib/textarea.ws.js +0 -44
  117. package/lib/vimeo-play-button.js +0 -19
  118. package/lib/vimeo-play-button.stories.js +0 -11
  119. package/lib/vimeo-play-button.ws.js +0 -25
  120. package/lib/vimeo-preview-image.js +0 -21
  121. package/lib/vimeo-preview-image.stories.js +0 -11
  122. package/lib/vimeo-preview-image.ws.js +0 -19
  123. package/lib/vimeo-spinner.js +0 -18
  124. package/lib/vimeo-spinner.stories.js +0 -11
  125. package/lib/vimeo-spinner.ws.js +0 -23
  126. package/lib/vimeo.js +0 -279
  127. package/lib/vimeo.stories.js +0 -11
  128. package/lib/vimeo.ws.js +0 -327
@@ -1,75 +0,0 @@
1
- "use strict";
2
- import { BlockquoteIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import { props } from "./__generated__/blockquote.props";
7
- const presetStyle = {
8
- blockquote: [
9
- {
10
- property: "marginTop",
11
- value: { type: "unit", value: 0, unit: "number" }
12
- },
13
- {
14
- property: "marginRight",
15
- value: { type: "unit", value: 0, unit: "number" }
16
- },
17
- {
18
- property: "marginBottom",
19
- value: { type: "unit", value: 10, unit: "px" }
20
- },
21
- {
22
- property: "marginLeft",
23
- value: { type: "unit", value: 0, unit: "number" }
24
- },
25
- {
26
- property: "paddingTop",
27
- value: { type: "unit", value: 10, unit: "px" }
28
- },
29
- {
30
- property: "paddingBottom",
31
- value: { type: "unit", value: 10, unit: "px" }
32
- },
33
- {
34
- property: "paddingLeft",
35
- value: { type: "unit", value: 20, unit: "px" }
36
- },
37
- {
38
- property: "paddingRight",
39
- value: { type: "unit", value: 20, unit: "px" }
40
- },
41
- {
42
- property: "borderLeftWidth",
43
- value: { type: "unit", value: 5, unit: "px" }
44
- },
45
- {
46
- property: "borderLeftStyle",
47
- value: { type: "keyword", value: "solid" }
48
- },
49
- {
50
- property: "borderLeftColor",
51
- value: { type: "rgb", r: 226, g: 226, b: 226, alpha: 1 }
52
- }
53
- ]
54
- };
55
- export const meta = {
56
- category: "text",
57
- type: "container",
58
- label: "Blockquote",
59
- description: "Use to style a quote from an external source like an article or book.",
60
- icon: BlockquoteIcon,
61
- states: defaultStates,
62
- presetStyle,
63
- template: [
64
- {
65
- type: "instance",
66
- component: "Blockquote",
67
- children: [{ type: "text", value: "Blockquote you can edit" }]
68
- }
69
- ],
70
- order: 3
71
- };
72
- export const propsMeta = {
73
- props,
74
- initialProps: ["id", "cite"]
75
- };
package/lib/body.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import { forwardRef } from "react";
4
- export const defaultTag = "body";
5
- export const Body = forwardRef((props, ref) => /* @__PURE__ */ jsx("body", { ...props, ref }));
6
- Body.displayName = "Body";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- import { Body as BodyPrimitive } from "./body";
3
- export default {
4
- title: "Components/Body",
5
- component: BodyPrimitive
6
- };
7
- export const Body = {
8
- args: {
9
- children: "Body"
10
- }
11
- };
package/lib/body.ws.js DELETED
@@ -1,31 +0,0 @@
1
- "use strict";
2
- import { BodyIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import { body } from "@webstudio-is/react-sdk/css-normalize";
7
- import { props } from "./__generated__/body.props";
8
- const presetStyle = {
9
- body: [
10
- ...body,
11
- {
12
- property: "WebkitFontSmoothing",
13
- value: { type: "keyword", value: "antialiased" }
14
- },
15
- {
16
- property: "MozOsxFontSmoothing",
17
- value: { type: "keyword", value: "grayscale" }
18
- }
19
- ]
20
- };
21
- export const meta = {
22
- type: "container",
23
- label: "Body",
24
- icon: BodyIcon,
25
- states: defaultStates,
26
- presetStyle
27
- };
28
- export const propsMeta = {
29
- props,
30
- initialProps: ["id"]
31
- };
package/lib/bold.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import { forwardRef } from "react";
4
- export const defaultTag = "b";
5
- export const Bold = forwardRef((props, ref) => /* @__PURE__ */ jsx("b", { ...props, ref }));
6
- Bold.displayName = "Bold";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- import { Bold as BoldPrimitive } from "./bold";
3
- export default {
4
- title: "Components/Bold",
5
- component: BoldPrimitive
6
- };
7
- export const Bold = {
8
- args: {
9
- children: "some bold text"
10
- }
11
- };
package/lib/bold.ws.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- import { BoldIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import { b } from "@webstudio-is/react-sdk/css-normalize";
7
- import { props } from "./__generated__/bold.props";
8
- const presetStyle = {
9
- b
10
- };
11
- export const meta = {
12
- type: "rich-text-child",
13
- label: "Bold Text",
14
- icon: BoldIcon,
15
- states: defaultStates,
16
- presetStyle
17
- };
18
- export const propsMeta = {
19
- props,
20
- initialProps: ["id"]
21
- };
package/lib/box.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- import {
3
- createElement,
4
- forwardRef
5
- } from "react";
6
- export const defaultTag = "div";
7
- export const Box = forwardRef(
8
- ({ tag = defaultTag, ...props }, ref) => {
9
- return createElement(tag, { ...props, ref });
10
- }
11
- );
12
- Box.displayName = "Box";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- import { Box as BoxPrimitive } from "./box";
3
- export default {
4
- title: "Components/Box",
5
- component: BoxPrimitive
6
- };
7
- export const Box = {
8
- args: {
9
- children: "Box"
10
- }
11
- };
package/lib/box.ws.js DELETED
@@ -1,44 +0,0 @@
1
- "use strict";
2
- import { BoxIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import {
7
- div,
8
- address,
9
- article,
10
- aside,
11
- figure,
12
- footer,
13
- header,
14
- main,
15
- nav,
16
- section
17
- } from "@webstudio-is/react-sdk/css-normalize";
18
- import { props } from "./__generated__/box.props";
19
- const presetStyle = {
20
- div,
21
- address,
22
- article,
23
- aside,
24
- figure,
25
- footer,
26
- header,
27
- main,
28
- nav,
29
- section
30
- };
31
- export const meta = {
32
- category: "general",
33
- type: "container",
34
- label: "Box",
35
- description: "A container for content. By default this is a Div, but the tag can be changed in settings.",
36
- icon: BoxIcon,
37
- states: defaultStates,
38
- presetStyle,
39
- order: 0
40
- };
41
- export const propsMeta = {
42
- props,
43
- initialProps: ["id", "tag"]
44
- };
package/lib/button.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import { forwardRef } from "react";
4
- export const defaultTag = "button";
5
- export const Button = forwardRef(
6
- ({ type = "submit", children, ...props }, ref) => /* @__PURE__ */ jsx("button", { type, ...props, ref, children })
7
- );
8
- Button.displayName = "Button";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- import { Button as ButtonPrimitive } from "./button";
3
- export default {
4
- title: "Components/Button",
5
- component: ButtonPrimitive
6
- };
7
- export const Button = {
8
- args: {
9
- children: "Click me"
10
- }
11
- };
package/lib/button.ws.js DELETED
@@ -1,36 +0,0 @@
1
- "use strict";
2
- import { ButtonElementIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import { button } from "@webstudio-is/react-sdk/css-normalize";
7
- import { props } from "./__generated__/button.props";
8
- const presetStyle = {
9
- button
10
- };
11
- export const meta = {
12
- category: "forms",
13
- type: "container",
14
- invalidAncestors: ["Button"],
15
- label: "Button",
16
- description: "Use a button to submit forms or trigger actions within a page. Do not use a button to navigate users to another resource or another page - that\u2019s what a link is used for.",
17
- icon: ButtonElementIcon,
18
- presetStyle,
19
- states: [
20
- ...defaultStates,
21
- { selector: ":disabled", label: "Disabled" },
22
- { selector: ":enabled", label: "Enabled" }
23
- ],
24
- order: 1,
25
- template: [
26
- {
27
- type: "instance",
28
- component: "Button",
29
- children: [{ type: "text", value: "Button you can edit" }]
30
- }
31
- ]
32
- };
33
- export const propsMeta = {
34
- props,
35
- initialProps: ["id", "type", "aria-label"]
36
- };
package/lib/checkbox.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import { forwardRef } from "react";
4
- export const defaultTag = "input";
5
- export const Checkbox = forwardRef(({ children: _children, ...props }, ref) => /* @__PURE__ */ jsx("input", { ...props, type: "checkbox", ref }));
6
- Checkbox.displayName = "Checkbox";
@@ -1,57 +0,0 @@
1
- "use strict";
2
- import { CheckboxCheckedIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import { input } from "@webstudio-is/react-sdk/css-normalize";
7
- import { props } from "./__generated__/checkbox.props";
8
- const presetStyle = {
9
- input: [
10
- ...input,
11
- {
12
- property: "marginRight",
13
- value: { type: "unit", unit: "em", value: 0.5 }
14
- }
15
- ]
16
- };
17
- export const meta = {
18
- category: "forms",
19
- invalidAncestors: ["Button"],
20
- type: "control",
21
- label: "Checkbox",
22
- description: "Use within a form to allow your users to toggle between checked and not checked. Group checkboxes by matching their \u201CName\u201D properties. Unlike radios, any number of checkboxes in a group can be checked.",
23
- icon: CheckboxCheckedIcon,
24
- presetStyle,
25
- order: 6,
26
- states: [
27
- ...defaultStates,
28
- { selector: ":checked", label: "Checked" },
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
- template: [
37
- {
38
- type: "instance",
39
- component: "Label",
40
- label: "Checkbox Field",
41
- children: [
42
- { type: "instance", component: "Checkbox", children: [] },
43
- {
44
- type: "instance",
45
- component: "Text",
46
- label: "Checkbox Label",
47
- props: [{ type: "string", name: "tag", value: "span" }],
48
- children: [{ type: "text", value: "Checkbox" }]
49
- }
50
- ]
51
- }
52
- ]
53
- };
54
- export const propsMeta = {
55
- props,
56
- initialProps: ["id", "name"]
57
- };
package/lib/code-text.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- import {
3
- forwardRef,
4
- createElement
5
- } from "react";
6
- export const defaultTag = "code";
7
- export const CodeText = forwardRef((props, ref) => {
8
- return createElement(defaultTag, { ...props, ref });
9
- });
10
- CodeText.displayName = "CodeText";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- import { CodeText as CodeTextPrimitive } from "./code-text";
3
- export default {
4
- title: "Components/CodeText",
5
- component: CodeTextPrimitive
6
- };
7
- export const CodeText = {
8
- args: {
9
- children: "alert('Hello World!')"
10
- }
11
- };
@@ -1,54 +0,0 @@
1
- "use strict";
2
- import { CodeTextIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import { code } from "@webstudio-is/react-sdk/css-normalize";
7
- import { props } from "./__generated__/code-text.props";
8
- const presetStyle = {
9
- code: [
10
- ...code,
11
- {
12
- property: "display",
13
- value: { type: "keyword", value: "block" }
14
- },
15
- {
16
- property: "whiteSpace",
17
- value: { type: "keyword", value: "pre-wrap" }
18
- },
19
- {
20
- property: "paddingLeft",
21
- value: { type: "unit", value: 0.2, unit: "em" }
22
- },
23
- {
24
- property: "paddingRight",
25
- value: { type: "unit", value: 0.2, unit: "em" }
26
- },
27
- {
28
- property: "backgroundColor",
29
- value: { type: "rgb", r: 238, g: 238, b: 238, alpha: 1 }
30
- }
31
- ]
32
- };
33
- export const meta = {
34
- category: "general",
35
- type: "container",
36
- label: "Code Text",
37
- description: "Use this component when you want to display code as text on the page.",
38
- icon: CodeTextIcon,
39
- invalidAncestors: ["CodeText"],
40
- states: defaultStates,
41
- presetStyle,
42
- template: [
43
- {
44
- type: "instance",
45
- component: "CodeText",
46
- children: [{ type: "text", value: "Code you can edit" }]
47
- }
48
- ],
49
- order: 8
50
- };
51
- export const propsMeta = {
52
- props,
53
- initialProps: ["id", "lang"]
54
- };
package/lib/form.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import { forwardRef } from "react";
4
- export const defaultTag = "form";
5
- export const Form = forwardRef(({ children, ...props }, ref) => /* @__PURE__ */ jsx("form", { ...props, ref, children }));
6
- Form.displayName = "Form";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- import { Form as FormPrimitive } from "./form";
3
- export default {
4
- title: "Components/Form",
5
- component: FormPrimitive
6
- };
7
- export const Form = {
8
- args: {
9
- children: "Form"
10
- }
11
- };
package/lib/form.ws.js DELETED
@@ -1,63 +0,0 @@
1
- "use strict";
2
- import { FormIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import { form } from "@webstudio-is/react-sdk/css-normalize";
7
- import { props } from "./__generated__/form.props";
8
- const presetStyle = {
9
- form: [
10
- ...form,
11
- { property: "minHeight", value: { type: "unit", unit: "px", value: 20 } }
12
- ]
13
- };
14
- export const meta = {
15
- category: "forms",
16
- type: "container",
17
- invalidAncestors: ["Form"],
18
- label: "Form",
19
- description: "Collect information from your users using validation rules.",
20
- icon: FormIcon,
21
- states: defaultStates,
22
- presetStyle,
23
- order: 0,
24
- template: [
25
- {
26
- type: "instance",
27
- component: "Form",
28
- children: [
29
- {
30
- type: "instance",
31
- component: "Label",
32
- children: [{ type: "text", value: "Name" }]
33
- },
34
- {
35
- type: "instance",
36
- component: "Input",
37
- props: [{ type: "string", name: "name", value: "name" }],
38
- children: []
39
- },
40
- {
41
- type: "instance",
42
- component: "Label",
43
- children: [{ type: "text", value: "Email" }]
44
- },
45
- {
46
- type: "instance",
47
- component: "Input",
48
- props: [{ type: "string", name: "name", value: "email" }],
49
- children: []
50
- },
51
- {
52
- type: "instance",
53
- component: "Button",
54
- children: [{ type: "text", value: "Submit" }]
55
- }
56
- ]
57
- }
58
- ]
59
- };
60
- export const propsMeta = {
61
- props,
62
- initialProps: ["id", "action"]
63
- };
package/lib/fragment.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import { forwardRef } from "react";
4
- export const Fragment = forwardRef((props, ref) => {
5
- return /* @__PURE__ */ jsx("div", { ...props, ref, style: { display: "contents" } });
6
- });
7
- Fragment.displayName = "Fragment";
@@ -1,10 +0,0 @@
1
- "use strict";
2
- export const meta = {
3
- type: "container",
4
- label: "Fragment",
5
- icon: "",
6
- stylable: false
7
- };
8
- export const propsMeta = {
9
- props: {}
10
- };
package/lib/heading.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- import {
3
- forwardRef,
4
- createElement
5
- } from "react";
6
- const defaultTag = "h1";
7
- export const Heading = forwardRef(
8
- ({ tag = defaultTag, ...props }, ref) => {
9
- return createElement(tag, { ...props, ref });
10
- }
11
- );
12
- Heading.displayName = "Heading";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- import { Heading as HeadingPrimitive } from "./heading";
3
- export default {
4
- title: "Components/Heading",
5
- component: HeadingPrimitive
6
- };
7
- export const Heading = {
8
- args: {
9
- children: "Heading"
10
- }
11
- };
package/lib/heading.ws.js DELETED
@@ -1,37 +0,0 @@
1
- "use strict";
2
- import { HeadingIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import { h1, h2, h3, h4, h5, h6 } from "@webstudio-is/react-sdk/css-normalize";
7
- import { props } from "./__generated__/heading.props";
8
- const presetStyle = {
9
- h1,
10
- h2,
11
- h3,
12
- h4,
13
- h5,
14
- h6
15
- };
16
- export const meta = {
17
- category: "text",
18
- type: "container",
19
- label: "Heading",
20
- description: "Use HTML headings to structure and organize content. Use the Tag property in settings to change the heading level (h1-h6).",
21
- icon: HeadingIcon,
22
- invalidAncestors: ["Heading"],
23
- states: defaultStates,
24
- presetStyle,
25
- template: [
26
- {
27
- type: "instance",
28
- component: "Heading",
29
- children: [{ type: "text", value: "Heading you can edit" }]
30
- }
31
- ],
32
- order: 1
33
- };
34
- export const propsMeta = {
35
- props,
36
- initialProps: ["id", "tag"]
37
- };
package/lib/html-embed.js DELETED
@@ -1,63 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import {
4
- forwardRef,
5
- useContext,
6
- useEffect,
7
- useRef
8
- } from "react";
9
- import { mergeRefs } from "@react-aria/utils";
10
- import { ReactSdkContext } from "@webstudio-is/react-sdk";
11
- const ExecutableHtml = (props) => {
12
- const { code, innerRef, ...rest } = props;
13
- const containerRef = useRef(null);
14
- useEffect(() => {
15
- const container = containerRef.current;
16
- if (container === null || code === void 0) {
17
- return;
18
- }
19
- const range = document.createRange();
20
- range.setStart(container, 0);
21
- const fragment = range.createContextualFragment(code);
22
- while (container.firstChild) {
23
- container.removeChild(container.firstChild);
24
- }
25
- container.append(fragment);
26
- }, [code]);
27
- return /* @__PURE__ */ jsx(
28
- "div",
29
- {
30
- ...rest,
31
- ref: mergeRefs(innerRef, containerRef),
32
- style: { display: "contents" }
33
- }
34
- );
35
- };
36
- const InnerHtml = (props) => {
37
- const { code, innerRef, ...rest } = props;
38
- return /* @__PURE__ */ jsx(
39
- "div",
40
- {
41
- ...rest,
42
- ref: innerRef,
43
- style: { display: "contents" },
44
- dangerouslySetInnerHTML: { __html: props.code ?? "" }
45
- }
46
- );
47
- };
48
- const Placeholder = (props) => {
49
- const { code, innerRef, ...rest } = props;
50
- return /* @__PURE__ */ jsx("div", { ref: innerRef, ...rest, style: { padding: "20px" }, children: 'Open the "Settings" panel to insert HTML code' });
51
- };
52
- export const HtmlEmbed = forwardRef((props, ref) => {
53
- const { renderer } = useContext(ReactSdkContext);
54
- const { code, executeScriptOnCanvas, ...rest } = props;
55
- if (code === void 0 || code.trim().length === 0) {
56
- return /* @__PURE__ */ jsx(Placeholder, { innerRef: ref, ...rest });
57
- }
58
- if (renderer === "canvas" && executeScriptOnCanvas === true || renderer === "preview") {
59
- return /* @__PURE__ */ jsx(ExecutableHtml, { innerRef: ref, code, ...rest });
60
- }
61
- return /* @__PURE__ */ jsx(InnerHtml, { innerRef: ref, code, ...rest });
62
- });
63
- HtmlEmbed.displayName = "HtmlEmbed";