@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.
Files changed (199) hide show
  1. package/lib/__generated__/accordion.props.js +6 -12
  2. package/lib/__generated__/checkbox.props.js +3 -6
  3. package/lib/__generated__/collapsible.props.js +4 -8
  4. package/lib/__generated__/dialog.props.js +8 -16
  5. package/lib/__generated__/label.props.js +2 -4
  6. package/lib/__generated__/navigation-menu.props.js +8 -16
  7. package/lib/__generated__/popover.props.js +4 -8
  8. package/lib/__generated__/radio-group.props.js +4 -8
  9. package/lib/__generated__/select.props.js +15 -19
  10. package/lib/__generated__/sheet.props.js +8 -16
  11. package/lib/__generated__/switch.props.js +3 -6
  12. package/lib/__generated__/tabs.props.js +5 -10
  13. package/lib/__generated__/tooltip.props.js +4 -8
  14. package/lib/accordion.js +7 -14
  15. package/{src/accordion.stories.tsx → lib/accordion.stories.js} +9 -12
  16. package/lib/accordion.ws.js +11 -22
  17. package/lib/checkbox.js +3 -6
  18. package/lib/checkbox.stories.js +19 -0
  19. package/lib/checkbox.ws.js +5 -10
  20. package/lib/collapsible.js +5 -10
  21. package/{src/collapsible.stories.tsx → lib/collapsible.stories.js} +9 -12
  22. package/lib/collapsible.ws.js +7 -14
  23. package/lib/components.js +13 -62
  24. package/lib/dialog.js +9 -18
  25. package/{src/dialog.stories.tsx → lib/dialog.stories.js} +9 -12
  26. package/lib/dialog.ws.js +17 -30
  27. package/lib/hooks.js +2 -4
  28. package/lib/label.js +2 -4
  29. package/lib/label.stories.js +19 -0
  30. package/lib/label.ws.js +3 -6
  31. package/lib/metas.js +55 -105
  32. package/lib/navigation-menu.js +9 -18
  33. package/{src/navigation-menu.stories.tsx → lib/navigation-menu.stories.js} +9 -12
  34. package/lib/navigation-menu.ws.js +16 -31
  35. package/lib/popover.js +5 -10
  36. package/{src/popover.stories.tsx → lib/popover.stories.js} +9 -12
  37. package/lib/popover.ws.js +7 -14
  38. package/lib/props-descriptions.js +2 -4
  39. package/lib/props.js +54 -103
  40. package/lib/radio-group.js +4 -8
  41. package/lib/radio-group.stories.js +19 -0
  42. package/lib/radio-group.ws.js +7 -14
  43. package/lib/select.js +10 -20
  44. package/{src/select.stories.tsx → lib/select.stories.js} +9 -12
  45. package/lib/select.ws.js +17 -34
  46. package/lib/sheet.js +9 -18
  47. package/{src/sheet.stories.tsx → lib/sheet.stories.js} +9 -12
  48. package/lib/sheet.ws.js +2 -4
  49. package/lib/switch.js +3 -6
  50. package/lib/switch.stories.js +19 -0
  51. package/lib/switch.ws.js +5 -10
  52. package/lib/tabs.js +6 -12
  53. package/{src/tabs.stories.tsx → lib/tabs.stories.js} +9 -12
  54. package/lib/tabs.ws.js +9 -18
  55. package/lib/theme/__generated__/tailwind-theme.js +517 -0
  56. package/lib/theme/styles.js +3 -6
  57. package/lib/theme/tailwind-classes.js +149 -301
  58. package/lib/theme/tailwind-colors.js +2 -4
  59. package/lib/tooltip.js +5 -10
  60. package/{src/tooltip.stories.tsx → lib/tooltip.stories.js} +9 -12
  61. package/lib/tooltip.ws.js +7 -14
  62. package/lib/types/__generated__/accordion.props.d.ts +1 -1
  63. package/lib/types/__generated__/checkbox.props.d.ts +1 -1
  64. package/lib/types/__generated__/collapsible.props.d.ts +1 -1
  65. package/lib/types/__generated__/dialog.props.d.ts +1 -1
  66. package/lib/types/__generated__/label.props.d.ts +1 -1
  67. package/lib/types/__generated__/navigation-menu.props.d.ts +1 -1
  68. package/lib/types/__generated__/popover.props.d.ts +1 -1
  69. package/lib/types/__generated__/radio-group.props.d.ts +1 -1
  70. package/lib/types/__generated__/select.props.d.ts +1 -1
  71. package/lib/types/__generated__/sheet.props.d.ts +1 -1
  72. package/lib/types/__generated__/switch.props.d.ts +1 -1
  73. package/lib/types/__generated__/tabs.props.d.ts +1 -1
  74. package/lib/types/__generated__/tooltip.props.d.ts +1 -1
  75. package/lib/types/accordion.d.ts +1 -1
  76. package/lib/types/sheet.d.ts +1 -1
  77. package/lib/types/theme/__generated__/tailwind-theme.d.ts +26 -0
  78. package/lib/types/theme/styles.d.ts +60 -60
  79. package/lib/types/theme/tailwind-classes.d.ts +33 -33
  80. package/package.json +20 -23
  81. package/lib/__generated__/button.props.js +0 -565
  82. package/lib/__generated__/input.props.js +0 -668
  83. package/lib/__generated__/textarea.props.js +0 -577
  84. package/lib/cjs/__generated__/accordion.props.js +0 -2645
  85. package/lib/cjs/__generated__/button.props.js +0 -585
  86. package/lib/cjs/__generated__/checkbox.props.js +0 -1103
  87. package/lib/cjs/__generated__/collapsible.props.js +0 -1050
  88. package/lib/cjs/__generated__/dialog.props.js +0 -2623
  89. package/lib/cjs/__generated__/input.props.js +0 -688
  90. package/lib/cjs/__generated__/label.props.js +0 -541
  91. package/lib/cjs/__generated__/navigation-menu.props.js +0 -2585
  92. package/lib/cjs/__generated__/popover.props.js +0 -582
  93. package/lib/cjs/__generated__/radio-group.props.js +0 -1647
  94. package/lib/cjs/__generated__/select.props.js +0 -3698
  95. package/lib/cjs/__generated__/sheet.props.js +0 -2642
  96. package/lib/cjs/__generated__/switch.props.js +0 -1103
  97. package/lib/cjs/__generated__/tabs.props.js +0 -2144
  98. package/lib/cjs/__generated__/textarea.props.js +0 -597
  99. package/lib/cjs/__generated__/tooltip.props.js +0 -593
  100. package/lib/cjs/accordion.js +0 -67
  101. package/lib/cjs/accordion.ws.js +0 -285
  102. package/lib/cjs/checkbox.js +0 -31
  103. package/lib/cjs/checkbox.ws.js +0 -174
  104. package/lib/cjs/collapsible.js +0 -53
  105. package/lib/cjs/collapsible.ws.js +0 -122
  106. package/lib/cjs/components.js +0 -82
  107. package/lib/cjs/dialog.js +0 -89
  108. package/lib/cjs/dialog.ws.js +0 -314
  109. package/lib/cjs/hooks.js +0 -43
  110. package/lib/cjs/label.js +0 -37
  111. package/lib/cjs/label.ws.js +0 -75
  112. package/lib/cjs/metas.js +0 -84
  113. package/lib/cjs/navigation-menu.js +0 -107
  114. package/lib/cjs/navigation-menu.ws.js +0 -514
  115. package/lib/cjs/package.json +0 -1
  116. package/lib/cjs/popover.js +0 -90
  117. package/lib/cjs/popover.ws.js +0 -142
  118. package/lib/cjs/props-descriptions.js +0 -56
  119. package/lib/cjs/props.js +0 -82
  120. package/lib/cjs/radio-group.js +0 -30
  121. package/lib/cjs/radio-group.ws.js +0 -191
  122. package/lib/cjs/select.js +0 -83
  123. package/lib/cjs/select.ws.js +0 -350
  124. package/lib/cjs/sheet.js +0 -96
  125. package/lib/cjs/sheet.ws.js +0 -257
  126. package/lib/cjs/switch.js +0 -27
  127. package/lib/cjs/switch.ws.js +0 -173
  128. package/lib/cjs/tabs.js +0 -59
  129. package/lib/cjs/tabs.ws.js +0 -196
  130. package/lib/cjs/theme/radix-common-types.js +0 -16
  131. package/lib/cjs/theme/styles.js +0 -96
  132. package/lib/cjs/theme/tailwind-classes.js +0 -819
  133. package/lib/cjs/theme/tailwind-colors.js +0 -45
  134. package/lib/cjs/theme/tailwind-theme.js +0 -46
  135. package/lib/cjs/tooltip.js +0 -87
  136. package/lib/cjs/tooltip.ws.js +0 -143
  137. package/lib/theme/radix-common-types.js +0 -0
  138. package/lib/theme/tailwind-theme.js +0 -16
  139. package/lib/types/__generated__/button.props.d.ts +0 -2
  140. package/lib/types/__generated__/input.props.d.ts +0 -2
  141. package/lib/types/__generated__/textarea.props.d.ts +0 -2
  142. package/lib/types/theme/radix-common-types.d.ts +0 -85
  143. package/lib/types/theme/tailwind-theme.d.ts +0 -72
  144. package/src/__generated__/accordion.props.ts +0 -2949
  145. package/src/__generated__/button.props.ts +0 -635
  146. package/src/__generated__/checkbox.props.ts +0 -1217
  147. package/src/__generated__/collapsible.props.ts +0 -1156
  148. package/src/__generated__/dialog.props.ts +0 -2923
  149. package/src/__generated__/input.props.ts +0 -748
  150. package/src/__generated__/label.props.ts +0 -585
  151. package/src/__generated__/navigation-menu.props.ts +0 -2882
  152. package/src/__generated__/popover.props.ts +0 -626
  153. package/src/__generated__/radio-group.props.ts +0 -1828
  154. package/src/__generated__/select.props.ts +0 -4130
  155. package/src/__generated__/sheet.props.ts +0 -2942
  156. package/src/__generated__/switch.props.ts +0 -1217
  157. package/src/__generated__/tabs.props.ts +0 -2386
  158. package/src/__generated__/textarea.props.ts +0 -645
  159. package/src/__generated__/tooltip.props.ts +0 -639
  160. package/src/accordion.tsx +0 -88
  161. package/src/accordion.ws.ts +0 -296
  162. package/src/checkbox.stories.ts +0 -22
  163. package/src/checkbox.tsx +0 -22
  164. package/src/checkbox.ws.ts +0 -154
  165. package/src/collapsible.tsx +0 -62
  166. package/src/collapsible.ws.ts +0 -115
  167. package/src/components.ts +0 -50
  168. package/src/dialog.tsx +0 -92
  169. package/src/dialog.ws.tsx +0 -318
  170. package/src/hooks.ts +0 -22
  171. package/src/label.stories.ts +0 -22
  172. package/src/label.tsx +0 -15
  173. package/src/label.ws.ts +0 -50
  174. package/src/metas.ts +0 -74
  175. package/src/navigation-menu.tsx +0 -130
  176. package/src/navigation-menu.ws.ts +0 -524
  177. package/src/popover.tsx +0 -96
  178. package/src/popover.ws.tsx +0 -128
  179. package/src/props-descriptions.ts +0 -43
  180. package/src/props.ts +0 -73
  181. package/src/radio-group.stories.ts +0 -22
  182. package/src/radio-group.tsx +0 -17
  183. package/src/radio-group.ws.ts +0 -178
  184. package/src/select.tsx +0 -112
  185. package/src/select.ws.ts +0 -349
  186. package/src/sheet.tsx +0 -79
  187. package/src/sheet.ws.tsx +0 -236
  188. package/src/switch.stories.ts +0 -22
  189. package/src/switch.tsx +0 -10
  190. package/src/switch.ws.ts +0 -146
  191. package/src/tabs.tsx +0 -64
  192. package/src/tabs.ws.ts +0 -198
  193. package/src/theme/radix-common-types.ts +0 -496
  194. package/src/theme/styles.ts +0 -76
  195. package/src/theme/tailwind-classes.ts +0 -1026
  196. package/src/theme/tailwind-colors.ts +0 -39
  197. package/src/theme/tailwind-theme.ts +0 -24
  198. package/src/tooltip.tsx +0 -95
  199. package/src/tooltip.ws.tsx +0 -130
