@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/src/accordion.ws.ts
CHANGED
|
@@ -4,15 +4,18 @@ import {
|
|
|
4
4
|
HeaderIcon,
|
|
5
5
|
TriggerIcon,
|
|
6
6
|
ContentIcon,
|
|
7
|
+
ChevronDownIcon,
|
|
7
8
|
} from "@webstudio-is/icons/svg";
|
|
8
9
|
import type {
|
|
9
10
|
EmbedTemplateStyleDecl,
|
|
10
11
|
PresetStyle,
|
|
11
12
|
WsComponentMeta,
|
|
12
13
|
WsComponentPropsMeta,
|
|
14
|
+
WsEmbedTemplate,
|
|
13
15
|
} from "@webstudio-is/react-sdk";
|
|
14
16
|
import { div, h3, button } from "@webstudio-is/react-sdk/css-normalize";
|
|
15
17
|
import * as tc from "./theme/tailwind-classes";
|
|
18
|
+
import { buttonReset } from "./theme/styles";
|
|
16
19
|
import {
|
|
17
20
|
propsAccordion,
|
|
18
21
|
propsAccordionItem,
|
|
@@ -37,20 +40,73 @@ const presetStyle = {
|
|
|
37
40
|
// border-b
|
|
38
41
|
const accordionItemStyles: EmbedTemplateStyleDecl[] = [tc.borderB()].flat();
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
tc.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
]
|
|
43
|
+
const createAccordionTrigger = ({
|
|
44
|
+
children,
|
|
45
|
+
}: {
|
|
46
|
+
children: WsEmbedTemplate;
|
|
47
|
+
}): WsEmbedTemplate[number] => ({
|
|
48
|
+
type: "instance",
|
|
49
|
+
component: "AccordionHeader",
|
|
50
|
+
// flex
|
|
51
|
+
styles: [tc.flex()].flat(),
|
|
52
|
+
children: [
|
|
53
|
+
{
|
|
54
|
+
type: "instance",
|
|
55
|
+
component: "AccordionTrigger",
|
|
56
|
+
// flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180
|
|
57
|
+
styles: [
|
|
58
|
+
tc.flex(),
|
|
59
|
+
tc.flex(1),
|
|
60
|
+
tc.items("center"),
|
|
61
|
+
tc.justify("between"),
|
|
62
|
+
tc.py(4),
|
|
63
|
+
tc.font("medium"),
|
|
64
|
+
tc.hover([tc.underline()].flat()),
|
|
65
|
+
tc.property("--accordion-trigger-icon-transform", "0deg"),
|
|
66
|
+
tc.state(
|
|
67
|
+
[tc.property("--accordion-trigger-icon-transform", "180deg")],
|
|
68
|
+
"[data-state=open]"
|
|
69
|
+
),
|
|
70
|
+
].flat(),
|
|
71
|
+
children: [
|
|
72
|
+
{
|
|
73
|
+
type: "instance",
|
|
74
|
+
component: "Text",
|
|
75
|
+
children,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "instance",
|
|
79
|
+
component: "Box",
|
|
80
|
+
label: "Icon Container",
|
|
81
|
+
// h-4 w-4 shrink-0 transition-transform duration-200
|
|
82
|
+
styles: [
|
|
83
|
+
tc.property("rotate", "--accordion-trigger-icon-transform"),
|
|
84
|
+
tc.h(4),
|
|
85
|
+
tc.w(4),
|
|
86
|
+
tc.shrink(0),
|
|
87
|
+
tc.transition("all"),
|
|
88
|
+
tc.duration(200),
|
|
89
|
+
].flat(),
|
|
90
|
+
children: [
|
|
91
|
+
{
|
|
92
|
+
type: "instance",
|
|
93
|
+
component: "HtmlEmbed",
|
|
94
|
+
label: "Chevron Icon",
|
|
95
|
+
props: [
|
|
96
|
+
{
|
|
97
|
+
type: "string",
|
|
98
|
+
name: "code",
|
|
99
|
+
value: ChevronDownIcon,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
children: [],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
});
|
|
54
110
|
|
|
55
111
|
// overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down
|
|
56
112
|
// pb-4 pt-0
|
|
@@ -64,6 +120,7 @@ const accordionContentStyles: EmbedTemplateStyleDecl[] = [
|
|
|
64
120
|
|
|
65
121
|
export const metaAccordion: WsComponentMeta = {
|
|
66
122
|
category: "radix",
|
|
123
|
+
order: 3,
|
|
67
124
|
type: "container",
|
|
68
125
|
icon: AccordionIcon,
|
|
69
126
|
presetStyle,
|
|
@@ -95,19 +152,9 @@ export const metaAccordion: WsComponentMeta = {
|
|
|
95
152
|
component: "AccordionItem",
|
|
96
153
|
styles: accordionItemStyles,
|
|
97
154
|
children: [
|
|
98
|
-
{
|
|
99
|
-
type: "
|
|
100
|
-
|
|
101
|
-
styles: accordionHeaderStyles,
|
|
102
|
-
children: [
|
|
103
|
-
{
|
|
104
|
-
type: "instance",
|
|
105
|
-
component: "AccordionTrigger",
|
|
106
|
-
styles: accordionTriggerStyles,
|
|
107
|
-
children: [{ type: "text", value: "Is it accessible?" }],
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
155
|
+
createAccordionTrigger({
|
|
156
|
+
children: [{ type: "text", value: "Is it accessible?" }],
|
|
157
|
+
}),
|
|
111
158
|
{
|
|
112
159
|
type: "instance",
|
|
113
160
|
component: "AccordionContent",
|
|
@@ -127,19 +174,9 @@ export const metaAccordion: WsComponentMeta = {
|
|
|
127
174
|
component: "AccordionItem",
|
|
128
175
|
styles: accordionItemStyles,
|
|
129
176
|
children: [
|
|
130
|
-
{
|
|
131
|
-
type: "
|
|
132
|
-
|
|
133
|
-
styles: accordionHeaderStyles,
|
|
134
|
-
children: [
|
|
135
|
-
{
|
|
136
|
-
type: "instance",
|
|
137
|
-
component: "AccordionTrigger",
|
|
138
|
-
styles: accordionTriggerStyles,
|
|
139
|
-
children: [{ type: "text", value: "Is it styled?" }],
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
},
|
|
177
|
+
createAccordionTrigger({
|
|
178
|
+
children: [{ type: "text", value: "Is it styled?" }],
|
|
179
|
+
}),
|
|
143
180
|
{
|
|
144
181
|
type: "instance",
|
|
145
182
|
component: "AccordionContent",
|
|
@@ -160,19 +197,9 @@ export const metaAccordion: WsComponentMeta = {
|
|
|
160
197
|
component: "AccordionItem",
|
|
161
198
|
styles: accordionItemStyles,
|
|
162
199
|
children: [
|
|
163
|
-
{
|
|
164
|
-
type: "
|
|
165
|
-
|
|
166
|
-
styles: accordionHeaderStyles,
|
|
167
|
-
children: [
|
|
168
|
-
{
|
|
169
|
-
type: "instance",
|
|
170
|
-
component: "AccordionTrigger",
|
|
171
|
-
styles: accordionTriggerStyles,
|
|
172
|
-
children: [{ type: "text", value: "Is it animated?" }],
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
},
|
|
200
|
+
createAccordionTrigger({
|
|
201
|
+
children: [{ type: "text", value: "Is it animated?" }],
|
|
202
|
+
}),
|
|
176
203
|
{
|
|
177
204
|
type: "instance",
|
|
178
205
|
component: "AccordionContent",
|
|
@@ -199,6 +226,7 @@ export const metaAccordionItem: WsComponentMeta = {
|
|
|
199
226
|
requiredAncestors: ["Accordion"],
|
|
200
227
|
indexWithinAncestor: "Accordion",
|
|
201
228
|
presetStyle,
|
|
229
|
+
label: "Item",
|
|
202
230
|
};
|
|
203
231
|
|
|
204
232
|
export const metaAccordionHeader: WsComponentMeta = {
|
|
@@ -210,6 +238,7 @@ export const metaAccordionHeader: WsComponentMeta = {
|
|
|
210
238
|
presetStyle: {
|
|
211
239
|
h3: [h3, tc.my(0)].flat(),
|
|
212
240
|
},
|
|
241
|
+
label: "Item Header",
|
|
213
242
|
};
|
|
214
243
|
|
|
215
244
|
export const metaAccordionTrigger: WsComponentMeta = {
|
|
@@ -219,24 +248,9 @@ export const metaAccordionTrigger: WsComponentMeta = {
|
|
|
219
248
|
requiredAncestors: ["AccordionHeader"],
|
|
220
249
|
detachable: false,
|
|
221
250
|
presetStyle: {
|
|
222
|
-
button: [
|
|
223
|
-
button,
|
|
224
|
-
{
|
|
225
|
-
property: "backgroundColor",
|
|
226
|
-
value: { type: "keyword", value: "transparent" },
|
|
227
|
-
} as const,
|
|
228
|
-
{
|
|
229
|
-
property: "backgroundImage",
|
|
230
|
-
value: { type: "keyword", value: "none" },
|
|
231
|
-
} as const,
|
|
232
|
-
{
|
|
233
|
-
property: "cursor",
|
|
234
|
-
value: { type: "keyword", value: "pointer" },
|
|
235
|
-
} as const,
|
|
236
|
-
tc.px(0),
|
|
237
|
-
tc.border(0),
|
|
238
|
-
].flat(),
|
|
251
|
+
button: [button, buttonReset].flat(),
|
|
239
252
|
},
|
|
253
|
+
label: "Item Trigger",
|
|
240
254
|
};
|
|
241
255
|
|
|
242
256
|
export const metaAccordionContent: WsComponentMeta = {
|
|
@@ -246,6 +260,7 @@ export const metaAccordionContent: WsComponentMeta = {
|
|
|
246
260
|
requiredAncestors: ["AccordionItem"],
|
|
247
261
|
detachable: false,
|
|
248
262
|
presetStyle,
|
|
263
|
+
label: "Item Content",
|
|
249
264
|
};
|
|
250
265
|
|
|
251
266
|
export const propsMetaAccordion: WsComponentPropsMeta = {
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { renderComponentTemplate } from "@webstudio-is/react-sdk";
|
|
3
|
-
import { Textarea as TextareaPrimitive } from "./textarea";
|
|
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 { Checkbox as CheckboxPrimitive } from "./checkbox";
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
|
-
title: "Components/
|
|
11
|
-
component:
|
|
12
|
-
|
|
13
|
-
placeholder: {
|
|
14
|
-
type: "string",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
} satisfies Meta<typeof TextareaPrimitive>;
|
|
10
|
+
title: "Components/Checkbox",
|
|
11
|
+
component: CheckboxPrimitive,
|
|
12
|
+
} satisfies Meta<typeof CheckboxPrimitive>;
|
|
18
13
|
|
|
19
|
-
export const
|
|
14
|
+
export const Checkbox: StoryObj<typeof CheckboxPrimitive> = {
|
|
20
15
|
render: (props) =>
|
|
21
16
|
renderComponentTemplate({
|
|
22
|
-
name: "
|
|
17
|
+
name: "Checkbox",
|
|
23
18
|
props: { ...props },
|
|
24
19
|
components: { ...baseComponents, ...radixComponents },
|
|
25
20
|
metas: { ...baseMetas, ...radixMetas },
|
package/src/checkbox.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
2
|
+
// We can't use .displayName until this is merged https://github.com/styleguidist/react-docgen-typescript/pull/449
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
type ForwardRefExoticComponent,
|
|
6
|
+
type ComponentPropsWithRef,
|
|
7
|
+
forwardRef,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { Root, Indicator } from "@radix-ui/react-checkbox";
|
|
10
|
+
|
|
11
|
+
export const Checkbox = forwardRef<
|
|
12
|
+
HTMLButtonElement,
|
|
13
|
+
// radix checked has complex named type which cannot be parsed
|
|
14
|
+
// cast to boolean
|
|
15
|
+
Omit<ComponentPropsWithRef<typeof Root>, "checked"> & { checked: boolean }
|
|
16
|
+
>((props, ref) => {
|
|
17
|
+
return <Root ref={ref} {...props} />;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const CheckboxIndicator: ForwardRefExoticComponent<
|
|
21
|
+
ComponentPropsWithRef<typeof Indicator>
|
|
22
|
+
> = Indicator;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CheckMarkIcon,
|
|
3
|
+
CheckboxCheckedIcon,
|
|
4
|
+
TriggerIcon,
|
|
5
|
+
} from "@webstudio-is/icons/svg";
|
|
6
|
+
import {
|
|
7
|
+
defaultStates,
|
|
8
|
+
type WsComponentMeta,
|
|
9
|
+
type WsComponentPropsMeta,
|
|
10
|
+
} from "@webstudio-is/react-sdk";
|
|
11
|
+
import { button, span } from "@webstudio-is/react-sdk/css-normalize";
|
|
12
|
+
import * as tc from "./theme/tailwind-classes";
|
|
13
|
+
import { buttonReset } from "./theme/styles";
|
|
14
|
+
import {
|
|
15
|
+
propsCheckbox,
|
|
16
|
+
propsCheckboxIndicator,
|
|
17
|
+
} from "./__generated__/checkbox.props";
|
|
18
|
+
|
|
19
|
+
export const metaCheckbox: WsComponentMeta = {
|
|
20
|
+
category: "radix",
|
|
21
|
+
order: 101,
|
|
22
|
+
type: "container",
|
|
23
|
+
icon: CheckboxCheckedIcon,
|
|
24
|
+
states: [
|
|
25
|
+
...defaultStates,
|
|
26
|
+
{
|
|
27
|
+
label: "Checked",
|
|
28
|
+
selector: "[data-state=checked]",
|
|
29
|
+
category: "component-states",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: "Unchecked",
|
|
33
|
+
selector: "[data-state=unchecked]",
|
|
34
|
+
category: "component-states",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
presetStyle: {
|
|
38
|
+
button: [button, buttonReset].flat(),
|
|
39
|
+
},
|
|
40
|
+
template: [
|
|
41
|
+
{
|
|
42
|
+
type: "instance",
|
|
43
|
+
component: "Label",
|
|
44
|
+
label: "Checkbox Field",
|
|
45
|
+
styles: [tc.flex(), tc.gap(2), tc.items("center")].flat(),
|
|
46
|
+
children: [
|
|
47
|
+
{
|
|
48
|
+
type: "instance",
|
|
49
|
+
component: "Checkbox",
|
|
50
|
+
dataSources: {
|
|
51
|
+
checkboxChecked: { type: "variable", initialValue: false },
|
|
52
|
+
},
|
|
53
|
+
props: [
|
|
54
|
+
{
|
|
55
|
+
name: "checked",
|
|
56
|
+
type: "dataSource",
|
|
57
|
+
dataSourceName: "checkboxChecked",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "onCheckedChange",
|
|
61
|
+
type: "action",
|
|
62
|
+
value: [
|
|
63
|
+
{
|
|
64
|
+
type: "execute",
|
|
65
|
+
args: ["checked"],
|
|
66
|
+
code: `checkboxChecked = checked`,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
// peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background
|
|
72
|
+
// focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
|
|
73
|
+
// disabled:cursor-not-allowed disabled:opacity-50
|
|
74
|
+
// data-[state=checked]:bg-primary
|
|
75
|
+
// data-[state=checked]:text-primary-foreground",
|
|
76
|
+
styles: [
|
|
77
|
+
// We are not supporting peer like styles yet
|
|
78
|
+
tc.h(4),
|
|
79
|
+
tc.w(4),
|
|
80
|
+
tc.shrink(0),
|
|
81
|
+
tc.rounded("sm"),
|
|
82
|
+
tc.border(),
|
|
83
|
+
tc.border("primary"),
|
|
84
|
+
tc.focusVisible(
|
|
85
|
+
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
86
|
+
),
|
|
87
|
+
tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat()),
|
|
88
|
+
tc.state(
|
|
89
|
+
[tc.bg("primary"), tc.text("primaryForeground")].flat(),
|
|
90
|
+
"[data-state=checked]"
|
|
91
|
+
),
|
|
92
|
+
].flat(),
|
|
93
|
+
children: [
|
|
94
|
+
{
|
|
95
|
+
type: "instance",
|
|
96
|
+
component: "CheckboxIndicator",
|
|
97
|
+
// flex items-center justify-center text-current
|
|
98
|
+
styles: [
|
|
99
|
+
tc.flex(),
|
|
100
|
+
tc.items("center"),
|
|
101
|
+
tc.justify("center"),
|
|
102
|
+
tc.text("current"),
|
|
103
|
+
].flat(),
|
|
104
|
+
children: [
|
|
105
|
+
{
|
|
106
|
+
type: "instance",
|
|
107
|
+
component: "HtmlEmbed",
|
|
108
|
+
label: "Indicator Icon",
|
|
109
|
+
props: [
|
|
110
|
+
{
|
|
111
|
+
type: "string",
|
|
112
|
+
name: "code",
|
|
113
|
+
value: CheckMarkIcon,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
children: [],
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: "instance",
|
|
124
|
+
component: "Text",
|
|
125
|
+
label: "Checkbox Label",
|
|
126
|
+
props: [{ name: "tag", type: "string", value: "span" }],
|
|
127
|
+
children: [{ type: "text", value: "Checkbox" }],
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const metaCheckboxIndicator: WsComponentMeta = {
|
|
135
|
+
category: "hidden",
|
|
136
|
+
type: "container",
|
|
137
|
+
icon: TriggerIcon,
|
|
138
|
+
states: defaultStates,
|
|
139
|
+
presetStyle: {
|
|
140
|
+
span,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const propsMetaCheckbox: WsComponentPropsMeta = {
|
|
145
|
+
props: propsCheckbox,
|
|
146
|
+
initialProps: ["id", "checked", "name", "required"],
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const propsMetaCheckboxIndicator: WsComponentPropsMeta = {
|
|
150
|
+
props: propsCheckboxIndicator,
|
|
151
|
+
};
|
package/src/collapsible.ws.ts
CHANGED
|
@@ -8,12 +8,13 @@ import type {
|
|
|
8
8
|
WsComponentMeta,
|
|
9
9
|
WsComponentPropsMeta,
|
|
10
10
|
} from "@webstudio-is/react-sdk";
|
|
11
|
+
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
11
12
|
import {
|
|
12
13
|
propsCollapsible,
|
|
13
14
|
propsCollapsibleContent,
|
|
14
15
|
propsCollapsibleTrigger,
|
|
15
16
|
} from "./__generated__/collapsible.props";
|
|
16
|
-
import {
|
|
17
|
+
import { getButtonStyles } from "./theme/styles";
|
|
17
18
|
|
|
18
19
|
const presetStyle = {
|
|
19
20
|
div,
|
|
@@ -21,6 +22,7 @@ const presetStyle = {
|
|
|
21
22
|
|
|
22
23
|
export const metaCollapsible: WsComponentMeta = {
|
|
23
24
|
category: "radix",
|
|
25
|
+
order: 5,
|
|
24
26
|
type: "container",
|
|
25
27
|
presetStyle,
|
|
26
28
|
icon: CollapsibleIcon,
|
|
@@ -53,6 +55,7 @@ export const metaCollapsible: WsComponentMeta = {
|
|
|
53
55
|
{
|
|
54
56
|
type: "instance",
|
|
55
57
|
component: "Button",
|
|
58
|
+
styles: getButtonStyles("outline"),
|
|
56
59
|
children: [{ type: "text", value: "Click to toggle content" }],
|
|
57
60
|
},
|
|
58
61
|
],
|
package/src/components.ts
CHANGED
|
@@ -14,19 +14,7 @@ export {
|
|
|
14
14
|
} from "./dialog";
|
|
15
15
|
export { Popover, PopoverTrigger, PopoverContent } from "./popover";
|
|
16
16
|
export { Tooltip, TooltipTrigger, TooltipContent } from "./tooltip";
|
|
17
|
-
export {
|
|
18
|
-
Sheet,
|
|
19
|
-
SheetTrigger,
|
|
20
|
-
SheetOverlay,
|
|
21
|
-
SheetContent,
|
|
22
|
-
SheetClose,
|
|
23
|
-
SheetTitle,
|
|
24
|
-
SheetDescription,
|
|
25
|
-
} from "./sheet";
|
|
26
17
|
export { Tabs, TabsList, TabsTrigger, TabsContent } from "./tabs";
|
|
27
|
-
export { Button } from "./button";
|
|
28
|
-
export { Input } from "./input";
|
|
29
|
-
export { Textarea } from "./textarea";
|
|
30
18
|
export { Label } from "./label";
|
|
31
19
|
export {
|
|
32
20
|
Accordion,
|
|
@@ -35,3 +23,28 @@ export {
|
|
|
35
23
|
AccordionTrigger,
|
|
36
24
|
AccordionContent,
|
|
37
25
|
} from "./accordion";
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
NavigationMenu,
|
|
29
|
+
NavigationMenuList,
|
|
30
|
+
NavigationMenuItem,
|
|
31
|
+
NavigationMenuTrigger,
|
|
32
|
+
NavigationMenuContent,
|
|
33
|
+
NavigationMenuLink,
|
|
34
|
+
NavigationMenuViewport,
|
|
35
|
+
} from "./navigation-menu";
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
Select,
|
|
39
|
+
SelectTrigger,
|
|
40
|
+
SelectValue,
|
|
41
|
+
SelectViewport,
|
|
42
|
+
SelectContent,
|
|
43
|
+
SelectItem,
|
|
44
|
+
SelectItemIndicator,
|
|
45
|
+
SelectItemText,
|
|
46
|
+
} from "./select";
|
|
47
|
+
|
|
48
|
+
export { Switch, SwitchThumb } from "./switch";
|
|
49
|
+
export { Checkbox, CheckboxIndicator } from "./checkbox";
|
|
50
|
+
export { RadioGroup, RadioGroupItem, RadioGroupIndicator } from "./radio-group";
|
package/src/dialog.ws.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type WsComponentMeta,
|
|
13
13
|
type WsComponentPropsMeta,
|
|
14
14
|
} from "@webstudio-is/react-sdk";
|
|
15
|
+
import { div, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
|
|
15
16
|
import * as tc from "./theme/tailwind-classes";
|
|
16
17
|
import {
|
|
17
18
|
propsDialog,
|
|
@@ -22,9 +23,7 @@ import {
|
|
|
22
23
|
propsDialogTitle,
|
|
23
24
|
propsDialogDescription,
|
|
24
25
|
} from "./__generated__/dialog.props";
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
import { div, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
|
|
26
|
+
import { getButtonStyles } from "./theme/styles";
|
|
28
27
|
|
|
29
28
|
const presetStyle = {
|
|
30
29
|
div,
|
|
@@ -86,6 +85,7 @@ export const metaDialogClose: WsComponentMeta = {
|
|
|
86
85
|
type: "container",
|
|
87
86
|
presetStyle: buttonPresetStyle,
|
|
88
87
|
icon: ButtonElementIcon,
|
|
88
|
+
label: "Close Button",
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -98,9 +98,9 @@ export const metaDialogClose: WsComponentMeta = {
|
|
|
98
98
|
**/
|
|
99
99
|
export const metaDialog: WsComponentMeta = {
|
|
100
100
|
category: "radix",
|
|
101
|
+
order: 4,
|
|
101
102
|
type: "container",
|
|
102
103
|
icon: DialogIcon,
|
|
103
|
-
order: 15,
|
|
104
104
|
stylable: false,
|
|
105
105
|
template: [
|
|
106
106
|
{
|
|
@@ -127,15 +127,18 @@ export const metaDialog: WsComponentMeta = {
|
|
|
127
127
|
{
|
|
128
128
|
type: "instance",
|
|
129
129
|
component: "DialogTrigger",
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
children: [
|
|
131
|
+
{
|
|
132
|
+
type: "instance",
|
|
133
|
+
component: "Button",
|
|
134
|
+
styles: getButtonStyles("outline"),
|
|
135
|
+
children: [{ type: "text", value: "Button" }],
|
|
136
|
+
},
|
|
137
|
+
],
|
|
134
138
|
},
|
|
135
139
|
{
|
|
136
140
|
type: "instance",
|
|
137
141
|
component: "DialogOverlay",
|
|
138
|
-
props: [],
|
|
139
142
|
/**
|
|
140
143
|
* fixed inset-0 z-50 bg-background/80 backdrop-blur-sm
|
|
141
144
|
* flex
|
|
@@ -148,12 +151,12 @@ export const metaDialog: WsComponentMeta = {
|
|
|
148
151
|
tc.backdropBlur("sm"),
|
|
149
152
|
// To allow positioning Content
|
|
150
153
|
tc.flex(),
|
|
154
|
+
tc.overflow("auto"),
|
|
151
155
|
].flat(),
|
|
152
156
|
children: [
|
|
153
157
|
{
|
|
154
158
|
type: "instance",
|
|
155
159
|
component: "DialogContent",
|
|
156
|
-
props: [],
|
|
157
160
|
/**
|
|
158
161
|
* fixed w-full z-50
|
|
159
162
|
* grid gap-4 max-w-lg
|
|
@@ -179,13 +182,11 @@ export const metaDialog: WsComponentMeta = {
|
|
|
179
182
|
type: "instance",
|
|
180
183
|
component: "Box",
|
|
181
184
|
label: "Dialog Header",
|
|
182
|
-
props: [],
|
|
183
185
|
styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
|
|
184
186
|
children: [
|
|
185
187
|
{
|
|
186
188
|
type: "instance",
|
|
187
189
|
component: "DialogTitle",
|
|
188
|
-
props: [],
|
|
189
190
|
/**
|
|
190
191
|
* text-lg leading-none tracking-tight
|
|
191
192
|
**/
|
|
@@ -205,7 +206,6 @@ export const metaDialog: WsComponentMeta = {
|
|
|
205
206
|
{
|
|
206
207
|
type: "instance",
|
|
207
208
|
component: "DialogDescription",
|
|
208
|
-
props: [],
|
|
209
209
|
/**
|
|
210
210
|
* text-sm text-muted-foreground
|
|
211
211
|
**/
|
|
@@ -217,7 +217,7 @@ export const metaDialog: WsComponentMeta = {
|
|
|
217
217
|
children: [
|
|
218
218
|
{
|
|
219
219
|
type: "text",
|
|
220
|
-
value: "
|
|
220
|
+
value: "Dialog description text you can edit",
|
|
221
221
|
},
|
|
222
222
|
],
|
|
223
223
|
},
|
|
@@ -233,7 +233,6 @@ export const metaDialog: WsComponentMeta = {
|
|
|
233
233
|
{
|
|
234
234
|
type: "instance",
|
|
235
235
|
component: "DialogClose",
|
|
236
|
-
props: [],
|
|
237
236
|
/**
|
|
238
237
|
* absolute right-4 top-4
|
|
239
238
|
* rounded-sm opacity-70
|
|
@@ -271,7 +270,7 @@ export const metaDialog: WsComponentMeta = {
|
|
|
271
270
|
|
|
272
271
|
export const propsMetaDialog: WsComponentPropsMeta = {
|
|
273
272
|
props: propsDialog,
|
|
274
|
-
initialProps: ["open"
|
|
273
|
+
initialProps: ["open"],
|
|
275
274
|
};
|
|
276
275
|
|
|
277
276
|
export const propsMetaDialogTrigger: WsComponentPropsMeta = {
|
package/src/hooks.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { hooksPopover } from "./popover";
|
|
|
6
6
|
import { hooksSheet } from "./sheet";
|
|
7
7
|
import { hooksTooltip } from "./tooltip";
|
|
8
8
|
import { hooksAccordion } from "./accordion";
|
|
9
|
+
import { hooksNavigationMenu } from "./navigation-menu";
|
|
10
|
+
import { hooksSelect } from "./select";
|
|
9
11
|
|
|
10
12
|
export const hooks: Hook[] = [
|
|
11
13
|
hooksCollapsible,
|
|
@@ -15,4 +17,6 @@ export const hooks: Hook[] = [
|
|
|
15
17
|
hooksSheet,
|
|
16
18
|
hooksTooltip,
|
|
17
19
|
hooksAccordion,
|
|
20
|
+
hooksNavigationMenu,
|
|
21
|
+
hooksSelect,
|
|
18
22
|
];
|
package/src/label.ws.ts
CHANGED