@webstudio-is/sdk-components-react-remix 0.68.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/LICENSE +21 -0
- package/README.md +4 -0
- package/lib/__generated__/form.props.js +411 -0
- package/lib/__generated__/link-block.props.js +432 -0
- package/lib/__generated__/link.props.js +432 -0
- package/lib/__generated__/rich-text-link.props.js +432 -0
- package/lib/cjs/__generated__/form.props.js +431 -0
- package/lib/cjs/__generated__/link-block.props.js +452 -0
- package/lib/cjs/__generated__/link.props.js +452 -0
- package/lib/cjs/__generated__/rich-text-link.props.js +452 -0
- package/lib/cjs/components.js +30 -0
- package/lib/cjs/form.js +81 -0
- package/lib/cjs/form.ws.js +110 -0
- package/lib/cjs/link-block.js +26 -0
- package/lib/cjs/link.js +26 -0
- package/lib/cjs/metas.js +24 -0
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/props.js +24 -0
- package/lib/cjs/rich-text-link.js +26 -0
- package/lib/cjs/shared/remix-link.js +42 -0
- package/lib/components.js +10 -0
- package/lib/form.js +65 -0
- package/lib/form.ws.js +90 -0
- package/lib/link-block.js +6 -0
- package/lib/link.js +6 -0
- package/lib/metas.js +4 -0
- package/lib/props.js +4 -0
- package/lib/rich-text-link.js +6 -0
- package/lib/shared/remix-link.js +25 -0
- package/lib/types/__generated__/form.props.d.ts +2 -0
- package/lib/types/__generated__/link-block.props.d.ts +2 -0
- package/lib/types/__generated__/link.props.d.ts +2 -0
- package/lib/types/__generated__/rich-text-link.props.d.ts +2 -0
- package/lib/types/components.d.ts +4 -0
- package/lib/types/form.d.ts +5 -0
- package/lib/types/form.ws.d.ts +3 -0
- package/lib/types/link-block.d.ts +6 -0
- package/lib/types/link.d.ts +6 -0
- package/lib/types/metas.d.ts +1 -0
- package/lib/types/props.d.ts +1 -0
- package/lib/types/rich-text-link.d.ts +6 -0
- package/lib/types/shared/remix-link.d.ts +10 -0
- package/package.json +63 -0
- package/src/__generated__/form.props.ts +456 -0
- package/src/__generated__/link-block.props.ts +477 -0
- package/src/__generated__/link.props.ts +477 -0
- package/src/__generated__/rich-text-link.props.ts +477 -0
- package/src/components.ts +4 -0
- package/src/form.tsx +111 -0
- package/src/form.ws.tsx +95 -0
- package/src/link-block.tsx +4 -0
- package/src/link.tsx +4 -0
- package/src/metas.ts +1 -0
- package/src/props.ts +1 -0
- package/src/rich-text-link.tsx +4 -0
- package/src/shared/remix-link.tsx +30 -0
package/src/metas.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { meta as Form } from "./form.ws";
|
package/src/props.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { propsMeta as Form } from "./form.ws";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { forwardRef, type ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { NavLink as RemixLink } from "@remix-run/react";
|
|
3
|
+
import {
|
|
4
|
+
type Link,
|
|
5
|
+
usePropUrl,
|
|
6
|
+
getInstanceIdFromComponentProps,
|
|
7
|
+
} from "@webstudio-is/react-sdk";
|
|
8
|
+
|
|
9
|
+
type LinkComponent = typeof Link;
|
|
10
|
+
type LinkProps = ComponentPropsWithoutRef<LinkComponent>;
|
|
11
|
+
|
|
12
|
+
export const wrapLinkComponent = (BaseLink: LinkComponent) => {
|
|
13
|
+
const Component: LinkComponent = forwardRef((props: LinkProps, ref) => {
|
|
14
|
+
const href = usePropUrl(getInstanceIdFromComponentProps(props), "href");
|
|
15
|
+
|
|
16
|
+
if (href?.type === "page") {
|
|
17
|
+
let to = href.page.path === "" ? "/" : href.page.path;
|
|
18
|
+
if (href.hash !== undefined) {
|
|
19
|
+
to += `#${href.hash}`;
|
|
20
|
+
}
|
|
21
|
+
return <RemixLink {...props} to={to} ref={ref} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return <BaseLink {...props} ref={ref} />;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
Component.displayName = BaseLink.displayName;
|
|
28
|
+
|
|
29
|
+
return Component;
|
|
30
|
+
};
|