@techsio/ui-kit 0.0.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 (183) hide show
  1. package/README.md +165 -0
  2. package/dist/atoms/badge.js +66 -0
  3. package/dist/atoms/button.js +275 -0
  4. package/dist/atoms/error-text.js +38 -0
  5. package/dist/atoms/extra-text.js +27 -0
  6. package/dist/atoms/icon.js +42 -0
  7. package/dist/atoms/image.js +11 -0
  8. package/dist/atoms/input.js +83 -0
  9. package/dist/atoms/label.js +43 -0
  10. package/dist/atoms/link-button.js +51 -0
  11. package/dist/atoms/link.js +23 -0
  12. package/dist/atoms/numeric-input.js +221 -0
  13. package/dist/atoms/rating.js +117 -0
  14. package/dist/atoms/textarea.js +81 -0
  15. package/dist/atoms/tooltip.js +119 -0
  16. package/dist/molecules/accordion.js +245 -0
  17. package/dist/molecules/breadcrumb.js +168 -0
  18. package/dist/molecules/carousel.js +333 -0
  19. package/dist/molecules/checkbox.js +92 -0
  20. package/dist/molecules/color-select.js +159 -0
  21. package/dist/molecules/combobox.js +253 -0
  22. package/dist/molecules/dialog.js +313 -0
  23. package/dist/molecules/form-checkbox.js +59 -0
  24. package/dist/molecules/form-input.js +55 -0
  25. package/dist/molecules/form-numeric-input.js +47 -0
  26. package/dist/molecules/form-textarea.js +54 -0
  27. package/dist/molecules/menu.js +302 -0
  28. package/dist/molecules/pagination.js +184 -0
  29. package/dist/molecules/popover.js +152 -0
  30. package/dist/molecules/product-card.js +194 -0
  31. package/dist/molecules/search-form.js +106 -0
  32. package/dist/molecules/select.js +217 -0
  33. package/dist/molecules/slider.js +249 -0
  34. package/dist/molecules/steps.js +178 -0
  35. package/dist/molecules/switch.js +109 -0
  36. package/dist/molecules/tabs.js +211 -0
  37. package/dist/molecules/toast.js +126 -0
  38. package/dist/molecules/tree-view.js +451 -0
  39. package/dist/organisms/footer.js +209 -0
  40. package/dist/organisms/header.js +245 -0
  41. package/dist/organisms/table.js +233 -0
  42. package/dist/src/atoms/badge.d.ts +59 -0
  43. package/dist/src/atoms/badge.d.ts.map +1 -0
  44. package/dist/src/atoms/button.d.ts +97 -0
  45. package/dist/src/atoms/button.d.ts.map +1 -0
  46. package/dist/src/atoms/error-text.d.ts +29 -0
  47. package/dist/src/atoms/error-text.d.ts.map +1 -0
  48. package/dist/src/atoms/extra-text.d.ts +27 -0
  49. package/dist/src/atoms/extra-text.d.ts.map +1 -0
  50. package/dist/src/atoms/icon.d.ts +65 -0
  51. package/dist/src/atoms/icon.d.ts.map +1 -0
  52. package/dist/src/atoms/image.d.ts +17 -0
  53. package/dist/src/atoms/image.d.ts.map +1 -0
  54. package/dist/src/atoms/input.d.ts +78 -0
  55. package/dist/src/atoms/input.d.ts.map +1 -0
  56. package/dist/src/atoms/label.d.ts +41 -0
  57. package/dist/src/atoms/label.d.ts.map +1 -0
  58. package/dist/src/atoms/link-button.d.ts +129 -0
  59. package/dist/src/atoms/link-button.d.ts.map +1 -0
  60. package/dist/src/atoms/link.d.ts +17 -0
  61. package/dist/src/atoms/link.d.ts.map +1 -0
  62. package/dist/src/atoms/numeric-input.d.ts +64 -0
  63. package/dist/src/atoms/numeric-input.d.ts.map +1 -0
  64. package/dist/src/atoms/rating.d.ts +108 -0
  65. package/dist/src/atoms/rating.d.ts.map +1 -0
  66. package/dist/src/atoms/textarea.d.ts +81 -0
  67. package/dist/src/atoms/textarea.d.ts.map +1 -0
  68. package/dist/src/atoms/tooltip.d.ts +88 -0
  69. package/dist/src/atoms/tooltip.d.ts.map +1 -0
  70. package/dist/src/molecules/accordion.d.ts +182 -0
  71. package/dist/src/molecules/accordion.d.ts.map +1 -0
  72. package/dist/src/molecules/breadcrumb.d.ts +117 -0
  73. package/dist/src/molecules/breadcrumb.d.ts.map +1 -0
  74. package/dist/src/molecules/carousel.d.ts +261 -0
  75. package/dist/src/molecules/carousel.d.ts.map +1 -0
  76. package/dist/src/molecules/checkbox.d.ts +19 -0
  77. package/dist/src/molecules/checkbox.d.ts.map +1 -0
  78. package/dist/src/molecules/color-select.d.ts +20 -0
  79. package/dist/src/molecules/color-select.d.ts.map +1 -0
  80. package/dist/src/molecules/combobox.d.ts +141 -0
  81. package/dist/src/molecules/combobox.d.ts.map +1 -0
  82. package/dist/src/molecules/dialog.d.ts +234 -0
  83. package/dist/src/molecules/dialog.d.ts.map +1 -0
  84. package/dist/src/molecules/form-checkbox.d.ts +15 -0
  85. package/dist/src/molecules/form-checkbox.d.ts.map +1 -0
  86. package/dist/src/molecules/form-input.d.ts +14 -0
  87. package/dist/src/molecules/form-input.d.ts.map +1 -0
  88. package/dist/src/molecules/form-numeric-input.d.ts +14 -0
  89. package/dist/src/molecules/form-numeric-input.d.ts.map +1 -0
  90. package/dist/src/molecules/form-textarea.d.ts +14 -0
  91. package/dist/src/molecules/form-textarea.d.ts.map +1 -0
  92. package/dist/src/molecules/menu.d.ts +153 -0
  93. package/dist/src/molecules/menu.d.ts.map +1 -0
  94. package/dist/src/molecules/pagination.d.ts +123 -0
  95. package/dist/src/molecules/pagination.d.ts.map +1 -0
  96. package/dist/src/molecules/popover.d.ts +124 -0
  97. package/dist/src/molecules/popover.d.ts.map +1 -0
  98. package/dist/src/molecules/product-card.d.ts +160 -0
  99. package/dist/src/molecules/product-card.d.ts.map +1 -0
  100. package/dist/src/molecules/search-form.d.ts +39 -0
  101. package/dist/src/molecules/search-form.d.ts.map +1 -0
  102. package/dist/src/molecules/select.d.ts +126 -0
  103. package/dist/src/molecules/select.d.ts.map +1 -0
  104. package/dist/src/molecules/slider.d.ts +120 -0
  105. package/dist/src/molecules/slider.d.ts.map +1 -0
  106. package/dist/src/molecules/steps.d.ts +96 -0
  107. package/dist/src/molecules/steps.d.ts.map +1 -0
  108. package/dist/src/molecules/switch.d.ts +71 -0
  109. package/dist/src/molecules/switch.d.ts.map +1 -0
  110. package/dist/src/molecules/tabs.d.ts +207 -0
  111. package/dist/src/molecules/tabs.d.ts.map +1 -0
  112. package/dist/src/molecules/toast.d.ts +83 -0
  113. package/dist/src/molecules/toast.d.ts.map +1 -0
  114. package/dist/src/molecules/tree-view.d.ts +202 -0
  115. package/dist/src/molecules/tree-view.d.ts.map +1 -0
  116. package/dist/src/organisms/footer.d.ts +254 -0
  117. package/dist/src/organisms/footer.d.ts.map +1 -0
  118. package/dist/src/organisms/header.d.ts +186 -0
  119. package/dist/src/organisms/header.d.ts.map +1 -0
  120. package/dist/src/organisms/table.d.ts +250 -0
  121. package/dist/src/organisms/table.d.ts.map +1 -0
  122. package/dist/src/templates/accordion.d.ts +15 -0
  123. package/dist/src/templates/accordion.d.ts.map +1 -0
  124. package/dist/src/templates/carousel.d.ts +13 -0
  125. package/dist/src/templates/carousel.d.ts.map +1 -0
  126. package/dist/src/templates/numeric-input.d.ts +14 -0
  127. package/dist/src/templates/numeric-input.d.ts.map +1 -0
  128. package/dist/src/templates/product-card.d.ts +33 -0
  129. package/dist/src/templates/product-card.d.ts.map +1 -0
  130. package/dist/src/templates/tabs.d.ts +16 -0
  131. package/dist/src/templates/tabs.d.ts.map +1 -0
  132. package/dist/src/types/zag.d.ts +19 -0
  133. package/dist/src/types/zag.d.ts.map +1 -0
  134. package/dist/src/utils.d.ts +4 -0
  135. package/dist/src/utils.d.ts.map +1 -0
  136. package/dist/templates/accordion.js +37 -0
  137. package/dist/templates/carousel.js +55 -0
  138. package/dist/templates/numeric-input.js +49 -0
  139. package/dist/templates/product-card.js +92 -0
  140. package/dist/templates/tabs.js +34 -0
  141. package/dist/types/zag.js +0 -0
  142. package/dist/utils.js +20 -0
  143. package/package.json +126 -0
  144. package/src/tokens/_base.css +25 -0
  145. package/src/tokens/_colors.css +5 -0
  146. package/src/tokens/_layout.css +34 -0
  147. package/src/tokens/_semantic.css +360 -0
  148. package/src/tokens/_spacing.css +22 -0
  149. package/src/tokens/_typography.css +17 -0
  150. package/src/tokens/components/atoms/_badge.css +61 -0
  151. package/src/tokens/components/atoms/_button.css +215 -0
  152. package/src/tokens/components/atoms/_icon.css +122 -0
  153. package/src/tokens/components/atoms/_input.css +125 -0
  154. package/src/tokens/components/atoms/_numeric-input.css +57 -0
  155. package/src/tokens/components/atoms/_rating.css +33 -0
  156. package/src/tokens/components/atoms/_textarea.css +93 -0
  157. package/src/tokens/components/atoms/_tooltip.css +21 -0
  158. package/src/tokens/components/components.css +32 -0
  159. package/src/tokens/components/molecules/_accordion.css +85 -0
  160. package/src/tokens/components/molecules/_breadcrumb.css +44 -0
  161. package/src/tokens/components/molecules/_carousel.css +72 -0
  162. package/src/tokens/components/molecules/_checkbox.css +29 -0
  163. package/src/tokens/components/molecules/_color-select.css +61 -0
  164. package/src/tokens/components/molecules/_combobox.css +116 -0
  165. package/src/tokens/components/molecules/_dialog.css +75 -0
  166. package/src/tokens/components/molecules/_menu.css +48 -0
  167. package/src/tokens/components/molecules/_pagination.css +75 -0
  168. package/src/tokens/components/molecules/_popover.css +39 -0
  169. package/src/tokens/components/molecules/_product-card.css +85 -0
  170. package/src/tokens/components/molecules/_search-form.css +10 -0
  171. package/src/tokens/components/molecules/_select.css +88 -0
  172. package/src/tokens/components/molecules/_slider.css +75 -0
  173. package/src/tokens/components/molecules/_steps.css +54 -0
  174. package/src/tokens/components/molecules/_switch.css +62 -0
  175. package/src/tokens/components/molecules/_tabs.css +69 -0
  176. package/src/tokens/components/molecules/_toast.css +77 -0
  177. package/src/tokens/components/molecules/_tree-view.css +80 -0
  178. package/src/tokens/components/molecules/index.css +2 -0
  179. package/src/tokens/components/organisms/_footer.css +90 -0
  180. package/src/tokens/components/organisms/_header.css +86 -0
  181. package/src/tokens/components/organisms/_table.css +63 -0
  182. package/src/tokens/index.css +67 -0
  183. package/src/tokens/tokens-only.css +66 -0