@@ -1,39 +0,0 @@
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
- inherit: "inherit",
15
- popover: "rgb(255, 255, 255)",
16
- popoverForeground: "rgb(2, 8, 23)",
17
- border: "rgb(226, 232, 240)",
18
- background: "rgb(255, 255, 255)",
19
- foreground: "hsl(222.2 84% 4.9%)",
20
- ring: "rgb(148, 163, 184)",
21
- mutedForeground: "rgb(100, 116, 139)",
22
- muted: `hsl(210 40% 96.1%)`,
23
- primary: "rgb(15, 23, 42)",
24
- primaryForeground: "hsl(210 40% 98%)",
25
- destructive: "rgb(239, 68, 68)",
26
- destructiveForeground: "rgb(248, 250, 252)",
27
- accent: "rgb(241, 245, 249)",
28
- accentForeground: "rgb(15, 23, 42)",
29
- input: "rgb(226, 232, 240)",
30
- secondary: "rgb(241, 245, 249)",
31
- secondaryForeground: "rgb(15, 23, 42)",
32
- } as const;
33
-
34
- /*
35
- // Not used, leave it for the following components.
36
-
37
- --card: 0 0% 100%;
38
- --card-foreground: 222.2 84% 4.9%;
39
- */
@@ -1,24 +0,0 @@
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 DELETED
@@ -1,95 +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 * as TooltipPrimitive from "@radix-ui/react-tooltip";
5
- import { getClosestInstance, type Hook } from "@webstudio-is/react-sdk";
6
-
7
- import {
8
- forwardRef,
9
- type ComponentPropsWithoutRef,
10
- type ReactNode,
11
- Children,
12
- } from "react";
13
-
14
- export const Tooltip = forwardRef<
15
- HTMLDivElement,
16
- Omit<ComponentPropsWithoutRef<typeof TooltipPrimitive.Root>, "defaultOpen">
17
- >((props, _ref) => {
18
- return (
19
- <TooltipPrimitive.Provider>
20
- <TooltipPrimitive.Root {...props} />
21
- </TooltipPrimitive.Provider>
22
- );
23
- });
24
-
25
- /**
26
- * We're not exposing the 'asChild' property for the Trigger.
27
- * Instead, we're enforcing 'asChild=true' for the Trigger and making it style-less.
28
- * This avoids situations where the Trigger inadvertently passes all styles to its child,
29
- * which would prevent us from displaying styles properly in the builder.
30
- */
31
- export const TooltipTrigger = forwardRef<
32
- HTMLButtonElement,
33
- { children: ReactNode }
34
- >(({ children, ...props }, ref) => {
35
- const firstChild = Children.toArray(children)[0];
36
-
37
- return (
38
- <TooltipPrimitive.Trigger asChild={true} ref={ref} {...props}>
39
- {firstChild ?? <button>Add button or link</button>}
40
- </TooltipPrimitive.Trigger>
41
- );
42
- });
43
-
44
- export const TooltipContent = forwardRef<
45
- HTMLDivElement,
46
- ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
47
- >(({ sideOffset = 4, hideWhenDetached = true, ...props }, ref) => (
48
- <TooltipPrimitive.Portal>
49
- <TooltipPrimitive.Content
50
- ref={ref}
51
- // Do not show content if trigger is detached
52
- hideWhenDetached={hideWhenDetached}
53
- sideOffset={sideOffset}
54
- {...props}
55
- />
56
- </TooltipPrimitive.Portal>
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
- };
@@ -1,130 +0,0 @@
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 { div } from "@webstudio-is/react-sdk/css-normalize";
8
- import * as tc from "./theme/tailwind-classes";
9
- import {
10
- propsTooltip,
11
- propsTooltipContent,
12
- propsTooltipTrigger,
13
- } from "./__generated__/tooltip.props";
14
- import { getButtonStyles } from "./theme/styles";
15
-
16
- const presetStyle = {
17
- div,
18
- } satisfies PresetStyle<"div">;
19
-
20
- // @todo add [data-state] to button and link
21
- export const metaTooltipTrigger: WsComponentMeta = {
22
- category: "hidden",
23
- detachable: false,
24
- type: "container",
25
- icon: TriggerIcon,
26
- stylable: false,
27
- };
28
-
29
- export const metaTooltipContent: WsComponentMeta = {
30
- category: "hidden",
31
- detachable: false,
32
- type: "container",
33
- presetStyle,
34
- icon: ContentIcon,
35
- };
36
-
37
- /**
38
- * Styles source without animations:
39
- * https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/tooltip.tsx
40
- *
41
- * Attributions
42
- * MIT License
43
- * Copyright (c) 2023 shadcn
44
- **/
45
- export const metaTooltip: WsComponentMeta = {
46
- category: "radix",
47
- order: 7,
48
- type: "container",
49
- icon: TooltipIcon,
50
- stylable: false,
51
- description:
52
- "Displays content that is related to the trigger, when the trigger is hovered with the mouse or focused with the keyboard. You are reading an example of a tooltip right now.",
53
- template: [
54
- {
55
- type: "instance",
56
- component: "Tooltip",
57
- dataSources: {
58
- tooltipOpen: { type: "variable", initialValue: false },
59
- },
60
- props: [
61
- {
62
- type: "dataSource",
63
- name: "open",
64
- dataSourceName: "tooltipOpen",
65
- },
66
- {
67
- name: "onOpenChange",
68
- type: "action",
69
- value: [
70
- { type: "execute", args: ["open"], code: `tooltipOpen = open` },
71
- ],
72
- },
73
- ],
74
- children: [
75
- {
76
- type: "instance",
77
- component: "TooltipTrigger",
78
- children: [
79
- {
80
- type: "instance",
81
- component: "Button",
82
- styles: getButtonStyles("outline"),
83
- children: [{ type: "text", value: "Button" }],
84
- },
85
- ],
86
- },
87
- {
88
- type: "instance",
89
- component: "TooltipContent",
90
- /**
91
- * z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md
92
- **/
93
- styles: [
94
- tc.z(50),
95
- tc.overflow("hidden"),
96
- tc.rounded("md"),
97
- tc.border(),
98
- tc.bg("popover"),
99
- tc.px(3),
100
- tc.py(1.5),
101
- tc.text("sm"),
102
- tc.text("popoverForeground"),
103
- tc.shadow("md"),
104
- ].flat(),
105
- children: [
106
- {
107
- type: "instance",
108
- component: "Text",
109
- children: [{ type: "text", value: "The text you can edit" }],
110
- },
111
- ],
112
- },
113
- ],
114
- },
115
- ],
116
- };
117
-
118
- export const propsMetaTooltip: WsComponentPropsMeta = {
119
- props: propsTooltip,
120
- initialProps: ["open", "delayDuration", "disableHoverableContent"],
121
- };
122
-
123
- export const propsMetaTooltipTrigger: WsComponentPropsMeta = {
124
- props: propsTooltipTrigger,
125
- };
126
-
127
- export const propsMetaTooltipContent: WsComponentPropsMeta = {
128
- props: propsTooltipContent,
129
- initialProps: ["side", "sideOffset", "align", "alignOffset"],
130
- };