@webstudio-is/sdk-components-react-radix 0.87.1 → 0.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__generated__/accordion.props.js +605 -114
- package/lib/__generated__/button.props.js +158 -47
- package/lib/__generated__/checkbox.props.js +1083 -0
- package/lib/__generated__/collapsible.props.js +234 -44
- package/lib/__generated__/dialog.props.js +611 -121
- package/lib/__generated__/input.props.js +264 -47
- package/lib/__generated__/label.props.js +123 -23
- package/lib/__generated__/navigation-menu.props.js +2565 -0
- package/lib/__generated__/popover.props.js +129 -28
- package/lib/__generated__/radio-group.props.js +1627 -0
- package/lib/__generated__/select.props.js +3678 -0
- package/lib/__generated__/sheet.props.js +591 -121
- package/lib/__generated__/switch.props.js +1083 -0
- package/lib/__generated__/tabs.props.js +906 -68
- package/lib/__generated__/textarea.props.js +177 -31
- package/lib/__generated__/tooltip.props.js +131 -29
- package/lib/accordion.js +11 -4
- package/lib/accordion.ws.js +88 -72
- package/lib/checkbox.js +13 -0
- package/lib/checkbox.ws.js +153 -0
- package/lib/cjs/__generated__/accordion.props.js +605 -114
- package/lib/cjs/__generated__/button.props.js +158 -47
- package/lib/cjs/__generated__/checkbox.props.js +1103 -0
- package/lib/cjs/__generated__/collapsible.props.js +234 -44
- package/lib/cjs/__generated__/dialog.props.js +611 -121
- package/lib/cjs/__generated__/input.props.js +264 -47
- package/lib/cjs/__generated__/label.props.js +123 -23
- package/lib/cjs/__generated__/navigation-menu.props.js +2585 -0
- package/lib/cjs/__generated__/popover.props.js +129 -28
- package/lib/cjs/__generated__/radio-group.props.js +1647 -0
- package/lib/cjs/__generated__/select.props.js +3698 -0
- package/lib/cjs/__generated__/sheet.props.js +591 -121
- package/lib/cjs/__generated__/switch.props.js +1103 -0
- package/lib/cjs/__generated__/tabs.props.js +906 -68
- package/lib/cjs/__generated__/textarea.props.js +177 -31
- package/lib/cjs/__generated__/tooltip.props.js +131 -29
- package/lib/cjs/accordion.js +11 -4
- package/lib/cjs/accordion.ws.js +86 -71
- package/lib/cjs/{textarea.js → checkbox.js} +9 -6
- package/lib/cjs/checkbox.ws.js +174 -0
- package/lib/cjs/collapsible.ws.js +5 -1
- package/lib/cjs/components.js +27 -14
- package/lib/cjs/dialog.ws.js +18 -17
- package/lib/cjs/hooks.js +5 -1
- package/lib/cjs/label.ws.js +2 -1
- package/lib/cjs/metas.js +29 -14
- package/lib/cjs/navigation-menu.js +107 -0
- package/lib/cjs/navigation-menu.ws.js +514 -0
- package/lib/cjs/popover.ws.js +13 -9
- package/lib/cjs/props-descriptions.js +56 -0
- package/lib/cjs/props.js +27 -14
- package/lib/cjs/{button.js → radio-group.js} +10 -8
- package/lib/cjs/radio-group.ws.js +191 -0
- package/lib/cjs/select.js +83 -0
- package/lib/cjs/select.ws.js +350 -0
- package/lib/cjs/sheet.ws.js +88 -176
- package/lib/cjs/{input.js → switch.js} +8 -9
- package/lib/cjs/switch.ws.js +173 -0
- package/lib/cjs/tabs.js +2 -3
- package/lib/cjs/tabs.ws.js +14 -18
- package/lib/cjs/theme/styles.js +100 -0
- package/lib/cjs/theme/tailwind-classes.js +125 -16
- package/lib/cjs/theme/tailwind-colors.js +1 -0
- package/lib/cjs/tooltip.ws.js +12 -8
- package/lib/collapsible.ws.js +5 -1
- package/lib/components.js +44 -22
- package/lib/dialog.ws.js +18 -17
- package/lib/hooks.js +5 -1
- package/lib/label.ws.js +2 -1
- package/lib/metas.js +58 -24
- package/lib/navigation-menu.js +85 -0
- package/lib/navigation-menu.ws.js +501 -0
- package/lib/popover.ws.js +13 -9
- package/lib/props-descriptions.js +36 -0
- package/lib/props.js +56 -24
- package/lib/radio-group.js +11 -0
- package/lib/radio-group.ws.js +173 -0
- package/lib/select.js +75 -0
- package/lib/select.ws.js +338 -0
- package/lib/sheet.ws.js +89 -194
- package/lib/switch.js +7 -0
- package/lib/switch.ws.js +145 -0
- package/lib/tabs.js +3 -5
- package/lib/tabs.ws.js +15 -19
- package/lib/theme/styles.js +70 -0
- package/lib/theme/tailwind-classes.js +125 -16
- package/lib/theme/tailwind-colors.js +1 -0
- package/lib/tooltip.ws.js +12 -8
- package/lib/types/__generated__/checkbox.props.d.ts +3 -0
- package/lib/types/__generated__/navigation-menu.props.d.ts +8 -0
- package/lib/types/__generated__/radio-group.props.d.ts +4 -0
- package/lib/types/__generated__/select.props.d.ts +9 -0
- package/lib/types/__generated__/switch.props.d.ts +3 -0
- package/lib/types/checkbox.d.ts +6 -0
- package/lib/types/checkbox.stories.d.ts +11 -0
- package/lib/types/checkbox.ws.d.ts +5 -0
- package/lib/types/components.d.ts +5 -4
- package/lib/types/metas.d.ts +6 -4
- package/lib/types/navigation-menu.d.ts +15 -0
- package/lib/types/navigation-menu.ws.d.ts +15 -0
- package/lib/types/props-descriptions.d.ts +29 -0
- package/lib/types/props.d.ts +5 -4
- package/lib/types/radio-group.d.ts +5 -0
- package/lib/types/radio-group.stories.d.ts +9 -0
- package/lib/types/radio-group.ws.d.ts +7 -0
- package/lib/types/select.d.ts +14 -0
- package/lib/types/select.ws.d.ts +17 -0
- package/lib/types/sheet.ws.d.ts +2 -15
- package/lib/types/switch.d.ts +4 -0
- package/lib/types/switch.stories.d.ts +9 -0
- package/lib/types/switch.ws.d.ts +5 -0
- package/lib/types/tabs.d.ts +3 -12
- package/lib/types/theme/radix-common-types.d.ts +3 -2
- package/lib/types/theme/styles.d.ts +215 -0
- package/lib/types/theme/tailwind-classes.d.ts +16 -6
- package/lib/types/theme/tailwind-colors.d.ts +1 -0
- package/lib/types/theme/tailwind-theme.d.ts +1 -1
- package/package.json +12 -7
- package/src/__generated__/accordion.props.ts +675 -108
- package/src/__generated__/button.props.ts +177 -45
- package/src/__generated__/checkbox.props.ts +1217 -0
- package/src/__generated__/collapsible.props.ts +261 -42
- package/src/__generated__/dialog.props.ts +682 -115
- package/src/__generated__/input.props.ts +292 -44
- package/src/__generated__/label.props.ts +137 -22
- package/src/__generated__/navigation-menu.props.ts +2882 -0
- package/src/__generated__/popover.props.ts +142 -24
- package/src/__generated__/radio-group.props.ts +1828 -0
- package/src/__generated__/select.props.ts +4130 -0
- package/src/__generated__/sheet.props.ts +657 -110
- package/src/__generated__/switch.props.ts +1217 -0
- package/src/__generated__/tabs.props.ts +1019 -67
- package/src/__generated__/textarea.props.ts +195 -30
- package/src/__generated__/tooltip.props.ts +145 -25
- package/src/accordion.tsx +14 -7
- package/src/accordion.ws.ts +87 -70
- package/src/{textarea.stories.ts → checkbox.stories.ts} +6 -11
- package/src/checkbox.tsx +22 -0
- package/src/checkbox.ws.ts +154 -0
- package/src/collapsible.ws.ts +6 -1
- package/src/components.ts +25 -12
- package/src/dialog.ws.tsx +17 -16
- package/src/hooks.ts +4 -0
- package/src/label.ws.ts +3 -1
- package/src/metas.ts +36 -12
- package/src/navigation-menu.stories.tsx +21 -0
- package/src/navigation-menu.tsx +130 -0
- package/src/navigation-menu.ws.ts +524 -0
- package/src/popover.ws.tsx +13 -9
- package/src/props-descriptions.ts +43 -0
- package/src/props.ts +35 -12
- package/src/{input.stories.ts → radio-group.stories.ts} +6 -15
- package/src/radio-group.tsx +17 -0
- package/src/radio-group.ws.ts +178 -0
- package/src/select.stories.tsx +21 -0
- package/src/select.tsx +112 -0
- package/src/select.ws.ts +349 -0
- package/src/sheet.ws.tsx +91 -209
- package/src/{button.stories.ts → switch.stories.ts} +6 -19
- package/src/switch.tsx +10 -0
- package/src/switch.ws.ts +146 -0
- package/src/tabs.tsx +4 -17
- package/src/tabs.ws.ts +19 -19
- package/src/theme/radix-common-types.ts +3 -2
- package/src/theme/styles.ts +80 -0
- package/src/theme/tailwind-classes.ts +150 -14
- package/src/theme/tailwind-colors.ts +1 -0
- package/src/tooltip.ws.tsx +13 -8
- package/lib/button.js +0 -8
- package/lib/button.ws.js +0 -133
- package/lib/cjs/button.ws.js +0 -160
- package/lib/cjs/input.ws.js +0 -103
- package/lib/cjs/textarea.ws.js +0 -98
- package/lib/input.js +0 -8
- package/lib/input.ws.js +0 -75
- package/lib/textarea.js +0 -8
- package/lib/textarea.ws.js +0 -70
- package/lib/types/button.d.ts +0 -7
- package/lib/types/button.stories.d.ts +0 -20
- package/lib/types/button.ws.d.ts +0 -7
- package/lib/types/input.d.ts +0 -2
- package/lib/types/input.stories.d.ts +0 -20
- package/lib/types/input.ws.d.ts +0 -3
- package/lib/types/textarea.d.ts +0 -2
- package/lib/types/textarea.stories.d.ts +0 -14
- package/lib/types/textarea.ws.d.ts +0 -3
- package/src/button.tsx +0 -25
- package/src/button.ws.ts +0 -155
- package/src/input.tsx +0 -12
- package/src/input.ws.ts +0 -78
- package/src/textarea.tsx +0 -12
- package/src/textarea.ws.ts +0 -74
package/src/metas.ts
CHANGED
|
@@ -12,6 +12,7 @@ export {
|
|
|
12
12
|
metaDialogTitle as DialogTitle,
|
|
13
13
|
metaDialogDescription as DialogDescription,
|
|
14
14
|
} from "./dialog.ws";
|
|
15
|
+
export { meta as Sheet } from "./sheet.ws";
|
|
15
16
|
export {
|
|
16
17
|
metaPopover as Popover,
|
|
17
18
|
metaPopoverTrigger as PopoverTrigger,
|
|
@@ -22,24 +23,12 @@ export {
|
|
|
22
23
|
metaTooltipTrigger as TooltipTrigger,
|
|
23
24
|
metaTooltipContent as TooltipContent,
|
|
24
25
|
} from "./tooltip.ws";
|
|
25
|
-
export {
|
|
26
|
-
metaSheet as Sheet,
|
|
27
|
-
metaSheetTrigger as SheetTrigger,
|
|
28
|
-
metaSheetOverlay as SheetOverlay,
|
|
29
|
-
metaSheetContent as SheetContent,
|
|
30
|
-
metaSheetClose as SheetClose,
|
|
31
|
-
metaSheetTitle as SheetTitle,
|
|
32
|
-
metaSheetDescription as SheetDescription,
|
|
33
|
-
} from "./sheet.ws";
|
|
34
26
|
export {
|
|
35
27
|
metaTabs as Tabs,
|
|
36
28
|
metaTabsList as TabsList,
|
|
37
29
|
metaTabsTrigger as TabsTrigger,
|
|
38
30
|
metaTabsContent as TabsContent,
|
|
39
31
|
} from "./tabs.ws";
|
|
40
|
-
export { meta as Button } from "./button.ws";
|
|
41
|
-
export { meta as Input } from "./input.ws";
|
|
42
|
-
export { meta as Textarea } from "./textarea.ws";
|
|
43
32
|
export { meta as Label } from "./label.ws";
|
|
44
33
|
export {
|
|
45
34
|
metaAccordion as Accordion,
|
|
@@ -48,3 +37,38 @@ export {
|
|
|
48
37
|
metaAccordionTrigger as AccordionTrigger,
|
|
49
38
|
metaAccordionContent as AccordionContent,
|
|
50
39
|
} from "./accordion.ws";
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
metaNavigationMenu as NavigationMenu,
|
|
43
|
+
metaNavigationMenuList as NavigationMenuList,
|
|
44
|
+
metaNavigationMenuItem as NavigationMenuItem,
|
|
45
|
+
metaNavigationMenuTrigger as NavigationMenuTrigger,
|
|
46
|
+
metaNavigationMenuContent as NavigationMenuContent,
|
|
47
|
+
metaNavigationMenuLink as NavigationMenuLink,
|
|
48
|
+
metaNavigationMenuViewport as NavigationMenuViewport,
|
|
49
|
+
} from "./navigation-menu.ws";
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
metaSelect as Select,
|
|
53
|
+
metaSelectTrigger as SelectTrigger,
|
|
54
|
+
metaSelectValue as SelectValue,
|
|
55
|
+
metaSelectViewport as SelectViewport,
|
|
56
|
+
metaSelectContent as SelectContent,
|
|
57
|
+
metaSelectItem as SelectItem,
|
|
58
|
+
metaSelectItemIndicator as SelectItemIndicator,
|
|
59
|
+
metaSelectItemText as SelectItemText,
|
|
60
|
+
} from "./select.ws";
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
metaSwitch as Switch,
|
|
64
|
+
metaSwitchThumb as SwitchThumb,
|
|
65
|
+
} from "./switch.ws";
|
|
66
|
+
export {
|
|
67
|
+
metaCheckbox as Checkbox,
|
|
68
|
+
metaCheckboxIndicator as CheckboxIndicator,
|
|
69
|
+
} from "./checkbox.ws";
|
|
70
|
+
export {
|
|
71
|
+
metaRadioGroup as RadioGroup,
|
|
72
|
+
metaRadioGroupItem as RadioGroupItem,
|
|
73
|
+
metaRadioGroupIndicator as RadioGroupIndicator,
|
|
74
|
+
} from "./radio-group.ws";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { renderComponentTemplate } from "@webstudio-is/react-sdk";
|
|
3
|
+
import { NavigationMenu as NavigationMenuPrimitive } from "./navigation-menu";
|
|
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
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: "Components/NavigationMenu",
|
|
11
|
+
component: NavigationMenuPrimitive,
|
|
12
|
+
} satisfies Meta<typeof NavigationMenuPrimitive>;
|
|
13
|
+
|
|
14
|
+
export const NavigationMenu: StoryObj<typeof NavigationMenuPrimitive> = {
|
|
15
|
+
render: () =>
|
|
16
|
+
renderComponentTemplate({
|
|
17
|
+
name: "NavigationMenu",
|
|
18
|
+
components: { ...baseComponents, ...radixComponents },
|
|
19
|
+
metas: { ...baseMetas, ...radixMetas },
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
2
|
+
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
|
3
|
+
import {
|
|
4
|
+
getClosestInstance,
|
|
5
|
+
getIndexWithinAncestorFromComponentProps,
|
|
6
|
+
ReactSdkContext,
|
|
7
|
+
type Hook,
|
|
8
|
+
} from "@webstudio-is/react-sdk";
|
|
9
|
+
import {
|
|
10
|
+
Children,
|
|
11
|
+
forwardRef,
|
|
12
|
+
type ComponentPropsWithoutRef,
|
|
13
|
+
type ReactNode,
|
|
14
|
+
useContext,
|
|
15
|
+
} from "react";
|
|
16
|
+
|
|
17
|
+
export const NavigationMenu = forwardRef<
|
|
18
|
+
HTMLLIElement,
|
|
19
|
+
Omit<
|
|
20
|
+
ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>,
|
|
21
|
+
"orientation" | "aria-orientation"
|
|
22
|
+
>
|
|
23
|
+
>(({ value: propsValue, ...props }, ref) => {
|
|
24
|
+
/**
|
|
25
|
+
* If the value is an empty string, "NavigationMenuViewport" isn't in the tree.
|
|
26
|
+
* This is Radix's way to differentiate animations. However, in the builder, we can't style non-existing elements.
|
|
27
|
+
* Since we don't need animations in the builder, we can trick Radix by setting a non-empty string like "-1" to the value property.
|
|
28
|
+
* This ensures "NavigationMenuViewport" always appears in the HTML tree.
|
|
29
|
+
**/
|
|
30
|
+
const { renderer } = useContext(ReactSdkContext);
|
|
31
|
+
let value = propsValue;
|
|
32
|
+
if (renderer === "canvas") {
|
|
33
|
+
value = value === "" ? "-1" : value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return <NavigationMenuPrimitive.Root ref={ref} value={value} {...props} />;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const NavigationMenuList = NavigationMenuPrimitive.List;
|
|
40
|
+
|
|
41
|
+
export const NavigationMenuViewport = NavigationMenuPrimitive.Viewport;
|
|
42
|
+
export const NavigationMenuContent = NavigationMenuPrimitive.Content;
|
|
43
|
+
|
|
44
|
+
export const NavigationMenuItem = forwardRef<
|
|
45
|
+
HTMLLIElement,
|
|
46
|
+
Omit<ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Item>, "asChild">
|
|
47
|
+
>(({ value, ...props }, ref) => {
|
|
48
|
+
const index = getIndexWithinAncestorFromComponentProps(props);
|
|
49
|
+
return (
|
|
50
|
+
<NavigationMenuPrimitive.Item ref={ref} value={value ?? index} {...props} />
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const NavigationMenuLink = forwardRef<
|
|
55
|
+
HTMLAnchorElement,
|
|
56
|
+
{ children: ReactNode }
|
|
57
|
+
>(({ children, ...props }, ref) => {
|
|
58
|
+
const firstChild = Children.toArray(children)[0];
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<NavigationMenuPrimitive.Link asChild={true} ref={ref} {...props}>
|
|
62
|
+
{firstChild ?? <a>Add link component</a>}
|
|
63
|
+
</NavigationMenuPrimitive.Link>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const NavigationMenuTrigger = forwardRef<
|
|
68
|
+
HTMLButtonElement,
|
|
69
|
+
{ children: ReactNode }
|
|
70
|
+
>(({ children, ...props }, ref) => {
|
|
71
|
+
const firstChild = Children.toArray(children)[0];
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<NavigationMenuPrimitive.Trigger asChild={true} ref={ref} {...props}>
|
|
75
|
+
{firstChild ?? <button>Add button or link</button>}
|
|
76
|
+
</NavigationMenuPrimitive.Trigger>
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
81
|
+
|
|
82
|
+
// For each NavigationMenuItem component within the selection,
|
|
83
|
+
// we identify its closest parent NavigationMenu component
|
|
84
|
+
// and update its open prop bound to variable.
|
|
85
|
+
export const hooksNavigationMenu: Hook = {
|
|
86
|
+
onNavigatorUnselect: (context, event) => {
|
|
87
|
+
for (const instance of event.instancePath) {
|
|
88
|
+
if (instance.component === `${namespace}:NavigationMenuContent`) {
|
|
89
|
+
const menu = getClosestInstance(
|
|
90
|
+
event.instancePath,
|
|
91
|
+
instance,
|
|
92
|
+
`${namespace}:NavigationMenu`
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
if (menu) {
|
|
96
|
+
context.setPropVariable(menu.id, "value", "");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
onNavigatorSelect: (context, event) => {
|
|
102
|
+
for (const instance of event.instancePath) {
|
|
103
|
+
if (instance.component === `${namespace}:NavigationMenuContent`) {
|
|
104
|
+
const menu = getClosestInstance(
|
|
105
|
+
event.instancePath,
|
|
106
|
+
instance,
|
|
107
|
+
`${namespace}:NavigationMenu`
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const menuItem = getClosestInstance(
|
|
111
|
+
event.instancePath,
|
|
112
|
+
instance,
|
|
113
|
+
`${namespace}:NavigationMenuItem`
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
if (menuItem === undefined || menu === undefined) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const contentValue =
|
|
121
|
+
context.getPropValue(menuItem.id, "value") ??
|
|
122
|
+
context.indexesWithinAncestors.get(menuItem.id)?.toString();
|
|
123
|
+
|
|
124
|
+
if (contentValue) {
|
|
125
|
+
context.setPropVariable(menu.id, "value", contentValue);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
};
|