@webstudio-is/react-sdk 0.51.0 → 0.53.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/cjs/components/{blockquote.cjs → blockquote.js} +2 -1
- package/lib/cjs/components/{blockquote.ws.cjs → blockquote.ws.js} +57 -35
- package/lib/cjs/components/{body.cjs → body.js} +2 -1
- package/lib/cjs/components/{body.ws.cjs → body.ws.js} +30 -46
- package/lib/cjs/components/{bold.cjs → bold.js} +2 -1
- package/lib/cjs/components/{bold.ws.cjs → bold.ws.js} +6 -1
- package/lib/cjs/components/{box.ws.cjs → box.ws.js} +11 -4
- package/lib/cjs/components/{button.cjs → button.js} +2 -1
- package/lib/cjs/components/{button.ws.cjs → button.ws.js} +6 -1
- package/lib/cjs/components/{code.cjs → code.js} +1 -0
- package/lib/cjs/components/{code.ws.cjs → code.ws.js} +31 -25
- package/lib/cjs/components/{form.cjs → form.js} +2 -1
- package/lib/cjs/components/{form.ws.cjs → form.ws.js} +8 -8
- package/lib/cjs/components/{heading.ws.cjs → heading.ws.js} +11 -1
- package/lib/cjs/components/{image.cjs → image.js} +2 -1
- package/lib/cjs/components/{image.ws.cjs → image.ws.js} +15 -11
- package/lib/cjs/components/{input.cjs → input.js} +2 -1
- package/lib/cjs/components/{input.ws.cjs → input.ws.js} +6 -1
- package/lib/cjs/components/{italic.cjs → italic.js} +2 -1
- package/lib/cjs/components/{italic.ws.cjs → italic.ws.js} +8 -4
- package/lib/cjs/components/{link-block.cjs → link-block.js} +3 -1
- package/lib/cjs/components/{link-block.ws.cjs → link-block.ws.js} +7 -7
- package/lib/cjs/components/{link.cjs → link.js} +3 -1
- package/lib/cjs/components/{link.ws.cjs → link.ws.js} +13 -9
- package/lib/cjs/components/{list-item.cjs → list-item.js} +2 -1
- package/lib/cjs/components/{list-item.ws.cjs → list-item.ws.js} +6 -1
- package/lib/cjs/components/{list.ws.cjs → list.ws.js} +29 -10
- package/lib/cjs/components/{paragraph.cjs → paragraph.js} +2 -1
- package/lib/cjs/components/{paragraph.ws.cjs → paragraph.ws.js} +6 -1
- package/lib/cjs/components/{separator.cjs → separator.js} +2 -1
- package/lib/cjs/components/{separator.ws.cjs → separator.ws.js} +27 -11
- package/lib/cjs/components/{span.cjs → span.js} +2 -1
- package/lib/cjs/components/{span.ws.cjs → span.ws.js} +6 -1
- package/lib/cjs/components/{subscript.cjs → subscript.js} +2 -1
- package/lib/cjs/components/{subscript.ws.cjs → subscript.ws.js} +6 -1
- package/lib/cjs/components/{superscript.cjs → superscript.js} +2 -1
- package/lib/cjs/components/{superscript.ws.cjs → superscript.ws.js} +6 -1
- package/lib/cjs/components/{text-block.cjs → text-block.js} +2 -1
- package/lib/cjs/components/{text-block.ws.cjs → text-block.ws.js} +9 -5
- package/lib/cjs/css/css.js +64 -0
- package/lib/cjs/css/global-rules.js +37 -0
- package/lib/cjs/css/{index.cjs → index.js} +3 -1
- package/lib/cjs/css/normalize-type-check.js +26 -0
- package/lib/cjs/css/normalize.js +358 -0
- package/lib/cjs/css/presets.js +61 -0
- package/lib/cjs/css/style-rules.js +62 -0
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/pubsub/{create.cjs → create.js} +6 -35
- package/lib/cjs/pubsub/raf-queue.js +45 -0
- package/lib/cjs/tree/{webstudio-component.cjs → webstudio-component.js} +1 -0
- package/lib/components/blockquote.js +2 -1
- package/lib/components/blockquote.ws.js +57 -35
- package/lib/components/body.js +2 -1
- package/lib/components/body.ws.js +30 -46
- package/lib/components/bold.js +2 -1
- package/lib/components/bold.ws.js +7 -2
- package/lib/components/box.ws.js +22 -4
- package/lib/components/button.js +2 -1
- package/lib/components/button.ws.js +7 -2
- package/lib/components/code.js +1 -0
- package/lib/components/code.ws.js +31 -25
- package/lib/components/form.js +2 -1
- package/lib/components/form.ws.js +8 -8
- package/lib/components/heading.ws.js +11 -1
- package/lib/components/image.js +2 -1
- package/lib/components/image.ws.js +15 -11
- package/lib/components/input.js +2 -1
- package/lib/components/input.ws.js +7 -2
- package/lib/components/italic.js +2 -1
- package/lib/components/italic.ws.js +9 -5
- package/lib/components/link-block.js +3 -1
- package/lib/components/link-block.ws.js +7 -7
- package/lib/components/link.js +3 -1
- package/lib/components/link.ws.js +14 -10
- package/lib/components/list-item.js +2 -1
- package/lib/components/list-item.ws.js +6 -1
- package/lib/components/list.ws.js +29 -10
- package/lib/components/paragraph.js +2 -1
- package/lib/components/paragraph.ws.js +6 -1
- package/lib/components/separator.js +2 -1
- package/lib/components/separator.ws.js +27 -11
- package/lib/components/span.js +2 -1
- package/lib/components/span.ws.js +7 -2
- package/lib/components/subscript.js +2 -1
- package/lib/components/subscript.ws.js +6 -1
- package/lib/components/superscript.js +2 -1
- package/lib/components/superscript.ws.js +6 -1
- package/lib/components/text-block.js +2 -1
- package/lib/components/text-block.ws.js +10 -6
- package/lib/css/css.js +44 -0
- package/lib/css/get-browser-style.js +3 -1
- package/lib/css/global-rules.js +20 -0
- package/lib/css/index.js +3 -1
- package/lib/css/normalize-type-check.js +3 -0
- package/lib/css/normalize.js +338 -0
- package/lib/css/presets.js +41 -0
- package/lib/css/style-rules.js +42 -0
- package/lib/pubsub/create.js +6 -25
- package/lib/pubsub/raf-queue.js +25 -0
- package/lib/tree/webstudio-component.js +1 -0
- package/lib/types/app/custom-components/image.d.ts +6 -0
- package/lib/types/app/custom-components/index.d.ts +26 -0
- package/lib/types/app/custom-components/link-block.d.ts +6 -0
- package/lib/types/app/custom-components/link.d.ts +6 -0
- package/lib/types/app/custom-components/rich-text-link.d.ts +6 -0
- package/lib/types/app/custom-components/shared/remix-link.d.ts +10 -0
- package/lib/types/app/handle-request.server.d.ts +2 -0
- package/lib/types/app/index.d.ts +3 -0
- package/lib/types/app/params.d.ts +5 -0
- package/lib/types/app/root.d.ts +8 -0
- package/lib/types/components/__generated__/blockquote.props.d.ts +2 -0
- package/lib/types/components/__generated__/body.props.d.ts +2 -0
- package/lib/types/components/__generated__/bold.props.d.ts +2 -0
- package/lib/types/components/__generated__/box.props.d.ts +2 -0
- package/lib/types/components/__generated__/button.props.d.ts +2 -0
- package/lib/types/components/__generated__/code.props.d.ts +2 -0
- package/lib/types/components/__generated__/form.props.d.ts +2 -0
- package/lib/types/components/__generated__/fragment.props.d.ts +2 -0
- package/lib/types/components/__generated__/heading.props.d.ts +2 -0
- package/lib/types/components/__generated__/image.props.d.ts +2 -0
- package/lib/types/components/__generated__/input.props.d.ts +2 -0
- package/lib/types/components/__generated__/italic.props.d.ts +2 -0
- package/lib/types/components/__generated__/link-block.props.d.ts +2 -0
- package/lib/types/components/__generated__/link.props.d.ts +2 -0
- package/lib/types/components/__generated__/list-item.props.d.ts +2 -0
- package/lib/types/components/__generated__/list.props.d.ts +2 -0
- package/lib/types/components/__generated__/paragraph.props.d.ts +2 -0
- package/lib/types/components/__generated__/rich-text-link.props.d.ts +2 -0
- package/lib/types/components/__generated__/separator.props.d.ts +2 -0
- package/lib/types/components/__generated__/slot.props.d.ts +2 -0
- package/lib/types/components/__generated__/span.props.d.ts +2 -0
- package/lib/types/components/__generated__/subscript.props.d.ts +2 -0
- package/lib/types/components/__generated__/superscript.props.d.ts +2 -0
- package/lib/types/components/__generated__/text-block.props.d.ts +2 -0
- package/lib/types/components/blockquote.d.ts +3 -0
- package/lib/types/components/blockquote.stories.d.ts +5 -0
- package/lib/types/components/blockquote.ws.d.ts +3 -0
- package/lib/types/components/body.d.ts +3 -0
- package/lib/types/components/body.stories.d.ts +6 -0
- package/lib/types/components/body.ws.d.ts +3 -0
- package/lib/types/components/bold.d.ts +3 -0
- package/lib/types/components/bold.stories.d.ts +5 -0
- package/lib/types/components/bold.ws.d.ts +3 -0
- package/lib/types/components/box.d.ts +7 -0
- package/lib/types/components/box.stories.d.ts +9 -0
- package/lib/types/components/box.ws.d.ts +3 -0
- package/lib/types/components/button.d.ts +7 -0
- package/lib/types/components/button.stories.d.ts +9 -0
- package/lib/types/components/button.ws.d.ts +3 -0
- package/lib/types/components/code.d.ts +9 -0
- package/lib/types/components/code.stories.d.ts +11 -0
- package/lib/types/components/code.ws.d.ts +3 -0
- package/lib/types/components/component-meta.d.ts +605 -0
- package/lib/types/components/components-utils.d.ts +34 -0
- package/lib/types/components/components.d.ts +31 -0
- package/lib/types/components/form.d.ts +3 -0
- package/lib/types/components/form.stories.d.ts +5 -0
- package/lib/types/components/form.ws.d.ts +3 -0
- package/lib/types/components/fragment.d.ts +6 -0
- package/lib/types/components/fragment.ws.d.ts +3 -0
- package/lib/types/components/heading.d.ts +7 -0
- package/lib/types/components/heading.stories.d.ts +9 -0
- package/lib/types/components/heading.ws.d.ts +3 -0
- package/lib/types/components/image.d.ts +3 -0
- package/lib/types/components/image.stories.d.ts +5 -0
- package/lib/types/components/image.ws.d.ts +3 -0
- package/lib/types/components/index.d.ts +17 -0
- package/lib/types/components/input.d.ts +3 -0
- package/lib/types/components/input.stories.d.ts +5 -0
- package/lib/types/components/input.ws.d.ts +3 -0
- package/lib/types/components/italic.d.ts +3 -0
- package/lib/types/components/italic.stories.d.ts +5 -0
- package/lib/types/components/italic.ws.d.ts +3 -0
- package/lib/types/components/link-block.d.ts +3 -0
- package/lib/types/components/link-block.stories.d.ts +13 -0
- package/lib/types/components/link-block.ws.d.ts +3 -0
- package/lib/types/components/link.d.ts +9 -0
- package/lib/types/components/link.stories.d.ts +13 -0
- package/lib/types/components/link.ws.d.ts +3 -0
- package/lib/types/components/list-item.d.ts +3 -0
- package/lib/types/components/list-item.stories.d.ts +5 -0
- package/lib/types/components/list-item.ws.d.ts +3 -0
- package/lib/types/components/list.d.ts +9 -0
- package/lib/types/components/list.stories.d.ts +9 -0
- package/lib/types/components/list.ws.d.ts +3 -0
- package/lib/types/components/paragraph.d.ts +3 -0
- package/lib/types/components/paragraph.stories.d.ts +5 -0
- package/lib/types/components/paragraph.ws.d.ts +3 -0
- package/lib/types/components/rich-text-link.d.ts +2 -0
- package/lib/types/components/rich-text-link.stories.d.ts +13 -0
- package/lib/types/components/rich-text-link.ws.d.ts +3 -0
- package/lib/types/components/separator.d.ts +3 -0
- package/lib/types/components/separator.stories.d.ts +5 -0
- package/lib/types/components/separator.ws.d.ts +3 -0
- package/lib/types/components/slot.d.ts +6 -0
- package/lib/types/components/slot.stories.d.ts +9 -0
- package/lib/types/components/slot.ws.d.ts +3 -0
- package/lib/types/components/span.d.ts +3 -0
- package/lib/types/components/span.stories.d.ts +5 -0
- package/lib/types/components/span.ws.d.ts +3 -0
- package/lib/types/components/subscript.d.ts +3 -0
- package/lib/types/components/subscript.stories.d.ts +5 -0
- package/lib/types/components/subscript.ws.d.ts +3 -0
- package/lib/types/components/superscript.d.ts +3 -0
- package/lib/types/components/superscript.stories.d.ts +5 -0
- package/lib/types/components/superscript.ws.d.ts +3 -0
- package/lib/types/components/text-block.d.ts +3 -0
- package/lib/types/components/text-block.stories.d.ts +5 -0
- package/lib/types/components/text-block.ws.d.ts +3 -0
- package/lib/types/context.d.ts +9 -0
- package/lib/types/css/css.d.ts +10 -0
- package/lib/types/css/get-browser-style.d.ts +2 -0
- package/lib/types/css/global-rules.d.ts +44 -0
- package/lib/types/css/index.d.ts +4 -0
- package/lib/types/css/normalize-type-check.d.ts +1 -0
- package/lib/types/css/normalize.d.ts +2429 -0
- package/lib/types/css/presets.d.ts +38 -0
- package/lib/types/css/style-rules.d.ts +248 -0
- package/lib/types/css/style-rules.test.d.ts +1 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/props.d.ts +97 -0
- package/lib/types/props.test.d.ts +1 -0
- package/lib/types/pubsub/create.d.ts +28 -0
- package/lib/types/pubsub/index.d.ts +1 -0
- package/lib/types/pubsub/raf-queue.d.ts +1 -0
- package/lib/types/tree/create-elements-tree.d.ts +16 -0
- package/lib/types/tree/index.d.ts +3 -0
- package/lib/types/tree/root.d.ts +25 -0
- package/lib/types/tree/session-storage-polyfill.d.ts +2 -0
- package/lib/types/tree/webstudio-component.d.ts +15 -0
- package/package.json +20 -19
- package/src/components/blockquote.tsx +1 -1
- package/src/components/blockquote.ws.tsx +63 -36
- package/src/components/body.tsx +1 -1
- package/src/components/body.ws.tsx +39 -47
- package/src/components/bold.tsx +1 -1
- package/src/components/bold.ws.tsx +10 -2
- package/src/components/box.ws.ts +28 -5
- package/src/components/button.tsx +1 -1
- package/src/components/button.ws.tsx +10 -2
- package/src/components/code.tsx +1 -1
- package/src/components/code.ws.tsx +36 -28
- package/src/components/component-meta.ts +4 -1
- package/src/components/form.tsx +1 -1
- package/src/components/form.ws.tsx +11 -9
- package/src/components/heading.ws.tsx +16 -0
- package/src/components/image.tsx +1 -1
- package/src/components/image.ws.tsx +19 -12
- package/src/components/input.tsx +1 -1
- package/src/components/input.ws.tsx +10 -2
- package/src/components/italic.tsx +1 -1
- package/src/components/italic.ws.tsx +12 -6
- package/src/components/link-block.tsx +1 -0
- package/src/components/link-block.ws.tsx +10 -8
- package/src/components/link.tsx +2 -0
- package/src/components/link.ws.tsx +17 -11
- package/src/components/list-item.tsx +1 -1
- package/src/components/list-item.ws.tsx +8 -0
- package/src/components/list.tsx +2 -0
- package/src/components/list.ws.tsx +32 -11
- package/src/components/paragraph.tsx +1 -1
- package/src/components/paragraph.ws.tsx +8 -0
- package/src/components/separator.tsx +1 -1
- package/src/components/separator.ws.tsx +33 -12
- package/src/components/span.tsx +1 -1
- package/src/components/span.ws.tsx +10 -2
- package/src/components/subscript.tsx +1 -1
- package/src/components/subscript.ws.tsx +8 -0
- package/src/components/superscript.tsx +1 -1
- package/src/components/superscript.ws.tsx +8 -0
- package/src/components/text-block.tsx +1 -1
- package/src/components/text-block.ws.tsx +14 -7
- package/src/context.tsx +2 -1
- package/src/css/css.ts +57 -0
- package/src/css/get-browser-style.ts +6 -1
- package/src/css/global-rules.ts +29 -0
- package/src/css/index.ts +3 -1
- package/src/css/normalize-type-check.ts +13 -0
- package/src/css/normalize.ts +519 -0
- package/src/css/presets.ts +42 -0
- package/src/css/style-rules.test.ts +147 -0
- package/src/css/style-rules.ts +66 -0
- package/src/props.ts +0 -2
- package/src/pubsub/create.ts +7 -38
- package/src/pubsub/raf-queue.ts +31 -0
- package/src/tree/create-elements-tree.tsx +2 -1
- package/src/tree/webstudio-component.tsx +1 -0
- package/lib/cjs/css/categories.cjs +0 -250
- package/lib/css/categories.js +0 -230
- package/src/css/categories.ts +0 -254
- /package/lib/cjs/app/custom-components/{image.cjs → image.js} +0 -0
- /package/lib/cjs/app/custom-components/{index.cjs → index.js} +0 -0
- /package/lib/cjs/app/custom-components/{link-block.cjs → link-block.js} +0 -0
- /package/lib/cjs/app/custom-components/{link.cjs → link.js} +0 -0
- /package/lib/cjs/app/custom-components/{rich-text-link.cjs → rich-text-link.js} +0 -0
- /package/lib/cjs/app/custom-components/shared/{remix-link.cjs → remix-link.js} +0 -0
- /package/lib/cjs/app/{handle-request.server.cjs → handle-request.server.js} +0 -0
- /package/lib/cjs/app/{index.cjs → index.js} +0 -0
- /package/lib/cjs/app/{params.cjs → params.js} +0 -0
- /package/lib/cjs/app/{root.cjs → root.js} +0 -0
- /package/lib/cjs/components/__generated__/{blockquote.props.cjs → blockquote.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{body.props.cjs → body.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{bold.props.cjs → bold.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{box.props.cjs → box.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{button.props.cjs → button.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{code.props.cjs → code.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{form.props.cjs → form.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{fragment.props.cjs → fragment.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{heading.props.cjs → heading.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{image.props.cjs → image.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{input.props.cjs → input.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{italic.props.cjs → italic.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{link-block.props.cjs → link-block.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{link.props.cjs → link.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{list-item.props.cjs → list-item.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{list.props.cjs → list.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{paragraph.props.cjs → paragraph.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{rich-text-link.props.cjs → rich-text-link.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{separator.props.cjs → separator.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{slot.props.cjs → slot.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{span.props.cjs → span.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{subscript.props.cjs → subscript.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{superscript.props.cjs → superscript.props.js} +0 -0
- /package/lib/cjs/components/__generated__/{text-block.props.cjs → text-block.props.js} +0 -0
- /package/lib/cjs/components/{box.cjs → box.js} +0 -0
- /package/lib/cjs/components/{component-meta.cjs → component-meta.js} +0 -0
- /package/lib/cjs/components/{components-utils.cjs → components-utils.js} +0 -0
- /package/lib/cjs/components/{components.cjs → components.js} +0 -0
- /package/lib/cjs/components/{fragment.cjs → fragment.js} +0 -0
- /package/lib/cjs/components/{fragment.ws.cjs → fragment.ws.js} +0 -0
- /package/lib/cjs/components/{heading.cjs → heading.js} +0 -0
- /package/lib/cjs/components/{index.cjs → index.js} +0 -0
- /package/lib/cjs/components/{list.cjs → list.js} +0 -0
- /package/lib/cjs/components/{rich-text-link.cjs → rich-text-link.js} +0 -0
- /package/lib/cjs/components/{rich-text-link.ws.cjs → rich-text-link.ws.js} +0 -0
- /package/lib/cjs/components/{slot.cjs → slot.js} +0 -0
- /package/lib/cjs/components/{slot.ws.cjs → slot.ws.js} +0 -0
- /package/lib/cjs/{context.cjs → context.js} +0 -0
- /package/lib/cjs/css/{get-browser-style.cjs → get-browser-style.js} +0 -0
- /package/lib/cjs/{index.cjs → index.js} +0 -0
- /package/lib/cjs/{props.cjs → props.js} +0 -0
- /package/lib/cjs/pubsub/{index.cjs → index.js} +0 -0
- /package/lib/cjs/tree/{create-elements-tree.cjs → create-elements-tree.js} +0 -0
- /package/lib/cjs/tree/{index.cjs → index.js} +0 -0
- /package/lib/cjs/tree/{root.cjs → root.js} +0 -0
- /package/lib/cjs/tree/{session-storage-polyfill.cjs → session-storage-polyfill.js} +0 -0
package/src/components/link.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { forwardRef, type ComponentProps } from "react";
|
|
2
2
|
import { usePropUrl, getInstanceIdFromComponentProps } from "../props";
|
|
3
3
|
|
|
4
|
+
export const defaultTag = "a";
|
|
5
|
+
|
|
4
6
|
// @todo props that come from remix link, shouldn't be here at all
|
|
5
7
|
// - prefetch should be only on remix component and it already is
|
|
6
8
|
// - props meta should be generated from Remix link
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
2
|
+
import { LinkIcon } from "@webstudio-is/icons";
|
|
3
|
+
import { a } from "../css/normalize";
|
|
2
4
|
import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
|
|
5
|
+
import type { defaultTag } from "./link";
|
|
3
6
|
import { props } from "./__generated__/link.props";
|
|
4
7
|
|
|
5
8
|
const presetStyle = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
a: {
|
|
10
|
+
...a,
|
|
11
|
+
minHeight: {
|
|
12
|
+
type: "unit",
|
|
13
|
+
unit: "em",
|
|
14
|
+
value: 1,
|
|
15
|
+
},
|
|
16
|
+
display: {
|
|
17
|
+
type: "keyword",
|
|
18
|
+
value: "inline-block",
|
|
19
|
+
},
|
|
14
20
|
},
|
|
15
|
-
} as const
|
|
21
|
+
} as const satisfies Record<typeof defaultTag, Style>;
|
|
16
22
|
|
|
17
23
|
export const meta: WsComponentMeta = {
|
|
18
24
|
category: "general",
|
|
19
25
|
type: "rich-text",
|
|
20
26
|
label: "Link Text",
|
|
21
|
-
Icon:
|
|
27
|
+
Icon: LinkIcon,
|
|
22
28
|
presetStyle,
|
|
23
29
|
children: ["Link text you can edit"],
|
|
24
30
|
};
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
1
2
|
import { ListItemIcon } from "@webstudio-is/icons";
|
|
3
|
+
import { li } from "../css/normalize";
|
|
2
4
|
import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
|
|
5
|
+
import type { defaultTag } from "./list-item";
|
|
3
6
|
import { props } from "./__generated__/list-item.props";
|
|
4
7
|
|
|
8
|
+
const presetStyle = {
|
|
9
|
+
li,
|
|
10
|
+
} as const satisfies Record<typeof defaultTag, Style>;
|
|
11
|
+
|
|
5
12
|
export const meta: WsComponentMeta = {
|
|
6
13
|
category: "typography",
|
|
7
14
|
type: "rich-text",
|
|
8
15
|
label: "List Item",
|
|
9
16
|
Icon: ListItemIcon,
|
|
10
17
|
children: ["List Item you can edit"],
|
|
18
|
+
presetStyle,
|
|
11
19
|
};
|
|
12
20
|
|
|
13
21
|
export const propsMeta: WsComponentPropsMeta = {
|
package/src/components/list.tsx
CHANGED
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
import { ListIcon } from "@webstudio-is/icons";
|
|
2
2
|
import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
|
|
3
3
|
import { props } from "./__generated__/list.props";
|
|
4
|
+
import type { ListTag } from "./list";
|
|
5
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
6
|
+
import { ol, ul } from "../css/normalize";
|
|
4
7
|
|
|
5
8
|
const presetStyle = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
ol: {
|
|
10
|
+
...ol,
|
|
11
|
+
marginTop: {
|
|
12
|
+
type: "keyword",
|
|
13
|
+
value: "0",
|
|
14
|
+
},
|
|
15
|
+
marginBottom: {
|
|
16
|
+
type: "keyword",
|
|
17
|
+
value: "10px",
|
|
18
|
+
},
|
|
19
|
+
paddingLeft: {
|
|
20
|
+
type: "keyword",
|
|
21
|
+
value: "40px",
|
|
22
|
+
},
|
|
9
23
|
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
ul: {
|
|
25
|
+
...ul,
|
|
26
|
+
marginTop: {
|
|
27
|
+
type: "keyword",
|
|
28
|
+
value: "0",
|
|
29
|
+
},
|
|
30
|
+
marginBottom: {
|
|
31
|
+
type: "keyword",
|
|
32
|
+
value: "10px",
|
|
33
|
+
},
|
|
34
|
+
paddingLeft: {
|
|
35
|
+
type: "keyword",
|
|
36
|
+
value: "40px",
|
|
37
|
+
},
|
|
13
38
|
},
|
|
14
|
-
|
|
15
|
-
type: "keyword",
|
|
16
|
-
value: "40px",
|
|
17
|
-
},
|
|
18
|
-
} as const;
|
|
39
|
+
} as const satisfies Record<ListTag, Style>;
|
|
19
40
|
|
|
20
41
|
export const meta: WsComponentMeta = {
|
|
21
42
|
category: "typography",
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
1
2
|
import { TextAlignLeftIcon } from "@webstudio-is/icons";
|
|
3
|
+
import { p } from "../css/normalize";
|
|
2
4
|
import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
|
|
5
|
+
import type { defaultTag } from "./paragraph";
|
|
3
6
|
import { props } from "./__generated__/paragraph.props";
|
|
4
7
|
|
|
8
|
+
const presetStyle = {
|
|
9
|
+
p,
|
|
10
|
+
} as const satisfies Record<typeof defaultTag, Style>;
|
|
11
|
+
|
|
5
12
|
export const meta: WsComponentMeta = {
|
|
6
13
|
category: "typography",
|
|
7
14
|
type: "rich-text",
|
|
8
15
|
label: "Paragraph",
|
|
9
16
|
Icon: TextAlignLeftIcon,
|
|
10
17
|
children: ["Pragraph you can edit"],
|
|
18
|
+
presetStyle,
|
|
11
19
|
};
|
|
12
20
|
|
|
13
21
|
export const propsMeta: WsComponentPropsMeta = {
|
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
import { DashIcon } from "@webstudio-is/icons";
|
|
2
2
|
import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
|
|
3
3
|
import { props } from "./__generated__/separator.props";
|
|
4
|
+
import type { defaultTag } from "./separator";
|
|
5
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
6
|
+
import { hr } from "../css/normalize";
|
|
4
7
|
|
|
5
8
|
const presetStyle = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
hr: {
|
|
10
|
+
...hr,
|
|
11
|
+
|
|
12
|
+
height: {
|
|
13
|
+
type: "keyword",
|
|
14
|
+
value: "1px",
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
backgroundColor: {
|
|
18
|
+
type: "keyword",
|
|
19
|
+
value: "gray",
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
borderTopStyle: {
|
|
23
|
+
type: "keyword",
|
|
24
|
+
value: "none",
|
|
25
|
+
},
|
|
26
|
+
borderRightStyle: {
|
|
27
|
+
type: "keyword",
|
|
28
|
+
value: "none",
|
|
29
|
+
},
|
|
30
|
+
borderLeftStyle: {
|
|
31
|
+
type: "keyword",
|
|
32
|
+
value: "none",
|
|
33
|
+
},
|
|
34
|
+
borderBottomStyle: {
|
|
35
|
+
type: "keyword",
|
|
36
|
+
value: "none",
|
|
37
|
+
},
|
|
17
38
|
},
|
|
18
|
-
} as const
|
|
39
|
+
} as const satisfies Record<typeof defaultTag, Style>;
|
|
19
40
|
|
|
20
41
|
export const meta: WsComponentMeta = {
|
|
21
42
|
category: "general",
|
package/src/components/span.tsx
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
2
|
+
import { PaintBrushIcon } from "@webstudio-is/icons";
|
|
3
|
+
import { span } from "../css/normalize";
|
|
2
4
|
import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
|
|
5
|
+
import type { defaultTag } from "./span";
|
|
3
6
|
import { props } from "./__generated__/span.props";
|
|
4
7
|
|
|
8
|
+
const presetStyle = {
|
|
9
|
+
span,
|
|
10
|
+
} as const satisfies Record<typeof defaultTag, Style>;
|
|
11
|
+
|
|
5
12
|
export const meta: WsComponentMeta = {
|
|
6
13
|
type: "rich-text-child",
|
|
7
14
|
label: "Styled Text",
|
|
8
|
-
Icon:
|
|
15
|
+
Icon: PaintBrushIcon,
|
|
16
|
+
presetStyle,
|
|
9
17
|
};
|
|
10
18
|
|
|
11
19
|
export const propsMeta: WsComponentPropsMeta = {
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
1
2
|
import { SubscriptIcon } from "@webstudio-is/icons";
|
|
3
|
+
import { sub } from "../css/normalize";
|
|
2
4
|
import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
|
|
5
|
+
import type { defaultTag } from "./subscript";
|
|
3
6
|
import { props } from "./__generated__/subscript.props";
|
|
4
7
|
|
|
8
|
+
const presetStyle = {
|
|
9
|
+
sub,
|
|
10
|
+
} as const satisfies Record<typeof defaultTag, Style>;
|
|
11
|
+
|
|
5
12
|
export const meta: WsComponentMeta = {
|
|
6
13
|
type: "rich-text-child",
|
|
7
14
|
label: "Subscript Text",
|
|
8
15
|
Icon: SubscriptIcon,
|
|
16
|
+
presetStyle,
|
|
9
17
|
};
|
|
10
18
|
|
|
11
19
|
export const propsMeta: WsComponentPropsMeta = {
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
1
2
|
import { SuperscriptIcon } from "@webstudio-is/icons";
|
|
3
|
+
import { sup } from "../css/normalize";
|
|
2
4
|
import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
|
|
5
|
+
import type { defaultTag } from "./superscript";
|
|
3
6
|
import { props } from "./__generated__/superscript.props";
|
|
4
7
|
|
|
8
|
+
const presetStyle = {
|
|
9
|
+
sup,
|
|
10
|
+
} as const satisfies Record<typeof defaultTag, Style>;
|
|
11
|
+
|
|
5
12
|
export const meta: WsComponentMeta = {
|
|
6
13
|
type: "rich-text-child",
|
|
7
14
|
label: "Superscript Text",
|
|
8
15
|
Icon: SuperscriptIcon,
|
|
16
|
+
presetStyle,
|
|
9
17
|
};
|
|
10
18
|
|
|
11
19
|
export const propsMeta: WsComponentPropsMeta = {
|
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TextBlockIcon } from "@webstudio-is/icons";
|
|
2
2
|
import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
|
|
3
3
|
import { props } from "./__generated__/text-block.props";
|
|
4
|
+
import type { defaultTag } from "./text-block";
|
|
5
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
6
|
+
import { div } from "../css/normalize";
|
|
4
7
|
|
|
5
8
|
const presetStyle = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
div: {
|
|
10
|
+
...div,
|
|
11
|
+
|
|
12
|
+
minHeight: {
|
|
13
|
+
type: "unit",
|
|
14
|
+
unit: "em",
|
|
15
|
+
value: 1,
|
|
16
|
+
},
|
|
10
17
|
},
|
|
11
|
-
} as const
|
|
18
|
+
} as const satisfies Record<typeof defaultTag, Style>;
|
|
12
19
|
|
|
13
20
|
export const meta: WsComponentMeta = {
|
|
14
21
|
category: "typography",
|
|
15
22
|
type: "rich-text",
|
|
16
23
|
label: "Text Block",
|
|
17
|
-
Icon:
|
|
24
|
+
Icon: TextBlockIcon,
|
|
18
25
|
presetStyle,
|
|
19
26
|
children: ["Block of text you can edit"],
|
|
20
27
|
};
|
package/src/context.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReadableAtom, atom } from "nanostores";
|
|
2
2
|
import { createContext } from "react";
|
|
3
|
-
import type { Assets
|
|
3
|
+
import type { Assets } from "@webstudio-is/asset-uploader";
|
|
4
|
+
import type { Pages, PropsByInstanceId } from "./props";
|
|
4
5
|
|
|
5
6
|
export const ReactSdkContext = createContext<{
|
|
6
7
|
propsByInstanceIdStore: ReadableAtom<PropsByInstanceId>;
|
package/src/css/css.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createCssEngine } from "@webstudio-is/css-engine";
|
|
2
|
+
import type { Asset } from "@webstudio-is/asset-uploader";
|
|
3
|
+
import type { Build } from "@webstudio-is/project-build";
|
|
4
|
+
import { getComponentNames } from "../components/components-utils";
|
|
5
|
+
import { getComponentMeta } from "../components";
|
|
6
|
+
import { componentAttribute, idAttribute } from "../tree";
|
|
7
|
+
import { addGlobalRules } from "./global-rules";
|
|
8
|
+
import { getStyleRules } from "./style-rules";
|
|
9
|
+
|
|
10
|
+
type Data = {
|
|
11
|
+
assets: Asset[];
|
|
12
|
+
breakpoints?: Build["breakpoints"];
|
|
13
|
+
styles?: Build["styles"];
|
|
14
|
+
styleSourceSelections?: Build["styleSourceSelections"];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const generateCssText = (data: Data) => {
|
|
18
|
+
const assets = new Map<Asset["id"], Asset>(
|
|
19
|
+
data.assets.map((asset) => [asset.id, asset])
|
|
20
|
+
);
|
|
21
|
+
const breakpoints = new Map(data.breakpoints);
|
|
22
|
+
const styles = new Map(data.styles);
|
|
23
|
+
const styleSourceSelections = new Map(data.styleSourceSelections);
|
|
24
|
+
|
|
25
|
+
const engine = createCssEngine({ name: "ssr" });
|
|
26
|
+
|
|
27
|
+
addGlobalRules(engine, { assets });
|
|
28
|
+
|
|
29
|
+
for (const breakpoint of breakpoints.values()) {
|
|
30
|
+
engine.addMediaRule(breakpoint.id, breakpoint);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (const component of getComponentNames()) {
|
|
34
|
+
const meta = getComponentMeta(component);
|
|
35
|
+
const presetStyle = meta?.presetStyle;
|
|
36
|
+
if (presetStyle !== undefined) {
|
|
37
|
+
for (const [tag, style] of Object.entries(presetStyle)) {
|
|
38
|
+
engine.addStyleRule(
|
|
39
|
+
`${tag}:where([${componentAttribute}=${component}])`,
|
|
40
|
+
{
|
|
41
|
+
style,
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const styleRules = getStyleRules(styles, styleSourceSelections);
|
|
49
|
+
for (const { breakpointId, instanceId, style } of styleRules) {
|
|
50
|
+
engine.addStyleRule(`[${idAttribute}="${instanceId}"]`, {
|
|
51
|
+
breakpoint: breakpointId,
|
|
52
|
+
style,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return engine.cssText;
|
|
57
|
+
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { detectFont } from "detect-font";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type Style,
|
|
4
|
+
type StyleValue,
|
|
5
|
+
type Unit,
|
|
6
|
+
keywordValues,
|
|
7
|
+
} from "@webstudio-is/css-data";
|
|
3
8
|
import { properties, units } from "@webstudio-is/css-data";
|
|
4
9
|
|
|
5
10
|
const unitsList = Object.values(units).flat();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CssEngine } from "@webstudio-is/css-engine";
|
|
2
|
+
import type { Assets, FontAsset } from "@webstudio-is/asset-uploader";
|
|
3
|
+
import {
|
|
4
|
+
type FontFormat,
|
|
5
|
+
FONT_FORMATS,
|
|
6
|
+
getFontFaces,
|
|
7
|
+
} from "@webstudio-is/fonts";
|
|
8
|
+
|
|
9
|
+
export const addGlobalRules = (
|
|
10
|
+
engine: CssEngine,
|
|
11
|
+
{ assets }: { assets: Assets }
|
|
12
|
+
) => {
|
|
13
|
+
// @todo we need to figure out all global resets while keeping
|
|
14
|
+
// the engine aware of all of them.
|
|
15
|
+
// Ideally, the user is somehow aware and in control of the reset
|
|
16
|
+
engine.addPlaintextRule("html {margin: 0; height: 100%}");
|
|
17
|
+
|
|
18
|
+
const fontAssets: Array<FontAsset> = [];
|
|
19
|
+
for (const asset of assets.values()) {
|
|
20
|
+
if (asset && FONT_FORMATS.has(asset.format as FontFormat)) {
|
|
21
|
+
fontAssets.push(asset as FontAsset);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const fontFaces = getFontFaces(fontAssets);
|
|
26
|
+
for (const fontFace of fontFaces) {
|
|
27
|
+
engine.addFontFaceRule(fontFace);
|
|
28
|
+
}
|
|
29
|
+
};
|
package/src/css/index.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as normalize from "./normalize";
|
|
2
|
+
import type { htmlTags as HtmlTags } from "html-tags";
|
|
3
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
4
|
+
|
|
5
|
+
// no way I found to check exports https://github.com/microsoft/TypeScript/issues/38511
|
|
6
|
+
// we can check here that all exports represents a valid html tag
|
|
7
|
+
const normalizeWithKeyof = { ...normalize };
|
|
8
|
+
|
|
9
|
+
type ExportedTags = keyof typeof normalizeWithKeyof;
|
|
10
|
+
|
|
11
|
+
type ValidTags = ExportedTags extends HtmlTags ? ExportedTags : false;
|
|
12
|
+
|
|
13
|
+
normalizeWithKeyof satisfies Record<ValidTags, Style>;
|