@webstudio-is/sdk-components-react-radix 0.87.0 → 0.88.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 +0 -5
- package/lib/__generated__/button.props.js +0 -21
- package/lib/__generated__/checkbox.props.js +850 -0
- package/lib/__generated__/collapsible.props.js +0 -2
- package/lib/__generated__/dialog.props.js +0 -11
- package/lib/__generated__/label.props.js +0 -1
- package/lib/__generated__/navigation-menu.props.js +2104 -0
- package/lib/__generated__/popover.props.js +0 -3
- package/lib/__generated__/radio-group.props.js +1282 -0
- package/lib/__generated__/select.props.js +2962 -0
- package/lib/__generated__/sheet.props.js +0 -11
- package/lib/__generated__/switch.props.js +850 -0
- package/lib/__generated__/tabs.props.js +428 -5
- package/lib/__generated__/tooltip.props.js +0 -2
- package/lib/accordion.js +11 -4
- package/lib/accordion.ws.js +87 -72
- package/lib/checkbox.js +13 -0
- package/lib/checkbox.ws.js +151 -0
- package/lib/cjs/__generated__/accordion.props.js +0 -5
- package/lib/cjs/__generated__/button.props.js +0 -21
- package/lib/cjs/__generated__/checkbox.props.js +870 -0
- package/lib/cjs/__generated__/collapsible.props.js +0 -2
- package/lib/cjs/__generated__/dialog.props.js +0 -11
- package/lib/cjs/__generated__/label.props.js +0 -1
- package/lib/cjs/__generated__/navigation-menu.props.js +2124 -0
- package/lib/cjs/__generated__/popover.props.js +0 -3
- package/lib/cjs/__generated__/radio-group.props.js +1302 -0
- package/lib/cjs/__generated__/select.props.js +2982 -0
- package/lib/cjs/__generated__/sheet.props.js +0 -11
- package/lib/cjs/__generated__/switch.props.js +870 -0
- package/lib/cjs/__generated__/tabs.props.js +428 -5
- package/lib/cjs/__generated__/tooltip.props.js +0 -2
- package/lib/cjs/accordion.js +11 -4
- package/lib/cjs/accordion.ws.js +85 -71
- package/lib/cjs/{textarea.js → checkbox.js} +9 -6
- package/lib/cjs/checkbox.ws.js +172 -0
- package/lib/cjs/collapsible.ws.js +4 -1
- package/lib/cjs/components.js +27 -14
- package/lib/cjs/dialog.ws.js +17 -17
- package/lib/cjs/hooks.js +5 -1
- package/lib/cjs/label.ws.js +1 -1
- package/lib/cjs/metas.js +29 -14
- package/lib/cjs/navigation-menu.js +107 -0
- package/lib/cjs/navigation-menu.ws.js +513 -0
- package/lib/cjs/popover.ws.js +12 -9
- package/lib/cjs/props.js +27 -14
- package/lib/cjs/{button.js → radio-group.js} +10 -8
- package/lib/cjs/radio-group.ws.js +188 -0
- package/lib/cjs/select.js +81 -0
- package/lib/cjs/select.ws.js +349 -0
- package/lib/cjs/sheet.ws.js +87 -176
- package/lib/cjs/{input.js → switch.js} +8 -9
- package/lib/cjs/switch.ws.js +171 -0
- package/lib/cjs/tabs.js +2 -3
- package/lib/cjs/tabs.ws.js +13 -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 +11 -8
- package/lib/collapsible.ws.js +4 -1
- package/lib/components.js +44 -22
- package/lib/dialog.ws.js +17 -17
- package/lib/hooks.js +5 -1
- package/lib/label.ws.js +1 -1
- package/lib/metas.js +58 -24
- package/lib/navigation-menu.js +85 -0
- package/lib/navigation-menu.ws.js +500 -0
- package/lib/popover.ws.js +12 -9
- package/lib/props.js +56 -24
- package/lib/radio-group.js +11 -0
- package/lib/radio-group.ws.js +170 -0
- package/lib/select.js +73 -0
- package/lib/select.ws.js +337 -0
- package/lib/sheet.ws.js +88 -194
- package/lib/switch.js +7 -0
- package/lib/switch.ws.js +143 -0
- package/lib/tabs.js +3 -5
- package/lib/tabs.ws.js +14 -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 +11 -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.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 +12 -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 +0 -5
- package/src/__generated__/button.props.ts +0 -21
- package/src/__generated__/checkbox.props.ts +948 -0
- package/src/__generated__/collapsible.props.ts +0 -2
- package/src/__generated__/dialog.props.ts +0 -11
- package/src/__generated__/label.props.ts +0 -1
- package/src/__generated__/navigation-menu.props.ts +2349 -0
- package/src/__generated__/popover.props.ts +0 -3
- package/src/__generated__/radio-group.props.ts +1429 -0
- package/src/__generated__/select.props.ts +3304 -0
- package/src/__generated__/sheet.props.ts +0 -11
- package/src/__generated__/switch.props.ts +948 -0
- package/src/__generated__/tabs.props.ts +477 -4
- package/src/__generated__/tooltip.props.ts +0 -2
- package/src/accordion.tsx +14 -7
- package/src/accordion.ws.ts +85 -70
- package/src/{textarea.stories.ts → checkbox.stories.ts} +6 -11
- package/src/checkbox.tsx +22 -0
- package/src/checkbox.ws.ts +151 -0
- package/src/collapsible.ws.ts +4 -1
- package/src/components.ts +25 -12
- package/src/dialog.ws.tsx +15 -16
- package/src/hooks.ts +4 -0
- package/src/label.ws.ts +1 -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 +523 -0
- package/src/popover.ws.tsx +12 -9
- 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 +174 -0
- package/src/select.stories.tsx +21 -0
- package/src/select.tsx +107 -0
- package/src/select.ws.ts +347 -0
- package/src/sheet.ws.tsx +89 -209
- package/src/{button.stories.ts → switch.stories.ts} +6 -19
- package/src/switch.tsx +10 -0
- package/src/switch.ws.ts +143 -0
- package/src/tabs.tsx +4 -17
- package/src/tabs.ws.ts +17 -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 +11 -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/lib/sheet.ws.js
CHANGED
|
@@ -1,97 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HamburgerMenuIcon,
|
|
3
|
-
TriggerIcon,
|
|
4
|
-
ContentIcon,
|
|
5
|
-
OverlayIcon,
|
|
6
|
-
HeadingIcon,
|
|
7
|
-
TextIcon,
|
|
8
|
-
ButtonElementIcon
|
|
9
|
-
} from "@webstudio-is/icons/svg";
|
|
10
|
-
import {
|
|
11
|
-
} from "@webstudio-is/react-sdk";
|
|
1
|
+
import { HamburgerMenuIcon } from "@webstudio-is/icons/svg";
|
|
12
2
|
import * as tc from "./theme/tailwind-classes";
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
propsSheetContent,
|
|
16
|
-
propsSheetTrigger,
|
|
17
|
-
propsSheetOverlay,
|
|
18
|
-
propsSheetClose,
|
|
19
|
-
propsSheetTitle,
|
|
20
|
-
propsSheetDescription
|
|
21
|
-
} from "./__generated__/sheet.props";
|
|
22
|
-
import { div, nav, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
|
|
23
|
-
import { template as buttonTemplate } from "./button.ws";
|
|
24
|
-
const contentPresetStyle = {
|
|
25
|
-
div,
|
|
26
|
-
nav
|
|
27
|
-
};
|
|
28
|
-
const presetStyle = {
|
|
29
|
-
div
|
|
30
|
-
};
|
|
31
|
-
const buttonPresetStyle = {
|
|
32
|
-
button
|
|
33
|
-
};
|
|
34
|
-
const titlePresetStyle = {
|
|
35
|
-
h2
|
|
36
|
-
};
|
|
37
|
-
const descriptionPresetStyle = {
|
|
38
|
-
p
|
|
39
|
-
};
|
|
40
|
-
const metaSheetTrigger = {
|
|
41
|
-
category: "hidden",
|
|
42
|
-
type: "container",
|
|
43
|
-
icon: TriggerIcon,
|
|
44
|
-
stylable: false,
|
|
45
|
-
detachable: false
|
|
46
|
-
};
|
|
47
|
-
const metaSheetContent = {
|
|
48
|
-
category: "hidden",
|
|
49
|
-
type: "container",
|
|
50
|
-
icon: ContentIcon,
|
|
51
|
-
detachable: false,
|
|
52
|
-
presetStyle: contentPresetStyle,
|
|
53
|
-
states: [
|
|
54
|
-
{ selector: "[data-side=top]", label: "Top Side" },
|
|
55
|
-
{ selector: "[data-side=right]", label: "Right Side" },
|
|
56
|
-
{ selector: "[data-side=bottom]", label: "Bottom Side" },
|
|
57
|
-
{ selector: "[data-side=left]", label: "Left Side" }
|
|
58
|
-
]
|
|
59
|
-
};
|
|
60
|
-
const metaSheetOverlay = {
|
|
61
|
-
category: "hidden",
|
|
62
|
-
type: "container",
|
|
63
|
-
presetStyle,
|
|
64
|
-
icon: OverlayIcon,
|
|
65
|
-
detachable: false
|
|
66
|
-
};
|
|
67
|
-
const metaSheetTitle = {
|
|
68
|
-
category: "hidden",
|
|
69
|
-
type: "container",
|
|
70
|
-
presetStyle: titlePresetStyle,
|
|
71
|
-
icon: HeadingIcon
|
|
72
|
-
};
|
|
73
|
-
const metaSheetDescription = {
|
|
74
|
-
category: "hidden",
|
|
75
|
-
type: "container",
|
|
76
|
-
presetStyle: descriptionPresetStyle,
|
|
77
|
-
icon: TextIcon
|
|
78
|
-
};
|
|
79
|
-
const metaSheetClose = {
|
|
80
|
-
category: "hidden",
|
|
81
|
-
type: "container",
|
|
82
|
-
presetStyle: buttonPresetStyle,
|
|
83
|
-
icon: ButtonElementIcon
|
|
84
|
-
};
|
|
85
|
-
const metaSheet = {
|
|
3
|
+
import { getButtonStyles } from "./theme/styles";
|
|
4
|
+
const meta = {
|
|
86
5
|
category: "radix",
|
|
6
|
+
order: 1,
|
|
87
7
|
type: "container",
|
|
88
8
|
icon: HamburgerMenuIcon,
|
|
89
|
-
order: 15,
|
|
90
9
|
stylable: false,
|
|
91
10
|
template: [
|
|
92
11
|
{
|
|
93
12
|
type: "instance",
|
|
94
|
-
component: "
|
|
13
|
+
component: "Dialog",
|
|
14
|
+
label: "Sheet",
|
|
95
15
|
dataSources: {
|
|
96
16
|
sheetOpen: { type: "variable", initialValue: false }
|
|
97
17
|
},
|
|
@@ -112,32 +32,35 @@ const metaSheet = {
|
|
|
112
32
|
children: [
|
|
113
33
|
{
|
|
114
34
|
type: "instance",
|
|
115
|
-
component: "
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
35
|
+
component: "DialogTrigger",
|
|
36
|
+
label: "Sheet Trigger",
|
|
37
|
+
children: [
|
|
38
|
+
{
|
|
39
|
+
type: "instance",
|
|
40
|
+
component: "Button",
|
|
41
|
+
styles: getButtonStyles("ghost", "icon"),
|
|
42
|
+
children: [
|
|
43
|
+
{
|
|
44
|
+
type: "instance",
|
|
45
|
+
component: "HtmlEmbed",
|
|
46
|
+
label: "Hamburger Menu Svg",
|
|
47
|
+
props: [
|
|
48
|
+
{
|
|
49
|
+
type: "string",
|
|
50
|
+
name: "code",
|
|
51
|
+
value: HamburgerMenuIcon
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
children: []
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
]
|
|
137
59
|
},
|
|
138
60
|
{
|
|
139
61
|
type: "instance",
|
|
140
|
-
component: "
|
|
62
|
+
component: "DialogOverlay",
|
|
63
|
+
label: "Sheet Overlay",
|
|
141
64
|
/**
|
|
142
65
|
* fixed inset-0 z-50 bg-background/80 backdrop-blur-sm
|
|
143
66
|
* flex
|
|
@@ -156,7 +79,8 @@ const metaSheet = {
|
|
|
156
79
|
children: [
|
|
157
80
|
{
|
|
158
81
|
type: "instance",
|
|
159
|
-
component: "
|
|
82
|
+
component: "DialogContent",
|
|
83
|
+
label: "Sheet Content",
|
|
160
84
|
/**
|
|
161
85
|
* fixed w-full z-50
|
|
162
86
|
* grid gap-4 max-w-lg
|
|
@@ -174,71 +98,81 @@ const metaSheet = {
|
|
|
174
98
|
tc.p(6),
|
|
175
99
|
tc.shadow("lg"),
|
|
176
100
|
tc.relative(),
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
)
|
|
181
|
-
tc.state(
|
|
182
|
-
[tc.ml("auto"), tc.maxW("sm"), tc.grow()].flat(),
|
|
183
|
-
"[data-side=right]"
|
|
184
|
-
),
|
|
185
|
-
tc.state([tc.mb("auto")].flat(), "[data-side=top]"),
|
|
186
|
-
tc.state([tc.mt("auto")].flat(), "[data-side=bottom]")
|
|
101
|
+
// side=left
|
|
102
|
+
tc.mr("auto"),
|
|
103
|
+
tc.maxW("sm"),
|
|
104
|
+
tc.grow()
|
|
187
105
|
].flat(),
|
|
188
106
|
children: [
|
|
189
107
|
{
|
|
190
108
|
type: "instance",
|
|
191
109
|
component: "Box",
|
|
192
|
-
label: "
|
|
193
|
-
|
|
110
|
+
label: "Navigation",
|
|
111
|
+
props: [
|
|
112
|
+
{ name: "tag", type: "string", value: "nav" },
|
|
113
|
+
{ name: "role", type: "string", value: "navigation" }
|
|
114
|
+
],
|
|
194
115
|
children: [
|
|
195
116
|
{
|
|
196
117
|
type: "instance",
|
|
197
|
-
component: "
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
**/
|
|
201
|
-
styles: [
|
|
202
|
-
tc.my(0),
|
|
203
|
-
tc.leading("none"),
|
|
204
|
-
tc.text("lg"),
|
|
205
|
-
tc.tracking("tight")
|
|
206
|
-
].flat(),
|
|
118
|
+
component: "Box",
|
|
119
|
+
label: "Sheet Header",
|
|
120
|
+
styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
|
|
207
121
|
children: [
|
|
208
122
|
{
|
|
209
|
-
type: "
|
|
210
|
-
|
|
123
|
+
type: "instance",
|
|
124
|
+
component: "DialogTitle",
|
|
125
|
+
label: "Sheet Title",
|
|
126
|
+
/**
|
|
127
|
+
* text-lg leading-none tracking-tight
|
|
128
|
+
**/
|
|
129
|
+
styles: [
|
|
130
|
+
tc.my(0),
|
|
131
|
+
tc.leading("none"),
|
|
132
|
+
tc.text("lg"),
|
|
133
|
+
tc.tracking("tight")
|
|
134
|
+
].flat(),
|
|
135
|
+
children: [
|
|
136
|
+
{
|
|
137
|
+
type: "text",
|
|
138
|
+
value: "Sheet Title"
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: "instance",
|
|
144
|
+
component: "DialogDescription",
|
|
145
|
+
label: "Sheet Description",
|
|
146
|
+
/**
|
|
147
|
+
* text-sm text-muted-foreground
|
|
148
|
+
**/
|
|
149
|
+
styles: [
|
|
150
|
+
tc.my(0),
|
|
151
|
+
tc.text("sm"),
|
|
152
|
+
tc.text("mutedForeground")
|
|
153
|
+
].flat(),
|
|
154
|
+
children: [
|
|
155
|
+
{
|
|
156
|
+
type: "text",
|
|
157
|
+
value: "Sheet description text you can edit"
|
|
158
|
+
}
|
|
159
|
+
]
|
|
211
160
|
}
|
|
212
161
|
]
|
|
213
162
|
},
|
|
214
163
|
{
|
|
215
164
|
type: "instance",
|
|
216
|
-
component: "
|
|
217
|
-
/**
|
|
218
|
-
* text-sm text-muted-foreground
|
|
219
|
-
**/
|
|
220
|
-
styles: [
|
|
221
|
-
tc.my(0),
|
|
222
|
-
tc.text("sm"),
|
|
223
|
-
tc.text("mutedForeground")
|
|
224
|
-
].flat(),
|
|
165
|
+
component: "Text",
|
|
225
166
|
children: [
|
|
226
|
-
{
|
|
227
|
-
type: "text",
|
|
228
|
-
value: "sheet description text you can edit"
|
|
229
|
-
}
|
|
167
|
+
{ type: "text", value: "The text you can edit" }
|
|
230
168
|
]
|
|
231
169
|
}
|
|
232
170
|
]
|
|
233
171
|
},
|
|
234
172
|
{
|
|
235
173
|
type: "instance",
|
|
236
|
-
component: "
|
|
237
|
-
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
type: "instance",
|
|
241
|
-
component: "SheetClose",
|
|
174
|
+
component: "DialogClose",
|
|
175
|
+
label: "Close Button",
|
|
242
176
|
/**
|
|
243
177
|
* absolute right-4 top-4
|
|
244
178
|
* rounded-sm opacity-70
|
|
@@ -273,46 +207,6 @@ const metaSheet = {
|
|
|
273
207
|
}
|
|
274
208
|
]
|
|
275
209
|
};
|
|
276
|
-
const propsMetaSheet = {
|
|
277
|
-
props: propsSheet,
|
|
278
|
-
initialProps: ["open", "modal"]
|
|
279
|
-
};
|
|
280
|
-
const propsMetaSheetTrigger = {
|
|
281
|
-
props: propsSheetTrigger
|
|
282
|
-
};
|
|
283
|
-
const propsMetaSheetContent = {
|
|
284
|
-
props: propsSheetContent,
|
|
285
|
-
initialProps: ["side", "role", "tag"]
|
|
286
|
-
};
|
|
287
|
-
const propsMetaSheetOverlay = {
|
|
288
|
-
props: propsSheetOverlay,
|
|
289
|
-
initialProps: []
|
|
290
|
-
};
|
|
291
|
-
const propsMetaSheetClose = {
|
|
292
|
-
props: propsSheetClose,
|
|
293
|
-
initialProps: []
|
|
294
|
-
};
|
|
295
|
-
const propsMetaSheetTitle = {
|
|
296
|
-
props: propsSheetTitle,
|
|
297
|
-
initialProps: []
|
|
298
|
-
};
|
|
299
|
-
const propsMetaSheetDescription = {
|
|
300
|
-
props: propsSheetDescription,
|
|
301
|
-
initialProps: []
|
|
302
|
-
};
|
|
303
210
|
export {
|
|
304
|
-
|
|
305
|
-
metaSheetClose,
|
|
306
|
-
metaSheetContent,
|
|
307
|
-
metaSheetDescription,
|
|
308
|
-
metaSheetOverlay,
|
|
309
|
-
metaSheetTitle,
|
|
310
|
-
metaSheetTrigger,
|
|
311
|
-
propsMetaSheet,
|
|
312
|
-
propsMetaSheetClose,
|
|
313
|
-
propsMetaSheetContent,
|
|
314
|
-
propsMetaSheetDescription,
|
|
315
|
-
propsMetaSheetOverlay,
|
|
316
|
-
propsMetaSheetTitle,
|
|
317
|
-
propsMetaSheetTrigger
|
|
211
|
+
meta
|
|
318
212
|
};
|
package/lib/switch.js
ADDED
package/lib/switch.ws.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { SwitchIcon, TriggerIcon } from "@webstudio-is/icons/svg";
|
|
2
|
+
import {
|
|
3
|
+
defaultStates
|
|
4
|
+
} from "@webstudio-is/react-sdk";
|
|
5
|
+
import { button, span } from "@webstudio-is/react-sdk/css-normalize";
|
|
6
|
+
import * as tc from "./theme/tailwind-classes";
|
|
7
|
+
import { buttonReset } from "./theme/styles";
|
|
8
|
+
import { propsSwitch, propsSwitchThumb } from "./__generated__/switch.props";
|
|
9
|
+
const metaSwitch = {
|
|
10
|
+
category: "radix",
|
|
11
|
+
order: 11,
|
|
12
|
+
type: "container",
|
|
13
|
+
icon: SwitchIcon,
|
|
14
|
+
states: [
|
|
15
|
+
...defaultStates,
|
|
16
|
+
{
|
|
17
|
+
label: "Checked",
|
|
18
|
+
selector: "[data-state=checked]",
|
|
19
|
+
category: "component-states"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "Unchecked",
|
|
23
|
+
selector: "[data-state=unchecked]",
|
|
24
|
+
category: "component-states"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
presetStyle: {
|
|
28
|
+
button: [button, buttonReset].flat()
|
|
29
|
+
},
|
|
30
|
+
template: [
|
|
31
|
+
{
|
|
32
|
+
type: "instance",
|
|
33
|
+
component: "Switch",
|
|
34
|
+
dataSources: {
|
|
35
|
+
switchChecked: { type: "variable", initialValue: false }
|
|
36
|
+
},
|
|
37
|
+
props: [
|
|
38
|
+
{
|
|
39
|
+
name: "checked",
|
|
40
|
+
type: "dataSource",
|
|
41
|
+
dataSourceName: "switchChecked"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "onCheckedChange",
|
|
45
|
+
type: "action",
|
|
46
|
+
value: [
|
|
47
|
+
{
|
|
48
|
+
type: "execute",
|
|
49
|
+
args: ["checked"],
|
|
50
|
+
code: `switchChecked = checked`
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
// peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors
|
|
56
|
+
// focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background
|
|
57
|
+
// disabled:cursor-not-allowed disabled:opacity-50
|
|
58
|
+
// data-[state=checked]:bg-primary
|
|
59
|
+
// data-[state=unchecked]:bg-input
|
|
60
|
+
styles: [
|
|
61
|
+
// We are not supporting peer like styles yet
|
|
62
|
+
tc.inlineFlex(),
|
|
63
|
+
tc.property("height", "24px"),
|
|
64
|
+
tc.property("width", "44px"),
|
|
65
|
+
tc.shrink(0),
|
|
66
|
+
tc.cursor("pointer"),
|
|
67
|
+
tc.items("center"),
|
|
68
|
+
tc.rounded("full"),
|
|
69
|
+
tc.border(2),
|
|
70
|
+
tc.border("transparent"),
|
|
71
|
+
tc.transition("all"),
|
|
72
|
+
tc.focusVisible(
|
|
73
|
+
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
74
|
+
),
|
|
75
|
+
tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat()),
|
|
76
|
+
tc.state([tc.bg("primary")].flat(), "[data-state=checked]"),
|
|
77
|
+
tc.state([tc.bg("input")].flat(), "[data-state=unchecked]")
|
|
78
|
+
].flat(),
|
|
79
|
+
children: [
|
|
80
|
+
{
|
|
81
|
+
type: "instance",
|
|
82
|
+
component: "SwitchThumb",
|
|
83
|
+
// pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform
|
|
84
|
+
// data-[state=checked]:translate-x-5
|
|
85
|
+
// data-[state=unchecked]:translate-x-0
|
|
86
|
+
styles: [
|
|
87
|
+
tc.pointerEvents("none"),
|
|
88
|
+
tc.block(),
|
|
89
|
+
tc.h(5),
|
|
90
|
+
tc.w(5),
|
|
91
|
+
tc.rounded("full"),
|
|
92
|
+
tc.bg("background"),
|
|
93
|
+
tc.shadow("lg"),
|
|
94
|
+
tc.transition("transform"),
|
|
95
|
+
tc.state(
|
|
96
|
+
[tc.property("transform", "translateX(20px)")].flat(),
|
|
97
|
+
"[data-state=checked]"
|
|
98
|
+
),
|
|
99
|
+
tc.state(
|
|
100
|
+
[tc.property("transform", "translateX(0px)")].flat(),
|
|
101
|
+
"[data-state=unchecked]"
|
|
102
|
+
)
|
|
103
|
+
].flat(),
|
|
104
|
+
children: []
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
};
|
|
110
|
+
const metaSwitchThumb = {
|
|
111
|
+
category: "hidden",
|
|
112
|
+
type: "container",
|
|
113
|
+
icon: TriggerIcon,
|
|
114
|
+
states: [
|
|
115
|
+
...defaultStates,
|
|
116
|
+
{
|
|
117
|
+
label: "Checked",
|
|
118
|
+
selector: "[data-state=checked]",
|
|
119
|
+
category: "component-states"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
label: "Unchecked",
|
|
123
|
+
selector: "[data-state=unchecked]",
|
|
124
|
+
category: "component-states"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
presetStyle: {
|
|
128
|
+
span
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const propsMetaSwitch = {
|
|
132
|
+
props: propsSwitch,
|
|
133
|
+
initialProps: ["id", "checked", "name", "required"]
|
|
134
|
+
};
|
|
135
|
+
const propsMetaSwitchThumb = {
|
|
136
|
+
props: propsSwitchThumb
|
|
137
|
+
};
|
|
138
|
+
export {
|
|
139
|
+
metaSwitch,
|
|
140
|
+
metaSwitchThumb,
|
|
141
|
+
propsMetaSwitch,
|
|
142
|
+
propsMetaSwitchThumb
|
|
143
|
+
};
|
package/lib/tabs.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import {
|
|
3
|
-
forwardRef
|
|
4
|
-
Children
|
|
3
|
+
forwardRef
|
|
5
4
|
} from "react";
|
|
6
5
|
import { Root, List, Trigger, Content } from "@radix-ui/react-tabs";
|
|
7
6
|
import {
|
|
@@ -10,10 +9,9 @@ import {
|
|
|
10
9
|
} from "@webstudio-is/react-sdk";
|
|
11
10
|
const Tabs = Root;
|
|
12
11
|
const TabsList = List;
|
|
13
|
-
const TabsTrigger = forwardRef(({ value,
|
|
14
|
-
const firstChild = Children.toArray(children)[0];
|
|
12
|
+
const TabsTrigger = forwardRef(({ value, ...props }, ref) => {
|
|
15
13
|
const index = getIndexWithinAncestorFromComponentProps(props);
|
|
16
|
-
return /* @__PURE__ */ jsx(Trigger, { ref, value: value ?? index,
|
|
14
|
+
return /* @__PURE__ */ jsx(Trigger, { ref, value: value ?? index, ...props });
|
|
17
15
|
});
|
|
18
16
|
const TabsContent = forwardRef(({ value, ...props }, ref) => {
|
|
19
17
|
const index = getIndexWithinAncestorFromComponentProps(props);
|
package/lib/tabs.ws.js
CHANGED
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
TabsIcon,
|
|
5
5
|
TriggerIcon
|
|
6
6
|
} from "@webstudio-is/icons/svg";
|
|
7
|
-
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
7
|
+
import { button, div } from "@webstudio-is/react-sdk/css-normalize";
|
|
8
8
|
import * as tc from "./theme/tailwind-classes";
|
|
9
|
+
import { buttonReset } from "./theme/styles";
|
|
9
10
|
import {
|
|
10
11
|
propsTabs,
|
|
11
12
|
propsTabsList,
|
|
@@ -43,6 +44,7 @@ const tabsContentStyles = [
|
|
|
43
44
|
].flat();
|
|
44
45
|
const metaTabs = {
|
|
45
46
|
category: "radix",
|
|
47
|
+
order: 2,
|
|
46
48
|
type: "container",
|
|
47
49
|
icon: TabsIcon,
|
|
48
50
|
presetStyle,
|
|
@@ -82,26 +84,14 @@ const metaTabs = {
|
|
|
82
84
|
{
|
|
83
85
|
type: "instance",
|
|
84
86
|
component: "TabsTrigger",
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
type: "instance",
|
|
88
|
-
component: "Button",
|
|
89
|
-
styles: tabsTriggerStyles,
|
|
90
|
-
children: [{ type: "text", value: "Account" }]
|
|
91
|
-
}
|
|
92
|
-
]
|
|
87
|
+
styles: tabsTriggerStyles,
|
|
88
|
+
children: [{ type: "text", value: "Account" }]
|
|
93
89
|
},
|
|
94
90
|
{
|
|
95
91
|
type: "instance",
|
|
96
92
|
component: "TabsTrigger",
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
type: "instance",
|
|
100
|
-
component: "Button",
|
|
101
|
-
styles: tabsTriggerStyles,
|
|
102
|
-
children: [{ type: "text", value: "Password" }]
|
|
103
|
-
}
|
|
104
|
-
]
|
|
93
|
+
styles: tabsTriggerStyles,
|
|
94
|
+
children: [{ type: "text", value: "Password" }]
|
|
105
95
|
}
|
|
106
96
|
]
|
|
107
97
|
},
|
|
@@ -137,7 +127,11 @@ const metaTabsTrigger = {
|
|
|
137
127
|
icon: TriggerIcon,
|
|
138
128
|
requiredAncestors: ["TabsList"],
|
|
139
129
|
invalidAncestors: ["TabsTrigger"],
|
|
140
|
-
indexWithinAncestor: "Tabs"
|
|
130
|
+
indexWithinAncestor: "Tabs",
|
|
131
|
+
label: "Tab Trigger",
|
|
132
|
+
presetStyle: {
|
|
133
|
+
button: [button, buttonReset].flat()
|
|
134
|
+
}
|
|
141
135
|
};
|
|
142
136
|
const metaTabsContent = {
|
|
143
137
|
category: "hidden",
|
|
@@ -145,7 +139,8 @@ const metaTabsContent = {
|
|
|
145
139
|
icon: ContentIcon,
|
|
146
140
|
requiredAncestors: ["Tabs"],
|
|
147
141
|
indexWithinAncestor: "Tabs",
|
|
148
|
-
presetStyle
|
|
142
|
+
presetStyle,
|
|
143
|
+
label: "Tab Content"
|
|
149
144
|
};
|
|
150
145
|
const propsMetaTabs = {
|
|
151
146
|
props: propsTabs
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as tc from "./tailwind-classes";
|
|
2
|
+
const getButtonStyles = (variant, size = "default") => {
|
|
3
|
+
const styles = [
|
|
4
|
+
// 'inline-flex items-center justify-center rounded-md text-sm font-medium
|
|
5
|
+
// ring-offset-background transition-colors
|
|
6
|
+
// focus-visible:outline-none focus-visible:ring-2
|
|
7
|
+
// focus-visible:ring-ring focus-visible:ring-offset-2
|
|
8
|
+
// disabled:pointer-events-none disabled:opacity-50'
|
|
9
|
+
tc.border(0),
|
|
10
|
+
tc.bg("transparent"),
|
|
11
|
+
tc.inlineFlex(),
|
|
12
|
+
tc.items("center"),
|
|
13
|
+
tc.justify("center"),
|
|
14
|
+
tc.rounded("md"),
|
|
15
|
+
tc.text("sm"),
|
|
16
|
+
tc.font("medium"),
|
|
17
|
+
tc.focusVisible(
|
|
18
|
+
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
19
|
+
),
|
|
20
|
+
tc.state([tc.pointerEvents("none"), tc.opacity(50)].flat(), ":disabled")
|
|
21
|
+
].flat();
|
|
22
|
+
let variantStyles = [];
|
|
23
|
+
if (variant === "ghost") {
|
|
24
|
+
variantStyles = [
|
|
25
|
+
tc.state([tc.bg("accent"), tc.text("accentForeground")].flat(), ":hover")
|
|
26
|
+
].flat();
|
|
27
|
+
}
|
|
28
|
+
if (variant === "outline") {
|
|
29
|
+
variantStyles = [
|
|
30
|
+
tc.border(),
|
|
31
|
+
tc.border("input"),
|
|
32
|
+
tc.bg("background"),
|
|
33
|
+
tc.state(
|
|
34
|
+
[tc.bg("accent", 90), tc.text("accentForeground")].flat(),
|
|
35
|
+
":hover"
|
|
36
|
+
)
|
|
37
|
+
].flat();
|
|
38
|
+
}
|
|
39
|
+
let sizeStyles = [];
|
|
40
|
+
if (size === "icon") {
|
|
41
|
+
sizeStyles = [tc.h(10), tc.w(10)].flat();
|
|
42
|
+
}
|
|
43
|
+
if (size === "sm") {
|
|
44
|
+
sizeStyles = [tc.h(10), tc.px(3)].flat();
|
|
45
|
+
}
|
|
46
|
+
if (size === "default") {
|
|
47
|
+
sizeStyles = [tc.h(10), tc.px(4), tc.py(2)].flat();
|
|
48
|
+
}
|
|
49
|
+
return [...styles, ...variantStyles, ...sizeStyles];
|
|
50
|
+
};
|
|
51
|
+
const buttonReset = [
|
|
52
|
+
{
|
|
53
|
+
property: "backgroundColor",
|
|
54
|
+
value: { type: "keyword", value: "transparent" }
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
property: "backgroundImage",
|
|
58
|
+
value: { type: "keyword", value: "none" }
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
property: "cursor",
|
|
62
|
+
value: { type: "keyword", value: "pointer" }
|
|
63
|
+
},
|
|
64
|
+
tc.border(0),
|
|
65
|
+
tc.p(0)
|
|
66
|
+
].flat();
|
|
67
|
+
export {
|
|
68
|
+
buttonReset,
|
|
69
|
+
getButtonStyles
|
|
70
|
+
};
|