@webstudio-is/sdk-components-react-radix 0.85.0 → 0.87.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 +2134 -0
- package/lib/__generated__/button.props.js +454 -0
- package/lib/__generated__/dialog.props.js +0 -7
- package/lib/__generated__/input.props.js +451 -0
- package/lib/__generated__/label.props.js +421 -0
- package/lib/__generated__/popover.props.js +0 -7
- package/lib/__generated__/sheet.props.js +0 -7
- package/lib/__generated__/textarea.props.js +431 -0
- package/lib/__generated__/tooltip.props.js +0 -7
- package/lib/accordion.js +51 -0
- package/lib/accordion.ws.js +243 -0
- package/lib/button.js +8 -0
- package/lib/button.ws.js +133 -0
- package/lib/cjs/__generated__/accordion.props.js +2154 -0
- package/lib/cjs/__generated__/button.props.js +474 -0
- package/lib/cjs/__generated__/dialog.props.js +0 -7
- package/lib/cjs/__generated__/input.props.js +471 -0
- package/lib/cjs/__generated__/label.props.js +441 -0
- package/lib/cjs/__generated__/popover.props.js +0 -7
- package/lib/cjs/__generated__/sheet.props.js +0 -7
- package/lib/cjs/__generated__/textarea.props.js +451 -0
- package/lib/cjs/__generated__/tooltip.props.js +0 -7
- package/lib/cjs/accordion.js +60 -0
- package/lib/cjs/accordion.ws.js +261 -0
- package/lib/cjs/button.js +28 -0
- package/lib/cjs/button.ws.js +160 -0
- package/lib/cjs/collapsible.js +2 -16
- package/lib/cjs/collapsible.ws.js +1 -8
- package/lib/cjs/components.js +14 -0
- package/lib/cjs/dialog.js +38 -6
- package/lib/cjs/dialog.ws.js +15 -26
- package/lib/cjs/hooks.js +15 -1
- package/lib/cjs/input.js +28 -0
- package/lib/cjs/input.ws.js +103 -0
- package/lib/cjs/label.js +37 -0
- package/lib/cjs/label.ws.js +74 -0
- package/lib/cjs/metas.js +14 -0
- package/lib/cjs/popover.js +37 -5
- package/lib/cjs/popover.ws.js +15 -18
- package/lib/cjs/props.js +14 -0
- package/lib/cjs/sheet.js +34 -1
- package/lib/cjs/sheet.ws.js +33 -19
- package/lib/cjs/tabs.js +20 -1
- package/lib/cjs/tabs.ws.js +3 -25
- package/lib/cjs/textarea.js +28 -0
- package/lib/cjs/textarea.ws.js +98 -0
- package/lib/cjs/theme/tailwind-classes.js +186 -23
- package/lib/cjs/theme/tailwind-colors.js +10 -1
- package/lib/cjs/tooltip.js +36 -4
- package/lib/cjs/tooltip.ws.js +15 -18
- package/lib/collapsible.js +2 -16
- package/lib/collapsible.ws.js +1 -8
- package/lib/components.js +20 -0
- package/lib/dialog.js +38 -6
- package/lib/dialog.ws.js +15 -26
- package/lib/hooks.js +15 -1
- package/lib/input.js +8 -0
- package/lib/input.ws.js +75 -0
- package/lib/label.js +9 -0
- package/lib/label.ws.js +46 -0
- package/lib/metas.js +20 -0
- package/lib/popover.js +37 -5
- package/lib/popover.ws.js +15 -18
- package/lib/props.js +20 -0
- package/lib/sheet.js +34 -1
- package/lib/sheet.ws.js +33 -19
- package/lib/tabs.js +24 -2
- package/lib/tabs.ws.js +3 -25
- package/lib/textarea.js +8 -0
- package/lib/textarea.ws.js +70 -0
- package/lib/theme/tailwind-classes.js +191 -24
- package/lib/theme/tailwind-colors.js +10 -1
- package/lib/tooltip.js +36 -4
- package/lib/tooltip.ws.js +15 -18
- package/lib/types/__generated__/accordion.props.d.ts +6 -0
- package/lib/types/__generated__/button.props.d.ts +2 -0
- package/lib/types/__generated__/input.props.d.ts +2 -0
- package/lib/types/__generated__/label.props.d.ts +2 -0
- package/lib/types/__generated__/textarea.props.d.ts +2 -0
- package/lib/types/accordion.d.ts +12 -0
- package/lib/types/accordion.ws.d.ts +11 -0
- package/lib/types/button.d.ts +7 -0
- package/lib/types/button.stories.d.ts +20 -0
- package/lib/types/button.ws.d.ts +7 -0
- package/lib/types/components.d.ts +5 -0
- package/lib/types/dialog.d.ts +5 -11
- package/lib/types/input.d.ts +2 -0
- package/lib/types/input.stories.d.ts +20 -0
- package/lib/types/input.ws.d.ts +3 -0
- package/lib/types/label.d.ts +3 -0
- package/lib/types/label.stories.d.ts +9 -0
- package/lib/types/label.ws.d.ts +3 -0
- package/lib/types/metas.d.ts +5 -0
- package/lib/types/popover.d.ts +4 -10
- package/lib/types/props.d.ts +5 -0
- package/lib/types/sheet.d.ts +4 -4
- package/lib/types/tabs.d.ts +2 -0
- package/lib/types/textarea.d.ts +2 -0
- package/lib/types/textarea.stories.d.ts +14 -0
- package/lib/types/textarea.ws.d.ts +3 -0
- package/lib/types/theme/tailwind-classes.d.ts +16 -5
- package/lib/types/theme/tailwind-colors.d.ts +9 -0
- package/lib/types/tooltip.d.ts +3 -9
- package/package.json +9 -7
- package/src/__generated__/accordion.props.ts +2382 -0
- package/src/__generated__/button.props.ts +503 -0
- package/src/__generated__/dialog.props.ts +0 -7
- package/src/__generated__/input.props.ts +500 -0
- package/src/__generated__/label.props.ts +470 -0
- package/src/__generated__/popover.props.ts +0 -7
- package/src/__generated__/sheet.props.ts +0 -7
- package/src/__generated__/textarea.props.ts +480 -0
- package/src/__generated__/tooltip.props.ts +0 -7
- package/src/accordion.stories.tsx +21 -0
- package/src/accordion.tsx +81 -0
- package/src/accordion.ws.ts +270 -0
- package/src/button.stories.ts +35 -0
- package/src/button.tsx +25 -0
- package/src/button.ws.ts +155 -0
- package/src/collapsible.tsx +2 -16
- package/src/collapsible.ws.ts +1 -8
- package/src/components.ts +11 -0
- package/src/dialog.stories.tsx +21 -0
- package/src/dialog.tsx +50 -24
- package/src/dialog.ws.tsx +15 -26
- package/src/hooks.ts +15 -1
- package/src/input.stories.ts +31 -0
- package/src/input.tsx +12 -0
- package/src/input.ws.ts +78 -0
- package/src/label.stories.ts +22 -0
- package/src/label.tsx +15 -0
- package/src/label.ws.ts +48 -0
- package/src/metas.ts +11 -0
- package/src/popover.stories.tsx +21 -0
- package/src/popover.tsx +49 -23
- package/src/popover.ws.tsx +15 -18
- package/src/props.ts +11 -0
- package/src/sheet.tsx +39 -0
- package/src/sheet.ws.tsx +33 -19
- package/src/tabs.tsx +32 -1
- package/src/tabs.ws.ts +1 -23
- package/src/textarea.stories.ts +27 -0
- package/src/textarea.tsx +12 -0
- package/src/textarea.ws.ts +74 -0
- package/src/theme/tailwind-classes.ts +233 -38
- package/src/theme/tailwind-colors.ts +9 -16
- package/src/tooltip.stories.tsx +21 -0
- package/src/tooltip.tsx +46 -20
- package/src/tooltip.ws.tsx +15 -18
|
@@ -19,6 +19,15 @@ export const colors = {
|
|
|
19
19
|
ring: "rgb(148, 163, 184)",
|
|
20
20
|
mutedForeground: "rgb(100, 116, 139)",
|
|
21
21
|
muted: `hsl(210 40% 96.1%)`,
|
|
22
|
+
primary: "rgb(15, 23, 42)",
|
|
23
|
+
primaryForeground: "hsl(210 40% 98%)",
|
|
24
|
+
destructive: "rgb(239, 68, 68)",
|
|
25
|
+
destructiveForeground: "rgb(248, 250, 252)",
|
|
26
|
+
accent: "rgb(241, 245, 249)",
|
|
27
|
+
accentForeground: "rgb(15, 23, 42)",
|
|
28
|
+
input: "rgb(226, 232, 240)",
|
|
29
|
+
secondary: "rgb(241, 245, 249)",
|
|
30
|
+
secondaryForeground: "rgb(15, 23, 42)",
|
|
22
31
|
} as const;
|
|
23
32
|
|
|
24
33
|
/*
|
|
@@ -26,20 +35,4 @@ export const colors = {
|
|
|
26
35
|
|
|
27
36
|
--card: 0 0% 100%;
|
|
28
37
|
--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
38
|
*/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { renderComponentTemplate } from "@webstudio-is/react-sdk";
|
|
3
|
+
import { Tooltip as TooltipPrimitive } from "./tooltip";
|
|
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/Tooltip",
|
|
11
|
+
component: TooltipPrimitive,
|
|
12
|
+
} satisfies Meta<typeof TooltipPrimitive>;
|
|
13
|
+
|
|
14
|
+
export const Tooltip: StoryObj<typeof TooltipPrimitive> = {
|
|
15
|
+
render: () =>
|
|
16
|
+
renderComponentTemplate({
|
|
17
|
+
name: "Tooltip",
|
|
18
|
+
components: { ...baseComponents, ...radixComponents },
|
|
19
|
+
metas: { ...baseMetas, ...radixMetas },
|
|
20
|
+
}),
|
|
21
|
+
};
|
package/src/tooltip.tsx
CHANGED
|
@@ -2,34 +2,22 @@
|
|
|
2
2
|
// We can't use .displayName until this is merged https://github.com/styleguidist/react-docgen-typescript/pull/449
|
|
3
3
|
|
|
4
4
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
5
|
+
import { getClosestInstance, type Hook } from "@webstudio-is/react-sdk";
|
|
5
6
|
|
|
6
7
|
import {
|
|
7
8
|
forwardRef,
|
|
8
|
-
type ElementRef,
|
|
9
9
|
type ComponentPropsWithoutRef,
|
|
10
|
-
Children,
|
|
11
10
|
type ReactNode,
|
|
11
|
+
Children,
|
|
12
12
|
} from "react";
|
|
13
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
14
|
export const Tooltip = forwardRef<
|
|
23
|
-
|
|
24
|
-
ComponentPropsWithoutRef<typeof TooltipPrimitive.Root>
|
|
25
|
-
>((
|
|
26
|
-
const open =
|
|
27
|
-
openProp ??
|
|
28
|
-
(isOpen === "open" ? true : isOpen === "closed" ? false : undefined);
|
|
29
|
-
|
|
15
|
+
HTMLDivElement,
|
|
16
|
+
Omit<ComponentPropsWithoutRef<typeof TooltipPrimitive.Root>, "defaultOpen">
|
|
17
|
+
>((props, _ref) => {
|
|
30
18
|
return (
|
|
31
19
|
<TooltipPrimitive.Provider>
|
|
32
|
-
<TooltipPrimitive.Root
|
|
20
|
+
<TooltipPrimitive.Root {...props} />
|
|
33
21
|
</TooltipPrimitive.Provider>
|
|
34
22
|
);
|
|
35
23
|
});
|
|
@@ -41,7 +29,7 @@ export const Tooltip = forwardRef<
|
|
|
41
29
|
* which would prevent us from displaying styles properly in the builder.
|
|
42
30
|
*/
|
|
43
31
|
export const TooltipTrigger = forwardRef<
|
|
44
|
-
|
|
32
|
+
HTMLButtonElement,
|
|
45
33
|
{ children: ReactNode }
|
|
46
34
|
>(({ children, ...props }, ref) => {
|
|
47
35
|
const firstChild = Children.toArray(children)[0];
|
|
@@ -54,7 +42,7 @@ export const TooltipTrigger = forwardRef<
|
|
|
54
42
|
});
|
|
55
43
|
|
|
56
44
|
export const TooltipContent = forwardRef<
|
|
57
|
-
|
|
45
|
+
HTMLDivElement,
|
|
58
46
|
ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
59
47
|
>(({ sideOffset = 4, hideWhenDetached = true, ...props }, ref) => (
|
|
60
48
|
<TooltipPrimitive.Portal>
|
|
@@ -67,3 +55,41 @@ export const TooltipContent = forwardRef<
|
|
|
67
55
|
/>
|
|
68
56
|
</TooltipPrimitive.Portal>
|
|
69
57
|
));
|
|
58
|
+
|
|
59
|
+
/* BUILDER HOOKS */
|
|
60
|
+
|
|
61
|
+
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
62
|
+
|
|
63
|
+
// For each TooltipContent component within the selection,
|
|
64
|
+
// we identify its closest parent Tooltip component
|
|
65
|
+
// and update its open prop bound to variable.
|
|
66
|
+
export const hooksTooltip: Hook = {
|
|
67
|
+
onNavigatorUnselect: (context, event) => {
|
|
68
|
+
for (const instance of event.instancePath) {
|
|
69
|
+
if (instance.component === `${namespace}:TooltipContent`) {
|
|
70
|
+
const tooltip = getClosestInstance(
|
|
71
|
+
event.instancePath,
|
|
72
|
+
instance,
|
|
73
|
+
`${namespace}:Tooltip`
|
|
74
|
+
);
|
|
75
|
+
if (tooltip) {
|
|
76
|
+
context.setPropVariable(tooltip.id, "open", false);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
onNavigatorSelect: (context, event) => {
|
|
82
|
+
for (const instance of event.instancePath) {
|
|
83
|
+
if (instance.component === `${namespace}:TooltipContent`) {
|
|
84
|
+
const tooltip = getClosestInstance(
|
|
85
|
+
event.instancePath,
|
|
86
|
+
instance,
|
|
87
|
+
`${namespace}:Tooltip`
|
|
88
|
+
);
|
|
89
|
+
if (tooltip) {
|
|
90
|
+
context.setPropVariable(tooltip.id, "open", true);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
package/src/tooltip.ws.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
propsTooltipTrigger,
|
|
12
12
|
} from "./__generated__/tooltip.props";
|
|
13
13
|
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
14
|
+
import { template as buttonTemplate } from "./button.ws";
|
|
14
15
|
|
|
15
16
|
const presetStyle = {
|
|
16
17
|
div,
|
|
@@ -20,9 +21,7 @@ const presetStyle = {
|
|
|
20
21
|
export const metaTooltipTrigger: WsComponentMeta = {
|
|
21
22
|
category: "hidden",
|
|
22
23
|
detachable: false,
|
|
23
|
-
invalidAncestors: [],
|
|
24
24
|
type: "container",
|
|
25
|
-
label: "Tooltip Trigger",
|
|
26
25
|
icon: TriggerIcon,
|
|
27
26
|
stylable: false,
|
|
28
27
|
};
|
|
@@ -30,10 +29,8 @@ export const metaTooltipTrigger: WsComponentMeta = {
|
|
|
30
29
|
export const metaTooltipContent: WsComponentMeta = {
|
|
31
30
|
category: "hidden",
|
|
32
31
|
detachable: false,
|
|
33
|
-
invalidAncestors: [],
|
|
34
32
|
type: "container",
|
|
35
33
|
presetStyle,
|
|
36
|
-
label: "Tooltip Content",
|
|
37
34
|
icon: ContentIcon,
|
|
38
35
|
};
|
|
39
36
|
|
|
@@ -47,9 +44,7 @@ export const metaTooltipContent: WsComponentMeta = {
|
|
|
47
44
|
**/
|
|
48
45
|
export const metaTooltip: WsComponentMeta = {
|
|
49
46
|
category: "radix",
|
|
50
|
-
invalidAncestors: [],
|
|
51
47
|
type: "container",
|
|
52
|
-
label: "Tooltip",
|
|
53
48
|
icon: TooltipIcon,
|
|
54
49
|
order: 15,
|
|
55
50
|
stylable: false,
|
|
@@ -58,14 +53,20 @@ export const metaTooltip: WsComponentMeta = {
|
|
|
58
53
|
type: "instance",
|
|
59
54
|
component: "Tooltip",
|
|
60
55
|
dataSources: {
|
|
61
|
-
|
|
62
|
-
isOpen: { type: "variable", initialValue: "initial" },
|
|
56
|
+
tooltipOpen: { type: "variable", initialValue: false },
|
|
63
57
|
},
|
|
64
58
|
props: [
|
|
65
59
|
{
|
|
66
60
|
type: "dataSource",
|
|
67
|
-
name: "
|
|
68
|
-
dataSourceName: "
|
|
61
|
+
name: "open",
|
|
62
|
+
dataSourceName: "tooltipOpen",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "onOpenChange",
|
|
66
|
+
type: "action",
|
|
67
|
+
value: [
|
|
68
|
+
{ type: "execute", args: ["open"], code: `tooltipOpen = open` },
|
|
69
|
+
],
|
|
69
70
|
},
|
|
70
71
|
],
|
|
71
72
|
children: [
|
|
@@ -73,13 +74,9 @@ export const metaTooltip: WsComponentMeta = {
|
|
|
73
74
|
type: "instance",
|
|
74
75
|
component: "TooltipTrigger",
|
|
75
76
|
props: [],
|
|
76
|
-
children:
|
|
77
|
-
{
|
|
78
|
-
|
|
79
|
-
component: "Button",
|
|
80
|
-
children: [{ type: "text", value: "Button" }],
|
|
81
|
-
},
|
|
82
|
-
],
|
|
77
|
+
children: buttonTemplate({
|
|
78
|
+
children: [{ type: "text", value: "Button" }],
|
|
79
|
+
}),
|
|
83
80
|
},
|
|
84
81
|
{
|
|
85
82
|
type: "instance",
|
|
@@ -115,7 +112,7 @@ export const metaTooltip: WsComponentMeta = {
|
|
|
115
112
|
|
|
116
113
|
export const propsMetaTooltip: WsComponentPropsMeta = {
|
|
117
114
|
props: propsTooltip,
|
|
118
|
-
initialProps: ["
|
|
115
|
+
initialProps: ["open", "delayDuration", "disableHoverableContent"],
|
|
119
116
|
};
|
|
120
117
|
|
|
121
118
|
export const propsMetaTooltipTrigger: WsComponentPropsMeta = {
|