@webstudio-is/sdk-components-react-radix 0.90.0 → 0.92.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 +6 -12
- package/lib/__generated__/checkbox.props.js +3 -6
- package/lib/__generated__/collapsible.props.js +4 -8
- package/lib/__generated__/dialog.props.js +8 -16
- package/lib/__generated__/label.props.js +2 -4
- package/lib/__generated__/navigation-menu.props.js +8 -16
- package/lib/__generated__/popover.props.js +4 -8
- package/lib/__generated__/radio-group.props.js +4 -8
- package/lib/__generated__/select.props.js +15 -19
- package/lib/__generated__/sheet.props.js +8 -16
- package/lib/__generated__/switch.props.js +3 -6
- package/lib/__generated__/tabs.props.js +5 -10
- package/lib/__generated__/tooltip.props.js +4 -8
- package/lib/accordion.js +7 -14
- package/{src/accordion.stories.tsx → lib/accordion.stories.js} +9 -12
- package/lib/accordion.ws.js +11 -22
- package/lib/checkbox.js +3 -6
- package/lib/checkbox.stories.js +19 -0
- package/lib/checkbox.ws.js +5 -10
- package/lib/collapsible.js +5 -10
- package/{src/collapsible.stories.tsx → lib/collapsible.stories.js} +9 -12
- package/lib/collapsible.ws.js +7 -14
- package/lib/components.js +13 -62
- package/lib/dialog.js +9 -18
- package/{src/dialog.stories.tsx → lib/dialog.stories.js} +9 -12
- package/lib/dialog.ws.js +17 -30
- package/lib/hooks.js +2 -4
- package/lib/label.js +2 -4
- package/lib/label.stories.js +19 -0
- package/lib/label.ws.js +3 -6
- package/lib/metas.js +55 -105
- package/lib/navigation-menu.js +9 -18
- package/{src/navigation-menu.stories.tsx → lib/navigation-menu.stories.js} +9 -12
- package/lib/navigation-menu.ws.js +16 -31
- package/lib/popover.js +5 -10
- package/{src/popover.stories.tsx → lib/popover.stories.js} +9 -12
- package/lib/popover.ws.js +7 -14
- package/lib/props-descriptions.js +2 -4
- package/lib/props.js +54 -103
- package/lib/radio-group.js +4 -8
- package/lib/radio-group.stories.js +19 -0
- package/lib/radio-group.ws.js +7 -14
- package/lib/select.js +10 -20
- package/{src/select.stories.tsx → lib/select.stories.js} +9 -12
- package/lib/select.ws.js +17 -34
- package/lib/sheet.js +9 -18
- package/{src/sheet.stories.tsx → lib/sheet.stories.js} +9 -12
- package/lib/sheet.ws.js +2 -4
- package/lib/switch.js +3 -6
- package/lib/switch.stories.js +19 -0
- package/lib/switch.ws.js +5 -10
- package/lib/tabs.js +6 -12
- package/{src/tabs.stories.tsx → lib/tabs.stories.js} +9 -12
- package/lib/tabs.ws.js +9 -18
- package/lib/theme/__generated__/tailwind-theme.js +517 -0
- package/lib/theme/styles.js +3 -6
- package/lib/theme/tailwind-classes.js +149 -301
- package/lib/theme/tailwind-colors.js +2 -4
- package/lib/tooltip.js +5 -10
- package/{src/tooltip.stories.tsx → lib/tooltip.stories.js} +9 -12
- package/lib/tooltip.ws.js +7 -14
- package/lib/types/__generated__/accordion.props.d.ts +1 -1
- package/lib/types/__generated__/checkbox.props.d.ts +1 -1
- package/lib/types/__generated__/collapsible.props.d.ts +1 -1
- package/lib/types/__generated__/dialog.props.d.ts +1 -1
- package/lib/types/__generated__/label.props.d.ts +1 -1
- package/lib/types/__generated__/navigation-menu.props.d.ts +1 -1
- package/lib/types/__generated__/popover.props.d.ts +1 -1
- package/lib/types/__generated__/radio-group.props.d.ts +1 -1
- package/lib/types/__generated__/select.props.d.ts +1 -1
- package/lib/types/__generated__/sheet.props.d.ts +1 -1
- package/lib/types/__generated__/switch.props.d.ts +1 -1
- package/lib/types/__generated__/tabs.props.d.ts +1 -1
- package/lib/types/__generated__/tooltip.props.d.ts +1 -1
- package/lib/types/accordion.d.ts +1 -1
- package/lib/types/sheet.d.ts +1 -1
- package/lib/types/theme/__generated__/tailwind-theme.d.ts +26 -0
- package/lib/types/theme/styles.d.ts +60 -60
- package/lib/types/theme/tailwind-classes.d.ts +33 -33
- package/package.json +20 -23
- package/lib/__generated__/button.props.js +0 -565
- package/lib/__generated__/input.props.js +0 -668
- package/lib/__generated__/textarea.props.js +0 -577
- package/lib/cjs/__generated__/accordion.props.js +0 -2645
- package/lib/cjs/__generated__/button.props.js +0 -585
- package/lib/cjs/__generated__/checkbox.props.js +0 -1103
- package/lib/cjs/__generated__/collapsible.props.js +0 -1050
- package/lib/cjs/__generated__/dialog.props.js +0 -2623
- package/lib/cjs/__generated__/input.props.js +0 -688
- package/lib/cjs/__generated__/label.props.js +0 -541
- package/lib/cjs/__generated__/navigation-menu.props.js +0 -2585
- package/lib/cjs/__generated__/popover.props.js +0 -582
- package/lib/cjs/__generated__/radio-group.props.js +0 -1647
- package/lib/cjs/__generated__/select.props.js +0 -3698
- package/lib/cjs/__generated__/sheet.props.js +0 -2642
- package/lib/cjs/__generated__/switch.props.js +0 -1103
- package/lib/cjs/__generated__/tabs.props.js +0 -2144
- package/lib/cjs/__generated__/textarea.props.js +0 -597
- package/lib/cjs/__generated__/tooltip.props.js +0 -593
- package/lib/cjs/accordion.js +0 -67
- package/lib/cjs/accordion.ws.js +0 -285
- package/lib/cjs/checkbox.js +0 -31
- package/lib/cjs/checkbox.ws.js +0 -174
- package/lib/cjs/collapsible.js +0 -53
- package/lib/cjs/collapsible.ws.js +0 -122
- package/lib/cjs/components.js +0 -82
- package/lib/cjs/dialog.js +0 -89
- package/lib/cjs/dialog.ws.js +0 -314
- package/lib/cjs/hooks.js +0 -43
- package/lib/cjs/label.js +0 -37
- package/lib/cjs/label.ws.js +0 -75
- package/lib/cjs/metas.js +0 -84
- package/lib/cjs/navigation-menu.js +0 -107
- package/lib/cjs/navigation-menu.ws.js +0 -514
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/popover.js +0 -90
- package/lib/cjs/popover.ws.js +0 -142
- package/lib/cjs/props-descriptions.js +0 -56
- package/lib/cjs/props.js +0 -82
- package/lib/cjs/radio-group.js +0 -30
- package/lib/cjs/radio-group.ws.js +0 -191
- package/lib/cjs/select.js +0 -83
- package/lib/cjs/select.ws.js +0 -350
- package/lib/cjs/sheet.js +0 -96
- package/lib/cjs/sheet.ws.js +0 -257
- package/lib/cjs/switch.js +0 -27
- package/lib/cjs/switch.ws.js +0 -173
- package/lib/cjs/tabs.js +0 -59
- package/lib/cjs/tabs.ws.js +0 -196
- package/lib/cjs/theme/radix-common-types.js +0 -16
- package/lib/cjs/theme/styles.js +0 -96
- package/lib/cjs/theme/tailwind-classes.js +0 -819
- package/lib/cjs/theme/tailwind-colors.js +0 -45
- package/lib/cjs/theme/tailwind-theme.js +0 -46
- package/lib/cjs/tooltip.js +0 -87
- package/lib/cjs/tooltip.ws.js +0 -143
- package/lib/theme/radix-common-types.js +0 -0
- package/lib/theme/tailwind-theme.js +0 -16
- package/lib/types/__generated__/button.props.d.ts +0 -2
- package/lib/types/__generated__/input.props.d.ts +0 -2
- package/lib/types/__generated__/textarea.props.d.ts +0 -2
- package/lib/types/theme/radix-common-types.d.ts +0 -85
- package/lib/types/theme/tailwind-theme.d.ts +0 -72
- package/src/__generated__/accordion.props.ts +0 -2949
- package/src/__generated__/button.props.ts +0 -635
- package/src/__generated__/checkbox.props.ts +0 -1217
- package/src/__generated__/collapsible.props.ts +0 -1156
- package/src/__generated__/dialog.props.ts +0 -2923
- package/src/__generated__/input.props.ts +0 -748
- package/src/__generated__/label.props.ts +0 -585
- package/src/__generated__/navigation-menu.props.ts +0 -2882
- package/src/__generated__/popover.props.ts +0 -626
- package/src/__generated__/radio-group.props.ts +0 -1828
- package/src/__generated__/select.props.ts +0 -4130
- package/src/__generated__/sheet.props.ts +0 -2942
- package/src/__generated__/switch.props.ts +0 -1217
- package/src/__generated__/tabs.props.ts +0 -2386
- package/src/__generated__/textarea.props.ts +0 -645
- package/src/__generated__/tooltip.props.ts +0 -639
- package/src/accordion.tsx +0 -88
- package/src/accordion.ws.ts +0 -296
- package/src/checkbox.stories.ts +0 -22
- package/src/checkbox.tsx +0 -22
- package/src/checkbox.ws.ts +0 -154
- package/src/collapsible.tsx +0 -62
- package/src/collapsible.ws.ts +0 -115
- package/src/components.ts +0 -50
- package/src/dialog.tsx +0 -92
- package/src/dialog.ws.tsx +0 -318
- package/src/hooks.ts +0 -22
- package/src/label.stories.ts +0 -22
- package/src/label.tsx +0 -15
- package/src/label.ws.ts +0 -50
- package/src/metas.ts +0 -74
- package/src/navigation-menu.tsx +0 -130
- package/src/navigation-menu.ws.ts +0 -524
- package/src/popover.tsx +0 -96
- package/src/popover.ws.tsx +0 -128
- package/src/props-descriptions.ts +0 -43
- package/src/props.ts +0 -73
- package/src/radio-group.stories.ts +0 -22
- package/src/radio-group.tsx +0 -17
- package/src/radio-group.ws.ts +0 -178
- package/src/select.tsx +0 -112
- package/src/select.ws.ts +0 -349
- package/src/sheet.tsx +0 -79
- package/src/sheet.ws.tsx +0 -236
- package/src/switch.stories.ts +0 -22
- package/src/switch.tsx +0 -10
- package/src/switch.ws.ts +0 -146
- package/src/tabs.tsx +0 -64
- package/src/tabs.ws.ts +0 -198
- package/src/theme/radix-common-types.ts +0 -496
- package/src/theme/styles.ts +0 -76
- package/src/theme/tailwind-classes.ts +0 -1026
- package/src/theme/tailwind-colors.ts +0 -39
- package/src/theme/tailwind-theme.ts +0 -24
- package/src/tooltip.tsx +0 -95
- package/src/tooltip.ws.tsx +0 -130
package/src/popover.ws.tsx
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { PopoverIcon, TriggerIcon, ContentIcon } from "@webstudio-is/icons/svg";
|
|
2
|
-
import {
|
|
3
|
-
type PresetStyle,
|
|
4
|
-
type WsComponentMeta,
|
|
5
|
-
type WsComponentPropsMeta,
|
|
6
|
-
} from "@webstudio-is/react-sdk";
|
|
7
|
-
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
8
|
-
import * as tc from "./theme/tailwind-classes";
|
|
9
|
-
import { getButtonStyles } from "./theme/styles";
|
|
10
|
-
import {
|
|
11
|
-
propsPopover,
|
|
12
|
-
propsPopoverContent,
|
|
13
|
-
propsPopoverTrigger,
|
|
14
|
-
} from "./__generated__/popover.props";
|
|
15
|
-
|
|
16
|
-
const presetStyle = {
|
|
17
|
-
div,
|
|
18
|
-
} satisfies PresetStyle<"div">;
|
|
19
|
-
|
|
20
|
-
// @todo add [data-state] to button and link
|
|
21
|
-
export const metaPopoverTrigger: WsComponentMeta = {
|
|
22
|
-
category: "hidden",
|
|
23
|
-
type: "container",
|
|
24
|
-
icon: TriggerIcon,
|
|
25
|
-
stylable: false,
|
|
26
|
-
detachable: false,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const metaPopoverContent: WsComponentMeta = {
|
|
30
|
-
category: "hidden",
|
|
31
|
-
type: "container",
|
|
32
|
-
presetStyle,
|
|
33
|
-
icon: ContentIcon,
|
|
34
|
-
detachable: false,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Styles source without animations:
|
|
39
|
-
* https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/popover.tsx
|
|
40
|
-
*
|
|
41
|
-
* Attributions
|
|
42
|
-
* MIT License
|
|
43
|
-
* Copyright (c) 2023 shadcn
|
|
44
|
-
**/
|
|
45
|
-
export const metaPopover: WsComponentMeta = {
|
|
46
|
-
category: "radix",
|
|
47
|
-
order: 6,
|
|
48
|
-
type: "container",
|
|
49
|
-
icon: PopoverIcon,
|
|
50
|
-
stylable: false,
|
|
51
|
-
description: "Displays rich content in a portal, triggered by a button.",
|
|
52
|
-
template: [
|
|
53
|
-
{
|
|
54
|
-
type: "instance",
|
|
55
|
-
component: "Popover",
|
|
56
|
-
dataSources: {
|
|
57
|
-
popoverOpen: { type: "variable", initialValue: false },
|
|
58
|
-
},
|
|
59
|
-
props: [
|
|
60
|
-
{
|
|
61
|
-
type: "dataSource",
|
|
62
|
-
name: "open",
|
|
63
|
-
dataSourceName: "popoverOpen",
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "onOpenChange",
|
|
67
|
-
type: "action",
|
|
68
|
-
value: [
|
|
69
|
-
{ type: "execute", args: ["open"], code: `popoverOpen = open` },
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
children: [
|
|
74
|
-
{
|
|
75
|
-
type: "instance",
|
|
76
|
-
component: "PopoverTrigger",
|
|
77
|
-
children: [
|
|
78
|
-
{
|
|
79
|
-
type: "instance",
|
|
80
|
-
component: "Button",
|
|
81
|
-
styles: getButtonStyles("outline"),
|
|
82
|
-
children: [{ type: "text", value: "Button" }],
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
type: "instance",
|
|
88
|
-
component: "PopoverContent",
|
|
89
|
-
/**
|
|
90
|
-
* z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none
|
|
91
|
-
**/
|
|
92
|
-
styles: [
|
|
93
|
-
tc.z(50),
|
|
94
|
-
tc.w(72),
|
|
95
|
-
tc.rounded("md"),
|
|
96
|
-
tc.border(),
|
|
97
|
-
tc.bg("popover"),
|
|
98
|
-
tc.p(4),
|
|
99
|
-
tc.text("popoverForeground"),
|
|
100
|
-
tc.shadow("md"),
|
|
101
|
-
tc.outline("none"),
|
|
102
|
-
].flat(),
|
|
103
|
-
children: [
|
|
104
|
-
{
|
|
105
|
-
type: "instance",
|
|
106
|
-
component: "Text",
|
|
107
|
-
children: [{ type: "text", value: "The text you can edit" }],
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const propsMetaPopover: WsComponentPropsMeta = {
|
|
117
|
-
props: propsPopover,
|
|
118
|
-
initialProps: ["open"],
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const propsMetaPopoverTrigger: WsComponentPropsMeta = {
|
|
122
|
-
props: propsPopoverTrigger,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export const propsMetaPopoverContent: WsComponentPropsMeta = {
|
|
126
|
-
props: propsPopoverContent,
|
|
127
|
-
initialProps: ["side", "sideOffset", "align", "alignOffset"],
|
|
128
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const open =
|
|
2
|
-
"Show or hide the content of this component on the canvas. This will not affect the initial state of the component.";
|
|
3
|
-
|
|
4
|
-
const alignOffset =
|
|
5
|
-
"The offset in pixels from the “start“ or “end“ alignment options.";
|
|
6
|
-
|
|
7
|
-
const sideOffset =
|
|
8
|
-
"The distance in pixels between the Content and the Trigger.";
|
|
9
|
-
|
|
10
|
-
const side =
|
|
11
|
-
"The preferred alignment against the Trigger. May change when collisions occur.";
|
|
12
|
-
|
|
13
|
-
export const propsDescriptions = {
|
|
14
|
-
Dialog: {
|
|
15
|
-
open,
|
|
16
|
-
},
|
|
17
|
-
Sheet: {
|
|
18
|
-
open,
|
|
19
|
-
},
|
|
20
|
-
Collapsible: {
|
|
21
|
-
open,
|
|
22
|
-
},
|
|
23
|
-
Popover: {
|
|
24
|
-
open,
|
|
25
|
-
},
|
|
26
|
-
PopoverContent: {
|
|
27
|
-
alignOffset,
|
|
28
|
-
sideOffset,
|
|
29
|
-
side,
|
|
30
|
-
},
|
|
31
|
-
Tooltip: {
|
|
32
|
-
open,
|
|
33
|
-
delayDuration:
|
|
34
|
-
"The delay before the Tooltip shows after the Trigger is hovered, in milliseconds. If no value is specified, the default is 700ms",
|
|
35
|
-
disableHoverableContent:
|
|
36
|
-
"When toggled, prevents the Tooltip content from showing when the Trigger is hovered.",
|
|
37
|
-
},
|
|
38
|
-
TooltipContent: {
|
|
39
|
-
alignOffset,
|
|
40
|
-
sideOffset,
|
|
41
|
-
side,
|
|
42
|
-
},
|
|
43
|
-
};
|
package/src/props.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
propsMetaCollapsible as Collapsible,
|
|
3
|
-
propsMetaCollapsibleTrigger as CollapsibleTrigger,
|
|
4
|
-
propsMetaCollapsibleContent as CollapsibleContent,
|
|
5
|
-
} from "./collapsible.ws";
|
|
6
|
-
export {
|
|
7
|
-
propsMetaDialog as Dialog,
|
|
8
|
-
propsMetaDialogTrigger as DialogTrigger,
|
|
9
|
-
propsMetaDialogOverlay as DialogOverlay,
|
|
10
|
-
propsMetaDialogContent as DialogContent,
|
|
11
|
-
propsMetaDialogClose as DialogClose,
|
|
12
|
-
propsMetaDialogTitle as DialogTitle,
|
|
13
|
-
propsMetaDialogDescription as DialogDescription,
|
|
14
|
-
} from "./dialog.ws";
|
|
15
|
-
export {
|
|
16
|
-
propsMetaPopover as Popover,
|
|
17
|
-
propsMetaPopoverTrigger as PopoverTrigger,
|
|
18
|
-
propsMetaPopoverContent as PopoverContent,
|
|
19
|
-
} from "./popover.ws";
|
|
20
|
-
export {
|
|
21
|
-
propsMetaTooltip as Tooltip,
|
|
22
|
-
propsMetaTooltipTrigger as TooltipTrigger,
|
|
23
|
-
propsMetaTooltipContent as TooltipContent,
|
|
24
|
-
} from "./tooltip.ws";
|
|
25
|
-
export {
|
|
26
|
-
propsMetaTabs as Tabs,
|
|
27
|
-
propsMetaTabsList as TabsList,
|
|
28
|
-
propsMetaTabsTrigger as TabsTrigger,
|
|
29
|
-
propsMetaTabsContent as TabsContent,
|
|
30
|
-
} from "./tabs.ws";
|
|
31
|
-
export { propsMeta as Label } from "./label.ws";
|
|
32
|
-
export {
|
|
33
|
-
propsMetaAccordion as Accordion,
|
|
34
|
-
propsMetaAccordionItem as AccordionItem,
|
|
35
|
-
propsMetaAccordionHeader as AccordionHeader,
|
|
36
|
-
propsMetaAccordionTrigger as AccordionTrigger,
|
|
37
|
-
propsMetaAccordionContent as AccordionContent,
|
|
38
|
-
} from "./accordion.ws";
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
propsMetaNavigationMenu as NavigationMenu,
|
|
42
|
-
propsMetaNavigationMenuList as NavigationMenuList,
|
|
43
|
-
propsMetaNavigationMenuItem as NavigationMenuItem,
|
|
44
|
-
propsMetaNavigationMenuTrigger as NavigationMenuTrigger,
|
|
45
|
-
propsMetaNavigationMenuContent as NavigationMenuContent,
|
|
46
|
-
propsMetaNavigationMenuLink as NavigationMenuLink,
|
|
47
|
-
propsMetaNavigationMenuViewport as NavigationMenuViewport,
|
|
48
|
-
} from "./navigation-menu.ws";
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
propsMetaSelect as Select,
|
|
52
|
-
propsMetaSelectTrigger as SelectTrigger,
|
|
53
|
-
propsMetaSelectValue as SelectValue,
|
|
54
|
-
propsMetaSelectViewport as SelectViewport,
|
|
55
|
-
propsMetaSelectContent as SelectContent,
|
|
56
|
-
propsMetaSelectItem as SelectItem,
|
|
57
|
-
propsMetaSelectItemIndicator as SelectItemIndicator,
|
|
58
|
-
propsMetaSelectItemText as SelectItemText,
|
|
59
|
-
} from "./select.ws";
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
propsMetaSwitch as Switch,
|
|
63
|
-
propsMetaSwitchThumb as SwitchThumb,
|
|
64
|
-
} from "./switch.ws";
|
|
65
|
-
export {
|
|
66
|
-
propsMetaCheckbox as Checkbox,
|
|
67
|
-
propsMetaCheckboxIndicator as CheckboxIndicator,
|
|
68
|
-
} from "./checkbox.ws";
|
|
69
|
-
export {
|
|
70
|
-
propsMetaRadioGroup as RadioGroup,
|
|
71
|
-
propsMetaRadioGroupItem as RadioGroupItem,
|
|
72
|
-
propsMetaRadioGroupIndicator as RadioGroupIndicator,
|
|
73
|
-
} from "./radio-group.ws";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
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 { RadioGroup as RadioGroupPrimitive } from "./radio-group";
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: "Components/RadioGroup",
|
|
11
|
-
component: RadioGroupPrimitive,
|
|
12
|
-
} satisfies Meta<typeof RadioGroupPrimitive>;
|
|
13
|
-
|
|
14
|
-
export const RadioGroup: StoryObj<typeof RadioGroupPrimitive> = {
|
|
15
|
-
render: (props) =>
|
|
16
|
-
renderComponentTemplate({
|
|
17
|
-
name: "RadioGroup",
|
|
18
|
-
props: { ...props },
|
|
19
|
-
components: { ...baseComponents, ...radixComponents },
|
|
20
|
-
metas: { ...baseMetas, ...radixMetas },
|
|
21
|
-
}),
|
|
22
|
-
};
|
package/src/radio-group.tsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ForwardRefExoticComponent,
|
|
3
|
-
type ComponentPropsWithRef,
|
|
4
|
-
} from "react";
|
|
5
|
-
import { Root, Item, Indicator } from "@radix-ui/react-radio-group";
|
|
6
|
-
|
|
7
|
-
export const RadioGroup: ForwardRefExoticComponent<
|
|
8
|
-
ComponentPropsWithRef<typeof Root>
|
|
9
|
-
> = Root;
|
|
10
|
-
|
|
11
|
-
export const RadioGroupItem: ForwardRefExoticComponent<
|
|
12
|
-
ComponentPropsWithRef<typeof Item>
|
|
13
|
-
> = Item;
|
|
14
|
-
|
|
15
|
-
export const RadioGroupIndicator: ForwardRefExoticComponent<
|
|
16
|
-
ComponentPropsWithRef<typeof Indicator>
|
|
17
|
-
> = Indicator;
|
package/src/radio-group.ws.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ItemIcon,
|
|
3
|
-
RadioCheckedIcon,
|
|
4
|
-
RadioDotIcon,
|
|
5
|
-
TriggerIcon,
|
|
6
|
-
} from "@webstudio-is/icons/svg";
|
|
7
|
-
import {
|
|
8
|
-
defaultStates,
|
|
9
|
-
WsEmbedTemplate,
|
|
10
|
-
type WsComponentMeta,
|
|
11
|
-
type WsComponentPropsMeta,
|
|
12
|
-
} from "@webstudio-is/react-sdk";
|
|
13
|
-
import { button, div, span } from "@webstudio-is/react-sdk/css-normalize";
|
|
14
|
-
import * as tc from "./theme/tailwind-classes";
|
|
15
|
-
import { buttonReset } from "./theme/styles";
|
|
16
|
-
import {
|
|
17
|
-
propsRadioGroup,
|
|
18
|
-
propsRadioGroupIndicator,
|
|
19
|
-
propsRadioGroupItem,
|
|
20
|
-
} from "./__generated__/radio-group.props";
|
|
21
|
-
|
|
22
|
-
const createRadioGroupItem = ({
|
|
23
|
-
value,
|
|
24
|
-
label,
|
|
25
|
-
}: {
|
|
26
|
-
value: string;
|
|
27
|
-
label: string;
|
|
28
|
-
}): WsEmbedTemplate[number] => ({
|
|
29
|
-
type: "instance",
|
|
30
|
-
component: "Label",
|
|
31
|
-
// flex items-center space-x-2
|
|
32
|
-
styles: [tc.flex(), tc.items("center"), tc.gap(2)].flat(),
|
|
33
|
-
children: [
|
|
34
|
-
{
|
|
35
|
-
type: "instance",
|
|
36
|
-
component: "RadioGroupItem",
|
|
37
|
-
props: [{ name: "value", type: "string", value }],
|
|
38
|
-
// aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background
|
|
39
|
-
// focus:outline-none
|
|
40
|
-
// focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
|
|
41
|
-
// disabled:cursor-not-allowed disabled:opacity-50
|
|
42
|
-
styles: [
|
|
43
|
-
tc.aspect("square"),
|
|
44
|
-
tc.h(4),
|
|
45
|
-
tc.w(4),
|
|
46
|
-
tc.rounded("full"),
|
|
47
|
-
tc.border(),
|
|
48
|
-
tc.border("primary"),
|
|
49
|
-
tc.text("primary"),
|
|
50
|
-
tc.focusVisible(
|
|
51
|
-
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
52
|
-
),
|
|
53
|
-
tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat()),
|
|
54
|
-
].flat(),
|
|
55
|
-
children: [
|
|
56
|
-
{
|
|
57
|
-
type: "instance",
|
|
58
|
-
component: "RadioGroupIndicator",
|
|
59
|
-
children: [
|
|
60
|
-
{
|
|
61
|
-
type: "instance",
|
|
62
|
-
component: "HtmlEmbed",
|
|
63
|
-
label: "Indicator Icon",
|
|
64
|
-
props: [
|
|
65
|
-
{
|
|
66
|
-
type: "string",
|
|
67
|
-
name: "code",
|
|
68
|
-
value: RadioDotIcon,
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
children: [],
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
type: "instance",
|
|
79
|
-
component: "Text",
|
|
80
|
-
children: [{ type: "text", value: label }],
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
export const metaRadioGroup: WsComponentMeta = {
|
|
86
|
-
category: "radix",
|
|
87
|
-
order: 100,
|
|
88
|
-
type: "container",
|
|
89
|
-
description:
|
|
90
|
-
"A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.",
|
|
91
|
-
icon: RadioCheckedIcon,
|
|
92
|
-
states: [
|
|
93
|
-
...defaultStates,
|
|
94
|
-
{
|
|
95
|
-
label: "Checked",
|
|
96
|
-
selector: "[data-state=checked]",
|
|
97
|
-
category: "component-states",
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
label: "Unchecked",
|
|
101
|
-
selector: "[data-state=unchecked]",
|
|
102
|
-
category: "component-states",
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
presetStyle: {
|
|
106
|
-
div,
|
|
107
|
-
},
|
|
108
|
-
template: [
|
|
109
|
-
{
|
|
110
|
-
type: "instance",
|
|
111
|
-
component: "RadioGroup",
|
|
112
|
-
dataSources: {
|
|
113
|
-
radioGroupValue: { type: "variable", initialValue: "" },
|
|
114
|
-
},
|
|
115
|
-
// grid gap-2
|
|
116
|
-
styles: [tc.flex(), tc.flex("col"), tc.gap(2)].flat(),
|
|
117
|
-
props: [
|
|
118
|
-
{
|
|
119
|
-
type: "dataSource",
|
|
120
|
-
name: "value",
|
|
121
|
-
dataSourceName: "radioGroupValue",
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: "onValueChange",
|
|
125
|
-
type: "action",
|
|
126
|
-
value: [
|
|
127
|
-
{
|
|
128
|
-
type: "execute",
|
|
129
|
-
args: ["value"],
|
|
130
|
-
code: `radioGroupValue = value`,
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
children: [
|
|
136
|
-
createRadioGroupItem({ value: "default", label: "Default" }),
|
|
137
|
-
createRadioGroupItem({ value: "comfortable", label: "Comfortable" }),
|
|
138
|
-
createRadioGroupItem({ value: "compact", label: "Compact" }),
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const metaRadioGroupItem: WsComponentMeta = {
|
|
145
|
-
category: "hidden",
|
|
146
|
-
type: "container",
|
|
147
|
-
requiredAncestors: ["RadioGroup"],
|
|
148
|
-
icon: ItemIcon,
|
|
149
|
-
states: defaultStates,
|
|
150
|
-
presetStyle: {
|
|
151
|
-
button: [button, buttonReset].flat(),
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const metaRadioGroupIndicator: WsComponentMeta = {
|
|
156
|
-
category: "hidden",
|
|
157
|
-
type: "container",
|
|
158
|
-
detachable: false,
|
|
159
|
-
icon: TriggerIcon,
|
|
160
|
-
states: defaultStates,
|
|
161
|
-
presetStyle: {
|
|
162
|
-
span,
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export const propsMetaRadioGroup: WsComponentPropsMeta = {
|
|
167
|
-
props: propsRadioGroup,
|
|
168
|
-
initialProps: ["id", "value", "name", "required"],
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
export const propsMetaRadioGroupItem: WsComponentPropsMeta = {
|
|
172
|
-
props: propsRadioGroupItem,
|
|
173
|
-
initialProps: ["value"],
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export const propsMetaRadioGroupIndicator: WsComponentPropsMeta = {
|
|
177
|
-
props: propsRadioGroupIndicator,
|
|
178
|
-
};
|
package/src/select.tsx
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
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
|
-
type ComponentPropsWithoutRef,
|
|
8
|
-
forwardRef,
|
|
9
|
-
} from "react";
|
|
10
|
-
import {
|
|
11
|
-
Root,
|
|
12
|
-
Value,
|
|
13
|
-
Trigger,
|
|
14
|
-
Content,
|
|
15
|
-
Item,
|
|
16
|
-
ItemIndicator,
|
|
17
|
-
ItemText,
|
|
18
|
-
Portal,
|
|
19
|
-
Viewport,
|
|
20
|
-
} from "@radix-ui/react-select";
|
|
21
|
-
import { type Hook, getClosestInstance } from "@webstudio-is/react-sdk";
|
|
22
|
-
|
|
23
|
-
// wrap in forwardRef because Root is functional component without ref
|
|
24
|
-
export const Select = forwardRef<
|
|
25
|
-
HTMLDivElement,
|
|
26
|
-
ComponentPropsWithoutRef<typeof Root>
|
|
27
|
-
>(({ value, ...props }, _ref) => {
|
|
28
|
-
// radix consider empty string as empty value since this change but not released yet
|
|
29
|
-
// https://github.com/radix-ui/primitives/commit/a3dadb0a825524dd60629d426538dac74930791a
|
|
30
|
-
if (value === "") {
|
|
31
|
-
value = undefined;
|
|
32
|
-
}
|
|
33
|
-
return <Root value={value} {...props} />;
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const SelectTrigger: ForwardRefExoticComponent<
|
|
37
|
-
ComponentPropsWithRef<typeof Trigger>
|
|
38
|
-
> = Trigger;
|
|
39
|
-
|
|
40
|
-
export const SelectValue = forwardRef<
|
|
41
|
-
HTMLDivElement,
|
|
42
|
-
Omit<ComponentPropsWithoutRef<typeof Value>, "placeholder"> & {
|
|
43
|
-
placeholder?: string;
|
|
44
|
-
}
|
|
45
|
-
>((props, ref) => {
|
|
46
|
-
return <Value ref={ref} {...props} />;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export const SelectContent = forwardRef<
|
|
50
|
-
HTMLDivElement,
|
|
51
|
-
Omit<ComponentPropsWithoutRef<typeof Content>, "position" | "side">
|
|
52
|
-
>((props, ref) => {
|
|
53
|
-
return (
|
|
54
|
-
<Portal>
|
|
55
|
-
<Content ref={ref} {...props} position="popper" />
|
|
56
|
-
</Portal>
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
export const SelectViewport: ForwardRefExoticComponent<
|
|
61
|
-
ComponentPropsWithRef<typeof Viewport>
|
|
62
|
-
> = Viewport;
|
|
63
|
-
|
|
64
|
-
export const SelectItem: ForwardRefExoticComponent<
|
|
65
|
-
ComponentPropsWithRef<typeof Item>
|
|
66
|
-
> = Item;
|
|
67
|
-
|
|
68
|
-
export const SelectItemIndicator: ForwardRefExoticComponent<
|
|
69
|
-
ComponentPropsWithRef<typeof ItemIndicator>
|
|
70
|
-
> = ItemIndicator;
|
|
71
|
-
|
|
72
|
-
export const SelectItemText: ForwardRefExoticComponent<
|
|
73
|
-
ComponentPropsWithRef<typeof ItemText>
|
|
74
|
-
> = ItemText;
|
|
75
|
-
|
|
76
|
-
/* BUILDER HOOKS */
|
|
77
|
-
|
|
78
|
-
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
79
|
-
|
|
80
|
-
// For each SelectContent component within the selection,
|
|
81
|
-
// we identify its closest parent Select component
|
|
82
|
-
// and update its open prop bound to variable.
|
|
83
|
-
export const hooksSelect: Hook = {
|
|
84
|
-
onNavigatorUnselect: (context, event) => {
|
|
85
|
-
for (const instance of event.instancePath) {
|
|
86
|
-
if (instance.component === `${namespace}:SelectContent`) {
|
|
87
|
-
const select = getClosestInstance(
|
|
88
|
-
event.instancePath,
|
|
89
|
-
instance,
|
|
90
|
-
`${namespace}:Select`
|
|
91
|
-
);
|
|
92
|
-
if (select) {
|
|
93
|
-
context.setPropVariable(select.id, "open", false);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
onNavigatorSelect: (context, event) => {
|
|
99
|
-
for (const instance of event.instancePath) {
|
|
100
|
-
if (instance.component === `${namespace}:SelectContent`) {
|
|
101
|
-
const select = getClosestInstance(
|
|
102
|
-
event.instancePath,
|
|
103
|
-
instance,
|
|
104
|
-
`${namespace}:Select`
|
|
105
|
-
);
|
|
106
|
-
if (select) {
|
|
107
|
-
context.setPropVariable(select.id, "open", true);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
};
|