@webstudio-is/sdk-components-react-radix 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.
Files changed (63) hide show
  1. package/lib/components.js +278 -35
  2. package/lib/hooks.js +475 -11
  3. package/lib/metas.js +4616 -58
  4. package/lib/props.js +23280 -57
  5. package/lib/types/theme/tailwind-classes.d.ts +4 -4
  6. package/package.json +9 -9
  7. package/lib/__generated__/accordion.props.js +0 -2619
  8. package/lib/__generated__/checkbox.props.js +0 -1080
  9. package/lib/__generated__/collapsible.props.js +0 -1026
  10. package/lib/__generated__/dialog.props.js +0 -2595
  11. package/lib/__generated__/label.props.js +0 -519
  12. package/lib/__generated__/navigation-menu.props.js +0 -2557
  13. package/lib/__generated__/popover.props.js +0 -558
  14. package/lib/__generated__/radio-group.props.js +0 -1623
  15. package/lib/__generated__/select.props.js +0 -3674
  16. package/lib/__generated__/sheet.props.js +0 -2614
  17. package/lib/__generated__/switch.props.js +0 -1080
  18. package/lib/__generated__/tabs.props.js +0 -2119
  19. package/lib/__generated__/tooltip.props.js +0 -569
  20. package/lib/accordion.js +0 -51
  21. package/lib/accordion.stories.js +0 -18
  22. package/lib/accordion.ws.js +0 -259
  23. package/lib/checkbox.js +0 -10
  24. package/lib/checkbox.stories.js +0 -19
  25. package/lib/checkbox.ws.js +0 -148
  26. package/lib/collapsible.js +0 -31
  27. package/lib/collapsible.stories.js +0 -18
  28. package/lib/collapsible.ws.js +0 -103
  29. package/lib/dialog.js +0 -53
  30. package/lib/dialog.stories.js +0 -18
  31. package/lib/dialog.ws.js +0 -289
  32. package/lib/label.js +0 -7
  33. package/lib/label.stories.js +0 -19
  34. package/lib/label.ws.js +0 -44
  35. package/lib/navigation-menu.js +0 -76
  36. package/lib/navigation-menu.stories.js +0 -18
  37. package/lib/navigation-menu.ws.js +0 -486
  38. package/lib/popover.js +0 -58
  39. package/lib/popover.stories.js +0 -18
  40. package/lib/popover.ws.js +0 -110
  41. package/lib/props-descriptions.js +0 -34
  42. package/lib/radio-group.js +0 -7
  43. package/lib/radio-group.stories.js +0 -19
  44. package/lib/radio-group.ws.js +0 -166
  45. package/lib/select.js +0 -65
  46. package/lib/select.stories.js +0 -18
  47. package/lib/select.ws.js +0 -321
  48. package/lib/sheet.js +0 -59
  49. package/lib/sheet.stories.js +0 -18
  50. package/lib/sheet.ws.js +0 -225
  51. package/lib/switch.js +0 -4
  52. package/lib/switch.stories.js +0 -19
  53. package/lib/switch.ws.js +0 -140
  54. package/lib/tabs.js +0 -38
  55. package/lib/tabs.stories.js +0 -18
  56. package/lib/tabs.ws.js +0 -169
  57. package/lib/theme/__generated__/tailwind-theme.js +0 -517
  58. package/lib/theme/styles.js +0 -63
  59. package/lib/theme/tailwind-classes.js +0 -651
  60. package/lib/theme/tailwind-colors.js +0 -23
  61. package/lib/tooltip.js +0 -55
  62. package/lib/tooltip.stories.js +0 -18
  63. package/lib/tooltip.ws.js +0 -111
