@webstudio-is/react-sdk 0.9.0 → 0.10.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/image.js +35 -13
- package/lib/app/custom-components/index.js +18 -1
- package/lib/app/custom-components/link.js +6 -0
- package/lib/app/custom-components/rich-text-link.js +6 -0
- package/lib/app/custom-components/shared/remix-link.js +29 -0
- package/lib/app/handle-request.server.js +16 -8
- package/lib/app/params.js +7 -3
- package/lib/app/root.js +37 -6
- package/lib/cjs/app/custom-components/image.cjs +60 -24
- package/lib/cjs/app/custom-components/index.cjs +35 -24
- package/lib/cjs/app/custom-components/link.cjs +26 -0
- package/lib/cjs/app/custom-components/rich-text-link.cjs +26 -0
- package/lib/cjs/app/custom-components/shared/remix-link.cjs +49 -0
- package/lib/cjs/app/handle-request.server.cjs +36 -12
- package/lib/cjs/app/index.cjs +18 -17
- package/lib/cjs/app/params.cjs +24 -5
- package/lib/cjs/app/root.cjs +58 -11
- package/lib/cjs/components/__generated__/body.props.json +489 -489
- package/lib/cjs/components/__generated__/bold.props.json +489 -489
- package/lib/cjs/components/__generated__/box.props.json +506 -506
- package/lib/cjs/components/__generated__/button.props.json +545 -545
- package/lib/cjs/components/__generated__/form.props.json +529 -529
- package/lib/cjs/components/__generated__/heading.props.json +495 -495
- package/lib/cjs/components/__generated__/image.props.json +558 -558
- package/lib/cjs/components/__generated__/input.props.json +655 -655
- package/lib/cjs/components/__generated__/italic.props.json +489 -489
- package/lib/cjs/components/__generated__/link.props.json +545 -545
- package/lib/cjs/components/__generated__/paragraph.props.json +489 -489
- package/lib/cjs/components/__generated__/rich-text-link.props.json +547 -0
- package/lib/cjs/components/__generated__/span.props.json +489 -489
- package/lib/cjs/components/__generated__/subscript.props.json +489 -489
- package/lib/cjs/components/__generated__/superscript.props.json +489 -489
- package/lib/cjs/components/__generated__/text-block.props.json +489 -489
- package/lib/cjs/components/body.cjs +29 -6
- package/lib/cjs/components/body.ws.cjs +83 -59
- package/lib/cjs/components/bold.cjs +29 -6
- package/lib/cjs/components/bold.ws.cjs +35 -11
- package/lib/cjs/components/box.cjs +29 -7
- package/lib/cjs/components/box.ws.cjs +40 -16
- package/lib/cjs/components/button.cjs +33 -8
- package/lib/cjs/components/button.ws.cjs +36 -12
- package/lib/cjs/components/component-type.cjs +77 -27
- package/lib/cjs/components/form.cjs +29 -6
- package/lib/cjs/components/form.ws.cjs +45 -21
- package/lib/cjs/components/heading.cjs +29 -7
- package/lib/cjs/components/heading.ws.cjs +36 -12
- package/lib/cjs/components/image.cjs +39 -14
- package/lib/cjs/components/image.ws.cjs +45 -24
- package/lib/cjs/components/index.cjs +133 -67
- package/lib/cjs/components/input.cjs +29 -6
- package/lib/cjs/components/input.ws.cjs +35 -11
- package/lib/cjs/components/italic.cjs +29 -6
- package/lib/cjs/components/italic.ws.cjs +40 -16
- package/lib/cjs/components/link.cjs +32 -7
- package/lib/cjs/components/link.ws.cjs +46 -22
- package/lib/cjs/components/paragraph.cjs +29 -6
- package/lib/cjs/components/paragraph.ws.cjs +36 -12
- package/lib/cjs/components/rich-text-link.cjs +33 -0
- package/lib/cjs/components/rich-text-link.ws.cjs +38 -0
- package/lib/cjs/components/span.cjs +29 -6
- package/lib/cjs/components/span.ws.cjs +35 -11
- package/lib/cjs/components/subscript.cjs +29 -6
- package/lib/cjs/components/subscript.ws.cjs +35 -11
- package/lib/cjs/components/superscript.cjs +29 -6
- package/lib/cjs/components/superscript.ws.cjs +35 -11
- package/lib/cjs/components/text-block.cjs +29 -6
- package/lib/cjs/components/text-block.ws.cjs +42 -18
- package/lib/cjs/css/breakpoints.cjs +27 -7
- package/lib/cjs/css/categories.cjs +218 -203
- package/lib/cjs/css/get-browser-style.cjs +56 -41
- package/lib/cjs/css/index.cjs +18 -17
- package/lib/cjs/db/index.cjs +17 -16
- package/lib/cjs/db/instance.cjs +37 -17
- package/lib/cjs/db/types.cjs +15 -1
- package/lib/cjs/index.cjs +30 -35
- package/lib/cjs/pubsub/create.cjs +76 -61
- package/lib/cjs/pubsub/index.cjs +16 -15
- package/lib/cjs/tree/create-elements-tree.cjs +90 -48
- package/lib/cjs/tree/index.cjs +18 -17
- package/lib/cjs/tree/root.cjs +42 -42
- package/lib/cjs/tree/session-storage-polyfill.cjs +60 -37
- package/lib/cjs/tree/wrapper-component.cjs +54 -24
- package/lib/cjs/user-props/all-user-props.cjs +35 -17
- package/lib/cjs/user-props/index.cjs +19 -18
- package/lib/cjs/user-props/schema.cjs +52 -31
- package/lib/cjs/user-props/types.cjs +15 -1
- package/lib/cjs/user-props/use-user-props-asset.cjs +38 -19
- package/lib/cjs/user-props/use-user-props.cjs +38 -20
- package/lib/components/__generated__/body.props.json +489 -489
- package/lib/components/__generated__/bold.props.json +489 -489
- package/lib/components/__generated__/box.props.json +506 -506
- package/lib/components/__generated__/button.props.json +545 -545
- package/lib/components/__generated__/form.props.json +529 -529
- package/lib/components/__generated__/heading.props.json +495 -495
- package/lib/components/__generated__/image.props.json +558 -558
- package/lib/components/__generated__/input.props.json +655 -655
- package/lib/components/__generated__/italic.props.json +489 -489
- package/lib/components/__generated__/link.props.json +545 -545
- package/lib/components/__generated__/paragraph.props.json +489 -489
- package/lib/components/__generated__/rich-text-link.props.json +547 -0
- package/lib/components/__generated__/span.props.json +489 -489
- package/lib/components/__generated__/subscript.props.json +489 -489
- package/lib/components/__generated__/superscript.props.json +489 -489
- package/lib/components/__generated__/text-block.props.json +489 -489
- package/lib/components/body.js +8 -2
- package/lib/components/body.ws.js +57 -57
- package/lib/components/bold.js +8 -2
- package/lib/components/bold.ws.js +9 -9
- package/lib/components/box.js +11 -3
- package/lib/components/box.ws.js +14 -14
- package/lib/components/button.js +11 -3
- package/lib/components/button.ws.js +10 -10
- package/lib/components/component-type.js +54 -21
- package/lib/components/form.js +8 -2
- package/lib/components/form.ws.js +19 -19
- package/lib/components/heading.js +11 -3
- package/lib/components/heading.ws.js +10 -10
- package/lib/components/image.js +17 -9
- package/lib/components/image.ws.js +19 -22
- package/lib/components/index.js +111 -61
- package/lib/components/input.js +8 -2
- package/lib/components/input.ws.js +9 -9
- package/lib/components/italic.js +8 -2
- package/lib/components/italic.ws.js +14 -14
- package/lib/components/link.js +11 -3
- package/lib/components/link.ws.js +20 -20
- package/lib/components/paragraph.js +8 -2
- package/lib/components/paragraph.ws.js +10 -10
- package/lib/components/rich-text-link.js +13 -0
- package/lib/components/rich-text-link.ws.js +12 -0
- package/lib/components/span.js +8 -2
- package/lib/components/span.ws.js +9 -9
- package/lib/components/subscript.js +8 -2
- package/lib/components/subscript.ws.js +9 -9
- package/lib/components/superscript.js +8 -2
- package/lib/components/superscript.ws.js +9 -9
- package/lib/components/text-block.js +8 -2
- package/lib/components/text-block.ws.js +16 -16
- package/lib/css/breakpoints.js +8 -5
- package/lib/css/categories.js +198 -200
- package/lib/css/get-browser-style.js +35 -36
- package/lib/db/instance.js +14 -10
- package/lib/db/types.js +0 -1
- package/lib/index.js +8 -2
- package/lib/pubsub/create.js +51 -55
- package/lib/tree/create-elements-tree.js +68 -42
- package/lib/tree/root.js +19 -12
- package/lib/tree/session-storage-polyfill.js +41 -34
- package/lib/tree/wrapper-component.js +33 -18
- package/lib/user-props/all-user-props.js +15 -13
- package/lib/user-props/schema.js +33 -29
- package/lib/user-props/types.js +0 -1
- package/lib/user-props/use-user-props-asset.js +18 -15
- package/lib/user-props/use-user-props.js +18 -16
- package/package.json +11 -19
- package/src/app/custom-components/image.tsx +62 -0
- package/src/app/custom-components/index.ts +17 -0
- package/src/app/custom-components/link.tsx +4 -0
- package/src/app/custom-components/rich-text-link.tsx +4 -0
- package/src/app/custom-components/shared/remix-link.tsx +40 -0
- package/src/app/handle-request.server.tsx +21 -0
- package/{lib/app/index.d.ts → src/app/index.ts} +0 -1
- package/src/app/params.ts +13 -0
- package/src/app/root.tsx +27 -0
- package/src/components/__generated__/body.props.json +491 -0
- package/src/components/__generated__/bold.props.json +491 -0
- package/src/components/__generated__/box.props.json +508 -0
- package/src/components/__generated__/button.props.json +547 -0
- package/src/components/__generated__/form.props.json +531 -0
- package/src/components/__generated__/heading.props.json +497 -0
- package/src/components/__generated__/image.props.json +560 -0
- package/src/components/__generated__/input.props.json +657 -0
- package/src/components/__generated__/italic.props.json +491 -0
- package/src/components/__generated__/link.props.json +547 -0
- package/src/components/__generated__/paragraph.props.json +491 -0
- package/src/components/__generated__/rich-text-link.props.json +547 -0
- package/src/components/__generated__/span.props.json +491 -0
- package/src/components/__generated__/subscript.props.json +491 -0
- package/src/components/__generated__/superscript.props.json +491 -0
- package/src/components/__generated__/text-block.props.json +491 -0
- package/src/components/body.stories.tsx +11 -0
- package/src/components/body.tsx +10 -0
- package/src/components/body.ws.tsx +63 -0
- package/src/components/bold.stories.tsx +16 -0
- package/src/components/bold.tsx +10 -0
- package/src/components/bold.ws.tsx +12 -0
- package/src/components/box.stories.tsx +17 -0
- package/src/components/box.tsx +31 -0
- package/src/components/box.ws.ts +20 -0
- package/src/components/button.stories.tsx +17 -0
- package/src/components/button.tsx +14 -0
- package/src/components/button.ws.tsx +13 -0
- package/src/components/component-type.ts +89 -0
- package/src/components/form.stories.tsx +14 -0
- package/src/components/form.tsx +10 -0
- package/src/components/form.ws.tsx +25 -0
- package/src/components/heading.stories.tsx +16 -0
- package/src/components/heading.tsx +20 -0
- package/src/components/heading.ws.tsx +13 -0
- package/src/components/image.stories.tsx +15 -0
- package/src/components/image.tsx +52 -0
- package/src/components/image.ws.tsx +28 -0
- package/src/components/index.test.ts +28 -0
- package/src/components/index.ts +159 -0
- package/src/components/input.stories.tsx +14 -0
- package/src/components/input.tsx +11 -0
- package/src/components/input.ws.tsx +12 -0
- package/src/components/italic.stories.tsx +16 -0
- package/src/components/italic.tsx +10 -0
- package/src/components/italic.ws.tsx +20 -0
- package/src/components/link.stories.tsx +16 -0
- package/src/components/link.tsx +9 -0
- package/src/components/link.ws.tsx +26 -0
- package/src/components/paragraph.stories.tsx +16 -0
- package/src/components/paragraph.tsx +10 -0
- package/src/components/paragraph.ws.tsx +13 -0
- package/src/components/rich-text-link.stories.tsx +16 -0
- package/src/components/rich-text-link.tsx +9 -0
- package/src/components/rich-text-link.ws.tsx +12 -0
- package/src/components/span.stories.tsx +16 -0
- package/src/components/span.tsx +10 -0
- package/src/components/span.ws.tsx +12 -0
- package/src/components/subscript.stories.tsx +16 -0
- package/src/components/subscript.tsx +10 -0
- package/src/components/subscript.ws.tsx +12 -0
- package/src/components/superscript.stories.tsx +16 -0
- package/src/components/superscript.tsx +10 -0
- package/src/components/superscript.ws.tsx +12 -0
- package/src/components/text-block.stories.tsx +16 -0
- package/src/components/text-block.tsx +10 -0
- package/src/components/text-block.ws.tsx +22 -0
- package/src/css/breakpoints.ts +10 -0
- package/src/css/categories.ts +254 -0
- package/src/css/get-browser-style.ts +50 -0
- package/{lib/cjs/css/index.d.ts → src/css/index.ts} +0 -1
- package/{lib/cjs/db/index.d.ts → src/db/index.ts} +0 -1
- package/src/db/instance.ts +34 -0
- package/src/db/types.ts +18 -0
- package/{lib/cjs/index.d.ts → src/index.ts} +5 -3
- package/src/pubsub/create.ts +84 -0
- package/src/pubsub/index.ts +1 -0
- package/src/tree/create-elements-tree.tsx +102 -0
- package/{lib/cjs/tree/index.d.ts → src/tree/index.ts} +0 -1
- package/src/tree/root.ts +45 -0
- package/src/tree/session-storage-polyfill.tsx +50 -0
- package/src/tree/wrapper-component.tsx +48 -0
- package/src/user-props/all-user-props.ts +22 -0
- package/{lib/cjs/user-props/index.d.ts → src/user-props/index.ts} +0 -1
- package/src/user-props/schema.ts +35 -0
- package/src/user-props/types.ts +14 -0
- package/src/user-props/use-user-props-asset.ts +31 -0
- package/src/user-props/use-user-props.ts +30 -0
- package/lib/app/custom-components/image.d.ts +0 -9
- package/lib/app/custom-components/image.d.ts.map +0 -1
- package/lib/app/custom-components/index.d.ts +0 -2
- package/lib/app/custom-components/index.d.ts.map +0 -1
- package/lib/app/handle-request.server.d.ts +0 -3
- package/lib/app/handle-request.server.d.ts.map +0 -1
- package/lib/app/index.d.ts.map +0 -1
- package/lib/app/params.d.ts +0 -6
- package/lib/app/params.d.ts.map +0 -1
- package/lib/app/root.d.ts +0 -9
- package/lib/app/root.d.ts.map +0 -1
- package/lib/cjs/app/custom-components/image.d.ts +0 -9
- package/lib/cjs/app/custom-components/image.d.ts.map +0 -1
- package/lib/cjs/app/custom-components/index.d.ts +0 -2
- package/lib/cjs/app/custom-components/index.d.ts.map +0 -1
- package/lib/cjs/app/handle-request.server.d.ts +0 -3
- package/lib/cjs/app/handle-request.server.d.ts.map +0 -1
- package/lib/cjs/app/index.d.ts +0 -4
- package/lib/cjs/app/index.d.ts.map +0 -1
- package/lib/cjs/app/params.d.ts +0 -6
- package/lib/cjs/app/params.d.ts.map +0 -1
- package/lib/cjs/app/root.d.ts +0 -9
- package/lib/cjs/app/root.d.ts.map +0 -1
- package/lib/cjs/components/body.d.ts +0 -3
- package/lib/cjs/components/body.d.ts.map +0 -1
- package/lib/cjs/components/body.stories.cjs +0 -11
- package/lib/cjs/components/body.stories.d.ts +0 -7
- package/lib/cjs/components/body.stories.d.ts.map +0 -1
- package/lib/cjs/components/body.ws.d.ts +0 -5
- package/lib/cjs/components/body.ws.d.ts.map +0 -1
- package/lib/cjs/components/bold.d.ts +0 -3
- package/lib/cjs/components/bold.d.ts.map +0 -1
- package/lib/cjs/components/bold.stories.cjs +0 -14
- package/lib/cjs/components/bold.stories.d.ts +0 -6
- package/lib/cjs/components/bold.stories.d.ts.map +0 -1
- package/lib/cjs/components/bold.ws.d.ts +0 -5
- package/lib/cjs/components/bold.ws.d.ts.map +0 -1
- package/lib/cjs/components/box.d.ts +0 -8
- package/lib/cjs/components/box.d.ts.map +0 -1
- package/lib/cjs/components/box.stories.cjs +0 -12
- package/lib/cjs/components/box.stories.d.ts +0 -10
- package/lib/cjs/components/box.stories.d.ts.map +0 -1
- package/lib/cjs/components/box.ws.d.ts +0 -5
- package/lib/cjs/components/box.ws.d.ts.map +0 -1
- package/lib/cjs/components/button.d.ts +0 -3
- package/lib/cjs/components/button.d.ts.map +0 -1
- package/lib/cjs/components/button.stories.cjs +0 -14
- package/lib/cjs/components/button.stories.d.ts +0 -6
- package/lib/cjs/components/button.stories.d.ts.map +0 -1
- package/lib/cjs/components/button.ws.d.ts +0 -5
- package/lib/cjs/components/button.ws.d.ts.map +0 -1
- package/lib/cjs/components/component-type.d.ts +0 -17
- package/lib/cjs/components/component-type.d.ts.map +0 -1
- package/lib/cjs/components/form.d.ts +0 -3
- package/lib/cjs/components/form.d.ts.map +0 -1
- package/lib/cjs/components/form.stories.cjs +0 -12
- package/lib/cjs/components/form.stories.d.ts +0 -6
- package/lib/cjs/components/form.stories.d.ts.map +0 -1
- package/lib/cjs/components/form.ws.d.ts +0 -5
- package/lib/cjs/components/form.ws.d.ts.map +0 -1
- package/lib/cjs/components/heading.d.ts +0 -8
- package/lib/cjs/components/heading.d.ts.map +0 -1
- package/lib/cjs/components/heading.stories.cjs +0 -14
- package/lib/cjs/components/heading.stories.d.ts +0 -10
- package/lib/cjs/components/heading.stories.d.ts.map +0 -1
- package/lib/cjs/components/heading.ws.d.ts +0 -5
- package/lib/cjs/components/heading.ws.d.ts.map +0 -1
- package/lib/cjs/components/image.d.ts +0 -3
- package/lib/cjs/components/image.d.ts.map +0 -1
- package/lib/cjs/components/image.stories.cjs +0 -12
- package/lib/cjs/components/image.stories.d.ts +0 -6
- package/lib/cjs/components/image.stories.d.ts.map +0 -1
- package/lib/cjs/components/image.ws.d.ts +0 -5
- package/lib/cjs/components/image.ws.d.ts.map +0 -1
- package/lib/cjs/components/index.d.ts +0 -90
- package/lib/cjs/components/index.d.ts.map +0 -1
- package/lib/cjs/components/index.test.cjs +0 -7
- package/lib/cjs/components/index.test.d.ts +0 -2
- package/lib/cjs/components/index.test.d.ts.map +0 -1
- package/lib/cjs/components/input.d.ts +0 -3
- package/lib/cjs/components/input.d.ts.map +0 -1
- package/lib/cjs/components/input.stories.cjs +0 -12
- package/lib/cjs/components/input.stories.d.ts +0 -6
- package/lib/cjs/components/input.stories.d.ts.map +0 -1
- package/lib/cjs/components/input.ws.d.ts +0 -5
- package/lib/cjs/components/input.ws.d.ts.map +0 -1
- package/lib/cjs/components/italic.d.ts +0 -3
- package/lib/cjs/components/italic.d.ts.map +0 -1
- package/lib/cjs/components/italic.stories.cjs +0 -14
- package/lib/cjs/components/italic.stories.d.ts +0 -6
- package/lib/cjs/components/italic.stories.d.ts.map +0 -1
- package/lib/cjs/components/italic.ws.d.ts +0 -5
- package/lib/cjs/components/italic.ws.d.ts.map +0 -1
- package/lib/cjs/components/link.d.ts +0 -8
- package/lib/cjs/components/link.d.ts.map +0 -1
- package/lib/cjs/components/link.stories.cjs +0 -14
- package/lib/cjs/components/link.stories.d.ts +0 -10
- package/lib/cjs/components/link.stories.d.ts.map +0 -1
- package/lib/cjs/components/link.ws.d.ts +0 -5
- package/lib/cjs/components/link.ws.d.ts.map +0 -1
- package/lib/cjs/components/meta.cjs +0 -42
- package/lib/cjs/components/meta.d.ts +0 -7464
- package/lib/cjs/components/meta.d.ts.map +0 -1
- package/lib/cjs/components/paragraph.d.ts +0 -3
- package/lib/cjs/components/paragraph.d.ts.map +0 -1
- package/lib/cjs/components/paragraph.stories.cjs +0 -14
- package/lib/cjs/components/paragraph.stories.d.ts +0 -6
- package/lib/cjs/components/paragraph.stories.d.ts.map +0 -1
- package/lib/cjs/components/paragraph.ws.d.ts +0 -5
- package/lib/cjs/components/paragraph.ws.d.ts.map +0 -1
- package/lib/cjs/components/span.d.ts +0 -3
- package/lib/cjs/components/span.d.ts.map +0 -1
- package/lib/cjs/components/span.stories.cjs +0 -14
- package/lib/cjs/components/span.stories.d.ts +0 -6
- package/lib/cjs/components/span.stories.d.ts.map +0 -1
- package/lib/cjs/components/span.ws.d.ts +0 -5
- package/lib/cjs/components/span.ws.d.ts.map +0 -1
- package/lib/cjs/components/subscript.d.ts +0 -3
- package/lib/cjs/components/subscript.d.ts.map +0 -1
- package/lib/cjs/components/subscript.stories.cjs +0 -14
- package/lib/cjs/components/subscript.stories.d.ts +0 -6
- package/lib/cjs/components/subscript.stories.d.ts.map +0 -1
- package/lib/cjs/components/subscript.ws.d.ts +0 -5
- package/lib/cjs/components/subscript.ws.d.ts.map +0 -1
- package/lib/cjs/components/superscript.d.ts +0 -3
- package/lib/cjs/components/superscript.d.ts.map +0 -1
- package/lib/cjs/components/superscript.stories.cjs +0 -14
- package/lib/cjs/components/superscript.stories.d.ts +0 -6
- package/lib/cjs/components/superscript.stories.d.ts.map +0 -1
- package/lib/cjs/components/superscript.ws.d.ts +0 -5
- package/lib/cjs/components/superscript.ws.d.ts.map +0 -1
- package/lib/cjs/components/text-block.d.ts +0 -3
- package/lib/cjs/components/text-block.d.ts.map +0 -1
- package/lib/cjs/components/text-block.stories.cjs +0 -14
- package/lib/cjs/components/text-block.stories.d.ts +0 -6
- package/lib/cjs/components/text-block.stories.d.ts.map +0 -1
- package/lib/cjs/components/text-block.ws.d.ts +0 -5
- package/lib/cjs/components/text-block.ws.d.ts.map +0 -1
- package/lib/cjs/css/breakpoints.d.ts +0 -4
- package/lib/cjs/css/breakpoints.d.ts.map +0 -1
- package/lib/cjs/css/categories.d.ts +0 -409
- package/lib/cjs/css/categories.d.ts.map +0 -1
- package/lib/cjs/css/get-browser-style.d.ts +0 -3
- package/lib/cjs/css/get-browser-style.d.ts.map +0 -1
- package/lib/cjs/css/index.d.ts.map +0 -1
- package/lib/cjs/db/index.d.ts.map +0 -1
- package/lib/cjs/db/instance.d.ts +0 -14
- package/lib/cjs/db/instance.d.ts.map +0 -1
- package/lib/cjs/db/types.d.ts +0 -17
- package/lib/cjs/db/types.d.ts.map +0 -1
- package/lib/cjs/index.d.ts.map +0 -1
- package/lib/cjs/pubsub/create.d.ts +0 -29
- package/lib/cjs/pubsub/create.d.ts.map +0 -1
- package/lib/cjs/pubsub/index.d.ts +0 -2
- package/lib/cjs/pubsub/index.d.ts.map +0 -1
- package/lib/cjs/tree/create-elements-tree.d.ts +0 -19
- package/lib/cjs/tree/create-elements-tree.d.ts.map +0 -1
- package/lib/cjs/tree/index.d.ts.map +0 -1
- package/lib/cjs/tree/root.d.ts +0 -20
- package/lib/cjs/tree/root.d.ts.map +0 -1
- package/lib/cjs/tree/session-storage-polyfill.d.ts +0 -3
- package/lib/cjs/tree/session-storage-polyfill.d.ts.map +0 -1
- package/lib/cjs/tree/wrapper-component.d.ts +0 -13
- package/lib/cjs/tree/wrapper-component.d.ts.map +0 -1
- package/lib/cjs/user-props/all-user-props.d.ts +0 -8
- package/lib/cjs/user-props/all-user-props.d.ts.map +0 -1
- package/lib/cjs/user-props/index.d.ts.map +0 -1
- package/lib/cjs/user-props/schema.d.ts +0 -72
- package/lib/cjs/user-props/schema.d.ts.map +0 -1
- package/lib/cjs/user-props/types.d.ts +0 -13
- package/lib/cjs/user-props/types.d.ts.map +0 -1
- package/lib/cjs/user-props/use-user-props-asset.d.ts +0 -8
- package/lib/cjs/user-props/use-user-props-asset.d.ts.map +0 -1
- package/lib/cjs/user-props/use-user-props.d.ts +0 -12
- package/lib/cjs/user-props/use-user-props.d.ts.map +0 -1
- package/lib/components/body.d.ts +0 -3
- package/lib/components/body.d.ts.map +0 -1
- package/lib/components/body.stories.d.ts +0 -7
- package/lib/components/body.stories.d.ts.map +0 -1
- package/lib/components/body.stories.js +0 -7
- package/lib/components/body.ws.d.ts +0 -5
- package/lib/components/body.ws.d.ts.map +0 -1
- package/lib/components/bold.d.ts +0 -3
- package/lib/components/bold.d.ts.map +0 -1
- package/lib/components/bold.stories.d.ts +0 -6
- package/lib/components/bold.stories.d.ts.map +0 -1
- package/lib/components/bold.stories.js +0 -11
- package/lib/components/bold.ws.d.ts +0 -5
- package/lib/components/bold.ws.d.ts.map +0 -1
- package/lib/components/box.d.ts +0 -8
- package/lib/components/box.d.ts.map +0 -1
- package/lib/components/box.stories.d.ts +0 -10
- package/lib/components/box.stories.d.ts.map +0 -1
- package/lib/components/box.stories.js +0 -9
- package/lib/components/box.ws.d.ts +0 -5
- package/lib/components/box.ws.d.ts.map +0 -1
- package/lib/components/button.d.ts +0 -3
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.stories.d.ts +0 -6
- package/lib/components/button.stories.d.ts.map +0 -1
- package/lib/components/button.stories.js +0 -11
- package/lib/components/button.ws.d.ts +0 -5
- package/lib/components/button.ws.d.ts.map +0 -1
- package/lib/components/component-type.d.ts +0 -17
- package/lib/components/component-type.d.ts.map +0 -1
- package/lib/components/form.d.ts +0 -3
- package/lib/components/form.d.ts.map +0 -1
- package/lib/components/form.stories.d.ts +0 -6
- package/lib/components/form.stories.d.ts.map +0 -1
- package/lib/components/form.stories.js +0 -9
- package/lib/components/form.ws.d.ts +0 -5
- package/lib/components/form.ws.d.ts.map +0 -1
- package/lib/components/heading.d.ts +0 -8
- package/lib/components/heading.d.ts.map +0 -1
- package/lib/components/heading.stories.d.ts +0 -10
- package/lib/components/heading.stories.d.ts.map +0 -1
- package/lib/components/heading.stories.js +0 -11
- package/lib/components/heading.ws.d.ts +0 -5
- package/lib/components/heading.ws.d.ts.map +0 -1
- package/lib/components/image.d.ts +0 -3
- package/lib/components/image.d.ts.map +0 -1
- package/lib/components/image.stories.d.ts +0 -6
- package/lib/components/image.stories.d.ts.map +0 -1
- package/lib/components/image.stories.js +0 -9
- package/lib/components/image.ws.d.ts +0 -5
- package/lib/components/image.ws.d.ts.map +0 -1
- package/lib/components/index.d.ts +0 -90
- package/lib/components/index.d.ts.map +0 -1
- package/lib/components/index.test.d.ts +0 -2
- package/lib/components/index.test.d.ts.map +0 -1
- package/lib/components/index.test.js +0 -5
- package/lib/components/input.d.ts +0 -3
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.stories.d.ts +0 -6
- package/lib/components/input.stories.d.ts.map +0 -1
- package/lib/components/input.stories.js +0 -9
- package/lib/components/input.ws.d.ts +0 -5
- package/lib/components/input.ws.d.ts.map +0 -1
- package/lib/components/italic.d.ts +0 -3
- package/lib/components/italic.d.ts.map +0 -1
- package/lib/components/italic.stories.d.ts +0 -6
- package/lib/components/italic.stories.d.ts.map +0 -1
- package/lib/components/italic.stories.js +0 -11
- package/lib/components/italic.ws.d.ts +0 -5
- package/lib/components/italic.ws.d.ts.map +0 -1
- package/lib/components/link.d.ts +0 -8
- package/lib/components/link.d.ts.map +0 -1
- package/lib/components/link.stories.d.ts +0 -10
- package/lib/components/link.stories.d.ts.map +0 -1
- package/lib/components/link.stories.js +0 -11
- package/lib/components/link.ws.d.ts +0 -5
- package/lib/components/link.ws.d.ts.map +0 -1
- package/lib/components/meta.d.ts +0 -7464
- package/lib/components/meta.d.ts.map +0 -1
- package/lib/components/meta.js +0 -35
- package/lib/components/paragraph.d.ts +0 -3
- package/lib/components/paragraph.d.ts.map +0 -1
- package/lib/components/paragraph.stories.d.ts +0 -6
- package/lib/components/paragraph.stories.d.ts.map +0 -1
- package/lib/components/paragraph.stories.js +0 -11
- package/lib/components/paragraph.ws.d.ts +0 -5
- package/lib/components/paragraph.ws.d.ts.map +0 -1
- package/lib/components/span.d.ts +0 -3
- package/lib/components/span.d.ts.map +0 -1
- package/lib/components/span.stories.d.ts +0 -6
- package/lib/components/span.stories.d.ts.map +0 -1
- package/lib/components/span.stories.js +0 -11
- package/lib/components/span.ws.d.ts +0 -5
- package/lib/components/span.ws.d.ts.map +0 -1
- package/lib/components/subscript.d.ts +0 -3
- package/lib/components/subscript.d.ts.map +0 -1
- package/lib/components/subscript.stories.d.ts +0 -6
- package/lib/components/subscript.stories.d.ts.map +0 -1
- package/lib/components/subscript.stories.js +0 -11
- package/lib/components/subscript.ws.d.ts +0 -5
- package/lib/components/subscript.ws.d.ts.map +0 -1
- package/lib/components/superscript.d.ts +0 -3
- package/lib/components/superscript.d.ts.map +0 -1
- package/lib/components/superscript.stories.d.ts +0 -6
- package/lib/components/superscript.stories.d.ts.map +0 -1
- package/lib/components/superscript.stories.js +0 -11
- package/lib/components/superscript.ws.d.ts +0 -5
- package/lib/components/superscript.ws.d.ts.map +0 -1
- package/lib/components/text-block.d.ts +0 -3
- package/lib/components/text-block.d.ts.map +0 -1
- package/lib/components/text-block.stories.d.ts +0 -6
- package/lib/components/text-block.stories.d.ts.map +0 -1
- package/lib/components/text-block.stories.js +0 -11
- package/lib/components/text-block.ws.d.ts +0 -5
- package/lib/components/text-block.ws.d.ts.map +0 -1
- package/lib/css/breakpoints.d.ts +0 -4
- package/lib/css/breakpoints.d.ts.map +0 -1
- package/lib/css/categories.d.ts +0 -409
- package/lib/css/categories.d.ts.map +0 -1
- package/lib/css/get-browser-style.d.ts +0 -3
- package/lib/css/get-browser-style.d.ts.map +0 -1
- package/lib/css/index.d.ts +0 -4
- package/lib/css/index.d.ts.map +0 -1
- package/lib/db/index.d.ts +0 -3
- package/lib/db/index.d.ts.map +0 -1
- package/lib/db/instance.d.ts +0 -14
- package/lib/db/instance.d.ts.map +0 -1
- package/lib/db/types.d.ts +0 -17
- package/lib/db/types.d.ts.map +0 -1
- package/lib/index.d.ts +0 -10
- package/lib/index.d.ts.map +0 -1
- package/lib/pubsub/create.d.ts +0 -29
- package/lib/pubsub/create.d.ts.map +0 -1
- package/lib/pubsub/index.d.ts +0 -2
- package/lib/pubsub/index.d.ts.map +0 -1
- package/lib/tree/create-elements-tree.d.ts +0 -19
- package/lib/tree/create-elements-tree.d.ts.map +0 -1
- package/lib/tree/index.d.ts +0 -4
- package/lib/tree/index.d.ts.map +0 -1
- package/lib/tree/root.d.ts +0 -20
- package/lib/tree/root.d.ts.map +0 -1
- package/lib/tree/session-storage-polyfill.d.ts +0 -3
- package/lib/tree/session-storage-polyfill.d.ts.map +0 -1
- package/lib/tree/wrapper-component.d.ts +0 -13
- package/lib/tree/wrapper-component.d.ts.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/user-props/all-user-props.d.ts +0 -8
- package/lib/user-props/all-user-props.d.ts.map +0 -1
- package/lib/user-props/index.d.ts +0 -5
- package/lib/user-props/index.d.ts.map +0 -1
- package/lib/user-props/schema.d.ts +0 -72
- package/lib/user-props/schema.d.ts.map +0 -1
- package/lib/user-props/types.d.ts +0 -13
- package/lib/user-props/types.d.ts.map +0 -1
- package/lib/user-props/use-user-props-asset.d.ts +0 -8
- package/lib/user-props/use-user-props-asset.d.ts.map +0 -1
- package/lib/user-props/use-user-props.d.ts +0 -12
- package/lib/user-props/use-user-props.d.ts.map +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import mitt from "mitt";
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
|
|
4
|
+
export const createPubsub = <PublishMap>() => {
|
|
5
|
+
type Action<Type extends keyof PublishMap> =
|
|
6
|
+
undefined extends PublishMap[Type]
|
|
7
|
+
? { type: Type; payload?: PublishMap[Type] }
|
|
8
|
+
: { type: Type; payload: PublishMap[Type] };
|
|
9
|
+
|
|
10
|
+
// `mitt` has a somewhat annoying overload for `*` type that makes it hard to wrap in a generic context
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
const emitter = mitt<Record<any, any>>();
|
|
13
|
+
|
|
14
|
+
if (typeof window === "object") {
|
|
15
|
+
window.addEventListener(
|
|
16
|
+
"message",
|
|
17
|
+
(event: MessageEvent) => {
|
|
18
|
+
// @todo this has no type safety built in, could be anything from any source.
|
|
19
|
+
// we could potentially maintain a list of valid event types at runtime
|
|
20
|
+
// at the very least we could add a brand property or something to our events
|
|
21
|
+
if (typeof event.data?.type === "string") {
|
|
22
|
+
emitter.emit(event.data.type, event.data.payload);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
false
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
/**
|
|
31
|
+
* To publish a postMessage event on the current window and parent window from the iframe.
|
|
32
|
+
*/
|
|
33
|
+
publish<Type extends keyof PublishMap>(action: Action<Type>) {
|
|
34
|
+
window.parent.postMessage(action, "*");
|
|
35
|
+
window.postMessage(action, "*");
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* To publish a postMessage event on the iframe and parent window from the parent window.
|
|
40
|
+
*/
|
|
41
|
+
usePublish() {
|
|
42
|
+
const iframeRef = useRef<HTMLIFrameElement | null>(null);
|
|
43
|
+
const publishCallback = useCallback(
|
|
44
|
+
<Type extends keyof PublishMap>(action: Action<Type>) => {
|
|
45
|
+
const element = iframeRef.current;
|
|
46
|
+
if (element?.contentWindow == null) return;
|
|
47
|
+
element.contentWindow.postMessage(action, "*");
|
|
48
|
+
window.postMessage(action, "*");
|
|
49
|
+
},
|
|
50
|
+
[iframeRef]
|
|
51
|
+
);
|
|
52
|
+
return [publishCallback, iframeRef] as const;
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* To subscribe a message event on the current window.
|
|
57
|
+
*/
|
|
58
|
+
useSubscribe<Type extends keyof PublishMap>(
|
|
59
|
+
type: Type,
|
|
60
|
+
onAction: (payload: PublishMap[Type]) => void
|
|
61
|
+
) {
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
emitter.on(type, onAction);
|
|
64
|
+
return () => {
|
|
65
|
+
emitter.off(type, onAction);
|
|
66
|
+
};
|
|
67
|
+
}, [type, onAction]);
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
useSubscribeAll(
|
|
71
|
+
onAction: <Type extends keyof PublishMap>(
|
|
72
|
+
type: Type,
|
|
73
|
+
payload: PublishMap[Type]
|
|
74
|
+
) => void
|
|
75
|
+
) {
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
emitter.on("*", onAction);
|
|
78
|
+
return () => {
|
|
79
|
+
emitter.off("*", onAction);
|
|
80
|
+
};
|
|
81
|
+
}, [onAction]);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./create";
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type ComponentProps, Fragment } from "react";
|
|
2
|
+
import type { Instance } from "../db";
|
|
3
|
+
import { WrapperComponent } from "./wrapper-component";
|
|
4
|
+
import { Scripts, ScrollRestoration } from "@remix-run/react";
|
|
5
|
+
import { SessionStoragePolyfill } from "./session-storage-polyfill";
|
|
6
|
+
|
|
7
|
+
export type ChildrenUpdates = Array<
|
|
8
|
+
| string
|
|
9
|
+
| {
|
|
10
|
+
id: undefined | Instance["id"];
|
|
11
|
+
component: Instance["component"];
|
|
12
|
+
children: ChildrenUpdates;
|
|
13
|
+
}
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export type OnChangeChildren = (change: {
|
|
17
|
+
instanceId: Instance["id"];
|
|
18
|
+
updates: ChildrenUpdates;
|
|
19
|
+
}) => void;
|
|
20
|
+
|
|
21
|
+
export const createElementsTree = ({
|
|
22
|
+
sandbox,
|
|
23
|
+
instance,
|
|
24
|
+
Component,
|
|
25
|
+
onChangeChildren,
|
|
26
|
+
}: {
|
|
27
|
+
sandbox?: boolean;
|
|
28
|
+
instance: Instance;
|
|
29
|
+
Component: (props: ComponentProps<typeof WrapperComponent>) => JSX.Element;
|
|
30
|
+
onChangeChildren?: OnChangeChildren;
|
|
31
|
+
}) => {
|
|
32
|
+
const children = createInstanceChildrenElements({
|
|
33
|
+
Component,
|
|
34
|
+
children: instance.children,
|
|
35
|
+
onChangeChildren,
|
|
36
|
+
});
|
|
37
|
+
const body = createInstanceElement({
|
|
38
|
+
Component,
|
|
39
|
+
instance,
|
|
40
|
+
children: [
|
|
41
|
+
<Fragment key="children">
|
|
42
|
+
{children}
|
|
43
|
+
{sandbox && <SessionStoragePolyfill />}
|
|
44
|
+
<ScrollRestoration />
|
|
45
|
+
<Scripts />
|
|
46
|
+
</Fragment>,
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
return body;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const createInstanceChildrenElements = ({
|
|
53
|
+
children,
|
|
54
|
+
Component,
|
|
55
|
+
onChangeChildren,
|
|
56
|
+
}: {
|
|
57
|
+
children: Instance["children"];
|
|
58
|
+
Component: (props: ComponentProps<typeof WrapperComponent>) => JSX.Element;
|
|
59
|
+
onChangeChildren?: OnChangeChildren;
|
|
60
|
+
}) => {
|
|
61
|
+
const elements = [];
|
|
62
|
+
for (const child of children) {
|
|
63
|
+
if (typeof child === "string") {
|
|
64
|
+
elements.push(child);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const children = createInstanceChildrenElements({
|
|
68
|
+
children: child.children,
|
|
69
|
+
Component,
|
|
70
|
+
onChangeChildren,
|
|
71
|
+
});
|
|
72
|
+
const element = createInstanceElement({
|
|
73
|
+
instance: child,
|
|
74
|
+
Component,
|
|
75
|
+
onChangeChildren,
|
|
76
|
+
children,
|
|
77
|
+
});
|
|
78
|
+
elements.push(element);
|
|
79
|
+
}
|
|
80
|
+
return elements;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const createInstanceElement = ({
|
|
84
|
+
Component,
|
|
85
|
+
instance,
|
|
86
|
+
children = [],
|
|
87
|
+
onChangeChildren,
|
|
88
|
+
}: {
|
|
89
|
+
instance: Instance;
|
|
90
|
+
Component: (props: ComponentProps<typeof WrapperComponent>) => JSX.Element;
|
|
91
|
+
onChangeChildren?: OnChangeChildren;
|
|
92
|
+
children?: Array<JSX.Element | string>;
|
|
93
|
+
}) => {
|
|
94
|
+
const props = {
|
|
95
|
+
instance,
|
|
96
|
+
children,
|
|
97
|
+
key: instance.id,
|
|
98
|
+
onChangeChildren,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return <Component {...props} />;
|
|
102
|
+
};
|
package/src/tree/root.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useAllUserProps } from "../user-props/";
|
|
2
|
+
import type { Tree, InstanceProps } from "../db";
|
|
3
|
+
import { createElementsTree } from "./create-elements-tree";
|
|
4
|
+
import { WrapperComponent } from "./wrapper-component";
|
|
5
|
+
import type { Asset } from "@webstudio-is/asset-uploader";
|
|
6
|
+
import { type ComponentProps } from "react";
|
|
7
|
+
import type { Breakpoint } from "@webstudio-is/css-data";
|
|
8
|
+
import { registerComponents } from "../components";
|
|
9
|
+
import { customComponents as defaultCustomComponents } from "../app/custom-components";
|
|
10
|
+
import { setParams, type Params } from "../app/params";
|
|
11
|
+
import type { DesignToken } from "@webstudio-is/design-tokens";
|
|
12
|
+
|
|
13
|
+
export type Data = {
|
|
14
|
+
tree: Tree | null;
|
|
15
|
+
breakpoints: Array<Breakpoint>;
|
|
16
|
+
designTokens: Array<DesignToken>;
|
|
17
|
+
props: Array<InstanceProps>;
|
|
18
|
+
assets: Array<Asset>;
|
|
19
|
+
params?: Params;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type RootProps = {
|
|
23
|
+
data: Data;
|
|
24
|
+
Component?: (props: ComponentProps<typeof WrapperComponent>) => JSX.Element;
|
|
25
|
+
customComponents?: Parameters<typeof registerComponents>[0];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const InstanceRoot = ({
|
|
29
|
+
data,
|
|
30
|
+
Component,
|
|
31
|
+
customComponents = defaultCustomComponents,
|
|
32
|
+
}: RootProps): JSX.Element | null => {
|
|
33
|
+
if (data.tree === null) {
|
|
34
|
+
throw new Error("Tree is null");
|
|
35
|
+
}
|
|
36
|
+
useAllUserProps(data.props);
|
|
37
|
+
setParams(data.params ?? null);
|
|
38
|
+
|
|
39
|
+
registerComponents(customComponents);
|
|
40
|
+
|
|
41
|
+
return createElementsTree({
|
|
42
|
+
instance: data.tree.root,
|
|
43
|
+
Component: Component ?? WrapperComponent,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// This is a temporary work around for https://github.com/remix-run/remix/issues/3659
|
|
2
|
+
|
|
3
|
+
// The code is based on this discussion https://bugs.chromium.org/p/chromium/issues/detail?id=357625
|
|
4
|
+
const polyfill = function () {
|
|
5
|
+
try {
|
|
6
|
+
const key = "__session_storage_availability_test__";
|
|
7
|
+
sessionStorage.setItem(key, "test"); // test
|
|
8
|
+
sessionStorage.removeItem(key); // cleanup
|
|
9
|
+
} catch (error) {
|
|
10
|
+
alert(
|
|
11
|
+
'It looks like you have disabled cookies in your browser. Webstudio designer may not work properly.\n\nTo enable cookies, go to "Setting" > "Privacy and security" > "Cookies and other site data", and make sure neither "Block all cookies" nor "Block third-party cookies" are selected.\n\nRead more at https://support.google.com/chrome/answer/95647'
|
|
12
|
+
);
|
|
13
|
+
const data = new Map();
|
|
14
|
+
Object.defineProperty(window, "sessionStorage", {
|
|
15
|
+
value: {
|
|
16
|
+
setItem: (key: string, val: unknown) => {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.warn(
|
|
19
|
+
`Session storage is unavailable due to Error "${
|
|
20
|
+
(error as Error).message
|
|
21
|
+
}". A polyfill is used to set value of "${key}". The value will be lost when the page is reloaded.`
|
|
22
|
+
);
|
|
23
|
+
data.set(key, String(val));
|
|
24
|
+
},
|
|
25
|
+
getItem: (key: string) => {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.warn(
|
|
28
|
+
`Session storage is unavailable due to Error "${
|
|
29
|
+
(error as Error).message
|
|
30
|
+
}". A polyfill is used to get value of "${key}". The value will be undefined if the page was reloaded after it was set.`
|
|
31
|
+
);
|
|
32
|
+
return data.get(key);
|
|
33
|
+
},
|
|
34
|
+
removeItem: (key: string) => {
|
|
35
|
+
data.delete(key);
|
|
36
|
+
},
|
|
37
|
+
clear: () => {
|
|
38
|
+
data.clear();
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}.toString();
|
|
44
|
+
|
|
45
|
+
export const SessionStoragePolyfill = () => (
|
|
46
|
+
<script
|
|
47
|
+
dangerouslySetInnerHTML={{ __html: `(${polyfill})()` }}
|
|
48
|
+
suppressHydrationWarning
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Fragment } from "react";
|
|
2
|
+
import type { Instance } from "../db";
|
|
3
|
+
import { getComponent } from "../components";
|
|
4
|
+
import { useUserProps } from "../user-props/use-user-props";
|
|
5
|
+
import type { OnChangeChildren } from "./create-elements-tree";
|
|
6
|
+
|
|
7
|
+
const renderText = (text: string): Array<JSX.Element> => {
|
|
8
|
+
const lines = text.split("\n");
|
|
9
|
+
return lines.map((line, index) => (
|
|
10
|
+
<Fragment key={index}>
|
|
11
|
+
{line}
|
|
12
|
+
{index < lines.length - 1 ? <br /> : null}
|
|
13
|
+
</Fragment>
|
|
14
|
+
));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const renderWrapperComponentChildren = (
|
|
18
|
+
children: Array<JSX.Element | string> | undefined
|
|
19
|
+
): Array<JSX.Element | string | Array<JSX.Element | string>> | undefined => {
|
|
20
|
+
// Some elements like input can't have children
|
|
21
|
+
// @todo needs to be made impossible to drag element into input
|
|
22
|
+
if (children === undefined || children.length === 0) return;
|
|
23
|
+
return children.map((child) => {
|
|
24
|
+
return typeof child === "string" ? renderText(child) : child;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type WrapperComponentProps = {
|
|
29
|
+
instance: Instance;
|
|
30
|
+
children: Array<JSX.Element | string>;
|
|
31
|
+
onChangeChildren?: OnChangeChildren;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const WrapperComponent = ({
|
|
35
|
+
instance,
|
|
36
|
+
onChangeChildren, // prevent it from passing to sdk component
|
|
37
|
+
children,
|
|
38
|
+
...rest
|
|
39
|
+
}: WrapperComponentProps) => {
|
|
40
|
+
const Component = getComponent(instance.component);
|
|
41
|
+
const userProps = useUserProps(instance.id);
|
|
42
|
+
const props = { ...userProps, ...rest, [idAttribute]: instance.id };
|
|
43
|
+
return (
|
|
44
|
+
<Component {...props}>{renderWrapperComponentChildren(children)}</Component>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const idAttribute = "data-ws-id";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
import { createValueContainer, useValue } from "react-nano-state";
|
|
3
|
+
import type { InstanceProps, Instance } from "../db";
|
|
4
|
+
|
|
5
|
+
export type AllUserProps = { [id: Instance["id"]]: InstanceProps };
|
|
6
|
+
|
|
7
|
+
export const allUserPropsContainer = createValueContainer<AllUserProps>({});
|
|
8
|
+
|
|
9
|
+
export const useAllUserProps = (initialUserProps?: Array<InstanceProps>) => {
|
|
10
|
+
// @todo ssr workaround for https://github.com/webstudio-is/webstudio-designer/issues/213
|
|
11
|
+
const ref = useRef(false);
|
|
12
|
+
if (ref.current === false && initialUserProps !== undefined) {
|
|
13
|
+
const propsMap: AllUserProps = {};
|
|
14
|
+
for (const props of initialUserProps) {
|
|
15
|
+
propsMap[props.instanceId] = props;
|
|
16
|
+
}
|
|
17
|
+
//We don't need to trigger rerender when setting the initial value
|
|
18
|
+
allUserPropsContainer.value = propsMap;
|
|
19
|
+
ref.current = true;
|
|
20
|
+
}
|
|
21
|
+
return useValue(allUserPropsContainer);
|
|
22
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Asset } from "@webstudio-is/asset-uploader";
|
|
3
|
+
|
|
4
|
+
const baseUserProps = {
|
|
5
|
+
id: z.string(),
|
|
6
|
+
prop: z.string(),
|
|
7
|
+
required: z.optional(z.boolean()),
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const UserProp = z.discriminatedUnion("type", [
|
|
11
|
+
z.object({
|
|
12
|
+
...baseUserProps,
|
|
13
|
+
type: z.literal("number"),
|
|
14
|
+
value: z.number(),
|
|
15
|
+
}),
|
|
16
|
+
z.object({
|
|
17
|
+
...baseUserProps,
|
|
18
|
+
type: z.literal("string"),
|
|
19
|
+
value: z.string(),
|
|
20
|
+
}),
|
|
21
|
+
z.object({
|
|
22
|
+
...baseUserProps,
|
|
23
|
+
type: z.literal("boolean"),
|
|
24
|
+
value: z.boolean(),
|
|
25
|
+
}),
|
|
26
|
+
z.object({
|
|
27
|
+
...baseUserProps,
|
|
28
|
+
type: z.literal("asset"),
|
|
29
|
+
value: Asset,
|
|
30
|
+
}),
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
export const UserProps = z.array(UserProp);
|
|
34
|
+
|
|
35
|
+
export type UserProp = z.infer<typeof UserProp>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InstanceProps, Instance } from "../db";
|
|
2
|
+
import { UserProp } from "./schema";
|
|
3
|
+
|
|
4
|
+
export type UserPropsUpdates = {
|
|
5
|
+
treeId: InstanceProps["treeId"];
|
|
6
|
+
propsId: InstanceProps["id"];
|
|
7
|
+
instanceId: Instance["id"];
|
|
8
|
+
updates: Array<UserProp>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type DeleteProp = {
|
|
12
|
+
instanceId: Instance["id"];
|
|
13
|
+
propId: UserProp["id"];
|
|
14
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { type Instance } from "../db";
|
|
3
|
+
import { type UserProp } from "./schema";
|
|
4
|
+
import { useAllUserProps } from "./all-user-props";
|
|
5
|
+
import type { Asset } from "@webstudio-is/asset-uploader";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get asset for prop, like src on the Image component
|
|
9
|
+
*/
|
|
10
|
+
export const useUserPropsAsset = (
|
|
11
|
+
instanceId: Instance["id"],
|
|
12
|
+
propName: UserProp["prop"]
|
|
13
|
+
): Asset | undefined => {
|
|
14
|
+
const [allUserProps] = useAllUserProps();
|
|
15
|
+
|
|
16
|
+
const propsData = allUserProps[instanceId];
|
|
17
|
+
const asset = useMemo(() => {
|
|
18
|
+
if (propsData == null) return undefined;
|
|
19
|
+
const prop = propsData.props.find((prop) => prop.prop === propName);
|
|
20
|
+
|
|
21
|
+
if (prop == null) return undefined;
|
|
22
|
+
|
|
23
|
+
if (prop.type === "asset") {
|
|
24
|
+
return prop.value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return undefined;
|
|
28
|
+
}, [propName, propsData]);
|
|
29
|
+
|
|
30
|
+
return asset;
|
|
31
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { type Instance } from "../db";
|
|
3
|
+
import { type UserProp } from "./schema";
|
|
4
|
+
import { useAllUserProps } from "./all-user-props";
|
|
5
|
+
|
|
6
|
+
type UserProps = { [prop: UserProp["prop"]]: string | number | boolean };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* User props mapped in prop:value format,
|
|
10
|
+
* up to date with props panel.
|
|
11
|
+
*/
|
|
12
|
+
export const useUserProps = (instanceId: Instance["id"]) => {
|
|
13
|
+
const [allUserProps] = useAllUserProps();
|
|
14
|
+
|
|
15
|
+
const propsData = allUserProps[instanceId];
|
|
16
|
+
const props = useMemo(() => {
|
|
17
|
+
if (propsData == null) return {};
|
|
18
|
+
const result: UserProps = {};
|
|
19
|
+
|
|
20
|
+
for (const userProp of propsData.props) {
|
|
21
|
+
if (userProp.type !== "asset") {
|
|
22
|
+
result[userProp.prop] = userProp.value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return result;
|
|
27
|
+
}, [propsData]);
|
|
28
|
+
|
|
29
|
+
return props;
|
|
30
|
+
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ComponentProps } from "react";
|
|
2
|
-
import { Image as WebstudioImage } from "@webstudio-is/image";
|
|
3
|
-
import { idAttribute } from "../../tree/wrapper-component";
|
|
4
|
-
declare type Props = ComponentProps<typeof WebstudioImage> & {
|
|
5
|
-
[idAttribute]: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const Component: import("react").ForwardRefExoticComponent<Pick<Props, "key" | keyof import("react").ImgHTMLAttributes<HTMLImageElement> | "data-ws-id" | "quality" | "loader" | "optimize"> & import("react").RefAttributes<HTMLImageElement>>;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=image.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/app/custom-components/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,IAAI,cAAc,EAAW,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAK3D,aAAK,KAAK,GAAG,cAAc,CAAC,OAAO,cAAc,CAAC,GAAG;IAAE,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,eAAO,MAAM,SAAS,gOAqBrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/custom-components/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handle-request.server.d.ts","sourceRoot":"","sources":["../../src/app/handle-request.server.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,aAAa,YACf,OAAO,sBACI,MAAM,mBACT,OAAO,gBACV,YAAY,aAY3B,CAAC"}
|
package/lib/app/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,UAAU,CAAC"}
|
package/lib/app/params.d.ts
DELETED
package/lib/app/params.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/app/params.ts"],"names":[],"mappings":"AAAA,oBAAY,MAAM,GAAG;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAMF,eAAO,MAAM,SAAS,QAAO,MAA+B,CAAC;AAE7D,eAAO,MAAM,SAAS,cAAe,MAAM,GAAG,IAAI,SAEjD,CAAC"}
|
package/lib/app/root.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Outlet as DefaultOutlet } from "@remix-run/react";
|
|
3
|
-
/**
|
|
4
|
-
* We are using Outlet prop from index layout when user renders site from a subdomain.
|
|
5
|
-
*/
|
|
6
|
-
export declare const Root: ({ Outlet, }: {
|
|
7
|
-
Outlet: typeof DefaultOutlet;
|
|
8
|
-
}) => JSX.Element;
|
|
9
|
-
//# sourceMappingURL=root.d.ts.map
|
package/lib/app/root.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/app/root.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAe,MAAM,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE;;GAEG;AACH,eAAO,MAAM,IAAI;YAGP,oBAAoB;iBAiB7B,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ComponentProps } from "react";
|
|
2
|
-
import { Image as WebstudioImage } from "@webstudio-is/image";
|
|
3
|
-
import { idAttribute } from "../../tree/wrapper-component";
|
|
4
|
-
declare type Props = ComponentProps<typeof WebstudioImage> & {
|
|
5
|
-
[idAttribute]: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const Component: import("react").ForwardRefExoticComponent<Pick<Props, "key" | keyof import("react").ImgHTMLAttributes<HTMLImageElement> | "data-ws-id" | "quality" | "loader" | "optimize"> & import("react").RefAttributes<HTMLImageElement>>;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=image.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/app/custom-components/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,IAAI,cAAc,EAAW,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAK3D,aAAK,KAAK,GAAG,cAAc,CAAC,OAAO,cAAc,CAAC,GAAG;IAAE,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,eAAO,MAAM,SAAS,gOAqBrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app/custom-components/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handle-request.server.d.ts","sourceRoot":"","sources":["../../../src/app/handle-request.server.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,aAAa,YACf,OAAO,sBACI,MAAM,mBACT,OAAO,gBACV,YAAY,aAY3B,CAAC"}
|
package/lib/cjs/app/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,UAAU,CAAC"}
|
package/lib/cjs/app/params.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../src/app/params.ts"],"names":[],"mappings":"AAAA,oBAAY,MAAM,GAAG;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAMF,eAAO,MAAM,SAAS,QAAO,MAA+B,CAAC;AAE7D,eAAO,MAAM,SAAS,cAAe,MAAM,GAAG,IAAI,SAEjD,CAAC"}
|
package/lib/cjs/app/root.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Outlet as DefaultOutlet } from "@remix-run/react";
|
|
3
|
-
/**
|
|
4
|
-
* We are using Outlet prop from index layout when user renders site from a subdomain.
|
|
5
|
-
*/
|
|
6
|
-
export declare const Root: ({ Outlet, }: {
|
|
7
|
-
Outlet: typeof DefaultOutlet;
|
|
8
|
-
}) => JSX.Element;
|
|
9
|
-
//# sourceMappingURL=root.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../src/app/root.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAe,MAAM,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE;;GAEG;AACH,eAAO,MAAM,IAAI;YAGP,oBAAoB;iBAiB7B,CAAC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const Body: import("react").ForwardRefExoticComponent<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>, "key" | keyof import("react").HTMLAttributes<HTMLBodyElement>> & import("react").RefAttributes<HTMLBodyElement>>;
|
|
3
|
-
//# sourceMappingURL=body.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/components/body.tsx"],"names":[],"mappings":";AAIA,eAAO,MAAM,IAAI,sQAG+B,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Body = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const body_1 = require("./body");
|
|
6
|
-
exports.default = {
|
|
7
|
-
title: "Components/Body",
|
|
8
|
-
component: body_1.Body,
|
|
9
|
-
};
|
|
10
|
-
const Body = (args) => ((0, jsx_runtime_1.jsx)(body_1.Body, { ...args }));
|
|
11
|
-
exports.Body = Body;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { ComponentStory, ComponentMeta } from "@storybook/react";
|
|
3
|
-
import { Body as BodyPrimitive } from "./body";
|
|
4
|
-
declare const _default: ComponentMeta<import("react").ForwardRefExoticComponent<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>, "key" | keyof import("react").HTMLAttributes<HTMLBodyElement>> & import("react").RefAttributes<HTMLBodyElement>>>;
|
|
5
|
-
export default _default;
|
|
6
|
-
export declare const Body: ComponentStory<typeof BodyPrimitive>;
|
|
7
|
-
//# sourceMappingURL=body.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"body.stories.d.ts","sourceRoot":"","sources":["../../../src/components/body.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAC;;AAE/C,wBAGyC;AAEzC,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,OAAO,aAAa,CAErD,CAAC"}
|