Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
merge webstudio meta for components with sdk react components
Oleg Isonen6b5582776e77
diff --git a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsxindex b73f7c6262..169e79370a 100644--- a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx+++ b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx@@ -6,8 +6,8 @@ import {toCss,useUserProps,renderWrapperComponentChildren,+ components,} from "@webstudio-is/react-sdk";-import { primitives } from "~/shared/canvas-components";import { useBreakpoints, useTextEditingInstanceId } from "~/shared/nano-states";import { useCss } from "./use-css";import { useDraggable } from "./use-draggable";@@ -63,7 +63,7 @@ export const WrapperComponentDev = ({const readonlyProps =instance.component === "Input" ? { readOnly: true } : undefined;- const { Component } = primitives[instance.component];+ const { Component } = components[instance.component];const props = {...userProps,@@ -122,7 +122,7 @@ export const InlineWrapperComponentDev = ({);const className = useCss({ instance, css });const userProps = useUserProps(instance.id);- const { Component } = primitives[instance.component];+ const { Component } = components[instance.component];return (<Componentdiff --git a/apps/designer/app/canvas/shared/use-shortcuts.ts b/apps/designer/app/canvas/shared/use-shortcuts.tsindex d1a9049258..f8594068b1 100644--- a/apps/designer/app/canvas/shared/use-shortcuts.ts+++ b/apps/designer/app/canvas/shared/use-shortcuts.ts@@ -1,6 +1,11 @@import { useHotkeys } from "react-hotkeys-hook";import store from "immerhin";-import { type Instance, publish, useSubscribe } from "@webstudio-is/react-sdk";+import {+ type Instance,+ publish,+ useSubscribe,+ components,+} from "@webstudio-is/react-sdk";import { shortcuts, options } from "~/shared/shortcuts";import { useSelectedInstance } from "./nano-states";import { copy, paste } from "./copy-paste";@@ -8,7 +13,6 @@ import {useRootInstance,useTextEditingInstanceId,} from "~/shared/nano-states";-import { primitives } from "~/shared/canvas-components";const inputTags = ["INPUT", "SELECT", "TEXTAREA"] as const;@@ -100,7 +104,7 @@ export const useShortcuts = () => {"enter",(event) => {if (selectedInstance === undefined) return;- const { isContentEditable } = primitives[selectedInstance.component];+ const { isContentEditable } = components[selectedInstance.component];if (isContentEditable === false) return;// Prevents inserting a newline when entering text-editing modeevent.preventDefault();diff --git a/apps/designer/app/canvas/shared/use-track-selected-element.ts b/apps/designer/app/canvas/shared/use-track-selected-element.tsindex 12c4c8e0d4..3428a7d4cf 100644--- a/apps/designer/app/canvas/shared/use-track-selected-element.ts+++ b/apps/designer/app/canvas/shared/use-track-selected-element.ts@@ -1,12 +1,16 @@import { useCallback, useEffect, useRef } from "react";-import { type Instance, publish, useSubscribe } from "@webstudio-is/react-sdk";+import {+ type Instance,+ publish,+ useSubscribe,+ components,+} from "@webstudio-is/react-sdk";import { useSelectedElement, useSelectedInstance } from "./nano-states";import {useRootInstance,useTextEditingInstanceId,} from "~/shared/nano-states";import { findInstanceById } from "~/shared/tree-utils";-import { primitives } from "~/shared/canvas-components";const eventOptions = {passive: true,@@ -83,10 +87,10 @@ export const useTrackSelectedElement = () => {// It's the second click in a double click.if (event.detail === 2) {const component = dataset.component as Instance["component"];- if (component === undefined || component in primitives === false) {+ if (component === undefined || component in components === false) {return;}- const { isInlineOnly, isContentEditable } = primitives[component];+ const { isInlineOnly, isContentEditable } = components[component];if (isContentEditable === false) {return;diff --git a/apps/designer/app/designer/features/sidebar-left/panels/components/component-thumb.tsx b/apps/designer/app/designer/features/sidebar-left/panels/components/component-thumb.tsxindex ddfd8df268..a0e2081305 100644--- a/apps/designer/app/designer/features/sidebar-left/panels/components/component-thumb.tsx+++ b/apps/designer/app/designer/features/sidebar-left/panels/components/component-thumb.tsx@@ -1,6 +1,5 @@-import { type Instance } from "@webstudio-is/react-sdk";+import { type Instance, components } from "@webstudio-is/react-sdk";import { forwardRef, type ElementRef, type ComponentProps } from "react";-import { primitives } from "~/shared/canvas-components";import { Flex, Text, styled } from "~/shared/design-system";const Thumb = styled(Flex, {@@ -31,7 +30,7 @@ export const ComponentThumb = forwardRef<ElementRef<typeof Thumb>,ComponentThumbProps>(({ component, ...rest }, ref) => {- const { Icon, label } = primitives[component];+ const { Icon, label } = components[component];return (<Thumbdirection="column"diff --git a/apps/designer/app/designer/features/sidebar-left/panels/components/components.tsx b/apps/designer/app/designer/features/sidebar-left/panels/components/components.tsxindex 5f11fc13aa..6861f1cc60 100644--- a/apps/designer/app/designer/features/sidebar-left/panels/components/components.tsx+++ b/apps/designer/app/designer/features/sidebar-left/panels/components/components.tsx@@ -1,10 +1,14 @@import { useEffect, useRef, type MouseEventHandler, useCallback } from "react";import { useDrag } from "react-dnd";import { getEmptyImage } from "react-dnd-html5-backend";-import { type Instance, type Publish } from "@webstudio-is/react-sdk";+import {+ type Instance,+ type Publish,+ components,+} from "@webstudio-is/react-sdk";import { Flex } from "~/shared/design-system";import { PlusIcon } from "@webstudio-is/icons";-import { primitives, type DragData } from "~/shared/canvas-components";+import { type DragData } from "~/shared/canvas-components";import { createInstance } from "~/shared/tree-utils";import type { TabName } from "../../types";import { CustomDragLayer } from "./custom-drag-layer";@@ -65,9 +69,9 @@ export const TabContent = ({publish,onSetActiveTab,}: TabContentProps) => {- const components = (- Object.keys(primitives) as Array<Instance["component"]>- ).filter((component) => primitives[component].isInlineOnly === false);+ const componentNames = (+ Object.keys(components) as Array<Instance["component"]>+ ).filter((component) => components[component].isInlineOnly === false);const handleDragChange = useCallback((isDragging: boolean) => {@@ -81,7 +85,7 @@ export const TabContent = ({return (<Flex gap="1" wrap="wrap" css={{ padding: "$1" }}>- {components.map((component: Instance["component"]) => (+ {componentNames.map((component: Instance["component"]) => (<DraggableThumbkey={component}component={component}diff --git a/apps/designer/app/designer/features/workspace/canvas-tools/outline/label.tsx b/apps/designer/app/designer/features/workspace/canvas-tools/outline/label.tsxindex 3541b5d55e..c481b0c5d6 100644--- a/apps/designer/app/designer/features/workspace/canvas-tools/outline/label.tsx+++ b/apps/designer/app/designer/features/workspace/canvas-tools/outline/label.tsx@@ -1,7 +1,6 @@import { useCallback, useState } from "react";import { styled } from "~/shared/design-system";-import { primitives } from "~/shared/canvas-components";-import { type Instance } from "@webstudio-is/react-sdk";+import { type Instance, components } from "@webstudio-is/react-sdk";type LabelPosition = "top" | "inside" | "bottom";type LabelRefCallback = (element: HTMLElement | null) => void;@@ -75,12 +74,11 @@ type LabelProps = {export const Label = ({ component, instanceRect }: LabelProps) => {const [labelRef, position] = useLabelPosition(instanceRect);- const primitive = primitives[component];- const { Icon } = primitive;+ const { Icon, label } = components[component];return (<LabelContainer position={position} ref={labelRef}><Icon width="1em" height="1em" />- {primitive.label}+ {label}</LabelContainer>);};diff --git a/apps/designer/app/designer/shared/inspector/component-info.tsx b/apps/designer/app/designer/shared/inspector/component-info.tsxindex 2bad1ae179..3e0ad64306 100644--- a/apps/designer/app/designer/shared/inspector/component-info.tsx+++ b/apps/designer/app/designer/shared/inspector/component-info.tsx@@ -1,6 +1,6 @@+import { components } from "@webstudio-is/react-sdk";import { Flex, Text } from "~/shared/design-system";import type { SelectedInstanceData } from "~/shared/canvas-components";-import { primitives } from "~/shared/canvas-components";export const ComponentInfo = ({selectedInstanceData,@@ -15,7 +15,7 @@ export const ComponentInfo = ({color: "$colors$slate11",fontWeight: "500",}}- >{`Selected: ${primitives[selectedInstanceData.component].label}`}</Text>+ >{`Selected: ${components[selectedInstanceData.component].label}`}</Text></Flex>);};diff --git a/apps/designer/app/designer/shared/tree/tree.tsx b/apps/designer/app/designer/shared/tree/tree.tsxindex 2e5eabfd8b..41adea19a3 100644--- a/apps/designer/app/designer/shared/tree/tree.tsx+++ b/apps/designer/app/designer/shared/tree/tree.tsx@@ -1,5 +1,5 @@import { useState, useMemo, useEffect } from "react";-import { type Instance } from "@webstudio-is/react-sdk";+import { type Instance, components } from "@webstudio-is/react-sdk";import {Flex,Text,@@ -9,7 +9,6 @@ import {styled,} from "~/shared/design-system";import { TriangleRightIcon, TriangleDownIcon } from "@webstudio-is/icons";-import { primitives } from "~/shared/canvas-components";import noop from "lodash.noop";const openKeyframes = keyframes({@@ -94,7 +93,7 @@ export const Tree = ({animate,]);- const { Icon, label } = primitives[instance.component];+ const { Icon, label } = components[instance.component];const CollapsibleContent = animate? CollapsibleContentAnimated: CollapsibleContentUnanimated;diff --git a/apps/designer/app/shared/canvas-components/index.ts b/apps/designer/app/shared/canvas-components/index.tsindex 31680dcff4..7cfc5f75cd 100644--- a/apps/designer/app/shared/canvas-components/index.ts+++ b/apps/designer/app/shared/canvas-components/index.ts@@ -1,3 +1,2 @@export * from "./instance-data";-export * as primitives from "./primitives";export * from "./draggable";diff --git a/apps/designer/app/shared/canvas-components/primitives/bold.tsx b/apps/designer/app/shared/canvas-components/primitives/bold.tsxdeleted file mode 100644index 209e772b64..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/bold.tsx+++ /dev/null@@ -1,15 +0,0 @@-import { components } from "@webstudio-is/react-sdk";-export { FontBoldIcon as Icon } from "@webstudio-is/icons";--export const canAcceptChild = (): boolean => {- return false;-};--export const isContentEditable = false;--export const label = "Bold Text";--// Can only be created from content editable fields-export const isInlineOnly = true;--export const Component = components.Bold;diff --git a/apps/designer/app/shared/canvas-components/primitives/box.tsx b/apps/designer/app/shared/canvas-components/primitives/box.tsxdeleted file mode 100644index f024cd2244..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/box.tsx+++ /dev/null@@ -1,23 +0,0 @@-import { type Style, components } from "@webstudio-is/react-sdk";-export { SquareIcon as Icon } from "@webstudio-is/icons";--// Webstudio specific default styles for the node type.-export const defaultStyle: Style = {- boxSizing: {- type: "keyword",- value: "border-box",- },-};--export const canAcceptChild = (): boolean => {- return true;-};--export const isContentEditable = false;--// Can only be created from content editable fields-export const isInlineOnly = false;--export const Component = components.Box;--export const label = "Box";diff --git a/apps/designer/app/shared/canvas-components/primitives/button.tsx b/apps/designer/app/shared/canvas-components/primitives/button.tsxdeleted file mode 100644index 9e02733ffb..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/button.tsx+++ /dev/null@@ -1,21 +0,0 @@-import { type Style, components } from "@webstudio-is/react-sdk";-export { ButtonIcon as Icon } from "@webstudio-is/icons";--// Webstudio specific default styles for the node type.-export const defaultStyle: Style = {};--export const canAcceptChild = (): boolean => {- // @todo could accept an icon in the future- return false;-};--export const isContentEditable = true;--// Can only be created from content editable fields-export const isInlineOnly = false;--export const children = ["Button text you can edit"];--export const Component = components.Button;--export const label = "Button";diff --git a/apps/designer/app/shared/canvas-components/primitives/form.tsx b/apps/designer/app/shared/canvas-components/primitives/form.tsxdeleted file mode 100644index ec8aba30d2..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/form.tsx+++ /dev/null@@ -1,28 +0,0 @@-import { type Style, components } from "@webstudio-is/react-sdk";-export { FormIcon as Icon } from "@webstudio-is/icons";--// Webstudio specific default styles for the node type.-export const defaultStyle: Style = {- minHeight: {- type: "unit",- unit: "px",- value: 20,- },- boxSizing: {- type: "keyword",- value: "border-box",- },-};--export const canAcceptChild = (): boolean => {- return true;-};--export const isContentEditable = false;--// Can only be created from content editable fields-export const isInlineOnly = false;--export const Component = components.Form;--export const label = "Form";diff --git a/apps/designer/app/shared/canvas-components/primitives/heading.tsx b/apps/designer/app/shared/canvas-components/primitives/heading.tsxdeleted file mode 100644index 47188bbc2c..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/heading.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { type Style, components } from "@webstudio-is/react-sdk";-export { HeadingIcon as Icon } from "@webstudio-is/icons";--// Webstudio specific default styles for the node type.-export const defaultStyle: Style = {};--export const children = ["Heading you can edit"];--export const canAcceptChild = (): boolean => {- return false;-};--export const isContentEditable = true;--// Can only be created from content editable fields-export const isInlineOnly = false;--export const label = "Heading";--export const Component = components.Heading;diff --git a/apps/designer/app/shared/canvas-components/primitives/index.ts b/apps/designer/app/shared/canvas-components/primitives/index.tsdeleted file mode 100644index 72a5bf6d39..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/index.ts+++ /dev/null@@ -1,10 +0,0 @@-export * as Box from "./box";-export * as TextBlock from "./text-block";-export * as Heading from "./heading";-export * as Paragraph from "./paragraph";-export * as Link from "./link";-export * as Bold from "./bold";-export * as Italic from "./italic";-export * as Button from "./button";-export * as Input from "./input";-export * as Form from "./form";diff --git a/apps/designer/app/shared/canvas-components/primitives/input.tsx b/apps/designer/app/shared/canvas-components/primitives/input.tsxdeleted file mode 100644index bfb79ffb5a..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/input.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { type Style, components } from "@webstudio-is/react-sdk";-export { InputIcon as Icon } from "@webstudio-is/icons";--// Webstudio specific default styles for the node type.-export const defaultStyle: Style = {};--export const canAcceptChild = (): boolean => {- return false;-};--export const isContentEditable = false;--// Can only be created from content editable fields-export const isInlineOnly = false;--export const Component = components.Input;--// @todo we can't render label as a tag using psuedo elements for an input-// we either need to start rendering tags outside or wrap elements which can't have children-export const label = "Input";diff --git a/apps/designer/app/shared/canvas-components/primitives/italic.tsx b/apps/designer/app/shared/canvas-components/primitives/italic.tsxdeleted file mode 100644index 9454fa99dc..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/italic.tsx+++ /dev/null@@ -1,15 +0,0 @@-import { components } from "@webstudio-is/react-sdk";-export { FontBoldIcon as Icon } from "@webstudio-is/icons";--export const canAcceptChild = (): boolean => {- return false;-};--export const isContentEditable = false;--export const label = "Italic Text";--// Can only be created from content editable fields-export const isInlineOnly = true;--export const Component = components.Italic;diff --git a/apps/designer/app/shared/canvas-components/primitives/link.tsx b/apps/designer/app/shared/canvas-components/primitives/link.tsxdeleted file mode 100644index 107c86d556..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/link.tsx+++ /dev/null@@ -1,30 +0,0 @@-import { type Style, components } from "@webstudio-is/react-sdk";-export { Link2Icon as Icon } from "@webstudio-is/icons";--// Webstudio specific default styles for the node type.-export const defaultStyle: Style = {- minHeight: {- type: "unit",- unit: "em",- value: 1,- },- display: {- type: "keyword",- value: "inline-block",- },-};--export const children = ["Link text you can edit"];--export const canAcceptChild = (): boolean => {- return false;-};--export const isContentEditable = true;--// Can only be created from content editable fields-export const isInlineOnly = false;--export const label = "Link";--export const Component = components.Link;diff --git a/apps/designer/app/shared/canvas-components/primitives/paragraph.tsx b/apps/designer/app/shared/canvas-components/primitives/paragraph.tsxdeleted file mode 100644index 9e3c781687..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/paragraph.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { type Style, components } from "@webstudio-is/react-sdk";-export { TextAlignLeftIcon as Icon } from "@webstudio-is/icons";--// Webstudio specific default styles for the node type.-export const defaultStyle: Style = {};--export const children = ["Pragraph you can edit"];--export const canAcceptChild = (): boolean => {- return false;-};--export const isContentEditable = true;--// Can only be created from content editable fields-export const isInlineOnly = false;--export const label = "Paragraph";--export const Component = components.Paragraph;diff --git a/apps/designer/app/shared/canvas-components/primitives/text-block.tsx b/apps/designer/app/shared/canvas-components/primitives/text-block.tsxdeleted file mode 100644index 5714711a65..0000000000--- a/apps/designer/app/shared/canvas-components/primitives/text-block.tsx+++ /dev/null@@ -1,26 +0,0 @@-import { type Style, components } from "@webstudio-is/react-sdk";-export { TextIcon as Icon } from "@webstudio-is/icons";--// Webstudio specific default styles for the node type.-export const defaultStyle: Style = {- minHeight: {- type: "unit",- unit: "em",- value: 1,- },-};--export const children = ["Block of text you can edit"];--export const canAcceptChild = (): boolean => {- return false;-};--export const isContentEditable = true;--// Can only be created from content editable fields-export const isInlineOnly = false;--export const label = "Text Block";--export const Component = components.TextBlock;diff --git a/apps/designer/app/shared/db/tree.server.ts b/apps/designer/app/shared/db/tree.server.tsindex 5275a0f98a..e28d35b2cf 100644--- a/apps/designer/app/shared/db/tree.server.ts+++ b/apps/designer/app/shared/db/tree.server.ts@@ -17,7 +17,7 @@ export const createRootInstance = (breakpoints: Array<Breakpoint>) => {if (defaultBreakpoint === undefined) {throw new Error("A breakpoint with minWidth 0 is required");}- // @todo this should be part of a root primitive in primitives+ // @todo this should be part of a root component in sdkconst rootConfig: Pick<Instance, "component" | "cssRules"> = {component: "Box",cssRules: [diff --git a/apps/designer/app/shared/tree-utils/create-instance.ts b/apps/designer/app/shared/tree-utils/create-instance.tsindex d30cb3e7be..ffec7693a0 100644--- a/apps/designer/app/shared/tree-utils/create-instance.ts+++ b/apps/designer/app/shared/tree-utils/create-instance.ts@@ -1,6 +1,9 @@import ObjectId from "bson-objectid";-import { type CssRule, type Instance } from "@webstudio-is/react-sdk";-import { primitives } from "~/shared/canvas-components";+import {+ type CssRule,+ type Instance,+ components,+} from "@webstudio-is/react-sdk";export const createInstance = ({component,@@ -13,15 +16,15 @@ export const createInstance = ({children?: Instance["children"];cssRules?: Array<CssRule>;}): Instance => {- const primitive = primitives[component];+ const componentMeta = components[component];return {component,id: id === undefined ? ObjectId().toString() : id,cssRules: cssRules ?? [],children:children === undefined- ? "children" in primitive- ? primitive.children+ ? "children" in componentMeta+ ? componentMeta.children: []: children,};diff --git a/apps/designer/app/shared/tree-utils/populate.ts b/apps/designer/app/shared/tree-utils/populate.tsindex 7329f4df0a..42b36eecfa 100644--- a/apps/designer/app/shared/tree-utils/populate.ts+++ b/apps/designer/app/shared/tree-utils/populate.ts@@ -1,5 +1,4 @@-import { type Instance } from "@webstudio-is/react-sdk";-import { primitives } from "~/shared/canvas-components";+import { type Instance, components } from "@webstudio-is/react-sdk";/*** Populate instance with:@@ -8,11 +7,11 @@ import { primitives } from "~/shared/canvas-components";*/export const populateInstance = (instance: Instance): Instance => {const populatedInstance = { ...instance };- const primitive = primitives[instance.component];- if (primitive !== undefined && "defaultStyle" in primitive) {+ const componentMeta = components[instance.component];+ if (componentMeta !== undefined && "defaultStyle" in componentMeta) {const cssRule = {breakpoint: "",- style: primitive.defaultStyle,+ style: componentMeta.defaultStyle,};populatedInstance.cssRules.push(cssRule);}diff --git a/packages/react-sdk/package.json b/packages/react-sdk/package.jsonindex 6c37bddc81..60a718a910 100644--- a/packages/react-sdk/package.json+++ b/packages/react-sdk/package.json@@ -8,7 +8,7 @@"dev": "tsup src/index.ts --format esm,cjs --watch --out-dir=lib","build": "yarn build:mdn-data && yarn build:args && yarn build:lib","build:mdn-data": "node --experimental-loader esbuild-node-loader ./bin/mdn-data.ts ./src/css",- "build:args": "node --experimental-loader esbuild-node-loader ./bin/generate-arg-types.ts './src/components/*.tsx !./src/**/*.stories.tsx'",+ "build:args": "node --experimental-loader esbuild-node-loader ./bin/generate-arg-types.ts './src/components/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx'","typecheck": "tsc --noEmit","build:lib": "rm -fr lib && tsc","test": "jest",diff --git a/packages/react-sdk/src/components/bold.ws.tsx b/packages/react-sdk/src/components/bold.ws.tsxnew file mode 100644index 0000000000..7f8d429b90--- /dev/null+++ b/packages/react-sdk/src/components/bold.ws.tsx@@ -0,0 +1,12 @@+import { FontBoldIcon } from "@webstudio-is/icons";+import type { WsComponentMeta } from "./component-type";+import { Bold } from "./bold";++export default {+ Icon: FontBoldIcon,+ Component: Bold,+ canAcceptChild: () => false,+ isContentEditable: false,+ label: "Bold Text",+ isInlineOnly: true,+} as WsComponentMeta<typeof Bold>;diff --git a/packages/react-sdk/src/components/box.ws.ts b/packages/react-sdk/src/components/box.ws.tsnew file mode 100644index 0000000000..f0d2a62733--- /dev/null+++ b/packages/react-sdk/src/components/box.ws.ts@@ -0,0 +1,19 @@+import { SquareIcon } from "@webstudio-is/icons";+import type { WsComponentMeta } from "./component-type";+import { Box } from "./box";++const defaultStyle = {+ boxSizing: {+ type: "keyword",+ value: "border-box",+ },+};++export default {+ Icon: SquareIcon,+ Component: Box,+ defaultStyle,+ canAcceptChild: () => true,+ isContentEditable: false,+ label: "Box",+} as WsComponentMeta<typeof Box>;diff --git a/packages/react-sdk/src/components/button.tsx b/packages/react-sdk/src/components/button.tsxindex 46f9c14f79..73b611d339 100644--- a/packages/react-sdk/src/components/button.tsx+++ b/packages/react-sdk/src/components/button.tsx@@ -2,7 +2,7 @@ import React, { forwardRef, type ElementRef, type ComponentProps } from "react";const defaultTag = "button";-export type ButtonProps = ComponentProps<typeof defaultTag>;+type ButtonProps = ComponentProps<typeof defaultTag>;export const Button = forwardRef<ElementRef<typeof defaultTag>, ButtonProps>((props, ref) => <button {...props} ref={ref} />diff --git a/packages/react-sdk/src/components/button.ws.tsx b/packages/react-sdk/src/components/button.ws.tsxnew file mode 100644index 0000000000..36bb96586a--- /dev/null+++ b/packages/react-sdk/src/components/button.ws.tsx@@ -0,0 +1,13 @@+import { ButtonIcon } from "@webstudio-is/icons";+import type { WsComponentMeta } from "./component-type";+import { Button } from "./button";++export default {+ Icon: ButtonIcon,+ Component: Button,+ canAcceptChild: () => false,+ isContentEditable: true,+ isInlineOnly: false,+ label: "Button",+ children: ["Button text you can edit"],+} as WsComponentMeta<typeof Button>;diff --git a/packages/react-sdk/src/components/component-type.ts b/packages/react-sdk/src/components/component-type.tsnew file mode 100644index 0000000000..c02fa97ce1--- /dev/null+++ b/packages/react-sdk/src/components/component-type.ts@@ -0,0 +1,12 @@+import type { Style } from "../css";++export type WsComponentMeta<ComponentType> = {+ Component: ComponentType;+ Icon: ComponentType;+ defaultStyle: Style;+ canAcceptChild: () => boolean;+ isContentEditable: boolean;+ isInlineOnly: boolean;+ label: string;+ children: Array<string>;+};diff --git a/packages/react-sdk/src/components/form.ws.tsx b/packages/react-sdk/src/components/form.ws.tsxnew file mode 100644index 0000000000..bb1c7fac4a--- /dev/null+++ b/packages/react-sdk/src/components/form.ws.tsx@@ -0,0 +1,25 @@+import { FormIcon } from "@webstudio-is/icons";+import type { WsComponentMeta } from "./component-type";+import { Form } from "./form";++const defaultStyle = {+ minHeight: {+ type: "unit",+ unit: "px",+ value: 20,+ },+ boxSizing: {+ type: "keyword",+ value: "border-box",+ },+};++export default {+ Icon: FormIcon,+ Component: Form,+ defaultStyle,+ canAcceptChild: () => true,+ isContentEditable: false,+ isInlineOnly: false,+ label: "Form",+} as WsComponentMeta<typeof Form>;diff --git a/packages/react-sdk/src/components/heading.ws.tsx b/packages/react-sdk/src/components/heading.ws.tsxnew file mode 100644index 0000000000..d4baa43cb5--- /dev/null+++ b/packages/react-sdk/src/components/heading.ws.tsx@@ -0,0 +1,18 @@+import React, {+ forwardRef,+ createElement,+ type ElementRef,+ type ComponentProps,+} from "react";+import { HeadingIcon } from "@webstudio-is/icons";+import type { WsComponentMeta } from "./component-type";+import { Heading } from "./heading";++export default {+ Icon: HeadingIcon,+ Component: Heading,+ canAcceptChild: () => false,+ isContentEditable: true,+ isInlineOnly: false,+ label: "Heading",+} as WsComponentMeta<typeof Heading>;diff --git a/packages/react-sdk/src/components/index.ts b/packages/react-sdk/src/components/index.tsindex 48ef592b22..87054a080b 100644--- a/packages/react-sdk/src/components/index.ts+++ b/packages/react-sdk/src/components/index.ts@@ -1,10 +1,10 @@-export * from "./box";-export * from "./text-block";-export * from "./heading";-export * from "./paragraph";-export * from "./link";-export * from "./bold";-export * from "./italic";-export * from "./button";-export * from "./input";-export * from "./form";+export { default as Box } from "./box.ws";+export { default as TextBlock } from "./text-block.ws";+export { default as Heading } from "./heading.ws";+export { default as Paragraph } from "./paragraph.ws";+export { default as Link } from "./link.ws";+export { default as Bold } from "./bold.ws";+export { default as Italic } from "./italic.ws";+export { default as Button } from "./button.ws";+export { default as Input } from "./input.ws";+export { default as Form } from "./form.ws";diff --git a/packages/react-sdk/src/components/input.ws.tsx b/packages/react-sdk/src/components/input.ws.tsxnew file mode 100644index 0000000000..2f2509e102--- /dev/null+++ b/packages/react-sdk/src/components/input.ws.tsx@@ -0,0 +1,13 @@+import React, { forwardRef, type ElementRef, type ComponentProps } from "react";+import { InputIcon } from "@webstudio-is/icons";+import type { WsComponentMeta } from "./component-type";+import { Input } from "./input";++export default {+ Icon: InputIcon,+ Component: Input,+ canAcceptChild: () => false,+ isContentEditable: false,+ isInlineOnly: false,+ label: "Input",+} as WsComponentMeta<typeof Input>;diff --git a/packages/react-sdk/src/components/italic.ws.tsx b/packages/react-sdk/src/components/italic.ws.tsxnew file mode 100644index 0000000000..5cf45dfa5f--- /dev/null+++ b/packages/react-sdk/src/components/italic.ws.tsx@@ -0,0 +1,12 @@+import { FontBoldIcon } from "@webstudio-is/icons";+import type { WsComponentMeta } from "./component-type";+import { Italic } from "./italic";++export default {+ Icon: FontBoldIcon,+ Component: Italic,+ canAcceptChild: () => false,+ isContentEditable: false,+ isInlineOnly: true,+ label: "Italic Text",+} as WsComponentMeta<typeof Italic>;diff --git a/packages/react-sdk/src/components/link.tsx b/packages/react-sdk/src/components/link.tsxindex 9ab79b80e1..66d43b59b7 100644--- a/packages/react-sdk/src/components/link.tsx+++ b/packages/react-sdk/src/components/link.tsx@@ -2,7 +2,7 @@ import React, { forwardRef, type ElementRef, type ComponentProps } from "react";const defaultTag = "a";-export type LinkProps = Omit<ComponentProps<typeof defaultTag>, "href"> & {+type LinkProps = Omit<ComponentProps<typeof defaultTag>, "href"> & {href?: string;};diff --git a/packages/react-sdk/src/components/link.ws.tsx b/packages/react-sdk/src/components/link.ws.tsxnew file mode 100644index 0000000000..f202690eb0--- /dev/null+++ b/packages/react-sdk/src/components/link.ws.tsx@@ -0,0 +1,26 @@+import { Link2Icon } from "@webstudio-is/icons";+import { Link } from "./link";+import type { WsComponentMeta } from "./component-type";++const defaultStyle = {+ minHeight: {+ type: "unit",+ unit: "em",+ value: 1,+ },+ display: {+ type: "keyword",+ value: "inline-block",+ },+};++export default {+ Icon: Link2Icon,+ Component: Link,+ defaultStyle,+ canAcceptChild: () => false,+ isContentEditable: true,+ isInlineOnly: false,+ label: "Link",+ children: ["Link text you can edit"],+} as WsComponentMeta<typeof Link>;diff --git a/packages/react-sdk/src/components/paragraph.ws.tsx b/packages/react-sdk/src/components/paragraph.ws.tsxnew file mode 100644index 0000000000..c2e9210163--- /dev/null+++ b/packages/react-sdk/src/components/paragraph.ws.tsx@@ -0,0 +1,13 @@+import { TextAlignLeftIcon } from "@webstudio-is/icons";+import type { WsComponentMeta } from "./component-type";+import { Paragraph } from "./paragraph";++export default {+ Icon: TextAlignLeftIcon,+ Component: Paragraph,+ canAcceptChild: () => false,+ isContentEditable: true,+ isInlineOnly: false,+ label: "Paragraph",+ children: ["Pragraph you can edit"],+} as WsComponentMeta<typeof Paragraph>;diff --git a/packages/react-sdk/src/components/text-block.ws.tsx b/packages/react-sdk/src/components/text-block.ws.tsxnew file mode 100644index 0000000000..f09fad9f6e--- /dev/null+++ b/packages/react-sdk/src/components/text-block.ws.tsx@@ -0,0 +1,22 @@+import { TextIcon } from "@webstudio-is/icons";+import type { WsComponentMeta } from "./component-type";+import { TextBlock } from "./text-block";++const defaultStyle = {+ minHeight: {+ type: "unit",+ unit: "em",+ value: 1,+ },+};++export default {+ Icon: TextIcon,+ Component: TextBlock,+ defaultStyle,+ canAcceptChild: () => false,+ isContentEditable: true,+ isInlineOnly: false,+ label: "Text Block",+ children: ["Block of text you can edit"],+} as WsComponentMeta<typeof TextBlock>;diff --git a/packages/react-sdk/src/tree/wrapper-component.tsx b/packages/react-sdk/src/tree/wrapper-component.tsxindex 317195fc4e..dc01081dc9 100644--- a/packages/react-sdk/src/tree/wrapper-component.tsx+++ b/packages/react-sdk/src/tree/wrapper-component.tsx@@ -36,12 +36,12 @@ export type WrapperComponentProps = {export const WrapperComponent = ({instance,css,- onChangeChildren, // prevent it from passing to primitives+ onChangeChildren, // prevent it from passing to sdk componentchildren,...rest}: WrapperComponentProps) => {const className = useMemo(() => createCss(css)(), [css]);- const Component = components[instance.component];+ const { Component } = components[instance.component];const userProps = useUserProps(instance.id);return (<Component {...userProps} {...rest} id={instance.id} className={className}>