@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.
- package/lib/components.js +278 -35
- package/lib/hooks.js +475 -11
- package/lib/metas.js +4616 -58
- package/lib/props.js +23280 -57
- package/lib/types/theme/tailwind-classes.d.ts +4 -4
- package/package.json +9 -9
- package/lib/__generated__/accordion.props.js +0 -2619
- package/lib/__generated__/checkbox.props.js +0 -1080
- package/lib/__generated__/collapsible.props.js +0 -1026
- package/lib/__generated__/dialog.props.js +0 -2595
- package/lib/__generated__/label.props.js +0 -519
- package/lib/__generated__/navigation-menu.props.js +0 -2557
- package/lib/__generated__/popover.props.js +0 -558
- package/lib/__generated__/radio-group.props.js +0 -1623
- package/lib/__generated__/select.props.js +0 -3674
- package/lib/__generated__/sheet.props.js +0 -2614
- package/lib/__generated__/switch.props.js +0 -1080
- package/lib/__generated__/tabs.props.js +0 -2119
- package/lib/__generated__/tooltip.props.js +0 -569
- package/lib/accordion.js +0 -51
- package/lib/accordion.stories.js +0 -18
- package/lib/accordion.ws.js +0 -259
- package/lib/checkbox.js +0 -10
- package/lib/checkbox.stories.js +0 -19
- package/lib/checkbox.ws.js +0 -148
- package/lib/collapsible.js +0 -31
- package/lib/collapsible.stories.js +0 -18
- package/lib/collapsible.ws.js +0 -103
- package/lib/dialog.js +0 -53
- package/lib/dialog.stories.js +0 -18
- package/lib/dialog.ws.js +0 -289
- package/lib/label.js +0 -7
- package/lib/label.stories.js +0 -19
- package/lib/label.ws.js +0 -44
- package/lib/navigation-menu.js +0 -76
- package/lib/navigation-menu.stories.js +0 -18
- package/lib/navigation-menu.ws.js +0 -486
- package/lib/popover.js +0 -58
- package/lib/popover.stories.js +0 -18
- package/lib/popover.ws.js +0 -110
- package/lib/props-descriptions.js +0 -34
- package/lib/radio-group.js +0 -7
- package/lib/radio-group.stories.js +0 -19
- package/lib/radio-group.ws.js +0 -166
- package/lib/select.js +0 -65
- package/lib/select.stories.js +0 -18
- package/lib/select.ws.js +0 -321
- package/lib/sheet.js +0 -59
- package/lib/sheet.stories.js +0 -18
- package/lib/sheet.ws.js +0 -225
- package/lib/switch.js +0 -4
- package/lib/switch.stories.js +0 -19
- package/lib/switch.ws.js +0 -140
- package/lib/tabs.js +0 -38
- package/lib/tabs.stories.js +0 -18
- package/lib/tabs.ws.js +0 -169
- package/lib/theme/__generated__/tailwind-theme.js +0 -517
- package/lib/theme/styles.js +0 -63
- package/lib/theme/tailwind-classes.js +0 -651
- package/lib/theme/tailwind-colors.js +0 -23
- package/lib/tooltip.js +0 -55
- package/lib/tooltip.stories.js +0 -18
- package/lib/tooltip.ws.js +0 -111
package/lib/accordion.ws.js
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import {
|
|
3
|
-
AccordionIcon,
|
|
4
|
-
ItemIcon,
|
|
5
|
-
HeaderIcon,
|
|
6
|
-
TriggerIcon,
|
|
7
|
-
ContentIcon,
|
|
8
|
-
ChevronDownIcon
|
|
9
|
-
} from "@webstudio-is/icons/svg";
|
|
10
|
-
import {
|
|
11
|
-
defaultStates
|
|
12
|
-
} from "@webstudio-is/react-sdk";
|
|
13
|
-
import { div, h3, button } from "@webstudio-is/react-sdk/css-normalize";
|
|
14
|
-
import * as tc from "./theme/tailwind-classes";
|
|
15
|
-
import { buttonReset } from "./theme/styles";
|
|
16
|
-
import {
|
|
17
|
-
propsAccordion,
|
|
18
|
-
propsAccordionItem,
|
|
19
|
-
propsAccordionHeader,
|
|
20
|
-
propsAccordionTrigger,
|
|
21
|
-
propsAccordionContent
|
|
22
|
-
} from "./__generated__/accordion.props";
|
|
23
|
-
const presetStyle = {
|
|
24
|
-
div
|
|
25
|
-
};
|
|
26
|
-
const accordionItemStyles = [tc.borderB()].flat();
|
|
27
|
-
const createAccordionTrigger = ({
|
|
28
|
-
children
|
|
29
|
-
}) => ({
|
|
30
|
-
type: "instance",
|
|
31
|
-
component: "AccordionHeader",
|
|
32
|
-
// flex
|
|
33
|
-
styles: [tc.flex()].flat(),
|
|
34
|
-
children: [
|
|
35
|
-
{
|
|
36
|
-
type: "instance",
|
|
37
|
-
component: "AccordionTrigger",
|
|
38
|
-
// flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180
|
|
39
|
-
styles: [
|
|
40
|
-
tc.flex(),
|
|
41
|
-
tc.flex(1),
|
|
42
|
-
tc.items("center"),
|
|
43
|
-
tc.justify("between"),
|
|
44
|
-
tc.py(4),
|
|
45
|
-
tc.font("medium"),
|
|
46
|
-
tc.hover([tc.underline()].flat()),
|
|
47
|
-
tc.property("--accordion-trigger-icon-transform", "0deg"),
|
|
48
|
-
tc.state(
|
|
49
|
-
[tc.property("--accordion-trigger-icon-transform", "180deg")],
|
|
50
|
-
"[data-state=open]"
|
|
51
|
-
)
|
|
52
|
-
].flat(),
|
|
53
|
-
children: [
|
|
54
|
-
{
|
|
55
|
-
type: "instance",
|
|
56
|
-
component: "Text",
|
|
57
|
-
children
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: "instance",
|
|
61
|
-
component: "Box",
|
|
62
|
-
label: "Icon Container",
|
|
63
|
-
// h-4 w-4 shrink-0 transition-transform duration-200
|
|
64
|
-
styles: [
|
|
65
|
-
tc.property("rotate", "--accordion-trigger-icon-transform"),
|
|
66
|
-
tc.h(4),
|
|
67
|
-
tc.w(4),
|
|
68
|
-
tc.shrink(0),
|
|
69
|
-
tc.transition("all"),
|
|
70
|
-
tc.duration(200)
|
|
71
|
-
].flat(),
|
|
72
|
-
children: [
|
|
73
|
-
{
|
|
74
|
-
type: "instance",
|
|
75
|
-
component: "HtmlEmbed",
|
|
76
|
-
label: "Chevron Icon",
|
|
77
|
-
props: [
|
|
78
|
-
{
|
|
79
|
-
type: "string",
|
|
80
|
-
name: "code",
|
|
81
|
-
value: ChevronDownIcon
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
children: []
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
}
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
});
|
|
92
|
-
const accordionContentStyles = [
|
|
93
|
-
tc.overflow("hidden"),
|
|
94
|
-
tc.text("sm"),
|
|
95
|
-
// transition does not work with display: none
|
|
96
|
-
// tc.transition("all"),
|
|
97
|
-
tc.pb(4)
|
|
98
|
-
].flat();
|
|
99
|
-
export const metaAccordion = {
|
|
100
|
-
category: "radix",
|
|
101
|
-
order: 3,
|
|
102
|
-
type: "container",
|
|
103
|
-
icon: AccordionIcon,
|
|
104
|
-
presetStyle,
|
|
105
|
-
description: "A vertically stacked set of interactive headings that each reveal an associated section of content. Clicking on the heading will open the item and close other items.",
|
|
106
|
-
template: [
|
|
107
|
-
{
|
|
108
|
-
type: "instance",
|
|
109
|
-
component: "Accordion",
|
|
110
|
-
dataSources: {
|
|
111
|
-
accordionValue: { type: "variable", initialValue: "0" }
|
|
112
|
-
},
|
|
113
|
-
props: [
|
|
114
|
-
{ type: "boolean", name: "collapsible", value: true },
|
|
115
|
-
{ type: "dataSource", name: "value", dataSourceName: "accordionValue" },
|
|
116
|
-
{
|
|
117
|
-
name: "onValueChange",
|
|
118
|
-
type: "action",
|
|
119
|
-
value: [
|
|
120
|
-
{
|
|
121
|
-
type: "execute",
|
|
122
|
-
args: ["value"],
|
|
123
|
-
code: `accordionValue = value`
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
children: [
|
|
129
|
-
{
|
|
130
|
-
type: "instance",
|
|
131
|
-
component: "AccordionItem",
|
|
132
|
-
styles: accordionItemStyles,
|
|
133
|
-
children: [
|
|
134
|
-
createAccordionTrigger({
|
|
135
|
-
children: [{ type: "text", value: "Is it accessible?" }]
|
|
136
|
-
}),
|
|
137
|
-
{
|
|
138
|
-
type: "instance",
|
|
139
|
-
component: "AccordionContent",
|
|
140
|
-
styles: accordionContentStyles,
|
|
141
|
-
children: [
|
|
142
|
-
{
|
|
143
|
-
type: "text",
|
|
144
|
-
value: "Yes. It adheres to the WAI-ARIA design pattern."
|
|
145
|
-
}
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
]
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
type: "instance",
|
|
152
|
-
component: "AccordionItem",
|
|
153
|
-
styles: accordionItemStyles,
|
|
154
|
-
children: [
|
|
155
|
-
createAccordionTrigger({
|
|
156
|
-
children: [{ type: "text", value: "Is it styled?" }]
|
|
157
|
-
}),
|
|
158
|
-
{
|
|
159
|
-
type: "instance",
|
|
160
|
-
component: "AccordionContent",
|
|
161
|
-
styles: accordionContentStyles,
|
|
162
|
-
children: [
|
|
163
|
-
{
|
|
164
|
-
type: "text",
|
|
165
|
-
value: "Yes. It comes with default styles that matches the other components' aesthetic."
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
type: "instance",
|
|
173
|
-
component: "AccordionItem",
|
|
174
|
-
styles: accordionItemStyles,
|
|
175
|
-
children: [
|
|
176
|
-
createAccordionTrigger({
|
|
177
|
-
children: [{ type: "text", value: "Is it animated?" }]
|
|
178
|
-
}),
|
|
179
|
-
{
|
|
180
|
-
type: "instance",
|
|
181
|
-
component: "AccordionContent",
|
|
182
|
-
styles: accordionContentStyles,
|
|
183
|
-
children: [
|
|
184
|
-
{
|
|
185
|
-
type: "text",
|
|
186
|
-
value: "Yes. It's animated by default, but you can disable it if you prefer."
|
|
187
|
-
}
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
|
-
]
|
|
191
|
-
}
|
|
192
|
-
]
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
};
|
|
196
|
-
export const metaAccordionItem = {
|
|
197
|
-
category: "hidden",
|
|
198
|
-
type: "container",
|
|
199
|
-
label: "Item",
|
|
200
|
-
icon: ItemIcon,
|
|
201
|
-
requiredAncestors: ["Accordion"],
|
|
202
|
-
indexWithinAncestor: "Accordion",
|
|
203
|
-
presetStyle
|
|
204
|
-
};
|
|
205
|
-
export const metaAccordionHeader = {
|
|
206
|
-
category: "hidden",
|
|
207
|
-
type: "container",
|
|
208
|
-
label: "Item Header",
|
|
209
|
-
icon: HeaderIcon,
|
|
210
|
-
requiredAncestors: ["AccordionItem"],
|
|
211
|
-
detachable: false,
|
|
212
|
-
presetStyle: {
|
|
213
|
-
h3: [h3, tc.my(0)].flat()
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
export const metaAccordionTrigger = {
|
|
217
|
-
category: "hidden",
|
|
218
|
-
type: "container",
|
|
219
|
-
label: "Item Trigger",
|
|
220
|
-
icon: TriggerIcon,
|
|
221
|
-
requiredAncestors: ["AccordionHeader"],
|
|
222
|
-
detachable: false,
|
|
223
|
-
states: [
|
|
224
|
-
...defaultStates,
|
|
225
|
-
{
|
|
226
|
-
category: "component-states",
|
|
227
|
-
label: "Open",
|
|
228
|
-
selector: "[data-state=open]"
|
|
229
|
-
}
|
|
230
|
-
],
|
|
231
|
-
presetStyle: {
|
|
232
|
-
button: [button, buttonReset].flat()
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
export const metaAccordionContent = {
|
|
236
|
-
category: "hidden",
|
|
237
|
-
type: "container",
|
|
238
|
-
label: "Item Content",
|
|
239
|
-
icon: ContentIcon,
|
|
240
|
-
requiredAncestors: ["AccordionItem"],
|
|
241
|
-
detachable: false,
|
|
242
|
-
presetStyle
|
|
243
|
-
};
|
|
244
|
-
export const propsMetaAccordion = {
|
|
245
|
-
props: propsAccordion,
|
|
246
|
-
initialProps: ["value", "collapsible"]
|
|
247
|
-
};
|
|
248
|
-
export const propsMetaAccordionItem = {
|
|
249
|
-
props: propsAccordionItem
|
|
250
|
-
};
|
|
251
|
-
export const propsMetaAccordionHeader = {
|
|
252
|
-
props: propsAccordionHeader
|
|
253
|
-
};
|
|
254
|
-
export const propsMetaAccordionTrigger = {
|
|
255
|
-
props: propsAccordionTrigger
|
|
256
|
-
};
|
|
257
|
-
export const propsMetaAccordionContent = {
|
|
258
|
-
props: propsAccordionContent
|
|
259
|
-
};
|
package/lib/checkbox.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
forwardRef
|
|
5
|
-
} from "react";
|
|
6
|
-
import { Root, Indicator } from "@radix-ui/react-checkbox";
|
|
7
|
-
export const Checkbox = forwardRef((props, ref) => {
|
|
8
|
-
return /* @__PURE__ */ jsx(Root, { ref, ...props });
|
|
9
|
-
});
|
|
10
|
-
export const CheckboxIndicator = Indicator;
|
package/lib/checkbox.stories.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import { renderComponentTemplate } from "@webstudio-is/react-sdk";
|
|
3
|
-
import * as baseComponents from "@webstudio-is/sdk-components-react";
|
|
4
|
-
import * as baseMetas from "@webstudio-is/sdk-components-react/metas";
|
|
5
|
-
import * as radixComponents from "./components";
|
|
6
|
-
import * as radixMetas from "./metas";
|
|
7
|
-
import { Checkbox as CheckboxPrimitive } from "./checkbox";
|
|
8
|
-
export default {
|
|
9
|
-
title: "Components/Checkbox",
|
|
10
|
-
component: CheckboxPrimitive
|
|
11
|
-
};
|
|
12
|
-
export const Checkbox = {
|
|
13
|
-
render: (props) => renderComponentTemplate({
|
|
14
|
-
name: "Checkbox",
|
|
15
|
-
props: { ...props },
|
|
16
|
-
components: { ...baseComponents, ...radixComponents },
|
|
17
|
-
metas: { ...baseMetas, ...radixMetas }
|
|
18
|
-
})
|
|
19
|
-
};
|
package/lib/checkbox.ws.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import {
|
|
3
|
-
CheckMarkIcon,
|
|
4
|
-
CheckboxCheckedIcon,
|
|
5
|
-
TriggerIcon
|
|
6
|
-
} from "@webstudio-is/icons/svg";
|
|
7
|
-
import {
|
|
8
|
-
defaultStates
|
|
9
|
-
} from "@webstudio-is/react-sdk";
|
|
10
|
-
import { button, span } from "@webstudio-is/react-sdk/css-normalize";
|
|
11
|
-
import * as tc from "./theme/tailwind-classes";
|
|
12
|
-
import { buttonReset } from "./theme/styles";
|
|
13
|
-
import {
|
|
14
|
-
propsCheckbox,
|
|
15
|
-
propsCheckboxIndicator
|
|
16
|
-
} from "./__generated__/checkbox.props";
|
|
17
|
-
export const metaCheckbox = {
|
|
18
|
-
category: "radix",
|
|
19
|
-
order: 101,
|
|
20
|
-
type: "container",
|
|
21
|
-
icon: CheckboxCheckedIcon,
|
|
22
|
-
description: "Use within a form to allow your users to toggle between checked and not checked. Group checkboxes by matching their \u201CName\u201D properties. Unlike radios, any number of checkboxes in a group can be checked.",
|
|
23
|
-
states: [
|
|
24
|
-
...defaultStates,
|
|
25
|
-
{
|
|
26
|
-
label: "Checked",
|
|
27
|
-
selector: "[data-state=checked]",
|
|
28
|
-
category: "component-states"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
label: "Unchecked",
|
|
32
|
-
selector: "[data-state=unchecked]",
|
|
33
|
-
category: "component-states"
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
presetStyle: {
|
|
37
|
-
button: [button, buttonReset].flat()
|
|
38
|
-
},
|
|
39
|
-
template: [
|
|
40
|
-
{
|
|
41
|
-
type: "instance",
|
|
42
|
-
component: "Label",
|
|
43
|
-
label: "Checkbox Field",
|
|
44
|
-
styles: [tc.flex(), tc.gap(2), tc.items("center")].flat(),
|
|
45
|
-
children: [
|
|
46
|
-
{
|
|
47
|
-
type: "instance",
|
|
48
|
-
component: "Checkbox",
|
|
49
|
-
dataSources: {
|
|
50
|
-
checkboxChecked: { type: "variable", initialValue: false }
|
|
51
|
-
},
|
|
52
|
-
props: [
|
|
53
|
-
{
|
|
54
|
-
name: "checked",
|
|
55
|
-
type: "dataSource",
|
|
56
|
-
dataSourceName: "checkboxChecked"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: "onCheckedChange",
|
|
60
|
-
type: "action",
|
|
61
|
-
value: [
|
|
62
|
-
{
|
|
63
|
-
type: "execute",
|
|
64
|
-
args: ["checked"],
|
|
65
|
-
code: `checkboxChecked = checked`
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
],
|
|
70
|
-
// peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background
|
|
71
|
-
// focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
|
|
72
|
-
// disabled:cursor-not-allowed disabled:opacity-50
|
|
73
|
-
// data-[state=checked]:bg-primary
|
|
74
|
-
// data-[state=checked]:text-primary-foreground",
|
|
75
|
-
styles: [
|
|
76
|
-
// We are not supporting peer like styles yet
|
|
77
|
-
tc.h(4),
|
|
78
|
-
tc.w(4),
|
|
79
|
-
tc.shrink(0),
|
|
80
|
-
tc.rounded("sm"),
|
|
81
|
-
tc.border(),
|
|
82
|
-
tc.border("primary"),
|
|
83
|
-
tc.focusVisible(
|
|
84
|
-
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
85
|
-
),
|
|
86
|
-
tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat()),
|
|
87
|
-
tc.state(
|
|
88
|
-
[tc.bg("primary"), tc.text("primaryForeground")].flat(),
|
|
89
|
-
"[data-state=checked]"
|
|
90
|
-
)
|
|
91
|
-
].flat(),
|
|
92
|
-
children: [
|
|
93
|
-
{
|
|
94
|
-
type: "instance",
|
|
95
|
-
component: "CheckboxIndicator",
|
|
96
|
-
// flex items-center justify-center text-current
|
|
97
|
-
styles: [
|
|
98
|
-
tc.flex(),
|
|
99
|
-
tc.items("center"),
|
|
100
|
-
tc.justify("center"),
|
|
101
|
-
tc.text("current")
|
|
102
|
-
].flat(),
|
|
103
|
-
children: [
|
|
104
|
-
{
|
|
105
|
-
type: "instance",
|
|
106
|
-
component: "HtmlEmbed",
|
|
107
|
-
label: "Indicator Icon",
|
|
108
|
-
props: [
|
|
109
|
-
{
|
|
110
|
-
type: "string",
|
|
111
|
-
name: "code",
|
|
112
|
-
value: CheckMarkIcon
|
|
113
|
-
}
|
|
114
|
-
],
|
|
115
|
-
children: []
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
type: "instance",
|
|
123
|
-
component: "Text",
|
|
124
|
-
label: "Checkbox Label",
|
|
125
|
-
props: [{ name: "tag", type: "string", value: "span" }],
|
|
126
|
-
children: [{ type: "text", value: "Checkbox" }]
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
}
|
|
130
|
-
]
|
|
131
|
-
};
|
|
132
|
-
export const metaCheckboxIndicator = {
|
|
133
|
-
category: "hidden",
|
|
134
|
-
type: "container",
|
|
135
|
-
detachable: false,
|
|
136
|
-
icon: TriggerIcon,
|
|
137
|
-
states: defaultStates,
|
|
138
|
-
presetStyle: {
|
|
139
|
-
span
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
export const propsMetaCheckbox = {
|
|
143
|
-
props: propsCheckbox,
|
|
144
|
-
initialProps: ["id", "checked", "name", "required"]
|
|
145
|
-
};
|
|
146
|
-
export const propsMetaCheckboxIndicator = {
|
|
147
|
-
props: propsCheckboxIndicator
|
|
148
|
-
};
|
package/lib/collapsible.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
forwardRef,
|
|
5
|
-
Children
|
|
6
|
-
} from "react";
|
|
7
|
-
import { Root, Trigger, Content } from "@radix-ui/react-collapsible";
|
|
8
|
-
import { getClosestInstance } from "@webstudio-is/react-sdk";
|
|
9
|
-
export const Collapsible = Root;
|
|
10
|
-
export const CollapsibleTrigger = forwardRef(({ children, ...props }, ref) => {
|
|
11
|
-
const firstChild = Children.toArray(children)[0];
|
|
12
|
-
return /* @__PURE__ */ jsx(Trigger, { asChild: true, ref, ...props, children: firstChild ?? /* @__PURE__ */ jsx("button", { children: "Add button" }) });
|
|
13
|
-
});
|
|
14
|
-
export const CollapsibleContent = Content;
|
|
15
|
-
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
16
|
-
export const hooksCollapsible = {
|
|
17
|
-
onNavigatorSelect: (context, event) => {
|
|
18
|
-
for (const instance of event.instancePath) {
|
|
19
|
-
if (instance.component === `${namespace}:CollapsibleContent`) {
|
|
20
|
-
const collapsible = getClosestInstance(
|
|
21
|
-
event.instancePath,
|
|
22
|
-
instance,
|
|
23
|
-
`${namespace}:Collapsible`
|
|
24
|
-
);
|
|
25
|
-
if (collapsible) {
|
|
26
|
-
context.setPropVariable(collapsible.id, "open", true);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import { renderComponentTemplate } from "@webstudio-is/react-sdk";
|
|
3
|
-
import { Collapsible as CollapsiblePrimitive } from "./collapsible";
|
|
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/Collapsible",
|
|
10
|
-
component: CollapsiblePrimitive
|
|
11
|
-
};
|
|
12
|
-
export const Collapsible = {
|
|
13
|
-
render: () => renderComponentTemplate({
|
|
14
|
-
name: "Collapsible",
|
|
15
|
-
components: { ...baseComponents, ...radixComponents },
|
|
16
|
-
metas: { ...baseMetas, ...radixMetas }
|
|
17
|
-
})
|
|
18
|
-
};
|
package/lib/collapsible.ws.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import {
|
|
3
|
-
CollapsibleIcon,
|
|
4
|
-
TriggerIcon,
|
|
5
|
-
ContentIcon
|
|
6
|
-
} from "@webstudio-is/icons/svg";
|
|
7
|
-
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
8
|
-
import {
|
|
9
|
-
propsCollapsible,
|
|
10
|
-
propsCollapsibleContent,
|
|
11
|
-
propsCollapsibleTrigger
|
|
12
|
-
} from "./__generated__/collapsible.props";
|
|
13
|
-
import { getButtonStyles } from "./theme/styles";
|
|
14
|
-
const presetStyle = {
|
|
15
|
-
div
|
|
16
|
-
};
|
|
17
|
-
export const metaCollapsible = {
|
|
18
|
-
category: "radix",
|
|
19
|
-
order: 5,
|
|
20
|
-
type: "container",
|
|
21
|
-
presetStyle,
|
|
22
|
-
icon: CollapsibleIcon,
|
|
23
|
-
description: "An interactive component which expands and collapses some content, triggered by a button.",
|
|
24
|
-
template: [
|
|
25
|
-
{
|
|
26
|
-
type: "instance",
|
|
27
|
-
component: "Collapsible",
|
|
28
|
-
dataSources: {
|
|
29
|
-
collapsibleOpen: { type: "variable", initialValue: false }
|
|
30
|
-
},
|
|
31
|
-
props: [
|
|
32
|
-
{
|
|
33
|
-
type: "dataSource",
|
|
34
|
-
name: "open",
|
|
35
|
-
dataSourceName: "collapsibleOpen"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: "onOpenChange",
|
|
39
|
-
type: "action",
|
|
40
|
-
value: [
|
|
41
|
-
{ type: "execute", args: ["open"], code: `collapsibleOpen = open` }
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
children: [
|
|
46
|
-
{
|
|
47
|
-
type: "instance",
|
|
48
|
-
component: "CollapsibleTrigger",
|
|
49
|
-
children: [
|
|
50
|
-
{
|
|
51
|
-
type: "instance",
|
|
52
|
-
component: "Button",
|
|
53
|
-
styles: getButtonStyles("outline"),
|
|
54
|
-
children: [{ type: "text", value: "Click to toggle content" }]
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: "instance",
|
|
60
|
-
component: "CollapsibleContent",
|
|
61
|
-
children: [
|
|
62
|
-
{
|
|
63
|
-
type: "instance",
|
|
64
|
-
component: "Text",
|
|
65
|
-
children: [{ type: "text", value: "Collapsible Content" }]
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
};
|
|
73
|
-
export const metaCollapsibleTrigger = {
|
|
74
|
-
category: "hidden",
|
|
75
|
-
type: "container",
|
|
76
|
-
icon: TriggerIcon,
|
|
77
|
-
stylable: false,
|
|
78
|
-
detachable: false
|
|
79
|
-
};
|
|
80
|
-
export const metaCollapsibleContent = {
|
|
81
|
-
category: "hidden",
|
|
82
|
-
type: "container",
|
|
83
|
-
presetStyle,
|
|
84
|
-
icon: ContentIcon,
|
|
85
|
-
detachable: false
|
|
86
|
-
};
|
|
87
|
-
export const propsMetaCollapsible = {
|
|
88
|
-
props: {
|
|
89
|
-
...propsCollapsible,
|
|
90
|
-
onOpenChange: {
|
|
91
|
-
type: "action",
|
|
92
|
-
control: "action",
|
|
93
|
-
required: false
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
initialProps: ["open", "onOpenChange"]
|
|
97
|
-
};
|
|
98
|
-
export const propsMetaCollapsibleTrigger = {
|
|
99
|
-
props: propsCollapsibleTrigger
|
|
100
|
-
};
|
|
101
|
-
export const propsMetaCollapsibleContent = {
|
|
102
|
-
props: propsCollapsibleContent
|
|
103
|
-
};
|
package/lib/dialog.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
forwardRef,
|
|
5
|
-
Children
|
|
6
|
-
} from "react";
|
|
7
|
-
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
8
|
-
import { getClosestInstance } from "@webstudio-is/react-sdk";
|
|
9
|
-
export const Dialog = forwardRef((props, _ref) => {
|
|
10
|
-
return /* @__PURE__ */ jsx(DialogPrimitive.Root, { ...props });
|
|
11
|
-
});
|
|
12
|
-
export const DialogTrigger = forwardRef(({ children, ...props }, ref) => {
|
|
13
|
-
const firstChild = Children.toArray(children)[0];
|
|
14
|
-
return /* @__PURE__ */ jsx(DialogPrimitive.Trigger, { ref, asChild: true, ...props, children: firstChild ?? /* @__PURE__ */ jsx("button", { children: "Add button or link" }) });
|
|
15
|
-
});
|
|
16
|
-
export const DialogOverlay = forwardRef((props, ref) => {
|
|
17
|
-
return /* @__PURE__ */ jsx(DialogPrimitive.DialogPortal, { children: /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { ref, ...props }) });
|
|
18
|
-
});
|
|
19
|
-
export const DialogContent = DialogPrimitive.Content;
|
|
20
|
-
export const DialogClose = DialogPrimitive.Close;
|
|
21
|
-
export const DialogTitle = DialogPrimitive.Title;
|
|
22
|
-
export const DialogDescription = DialogPrimitive.Description;
|
|
23
|
-
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
24
|
-
export const hooksDialog = {
|
|
25
|
-
onNavigatorUnselect: (context, event) => {
|
|
26
|
-
for (const instance of event.instancePath) {
|
|
27
|
-
if (instance.component === `${namespace}:DialogOverlay`) {
|
|
28
|
-
const dialog = getClosestInstance(
|
|
29
|
-
event.instancePath,
|
|
30
|
-
instance,
|
|
31
|
-
`${namespace}:Dialog`
|
|
32
|
-
);
|
|
33
|
-
if (dialog) {
|
|
34
|
-
context.setPropVariable(dialog.id, "open", false);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
onNavigatorSelect: (context, event) => {
|
|
40
|
-
for (const instance of event.instancePath) {
|
|
41
|
-
if (instance.component === `${namespace}:DialogOverlay`) {
|
|
42
|
-
const dialog = getClosestInstance(
|
|
43
|
-
event.instancePath,
|
|
44
|
-
instance,
|
|
45
|
-
`${namespace}:Dialog`
|
|
46
|
-
);
|
|
47
|
-
if (dialog) {
|
|
48
|
-
context.setPropVariable(dialog.id, "open", true);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
package/lib/dialog.stories.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import { renderComponentTemplate } from "@webstudio-is/react-sdk";
|
|
3
|
-
import { Dialog as DialogPrimitive } from "./dialog";
|
|
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/Dialog",
|
|
10
|
-
component: DialogPrimitive
|
|
11
|
-
};
|
|
12
|
-
export const Dialog = {
|
|
13
|
-
render: () => renderComponentTemplate({
|
|
14
|
-
name: "Dialog",
|
|
15
|
-
components: { ...baseComponents, ...radixComponents },
|
|
16
|
-
metas: { ...baseMetas, ...radixMetas }
|
|
17
|
-
})
|
|
18
|
-
};
|