@webstudio-is/sdk-components-react-radix 0.83.0 → 0.85.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__/dialog.props.js +2120 -0
- package/lib/__generated__/popover.props.js +468 -0
- package/lib/__generated__/sheet.props.js +2159 -0
- package/lib/__generated__/tabs.props.js +1286 -0
- package/lib/__generated__/tooltip.props.js +478 -0
- package/lib/cjs/__generated__/dialog.props.js +2140 -0
- package/lib/cjs/__generated__/popover.props.js +488 -0
- package/lib/cjs/__generated__/sheet.props.js +2179 -0
- package/lib/cjs/__generated__/tabs.props.js +1306 -0
- package/lib/cjs/__generated__/tooltip.props.js +498 -0
- package/lib/cjs/collapsible.js +34 -4
- package/lib/cjs/collapsible.ws.js +14 -9
- package/lib/cjs/components.js +30 -1
- package/lib/cjs/dialog.js +57 -0
- package/lib/cjs/dialog.ws.js +311 -0
- package/lib/cjs/hooks.js +25 -0
- package/lib/cjs/metas.js +30 -1
- package/lib/cjs/popover.js +58 -0
- package/lib/cjs/popover.ws.js +141 -0
- package/lib/cjs/props.js +30 -1
- package/lib/cjs/sheet.js +63 -0
- package/lib/cjs/sheet.ws.js +317 -0
- package/lib/cjs/tabs.js +41 -0
- package/lib/cjs/tabs.ws.js +213 -0
- package/lib/cjs/theme/radix-common-types.js +16 -0
- package/lib/cjs/theme/tailwind-classes.js +547 -0
- package/lib/cjs/theme/tailwind-colors.js +35 -0
- package/lib/cjs/theme/tailwind-theme.js +46 -0
- package/lib/cjs/tooltip.js +55 -0
- package/lib/cjs/tooltip.ws.js +142 -0
- package/lib/collapsible.js +35 -7
- package/lib/collapsible.ws.js +19 -10
- package/lib/components.js +46 -1
- package/lib/dialog.js +30 -0
- package/lib/dialog.ws.js +298 -0
- package/lib/hooks.js +5 -0
- package/lib/metas.js +59 -1
- package/lib/popover.js +31 -0
- package/lib/popover.ws.js +116 -0
- package/lib/props.js +59 -1
- package/lib/sheet.js +35 -0
- package/lib/sheet.ws.js +304 -0
- package/lib/tabs.js +24 -0
- package/lib/tabs.ws.js +193 -0
- package/lib/theme/radix-common-types.js +0 -0
- package/lib/theme/tailwind-classes.js +527 -0
- package/lib/theme/tailwind-colors.js +15 -0
- package/lib/theme/tailwind-theme.js +16 -0
- package/lib/tooltip.js +28 -0
- package/lib/tooltip.ws.js +117 -0
- package/lib/types/__generated__/dialog.props.d.ts +8 -0
- package/lib/types/__generated__/popover.props.d.ts +4 -0
- package/lib/types/__generated__/sheet.props.d.ts +8 -0
- package/lib/types/__generated__/tabs.props.d.ts +5 -0
- package/lib/types/__generated__/tooltip.props.d.ts +4 -0
- package/lib/types/collapsible.d.ts +4 -3
- package/lib/types/components.d.ts +5 -0
- package/lib/types/dialog.d.ts +25 -0
- package/lib/types/dialog.ws.d.ts +23 -0
- package/lib/types/hooks.d.ts +2 -0
- package/lib/types/metas.d.ts +5 -0
- package/lib/types/popover.d.ts +21 -0
- package/lib/types/popover.ws.d.ts +15 -0
- package/lib/types/props.d.ts +5 -0
- package/lib/types/sheet.d.ts +15 -0
- package/lib/types/sheet.ws.d.ts +23 -0
- package/lib/types/tabs.d.ts +15 -0
- package/lib/types/tabs.ws.d.ts +9 -0
- package/lib/types/theme/radix-common-types.d.ts +84 -0
- package/lib/types/theme/tailwind-classes.d.ts +83 -0
- package/lib/types/theme/tailwind-colors.d.ts +21 -0
- package/lib/types/theme/tailwind-theme.d.ts +72 -0
- package/lib/types/tooltip.d.ts +21 -0
- package/lib/types/tooltip.ws.d.ts +15 -0
- package/package.json +23 -6
- package/src/__generated__/dialog.props.ts +2363 -0
- package/src/__generated__/popover.props.ts +515 -0
- package/src/__generated__/sheet.props.ts +2402 -0
- package/src/__generated__/tabs.props.ts +1434 -0
- package/src/__generated__/tooltip.props.ts +526 -0
- package/src/collapsible.stories.tsx +21 -0
- package/src/collapsible.tsx +44 -21
- package/src/collapsible.ws.ts +21 -10
- package/src/components.ts +21 -0
- package/src/dialog.tsx +66 -0
- package/src/dialog.ws.tsx +315 -0
- package/src/hooks.ts +4 -0
- package/src/metas.ts +34 -0
- package/src/popover.tsx +70 -0
- package/src/popover.ws.tsx +127 -0
- package/src/props.ts +34 -0
- package/src/sheet.stories.tsx +21 -0
- package/src/sheet.tsx +40 -0
- package/src/sheet.ws.tsx +326 -0
- package/src/tabs.stories.tsx +21 -0
- package/src/tabs.tsx +46 -0
- package/src/tabs.ws.ts +211 -0
- package/src/theme/radix-common-types.ts +495 -0
- package/src/theme/tailwind-classes.ts +695 -0
- package/src/theme/tailwind-colors.ts +45 -0
- package/src/theme/tailwind-theme.ts +24 -0
- package/src/tooltip.tsx +69 -0
- package/src/tooltip.ws.tsx +128 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variables source:
|
|
3
|
+
* https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/themes.ts#L1
|
|
4
|
+
* https://github.com/shadcn-ui/ui/blob/5e172fc34fdf015aa0d141f52cc8c082b8ae6613/apps/www/scripts/build-registry.ts#L220
|
|
5
|
+
*
|
|
6
|
+
* Attributions
|
|
7
|
+
* MIT License
|
|
8
|
+
* Copyright (c) 2023 shadcn
|
|
9
|
+
**/
|
|
10
|
+
|
|
11
|
+
export const colors = {
|
|
12
|
+
transparent: "transparent",
|
|
13
|
+
current: "currentColor",
|
|
14
|
+
popover: "rgb(255, 255, 255)",
|
|
15
|
+
popoverForeground: "rgb(2, 8, 23)",
|
|
16
|
+
border: "rgb(226, 232, 240)",
|
|
17
|
+
background: "rgb(255, 255, 255)",
|
|
18
|
+
foreground: "hsl(222.2 84% 4.9%)",
|
|
19
|
+
ring: "rgb(148, 163, 184)",
|
|
20
|
+
mutedForeground: "rgb(100, 116, 139)",
|
|
21
|
+
muted: `hsl(210 40% 96.1%)`,
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
// Not used, leave it for the following components.
|
|
26
|
+
|
|
27
|
+
--card: 0 0% 100%;
|
|
28
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
29
|
+
|
|
30
|
+
--input: 214.3 31.8% 91.4%;
|
|
31
|
+
|
|
32
|
+
--primary: 222.2 47.4% 11.2%;
|
|
33
|
+
--primary-foreground: 210 40% 98%;
|
|
34
|
+
|
|
35
|
+
--secondary: 210 40% 96.1%;
|
|
36
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
37
|
+
|
|
38
|
+
--accent: 210 40% 96.1%;
|
|
39
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
40
|
+
|
|
41
|
+
--destructive: 0 84.2% 60.2%;
|
|
42
|
+
--destructive-foreground: 210 40% 98%;
|
|
43
|
+
|
|
44
|
+
--ring: 215 20.2% 65.1%;
|
|
45
|
+
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
2
|
+
import defaultTheme from "tailwindcss/defaultTheme"; // Imported theme https://github.com/tailwindlabs/tailwindcss/blob/e0c52a9332a64ef7eb0ba23d2a0fd5a16fe57ab7/stubs/config.full.js
|
|
3
|
+
import type { EvaluatedDefaultTheme } from "./radix-common-types";
|
|
4
|
+
import { colors } from "./tailwind-colors";
|
|
5
|
+
|
|
6
|
+
// Override the default theme with our own colors and other values if needed
|
|
7
|
+
const localTheme = { ...defaultTheme };
|
|
8
|
+
|
|
9
|
+
export const theme = <T extends keyof EvaluatedDefaultTheme>(
|
|
10
|
+
name: T
|
|
11
|
+
): EvaluatedDefaultTheme[T] => {
|
|
12
|
+
const value = localTheme?.[name] as unknown;
|
|
13
|
+
|
|
14
|
+
if (typeof value === "function") {
|
|
15
|
+
return value({ theme, colors, breakpoints: () => ({}) });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return value as never;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Override with our own colors, and other values if needed
|
|
22
|
+
localTheme.colors = colors;
|
|
23
|
+
localTheme.borderRadius = { ...theme("borderRadius") };
|
|
24
|
+
localTheme.borderRadius.DEFAULT = "0.5rem";
|
package/src/tooltip.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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 * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
forwardRef,
|
|
8
|
+
type ElementRef,
|
|
9
|
+
type ComponentPropsWithoutRef,
|
|
10
|
+
Children,
|
|
11
|
+
type ReactNode,
|
|
12
|
+
} from "react";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* We don't have support for boolean or undefined nor in UI not at Data variables,
|
|
16
|
+
* instead of binding on "open" prop we bind variable on a isOpen prop to be able to show Tooltip in the builder
|
|
17
|
+
**/
|
|
18
|
+
type BuilderTooltipProps = {
|
|
19
|
+
isOpen: "initial" | "open" | "closed";
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Tooltip = forwardRef<
|
|
23
|
+
ElementRef<"div">,
|
|
24
|
+
ComponentPropsWithoutRef<typeof TooltipPrimitive.Root> & BuilderTooltipProps
|
|
25
|
+
>(({ open: openProp, isOpen, ...props }, ref) => {
|
|
26
|
+
const open =
|
|
27
|
+
openProp ??
|
|
28
|
+
(isOpen === "open" ? true : isOpen === "closed" ? false : undefined);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<TooltipPrimitive.Provider>
|
|
32
|
+
<TooltipPrimitive.Root open={open} {...props} />
|
|
33
|
+
</TooltipPrimitive.Provider>
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* We're not exposing the 'asChild' property for the Trigger.
|
|
39
|
+
* Instead, we're enforcing 'asChild=true' for the Trigger and making it style-less.
|
|
40
|
+
* This avoids situations where the Trigger inadvertently passes all styles to its child,
|
|
41
|
+
* which would prevent us from displaying styles properly in the builder.
|
|
42
|
+
*/
|
|
43
|
+
export const TooltipTrigger = forwardRef<
|
|
44
|
+
ElementRef<"button">,
|
|
45
|
+
{ children: ReactNode }
|
|
46
|
+
>(({ children, ...props }, ref) => {
|
|
47
|
+
const firstChild = Children.toArray(children)[0];
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<TooltipPrimitive.Trigger asChild={true} ref={ref} {...props}>
|
|
51
|
+
{firstChild ?? <button>Add button or link</button>}
|
|
52
|
+
</TooltipPrimitive.Trigger>
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export const TooltipContent = forwardRef<
|
|
57
|
+
ElementRef<typeof TooltipPrimitive.Content>,
|
|
58
|
+
ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
59
|
+
>(({ sideOffset = 4, hideWhenDetached = true, ...props }, ref) => (
|
|
60
|
+
<TooltipPrimitive.Portal>
|
|
61
|
+
<TooltipPrimitive.Content
|
|
62
|
+
ref={ref}
|
|
63
|
+
// Do not show content if trigger is detached
|
|
64
|
+
hideWhenDetached={hideWhenDetached}
|
|
65
|
+
sideOffset={sideOffset}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
</TooltipPrimitive.Portal>
|
|
69
|
+
));
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { TooltipIcon, 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 * as tc from "./theme/tailwind-classes";
|
|
8
|
+
import {
|
|
9
|
+
propsTooltip,
|
|
10
|
+
propsTooltipContent,
|
|
11
|
+
propsTooltipTrigger,
|
|
12
|
+
} from "./__generated__/tooltip.props";
|
|
13
|
+
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
14
|
+
|
|
15
|
+
const presetStyle = {
|
|
16
|
+
div,
|
|
17
|
+
} satisfies PresetStyle<"div">;
|
|
18
|
+
|
|
19
|
+
// @todo add [data-state] to button and link
|
|
20
|
+
export const metaTooltipTrigger: WsComponentMeta = {
|
|
21
|
+
category: "hidden",
|
|
22
|
+
detachable: false,
|
|
23
|
+
invalidAncestors: [],
|
|
24
|
+
type: "container",
|
|
25
|
+
label: "Tooltip Trigger",
|
|
26
|
+
icon: TriggerIcon,
|
|
27
|
+
stylable: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const metaTooltipContent: WsComponentMeta = {
|
|
31
|
+
category: "hidden",
|
|
32
|
+
detachable: false,
|
|
33
|
+
invalidAncestors: [],
|
|
34
|
+
type: "container",
|
|
35
|
+
presetStyle,
|
|
36
|
+
label: "Tooltip Content",
|
|
37
|
+
icon: ContentIcon,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Styles source without animations:
|
|
42
|
+
* https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/tooltip.tsx
|
|
43
|
+
*
|
|
44
|
+
* Attributions
|
|
45
|
+
* MIT License
|
|
46
|
+
* Copyright (c) 2023 shadcn
|
|
47
|
+
**/
|
|
48
|
+
export const metaTooltip: WsComponentMeta = {
|
|
49
|
+
category: "radix",
|
|
50
|
+
invalidAncestors: [],
|
|
51
|
+
type: "container",
|
|
52
|
+
label: "Tooltip",
|
|
53
|
+
icon: TooltipIcon,
|
|
54
|
+
order: 15,
|
|
55
|
+
stylable: false,
|
|
56
|
+
template: [
|
|
57
|
+
{
|
|
58
|
+
type: "instance",
|
|
59
|
+
component: "Tooltip",
|
|
60
|
+
dataSources: {
|
|
61
|
+
// We don't have support for boolean or undefined, instead of binding on open we bind on a string
|
|
62
|
+
isOpen: { type: "variable", initialValue: "initial" },
|
|
63
|
+
},
|
|
64
|
+
props: [
|
|
65
|
+
{
|
|
66
|
+
type: "dataSource",
|
|
67
|
+
name: "isOpen",
|
|
68
|
+
dataSourceName: "isOpen",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
children: [
|
|
72
|
+
{
|
|
73
|
+
type: "instance",
|
|
74
|
+
component: "TooltipTrigger",
|
|
75
|
+
props: [],
|
|
76
|
+
children: [
|
|
77
|
+
{
|
|
78
|
+
type: "instance",
|
|
79
|
+
component: "Button",
|
|
80
|
+
children: [{ type: "text", value: "Button" }],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: "instance",
|
|
86
|
+
component: "TooltipContent",
|
|
87
|
+
props: [],
|
|
88
|
+
/**
|
|
89
|
+
* z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md
|
|
90
|
+
**/
|
|
91
|
+
styles: [
|
|
92
|
+
tc.z(50),
|
|
93
|
+
tc.overflow("hidden"),
|
|
94
|
+
tc.rounded("md"),
|
|
95
|
+
tc.border(),
|
|
96
|
+
tc.bg("popover"),
|
|
97
|
+
tc.px(3),
|
|
98
|
+
tc.py(1.5),
|
|
99
|
+
tc.text("sm"),
|
|
100
|
+
tc.text("popoverForeground"),
|
|
101
|
+
tc.shadow("md"),
|
|
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 propsMetaTooltip: WsComponentPropsMeta = {
|
|
117
|
+
props: propsTooltip,
|
|
118
|
+
initialProps: ["isOpen", "delayDuration", "disableHoverableContent"],
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const propsMetaTooltipTrigger: WsComponentPropsMeta = {
|
|
122
|
+
props: propsTooltipTrigger,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const propsMetaTooltipContent: WsComponentPropsMeta = {
|
|
126
|
+
props: propsTooltipContent,
|
|
127
|
+
initialProps: ["side", "sideOffset", "align", "alignOffset"],
|
|
128
|
+
};
|