package/lib/dialog.ws.js DELETED
@@ -1,289 +0,0 @@
1
- "use strict";
2
- import {
3
- DialogIcon,
4
- TriggerIcon,
5
- ContentIcon,
6
- OverlayIcon,
7
- HeadingIcon,
8
- TextIcon,
9
- ButtonElementIcon,
10
- LargeXIcon
11
- } from "@webstudio-is/icons/svg";
12
- import {
13
- defaultStates
14
- } from "@webstudio-is/react-sdk";
15
- import { div, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
16
- import * as tc from "./theme/tailwind-classes";
17
- import {
18
- propsDialog,
19
- propsDialogContent,
20
- propsDialogTrigger,
21
- propsDialogOverlay,
22
- propsDialogClose,
23
- propsDialogTitle,
24
- propsDialogDescription
25
- } from "./__generated__/dialog.props";
26
- import { buttonReset, getButtonStyles } from "./theme/styles";
27
- const presetStyle = {
28
- div
29
- };
30
- const titlePresetStyle = {
31
- h2
32
- };
33
- const descriptionPresetStyle = {
34
- p
35
- };
36
- export const metaDialogTrigger = {
37
- category: "hidden",
38
- type: "container",
39
- icon: TriggerIcon,
40
- stylable: false,
41
- detachable: false
42
- };
43
- export const metaDialogContent = {
44
- category: "hidden",
45
- type: "container",
46
- presetStyle,
47
- icon: ContentIcon,
48
- detachable: false
49
- };
50
- export const metaDialogOverlay = {
51
- category: "hidden",
52
- type: "container",
53
- presetStyle,
54
- icon: OverlayIcon,
55
- detachable: false
56
- };
57
- export const metaDialogTitle = {
58
- category: "hidden",
59
- type: "container",
60
- presetStyle: titlePresetStyle,
61
- icon: HeadingIcon
62
- };
63
- export const metaDialogDescription = {
64
- category: "hidden",
65
- type: "container",
66
- presetStyle: descriptionPresetStyle,
67
- icon: TextIcon
68
- };
69
- export const metaDialogClose = {
70
- category: "hidden",
71
- type: "container",
72
- presetStyle: {
73
- button: [buttonReset, button].flat()
74
- },
75
- states: defaultStates,
76
- icon: ButtonElementIcon,
77
- label: "Close Button"
78
- };
79
- export const metaDialog = {
80
- category: "radix",
81
- order: 4,
82
- type: "container",
83
- icon: DialogIcon,
84
- stylable: false,
85
- description: "Displays content with an overlay that covers the window, triggered by a button. Clicking the overlay will close the dialog.",
86
- template: [
87
- {
88
- type: "instance",
89
- component: "Dialog",
90
- dataSources: {
91
- dialogOpen: { type: "variable", initialValue: false }
92
- },
93
- props: [
94
- {
95
- type: "dataSource",
96
- name: "open",
97
- dataSourceName: "dialogOpen"
98
- },
99
- {
100
- name: "onOpenChange",
101
- type: "action",
102
- value: [
103
- { type: "execute", args: ["open"], code: `dialogOpen = open` }
104
- ]
105
- }
106
- ],
107
- children: [
108
- {
109
- type: "instance",
110
- component: "DialogTrigger",
111
- children: [
112
- {
113
- type: "instance",
114
- component: "Button",
115
- styles: getButtonStyles("outline"),
116
- children: [{ type: "text", value: "Button" }]
117
- }
118
- ]
119
- },
120
- {
121
- type: "instance",
122
- component: "DialogOverlay",
123
- /**
124
- * fixed inset-0 z-50 bg-background/80 backdrop-blur-sm
125
- * flex
126
- **/
127
- styles: [
128
- tc.fixed(),
129
- tc.inset(0),
130
- tc.z(50),
131
- tc.bg("background", 80),
132
- tc.backdropBlur("sm"),
133
- // To allow positioning Content
134
- tc.flex(),
135
- tc.overflow("auto")
136
- ].flat(),
137
- children: [
138
- {
139
- type: "instance",
140
- component: "DialogContent",
141
- /**
142
- * fixed w-full z-50
143
- * grid gap-4 max-w-lg
144
- * m-auto
145
- * border bg-background p-6 shadow-lg
146
- **/
147
- styles: [
148
- tc.w("full"),
149
- tc.z(50),
150
- tc.flex(),
151
- tc.flex("col"),
152
- tc.gap(4),
153
- tc.m("auto"),
154
- tc.maxW("lg"),
155
- tc.border(),
156
- tc.bg("background"),
157
- tc.p(6),
158
- tc.shadow("lg"),
159
- tc.relative()
160
- ].flat(),
161
- children: [
162
- {
163
- type: "instance",
164
- component: "Box",
165
- label: "Dialog Header",
166
- styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
167
- children: [
168
- {
169
- type: "instance",
170
- component: "DialogTitle",
171
- /**
172
- * text-lg leading-none tracking-tight
173
- **/
174
- styles: [
175
- tc.my(0),
176
- tc.leading("none"),
177
- tc.text("lg"),
178
- tc.tracking("tight")
179
- ].flat(),
180
- children: [
181
- {
182
- type: "text",
183
- value: "Dialog Title"
184
- }
185
- ]
186
- },
187
- {
188
- type: "instance",
189
- component: "DialogDescription",
190
- /**
191
- * text-sm text-muted-foreground
192
- **/
193
- styles: [
194
- tc.my(0),
195
- tc.text("sm"),
196
- tc.text("mutedForeground")
197
- ].flat(),
198
- children: [
199
- {
200
- type: "text",
201
- value: "Dialog description text you can edit"
202
- }
203
- ]
204
- }
205
- ]
206
- },
207
- {
208
- type: "instance",
209
- component: "Text",
210
- children: [{ type: "text", value: "The text you can edit" }]
211
- },
212
- {
213
- type: "instance",
214
- component: "DialogClose",
215
- /**
216
- * absolute right-4 top-4
217
- * rounded-sm opacity-70
218
- * ring-offset-background
219
- * hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
220
- * flex items-center justify-center h-4 w-4
221
- **/
222
- styles: [
223
- tc.absolute(),
224
- tc.right(4),
225
- tc.top(4),
226
- tc.rounded("sm"),
227
- tc.opacity(70),
228
- tc.flex(),
229
- tc.items("center"),
230
- tc.justify("center"),
231
- tc.h(4),
232
- tc.w(4),
233
- tc.border(0),
234
- tc.bg("transparent"),
235
- tc.outline("none"),
236
- tc.hover(tc.opacity(100)),
237
- tc.focus(tc.ring("ring", 2, "background", 2))
238
- ].flat(),
239
- children: [
240
- {
241
- type: "instance",
242
- component: "HtmlEmbed",
243
- label: "Close Icon",
244
- props: [
245
- {
246
- type: "string",
247
- name: "code",
248
- value: LargeXIcon
249
- }
250
- ],
251
- children: []
252
- }
253
- ]
254
- }
255
- ]
256
- }
257
- ]
258
- }
259
- ]
260
- }
261
- ]
262
- };
263
- export const propsMetaDialog = {
264
- props: propsDialog,
265
- initialProps: ["open"]
266
- };
267
- export const propsMetaDialogTrigger = {
268
- props: propsDialogTrigger
269
- };
270
- export const propsMetaDialogContent = {
271
- props: propsDialogContent,
272
- initialProps: []
273
- };
274
- export const propsMetaDialogOverlay = {
275
- props: propsDialogOverlay,
276
- initialProps: []
277
- };
278
- export const propsMetaDialogClose = {
279
- props: propsDialogClose,
280
- initialProps: []
281
- };
282
- export const propsMetaDialogTitle = {
283
- props: propsDialogTitle,
284
- initialProps: []
285
- };
286
- export const propsMetaDialogDescription = {
287
- props: propsDialogDescription,
288
- initialProps: []
289
- };
package/lib/label.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import {
4
- forwardRef
5
- } from "react";
6
- import * as LabelPrimitive from "@radix-ui/react-label";
7
- export const Label = forwardRef((props, ref) => /* @__PURE__ */ jsx(LabelPrimitive.Root, { ref, ...props }));
@@ -1,19 +0,0 @@
1
- "use strict";
2
- import { renderComponentTemplate } from "@webstudio-is/react-sdk";
3
- import { Label as LabelPrimitive } from "./label";
4
- import * as baseComponents from "@webstudio-is/sdk-components-react";
5
- import * as baseMetas from "@webstudio-is/sdk-components-react/metas";
6
- import * as radixComponents from "./components";
7
- import * as radixMetas from "./metas";
8
- export default {
9
- title: "Components/Label",
10
- component: LabelPrimitive
11
- };
12
- export const Label = {
13
- render: (props) => renderComponentTemplate({
14
- name: "Label",
15
- props: { ...props },
16
- components: { ...baseComponents, ...radixComponents },
17
- metas: { ...baseMetas, ...radixMetas }
18
- })
19
- };
package/lib/label.ws.js DELETED
@@ -1,44 +0,0 @@
1
- "use strict";
2
- import { LabelIcon } from "@webstudio-is/icons/svg";
3
- import {
4
- defaultStates
5
- } from "@webstudio-is/react-sdk";
6
- import { label } from "@webstudio-is/react-sdk/css-normalize";
7
- import { props } from "./__generated__/label.props";
8
- import * as tc from "./theme/tailwind-classes";
9
- const presetStyle = {
10
- label
11
- };
12
- export const meta = {
13
- category: "radix",
14
- order: 102,
15
- type: "container",
16
- icon: LabelIcon,
17
- presetStyle,
18
- states: defaultStates,
19
- description: "An accessible label to describe the purpose of an input. Match the \u201CFor\u201D property on the label with the \u201CID\u201D of the input to connect them.",
20
- template: [
21
- {
22
- type: "instance",
23
- component: "Label",
24
- styles: [
25
- // text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70
26
- tc.text("sm"),
27
- tc.font("medium"),
28
- tc.leading("none")
29
- // We are not supporting peer like styles yet
30
- ].flat(),
31
- children: [{ type: "text", value: "Form Label" }]
32
- }
33
- ]
34
- };
35
- export const propsMeta = {
36
- props: {
37
- ...props,
38
- htmlFor: {
39
- ...props.htmlFor,
40
- label: "For"
41
- }
42
- },
43
- initialProps: ["id", "htmlFor"]
44
- };
@@ -1,76 +0,0 @@
1
- "use strict";
2
- import { jsx } from "react/jsx-runtime";
3
- import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
4
- import {
5
- getClosestInstance,
6
- getIndexWithinAncestorFromComponentProps,
7
- ReactSdkContext
8
- } from "@webstudio-is/react-sdk";
9
- import {
10
- Children,
11
- forwardRef,
12
- useContext
13
- } from "react";
14
- export const NavigationMenu = forwardRef(({ value: propsValue, ...props }, ref) => {
15
- const { renderer } = useContext(ReactSdkContext);
16
- let value = propsValue;
17
- if (renderer === "canvas") {
18
- value = value === "" ? "-1" : value;
19
- }
20
- return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Root, { ref, value, ...props });
21
- });
22
- export const NavigationMenuList = NavigationMenuPrimitive.List;
23
- export const NavigationMenuViewport = NavigationMenuPrimitive.Viewport;
24
- export const NavigationMenuContent = NavigationMenuPrimitive.Content;
25
- export const NavigationMenuItem = forwardRef(({ value, ...props }, ref) => {
26
- const index = getIndexWithinAncestorFromComponentProps(props);
27
- return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Item, { ref, value: value ?? index, ...props });
28
- });
29
- export const NavigationMenuLink = forwardRef(({ children, ...props }, ref) => {
30
- const firstChild = Children.toArray(children)[0];
31
- return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Link, { asChild: true, ref, ...props, children: firstChild ?? /* @__PURE__ */ jsx("a", { children: "Add link component" }) });
32
- });
33
- export const NavigationMenuTrigger = forwardRef(({ children, ...props }, ref) => {
34
- const firstChild = Children.toArray(children)[0];
35
- return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Trigger, { asChild: true, ref, ...props, children: firstChild ?? /* @__PURE__ */ jsx("button", { children: "Add button or link" }) });
36
- });
37
- const namespace = "@webstudio-is/sdk-components-react-radix";
38
- export const hooksNavigationMenu = {
39
- onNavigatorUnselect: (context, event) => {
40
- for (const instance of event.instancePath) {
41
- if (instance.component === `${namespace}:NavigationMenuContent`) {
42
- const menu = getClosestInstance(
43
- event.instancePath,
44
- instance,
45
- `${namespace}:NavigationMenu`
46
- );
47
- if (menu) {
48
- context.setPropVariable(menu.id, "value", "");
49
- }
50
- }
51
- }
52
- },
53
- onNavigatorSelect: (context, event) => {
54
- for (const instance of event.instancePath) {
55
- if (instance.component === `${namespace}:NavigationMenuContent`) {
56
- const menu = getClosestInstance(
57
- event.instancePath,
58
- instance,
59
- `${namespace}:NavigationMenu`
60
- );
61
- const menuItem = getClosestInstance(
62
- event.instancePath,
63
- instance,
64
- `${namespace}:NavigationMenuItem`
65
- );
66
- if (menuItem === void 0 || menu === void 0) {
67
- return;
68
- }
69
- const contentValue = context.getPropValue(menuItem.id, "value") ?? context.indexesWithinAncestors.get(menuItem.id)?.toString();
70
- if (contentValue) {
71
- context.setPropVariable(menu.id, "value", contentValue);
72
- }
73
- }
74
- }
75
- }
76
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- import { renderComponentTemplate } from "@webstudio-is/react-sdk";
3
- import { NavigationMenu as NavigationMenuPrimitive } from "./navigation-menu";
4
- import * as baseComponents from "@webstudio-is/sdk-components-react";
5
- import * as baseMetas from "@webstudio-is/sdk-components-react/metas";
6
- import * as radixComponents from "./components";
7
- import * as radixMetas from "./metas";
8
- export default {
9
- title: "Components/NavigationMenu",
10
- component: NavigationMenuPrimitive
11
- };
12
- export const NavigationMenu = {
13
- render: () => renderComponentTemplate({
14
- name: "NavigationMenu",
15
- components: { ...baseComponents, ...radixComponents },
16
- metas: { ...baseMetas, ...radixMetas }
17
- })
18
- };