@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.
Files changed (149) hide show
  1. package/lib/__generated__/accordion.props.js +2134 -0
  2. package/lib/__generated__/button.props.js +454 -0
  3. package/lib/__generated__/dialog.props.js +0 -7
  4. package/lib/__generated__/input.props.js +451 -0
  5. package/lib/__generated__/label.props.js +421 -0
  6. package/lib/__generated__/popover.props.js +0 -7
  7. package/lib/__generated__/sheet.props.js +0 -7
  8. package/lib/__generated__/textarea.props.js +431 -0
  9. package/lib/__generated__/tooltip.props.js +0 -7
  10. package/lib/accordion.js +51 -0
  11. package/lib/accordion.ws.js +243 -0
  12. package/lib/button.js +8 -0
  13. package/lib/button.ws.js +133 -0
  14. package/lib/cjs/__generated__/accordion.props.js +2154 -0
  15. package/lib/cjs/__generated__/button.props.js +474 -0
  16. package/lib/cjs/__generated__/dialog.props.js +0 -7
  17. package/lib/cjs/__generated__/input.props.js +471 -0
  18. package/lib/cjs/__generated__/label.props.js +441 -0
  19. package/lib/cjs/__generated__/popover.props.js +0 -7
  20. package/lib/cjs/__generated__/sheet.props.js +0 -7
  21. package/lib/cjs/__generated__/textarea.props.js +451 -0
  22. package/lib/cjs/__generated__/tooltip.props.js +0 -7
  23. package/lib/cjs/accordion.js +60 -0
  24. package/lib/cjs/accordion.ws.js +261 -0
  25. package/lib/cjs/button.js +28 -0
  26. package/lib/cjs/button.ws.js +160 -0
  27. package/lib/cjs/collapsible.js +2 -16
  28. package/lib/cjs/collapsible.ws.js +1 -8
  29. package/lib/cjs/components.js +14 -0
  30. package/lib/cjs/dialog.js +38 -6
  31. package/lib/cjs/dialog.ws.js +15 -26
  32. package/lib/cjs/hooks.js +15 -1
  33. package/lib/cjs/input.js +28 -0
  34. package/lib/cjs/input.ws.js +103 -0
  35. package/lib/cjs/label.js +37 -0
  36. package/lib/cjs/label.ws.js +74 -0
  37. package/lib/cjs/metas.js +14 -0
  38. package/lib/cjs/popover.js +37 -5
  39. package/lib/cjs/popover.ws.js +15 -18
  40. package/lib/cjs/props.js +14 -0
  41. package/lib/cjs/sheet.js +34 -1
  42. package/lib/cjs/sheet.ws.js +33 -19
  43. package/lib/cjs/tabs.js +20 -1
  44. package/lib/cjs/tabs.ws.js +3 -25
  45. package/lib/cjs/textarea.js +28 -0
  46. package/lib/cjs/textarea.ws.js +98 -0
  47. package/lib/cjs/theme/tailwind-classes.js +186 -23
  48. package/lib/cjs/theme/tailwind-colors.js +10 -1
  49. package/lib/cjs/tooltip.js +36 -4
  50. package/lib/cjs/tooltip.ws.js +15 -18
  51. package/lib/collapsible.js +2 -16
  52. package/lib/collapsible.ws.js +1 -8
  53. package/lib/components.js +20 -0
  54. package/lib/dialog.js +38 -6
  55. package/lib/dialog.ws.js +15 -26
  56. package/lib/hooks.js +15 -1
  57. package/lib/input.js +8 -0
  58. package/lib/input.ws.js +75 -0
  59. package/lib/label.js +9 -0
  60. package/lib/label.ws.js +46 -0
  61. package/lib/metas.js +20 -0
  62. package/lib/popover.js +37 -5
  63. package/lib/popover.ws.js +15 -18
  64. package/lib/props.js +20 -0
  65. package/lib/sheet.js +34 -1
  66. package/lib/sheet.ws.js +33 -19
  67. package/lib/tabs.js +24 -2
  68. package/lib/tabs.ws.js +3 -25
  69. package/lib/textarea.js +8 -0
  70. package/lib/textarea.ws.js +70 -0
  71. package/lib/theme/tailwind-classes.js +191 -24
  72. package/lib/theme/tailwind-colors.js +10 -1
  73. package/lib/tooltip.js +36 -4
  74. package/lib/tooltip.ws.js +15 -18
  75. package/lib/types/__generated__/accordion.props.d.ts +6 -0
  76. package/lib/types/__generated__/button.props.d.ts +2 -0
  77. package/lib/types/__generated__/input.props.d.ts +2 -0
  78. package/lib/types/__generated__/label.props.d.ts +2 -0
  79. package/lib/types/__generated__/textarea.props.d.ts +2 -0
  80. package/lib/types/accordion.d.ts +12 -0
  81. package/lib/types/accordion.ws.d.ts +11 -0
  82. package/lib/types/button.d.ts +7 -0
  83. package/lib/types/button.stories.d.ts +20 -0
  84. package/lib/types/button.ws.d.ts +7 -0
  85. package/lib/types/components.d.ts +5 -0
  86. package/lib/types/dialog.d.ts +5 -11
  87. package/lib/types/input.d.ts +2 -0
  88. package/lib/types/input.stories.d.ts +20 -0
  89. package/lib/types/input.ws.d.ts +3 -0
  90. package/lib/types/label.d.ts +3 -0
  91. package/lib/types/label.stories.d.ts +9 -0
  92. package/lib/types/label.ws.d.ts +3 -0
  93. package/lib/types/metas.d.ts +5 -0
  94. package/lib/types/popover.d.ts +4 -10
  95. package/lib/types/props.d.ts +5 -0
  96. package/lib/types/sheet.d.ts +4 -4
  97. package/lib/types/tabs.d.ts +2 -0
  98. package/lib/types/textarea.d.ts +2 -0
  99. package/lib/types/textarea.stories.d.ts +14 -0
  100. package/lib/types/textarea.ws.d.ts +3 -0
  101. package/lib/types/theme/tailwind-classes.d.ts +16 -5
  102. package/lib/types/theme/tailwind-colors.d.ts +9 -0
  103. package/lib/types/tooltip.d.ts +3 -9
  104. package/package.json +9 -7
  105. package/src/__generated__/accordion.props.ts +2382 -0
  106. package/src/__generated__/button.props.ts +503 -0
  107. package/src/__generated__/dialog.props.ts +0 -7
  108. package/src/__generated__/input.props.ts +500 -0
  109. package/src/__generated__/label.props.ts +470 -0
  110. package/src/__generated__/popover.props.ts +0 -7
  111. package/src/__generated__/sheet.props.ts +0 -7
  112. package/src/__generated__/textarea.props.ts +480 -0
  113. package/src/__generated__/tooltip.props.ts +0 -7
  114. package/src/accordion.stories.tsx +21 -0
  115. package/src/accordion.tsx +81 -0
  116. package/src/accordion.ws.ts +270 -0
  117. package/src/button.stories.ts +35 -0
  118. package/src/button.tsx +25 -0
  119. package/src/button.ws.ts +155 -0
  120. package/src/collapsible.tsx +2 -16
  121. package/src/collapsible.ws.ts +1 -8
  122. package/src/components.ts +11 -0
  123. package/src/dialog.stories.tsx +21 -0
  124. package/src/dialog.tsx +50 -24
  125. package/src/dialog.ws.tsx +15 -26
  126. package/src/hooks.ts +15 -1
  127. package/src/input.stories.ts +31 -0
  128. package/src/input.tsx +12 -0
  129. package/src/input.ws.ts +78 -0
  130. package/src/label.stories.ts +22 -0
  131. package/src/label.tsx +15 -0
  132. package/src/label.ws.ts +48 -0
  133. package/src/metas.ts +11 -0
  134. package/src/popover.stories.tsx +21 -0
  135. package/src/popover.tsx +49 -23
  136. package/src/popover.ws.tsx +15 -18
  137. package/src/props.ts +11 -0
  138. package/src/sheet.tsx +39 -0
  139. package/src/sheet.ws.tsx +33 -19
  140. package/src/tabs.tsx +32 -1
  141. package/src/tabs.ws.ts +1 -23
  142. package/src/textarea.stories.ts +27 -0
  143. package/src/textarea.tsx +12 -0
  144. package/src/textarea.ws.ts +74 -0
  145. package/src/theme/tailwind-classes.ts +233 -38
  146. package/src/theme/tailwind-colors.ts +9 -16
  147. package/src/tooltip.stories.tsx +21 -0
  148. package/src/tooltip.tsx +46 -20
  149. package/src/tooltip.ws.tsx +15 -18
