@webstudio-is/sdk-components-react-radix 0.91.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 +15 -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 -315
- 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 -320
- 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/collapsible.ws.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CollapsibleIcon,
|
|
3
|
-
TriggerIcon,
|
|
4
|
-
ContentIcon,
|
|
5
|
-
} from "@webstudio-is/icons/svg";
|
|
6
|
-
import type {
|
|
7
|
-
PresetStyle,
|
|
8
|
-
WsComponentMeta,
|
|
9
|
-
WsComponentPropsMeta,
|
|
10
|
-
} from "@webstudio-is/react-sdk";
|
|
11
|
-
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
12
|
-
import {
|
|
13
|
-
propsCollapsible,
|
|
14
|
-
propsCollapsibleContent,
|
|
15
|
-
propsCollapsibleTrigger,
|
|
16
|
-
} from "./__generated__/collapsible.props";
|
|
17
|
-
import { getButtonStyles } from "./theme/styles";
|
|
18
|
-
|
|
19
|
-
const presetStyle = {
|
|
20
|
-
div,
|
|
21
|
-
} satisfies PresetStyle<"div">;
|
|
22
|
-
|
|
23
|
-
export const metaCollapsible: WsComponentMeta = {
|
|
24
|
-
category: "radix",
|
|
25
|
-
order: 5,
|
|
26
|
-
type: "container",
|
|
27
|
-
presetStyle,
|
|
28
|
-
icon: CollapsibleIcon,
|
|
29
|
-
description:
|
|
30
|
-
"An interactive component which expands and collapses some content, triggered by a button.",
|
|
31
|
-
template: [
|
|
32
|
-
{
|
|
33
|
-
type: "instance",
|
|
34
|
-
component: "Collapsible",
|
|
35
|
-
dataSources: {
|
|
36
|
-
collapsibleOpen: { type: "variable", initialValue: false },
|
|
37
|
-
},
|
|
38
|
-
props: [
|
|
39
|
-
{
|
|
40
|
-
type: "dataSource",
|
|
41
|
-
name: "open",
|
|
42
|
-
dataSourceName: "collapsibleOpen",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "onOpenChange",
|
|
46
|
-
type: "action",
|
|
47
|
-
value: [
|
|
48
|
-
{ type: "execute", args: ["open"], code: `collapsibleOpen = open` },
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
children: [
|
|
53
|
-
{
|
|
54
|
-
type: "instance",
|
|
55
|
-
component: "CollapsibleTrigger",
|
|
56
|
-
children: [
|
|
57
|
-
{
|
|
58
|
-
type: "instance",
|
|
59
|
-
component: "Button",
|
|
60
|
-
styles: getButtonStyles("outline"),
|
|
61
|
-
children: [{ type: "text", value: "Click to toggle content" }],
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
type: "instance",
|
|
67
|
-
component: "CollapsibleContent",
|
|
68
|
-
children: [
|
|
69
|
-
{
|
|
70
|
-
type: "instance",
|
|
71
|
-
component: "Text",
|
|
72
|
-
children: [{ type: "text", value: "Collapsible Content" }],
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const metaCollapsibleTrigger: WsComponentMeta = {
|
|
82
|
-
category: "hidden",
|
|
83
|
-
type: "container",
|
|
84
|
-
icon: TriggerIcon,
|
|
85
|
-
stylable: false,
|
|
86
|
-
detachable: false,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const metaCollapsibleContent: WsComponentMeta = {
|
|
90
|
-
category: "hidden",
|
|
91
|
-
type: "container",
|
|
92
|
-
presetStyle,
|
|
93
|
-
icon: ContentIcon,
|
|
94
|
-
detachable: false,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const propsMetaCollapsible: WsComponentPropsMeta = {
|
|
98
|
-
props: {
|
|
99
|
-
...propsCollapsible,
|
|
100
|
-
onOpenChange: {
|
|
101
|
-
type: "action",
|
|
102
|
-
control: "action",
|
|
103
|
-
required: false,
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
initialProps: ["open", "onOpenChange"],
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const propsMetaCollapsibleTrigger: WsComponentPropsMeta = {
|
|
110
|
-
props: propsCollapsibleTrigger,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const propsMetaCollapsibleContent: WsComponentPropsMeta = {
|
|
114
|
-
props: propsCollapsibleContent,
|
|
115
|
-
};
|
package/src/components.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
Collapsible,
|
|
3
|
-
CollapsibleTrigger,
|
|
4
|
-
CollapsibleContent,
|
|
5
|
-
} from "./collapsible";
|
|
6
|
-
export {
|
|
7
|
-
Dialog,
|
|
8
|
-
DialogTrigger,
|
|
9
|
-
DialogOverlay,
|
|
10
|
-
DialogContent,
|
|
11
|
-
DialogClose,
|
|
12
|
-
DialogTitle,
|
|
13
|
-
DialogDescription,
|
|
14
|
-
} from "./dialog";
|
|
15
|
-
export { Popover, PopoverTrigger, PopoverContent } from "./popover";
|
|
16
|
-
export { Tooltip, TooltipTrigger, TooltipContent } from "./tooltip";
|
|
17
|
-
export { Tabs, TabsList, TabsTrigger, TabsContent } from "./tabs";
|
|
18
|
-
export { Label } from "./label";
|
|
19
|
-
export {
|
|
20
|
-
Accordion,
|
|
21
|
-
AccordionItem,
|
|
22
|
-
AccordionHeader,
|
|
23
|
-
AccordionTrigger,
|
|
24
|
-
AccordionContent,
|
|
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.tsx
DELETED
|
@@ -1,92 +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 ComponentPropsWithoutRef,
|
|
6
|
-
type ReactNode,
|
|
7
|
-
forwardRef,
|
|
8
|
-
Children,
|
|
9
|
-
} from "react";
|
|
10
|
-
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
11
|
-
import { getClosestInstance, type Hook } from "@webstudio-is/react-sdk";
|
|
12
|
-
|
|
13
|
-
// wrap in forwardRef because Root is functional component without ref
|
|
14
|
-
export const Dialog = forwardRef<
|
|
15
|
-
HTMLDivElement,
|
|
16
|
-
Omit<ComponentPropsWithoutRef<typeof DialogPrimitive.Root>, "defaultOpen">
|
|
17
|
-
>((props, _ref) => {
|
|
18
|
-
return <DialogPrimitive.Root {...props} />;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* We're not exposing the 'asChild' property for the Trigger.
|
|
23
|
-
* Instead, we're enforcing 'asChild=true' for the Trigger and making it style-less.
|
|
24
|
-
* This avoids situations where the Trigger inadvertently passes all styles to its child,
|
|
25
|
-
* which would prevent us from displaying styles properly in the builder.
|
|
26
|
-
*/
|
|
27
|
-
export const DialogTrigger = forwardRef<
|
|
28
|
-
HTMLButtonElement,
|
|
29
|
-
{ children: ReactNode }
|
|
30
|
-
>(({ children, ...props }, ref) => {
|
|
31
|
-
const firstChild = Children.toArray(children)[0];
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<DialogPrimitive.Trigger ref={ref} asChild={true} {...props}>
|
|
35
|
-
{firstChild ?? <button>Add button or link</button>}
|
|
36
|
-
</DialogPrimitive.Trigger>
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const DialogOverlay = forwardRef<
|
|
41
|
-
HTMLDivElement,
|
|
42
|
-
ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
43
|
-
>((props, ref) => {
|
|
44
|
-
return (
|
|
45
|
-
<DialogPrimitive.DialogPortal>
|
|
46
|
-
<DialogPrimitive.Overlay ref={ref} {...props} />
|
|
47
|
-
</DialogPrimitive.DialogPortal>
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export const DialogContent = DialogPrimitive.Content;
|
|
52
|
-
export const DialogClose = DialogPrimitive.Close;
|
|
53
|
-
export const DialogTitle = DialogPrimitive.Title;
|
|
54
|
-
export const DialogDescription = DialogPrimitive.Description;
|
|
55
|
-
|
|
56
|
-
/* BUILDER HOOKS */
|
|
57
|
-
|
|
58
|
-
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
59
|
-
|
|
60
|
-
// For each DialogOverlay component within the selection,
|
|
61
|
-
// we identify its closest parent Dialog component
|
|
62
|
-
// and update its open prop bound to variable.
|
|
63
|
-
export const hooksDialog: Hook = {
|
|
64
|
-
onNavigatorUnselect: (context, event) => {
|
|
65
|
-
for (const instance of event.instancePath) {
|
|
66
|
-
if (instance.component === `${namespace}:DialogOverlay`) {
|
|
67
|
-
const dialog = getClosestInstance(
|
|
68
|
-
event.instancePath,
|
|
69
|
-
instance,
|
|
70
|
-
`${namespace}:Dialog`
|
|
71
|
-
);
|
|
72
|
-
if (dialog) {
|
|
73
|
-
context.setPropVariable(dialog.id, "open", false);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
onNavigatorSelect: (context, event) => {
|
|
79
|
-
for (const instance of event.instancePath) {
|
|
80
|
-
if (instance.component === `${namespace}:DialogOverlay`) {
|
|
81
|
-
const dialog = getClosestInstance(
|
|
82
|
-
event.instancePath,
|
|
83
|
-
instance,
|
|
84
|
-
`${namespace}:Dialog`
|
|
85
|
-
);
|
|
86
|
-
if (dialog) {
|
|
87
|
-
context.setPropVariable(dialog.id, "open", true);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
};
|
package/src/dialog.ws.tsx
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DialogIcon,
|
|
3
|
-
TriggerIcon,
|
|
4
|
-
ContentIcon,
|
|
5
|
-
OverlayIcon,
|
|
6
|
-
HeadingIcon,
|
|
7
|
-
TextIcon,
|
|
8
|
-
ButtonElementIcon,
|
|
9
|
-
LargeXIcon,
|
|
10
|
-
} from "@webstudio-is/icons/svg";
|
|
11
|
-
import {
|
|
12
|
-
defaultStates,
|
|
13
|
-
type PresetStyle,
|
|
14
|
-
type WsComponentMeta,
|
|
15
|
-
type WsComponentPropsMeta,
|
|
16
|
-
} from "@webstudio-is/react-sdk";
|
|
17
|
-
import { div, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
|
|
18
|
-
import * as tc from "./theme/tailwind-classes";
|
|
19
|
-
import {
|
|
20
|
-
propsDialog,
|
|
21
|
-
propsDialogContent,
|
|
22
|
-
propsDialogTrigger,
|
|
23
|
-
propsDialogOverlay,
|
|
24
|
-
propsDialogClose,
|
|
25
|
-
propsDialogTitle,
|
|
26
|
-
propsDialogDescription,
|
|
27
|
-
} from "./__generated__/dialog.props";
|
|
28
|
-
import { buttonReset, getButtonStyles } from "./theme/styles";
|
|
29
|
-
|
|
30
|
-
const presetStyle = {
|
|
31
|
-
div,
|
|
32
|
-
} satisfies PresetStyle<"div">;
|
|
33
|
-
|
|
34
|
-
const titlePresetStyle = {
|
|
35
|
-
h2,
|
|
36
|
-
} satisfies PresetStyle<"h2">;
|
|
37
|
-
|
|
38
|
-
const descriptionPresetStyle = {
|
|
39
|
-
p,
|
|
40
|
-
} satisfies PresetStyle<"p">;
|
|
41
|
-
|
|
42
|
-
// @todo add [data-state] to button and link
|
|
43
|
-
export const metaDialogTrigger: WsComponentMeta = {
|
|
44
|
-
category: "hidden",
|
|
45
|
-
type: "container",
|
|
46
|
-
icon: TriggerIcon,
|
|
47
|
-
stylable: false,
|
|
48
|
-
detachable: false,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const metaDialogContent: WsComponentMeta = {
|
|
52
|
-
category: "hidden",
|
|
53
|
-
type: "container",
|
|
54
|
-
presetStyle,
|
|
55
|
-
icon: ContentIcon,
|
|
56
|
-
detachable: false,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const metaDialogOverlay: WsComponentMeta = {
|
|
60
|
-
category: "hidden",
|
|
61
|
-
type: "container",
|
|
62
|
-
presetStyle,
|
|
63
|
-
icon: OverlayIcon,
|
|
64
|
-
detachable: false,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const metaDialogTitle: WsComponentMeta = {
|
|
68
|
-
category: "hidden",
|
|
69
|
-
type: "container",
|
|
70
|
-
presetStyle: titlePresetStyle,
|
|
71
|
-
icon: HeadingIcon,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const metaDialogDescription: WsComponentMeta = {
|
|
75
|
-
category: "hidden",
|
|
76
|
-
type: "container",
|
|
77
|
-
presetStyle: descriptionPresetStyle,
|
|
78
|
-
icon: TextIcon,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const metaDialogClose: WsComponentMeta = {
|
|
82
|
-
category: "hidden",
|
|
83
|
-
type: "container",
|
|
84
|
-
presetStyle: {
|
|
85
|
-
button: [buttonReset, button].flat(),
|
|
86
|
-
},
|
|
87
|
-
states: defaultStates,
|
|
88
|
-
icon: ButtonElementIcon,
|
|
89
|
-
label: "Close Button",
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Styles source without animations:
|
|
94
|
-
* https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/dialog.tsx
|
|
95
|
-
*
|
|
96
|
-
* Attributions
|
|
97
|
-
* MIT License
|
|
98
|
-
* Copyright (c) 2023 shadcn
|
|
99
|
-
**/
|
|
100
|
-
export const metaDialog: WsComponentMeta = {
|
|
101
|
-
category: "radix",
|
|
102
|
-
order: 4,
|
|
103
|
-
type: "container",
|
|
104
|
-
icon: DialogIcon,
|
|
105
|
-
stylable: false,
|
|
106
|
-
description:
|
|
107
|
-
"Displays content with an overlay that covers the window, triggered by a button. Clicking the overlay will close the dialog.",
|
|
108
|
-
template: [
|
|
109
|
-
{
|
|
110
|
-
type: "instance",
|
|
111
|
-
component: "Dialog",
|
|
112
|
-
dataSources: {
|
|
113
|
-
dialogOpen: { type: "variable", initialValue: false },
|
|
114
|
-
},
|
|
115
|
-
props: [
|
|
116
|
-
{
|
|
117
|
-
type: "dataSource",
|
|
118
|
-
name: "open",
|
|
119
|
-
dataSourceName: "dialogOpen",
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: "onOpenChange",
|
|
123
|
-
type: "action",
|
|
124
|
-
value: [
|
|
125
|
-
{ type: "execute", args: ["open"], code: `dialogOpen = open` },
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
children: [
|
|
130
|
-
{
|
|
131
|
-
type: "instance",
|
|
132
|
-
component: "DialogTrigger",
|
|
133
|
-
children: [
|
|
134
|
-
{
|
|
135
|
-
type: "instance",
|
|
136
|
-
component: "Button",
|
|
137
|
-
styles: getButtonStyles("outline"),
|
|
138
|
-
children: [{ type: "text", value: "Button" }],
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
type: "instance",
|
|
144
|
-
component: "DialogOverlay",
|
|
145
|
-
/**
|
|
146
|
-
* fixed inset-0 z-50 bg-background/80 backdrop-blur-sm
|
|
147
|
-
* flex
|
|
148
|
-
**/
|
|
149
|
-
styles: [
|
|
150
|
-
tc.fixed(),
|
|
151
|
-
tc.inset(0),
|
|
152
|
-
tc.z(50),
|
|
153
|
-
tc.bg("background", 80),
|
|
154
|
-
tc.backdropBlur("sm"),
|
|
155
|
-
// To allow positioning Content
|
|
156
|
-
tc.flex(),
|
|
157
|
-
tc.overflow("auto"),
|
|
158
|
-
].flat(),
|
|
159
|
-
children: [
|
|
160
|
-
{
|
|
161
|
-
type: "instance",
|
|
162
|
-
component: "DialogContent",
|
|
163
|
-
/**
|
|
164
|
-
* fixed w-full z-50
|
|
165
|
-
* grid gap-4 max-w-lg
|
|
166
|
-
* m-auto
|
|
167
|
-
* border bg-background p-6 shadow-lg
|
|
168
|
-
**/
|
|
169
|
-
styles: [
|
|
170
|
-
tc.w("full"),
|
|
171
|
-
tc.z(50),
|
|
172
|
-
tc.flex(),
|
|
173
|
-
tc.flex("col"),
|
|
174
|
-
tc.gap(4),
|
|
175
|
-
tc.m("auto"),
|
|
176
|
-
tc.maxW("lg"),
|
|
177
|
-
tc.border(),
|
|
178
|
-
tc.bg("background"),
|
|
179
|
-
tc.p(6),
|
|
180
|
-
tc.shadow("lg"),
|
|
181
|
-
tc.relative(),
|
|
182
|
-
].flat(),
|
|
183
|
-
children: [
|
|
184
|
-
{
|
|
185
|
-
type: "instance",
|
|
186
|
-
component: "Box",
|
|
187
|
-
label: "Dialog Header",
|
|
188
|
-
styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
|
|
189
|
-
children: [
|
|
190
|
-
{
|
|
191
|
-
type: "instance",
|
|
192
|
-
component: "DialogTitle",
|
|
193
|
-
/**
|
|
194
|
-
* text-lg leading-none tracking-tight
|
|
195
|
-
**/
|
|
196
|
-
styles: [
|
|
197
|
-
tc.my(0),
|
|
198
|
-
tc.leading("none"),
|
|
199
|
-
tc.text("lg"),
|
|
200
|
-
tc.tracking("tight"),
|
|
201
|
-
].flat(),
|
|
202
|
-
children: [
|
|
203
|
-
{
|
|
204
|
-
type: "text",
|
|
205
|
-
value: "Dialog Title",
|
|
206
|
-
},
|
|
207
|
-
],
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
type: "instance",
|
|
211
|
-
component: "DialogDescription",
|
|
212
|
-
/**
|
|
213
|
-
* text-sm text-muted-foreground
|
|
214
|
-
**/
|
|
215
|
-
styles: [
|
|
216
|
-
tc.my(0),
|
|
217
|
-
tc.text("sm"),
|
|
218
|
-
tc.text("mutedForeground"),
|
|
219
|
-
].flat(),
|
|
220
|
-
children: [
|
|
221
|
-
{
|
|
222
|
-
type: "text",
|
|
223
|
-
value: "Dialog description text you can edit",
|
|
224
|
-
},
|
|
225
|
-
],
|
|
226
|
-
},
|
|
227
|
-
],
|
|
228
|
-
},
|
|
229
|
-
|
|
230
|
-
{
|
|
231
|
-
type: "instance",
|
|
232
|
-
component: "Text",
|
|
233
|
-
children: [{ type: "text", value: "The text you can edit" }],
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
{
|
|
237
|
-
type: "instance",
|
|
238
|
-
component: "DialogClose",
|
|
239
|
-
/**
|
|
240
|
-
* absolute right-4 top-4
|
|
241
|
-
* rounded-sm opacity-70
|
|
242
|
-
* ring-offset-background
|
|
243
|
-
* hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
|
|
244
|
-
* flex items-center justify-center h-4 w-4
|
|
245
|
-
**/
|
|
246
|
-
styles: [
|
|
247
|
-
tc.absolute(),
|
|
248
|
-
tc.right(4),
|
|
249
|
-
tc.top(4),
|
|
250
|
-
tc.rounded("sm"),
|
|
251
|
-
tc.opacity(70),
|
|
252
|
-
tc.flex(),
|
|
253
|
-
tc.items("center"),
|
|
254
|
-
tc.justify("center"),
|
|
255
|
-
tc.h(4),
|
|
256
|
-
tc.w(4),
|
|
257
|
-
tc.border(0),
|
|
258
|
-
tc.bg("transparent"),
|
|
259
|
-
tc.outline("none"),
|
|
260
|
-
tc.hover(tc.opacity(100)),
|
|
261
|
-
tc.focus(tc.ring("ring", 2, "background", 2)),
|
|
262
|
-
].flat(),
|
|
263
|
-
children: [
|
|
264
|
-
{
|
|
265
|
-
type: "instance",
|
|
266
|
-
component: "HtmlEmbed",
|
|
267
|
-
label: "Close Icon",
|
|
268
|
-
props: [
|
|
269
|
-
{
|
|
270
|
-
type: "string",
|
|
271
|
-
name: "code",
|
|
272
|
-
value: LargeXIcon,
|
|
273
|
-
},
|
|
274
|
-
],
|
|
275
|
-
children: [],
|
|
276
|
-
},
|
|
277
|
-
],
|
|
278
|
-
},
|
|
279
|
-
],
|
|
280
|
-
},
|
|
281
|
-
],
|
|
282
|
-
},
|
|
283
|
-
],
|
|
284
|
-
},
|
|
285
|
-
],
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
export const propsMetaDialog: WsComponentPropsMeta = {
|
|
289
|
-
props: propsDialog,
|
|
290
|
-
initialProps: ["open"],
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export const propsMetaDialogTrigger: WsComponentPropsMeta = {
|
|
294
|
-
props: propsDialogTrigger,
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
export const propsMetaDialogContent: WsComponentPropsMeta = {
|
|
298
|
-
props: propsDialogContent,
|
|
299
|
-
initialProps: [],
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
export const propsMetaDialogOverlay: WsComponentPropsMeta = {
|
|
303
|
-
props: propsDialogOverlay,
|
|
304
|
-
initialProps: [],
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
export const propsMetaDialogClose: WsComponentPropsMeta = {
|
|
308
|
-
props: propsDialogClose,
|
|
309
|
-
initialProps: [],
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
export const propsMetaDialogTitle: WsComponentPropsMeta = {
|
|
313
|
-
props: propsDialogTitle,
|
|
314
|
-
initialProps: [],
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
export const propsMetaDialogDescription: WsComponentPropsMeta = {
|
|
318
|
-
props: propsDialogDescription,
|
|
319
|
-
initialProps: [],
|
|
320
|
-
};
|
package/src/hooks.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Hook } from "@webstudio-is/react-sdk";
|
|
2
|
-
import { hooksCollapsible } from "./collapsible";
|
|
3
|
-
import { hooksTabs } from "./tabs";
|
|
4
|
-
import { hooksDialog } from "./dialog";
|
|
5
|
-
import { hooksPopover } from "./popover";
|
|
6
|
-
import { hooksSheet } from "./sheet";
|
|
7
|
-
import { hooksTooltip } from "./tooltip";
|
|
8
|
-
import { hooksAccordion } from "./accordion";
|
|
9
|
-
import { hooksNavigationMenu } from "./navigation-menu";
|
|
10
|
-
import { hooksSelect } from "./select";
|
|
11
|
-
|
|
12
|
-
export const hooks: Hook[] = [
|
|
13
|
-
hooksCollapsible,
|
|
14
|
-
hooksTabs,
|
|
15
|
-
hooksDialog,
|
|
16
|
-
hooksPopover,
|
|
17
|
-
hooksSheet,
|
|
18
|
-
hooksTooltip,
|
|
19
|
-
hooksAccordion,
|
|
20
|
-
hooksNavigationMenu,
|
|
21
|
-
hooksSelect,
|
|
22
|
-
];
|
package/src/label.stories.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { renderComponentTemplate } from "@webstudio-is/react-sdk";
|
|
3
|
-
import { Label as LabelPrimitive } from "./label";
|
|
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/Label",
|
|
11
|
-
component: LabelPrimitive,
|
|
12
|
-
} satisfies Meta<typeof LabelPrimitive>;
|
|
13
|
-
|
|
14
|
-
export const Label: StoryObj<typeof LabelPrimitive> = {
|
|
15
|
-
render: (props) =>
|
|
16
|
-
renderComponentTemplate({
|
|
17
|
-
name: "Label",
|
|
18
|
-
props: { ...props },
|
|
19
|
-
components: { ...baseComponents, ...radixComponents },
|
|
20
|
-
metas: { ...baseMetas, ...radixMetas },
|
|
21
|
-
}),
|
|
22
|
-
};
|
package/src/label.tsx
DELETED
|
@@ -1,15 +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
|
-
forwardRef,
|
|
6
|
-
type ComponentPropsWithoutRef,
|
|
7
|
-
type ElementRef,
|
|
8
|
-
} from "react";
|
|
9
|
-
|
|
10
|
-
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
11
|
-
|
|
12
|
-
export const Label = forwardRef<
|
|
13
|
-
ElementRef<typeof LabelPrimitive.Root>,
|
|
14
|
-
Omit<ComponentPropsWithoutRef<typeof LabelPrimitive.Root>, "asChild">
|
|
15
|
-
>((props, ref) => <LabelPrimitive.Root ref={ref} {...props} />);
|
package/src/label.ws.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { LabelIcon } from "@webstudio-is/icons/svg";
|
|
2
|
-
import {
|
|
3
|
-
defaultStates,
|
|
4
|
-
type PresetStyle,
|
|
5
|
-
type WsComponentMeta,
|
|
6
|
-
type WsComponentPropsMeta,
|
|
7
|
-
} from "@webstudio-is/react-sdk";
|
|
8
|
-
import { label } from "@webstudio-is/react-sdk/css-normalize";
|
|
9
|
-
import { props } from "./__generated__/label.props";
|
|
10
|
-
import * as tc from "./theme/tailwind-classes";
|
|
11
|
-
|
|
12
|
-
const presetStyle = {
|
|
13
|
-
label,
|
|
14
|
-
} satisfies PresetStyle<"label">;
|
|
15
|
-
|
|
16
|
-
export const meta: WsComponentMeta = {
|
|
17
|
-
category: "radix",
|
|
18
|
-
order: 102,
|
|
19
|
-
type: "container",
|
|
20
|
-
icon: LabelIcon,
|
|
21
|
-
presetStyle,
|
|
22
|
-
states: defaultStates,
|
|
23
|
-
description:
|
|
24
|
-
"An accessible label to describe the purpose of an input. Match the “For” property on the label with the “ID” of the input to connect them.",
|
|
25
|
-
template: [
|
|
26
|
-
{
|
|
27
|
-
type: "instance",
|
|
28
|
-
component: "Label",
|
|
29
|
-
styles: [
|
|
30
|
-
// text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70
|
|
31
|
-
tc.text("sm"),
|
|
32
|
-
tc.font("medium"),
|
|
33
|
-
tc.leading("none"),
|
|
34
|
-
// We are not supporting peer like styles yet
|
|
35
|
-
].flat(),
|
|
36
|
-
children: [{ type: "text", value: "Form Label" }],
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const propsMeta: WsComponentPropsMeta = {
|
|
42
|
-
props: {
|
|
43
|
-
...props,
|
|
44
|
-
htmlFor: {
|
|
45
|
-
...props.htmlFor,
|
|
46
|
-
label: "For",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
initialProps: ["id", "htmlFor"],
|
|
50
|
-
};
|