@@ -0,0 +1,333 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { connect, machine } from "@zag-js/carousel";
3
+ import { normalizeProps, useMachine } from "@zag-js/react";
4
+ import { createContext, useContext, useId } from "react";
5
+ import { tv } from "tailwind-variants";
6
+ import { Button } from "../atoms/button.js";
7
+ import { Image } from "../atoms/image.js";
8
+ const carouselVariants = tv({
9
+ slots: {
10
+ wrapper: [
11
+ 'relative w-fit'
12
+ ],
13
+ root: [
14
+ 'relative overflow-hidden',
15
+ 'rounded-carousel'
16
+ ],
17
+ control: [
18
+ 'flex absolute bottom-0 left-1/2 -translate-x-1/2',
19
+ 'gap-carousel-control p-carousel-control',
20
+ 'bg-carousel-control-bg',
21
+ 'rounded-carousel'
22
+ ],
23
+ slideGroup: [
24
+ 'overflow-hidden',
25
+ 'scrollbar-hide',
26
+ 'data-[dragging]:cursor-grabbing'
27
+ ],
28
+ slide: [
29
+ 'relative flex-shrink-0',
30
+ 'flex items-center justify-center',
31
+ 'overflow-hidden'
32
+ ],
33
+ prevTrigger: '',
34
+ nextTrigger: '',
35
+ indicatorGroup: [
36
+ 'flex justify-center w-full items-center gap-carousel-indicator'
37
+ ],
38
+ indicator: [
39
+ 'aspect-carousel-indicator bg-carousel-indicator-bg w-carousel-indicator',
40
+ 'data-[current]:bg-carousel-indicator-bg-active',
41
+ 'data-[current]:border-carousel-indicator-border-active',
42
+ 'rounded-carousel-indicator border border-carousel-indicator-border'
43
+ ],
44
+ autoplayIcon: [
45
+ 'icon-[mdi--play]',
46
+ 'data-[pressed=true]:icon-[mdi--pause]'
47
+ ],
48
+ autoplayTrigger: [
49
+ 'absolute top-carousel-trigger-top right-carousel-trigger-right z-50',
50
+ 'bg-carousel-trigger-bg'
51
+ ],
52
+ spacer: [
53
+ 'flex-1'
54
+ ]
55
+ },
56
+ compoundSlots: [
57
+ {
58
+ slots: [
59
+ 'autoplayTrigger',
60
+ 'indicator',
61
+ 'prevTrigger',
62
+ 'nextTrigger'
63
+ ],
64
+ class: [
65
+ 'p-carousel-trigger',
66
+ 'focus:outline-none text-carousel-trigger-fg',
67
+ 'focus:ring',
68
+ 'focus:ring-carousel-ring'
69
+ ]
70
+ },
71
+ {
72
+ slots: [
73
+ 'prevTrigger',
74
+ 'nextTrigger'
75
+ ],
76
+ class: [
77
+ 'bg-carousel-trigger-bg hover:bg-carousel-trigger-bg-hover text-carousel-trigger-size',
78
+ 'hover:text-carousel-trigger-fg-hover'
79
+ ]
80
+ }
81
+ ],
82
+ variants: {
83
+ objectFit: {
84
+ cover: {
85
+ slide: '*:w-full *:h-full *:object-cover'
86
+ },
87
+ contain: {
88
+ slide: '*:w-full *:h-full *:object-contain'
89
+ },
90
+ fill: {
91
+ slide: '*:w-full *:h-full *:object-fill'
92
+ },
93
+ none: {
94
+ slide: ''
95
+ }
96
+ },
97
+ aspectRatio: {
98
+ square: {
99
+ slide: 'aspect-square'
100
+ },
101
+ landscape: {
102
+ slide: 'aspect-video'
103
+ },
104
+ portrait: {
105
+ slide: 'aspect-portrait'
106
+ },
107
+ wide: {
108
+ slide: 'aspect-wide'
109
+ },
110
+ none: {
111
+ slide: ''
112
+ }
113
+ },
114
+ size: {
115
+ sm: {
116
+ root: [
117
+ 'data-[orientation=horizontal]:max-w-carousel-root-sm',
118
+ 'data-[orientation=vertical]:max-h-carousel-root-sm'
119
+ ],
120
+ slide: [
121
+ 'data-[orientation=horizontal]:max-w-carousel-root-sm',
122
+ 'data-[orientation=vertical]:max-h-carousel-root-sm'
123
+ ]
124
+ },
125
+ md: {
126
+ root: [
127
+ 'data-[orientation=horizontal]:max-w-carousel-root-md',
128
+ 'data-[orientation=vertical]:max-h-carousel-root-md'
129
+ ],
130
+ slide: [
131
+ 'data-[orientation=horizontal]:max-w-carousel-root-md',
132
+ 'data-[orientation=vertical]:max-h-carousel-root-md'
133
+ ]
134
+ },
135
+ lg: {
136
+ root: [
137
+ 'data-[orientation=horizontal]:max-w-carousel-root-lg',
138
+ 'data-[orientation=vertical]:max-h-carousel-root-lg'
139
+ ],
140
+ slide: [
141
+ 'data-[orientation=horizontal]:max-w-carousel-root-lg',
142
+ 'data-[orientation=vertical]:max-h-carousel-root-lg'
143
+ ]
144
+ },
145
+ full: {
146
+ root: [
147
+ 'data-[orientation=horizontal]:w-full',
148
+ 'data-[orientation=vertical]:h-full'
149
+ ]
150
+ }
151
+ }
152
+ },
153
+ defaultVariants: {
154
+ aspectRatio: 'square',
155
+ objectFit: 'cover',
156
+ size: 'md'
157
+ }
158
+ });
159
+ const CarouselContext = /*#__PURE__*/ createContext(null);
160
+ const useCarouselContext = ()=>{
161
+ const context = useContext(CarouselContext);
162
+ if (!context) throw new Error('Carousel components must be used within Carousel.Root');
163
+ return context;
164
+ };
165
+ function Carousel({ id, size, objectFit, aspectRatio, orientation = 'horizontal', slideCount = 1, loop = true, autoplay = false, allowMouseDrag = true, slidesPerPage = 1, slidesPerMove = 1, spacing = '0px', padding = '0px', dir = 'ltr', className, children, onPageChange, ...props }) {
166
+ const fallbackId = useId();
167
+ const service = useMachine(machine, {
168
+ id: id ?? fallbackId,
169
+ slideCount,
170
+ autoplay,
171
+ orientation,
172
+ allowMouseDrag,
173
+ loop,
174
+ slidesPerPage,
175
+ slidesPerMove,
176
+ spacing,
177
+ padding,
178
+ dir,
179
+ onPageChange,
180
+ ...props
181
+ });
182
+ const api = connect(service, normalizeProps);
183
+ const { wrapper, root } = carouselVariants({
184
+ size,
185
+ objectFit,
186
+ aspectRatio
187
+ });
188
+ return /*#__PURE__*/ jsx(CarouselContext.Provider, {
189
+ value: {
190
+ api,
191
+ size,
192
+ objectFit,
193
+ aspectRatio
194
+ },
195
+ children: /*#__PURE__*/ jsx("div", {
196
+ className: wrapper({
197
+ className
198
+ }),
199
+ children: /*#__PURE__*/ jsx("div", {
200
+ className: root(),
201
+ ...api.getRootProps(),
202
+ children: children
203
+ })
204
+ })
205
+ });
206
+ }
207
+ Carousel.Slides = function({ slides, size: overrideSize, imageAs, width, height, className }) {
208
+ const { api, size: contextSize, objectFit, aspectRatio } = useCarouselContext();
209
+ const size = overrideSize ?? contextSize;
210
+ const { slideGroup } = carouselVariants({
211
+ size,
212
+ objectFit,
213
+ aspectRatio
214
+ });
215
+ const ImageComponent = imageAs || Image;
216
+ return /*#__PURE__*/ jsx("div", {
217
+ className: slideGroup({
218
+ className
219
+ }),
220
+ ...api.getItemGroupProps(),
221
+ children: slides.map((slide, index)=>/*#__PURE__*/ jsx(Carousel.Slide, {
222
+ index: index,
223
+ children: slide.content || /*#__PURE__*/ jsx(ImageComponent, {
224
+ as: imageAs === Image ? void 0 : imageAs,
225
+ src: slide.src || '',
226
+ alt: slide.alt || '',
227
+ width: width,
228
+ height: height,
229
+ ...slide.imageProps
230
+ })
231
+ }, slide.id))
232
+ });
233
+ };
234
+ Carousel.Slide = function({ index, children, size: overrideSize, className }) {
235
+ const { api, size: contextSize, objectFit, aspectRatio } = useCarouselContext();
236
+ const size = overrideSize ?? contextSize;
237
+ const { slide: slideSlot } = carouselVariants({
238
+ size,
239
+ objectFit,
240
+ aspectRatio
241
+ });
242
+ return /*#__PURE__*/ jsx("div", {
243
+ className: slideSlot({
244
+ className
245
+ }),
246
+ ...api.getItemProps({
247
+ index
248
+ }),
249
+ children: children
250
+ });
251
+ };
252
+ Carousel.Previous = function({ className, icon = 'token-icon-carousel-prev' }) {
253
+ const { api } = useCarouselContext();
254
+ const { prevTrigger } = carouselVariants();
255
+ return /*#__PURE__*/ jsx(Button, {
256
+ className: prevTrigger({
257
+ className
258
+ }),
259
+ ...api.getPrevTriggerProps(),
260
+ icon: icon
261
+ });
262
+ };
263
+ Carousel.Next = function({ className, icon = 'token-icon-carousel-next' }) {
264
+ const { api } = useCarouselContext();
265
+ const { nextTrigger } = carouselVariants();
266
+ return /*#__PURE__*/ jsx(Button, {
267
+ className: nextTrigger({
268
+ className
269
+ }),
270
+ ...api.getNextTriggerProps(),
271
+ icon: icon
272
+ });
273
+ };
274
+ Carousel.Indicators = function({ className, children }) {
275
+ const { api } = useCarouselContext();
276
+ const { indicatorGroup, indicator } = carouselVariants();
277
+ if (children) return /*#__PURE__*/ jsx("div", {
278
+ className: indicatorGroup({
279
+ className
280
+ }),
281
+ ...api.getIndicatorGroupProps(),
282
+ children: children
283
+ });
284
+ return /*#__PURE__*/ jsx("div", {
285
+ className: indicatorGroup({
286
+ className
287
+ }),
288
+ ...api.getIndicatorGroupProps(),
289
+ children: api.pageSnapPoints.map((_, index)=>/*#__PURE__*/ jsx(Button, {
290
+ className: indicator(),
291
+ ...api.getIndicatorProps({
292
+ index
293
+ })
294
+ }, index))
295
+ });
296
+ };
297
+ Carousel.Indicator = function({ index, className, children }) {
298
+ const { api } = useCarouselContext();
299
+ const { indicator } = carouselVariants();
300
+ return /*#__PURE__*/ jsx(Button, {
301
+ className: indicator({
302
+ className
303
+ }),
304
+ ...api.getIndicatorProps({
305
+ index
306
+ }),
307
+ children: children
308
+ });
309
+ };
310
+ Carousel.Autoplay = function({ className }) {
311
+ const { api } = useCarouselContext();
312
+ const { autoplayTrigger: autoplayTriggerSlot } = carouselVariants();
313
+ return /*#__PURE__*/ jsx(Button, {
314
+ icon: api.isPlaying ? 'icon-[mdi--pause]' : 'icon-[mdi--play]',
315
+ className: autoplayTriggerSlot({
316
+ className
317
+ }),
318
+ ...api.getAutoplayTriggerProps()
319
+ });
320
+ };
321
+ Carousel.Control = function({ children, className }) {
322
+ const { api } = useCarouselContext();
323
+ const { control } = carouselVariants();
324
+ return /*#__PURE__*/ jsx("div", {
325
+ className: control({
326
+ className
327
+ }),
328
+ ...api.getControlProps(),
329
+ children: children
330
+ });
331
+ };
332
+ Carousel.Root = Carousel;
333
+ export { Carousel };
@@ -0,0 +1,92 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { connect, machine } from "@zag-js/checkbox";
3
+ import { normalizeProps, useMachine } from "@zag-js/react";
4
+ import { useId } from "react";
5
+ import { ErrorText } from "../atoms/error-text.js";
6
+ import { ExtraText } from "../atoms/extra-text.js";
7
+ import { Label } from "../atoms/label.js";
8
+ import { tv } from "../utils.js";
9
+ const checkboxVariants = tv({
10
+ slots: {
11
+ root: [],
12
+ label: [
13
+ 'flex items-center gap-2 cursor-pointer'
14
+ ],
15
+ checkbox: [
16
+ 'appearance-none relative cursor-pointer flex-shrink-0',
17
+ 'h-checkbox w-checkbox',
18
+ 'border border-checkbox-border rounded-checkbox',
19
+ 'bg-checkbox data-[state=checked]:bg-checkbox-checked border-checkbox',
20
+ 'after:absolute after:left-1/2 after:top-1/2 after:-translate-x-1/2 after:-translate-y-1/2',
21
+ 'data-[state=checked]:after:token-icon-checkbox text-icon-fg data-[state=checked]:text-checkbox-icon-md',
22
+ 'data-[disabled]:opacity-checkbox-disabled data-[disabled]:cursor-not-allowed data-[disabled]:grayscale',
23
+ 'transition-all duration-200',
24
+ 'data-[focus]:outline-none',
25
+ 'data-[focus]:ring',
26
+ 'data-[focus]:ring-checkbox-ring',
27
+ 'data-[invalid]:ring-checkbox-error ',
28
+ 'data-[invalid]:border-checkbox-border-error',
29
+ 'data-[state=indeterminate]:bg-checkbox-indeterminate',
30
+ 'data-[state=indeterminate]:after:w-indeterminate data-[state=indeterminate]:after:h-indeterminate',
31
+ 'data-[state=indeterminate]:after:bg-icon-fg'
32
+ ]
33
+ }
34
+ });
35
+ function Checkbox({ id, name, checked, defaultChecked, indeterminate, disabled, onCheckedChange, className, invalid, readOnly, labelText, errorText, helperText }) {
36
+ const fallbackId = useId();
37
+ const service = useMachine(machine, {
38
+ id: id || fallbackId,
39
+ name,
40
+ disabled,
41
+ defaultChecked,
42
+ readOnly,
43
+ checked: indeterminate ? 'indeterminate' : checked,
44
+ invalid: invalid,
45
+ onCheckedChange: (details)=>{
46
+ onCheckedChange?.(details);
47
+ }
48
+ });
49
+ const api = connect(service, normalizeProps);
50
+ const { checkbox: checkboxSlot, root, label: labelSlot } = checkboxVariants({
51
+ className
52
+ });
53
+ return /*#__PURE__*/ jsxs("div", {
54
+ className: root({
55
+ className
56
+ }),
57
+ children: [
58
+ /*#__PURE__*/ jsxs(Label, {
59
+ className: labelSlot(),
60
+ ...api.getRootProps(),
61
+ children: [
62
+ /*#__PURE__*/ jsx("div", {
63
+ ...api.getControlProps(),
64
+ className: checkboxSlot({
65
+ className
66
+ }),
67
+ "data-invalid": invalid
68
+ }),
69
+ /*#__PURE__*/ jsx("input", {
70
+ ...api.getHiddenInputProps()
71
+ }),
72
+ labelText && /*#__PURE__*/ jsx(Label, {
73
+ ...api.getLabelProps(),
74
+ children: labelText
75
+ })
76
+ ]
77
+ }),
78
+ (errorText || helperText) && /*#__PURE__*/ jsxs("div", {
79
+ children: [
80
+ invalid && errorText && /*#__PURE__*/ jsx(ErrorText, {
81
+ children: errorText
82
+ }),
83
+ !invalid && helperText && /*#__PURE__*/ jsx(ExtraText, {
84
+ children: helperText
85
+ })
86
+ ]
87
+ })
88
+ ]
89
+ });
90
+ }
91
+ Checkbox.displayName = 'Checkbox';
92
+ export { Checkbox };
@@ -0,0 +1,159 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button } from "../atoms/button.js";
3
+ import { Icon } from "../atoms/icon.js";
4
+ import { tv } from "../utils.js";
5
+ const colorSelectVariants = tv({
6
+ slots: {
7
+ group: [
8
+ 'grid place-items-start'
9
+ ],
10
+ cell: 'grid',
11
+ atom: [
12
+ 'relative cursor-pointer p-color-select-atom',
13
+ 'aspect-square overflow-hidden',
14
+ 'border-2 transition-all duration-200',
15
+ 'border-color-select-border hover:border-color-select-border-hover shadow-color-select',
16
+ 'focus-visible:outline-none',
17
+ 'focus-visible:ring',
18
+ 'focus-visible:ring-color-select-ring',
19
+ 'data-[selected=true]:border-color-select-selected data-[selected=true]:shadow-none'
20
+ ],
21
+ color: [
22
+ 'absolute',
23
+ 'w-full h-full hover:brightness-75',
24
+ 'data-[selected=true]:brightness-75'
25
+ ],
26
+ icon: [
27
+ 'absolute items-center hidden justify-center',
28
+ 'text-color-select-fg-check drop-shadow-sm',
29
+ 'pointer-events-none',
30
+ 'data-[selected=true]:flex'
31
+ ],
32
+ labelContainer: [
33
+ 'text-center'
34
+ ],
35
+ labelText: [
36
+ 'text-xs text-color-select-label-fg'
37
+ ],
38
+ countText: [
39
+ 'text-xs text-color-select-label-fg'
40
+ ]
41
+ },
42
+ variants: {
43
+ radius: {
44
+ sm: {
45
+ atom: 'rounded-color-select-sm'
46
+ },
47
+ md: {
48
+ atom: 'rounded-color-select-md'
49
+ },
50
+ lg: {
51
+ atom: 'rounded-color-select-lg'
52
+ },
53
+ full: {
54
+ atom: 'rounded-color-select-full'
55
+ }
56
+ },
57
+ size: {
58
+ sm: {
59
+ group: 'gap-color-select-group-sm',
60
+ atom: 'h-color-select-sm',
61
+ icon: 'text-color-select-sm'
62
+ },
63
+ md: {
64
+ group: 'gap-color-select-group-md',
65
+ atom: 'h-color-select-md',
66
+ icon: 'text-color-select-md'
67
+ },
68
+ lg: {
69
+ group: 'gap-color-select-group-lg',
70
+ atom: 'h-color-select-lg',
71
+ icon: 'text-color-select-lg'
72
+ },
73
+ full: {
74
+ group: 'h-full',
75
+ cell: 'h-full',
76
+ atom: 'h-full',
77
+ icon: 'w-color-select-icon h-color-select-icon'
78
+ }
79
+ },
80
+ layout: {
81
+ list: {
82
+ group: 'grid-cols-1'
83
+ },
84
+ grid: {
85
+ group: 'color-select-grid'
86
+ }
87
+ },
88
+ disabled: {
89
+ true: {
90
+ atom: 'select-disabled hover:border-color-select-border'
91
+ }
92
+ }
93
+ },
94
+ defaultVariants: {
95
+ radius: 'full',
96
+ size: 'lg',
97
+ layout: 'list'
98
+ }
99
+ });
100
+ const ColorSelect = ({ colors, layout = 'grid', size = 'lg', radius = 'full', disabled, onColorClick, selectionMode = 'single' })=>{
101
+ const { group, cell, atom, color: colorSlot, icon, labelContainer, labelText, countText } = colorSelectVariants({
102
+ layout,
103
+ size,
104
+ radius,
105
+ disabled
106
+ });
107
+ return /*#__PURE__*/ jsx("div", {
108
+ className: group(),
109
+ role: 'single' === selectionMode ? 'radiogroup' : 'group',
110
+ children: colors.map((colorItem)=>/*#__PURE__*/ jsxs("div", {
111
+ className: cell(),
112
+ children: [
113
+ /*#__PURE__*/ jsxs(Button, {
114
+ theme: "borderless",
115
+ className: `${atom()} ${colorItem.disabled ? 'select-disabled' : ''}`,
116
+ disabled: colorItem.disabled || disabled,
117
+ onClick: ()=>onColorClick?.(colorItem.color),
118
+ role: 'single' === selectionMode ? 'radio' : 'checkbox',
119
+ "aria-label": `Select color ${colorItem.label ?? colorItem.color}`,
120
+ "aria-checked": !!colorItem.selected,
121
+ "data-selected": colorItem.selected || false,
122
+ children: [
123
+ /*#__PURE__*/ jsx("span", {
124
+ className: colorSlot(),
125
+ style: {
126
+ backgroundColor: colorItem.color
127
+ },
128
+ "aria-hidden": "true",
129
+ "data-selected": colorItem.selected || false
130
+ }),
131
+ /*#__PURE__*/ jsx(Icon, {
132
+ icon: "token-icon-color-select",
133
+ className: icon(),
134
+ "data-selected": colorItem.selected || false
135
+ })
136
+ ]
137
+ }),
138
+ (null != colorItem.label || null != colorItem.count) && /*#__PURE__*/ jsxs("div", {
139
+ className: labelContainer(),
140
+ children: [
141
+ colorItem.label && /*#__PURE__*/ jsx("span", {
142
+ className: labelText(),
143
+ children: colorItem.label
144
+ }),
145
+ null != colorItem.count && /*#__PURE__*/ jsxs("span", {
146
+ className: countText(),
147
+ children: [
148
+ "(",
149
+ colorItem.count,
150
+ ")"
151
+ ]
152
+ })
153
+ ]
154
+ })
155
+ ]
156
+ }, colorItem.id || colorItem.color))
157
+ });
158
+ };
159
+ export { ColorSelect };