@@ -0,0 +1,243 @@
1
+ import {
2
+ AccordionIcon,
3
+ ItemIcon,
4
+ HeaderIcon,
5
+ TriggerIcon,
6
+ ContentIcon
7
+ } from "@webstudio-is/icons/svg";
8
+ import { div, h3, button } from "@webstudio-is/react-sdk/css-normalize";
9
+ import * as tc from "./theme/tailwind-classes";
10
+ import {
11
+ propsAccordion,
12
+ propsAccordionItem,
13
+ propsAccordionHeader,
14
+ propsAccordionTrigger,
15
+ propsAccordionContent
16
+ } from "./__generated__/accordion.props";
17
+ const presetStyle = {
18
+ div
19
+ };
20
+ const accordionItemStyles = [tc.borderB()].flat();
21
+ const accordionHeaderStyles = [tc.flex()].flat();
22
+ const accordionTriggerStyles = [
23
+ tc.flex(),
24
+ tc.flex(1),
25
+ tc.items("center"),
26
+ tc.justify("between"),
27
+ tc.py(4),
28
+ tc.font("medium"),
29
+ tc.transition("all"),
30
+ tc.hover([tc.underline()].flat())
31
+ ].flat();
32
+ const accordionContentStyles = [
33
+ tc.overflow("hidden"),
34
+ tc.text("sm"),
35
+ // transition does not work with display: none
36
+ // tc.transition("all"),
37
+ tc.pb(4)
38
+ ].flat();
39
+ const metaAccordion = {
40
+ category: "radix",
41
+ type: "container",
42
+ icon: AccordionIcon,
43
+ presetStyle,
44
+ template: [
45
+ {
46
+ type: "instance",
47
+ component: "Accordion",
48
+ dataSources: {
49
+ accordionValue: { type: "variable", initialValue: "0" }
50
+ },
51
+ props: [
52
+ { type: "boolean", name: "collapsible", value: true },
53
+ { type: "dataSource", name: "value", dataSourceName: "accordionValue" },
54
+ {
55
+ name: "onValueChange",
56
+ type: "action",
57
+ value: [
58
+ {
59
+ type: "execute",
60
+ args: ["value"],
61
+ code: `accordionValue = value`
62
+ }
63
+ ]
64
+ }
65
+ ],
66
+ children: [
67
+ {
68
+ type: "instance",
69
+ component: "AccordionItem",
70
+ styles: accordionItemStyles,
71
+ children: [
72
+ {
73
+ type: "instance",
74
+ component: "AccordionHeader",
75
+ styles: accordionHeaderStyles,
76
+ children: [
77
+ {
78
+ type: "instance",
79
+ component: "AccordionTrigger",
80
+ styles: accordionTriggerStyles,
81
+ children: [{ type: "text", value: "Is it accessible?" }]
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ type: "instance",
87
+ component: "AccordionContent",
88
+ styles: accordionContentStyles,
89
+ children: [
90
+ {
91
+ type: "text",
92
+ value: "Yes. It adheres to the WAI-ARIA design pattern."
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ },
98
+ {
99
+ type: "instance",
100
+ component: "AccordionItem",
101
+ styles: accordionItemStyles,
102
+ children: [
103
+ {
104
+ type: "instance",
105
+ component: "AccordionHeader",
106
+ styles: accordionHeaderStyles,
107
+ children: [
108
+ {
109
+ type: "instance",
110
+ component: "AccordionTrigger",
111
+ styles: accordionTriggerStyles,
112
+ children: [{ type: "text", value: "Is it styled?" }]
113
+ }
114
+ ]
115
+ },
116
+ {
117
+ type: "instance",
118
+ component: "AccordionContent",
119
+ styles: accordionContentStyles,
120
+ children: [
121
+ {
122
+ type: "text",
123
+ value: "Yes. It comes with default styles that matches the other components' aesthetic."
124
+ }
125
+ ]
126
+ }
127
+ ]
128
+ },
129
+ {
130
+ type: "instance",
131
+ component: "AccordionItem",
132
+ styles: accordionItemStyles,
133
+ children: [
134
+ {
135
+ type: "instance",
136
+ component: "AccordionHeader",
137
+ styles: accordionHeaderStyles,
138
+ children: [
139
+ {
140
+ type: "instance",
141
+ component: "AccordionTrigger",
142
+ styles: accordionTriggerStyles,
143
+ children: [{ type: "text", value: "Is it animated?" }]
144
+ }
145
+ ]
146
+ },
147
+ {
148
+ type: "instance",
149
+ component: "AccordionContent",
150
+ styles: accordionContentStyles,
151
+ children: [
152
+ {
153
+ type: "text",
154
+ value: "Yes. It's animated by default, but you can disable it if you prefer."
155
+ }
156
+ ]
157
+ }
158
+ ]
159
+ }
160
+ ]
161
+ }
162
+ ]
163
+ };
164
+ const metaAccordionItem = {
165
+ category: "hidden",
166
+ type: "container",
167
+ icon: ItemIcon,
168
+ requiredAncestors: ["Accordion"],
169
+ indexWithinAncestor: "Accordion",
170
+ presetStyle
171
+ };
172
+ const metaAccordionHeader = {
173
+ category: "hidden",
174
+ type: "container",
175
+ icon: HeaderIcon,
176
+ requiredAncestors: ["AccordionItem"],
177
+ detachable: false,
178
+ presetStyle: {
179
+ h3: [h3, tc.my(0)].flat()
180
+ }
181
+ };
182
+ const metaAccordionTrigger = {
183
+ category: "hidden",
184
+ type: "container",
185
+ icon: TriggerIcon,
186
+ requiredAncestors: ["AccordionHeader"],
187
+ detachable: false,
188
+ presetStyle: {
189
+ button: [
190
+ button,
191
+ {
192
+ property: "backgroundColor",
193
+ value: { type: "keyword", value: "transparent" }
194
+ },
195
+ {
196
+ property: "backgroundImage",
197
+ value: { type: "keyword", value: "none" }
198
+ },
199
+ {
200
+ property: "cursor",
201
+ value: { type: "keyword", value: "pointer" }
202
+ },
203
+ tc.px(0),
204
+ tc.border(0)
205
+ ].flat()
206
+ }
207
+ };
208
+ const metaAccordionContent = {
209
+ category: "hidden",
210
+ type: "container",
211
+ icon: ContentIcon,
212
+ requiredAncestors: ["AccordionItem"],
213
+ detachable: false,
214
+ presetStyle
215
+ };
216
+ const propsMetaAccordion = {
217
+ props: propsAccordion,
218
+ initialProps: ["value", "collapsible", "dir", "orientation"]
219
+ };
220
+ const propsMetaAccordionItem = {
221
+ props: propsAccordionItem
222
+ };
223
+ const propsMetaAccordionHeader = {
224
+ props: propsAccordionHeader
225
+ };
226
+ const propsMetaAccordionTrigger = {
227
+ props: propsAccordionTrigger
228
+ };
229
+ const propsMetaAccordionContent = {
230
+ props: propsAccordionContent
231
+ };
232
+ export {
233
+ metaAccordion,
234
+ metaAccordionContent,
235
+ metaAccordionHeader,
236
+ metaAccordionItem,
237
+ metaAccordionTrigger,
238
+ propsMetaAccordion,
239
+ propsMetaAccordionContent,
240
+ propsMetaAccordionHeader,
241
+ propsMetaAccordionItem,
242
+ propsMetaAccordionTrigger
243
+ };
package/lib/button.js ADDED
@@ -0,0 +1,8 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ const Button = forwardRef(({ variant = "default", size = "default", ...props }, ref) => {
4
+ return /* @__PURE__ */ jsx("button", { ref, "data-size": size, "data-variant": variant, ...props });
5
+ });
6
+ export {
7
+ Button
8
+ };
@@ -0,0 +1,133 @@
1
+ import { ButtonElementIcon } from "@webstudio-is/icons/svg";
2
+ import {
3
+ defaultStates,
4
+ EmbedTemplateInstance
5
+ } from "@webstudio-is/react-sdk";
6
+ import { button } from "@webstudio-is/react-sdk/css-normalize";
7
+ import { props } from "./__generated__/button.props";
8
+ import * as tc from "./theme/tailwind-classes";
9
+ const presetStyle = {
10
+ button
11
+ };
12
+ const template = (props2) => [
13
+ {
14
+ type: "instance",
15
+ component: "Button",
16
+ styles: [
17
+ // 'inline-flex items-center justify-center rounded-md text-sm font-medium
18
+ // ring-offset-background transition-colors
19
+ // focus-visible:outline-none focus-visible:ring-2
20
+ // focus-visible:ring-ring focus-visible:ring-offset-2
21
+ // disabled:pointer-events-none disabled:opacity-50'
22
+ tc.border(0),
23
+ tc.bg("transparent"),
24
+ tc.inlineFlex(),
25
+ tc.items("center"),
26
+ tc.justify("center"),
27
+ tc.rounded("md"),
28
+ tc.text("sm"),
29
+ tc.font("medium"),
30
+ tc.focusVisible(
31
+ [tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
32
+ ),
33
+ tc.state([tc.pointerEvents("none"), tc.opacity(50)].flat(), ":disabled"),
34
+ // VARIANT
35
+ // default: 'bg-primary text-primary-foreground hover:bg-primary/90',
36
+ tc.state(
37
+ [tc.bg("primary"), tc.text("primaryForeground")].flat(),
38
+ "[data-variant=default]"
39
+ ),
40
+ tc.state(
41
+ [[tc.bg("primary", 90)].flat()].flat(),
42
+ "[data-variant=default]:hover"
43
+ ),
44
+ // destructive:'bg-destructive text-destructive-foreground hover:bg-destructive/90',
45
+ tc.state(
46
+ [tc.bg("destructive"), tc.text("destructiveForeground")].flat(),
47
+ "[data-variant=destructive]"
48
+ ),
49
+ tc.state(
50
+ [[tc.bg("destructive", 90)].flat()].flat(),
51
+ "[data-variant=destructive]:hover"
52
+ ),
53
+ // outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
54
+ tc.state(
55
+ [tc.border(), tc.border("input"), tc.bg("background")].flat(),
56
+ "[data-variant=outline]"
57
+ ),
58
+ tc.state(
59
+ [[tc.bg("accent", 90), tc.text("accentForeground")].flat()].flat(),
60
+ "[data-variant=outline]:hover"
61
+ ),
62
+ // secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
63
+ tc.state(
64
+ [tc.bg("secondary"), tc.text("secondaryForeground")].flat(),
65
+ "[data-variant=secondary]"
66
+ ),
67
+ tc.state(
68
+ [[tc.bg("secondary", 80)].flat()].flat(),
69
+ "[data-variant=secondary]:hover"
70
+ ),
71
+ // ghost: 'hover:bg-accent hover:text-accent-foreground',
72
+ tc.state(
73
+ [[tc.bg("accent"), tc.text("accentForeground")].flat()].flat(),
74
+ "[data-variant=ghost]:hover"
75
+ ),
76
+ // link: 'text-primary underline-offset-4 hover:underline',
77
+ tc.state(
78
+ [tc.text("primary"), tc.underlineOffset(4)].flat(),
79
+ "[data-variant=link]"
80
+ ),
81
+ tc.state([[tc.underline()].flat()].flat(), "[data-variant=link]:hover"),
82
+ // SIZE
83
+ // default: 'h-10 px-4 py-2',
84
+ tc.state([tc.h(10), tc.px(4), tc.py(2)].flat(), "[data-size=default]"),
85
+ // sm: 'h-9 rounded-md px-3',
86
+ tc.state([tc.h(10), tc.px(3)].flat(), "[data-size=sm]"),
87
+ // lg: 'h-11 rounded-md px-8',
88
+ tc.state([tc.h(11), tc.px(8)].flat(), "[data-size=lg]"),
89
+ // icon: 'h-10 w-10',
90
+ tc.state([tc.h(10), tc.w(10)].flat(), "[data-size=icon]")
91
+ ].flat(),
92
+ children: props2?.children ?? [{ type: "text", value: "Button" }],
93
+ props: props2?.props
94
+ }
95
+ ];
96
+ const meta = {
97
+ category: "radix",
98
+ type: "container",
99
+ invalidAncestors: ["Button"],
100
+ icon: ButtonElementIcon,
101
+ presetStyle,
102
+ states: [
103
+ ...defaultStates,
104
+ { selector: ":disabled", label: "Disabled" },
105
+ { selector: ":enabled", label: "Enabled" },
106
+ { selector: "[data-variant=default]", label: "Default" },
107
+ { selector: "[data-variant=default]:hover", label: "Default Hover" },
108
+ { selector: "[data-variant=destructive]", label: "Destructive" },
109
+ {
110
+ selector: "[data-variant=destructive]:hover",
111
+ label: "Destructive Hover"
112
+ },
113
+ { selector: "[data-variant=outline]", label: "Outline" },
114
+ { selector: "[data-variant=outline]:hover", label: "Outline Hover" },
115
+ { selector: "[data-variant=secondary]", label: "Secondary" },
116
+ { selector: "[data-variant=secondary]:hover", label: "Secondary Hover" },
117
+ { selector: "[data-variant=ghost]", label: "Ghost" },
118
+ { selector: "[data-variant=ghost]:hover", label: "Ghost Hover" },
119
+ { selector: "[data-variant=link]", label: "Link" },
120
+ { selector: "[data-variant=link]:hover", label: "Link Hover" }
121
+ ],
122
+ order: 1,
123
+ template: template()
124
+ };
125
+ const propsMeta = {
126
+ props,
127
+ initialProps: ["id", "type", "variant", "size", "aria-label"]
128
+ };
129
+ export {
130
+ meta,
131
+ propsMeta,
132
+ template
133
+ };