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
Split props for base and remix links (#1711)
Bogdan Chadkind92b628d23bc
diff --git a/packages/sdk-components-react-remix/src/__generated__/link-block.props.ts b/packages/sdk-components-react-remix/src/__generated__/link-block.props.tsindex d8a7b45ab5..3c0534a962 100644--- a/packages/sdk-components-react-remix/src/__generated__/link-block.props.ts+++ b/packages/sdk-components-react-remix/src/__generated__/link-block.props.ts@@ -4,14 +4,8 @@ export const props: Record<string, PropMeta> = {slot: { required: false, control: "text", type: "string" },style: { required: false, control: "text", type: "string" },title: { required: false, control: "text", type: "string" },- href: { required: false, control: "text", type: "string" },- target: {- required: false,- control: "select",- type: "string",- options: ["_self", "_blank", "_parent", "_top"],- },download: { required: false, control: "text", type: "string" },+ href: { required: false, control: "text", type: "string" },hrefLang: { required: false, control: "text", type: "string" },media: { required: false, control: "text", type: "string" },ping: { required: false, control: "text", type: "string" },@@ -468,10 +462,19 @@ export const props: Record<string, PropMeta> = {control: "text",type: "string",},+ target: {+ required: false,+ control: "select",+ type: "string",+ options: ["_self", "_blank", "_parent", "_top"],+ },prefetch: {required: false,control: "radio",type: "string",options: ["none", "intent", "render"],},+ reloadDocument: { required: false, control: "boolean", type: "boolean" },+ replace: { required: false, control: "boolean", type: "boolean" },+ preventScrollReset: { required: false, control: "boolean", type: "boolean" },};diff --git a/packages/sdk-components-react-remix/src/__generated__/link.props.ts b/packages/sdk-components-react-remix/src/__generated__/link.props.tsindex d8a7b45ab5..3c0534a962 100644--- a/packages/sdk-components-react-remix/src/__generated__/link.props.ts+++ b/packages/sdk-components-react-remix/src/__generated__/link.props.ts@@ -4,14 +4,8 @@ export const props: Record<string, PropMeta> = {slot: { required: false, control: "text", type: "string" },style: { required: false, control: "text", type: "string" },title: { required: false, control: "text", type: "string" },- href: { required: false, control: "text", type: "string" },- target: {- required: false,- control: "select",- type: "string",- options: ["_self", "_blank", "_parent", "_top"],- },download: { required: false, control: "text", type: "string" },+ href: { required: false, control: "text", type: "string" },hrefLang: { required: false, control: "text", type: "string" },media: { required: false, control: "text", type: "string" },ping: { required: false, control: "text", type: "string" },@@ -468,10 +462,19 @@ export const props: Record<string, PropMeta> = {control: "text",type: "string",},+ target: {+ required: false,+ control: "select",+ type: "string",+ options: ["_self", "_blank", "_parent", "_top"],+ },prefetch: {required: false,control: "radio",type: "string",options: ["none", "intent", "render"],},+ reloadDocument: { required: false, control: "boolean", type: "boolean" },+ replace: { required: false, control: "boolean", type: "boolean" },+ preventScrollReset: { required: false, control: "boolean", type: "boolean" },};diff --git a/packages/sdk-components-react-remix/src/__generated__/rich-text-link.props.ts b/packages/sdk-components-react-remix/src/__generated__/rich-text-link.props.tsindex d8a7b45ab5..3c0534a962 100644--- a/packages/sdk-components-react-remix/src/__generated__/rich-text-link.props.ts+++ b/packages/sdk-components-react-remix/src/__generated__/rich-text-link.props.ts@@ -4,14 +4,8 @@ export const props: Record<string, PropMeta> = {slot: { required: false, control: "text", type: "string" },style: { required: false, control: "text", type: "string" },title: { required: false, control: "text", type: "string" },- href: { required: false, control: "text", type: "string" },- target: {- required: false,- control: "select",- type: "string",- options: ["_self", "_blank", "_parent", "_top"],- },download: { required: false, control: "text", type: "string" },+ href: { required: false, control: "text", type: "string" },hrefLang: { required: false, control: "text", type: "string" },media: { required: false, control: "text", type: "string" },ping: { required: false, control: "text", type: "string" },@@ -468,10 +462,19 @@ export const props: Record<string, PropMeta> = {control: "text",type: "string",},+ target: {+ required: false,+ control: "select",+ type: "string",+ options: ["_self", "_blank", "_parent", "_top"],+ },prefetch: {required: false,control: "radio",type: "string",options: ["none", "intent", "render"],},+ reloadDocument: { required: false, control: "boolean", type: "boolean" },+ replace: { required: false, control: "boolean", type: "boolean" },+ preventScrollReset: { required: false, control: "boolean", type: "boolean" },};diff --git a/packages/sdk-components-react-remix/src/link-block.ws.tsx b/packages/sdk-components-react-remix/src/link-block.ws.tsxnew file mode 100644index 0000000000..412da4091e--- /dev/null+++ b/packages/sdk-components-react-remix/src/link-block.ws.tsx@@ -0,0 +1,6 @@+import type { WsComponentPropsMeta } from "@webstudio-is/react-sdk";+import { propsMeta as linkPropsMeta } from "./link.ws";++export { LinkBlock as meta } from "@webstudio-is/sdk-components-react/metas";++export const propsMeta: WsComponentPropsMeta = linkPropsMeta;diff --git a/packages/sdk-components-react-remix/src/link.ws.ts b/packages/sdk-components-react-remix/src/link.ws.tsnew file mode 100644index 0000000000..5ea4b29fd5--- /dev/null+++ b/packages/sdk-components-react-remix/src/link.ws.ts@@ -0,0 +1,16 @@+import type { WsComponentPropsMeta } from "@webstudio-is/react-sdk";+import { props } from "./__generated__/link.props";++export { Link as meta } from "@webstudio-is/sdk-components-react/metas";++export const propsMeta: WsComponentPropsMeta = {+ props: {+ ...props,+ href: {+ type: "string",+ control: "url",+ required: false,+ },+ },+ initialProps: ["href", "target", "prefetch"],+};diff --git a/packages/sdk-components-react-remix/src/props.ts b/packages/sdk-components-react-remix/src/props.tsindex 34fe4253cf..a27f60c149 100644--- a/packages/sdk-components-react-remix/src/props.ts+++ b/packages/sdk-components-react-remix/src/props.ts@@ -1 +1,4 @@export { propsMeta as Form } from "./form.ws";+export { propsMeta as Link } from "./link.ws";+export { propsMeta as LinkBlock } from "./link-block.ws";+export { propsMeta as RichTextLink } from "./rich-text-link.ws";diff --git a/packages/sdk-components-react-remix/src/rich-text-link.ws.tsx b/packages/sdk-components-react-remix/src/rich-text-link.ws.tsxnew file mode 100644index 0000000000..3c312880ca--- /dev/null+++ b/packages/sdk-components-react-remix/src/rich-text-link.ws.tsx@@ -0,0 +1,6 @@+import type { WsComponentPropsMeta } from "@webstudio-is/react-sdk";+import { propsMeta as linkPropsMeta } from "./link.ws";++export { RichTextLink as meta } from "@webstudio-is/sdk-components-react/metas";++export const propsMeta: WsComponentPropsMeta = linkPropsMeta;diff --git a/packages/sdk-components-react-remix/src/shared/remix-link.tsx b/packages/sdk-components-react-remix/src/shared/remix-link.tsxindex c2c8e5ea04..32cdf1488a 100644--- a/packages/sdk-components-react-remix/src/shared/remix-link.tsx+++ b/packages/sdk-components-react-remix/src/shared/remix-link.tsx@@ -6,11 +6,19 @@ import {} from "@webstudio-is/react-sdk";import type { Link } from "@webstudio-is/sdk-components-react";-type LinkComponent = typeof Link;-type LinkProps = ComponentPropsWithoutRef<LinkComponent>;+type Props = Omit<ComponentPropsWithoutRef<typeof Link>, "target"> & {+ // override (string & {}) in target to generate keywords+ target?: "_self" | "_blank" | "_parent" | "_top";-export const wrapLinkComponent = (BaseLink: LinkComponent) => {- const Component: LinkComponent = forwardRef((props: LinkProps, ref) => {+ // useful remix props+ prefetch?: "intent" | "render" | "none";+ reloadDocument?: boolean;+ replace?: boolean;+ preventScrollReset?: boolean;+};++export const wrapLinkComponent = (BaseLink: typeof Link) => {+ const Component = forwardRef<HTMLAnchorElement, Props>((props, ref) => {const href = usePropUrl(getInstanceIdFromComponentProps(props), "href");if (href?.type === "page") {diff --git a/packages/sdk-components-react/src/__generated__/link-block.props.ts b/packages/sdk-components-react/src/__generated__/link-block.props.tsindex d8a7b45ab5..7d27fd7be7 100644--- a/packages/sdk-components-react/src/__generated__/link-block.props.ts+++ b/packages/sdk-components-react/src/__generated__/link-block.props.ts@@ -4,7 +4,6 @@ export const props: Record<string, PropMeta> = {slot: { required: false, control: "text", type: "string" },style: { required: false, control: "text", type: "string" },title: { required: false, control: "text", type: "string" },- href: { required: false, control: "text", type: "string" },target: {required: false,control: "select",@@ -12,6 +11,7 @@ export const props: Record<string, PropMeta> = {options: ["_self", "_blank", "_parent", "_top"],},download: { required: false, control: "text", type: "string" },+ href: { required: false, control: "text", type: "string" },hrefLang: { required: false, control: "text", type: "string" },media: { required: false, control: "text", type: "string" },ping: { required: false, control: "text", type: "string" },@@ -468,10 +468,4 @@ export const props: Record<string, PropMeta> = {control: "text",type: "string",},- prefetch: {- required: false,- control: "radio",- type: "string",- options: ["none", "intent", "render"],- },};diff --git a/packages/sdk-components-react/src/__generated__/link.props.ts b/packages/sdk-components-react/src/__generated__/link.props.tsindex d8a7b45ab5..7d27fd7be7 100644--- a/packages/sdk-components-react/src/__generated__/link.props.ts+++ b/packages/sdk-components-react/src/__generated__/link.props.ts@@ -4,7 +4,6 @@ export const props: Record<string, PropMeta> = {slot: { required: false, control: "text", type: "string" },style: { required: false, control: "text", type: "string" },title: { required: false, control: "text", type: "string" },- href: { required: false, control: "text", type: "string" },target: {required: false,control: "select",@@ -12,6 +11,7 @@ export const props: Record<string, PropMeta> = {options: ["_self", "_blank", "_parent", "_top"],},download: { required: false, control: "text", type: "string" },+ href: { required: false, control: "text", type: "string" },hrefLang: { required: false, control: "text", type: "string" },media: { required: false, control: "text", type: "string" },ping: { required: false, control: "text", type: "string" },@@ -468,10 +468,4 @@ export const props: Record<string, PropMeta> = {control: "text",type: "string",},- prefetch: {- required: false,- control: "radio",- type: "string",- options: ["none", "intent", "render"],- },};diff --git a/packages/sdk-components-react/src/__generated__/rich-text-link.props.ts b/packages/sdk-components-react/src/__generated__/rich-text-link.props.tsindex d8a7b45ab5..7d27fd7be7 100644--- a/packages/sdk-components-react/src/__generated__/rich-text-link.props.ts+++ b/packages/sdk-components-react/src/__generated__/rich-text-link.props.ts@@ -4,7 +4,6 @@ export const props: Record<string, PropMeta> = {slot: { required: false, control: "text", type: "string" },style: { required: false, control: "text", type: "string" },title: { required: false, control: "text", type: "string" },- href: { required: false, control: "text", type: "string" },target: {required: false,control: "select",@@ -12,6 +11,7 @@ export const props: Record<string, PropMeta> = {options: ["_self", "_blank", "_parent", "_top"],},download: { required: false, control: "text", type: "string" },+ href: { required: false, control: "text", type: "string" },hrefLang: { required: false, control: "text", type: "string" },media: { required: false, control: "text", type: "string" },ping: { required: false, control: "text", type: "string" },@@ -468,10 +468,4 @@ export const props: Record<string, PropMeta> = {control: "text",type: "string",},- prefetch: {- required: false,- control: "radio",- type: "string",- options: ["none", "intent", "render"],- },};diff --git a/packages/sdk-components-react/src/link-block.ws.tsx b/packages/sdk-components-react/src/link-block.ws.tsxindex 224483d92c..e6e0b41574 100644--- a/packages/sdk-components-react/src/link-block.ws.tsx+++ b/packages/sdk-components-react/src/link-block.ws.tsx@@ -5,7 +5,6 @@ import type {WsComponentPropsMeta,} from "@webstudio-is/react-sdk";import { a } from "@webstudio-is/react-sdk/css-normalize";-import { props } from "./__generated__/link-block.props";import { meta as linkMeta, propsMeta as linkPropsMeta } from "./link.ws";import type { defaultTag } from "./link-block";@@ -29,10 +28,4 @@ export const meta: WsComponentMeta = {order: 2,};-export const propsMeta: WsComponentPropsMeta = {- props: {- ...props,- href: linkPropsMeta.props.href,- },- initialProps: linkPropsMeta.initialProps,-};+export const propsMeta: WsComponentPropsMeta = linkPropsMeta;diff --git a/packages/sdk-components-react/src/link.tsx b/packages/sdk-components-react/src/link.tsxindex 991ec4d1fe..ffe80fdb3a 100644--- a/packages/sdk-components-react/src/link.tsx+++ b/packages/sdk-components-react/src/link.tsx@@ -7,14 +7,9 @@ import {export const defaultTag = "a";-// @todo props that come from remix link, shouldn't be here at all-// - prefetch should be only on remix component and it already is-// - props meta should be generated from Remix link-// - changing this requires update in app/canvas/custom-components/link.tsx-type Props = Omit<ComponentProps<"a">, "href" | "target"> & {- href?: string;+type Props = Omit<ComponentProps<"a">, "target"> & {+ // override (string & {}) in target to generate keywordstarget?: "_self" | "_blank" | "_parent" | "_top";- prefetch?: "none" | "intent" | "render";};export const Link = forwardRef<HTMLAnchorElement, Props>((props, ref) => {diff --git a/packages/sdk-components-react/src/link.ws.tsx b/packages/sdk-components-react/src/link.ws.tsxindex d353da57fa..4f2fdea347 100644--- a/packages/sdk-components-react/src/link.ws.tsx+++ b/packages/sdk-components-react/src/link.ws.tsx@@ -60,5 +60,5 @@ export const propsMeta: WsComponentPropsMeta = {required: false,},},- initialProps: ["href", "target", "prefetch"],+ initialProps: ["href", "target"],};diff --git a/packages/sdk-components-react/src/rich-text-link.ws.tsx b/packages/sdk-components-react/src/rich-text-link.ws.tsxindex 916bcf2920..b9cfa575a5 100644--- a/packages/sdk-components-react/src/rich-text-link.ws.tsx+++ b/packages/sdk-components-react/src/rich-text-link.ws.tsx@@ -2,7 +2,6 @@ import type {WsComponentMeta,WsComponentPropsMeta,} from "@webstudio-is/react-sdk";-import { props } from "./__generated__/rich-text-link.props";import { meta as linkMeta, propsMeta as linkPropsMeta } from "./link.ws";const { category, ...linkMetaRest } = linkMeta;@@ -13,10 +12,4 @@ export const meta: WsComponentMeta = {template: [],};-export const propsMeta: WsComponentPropsMeta = {- initialProps: linkPropsMeta.initialProps,- props: {- ...props,- href: linkPropsMeta.props.href,- },-};+export const propsMeta: WsComponentPropsMeta = linkPropsMeta;