@webstudio-is/sdk-components-react-remix 0.95.0 → 0.97.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/form.ws.js DELETED
@@ -1,136 +0,0 @@
1
- "use strict";
2
- import { FormIcon } from "@webstudio-is/icons/svg";
3
- import { form } from "@webstudio-is/react-sdk/css-normalize";
4
- import {
5
- showAttribute
6
- } from "@webstudio-is/react-sdk";
7
- import { props } from "./__generated__/form.props";
8
- const presetStyle = {
9
- form: [
10
- ...form,
11
- { property: "minHeight", value: { type: "unit", unit: "px", value: 20 } }
12
- ]
13
- };
14
- export const meta = {
15
- category: "forms",
16
- type: "container",
17
- invalidAncestors: ["Form"],
18
- label: "Form",
19
- description: "Collect information from your users using validation rules.",
20
- icon: FormIcon,
21
- presetStyle,
22
- order: 0,
23
- states: [
24
- { selector: "[data-state=error]", label: "Error" },
25
- { selector: "[data-state=success]", label: "Success" }
26
- ],
27
- template: [
28
- {
29
- type: "instance",
30
- component: "Form",
31
- dataSources: {
32
- formState: { type: "variable", initialValue: "initial" }
33
- },
34
- props: [
35
- {
36
- type: "dataSource",
37
- name: "state",
38
- dataSourceName: "formState"
39
- }
40
- ],
41
- children: [
42
- {
43
- type: "instance",
44
- label: "Form Content",
45
- component: "Box",
46
- dataSources: {
47
- formInitial: {
48
- type: "expression",
49
- code: `formState === 'initial' || formState === 'error'`
50
- }
51
- },
52
- props: [
53
- {
54
- type: "dataSource",
55
- name: showAttribute,
56
- dataSourceName: "formInitial"
57
- }
58
- ],
59
- children: [
60
- {
61
- type: "instance",
62
- component: "Label",
63
- children: [{ type: "text", value: "Name" }]
64
- },
65
- {
66
- type: "instance",
67
- component: "Input",
68
- props: [{ type: "string", name: "name", value: "name" }],
69
- children: []
70
- },
71
- {
72
- type: "instance",
73
- component: "Label",
74
- children: [{ type: "text", value: "Email" }]
75
- },
76
- {
77
- type: "instance",
78
- component: "Input",
79
- props: [{ type: "string", name: "name", value: "email" }],
80
- children: []
81
- },
82
- {
83
- type: "instance",
84
- component: "Button",
85
- children: [{ type: "text", value: "Submit" }]
86
- }
87
- ]
88
- },
89
- {
90
- type: "instance",
91
- label: "Success Message",
92
- component: "Box",
93
- dataSources: {
94
- formSuccess: {
95
- type: "expression",
96
- code: `formState === 'success'`
97
- }
98
- },
99
- props: [
100
- {
101
- type: "dataSource",
102
- name: showAttribute,
103
- dataSourceName: "formSuccess"
104
- }
105
- ],
106
- children: [
107
- { type: "text", value: "Thank you for getting in touch!" }
108
- ]
109
- },
110
- {
111
- type: "instance",
112
- label: "Error Message",
113
- component: "Box",
114
- dataSources: {
115
- formError: {
116
- type: "expression",
117
- code: `formState === 'error'`
118
- }
119
- },
120
- props: [
121
- {
122
- type: "dataSource",
123
- name: showAttribute,
124
- dataSourceName: "formError"
125
- }
126
- ],
127
- children: [{ type: "text", value: "Sorry, something went wrong." }]
128
- }
129
- ]
130
- }
131
- ]
132
- };
133
- export const propsMeta = {
134
- props,
135
- initialProps: ["id", "state", "action"]
136
- };
package/lib/link.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- import { Link as BaseLink } from "@webstudio-is/sdk-components-react";
3
- import { wrapLinkComponent } from "./shared/remix-link";
4
- export const Link = wrapLinkComponent(BaseLink);
package/lib/link.ws.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- import { props } from "./__generated__/link.props";
3
- export { Link as meta } from "@webstudio-is/sdk-components-react/metas";
4
- export const propsMeta = {
5
- props: {
6
- ...props,
7
- href: {
8
- type: "string",
9
- control: "url",
10
- required: false
11
- }
12
- },
13
- initialProps: ["id", "href", "target", "prefetch"]
14
- };
@@ -1,4 +0,0 @@
1
- "use strict";
2
- import { RichTextLink as BaseLink } from "@webstudio-is/sdk-components-react";
3
- import { wrapLinkComponent } from "./shared/remix-link";
4
- export const RichTextLink = wrapLinkComponent(BaseLink);
@@ -1,4 +0,0 @@
1
- "use strict";
2
- import { propsMeta as linkPropsMeta } from "./link.ws";
3
- export { RichTextLink as meta } from "@webstudio-is/sdk-components-react/metas";
4
- export const propsMeta = linkPropsMeta;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import { forwardRef } from "react";
4
- import { NavLink as RemixLink } from "@remix-run/react";
5
- import {
6
- usePropUrl,
7
- getInstanceIdFromComponentProps
8
- } from "@webstudio-is/react-sdk";
9
- export const wrapLinkComponent = (BaseLink) => {
10
- const Component = forwardRef((props, ref) => {
11
- const href = usePropUrl(getInstanceIdFromComponentProps(props), "href");
12
- if (href?.type === "page") {
13
- let to = href.page.path === "" ? "/" : href.page.path;
14
- const urlTo = new URL(to, "https://any-valid.url");
15
- to = urlTo.pathname;
16
- if (href.hash !== void 0) {
17
- urlTo.hash = encodeURIComponent(href.hash);
18
- to = `${urlTo.pathname}${urlTo.hash}`;
19
- }
20
- return /* @__PURE__ */ jsx(RemixLink, { ...props, to, ref });
21
- }
22
- const { prefetch, reloadDocument, replace, preventScrollReset, ...rest } = props;
23
- return /* @__PURE__ */ jsx(BaseLink, { ...rest, ref });
24
- });
25
- Component.displayName = BaseLink.displayName;
26
- return Component;
27
- };