@webstudio-is/sdk-components-react-radix 0.87.1 → 0.89.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/__generated__/accordion.props.js +605 -114
- package/lib/__generated__/button.props.js +158 -47
- package/lib/__generated__/checkbox.props.js +1083 -0
- package/lib/__generated__/collapsible.props.js +234 -44
- package/lib/__generated__/dialog.props.js +611 -121
- package/lib/__generated__/input.props.js +264 -47
- package/lib/__generated__/label.props.js +123 -23
- package/lib/__generated__/navigation-menu.props.js +2565 -0
- package/lib/__generated__/popover.props.js +129 -28
- package/lib/__generated__/radio-group.props.js +1627 -0
- package/lib/__generated__/select.props.js +3678 -0
- package/lib/__generated__/sheet.props.js +591 -121
- package/lib/__generated__/switch.props.js +1083 -0
- package/lib/__generated__/tabs.props.js +906 -68
- package/lib/__generated__/textarea.props.js +177 -31
- package/lib/__generated__/tooltip.props.js +131 -29
- package/lib/accordion.js +11 -4
- package/lib/accordion.ws.js +88 -72
- package/lib/checkbox.js +13 -0
- package/lib/checkbox.ws.js +153 -0
- package/lib/cjs/__generated__/accordion.props.js +605 -114
- package/lib/cjs/__generated__/button.props.js +158 -47
- package/lib/cjs/__generated__/checkbox.props.js +1103 -0
- package/lib/cjs/__generated__/collapsible.props.js +234 -44
- package/lib/cjs/__generated__/dialog.props.js +611 -121
- package/lib/cjs/__generated__/input.props.js +264 -47
- package/lib/cjs/__generated__/label.props.js +123 -23
- package/lib/cjs/__generated__/navigation-menu.props.js +2585 -0
- package/lib/cjs/__generated__/popover.props.js +129 -28
- package/lib/cjs/__generated__/radio-group.props.js +1647 -0
- package/lib/cjs/__generated__/select.props.js +3698 -0
- package/lib/cjs/__generated__/sheet.props.js +591 -121
- package/lib/cjs/__generated__/switch.props.js +1103 -0
- package/lib/cjs/__generated__/tabs.props.js +906 -68
- package/lib/cjs/__generated__/textarea.props.js +177 -31
- package/lib/cjs/__generated__/tooltip.props.js +131 -29
- package/lib/cjs/accordion.js +11 -4
- package/lib/cjs/accordion.ws.js +86 -71
- package/lib/cjs/{textarea.js → checkbox.js} +9 -6
- package/lib/cjs/checkbox.ws.js +174 -0
- package/lib/cjs/collapsible.ws.js +5 -1
- package/lib/cjs/components.js +27 -14
- package/lib/cjs/dialog.ws.js +18 -17
- package/lib/cjs/hooks.js +5 -1
- package/lib/cjs/label.ws.js +2 -1
- package/lib/cjs/metas.js +29 -14
- package/lib/cjs/navigation-menu.js +107 -0
- package/lib/cjs/navigation-menu.ws.js +514 -0
- package/lib/cjs/popover.ws.js +13 -9
- package/lib/cjs/props-descriptions.js +56 -0
- package/lib/cjs/props.js +27 -14
- package/lib/cjs/{button.js → radio-group.js} +10 -8
- package/lib/cjs/radio-group.ws.js +191 -0
- package/lib/cjs/select.js +83 -0
- package/lib/cjs/select.ws.js +350 -0
- package/lib/cjs/sheet.ws.js +88 -176
- package/lib/cjs/{input.js → switch.js} +8 -9
- package/lib/cjs/switch.ws.js +173 -0
- package/lib/cjs/tabs.js +2 -3
- package/lib/cjs/tabs.ws.js +14 -18
- package/lib/cjs/theme/styles.js +100 -0
- package/lib/cjs/theme/tailwind-classes.js +125 -16
- package/lib/cjs/theme/tailwind-colors.js +1 -0
- package/lib/cjs/tooltip.ws.js +12 -8
- package/lib/collapsible.ws.js +5 -1
- package/lib/components.js +44 -22
- package/lib/dialog.ws.js +18 -17
- package/lib/hooks.js +5 -1
- package/lib/label.ws.js +2 -1
- package/lib/metas.js +58 -24
- package/lib/navigation-menu.js +85 -0
- package/lib/navigation-menu.ws.js +501 -0
- package/lib/popover.ws.js +13 -9
- package/lib/props-descriptions.js +36 -0
- package/lib/props.js +56 -24
- package/lib/radio-group.js +11 -0
- package/lib/radio-group.ws.js +173 -0
- package/lib/select.js +75 -0
- package/lib/select.ws.js +338 -0
- package/lib/sheet.ws.js +89 -194
- package/lib/switch.js +7 -0
- package/lib/switch.ws.js +145 -0
- package/lib/tabs.js +3 -5
- package/lib/tabs.ws.js +15 -19
- package/lib/theme/styles.js +70 -0
- package/lib/theme/tailwind-classes.js +125 -16
- package/lib/theme/tailwind-colors.js +1 -0
- package/lib/tooltip.ws.js +12 -8
- package/lib/types/__generated__/checkbox.props.d.ts +3 -0
- package/lib/types/__generated__/navigation-menu.props.d.ts +8 -0
- package/lib/types/__generated__/radio-group.props.d.ts +4 -0
- package/lib/types/__generated__/select.props.d.ts +9 -0
- package/lib/types/__generated__/switch.props.d.ts +3 -0
- package/lib/types/checkbox.d.ts +6 -0
- package/lib/types/checkbox.stories.d.ts +11 -0
- package/lib/types/checkbox.ws.d.ts +5 -0
- package/lib/types/components.d.ts +5 -4
- package/lib/types/metas.d.ts +6 -4
- package/lib/types/navigation-menu.d.ts +15 -0
- package/lib/types/navigation-menu.ws.d.ts +15 -0
- package/lib/types/props-descriptions.d.ts +29 -0
- package/lib/types/props.d.ts +5 -4
- package/lib/types/radio-group.d.ts +5 -0
- package/lib/types/radio-group.stories.d.ts +9 -0
- package/lib/types/radio-group.ws.d.ts +7 -0
- package/lib/types/select.d.ts +14 -0
- package/lib/types/select.ws.d.ts +17 -0
- package/lib/types/sheet.ws.d.ts +2 -15
- package/lib/types/switch.d.ts +4 -0
- package/lib/types/switch.stories.d.ts +9 -0
- package/lib/types/switch.ws.d.ts +5 -0
- package/lib/types/tabs.d.ts +3 -12
- package/lib/types/theme/radix-common-types.d.ts +3 -2
- package/lib/types/theme/styles.d.ts +215 -0
- package/lib/types/theme/tailwind-classes.d.ts +16 -6
- package/lib/types/theme/tailwind-colors.d.ts +1 -0
- package/lib/types/theme/tailwind-theme.d.ts +1 -1
- package/package.json +12 -7
- package/src/__generated__/accordion.props.ts +675 -108
- package/src/__generated__/button.props.ts +177 -45
- package/src/__generated__/checkbox.props.ts +1217 -0
- package/src/__generated__/collapsible.props.ts +261 -42
- package/src/__generated__/dialog.props.ts +682 -115
- package/src/__generated__/input.props.ts +292 -44
- package/src/__generated__/label.props.ts +137 -22
- package/src/__generated__/navigation-menu.props.ts +2882 -0
- package/src/__generated__/popover.props.ts +142 -24
- package/src/__generated__/radio-group.props.ts +1828 -0
- package/src/__generated__/select.props.ts +4130 -0
- package/src/__generated__/sheet.props.ts +657 -110
- package/src/__generated__/switch.props.ts +1217 -0
- package/src/__generated__/tabs.props.ts +1019 -67
- package/src/__generated__/textarea.props.ts +195 -30
- package/src/__generated__/tooltip.props.ts +145 -25
- package/src/accordion.tsx +14 -7
- package/src/accordion.ws.ts +87 -70
- package/src/{textarea.stories.ts → checkbox.stories.ts} +6 -11
- package/src/checkbox.tsx +22 -0
- package/src/checkbox.ws.ts +154 -0
- package/src/collapsible.ws.ts +6 -1
- package/src/components.ts +25 -12
- package/src/dialog.ws.tsx +17 -16
- package/src/hooks.ts +4 -0
- package/src/label.ws.ts +3 -1
- package/src/metas.ts +36 -12
- package/src/navigation-menu.stories.tsx +21 -0
- package/src/navigation-menu.tsx +130 -0
- package/src/navigation-menu.ws.ts +524 -0
- package/src/popover.ws.tsx +13 -9
- package/src/props-descriptions.ts +43 -0
- package/src/props.ts +35 -12
- package/src/{input.stories.ts → radio-group.stories.ts} +6 -15
- package/src/radio-group.tsx +17 -0
- package/src/radio-group.ws.ts +178 -0
- package/src/select.stories.tsx +21 -0
- package/src/select.tsx +112 -0
- package/src/select.ws.ts +349 -0
- package/src/sheet.ws.tsx +91 -209
- package/src/{button.stories.ts → switch.stories.ts} +6 -19
- package/src/switch.tsx +10 -0
- package/src/switch.ws.ts +146 -0
- package/src/tabs.tsx +4 -17
- package/src/tabs.ws.ts +19 -19
- package/src/theme/radix-common-types.ts +3 -2
- package/src/theme/styles.ts +80 -0
- package/src/theme/tailwind-classes.ts +150 -14
- package/src/theme/tailwind-colors.ts +1 -0
- package/src/tooltip.ws.tsx +13 -8
- package/lib/button.js +0 -8
- package/lib/button.ws.js +0 -133
- package/lib/cjs/button.ws.js +0 -160
- package/lib/cjs/input.ws.js +0 -103
- package/lib/cjs/textarea.ws.js +0 -98
- package/lib/input.js +0 -8
- package/lib/input.ws.js +0 -75
- package/lib/textarea.js +0 -8
- package/lib/textarea.ws.js +0 -70
- package/lib/types/button.d.ts +0 -7
- package/lib/types/button.stories.d.ts +0 -20
- package/lib/types/button.ws.d.ts +0 -7
- package/lib/types/input.d.ts +0 -2
- package/lib/types/input.stories.d.ts +0 -20
- package/lib/types/input.ws.d.ts +0 -3
- package/lib/types/textarea.d.ts +0 -2
- package/lib/types/textarea.stories.d.ts +0 -14
- package/lib/types/textarea.ws.d.ts +0 -3
- package/src/button.tsx +0 -25
- package/src/button.ws.ts +0 -155
- package/src/input.tsx +0 -12
- package/src/input.ws.ts +0 -78
- package/src/textarea.tsx +0 -12
- package/src/textarea.ws.ts +0 -74
package/src/sheet.ws.tsx
CHANGED
|
@@ -1,106 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
TriggerIcon,
|
|
4
|
-
ContentIcon,
|
|
5
|
-
OverlayIcon,
|
|
6
|
-
HeadingIcon,
|
|
7
|
-
TextIcon,
|
|
8
|
-
ButtonElementIcon,
|
|
9
|
-
} from "@webstudio-is/icons/svg";
|
|
10
|
-
import {
|
|
11
|
-
type PresetStyle,
|
|
12
|
-
type WsComponentMeta,
|
|
13
|
-
type WsComponentPropsMeta,
|
|
14
|
-
} from "@webstudio-is/react-sdk";
|
|
1
|
+
import { HamburgerMenuIcon } from "@webstudio-is/icons/svg";
|
|
2
|
+
import type { WsComponentMeta } from "@webstudio-is/react-sdk";
|
|
15
3
|
import * as tc from "./theme/tailwind-classes";
|
|
16
|
-
import {
|
|
17
|
-
propsSheet,
|
|
18
|
-
propsSheetContent,
|
|
19
|
-
propsSheetTrigger,
|
|
20
|
-
propsSheetOverlay,
|
|
21
|
-
propsSheetClose,
|
|
22
|
-
propsSheetTitle,
|
|
23
|
-
propsSheetDescription,
|
|
24
|
-
} from "./__generated__/sheet.props";
|
|
25
|
-
import { div, nav, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
|
|
26
|
-
import type { SheetContent } from "./sheet";
|
|
27
|
-
import type { ComponentProps } from "react";
|
|
28
|
-
import { template as buttonTemplate } from "./button.ws";
|
|
29
|
-
|
|
30
|
-
type ContentTags = NonNullable<ComponentProps<typeof SheetContent>["tag"]>;
|
|
31
|
-
|
|
32
|
-
const contentPresetStyle = {
|
|
33
|
-
div,
|
|
34
|
-
nav,
|
|
35
|
-
} satisfies PresetStyle<ContentTags>;
|
|
36
|
-
|
|
37
|
-
const presetStyle = {
|
|
38
|
-
div,
|
|
39
|
-
} satisfies PresetStyle<"div">;
|
|
40
|
-
|
|
41
|
-
const buttonPresetStyle = {
|
|
42
|
-
button,
|
|
43
|
-
} satisfies PresetStyle<"button">;
|
|
44
|
-
|
|
45
|
-
const titlePresetStyle = {
|
|
46
|
-
h2,
|
|
47
|
-
} satisfies PresetStyle<"h2">;
|
|
48
|
-
|
|
49
|
-
const descriptionPresetStyle = {
|
|
50
|
-
p,
|
|
51
|
-
} satisfies PresetStyle<"p">;
|
|
52
|
-
|
|
53
|
-
// @todo add [data-state] to button and link
|
|
54
|
-
export const metaSheetTrigger: WsComponentMeta = {
|
|
55
|
-
category: "hidden",
|
|
56
|
-
type: "container",
|
|
57
|
-
icon: TriggerIcon,
|
|
58
|
-
stylable: false,
|
|
59
|
-
detachable: false,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const metaSheetContent: WsComponentMeta = {
|
|
63
|
-
category: "hidden",
|
|
64
|
-
type: "container",
|
|
65
|
-
icon: ContentIcon,
|
|
66
|
-
detachable: false,
|
|
67
|
-
presetStyle: contentPresetStyle,
|
|
68
|
-
states: [
|
|
69
|
-
{ selector: "[data-side=top]", label: "Top Side" },
|
|
70
|
-
{ selector: "[data-side=right]", label: "Right Side" },
|
|
71
|
-
{ selector: "[data-side=bottom]", label: "Bottom Side" },
|
|
72
|
-
{ selector: "[data-side=left]", label: "Left Side" },
|
|
73
|
-
],
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const metaSheetOverlay: WsComponentMeta = {
|
|
77
|
-
category: "hidden",
|
|
78
|
-
type: "container",
|
|
79
|
-
presetStyle,
|
|
80
|
-
icon: OverlayIcon,
|
|
81
|
-
detachable: false,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const metaSheetTitle: WsComponentMeta = {
|
|
85
|
-
category: "hidden",
|
|
86
|
-
type: "container",
|
|
87
|
-
presetStyle: titlePresetStyle,
|
|
88
|
-
icon: HeadingIcon,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const metaSheetDescription: WsComponentMeta = {
|
|
92
|
-
category: "hidden",
|
|
93
|
-
type: "container",
|
|
94
|
-
presetStyle: descriptionPresetStyle,
|
|
95
|
-
icon: TextIcon,
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const metaSheetClose: WsComponentMeta = {
|
|
99
|
-
category: "hidden",
|
|
100
|
-
type: "container",
|
|
101
|
-
presetStyle: buttonPresetStyle,
|
|
102
|
-
icon: ButtonElementIcon,
|
|
103
|
-
};
|
|
4
|
+
import { getButtonStyles } from "./theme/styles";
|
|
104
5
|
|
|
105
6
|
/**
|
|
106
7
|
* Styles source without animations:
|
|
@@ -110,17 +11,19 @@ export const metaSheetClose: WsComponentMeta = {
|
|
|
110
11
|
* MIT License
|
|
111
12
|
* Copyright (c) 2023 shadcn
|
|
112
13
|
**/
|
|
113
|
-
export const
|
|
14
|
+
export const meta: WsComponentMeta = {
|
|
114
15
|
category: "radix",
|
|
115
|
-
|
|
16
|
+
order: 1,
|
|
116
17
|
type: "container",
|
|
117
18
|
icon: HamburgerMenuIcon,
|
|
118
|
-
order: 15,
|
|
119
19
|
stylable: false,
|
|
20
|
+
description:
|
|
21
|
+
"Displays content in a menu that slides out from the side of the screen, triggered by a button. Use this component for a typical mobile hamburger menu.",
|
|
120
22
|
template: [
|
|
121
23
|
{
|
|
122
24
|
type: "instance",
|
|
123
|
-
component: "
|
|
25
|
+
component: "Dialog",
|
|
26
|
+
label: "Sheet",
|
|
124
27
|
dataSources: {
|
|
125
28
|
sheetOpen: { type: "variable", initialValue: false },
|
|
126
29
|
},
|
|
@@ -141,32 +44,35 @@ export const metaSheet: WsComponentMeta = {
|
|
|
141
44
|
children: [
|
|
142
45
|
{
|
|
143
46
|
type: "instance",
|
|
144
|
-
component: "
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
47
|
+
component: "DialogTrigger",
|
|
48
|
+
label: "Sheet Trigger",
|
|
49
|
+
children: [
|
|
50
|
+
{
|
|
51
|
+
type: "instance",
|
|
52
|
+
component: "Button",
|
|
53
|
+
styles: getButtonStyles("ghost", "icon"),
|
|
54
|
+
children: [
|
|
55
|
+
{
|
|
56
|
+
type: "instance",
|
|
57
|
+
component: "HtmlEmbed",
|
|
58
|
+
label: "Hamburger Menu Svg",
|
|
59
|
+
props: [
|
|
60
|
+
{
|
|
61
|
+
type: "string",
|
|
62
|
+
name: "code",
|
|
63
|
+
value: HamburgerMenuIcon,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
children: [],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
166
71
|
},
|
|
167
72
|
{
|
|
168
73
|
type: "instance",
|
|
169
|
-
component: "
|
|
74
|
+
component: "DialogOverlay",
|
|
75
|
+
label: "Sheet Overlay",
|
|
170
76
|
/**
|
|
171
77
|
* fixed inset-0 z-50 bg-background/80 backdrop-blur-sm
|
|
172
78
|
* flex
|
|
@@ -185,7 +91,8 @@ export const metaSheet: WsComponentMeta = {
|
|
|
185
91
|
children: [
|
|
186
92
|
{
|
|
187
93
|
type: "instance",
|
|
188
|
-
component: "
|
|
94
|
+
component: "DialogContent",
|
|
95
|
+
label: "Sheet Content",
|
|
189
96
|
/**
|
|
190
97
|
* fixed w-full z-50
|
|
191
98
|
* grid gap-4 max-w-lg
|
|
@@ -203,73 +110,82 @@ export const metaSheet: WsComponentMeta = {
|
|
|
203
110
|
tc.p(6),
|
|
204
111
|
tc.shadow("lg"),
|
|
205
112
|
tc.relative(),
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
),
|
|
210
|
-
tc.state(
|
|
211
|
-
[tc.ml("auto"), tc.maxW("sm"), tc.grow()].flat(),
|
|
212
|
-
"[data-side=right]"
|
|
213
|
-
),
|
|
214
|
-
tc.state([tc.mb("auto")].flat(), "[data-side=top]"),
|
|
215
|
-
tc.state([tc.mt("auto")].flat(), "[data-side=bottom]"),
|
|
113
|
+
// side=left
|
|
114
|
+
tc.mr("auto"),
|
|
115
|
+
tc.maxW("sm"),
|
|
116
|
+
tc.grow(),
|
|
216
117
|
].flat(),
|
|
217
118
|
children: [
|
|
218
119
|
{
|
|
219
120
|
type: "instance",
|
|
220
121
|
component: "Box",
|
|
221
|
-
label: "
|
|
222
|
-
|
|
122
|
+
label: "Navigation",
|
|
123
|
+
props: [
|
|
124
|
+
{ name: "tag", type: "string", value: "nav" },
|
|
125
|
+
{ name: "role", type: "string", value: "navigation" },
|
|
126
|
+
],
|
|
223
127
|
children: [
|
|
224
128
|
{
|
|
225
129
|
type: "instance",
|
|
226
|
-
component: "
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
**/
|
|
230
|
-
styles: [
|
|
231
|
-
tc.my(0),
|
|
232
|
-
tc.leading("none"),
|
|
233
|
-
tc.text("lg"),
|
|
234
|
-
tc.tracking("tight"),
|
|
235
|
-
].flat(),
|
|
130
|
+
component: "Box",
|
|
131
|
+
label: "Sheet Header",
|
|
132
|
+
styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
|
|
236
133
|
children: [
|
|
237
134
|
{
|
|
238
|
-
type: "
|
|
239
|
-
|
|
135
|
+
type: "instance",
|
|
136
|
+
component: "DialogTitle",
|
|
137
|
+
label: "Sheet Title",
|
|
138
|
+
/**
|
|
139
|
+
* text-lg leading-none tracking-tight
|
|
140
|
+
**/
|
|
141
|
+
styles: [
|
|
142
|
+
tc.my(0),
|
|
143
|
+
tc.leading("none"),
|
|
144
|
+
tc.text("lg"),
|
|
145
|
+
tc.tracking("tight"),
|
|
146
|
+
].flat(),
|
|
147
|
+
children: [
|
|
148
|
+
{
|
|
149
|
+
type: "text",
|
|
150
|
+
value: "Sheet Title",
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
type: "instance",
|
|
156
|
+
component: "DialogDescription",
|
|
157
|
+
label: "Sheet Description",
|
|
158
|
+
/**
|
|
159
|
+
* text-sm text-muted-foreground
|
|
160
|
+
**/
|
|
161
|
+
styles: [
|
|
162
|
+
tc.my(0),
|
|
163
|
+
tc.text("sm"),
|
|
164
|
+
tc.text("mutedForeground"),
|
|
165
|
+
].flat(),
|
|
166
|
+
children: [
|
|
167
|
+
{
|
|
168
|
+
type: "text",
|
|
169
|
+
value: "Sheet description text you can edit",
|
|
170
|
+
},
|
|
171
|
+
],
|
|
240
172
|
},
|
|
241
173
|
],
|
|
242
174
|
},
|
|
175
|
+
|
|
243
176
|
{
|
|
244
177
|
type: "instance",
|
|
245
|
-
component: "
|
|
246
|
-
/**
|
|
247
|
-
* text-sm text-muted-foreground
|
|
248
|
-
**/
|
|
249
|
-
styles: [
|
|
250
|
-
tc.my(0),
|
|
251
|
-
tc.text("sm"),
|
|
252
|
-
tc.text("mutedForeground"),
|
|
253
|
-
].flat(),
|
|
178
|
+
component: "Text",
|
|
254
179
|
children: [
|
|
255
|
-
{
|
|
256
|
-
type: "text",
|
|
257
|
-
value: "sheet description text you can edit",
|
|
258
|
-
},
|
|
180
|
+
{ type: "text", value: "The text you can edit" },
|
|
259
181
|
],
|
|
260
182
|
},
|
|
261
183
|
],
|
|
262
184
|
},
|
|
263
|
-
|
|
264
|
-
{
|
|
265
|
-
type: "instance",
|
|
266
|
-
component: "Text",
|
|
267
|
-
children: [{ type: "text", value: "The text you can edit" }],
|
|
268
|
-
},
|
|
269
|
-
|
|
270
185
|
{
|
|
271
186
|
type: "instance",
|
|
272
|
-
component: "
|
|
187
|
+
component: "DialogClose",
|
|
188
|
+
label: "Close Button",
|
|
273
189
|
/**
|
|
274
190
|
* absolute right-4 top-4
|
|
275
191
|
* rounded-sm opacity-70
|
|
@@ -304,37 +220,3 @@ export const metaSheet: WsComponentMeta = {
|
|
|
304
220
|
},
|
|
305
221
|
],
|
|
306
222
|
};
|
|
307
|
-
|
|
308
|
-
export const propsMetaSheet: WsComponentPropsMeta = {
|
|
309
|
-
props: propsSheet,
|
|
310
|
-
initialProps: ["open", "modal"],
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
export const propsMetaSheetTrigger: WsComponentPropsMeta = {
|
|
314
|
-
props: propsSheetTrigger,
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
export const propsMetaSheetContent: WsComponentPropsMeta = {
|
|
318
|
-
props: propsSheetContent,
|
|
319
|
-
initialProps: ["side", "role", "tag"],
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
export const propsMetaSheetOverlay: WsComponentPropsMeta = {
|
|
323
|
-
props: propsSheetOverlay,
|
|
324
|
-
initialProps: [],
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
export const propsMetaSheetClose: WsComponentPropsMeta = {
|
|
328
|
-
props: propsSheetClose,
|
|
329
|
-
initialProps: [],
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
export const propsMetaSheetTitle: WsComponentPropsMeta = {
|
|
333
|
-
props: propsSheetTitle,
|
|
334
|
-
initialProps: [],
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
export const propsMetaSheetDescription: WsComponentPropsMeta = {
|
|
338
|
-
props: propsSheetDescription,
|
|
339
|
-
initialProps: [],
|
|
340
|
-
};
|
|
@@ -1,33 +1,20 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { renderComponentTemplate } from "@webstudio-is/react-sdk";
|
|
3
|
-
import { Button as ButtonPrimitive } from "./button";
|
|
4
3
|
import * as baseComponents from "@webstudio-is/sdk-components-react";
|
|
5
4
|
import * as baseMetas from "@webstudio-is/sdk-components-react/metas";
|
|
6
5
|
import * as radixComponents from "./components";
|
|
7
6
|
import * as radixMetas from "./metas";
|
|
7
|
+
import { Switch as SwitchPrimitive } from "./switch";
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
|
-
title: "Components/
|
|
11
|
-
component:
|
|
12
|
-
|
|
13
|
-
variant: {
|
|
14
|
-
options: [
|
|
15
|
-
"default",
|
|
16
|
-
"destructive",
|
|
17
|
-
"outline",
|
|
18
|
-
"secondary",
|
|
19
|
-
"ghost",
|
|
20
|
-
"link",
|
|
21
|
-
],
|
|
22
|
-
control: { type: "select" },
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
} satisfies Meta<typeof ButtonPrimitive>;
|
|
10
|
+
title: "Components/Switch",
|
|
11
|
+
component: SwitchPrimitive,
|
|
12
|
+
} satisfies Meta<typeof SwitchPrimitive>;
|
|
26
13
|
|
|
27
|
-
export const
|
|
14
|
+
export const Switch: StoryObj<typeof SwitchPrimitive> = {
|
|
28
15
|
render: (props) =>
|
|
29
16
|
renderComponentTemplate({
|
|
30
|
-
name: "
|
|
17
|
+
name: "Switch",
|
|
31
18
|
props: { ...props },
|
|
32
19
|
components: { ...baseComponents, ...radixComponents },
|
|
33
20
|
metas: { ...baseMetas, ...radixMetas },
|
package/src/switch.tsx
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ForwardRefExoticComponent, ComponentPropsWithRef } from "react";
|
|
2
|
+
import { Root, Thumb } from "@radix-ui/react-switch";
|
|
3
|
+
|
|
4
|
+
export const Switch: ForwardRefExoticComponent<
|
|
5
|
+
ComponentPropsWithRef<typeof Root>
|
|
6
|
+
> = Root;
|
|
7
|
+
|
|
8
|
+
export const SwitchThumb: ForwardRefExoticComponent<
|
|
9
|
+
ComponentPropsWithRef<typeof Thumb>
|
|
10
|
+
> = Thumb;
|
package/src/switch.ws.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { SwitchIcon, TriggerIcon } from "@webstudio-is/icons/svg";
|
|
2
|
+
import {
|
|
3
|
+
defaultStates,
|
|
4
|
+
type WsComponentMeta,
|
|
5
|
+
type WsComponentPropsMeta,
|
|
6
|
+
} from "@webstudio-is/react-sdk";
|
|
7
|
+
import { button, span } from "@webstudio-is/react-sdk/css-normalize";
|
|
8
|
+
import * as tc from "./theme/tailwind-classes";
|
|
9
|
+
import { buttonReset } from "./theme/styles";
|
|
10
|
+
import { propsSwitch, propsSwitchThumb } from "./__generated__/switch.props";
|
|
11
|
+
|
|
12
|
+
export const metaSwitch: WsComponentMeta = {
|
|
13
|
+
category: "radix",
|
|
14
|
+
order: 11,
|
|
15
|
+
type: "container",
|
|
16
|
+
description:
|
|
17
|
+
"A control that allows the user to toggle between checked and not checked.",
|
|
18
|
+
icon: SwitchIcon,
|
|
19
|
+
states: [
|
|
20
|
+
...defaultStates,
|
|
21
|
+
{
|
|
22
|
+
label: "Checked",
|
|
23
|
+
selector: "[data-state=checked]",
|
|
24
|
+
category: "component-states",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Unchecked",
|
|
28
|
+
selector: "[data-state=unchecked]",
|
|
29
|
+
category: "component-states",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
presetStyle: {
|
|
33
|
+
button: [button, buttonReset].flat(),
|
|
34
|
+
},
|
|
35
|
+
template: [
|
|
36
|
+
{
|
|
37
|
+
type: "instance",
|
|
38
|
+
component: "Switch",
|
|
39
|
+
dataSources: {
|
|
40
|
+
switchChecked: { type: "variable", initialValue: false },
|
|
41
|
+
},
|
|
42
|
+
props: [
|
|
43
|
+
{
|
|
44
|
+
name: "checked",
|
|
45
|
+
type: "dataSource",
|
|
46
|
+
dataSourceName: "switchChecked",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "onCheckedChange",
|
|
50
|
+
type: "action",
|
|
51
|
+
value: [
|
|
52
|
+
{
|
|
53
|
+
type: "execute",
|
|
54
|
+
args: ["checked"],
|
|
55
|
+
code: `switchChecked = checked`,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
// peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors
|
|
61
|
+
// focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background
|
|
62
|
+
// disabled:cursor-not-allowed disabled:opacity-50
|
|
63
|
+
// data-[state=checked]:bg-primary
|
|
64
|
+
// data-[state=unchecked]:bg-input
|
|
65
|
+
styles: [
|
|
66
|
+
// We are not supporting peer like styles yet
|
|
67
|
+
tc.inlineFlex(),
|
|
68
|
+
tc.property("height", "24px"),
|
|
69
|
+
tc.property("width", "44px"),
|
|
70
|
+
tc.shrink(0),
|
|
71
|
+
tc.cursor("pointer"),
|
|
72
|
+
tc.items("center"),
|
|
73
|
+
tc.rounded("full"),
|
|
74
|
+
tc.border(2),
|
|
75
|
+
tc.border("transparent"),
|
|
76
|
+
tc.transition("all"),
|
|
77
|
+
tc.focusVisible(
|
|
78
|
+
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
79
|
+
),
|
|
80
|
+
tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat()),
|
|
81
|
+
tc.state([tc.bg("primary")].flat(), "[data-state=checked]"),
|
|
82
|
+
tc.state([tc.bg("input")].flat(), "[data-state=unchecked]"),
|
|
83
|
+
].flat(),
|
|
84
|
+
children: [
|
|
85
|
+
{
|
|
86
|
+
type: "instance",
|
|
87
|
+
component: "SwitchThumb",
|
|
88
|
+
// pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform
|
|
89
|
+
// data-[state=checked]:translate-x-5
|
|
90
|
+
// data-[state=unchecked]:translate-x-0
|
|
91
|
+
styles: [
|
|
92
|
+
tc.pointerEvents("none"),
|
|
93
|
+
tc.block(),
|
|
94
|
+
tc.h(5),
|
|
95
|
+
tc.w(5),
|
|
96
|
+
tc.rounded("full"),
|
|
97
|
+
tc.bg("background"),
|
|
98
|
+
tc.shadow("lg"),
|
|
99
|
+
tc.transition("transform"),
|
|
100
|
+
tc.state(
|
|
101
|
+
[tc.property("transform", "translateX(20px)")].flat(),
|
|
102
|
+
"[data-state=checked]"
|
|
103
|
+
),
|
|
104
|
+
tc.state(
|
|
105
|
+
[tc.property("transform", "translateX(0px)")].flat(),
|
|
106
|
+
"[data-state=unchecked]"
|
|
107
|
+
),
|
|
108
|
+
].flat(),
|
|
109
|
+
children: [],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const metaSwitchThumb: WsComponentMeta = {
|
|
117
|
+
category: "hidden",
|
|
118
|
+
type: "container",
|
|
119
|
+
detachable: false,
|
|
120
|
+
icon: TriggerIcon,
|
|
121
|
+
states: [
|
|
122
|
+
...defaultStates,
|
|
123
|
+
{
|
|
124
|
+
label: "Checked",
|
|
125
|
+
selector: "[data-state=checked]",
|
|
126
|
+
category: "component-states",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
label: "Unchecked",
|
|
130
|
+
selector: "[data-state=unchecked]",
|
|
131
|
+
category: "component-states",
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
presetStyle: {
|
|
135
|
+
span,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const propsMetaSwitch: WsComponentPropsMeta = {
|
|
140
|
+
props: propsSwitch,
|
|
141
|
+
initialProps: ["id", "checked", "name", "required"],
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const propsMetaSwitchThumb: WsComponentPropsMeta = {
|
|
145
|
+
props: propsSwitchThumb,
|
|
146
|
+
};
|
package/src/tabs.tsx
CHANGED
|
@@ -5,9 +5,7 @@ import {
|
|
|
5
5
|
type ComponentPropsWithoutRef,
|
|
6
6
|
type ForwardRefExoticComponent,
|
|
7
7
|
type ComponentPropsWithRef,
|
|
8
|
-
type ReactNode,
|
|
9
8
|
forwardRef,
|
|
10
|
-
Children,
|
|
11
9
|
} from "react";
|
|
12
10
|
import { Root, List, Trigger, Content } from "@radix-ui/react-tabs";
|
|
13
11
|
import {
|
|
@@ -22,28 +20,17 @@ export const Tabs: ForwardRefExoticComponent<
|
|
|
22
20
|
|
|
23
21
|
export const TabsList = List;
|
|
24
22
|
|
|
25
|
-
/**
|
|
26
|
-
* We're not exposing the 'asChild' property for the Trigger.
|
|
27
|
-
* Instead, we're enforcing 'asChild=true' for the Trigger and making it style-less.
|
|
28
|
-
* This avoids situations where the Trigger inadvertently passes all styles to its child,
|
|
29
|
-
* which would prevent us from displaying styles properly in the builder.
|
|
30
|
-
*/
|
|
31
23
|
export const TabsTrigger = forwardRef<
|
|
32
24
|
HTMLButtonElement,
|
|
33
|
-
|
|
34
|
-
>(({ value,
|
|
35
|
-
const firstChild = Children.toArray(children)[0];
|
|
25
|
+
ComponentPropsWithoutRef<typeof Trigger>
|
|
26
|
+
>(({ value, ...props }, ref) => {
|
|
36
27
|
const index = getIndexWithinAncestorFromComponentProps(props);
|
|
37
|
-
return
|
|
38
|
-
<Trigger ref={ref} value={value ?? index} asChild={true} {...props}>
|
|
39
|
-
{firstChild ?? <button>Add button</button>}
|
|
40
|
-
</Trigger>
|
|
41
|
-
);
|
|
28
|
+
return <Trigger ref={ref} value={value ?? index} {...props} />;
|
|
42
29
|
});
|
|
43
30
|
|
|
44
31
|
export const TabsContent = forwardRef<
|
|
45
32
|
HTMLDivElement,
|
|
46
|
-
|
|
33
|
+
ComponentPropsWithoutRef<typeof Content>
|
|
47
34
|
>(({ value, ...props }, ref) => {
|
|
48
35
|
const index = getIndexWithinAncestorFromComponentProps(props);
|
|
49
36
|
return <Content ref={ref} value={value ?? index} {...props} />;
|
package/src/tabs.ws.ts
CHANGED
|
@@ -10,8 +10,9 @@ import type {
|
|
|
10
10
|
WsComponentMeta,
|
|
11
11
|
WsComponentPropsMeta,
|
|
12
12
|
} from "@webstudio-is/react-sdk";
|
|
13
|
-
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
13
|
+
import { button, div } from "@webstudio-is/react-sdk/css-normalize";
|
|
14
14
|
import * as tc from "./theme/tailwind-classes";
|
|
15
|
+
import { buttonReset } from "./theme/styles";
|
|
15
16
|
import {
|
|
16
17
|
propsTabs,
|
|
17
18
|
propsTabsList,
|
|
@@ -32,8 +33,11 @@ const presetStyle = {
|
|
|
32
33
|
* Copyright (c) 2023 shadcn
|
|
33
34
|
**/
|
|
34
35
|
|
|
35
|
-
// inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all
|
|
36
|
-
|
|
36
|
+
// inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all
|
|
37
|
+
// focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
|
|
38
|
+
// disabled:pointer-events-none disabled:opacity-50
|
|
39
|
+
// data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm
|
|
40
|
+
const tabsTriggerStyles = [
|
|
37
41
|
tc.inlineFlex(),
|
|
38
42
|
tc.items("center"),
|
|
39
43
|
tc.justify("center"),
|
|
@@ -64,9 +68,12 @@ const tabsContentStyles: EmbedTemplateStyleDecl[] = [
|
|
|
64
68
|
|
|
65
69
|
export const metaTabs: WsComponentMeta = {
|
|
66
70
|
category: "radix",
|
|
71
|
+
order: 2,
|
|
67
72
|
type: "container",
|
|
68
73
|
icon: TabsIcon,
|
|
69
74
|
presetStyle,
|
|
75
|
+
description:
|
|
76
|
+
"A set of panels with content that are displayed one at a time. Duplicate both a tab trigger and tab content to add more tabs. Triggers and content are connected according to their order in the Navigator.",
|
|
70
77
|
template: [
|
|
71
78
|
{
|
|
72
79
|
type: "instance",
|
|
@@ -103,26 +110,14 @@ export const metaTabs: WsComponentMeta = {
|
|
|
103
110
|
{
|
|
104
111
|
type: "instance",
|
|
105
112
|
component: "TabsTrigger",
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
type: "instance",
|
|
109
|
-
component: "Button",
|
|
110
|
-
styles: tabsTriggerStyles,
|
|
111
|
-
children: [{ type: "text", value: "Account" }],
|
|
112
|
-
},
|
|
113
|
-
],
|
|
113
|
+
styles: tabsTriggerStyles,
|
|
114
|
+
children: [{ type: "text", value: "Account" }],
|
|
114
115
|
},
|
|
115
116
|
{
|
|
116
117
|
type: "instance",
|
|
117
118
|
component: "TabsTrigger",
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
type: "instance",
|
|
121
|
-
component: "Button",
|
|
122
|
-
styles: tabsTriggerStyles,
|
|
123
|
-
children: [{ type: "text", value: "Password" }],
|
|
124
|
-
},
|
|
125
|
-
],
|
|
119
|
+
styles: tabsTriggerStyles,
|
|
120
|
+
children: [{ type: "text", value: "Password" }],
|
|
126
121
|
},
|
|
127
122
|
],
|
|
128
123
|
},
|
|
@@ -161,6 +156,10 @@ export const metaTabsTrigger: WsComponentMeta = {
|
|
|
161
156
|
requiredAncestors: ["TabsList"],
|
|
162
157
|
invalidAncestors: ["TabsTrigger"],
|
|
163
158
|
indexWithinAncestor: "Tabs",
|
|
159
|
+
label: "Tab Trigger",
|
|
160
|
+
presetStyle: {
|
|
161
|
+
button: [button, buttonReset].flat(),
|
|
162
|
+
},
|
|
164
163
|
};
|
|
165
164
|
|
|
166
165
|
export const metaTabsContent: WsComponentMeta = {
|
|
@@ -170,6 +169,7 @@ export const metaTabsContent: WsComponentMeta = {
|
|
|
170
169
|
requiredAncestors: ["Tabs"],
|
|
171
170
|
indexWithinAncestor: "Tabs",
|
|
172
171
|
presetStyle,
|
|
172
|
+
label: "Tab Content",
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
export const propsMetaTabs: WsComponentPropsMeta = {
|