@accelint/design-toolkit 4.0.0 → 5.1.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 (269) hide show
  1. package/dist/components/accordion/index.d.ts +1 -1
  2. package/dist/components/accordion/index.js +3 -1
  3. package/dist/components/accordion/index.js.map +1 -1
  4. package/dist/components/accordion/styles.js +1 -1
  5. package/dist/components/accordion/styles.js.map +1 -1
  6. package/dist/components/accordion/types.d.ts +1 -1
  7. package/dist/components/action-bar/index.d.ts +10 -0
  8. package/dist/components/action-bar/index.js +4 -0
  9. package/dist/components/action-bar/index.js.map +1 -0
  10. package/dist/components/action-bar/styles.d.ts +5 -0
  11. package/dist/components/action-bar/styles.js +2 -0
  12. package/dist/components/action-bar/styles.js.map +1 -0
  13. package/dist/components/action-bar/types.d.ts +5 -0
  14. package/dist/components/action-bar/types.js +2 -0
  15. package/dist/components/action-bar/types.js.map +1 -0
  16. package/dist/components/avatar/index.d.ts +1 -1
  17. package/dist/components/avatar/index.js +3 -1
  18. package/dist/components/avatar/index.js.map +1 -1
  19. package/dist/components/avatar/styles.js +1 -1
  20. package/dist/components/avatar/styles.js.map +1 -1
  21. package/dist/components/avatar/types.d.ts +1 -1
  22. package/dist/components/badge/index.d.ts +1 -1
  23. package/dist/components/badge/index.js +2 -0
  24. package/dist/components/badge/index.js.map +1 -1
  25. package/dist/components/badge/styles.js +1 -1
  26. package/dist/components/badge/styles.js.map +1 -1
  27. package/dist/components/button/index.d.ts +1 -1
  28. package/dist/components/button/index.js +2 -0
  29. package/dist/components/button/index.js.map +1 -1
  30. package/dist/components/button/styles.js +1 -1
  31. package/dist/components/button/styles.js.map +1 -1
  32. package/dist/components/button/types.d.ts +1 -1
  33. package/dist/components/checkbox/index.js +2 -0
  34. package/dist/components/checkbox/styles.js +1 -1
  35. package/dist/components/checkbox/styles.js.map +1 -1
  36. package/dist/components/chip/index.d.ts +1 -1
  37. package/dist/components/chip/index.js +2 -0
  38. package/dist/components/chip/index.js.map +1 -1
  39. package/dist/components/chip/styles.js +1 -1
  40. package/dist/components/chip/styles.js.map +1 -1
  41. package/dist/components/classification-badge/index.d.ts +1 -1
  42. package/dist/components/classification-badge/index.js +3 -1
  43. package/dist/components/classification-badge/index.js.map +1 -1
  44. package/dist/components/classification-badge/styles.d.ts +1 -1
  45. package/dist/components/classification-badge/styles.js +1 -1
  46. package/dist/components/classification-badge/styles.js.map +1 -1
  47. package/dist/components/classification-banner/index.d.ts +1 -1
  48. package/dist/components/classification-banner/index.js +3 -1
  49. package/dist/components/classification-banner/index.js.map +1 -1
  50. package/dist/components/classification-banner/styles.d.ts +1 -1
  51. package/dist/components/classification-banner/styles.js +1 -1
  52. package/dist/components/classification-banner/styles.js.map +1 -1
  53. package/dist/components/color-picker/index.js +2 -0
  54. package/dist/components/color-picker/styles.js +1 -1
  55. package/dist/components/color-picker/styles.js.map +1 -1
  56. package/dist/components/combobox-field/index.d.ts +1 -1
  57. package/dist/components/combobox-field/index.js +2 -0
  58. package/dist/components/combobox-field/index.js.map +1 -1
  59. package/dist/components/combobox-field/styles.d.ts +1 -1
  60. package/dist/components/combobox-field/styles.js +1 -1
  61. package/dist/components/combobox-field/styles.js.map +1 -1
  62. package/dist/components/combobox-field/types.d.ts +1 -1
  63. package/dist/components/date-field/index.js +2 -0
  64. package/dist/components/date-field/index.js.map +1 -1
  65. package/dist/components/date-field/styles.d.ts +1 -1
  66. package/dist/components/date-field/styles.js +1 -1
  67. package/dist/components/date-field/styles.js.map +1 -1
  68. package/dist/components/details-list/index.d.ts +1 -1
  69. package/dist/components/details-list/index.js +3 -1
  70. package/dist/components/details-list/index.js.map +1 -1
  71. package/dist/components/details-list/styles.js +1 -1
  72. package/dist/components/details-list/styles.js.map +1 -1
  73. package/dist/components/dialog/index.js +3 -1
  74. package/dist/components/dialog/index.js.map +1 -1
  75. package/dist/components/dialog/styles.d.ts +1 -1
  76. package/dist/components/dialog/styles.js +1 -1
  77. package/dist/components/dialog/styles.js.map +1 -1
  78. package/dist/components/drawer/index.d.ts +1 -1
  79. package/dist/components/drawer/index.js +3 -1
  80. package/dist/components/drawer/index.js.map +1 -1
  81. package/dist/components/drawer/styles.d.ts +4 -4
  82. package/dist/components/drawer/styles.js +1 -1
  83. package/dist/components/drawer/styles.js.map +1 -1
  84. package/dist/components/drawer/types.d.ts +1 -1
  85. package/dist/components/hero/index.js +3 -1
  86. package/dist/components/hero/index.js.map +1 -1
  87. package/dist/components/hero/styles.js +1 -1
  88. package/dist/components/hero/styles.js.map +1 -1
  89. package/dist/components/hotkey/index.d.ts +1 -1
  90. package/dist/components/hotkey/index.js +2 -0
  91. package/dist/components/hotkey/index.js.map +1 -1
  92. package/dist/components/hotkey/styles.js +1 -1
  93. package/dist/components/hotkey/styles.js.map +1 -1
  94. package/dist/components/icon/index.d.ts +1 -1
  95. package/dist/components/icon/index.js +3 -1
  96. package/dist/components/icon/index.js.map +1 -1
  97. package/dist/components/input/index.d.ts +1 -1
  98. package/dist/components/input/index.js +2 -0
  99. package/dist/components/input/index.js.map +1 -1
  100. package/dist/components/input/styles.js +1 -1
  101. package/dist/components/input/styles.js.map +1 -1
  102. package/dist/components/label/index.d.ts +1 -1
  103. package/dist/components/label/index.js +2 -0
  104. package/dist/components/label/index.js.map +1 -1
  105. package/dist/components/label/styles.js +1 -1
  106. package/dist/components/label/styles.js.map +1 -1
  107. package/dist/components/lines/index.d.ts +9 -0
  108. package/dist/components/lines/index.js +2 -0
  109. package/dist/components/lines/index.js.map +1 -0
  110. package/dist/components/lines/styles.d.ts +32 -0
  111. package/dist/components/lines/styles.js +2 -0
  112. package/dist/components/lines/styles.js.map +1 -0
  113. package/dist/components/lines/types.d.ts +10 -0
  114. package/dist/components/lines/types.js +2 -0
  115. package/dist/components/lines/types.js.map +1 -0
  116. package/dist/components/link/index.d.ts +17 -0
  117. package/dist/components/link/index.js +4 -0
  118. package/dist/components/link/index.js.map +1 -0
  119. package/dist/components/link/styles.d.ts +5 -0
  120. package/dist/components/link/styles.js +2 -0
  121. package/dist/components/link/styles.js.map +1 -0
  122. package/dist/components/link/types.d.ts +9 -0
  123. package/dist/components/link/types.js +2 -0
  124. package/dist/components/link/types.js.map +1 -0
  125. package/dist/components/menu/index.js +3 -1
  126. package/dist/components/menu/index.js.map +1 -1
  127. package/dist/components/menu/styles.js +1 -1
  128. package/dist/components/menu/styles.js.map +1 -1
  129. package/dist/components/options/index.js +2 -0
  130. package/dist/components/options/index.js.map +1 -1
  131. package/dist/components/options/styles.d.ts +1 -1
  132. package/dist/components/options/styles.js +1 -1
  133. package/dist/components/options/styles.js.map +1 -1
  134. package/dist/components/popover/index.js +2 -0
  135. package/dist/components/popover/index.js.map +1 -1
  136. package/dist/components/popover/styles.js +1 -1
  137. package/dist/components/popover/styles.js.map +1 -1
  138. package/dist/components/query-builder/action-element.js +2 -0
  139. package/dist/components/query-builder/action-element.js.map +1 -1
  140. package/dist/components/query-builder/group.js +3 -1
  141. package/dist/components/query-builder/group.js.map +1 -1
  142. package/dist/components/query-builder/index.js +1 -1
  143. package/dist/components/query-builder/index.js.map +1 -1
  144. package/dist/components/query-builder/rule.js +2 -0
  145. package/dist/components/query-builder/value-editor.js +2 -0
  146. package/dist/components/query-builder/value-editor.js.map +1 -1
  147. package/dist/components/query-builder/value-selector.js.map +1 -1
  148. package/dist/components/radio/index.js +2 -0
  149. package/dist/components/radio/styles.js +1 -1
  150. package/dist/components/radio/styles.js.map +1 -1
  151. package/dist/components/search-field/index.d.ts +3 -3
  152. package/dist/components/search-field/index.js +2 -0
  153. package/dist/components/search-field/index.js.map +1 -1
  154. package/dist/components/search-field/styles.js +1 -1
  155. package/dist/components/search-field/styles.js.map +1 -1
  156. package/dist/components/select-field/index.d.ts +1 -1
  157. package/dist/components/select-field/index.js +3 -1
  158. package/dist/components/select-field/index.js.map +1 -1
  159. package/dist/components/select-field/styles.js +1 -1
  160. package/dist/components/select-field/styles.js.map +1 -1
  161. package/dist/components/select-field/types.d.ts +1 -1
  162. package/dist/components/sidenav/events.d.ts +8 -0
  163. package/dist/components/sidenav/events.js +2 -0
  164. package/dist/components/sidenav/events.js.map +1 -0
  165. package/dist/components/sidenav/index.d.ts +64 -0
  166. package/dist/components/sidenav/index.js +4 -0
  167. package/dist/components/sidenav/index.js.map +1 -0
  168. package/dist/components/sidenav/styles.d.ts +156 -0
  169. package/dist/components/sidenav/styles.js +2 -0
  170. package/dist/components/sidenav/styles.js.map +1 -0
  171. package/dist/components/sidenav/types.d.ts +70 -0
  172. package/dist/components/sidenav/types.js +2 -0
  173. package/dist/components/sidenav/types.js.map +1 -0
  174. package/dist/components/skeleton/styles.d.ts +2 -2
  175. package/dist/components/skeleton/styles.js +1 -1
  176. package/dist/components/skeleton/styles.js.map +1 -1
  177. package/dist/components/slider/index.js +2 -0
  178. package/dist/components/slider/index.js.map +1 -1
  179. package/dist/components/slider/styles.d.ts +1 -1
  180. package/dist/components/slider/styles.js +1 -1
  181. package/dist/components/slider/styles.js.map +1 -1
  182. package/dist/components/switch/index.d.ts +1 -1
  183. package/dist/components/switch/index.js +2 -0
  184. package/dist/components/switch/index.js.map +1 -1
  185. package/dist/components/switch/styles.js +1 -1
  186. package/dist/components/switch/styles.js.map +1 -1
  187. package/dist/components/tabs/index.d.ts +37 -36
  188. package/dist/components/tabs/index.js +3 -1
  189. package/dist/components/tabs/index.js.map +1 -1
  190. package/dist/components/tabs/styles.d.ts +48 -0
  191. package/dist/components/tabs/styles.js +2 -0
  192. package/dist/components/tabs/styles.js.map +1 -0
  193. package/dist/components/tabs/types.d.ts +6 -0
  194. package/dist/components/tabs/types.js +2 -0
  195. package/dist/components/tabs/types.js.map +1 -0
  196. package/dist/components/text-area-field/index.d.ts +1 -1
  197. package/dist/components/text-area-field/index.js +2 -0
  198. package/dist/components/text-area-field/index.js.map +1 -1
  199. package/dist/components/text-area-field/styles.js +1 -1
  200. package/dist/components/text-area-field/styles.js.map +1 -1
  201. package/dist/components/text-field/index.js +2 -0
  202. package/dist/components/text-field/index.js.map +1 -1
  203. package/dist/components/text-field/styles.js +1 -1
  204. package/dist/components/text-field/styles.js.map +1 -1
  205. package/dist/components/tooltip/index.d.ts +1 -1
  206. package/dist/components/tooltip/index.js +3 -1
  207. package/dist/components/tooltip/index.js.map +1 -1
  208. package/dist/components/tooltip/styles.d.ts +1 -1
  209. package/dist/components/tooltip/styles.js +1 -1
  210. package/dist/components/tooltip/styles.js.map +1 -1
  211. package/dist/components/tooltip/types.d.ts +3 -1
  212. package/dist/components/tree/index.d.ts +51 -0
  213. package/dist/components/tree/index.js +4 -0
  214. package/dist/components/tree/index.js.map +1 -0
  215. package/dist/components/tree/styles.d.ts +128 -0
  216. package/dist/components/tree/styles.js +2 -0
  217. package/dist/components/tree/styles.js.map +1 -0
  218. package/dist/components/tree/types.d.ts +41 -0
  219. package/dist/components/tree/types.js +2 -0
  220. package/dist/components/tree/types.js.map +1 -0
  221. package/dist/components/view-stack/index.js +2 -0
  222. package/dist/components/view-stack/index.js.map +1 -1
  223. package/dist/foundation/token-data.d.ts +17 -0
  224. package/dist/foundation/token-data.js +2 -0
  225. package/dist/foundation/token-data.js.map +1 -0
  226. package/dist/hooks/use-tree/actions/cache.d.ts +78 -0
  227. package/dist/hooks/use-tree/actions/cache.js +2 -0
  228. package/dist/hooks/use-tree/actions/cache.js.map +1 -0
  229. package/dist/hooks/use-tree/actions/index.d.ts +38 -0
  230. package/dist/hooks/use-tree/actions/index.js +4 -0
  231. package/dist/hooks/use-tree/actions/index.js.map +1 -0
  232. package/dist/hooks/use-tree/state/index.d.ts +8 -0
  233. package/dist/hooks/use-tree/state/index.js +2 -0
  234. package/dist/hooks/use-tree/state/index.js.map +1 -0
  235. package/dist/hooks/use-tree/state/utils.d.ts +7 -0
  236. package/dist/hooks/use-tree/state/utils.js +2 -0
  237. package/dist/hooks/use-tree/state/utils.js.map +1 -0
  238. package/dist/hooks/use-tree/types.d.ts +171 -0
  239. package/dist/hooks/use-tree/types.js +2 -0
  240. package/dist/hooks/use-tree/types.js.map +1 -0
  241. package/dist/icons/catalog.js +1 -1
  242. package/dist/icons/catalog.js.map +1 -1
  243. package/dist/index.css +9 -15
  244. package/dist/index.d.ts +26 -3
  245. package/dist/index.js +1 -1
  246. package/dist/lib/react.d.ts +22 -8
  247. package/dist/lib/react.js +8 -4
  248. package/dist/lib/react.js.map +1 -1
  249. package/dist/lib/utils.d.ts +2 -2
  250. package/dist/lib/utils.js +1 -1
  251. package/dist/lib/utils.js.map +1 -1
  252. package/dist/metafile-esm.json +1 -1
  253. package/dist/providers/theme-provider.d.ts +22 -0
  254. package/dist/providers/theme-provider.js +4 -0
  255. package/dist/providers/theme-provider.js.map +1 -0
  256. package/dist/styles.css +1663 -920
  257. package/dist/tokens/themes.css +729 -53
  258. package/dist/tokens/tokens.css +121 -65
  259. package/dist/tokens/tokens.d.ts +449 -1
  260. package/dist/tokens/tokens.js +2 -0
  261. package/dist/tokens/tokens.js.map +1 -0
  262. package/dist/tokens/types.d.ts +299 -0
  263. package/dist/tokens/types.js +2 -0
  264. package/dist/tokens/types.js.map +1 -0
  265. package/dist/variants/variants.css +6 -1
  266. package/package.json +13 -8
  267. package/dist/tokens/index.d.ts +0 -123
  268. package/dist/tokens/index.js +0 -2
  269. package/dist/tokens/index.js.map +0 -1
package/dist/index.css CHANGED
@@ -41,6 +41,7 @@
41
41
  outline-offset: -1px;
42
42
  }
43
43
 
44
+ /* Note: we may want to generate these typography utility classes in themes.css in the future */
44
45
  @utility text-header-xxl {
45
46
  font-size: var(--typography-header-xxl-size);
46
47
  font-weight: 500;
@@ -163,13 +164,6 @@
163
164
  --icon-color: --value(--color- *);
164
165
  }
165
166
 
166
- @utility fg-* {
167
- color: --value([ *]);
168
- color: --value(--color- *);
169
- --icon-color: --value([ *]);
170
- --icon-color: --value(--color- *);
171
- }
172
-
173
167
  body {
174
168
  @apply font-primary;
175
169
  }
@@ -188,11 +182,11 @@ body {
188
182
  }
189
183
 
190
184
  ::-webkit-scrollbar-track {
191
- background: var(--color-interactive);
185
+ background: var(--bg-interactive-muted-hover);
192
186
  }
193
187
 
194
188
  ::-webkit-scrollbar-thumb{
195
- background-color: var(--color-interactive-hover-light);
189
+ background-color: var(--bg-interactive-muted);
196
190
  border-radius: var(--radius-large);
197
191
  border: 5px solid transparent;
198
192
  background-clip: padding-box;
@@ -210,8 +204,8 @@ body {
210
204
  bottom: 0;
211
205
  left: 50%;
212
206
  background-image:
213
- repeating-linear-gradient(to bottom, var(--colors-neutral-04), var(--colors-neutral-04)),
214
- repeating-linear-gradient(to right, var(--colors-neutral-04), var(--colors-neutral-04));
207
+ repeating-linear-gradient(to bottom, var(--primitive-neutral-400), var(--primitive-neutral-400)),
208
+ repeating-linear-gradient(to right, var(--primitive-neutral-400), var(--primitive-neutral-400));
215
209
  background-position: left -1px, center;
216
210
  background-repeat: repeat-y, repeat-x;
217
211
  background-size: 1px 4px, 4px 1px;
@@ -225,8 +219,8 @@ body {
225
219
  bottom: 50%;
226
220
  left: 50%;
227
221
  background-image:
228
- repeating-linear-gradient(to bottom,var(--colors-neutral-04), var(--colors-neutral-04)),
229
- repeating-linear-gradient(to right, var(--colors-neutral-04), var(--colors-neutral-04));
222
+ repeating-linear-gradient(to bottom,var(--primitive-neutral-400), var(--primitive-neutral-400)),
223
+ repeating-linear-gradient(to right, var(--primitive-neutral-400), var(--primitive-neutral-400));
230
224
  background-position: left -1px, bottom;
231
225
  background-repeat: repeat-y, repeat-x;
232
226
  background-size: 1px 4px, 4px 1px;
@@ -240,8 +234,8 @@ body {
240
234
  bottom: 0;
241
235
  left: 50%;
242
236
  background-image:
243
- repeating-linear-gradient(to bottom, var(--colors-neutral-04), var(--colors-neutral-04)),
244
- repeating-linear-gradient(to right, var(--colors-neutral-04), var(--colors-neutral-04));
237
+ repeating-linear-gradient(to bottom, var(--primitive-neutral-400), var(--primitive-neutral-400)),
238
+ repeating-linear-gradient(to right, var(--primitive-neutral-400), var(--primitive-neutral-400));
245
239
  background-position: left -1px, center;
246
240
  background-repeat: repeat-y, repeat-x;
247
241
  background-size: 1px 4px, 4px 1px;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export { Accordion, AccordionContext } from './components/accordion/index.js';
2
2
  export { AccordionStyles, AccordionStylesDefaults } from './components/accordion/styles.js';
3
3
  export { AccordionGroupProps, AccordionHeaderProps, AccordionPanelProps, AccordionProps, AccordionStyleVariants, AccordionTriggerProps } from './components/accordion/types.js';
4
+ export { ActionBar } from './components/action-bar/index.js';
5
+ export { ActionBarStyles } from './components/action-bar/styles.js';
6
+ export { ActionBarProps } from './components/action-bar/types.js';
4
7
  export { Avatar, AvatarContext } from './components/avatar/index.js';
5
8
  export { AvatarStyles } from './components/avatar/styles.js';
6
9
  export { AvatarProps } from './components/avatar/types.js';
@@ -56,6 +59,12 @@ export { InputProps } from './components/input/types.js';
56
59
  export { Label, LabelContext } from './components/label/index.js';
57
60
  export { LabelStyles } from './components/label/styles.js';
58
61
  export { LabelProps } from './components/label/types.js';
62
+ export { Lines } from './components/lines/index.js';
63
+ export { LinesStyles } from './components/lines/styles.js';
64
+ export { LinesProps, LinesStylesVariants } from './components/lines/types.js';
65
+ export { Link } from './components/link/index.js';
66
+ export { LinkStyles } from './components/link/styles.js';
67
+ export { LinkProps } from './components/link/types.js';
59
68
  export { Menu, MenuContext } from './components/menu/index.js';
60
69
  export { MenuStyles, MenuStylesDefaults } from './components/menu/styles.js';
61
70
  export { MenuItemProps, MenuProps, MenuSectionProps } from './components/menu/types.js';
@@ -76,6 +85,10 @@ export { SearchFieldProps, SearchFieldStyleVariants } from './components/search-
76
85
  export { SelectField, SelectFieldContext } from './components/select-field/index.js';
77
86
  export { SelectFieldStyles } from './components/select-field/styles.js';
78
87
  export { SelectFieldProps } from './components/select-field/types.js';
88
+ export { SidenavEventNamespace, SidenavEventTypes } from './components/sidenav/events.js';
89
+ export { Sidenav } from './components/sidenav/index.js';
90
+ export { SidenavStyles } from './components/sidenav/styles.js';
91
+ export { SidenavAvatarProps, SidenavCloseEvent, SidenavContentProps, SidenavContextValue, SidenavDividerProps, SidenavEvent, SidenavFooterProps, SidenavHeaderProps, SidenavItemProps, SidenavLinkProps, SidenavMenuItemProps, SidenavMenuProps, SidenavOpenEvent, SidenavProps, SidenavToggleEvent, SidenavTriggerProps } from './components/sidenav/types.js';
79
92
  export { Skeleton } from './components/skeleton/index.js';
80
93
  export { SkeletonStyles, SkeletonStylesDefaults } from './components/skeleton/styles.js';
81
94
  export { SkeletonProps, SkeletonStyleVariants } from './components/skeleton/types.js';
@@ -85,7 +98,9 @@ export { SliderProps } from './components/slider/types.js';
85
98
  export { Switch, SwitchContext } from './components/switch/index.js';
86
99
  export { SwitchStyles } from './components/switch/styles.js';
87
100
  export { SwitchProps } from './components/switch/types.js';
88
- export { TabListProps, TabPanelProps, TabProps, Tabs, TabsProps } from './components/tabs/index.js';
101
+ export { Tabs, TabsContext } from './components/tabs/index.js';
102
+ export { TabStyles } from './components/tabs/styles.js';
103
+ export { TabsProps } from './components/tabs/types.js';
89
104
  export { TextAreaField, TextAreaFieldContext } from './components/text-area-field/index.js';
90
105
  export { TextAreaStyles } from './components/text-area-field/styles.js';
91
106
  export { TextAreaFieldProps } from './components/text-area-field/types.js';
@@ -95,13 +110,21 @@ export { TextFieldProps } from './components/text-field/types.js';
95
110
  export { Tooltip, TooltipContext } from './components/tooltip/index.js';
96
111
  export { TooltipStyles } from './components/tooltip/styles.js';
97
112
  export { TooltipBodyProps, TooltipProps, TooltipTriggerProps } from './components/tooltip/types.js';
113
+ export { Tree, TreeContext, TreeItem, TreeItemContext } from './components/tree/index.js';
114
+ export { TreeStyles, TreeStylesDefaults } from './components/tree/styles.js';
115
+ export { TreeContextValue, TreeItemContentProps, TreeItemContentRenderProps, TreeItemContextValue, TreeItemProps, TreeProps } from './components/tree/types.js';
98
116
  export { ViewStackEventNamespace, ViewStackEventTypes } from './components/view-stack/events.js';
99
117
  export { ViewStack, ViewStackContext, ViewStackEventHandlers } from './components/view-stack/index.js';
100
118
  export { ViewStackBackEvent, ViewStackClearEvent, ViewStackContextValue, ViewStackEvent, ViewStackProps, ViewStackPushEvent, ViewStackResetEvent, ViewStackTriggerProps, ViewStackViewProps } from './components/view-stack/types.js';
101
- export { containsExactChildren, expectsIconWrapper } from './lib/react.js';
119
+ export { useTreeActions } from './hooks/use-tree/actions/index.js';
120
+ export { useTreeState } from './hooks/use-tree/state/index.js';
121
+ export { DragAndDropConfig, TreeActions, TreeData, TreeNode, TreeNodeBase, UseTreeActionsOptions, UseTreeState, UseTreeStateOptions } from './hooks/use-tree/types.js';
122
+ export { containsAnyOfExactChildren, containsExactChildren, expectsIconWrapper } from './lib/react.js';
102
123
  export { AriaAttributes, AriaAttributesWithRef, ChildrenRenderProps, ClassNameRenderProps, ProviderProps, RenderProps, RenderPropsChildren, RenderPropsClassName, RenderPropsStyle, SlottedValue, StylePropRenderProps, StyleRenderProps } from './lib/types.js';
103
124
  export { cn, isSlottedContextValue, mergeVariants, tv, twMerge } from './lib/utils.js';
104
- export { RGBAColor, colorAdvisory, colorAdvisoryBold, colorAdvisoryHover, colorAdvisorySubtle, colorClassificationConfidential, colorClassificationCui, colorClassificationMissing, colorClassificationSecret, colorClassificationTopSecret, colorClassificationTsSci, colorClassificationUnclass, colorCritical, colorCriticalBold, colorCriticalHover, colorCriticalSubtle, colorDefaultDark, colorDefaultLight, colorDisabled, colorHighlight, colorHighlightBold, colorHighlightHover, colorHighlightSubtle, colorInfo, colorInfoBold, colorInfoHover, colorInfoSubtle, colorInteractive, colorInteractiveDefault, colorInteractiveDisabled, colorInteractiveHover, colorInteractiveHoverDark, colorInteractiveHoverLight, colorInverseDark, colorInverseLight, colorNormal, colorNormalBold, colorNormalHover, colorNormalSubtle, colorSerious, colorSeriousBold, colorSeriousHover, colorSeriousSubtle, colorStaticDark, colorStaticLight, colorSurfaceDefault, colorSurfaceOverlay, colorSurfaceRaised, colorTransparentDark, colorTransparentLight, fontDisplay, fontPrimary, iconSizeL, iconSizeM, iconSizeS, iconSizeXs, radiusLarge, radiusMedium, radiusNone, radiusRound, radiusSmall, shadowElevationDefault, shadowElevationOverlay, shadowElevationRaised, spacing0, spacingL, spacingM, spacingNone, spacingOversized, spacingS, spacingXl, spacingXs, spacingXxl, spacingXxs, typographyBodyLHeight, typographyBodyLSize, typographyBodyLSpacing, typographyBodyMHeight, typographyBodyMSize, typographyBodyMSpacing, typographyBodySHeight, typographyBodySSize, typographyBodySSpacing, typographyBodyXsHeight, typographyBodyXsSize, typographyBodyXsSpacing, typographyBodyXxsHeight, typographyBodyXxsSize, typographyBodyXxsSpacing, typographyButtonLHeight, typographyButtonLSize, typographyButtonLSpacing, typographyButtonMHeight, typographyButtonMSize, typographyButtonMSpacing, typographyButtonSHeight, typographyButtonSSize, typographyButtonSSpacing, typographyButtonXsHeight, typographyButtonXsSize, typographyButtonXsSpacing, typographyHeaderLHeight, typographyHeaderLSize, typographyHeaderLSpacing, typographyHeaderMHeight, typographyHeaderMSize, typographyHeaderMSpacing, typographyHeaderSHeight, typographyHeaderSSize, typographyHeaderSSpacing, typographyHeaderXlHeight, typographyHeaderXlSize, typographyHeaderXlSpacing, typographyHeaderXsHeight, typographyHeaderXsSize, typographyHeaderXsSpacing, typographyHeaderXxlHeight, typographyHeaderXxlSize, typographyHeaderXxlSpacing } from './tokens/index.js';
125
+ export { ThemeProvider, useTheme } from './providers/theme-provider.js';
126
+ export { designTokens } from './tokens/tokens.js';
127
+ export { SemanticColorTokens, StaticColorTokens, ThemeTokens } from './tokens/types.js';
105
128
  import 'react/jsx-runtime';
106
129
  import 'react';
107
130
  import 'react-aria-components';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{Accordion,AccordionContext}from'./components/accordion/index.js';export{AccordionStyles,AccordionStylesDefaults}from'./components/accordion/styles.js';export{Avatar,AvatarContext}from'./components/avatar/index.js';export{AvatarStyles}from'./components/avatar/styles.js';export{Badge,BadgeContext}from'./components/badge/index.js';export{BadgeStyles,BadgeStylesDefaults}from'./components/badge/styles.js';export{Button,ButtonContext,LinkButton,LinkButtonContext,ToggleButton,ToggleButtonContext}from'./components/button/index.js';export{ButtonStyles,ButtonStylesDefaults,LinkButtonStyles,ToggleButtonStyles}from'./components/button/styles.js';export{Checkbox,CheckboxContext,CheckboxGroupContext}from'./components/checkbox/index.js';export{CheckboxStyles}from'./components/checkbox/styles.js';export{Chip,ChipContext}from'./components/chip/index.js';export{BaseChipStyles,ChipStyles,ChipStylesDefaults,DeletableChipStyles,SelectableChipStyles}from'./components/chip/styles.js';export{ClassificationBadge,ClassificationBadgeContext}from'./components/classification-badge/index.js';export{ClassificationBadgeStyles,ClassificationBadgeStylesDefaults}from'./components/classification-badge/styles.js';export{ClassificationBanner,ClassificationBannerContext}from'./components/classification-banner/index.js';export{ClassificationBannerStyles,ClassificationBannerStylesDefaults}from'./components/classification-banner/styles.js';export{ColorPicker}from'./components/color-picker/index.js';export{ColorPickerStyles}from'./components/color-picker/styles.js';export{ComboBoxField,ComboBoxFieldContext}from'./components/combobox-field/index.js';export{ComboBoxStyles}from'./components/combobox-field/styles.js';export{DateField}from'./components/date-field/index.js';export{DateFieldStyles,DateFieldStylesDefaults}from'./components/date-field/styles.js';export{DetailsList,DetailsListContext}from'./components/details-list/index.js';export{DetailsListStyles,DetailsListStylesDefaults}from'./components/details-list/styles.js';export{Dialog,DialogContext}from'./components/dialog/index.js';export{DialogStyles}from'./components/dialog/styles.js';export{DrawerEventNamespace,DrawerEventTypes}from'./components/drawer/events.js';export{Drawer,DrawerContext,DrawerEventHandlers}from'./components/drawer/index.js';export{DrawerMenuStyles,DrawerMenuStylesDefaults,DrawerStyles,DrawerTitleStyles,DrawerTitleStylesDefaults}from'./components/drawer/styles.js';export{Hero,HeroContext}from'./components/hero/index.js';export{HeroStyles}from'./components/hero/styles.js';export{Hotkey,HotkeyContext}from'./components/hotkey/index.js';export{HotkeyStyles,HotkeyStylesDefaults}from'./components/hotkey/styles.js';export{Icon,IconContext}from'./components/icon/index.js';export{IconStyles}from'./components/icon/styles.js';export{Input,InputContext}from'./components/input/index.js';export{InputStyles,InputStylesDefaults}from'./components/input/styles.js';export{Label,LabelContext}from'./components/label/index.js';export{LabelStyles}from'./components/label/styles.js';export{Menu,MenuContext}from'./components/menu/index.js';export{MenuStyles,MenuStylesDefaults}from'./components/menu/styles.js';export{Options,OptionsContext}from'./components/options/index.js';export{OptionsStyles}from'./components/options/styles.js';export{Popover}from'./components/popover/index.js';export{PopoverStyles}from'./components/popover/styles.js';export{QueryBuilder}from'./components/query-builder/index.js';export{Radio,RadioContext}from'./components/radio/index.js';export{RadioStyles}from'./components/radio/styles.js';export{SearchField,SearchFieldContext}from'./components/search-field/index.js';export{SearchFieldStyles,SearchFieldStylesDefaults}from'./components/search-field/styles.js';export{SelectField,SelectFieldContext}from'./components/select-field/index.js';export{SelectFieldStyles}from'./components/select-field/styles.js';export{Skeleton}from'./components/skeleton/index.js';export{SkeletonStyles,SkeletonStylesDefaults}from'./components/skeleton/styles.js';export{Slider}from'./components/slider/index.js';export{SliderStyles}from'./components/slider/styles.js';export{Switch,SwitchContext}from'./components/switch/index.js';export{SwitchStyles}from'./components/switch/styles.js';export{Tabs}from'./components/tabs/index.js';export{TextAreaField,TextAreaFieldContext}from'./components/text-area-field/index.js';export{TextAreaStyles}from'./components/text-area-field/styles.js';export{TextField,TextFieldContext}from'./components/text-field/index.js';export{TextFieldStyles}from'./components/text-field/styles.js';export{Tooltip,TooltipContext}from'./components/tooltip/index.js';export{TooltipStyles}from'./components/tooltip/styles.js';export{ViewStackEventNamespace,ViewStackEventTypes}from'./components/view-stack/events.js';export{ViewStack,ViewStackContext,ViewStackEventHandlers}from'./components/view-stack/index.js';export{containsExactChildren,expectsIconWrapper}from'./lib/react.js';export{cn,isSlottedContextValue,mergeVariants,tv,twMerge}from'./lib/utils.js';export{colorAdvisory,colorAdvisoryBold,colorAdvisoryHover,colorAdvisorySubtle,colorClassificationConfidential,colorClassificationCui,colorClassificationMissing,colorClassificationSecret,colorClassificationTopSecret,colorClassificationTsSci,colorClassificationUnclass,colorCritical,colorCriticalBold,colorCriticalHover,colorCriticalSubtle,colorDefaultDark,colorDefaultLight,colorDisabled,colorHighlight,colorHighlightBold,colorHighlightHover,colorHighlightSubtle,colorInfo,colorInfoBold,colorInfoHover,colorInfoSubtle,colorInteractive,colorInteractiveDefault,colorInteractiveDisabled,colorInteractiveHover,colorInteractiveHoverDark,colorInteractiveHoverLight,colorInverseDark,colorInverseLight,colorNormal,colorNormalBold,colorNormalHover,colorNormalSubtle,colorSerious,colorSeriousBold,colorSeriousHover,colorSeriousSubtle,colorStaticDark,colorStaticLight,colorSurfaceDefault,colorSurfaceOverlay,colorSurfaceRaised,colorTransparentDark,colorTransparentLight,fontDisplay,fontPrimary,iconSizeL,iconSizeM,iconSizeS,iconSizeXs,radiusLarge,radiusMedium,radiusNone,radiusRound,radiusSmall,shadowElevationDefault,shadowElevationOverlay,shadowElevationRaised,spacing0,spacingL,spacingM,spacingNone,spacingOversized,spacingS,spacingXl,spacingXs,spacingXxl,spacingXxs,typographyBodyLHeight,typographyBodyLSize,typographyBodyLSpacing,typographyBodyMHeight,typographyBodyMSize,typographyBodyMSpacing,typographyBodySHeight,typographyBodySSize,typographyBodySSpacing,typographyBodyXsHeight,typographyBodyXsSize,typographyBodyXsSpacing,typographyBodyXxsHeight,typographyBodyXxsSize,typographyBodyXxsSpacing,typographyButtonLHeight,typographyButtonLSize,typographyButtonLSpacing,typographyButtonMHeight,typographyButtonMSize,typographyButtonMSpacing,typographyButtonSHeight,typographyButtonSSize,typographyButtonSSpacing,typographyButtonXsHeight,typographyButtonXsSize,typographyButtonXsSpacing,typographyHeaderLHeight,typographyHeaderLSize,typographyHeaderLSpacing,typographyHeaderMHeight,typographyHeaderMSize,typographyHeaderMSpacing,typographyHeaderSHeight,typographyHeaderSSize,typographyHeaderSSpacing,typographyHeaderXlHeight,typographyHeaderXlSize,typographyHeaderXlSpacing,typographyHeaderXsHeight,typographyHeaderXsSize,typographyHeaderXsSpacing,typographyHeaderXxlHeight,typographyHeaderXxlSize,typographyHeaderXxlSpacing}from'./tokens/index.js';//# sourceMappingURL=index.js.map
1
+ export{Accordion,AccordionContext}from'./components/accordion/index.js';export{AccordionStyles,AccordionStylesDefaults}from'./components/accordion/styles.js';export{ActionBar}from'./components/action-bar/index.js';export{ActionBarStyles}from'./components/action-bar/styles.js';export{Avatar,AvatarContext}from'./components/avatar/index.js';export{AvatarStyles}from'./components/avatar/styles.js';export{Badge,BadgeContext}from'./components/badge/index.js';export{BadgeStyles,BadgeStylesDefaults}from'./components/badge/styles.js';export{Button,ButtonContext,LinkButton,LinkButtonContext,ToggleButton,ToggleButtonContext}from'./components/button/index.js';export{ButtonStyles,ButtonStylesDefaults,LinkButtonStyles,ToggleButtonStyles}from'./components/button/styles.js';export{Checkbox,CheckboxContext,CheckboxGroupContext}from'./components/checkbox/index.js';export{CheckboxStyles}from'./components/checkbox/styles.js';export{Chip,ChipContext}from'./components/chip/index.js';export{BaseChipStyles,ChipStyles,ChipStylesDefaults,DeletableChipStyles,SelectableChipStyles}from'./components/chip/styles.js';export{ClassificationBadge,ClassificationBadgeContext}from'./components/classification-badge/index.js';export{ClassificationBadgeStyles,ClassificationBadgeStylesDefaults}from'./components/classification-badge/styles.js';export{ClassificationBanner,ClassificationBannerContext}from'./components/classification-banner/index.js';export{ClassificationBannerStyles,ClassificationBannerStylesDefaults}from'./components/classification-banner/styles.js';export{ColorPicker}from'./components/color-picker/index.js';export{ColorPickerStyles}from'./components/color-picker/styles.js';export{ComboBoxField,ComboBoxFieldContext}from'./components/combobox-field/index.js';export{ComboBoxStyles}from'./components/combobox-field/styles.js';export{DateField}from'./components/date-field/index.js';export{DateFieldStyles,DateFieldStylesDefaults}from'./components/date-field/styles.js';export{DetailsList,DetailsListContext}from'./components/details-list/index.js';export{DetailsListStyles,DetailsListStylesDefaults}from'./components/details-list/styles.js';export{Dialog,DialogContext}from'./components/dialog/index.js';export{DialogStyles}from'./components/dialog/styles.js';export{DrawerEventNamespace,DrawerEventTypes}from'./components/drawer/events.js';export{Drawer,DrawerContext,DrawerEventHandlers}from'./components/drawer/index.js';export{DrawerMenuStyles,DrawerMenuStylesDefaults,DrawerStyles,DrawerTitleStyles,DrawerTitleStylesDefaults}from'./components/drawer/styles.js';export{Hero,HeroContext}from'./components/hero/index.js';export{HeroStyles}from'./components/hero/styles.js';export{Hotkey,HotkeyContext}from'./components/hotkey/index.js';export{HotkeyStyles,HotkeyStylesDefaults}from'./components/hotkey/styles.js';export{Icon,IconContext}from'./components/icon/index.js';export{IconStyles}from'./components/icon/styles.js';export{Input,InputContext}from'./components/input/index.js';export{InputStyles,InputStylesDefaults}from'./components/input/styles.js';export{Label,LabelContext}from'./components/label/index.js';export{LabelStyles}from'./components/label/styles.js';export{Lines}from'./components/lines/index.js';export{LinesStyles}from'./components/lines/styles.js';export{Link}from'./components/link/index.js';export{LinkStyles}from'./components/link/styles.js';export{Menu,MenuContext}from'./components/menu/index.js';export{MenuStyles,MenuStylesDefaults}from'./components/menu/styles.js';export{Options,OptionsContext}from'./components/options/index.js';export{OptionsStyles}from'./components/options/styles.js';export{Popover}from'./components/popover/index.js';export{PopoverStyles}from'./components/popover/styles.js';export{QueryBuilder}from'./components/query-builder/index.js';export{Radio,RadioContext}from'./components/radio/index.js';export{RadioStyles}from'./components/radio/styles.js';export{SearchField,SearchFieldContext}from'./components/search-field/index.js';export{SearchFieldStyles,SearchFieldStylesDefaults}from'./components/search-field/styles.js';export{SelectField,SelectFieldContext}from'./components/select-field/index.js';export{SelectFieldStyles}from'./components/select-field/styles.js';export{SidenavEventNamespace,SidenavEventTypes}from'./components/sidenav/events.js';export{Sidenav}from'./components/sidenav/index.js';export{SidenavStyles}from'./components/sidenav/styles.js';export{Skeleton}from'./components/skeleton/index.js';export{SkeletonStyles,SkeletonStylesDefaults}from'./components/skeleton/styles.js';export{Slider}from'./components/slider/index.js';export{SliderStyles}from'./components/slider/styles.js';export{Switch,SwitchContext}from'./components/switch/index.js';export{SwitchStyles}from'./components/switch/styles.js';export{Tabs,TabsContext}from'./components/tabs/index.js';export{TabStyles}from'./components/tabs/styles.js';export{TextAreaField,TextAreaFieldContext}from'./components/text-area-field/index.js';export{TextAreaStyles}from'./components/text-area-field/styles.js';export{TextField,TextFieldContext}from'./components/text-field/index.js';export{TextFieldStyles}from'./components/text-field/styles.js';export{Tooltip,TooltipContext}from'./components/tooltip/index.js';export{TooltipStyles}from'./components/tooltip/styles.js';export{Tree,TreeContext,TreeItem,TreeItemContext}from'./components/tree/index.js';export{TreeStyles,TreeStylesDefaults}from'./components/tree/styles.js';export{ViewStackEventNamespace,ViewStackEventTypes}from'./components/view-stack/events.js';export{ViewStack,ViewStackContext,ViewStackEventHandlers}from'./components/view-stack/index.js';export{useTreeActions}from'./hooks/use-tree/actions/index.js';export{useTreeState}from'./hooks/use-tree/state/index.js';export{containsAnyOfExactChildren,containsExactChildren,expectsIconWrapper}from'./lib/react.js';export{cn,isSlottedContextValue,mergeVariants,tv,twMerge}from'./lib/utils.js';export{ThemeProvider,useTheme}from'./providers/theme-provider.js';export{designTokens}from'./tokens/tokens.js';//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -3,16 +3,22 @@ import { ReactNode, JSXElementConstructor } from 'react';
3
3
  type ChildrenTypes = ReactNode | ReactNode[] | ((values: any & {
4
4
  defaultChildren: ReactNode | undefined;
5
5
  }) => ReactNode);
6
+ type Restriction = [
7
+ string | JSXElementConstructor<any>,
8
+ {
9
+ min: number;
10
+ max?: number;
11
+ }
12
+ ];
6
13
  type ContainsExactChildrenProps = {
7
14
  componentName: string;
8
15
  children: ChildrenTypes;
9
- restrictions: [
10
- string | JSXElementConstructor<any>,
11
- {
12
- min: number;
13
- max?: number;
14
- }
15
- ][];
16
+ restrictions: Restriction[];
17
+ };
18
+ type ContainsAnyOfExactChildrenProps = {
19
+ componentName: string;
20
+ children: ChildrenTypes;
21
+ restrictions: Restriction[][];
16
22
  };
17
23
  /**
18
24
  * Validates the intended composite component structure.
@@ -22,6 +28,14 @@ type ContainsExactChildrenProps = {
22
28
  * @param restrictions the record of validation rules
23
29
  */
24
30
  declare function containsExactChildren({ children, componentName, restrictions, }: ContainsExactChildrenProps): void;
31
+ /**
32
+ * Validates the intended composite component structure.
33
+ *
34
+ * @param children the children of the component
35
+ * @param componentName the displayName of the component
36
+ * @param restrictions the record of validation rules
37
+ */
38
+ declare function containsAnyOfExactChildren({ children, componentName, restrictions, }: ContainsAnyOfExactChildrenProps): void;
25
39
  /**
26
40
  * I look for svgIcons exported from the @accelint/icons library
27
41
  * and ensure that they are wrapped in an Icon component in order
@@ -42,4 +56,4 @@ declare function containsExactChildren({ children, componentName, restrictions,
42
56
  */
43
57
  declare function expectsIconWrapper({ children, componentName, }: Omit<ContainsExactChildrenProps, 'restrictions'>): void;
44
58
 
45
- export { containsExactChildren, expectsIconWrapper };
59
+ export { containsAnyOfExactChildren, containsExactChildren, expectsIconWrapper };
package/dist/lib/react.js CHANGED
@@ -1,5 +1,9 @@
1
- import {jsx,Fragment}from'react/jsx-runtime';import {isValidElement,Children,Fragment as Fragment$1}from'react';class m extends Error{constructor(t){super(t),this.name="ComponentStructureError";}}function y(o){const t=Children.toArray(typeof o=="function"?o({state:{},defaultChildren:jsx(Fragment,{})}):o);let i=0;for(;i<t.length;){const e=t[i];e!=null&&typeof e=="object"&&!(e instanceof Promise)&&!(Symbol.iterator in e)&&e.type===Fragment$1&&e.props!=null&&typeof e.props=="object"&&"children"in e.props?t.splice(i,1,...Children.toArray(e.props.children)):i++;}return t}function N({children:o,componentName:t,restrictions:i}){if(process.env.NODE_ENV==="production")return;const e=y(o);if(!e.every(isValidElement))throw new m(`<${t}> received invalid children.`);const f=e.reduce((n,s)=>{const r=s.type?.name??s.type?.displayName??s.type?.render?.name;return r&&(n[r]=(n[r]||0)+1),n},{}),p=[],d=[];for(const[n,{min:s,max:r}]of i){const c=typeof n=="string"?n:n.name??n.displayName??n.render?.name,a=f[c]??0;a<s&&p.push(`${s-a} of <${c}>`),r!==void 0&&a>r&&d.push(`${a-r} of <${c}>`);}if(p.length||d.length){const n=(r,c)=>c.length?` ${r}:
2
- ${c.join(", ")}
3
- `:"",s=`Invalid <${t}> structure
4
- ${n("Missing the following",p)}${n("Excess of the following",d)}`;throw new m(s.trim())}}function x({children:o,componentName:t}){if(process.env.NODE_ENV==="production")return;Children.toArray(o).map(e=>{if(isValidElement(e)&&e.type?.name?.startsWith("Svg"))throw new Error(`${t} is using an icon without the required Icon wrapper`)});}export{N as containsExactChildren,x as expectsIconWrapper};//# sourceMappingURL=react.js.map
1
+ import {jsx,Fragment}from'react/jsx-runtime';import {isValidElement,Children,Fragment as Fragment$1}from'react';class l extends Error{constructor(e){super(e),this.name="ComponentStructureError";}}function u(r){const e=Children.toArray(typeof r=="function"?r({state:{},defaultChildren:jsx(Fragment,{})}):r);let o=0;for(;o<e.length;){const n=e[o];n!=null&&typeof n=="object"&&!(n instanceof Promise)&&!(Symbol.iterator in n)&&n.type===Fragment$1&&n.props!=null&&typeof n.props=="object"&&"children"in n.props?e.splice(o,1,...Children.toArray(n.props.children)):o++;}return e}function m(r,e){const o=r.reduce((t,s)=>{const i=s.type?.name??s.type?.displayName??s.type?.render?.name;return i&&(t[i]=(t[i]||0)+1),t},{}),n=[],c=[];for(const[t,{min:s,max:i}]of e){const p=typeof t=="string"?t:t.name??t.displayName??t.render?.name,a=o[p]??0;a<s&&n.push(`${s-a} of <${p}>`),i!==void 0&&a>i&&c.push(`${a-i} of <${p}>`);}return {missingComponentsArray:n,excessComponentsArray:c}}function x({children:r,componentName:e,restrictions:o}){if(process.env.NODE_ENV==="production")return;const n=u(r);if(!n.every(isValidElement))throw new l(`<${e}> received invalid children.`);const{missingComponentsArray:c,excessComponentsArray:t}=m(n,o);if(c.length||t.length){const s=(p,a)=>a.length?` ${p}:
2
+ ${a.join(", ")}
3
+ `:"",i=`Invalid <${e}> structure
4
+ ${s("Missing the following",c)}${s("Excess of the following",t)}`;throw new l(i.trim())}}function $({children:r,componentName:e,restrictions:o}){if(process.env.NODE_ENV==="production")return;const n=u(r);if(!n.every(isValidElement))throw new l(`<${e}> received invalid children.`);const c=[];for(const t of o){const{missingComponentsArray:s,excessComponentsArray:i}=m(n,t);if(s.length||i.length){const p=(a,f)=>f.length?` ${a}:
5
+ ${f.join(", ")}`:"";c.push(`${p("Missing the following",s)}${p("Excess of the following",i)}`);}}if(c.length===o.length){const t=`Invalid <${e}> structure
6
+ ${c.join(`
7
+ OR
8
+ `)}`;throw new l(t)}}function w({children:r,componentName:e}){if(process.env.NODE_ENV==="production")return;Children.toArray(r).forEach(n=>{if(isValidElement(n)&&n.type?.name?.startsWith("Svg"))throw new Error(`${e} is using an icon without the required Icon wrapper`)});}export{$ as containsAnyOfExactChildren,x as containsExactChildren,w as expectsIconWrapper};//# sourceMappingURL=react.js.map
5
9
  //# sourceMappingURL=react.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/react.tsx"],"names":["ComponentStructureError","message","getChildren","children","childrenArray","Children","jsx","Fragment","index","child","containsExactChildren","componentName","restrictions","childrenComponents","isValidElement","accumulationResults","acc","name","missingComponentsArray","excessComponentsArray","component","min","max","found","formatList","label","items","errorMessage","expectsIconWrapper"],"mappings":"gHAoBA,MAAMA,CAAAA,SAAgC,KAAM,CAC1C,WAAA,CAAYC,CAAAA,CAAiB,CAC3B,KAAA,CAAMA,CAAO,CAAA,CACb,IAAA,CAAK,IAAA,CAAO,0BACd,CACF,CAYA,SAASC,CAAAA,CAAYC,CAAAA,CAAyB,CAC5C,MAAMC,CAAAA,CAAgBC,QAAAA,CAAS,OAAA,CAC7B,OAAOF,CAAAA,EAAa,UAAA,CAChBA,CAAAA,CAAS,CAAE,KAAA,CAAO,EAAC,CAAG,eAAA,CAAiBG,GAAAA,CAAAC,QAAAA,CAAA,EAAE,CAAI,CAAC,CAAA,CAC9CJ,CACN,CAAA,CACA,IAAIK,CAAAA,CAAQ,CAAA,CAEZ,KAAOA,CAAAA,CAAQ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,CAAW,yBAAA,CAA2BL,CAAqB,CAAC,CAAA,CAAA,CAEjE,MAAM,IAAInB,CAAAA,CAAwB2B,CAAAA,CAAa,IAAA,EAAM,CACvD,CACF,CAoBO,SAASC,CAAAA,CAAmB,CACjC,QAAA,CAAAzB,CAAAA,CACA,aAAA,CAAAQ,CACF,CAAA,CAAqD,CACnD,GAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,CAC3B,OAGyBN,QAAAA,CAAS,OAAA,CAClCF,CACF,CAAA,CAEmB,GAAA,CAAKM,CAAAA,EAAU,CAChC,GAAIK,cAAAA,CAAeL,CAAK,CAAA,EAGlBA,CAAAA,CAAM,IAAA,EAAM,IAAA,EAAM,UAAA,CAAW,KAAK,CAAA,CACpC,MAAM,IAAI,KAAA,CACR,CAAA,EAAGE,CAAa,CAAA,mDAAA,CAClB,CAGN,CAAC,EACH","file":"react.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n Children,\n Fragment,\n type JSXElementConstructor,\n type ReactNode,\n isValidElement,\n} from 'react';\n\nclass ComponentStructureError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ComponentStructureError';\n }\n}\n\ntype ChildrenTypes =\n | ReactNode\n | ReactNode[]\n | ((\n // biome-ignore lint/suspicious/noExplicitAny: aria render props include a generic type\n values: any & {\n defaultChildren: ReactNode | undefined;\n },\n ) => ReactNode);\n\nfunction getChildren(children: ChildrenTypes) {\n const childrenArray = Children.toArray(\n typeof children === 'function'\n ? children({ state: {}, defaultChildren: <></> })\n : children,\n );\n let index = 0;\n\n while (index < childrenArray.length) {\n const child = childrenArray[index];\n\n if (\n child != null &&\n typeof child === 'object' &&\n !(child instanceof Promise) &&\n !(Symbol.iterator in child) &&\n child.type === Fragment &&\n child.props != null &&\n typeof child.props === 'object' &&\n 'children' in child.props\n ) {\n childrenArray.splice(\n index,\n 1,\n ...Children.toArray(child.props.children as ReactNode | ReactNode[]),\n );\n } else {\n index++;\n }\n }\n\n return childrenArray;\n}\n\ntype ContainsExactChildrenProps = {\n componentName: string;\n children: ChildrenTypes;\n restrictions: [\n // biome-ignore lint/suspicious/noExplicitAny: allow all props\n string | JSXElementConstructor<any>,\n { min: number; max?: number },\n ][];\n};\n\n/**\n * Validates the intended composite component structure.\n *\n * @param children the children of the component\n * @param componentName the displayName of the component\n * @param restrictions the record of validation rules\n */\nexport function containsExactChildren({\n children,\n componentName,\n restrictions,\n}: ContainsExactChildrenProps) {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n const childrenComponents = getChildren(children);\n\n if (!childrenComponents.every(isValidElement)) {\n throw new ComponentStructureError(\n `<${componentName}> received invalid children.`,\n );\n }\n\n const accumulationResults = childrenComponents.reduce(\n (acc: Record<string, number>, child) => {\n const name =\n // @ts-expect-error Accessing undocumented / untyped properties of React components\n child.type?.name ?? child.type?.displayName ?? child.type?.render?.name;\n\n if (name) {\n acc[name] = (acc[name] || 0) + 1;\n }\n return acc;\n },\n {},\n );\n\n const missingComponentsArray: string[] = [];\n const excessComponentsArray: string[] = [];\n\n for (const [component, { min, max }] of restrictions) {\n const name =\n typeof component === 'string'\n ? component\n : // @ts-expect-error Accessing undocumented / untyped properties of React components\n (component.name ?? component.displayName ?? component.render?.name);\n\n const found = accumulationResults[name] ?? 0;\n\n if (found < min) {\n missingComponentsArray.push(`${min - found} of <${name}>`);\n }\n\n if (max !== undefined && found > max) {\n excessComponentsArray.push(`${found - max} of <${name}>`);\n }\n }\n\n if (missingComponentsArray.length || excessComponentsArray.length) {\n const formatList = (label: string, items: string[]) =>\n items.length ? `\\t${label}:\\n\\t\\t${items.join(', ')}\\n` : '';\n\n const errorMessage =\n `Invalid <${componentName}> structure \\n` +\n `${formatList('Missing the following', missingComponentsArray)}` +\n `${formatList('Excess of the following', excessComponentsArray)}`;\n\n throw new ComponentStructureError(errorMessage.trim());\n }\n}\n\n/**\n * I look for svgIcons exported from the @accelint/icons library\n * and ensure that they are wrapped in an Icon component in order\n * to get the classes and styles they need in context.\n *\n * Using isValidElement means we will filter out strings, boolean, etc.\n * that are valid nodes but not elements.\n *\n * @example\n * expectsIconWrapper({\n * children,\n * componentName: Button.displayName,\n * });\n *\n *\n * @param children the children of the calling component\n * @param componentName the displayName of the calling component\n */\nexport function expectsIconWrapper({\n children,\n componentName,\n}: Omit<ContainsExactChildrenProps, 'restrictions'>) {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n const childrenComponents = Children.toArray(\n children as ReactNode | ReactNode[],\n );\n\n childrenComponents.map((child) => {\n if (isValidElement(child)) {\n // icons should never be a direct child of the parent\n // @ts-expect-error Accessing undocumented / untyped properties of React components\n if (child.type?.name?.startsWith('Svg')) {\n throw new Error(\n `${componentName} is using an icon without the required Icon wrapper`,\n );\n }\n }\n });\n}\n"]}
1
+ {"version":3,"sources":["../../src/lib/react.tsx"],"names":["ComponentStructureError","message","getChildren","children","childrenArray","Children","jsx","Fragment","index","child","validateChildren","childrenComponents","restrictions","accumulationResults","acc","name","missingComponentsArray","excessComponentsArray","component","min","max","found","containsExactChildren","componentName","isValidElement","formatList","label","items","errorMessage","containsAnyOfExactChildren","errorMessages","restriction","expectsIconWrapper"],"mappings":"gHAoBA,MAAMA,CAAAA,SAAgC,KAAM,CAC1C,WAAA,CAAYC,CAAAA,CAAiB,CAC3B,KAAA,CAAMA,CAAO,EACb,IAAA,CAAK,IAAA,CAAO,0BACd,CACF,CAYA,SAASC,CAAAA,CAAYC,CAAAA,CAAyB,CAC5C,MAAMC,CAAAA,CAAgBC,QAAAA,CAAS,OAAA,CA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,CAAA,EAAGL,CAAAA,CAAW,uBAAA,CAAyBT,CAAsB,CAAC,CAAA,EACzDS,CAAAA,CAAW,yBAAA,CAA2BR,CAAqB,CAAC,CAAA,CACnE,EACF,CACF,CAEA,GAAIa,CAAAA,CAAc,MAAA,GAAWlB,CAAAA,CAAa,MAAA,CAAQ,CAChD,MAAMgB,CAAAA,CAAe,YAAYL,CAAa,CAAA;AAAA,CAAA,EAAkBO,EAAc,IAAA,CAAK;AAAA;AAAA,CAAU,CAAC,GAE9F,MAAM,IAAI9B,EAAwB4B,CAAY,CAChD,CACF,CAoBO,SAASI,CAAAA,CAAmB,CACjC,QAAA,CAAA7B,CAAAA,CACA,cAAAoB,CACF,CAAA,CAAqD,CACnD,GAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,CAC3B,OAGyBlB,SAAS,OAAA,CAClCF,CACF,EAEmB,OAAA,CAASM,CAAAA,EAAU,CACpC,GAAIe,cAAAA,CAAef,CAAK,CAAA,EAGlBA,CAAAA,CAAM,IAAA,EAAM,MAAM,UAAA,CAAW,KAAK,CAAA,CACpC,MAAM,IAAI,KAAA,CACR,GAAGc,CAAa,CAAA,mDAAA,CAClB,CAGN,CAAC,EACH","file":"react.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n Children,\n Fragment,\n isValidElement,\n type JSXElementConstructor,\n type ReactNode,\n} from 'react';\n\nclass ComponentStructureError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ComponentStructureError';\n }\n}\n\ntype ChildrenTypes =\n | ReactNode\n | ReactNode[]\n | ((\n // biome-ignore lint/suspicious/noExplicitAny: aria render props include a generic type\n values: any & {\n defaultChildren: ReactNode | undefined;\n },\n ) => ReactNode);\n\nfunction getChildren(children: ChildrenTypes) {\n const childrenArray = Children.toArray(\n typeof children === 'function'\n ? children({ state: {}, defaultChildren: <></> })\n : children,\n );\n let index = 0;\n\n while (index < childrenArray.length) {\n const child = childrenArray[index];\n\n if (\n child != null &&\n typeof child === 'object' &&\n !(child instanceof Promise) &&\n !(Symbol.iterator in child) &&\n child.type === Fragment &&\n child.props != null &&\n typeof child.props === 'object' &&\n 'children' in child.props\n ) {\n childrenArray.splice(\n index,\n 1,\n ...Children.toArray(child.props.children as ReactNode | ReactNode[]),\n );\n } else {\n index++;\n }\n }\n\n return childrenArray;\n}\n\ntype Restriction = [\n // biome-ignore lint/suspicious/noExplicitAny: allow all props\n string | JSXElementConstructor<any>,\n { min: number; max?: number },\n];\n\ntype ContainsExactChildrenProps = {\n componentName: string;\n children: ChildrenTypes;\n restrictions: Restriction[];\n};\n\ntype ContainsAnyOfExactChildrenProps = {\n componentName: string;\n children: ChildrenTypes;\n restrictions: Restriction[][];\n};\n\nfunction validateChildren(\n childrenComponents: ReturnType<typeof getChildren>,\n restrictions: Restriction[],\n) {\n const accumulationResults = childrenComponents.reduce(\n (acc: Record<string, number>, child) => {\n const name =\n // @ts-expect-error Accessing undocumented / untyped properties of React components\n child.type?.name ?? child.type?.displayName ?? child.type?.render?.name;\n\n if (name) {\n acc[name] = (acc[name] || 0) + 1;\n }\n return acc;\n },\n {},\n );\n\n const missingComponentsArray: string[] = [];\n const excessComponentsArray: string[] = [];\n\n for (const [component, { min, max }] of restrictions) {\n const name =\n typeof component === 'string'\n ? component\n : // @ts-expect-error Accessing undocumented / untyped properties of React components\n (component.name ?? component.displayName ?? component.render?.name);\n\n const found = accumulationResults[name] ?? 0;\n\n if (found < min) {\n missingComponentsArray.push(`${min - found} of <${name}>`);\n }\n\n if (max !== undefined && found > max) {\n excessComponentsArray.push(`${found - max} of <${name}>`);\n }\n }\n\n return { missingComponentsArray, excessComponentsArray };\n}\n\n/**\n * Validates the intended composite component structure.\n *\n * @param children the children of the component\n * @param componentName the displayName of the component\n * @param restrictions the record of validation rules\n */\nexport function containsExactChildren({\n children,\n componentName,\n restrictions,\n}: ContainsExactChildrenProps) {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n const childrenComponents = getChildren(children);\n\n if (!childrenComponents.every(isValidElement)) {\n throw new ComponentStructureError(\n `<${componentName}> received invalid children.`,\n );\n }\n\n const { missingComponentsArray, excessComponentsArray } = validateChildren(\n childrenComponents,\n restrictions,\n );\n\n if (missingComponentsArray.length || excessComponentsArray.length) {\n const formatList = (label: string, items: string[]) =>\n items.length ? `\\t${label}:\\n\\t\\t${items.join(', ')}\\n` : '';\n\n const errorMessage =\n `Invalid <${componentName}> structure \\n` +\n `${formatList('Missing the following', missingComponentsArray)}` +\n `${formatList('Excess of the following', excessComponentsArray)}`;\n\n throw new ComponentStructureError(errorMessage.trim());\n }\n}\n\n/**\n * Validates the intended composite component structure.\n *\n * @param children the children of the component\n * @param componentName the displayName of the component\n * @param restrictions the record of validation rules\n */\nexport function containsAnyOfExactChildren({\n children,\n componentName,\n restrictions,\n}: ContainsAnyOfExactChildrenProps) {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n const childrenComponents = getChildren(children);\n\n if (!childrenComponents.every(isValidElement)) {\n throw new ComponentStructureError(\n `<${componentName}> received invalid children.`,\n );\n }\n\n const errorMessages = [];\n\n for (const restriction of restrictions) {\n const { missingComponentsArray, excessComponentsArray } = validateChildren(\n childrenComponents,\n restriction,\n );\n\n if (missingComponentsArray.length || excessComponentsArray.length) {\n const formatList = (label: string, items: string[]) =>\n items.length ? `\\t${label}:\\n\\t\\t${items.join(', ')}` : '';\n\n errorMessages.push(\n `${formatList('Missing the following', missingComponentsArray)}` +\n `${formatList('Excess of the following', excessComponentsArray)}`,\n );\n }\n }\n\n if (errorMessages.length === restrictions.length) {\n const errorMessage = `Invalid <${componentName}> structure \\n ${errorMessages.join('\\n\\tOR\\n')}`;\n\n throw new ComponentStructureError(errorMessage);\n }\n}\n\n/**\n * I look for svgIcons exported from the @accelint/icons library\n * and ensure that they are wrapped in an Icon component in order\n * to get the classes and styles they need in context.\n *\n * Using isValidElement means we will filter out strings, boolean, etc.\n * that are valid nodes but not elements.\n *\n * @example\n * expectsIconWrapper({\n * children,\n * componentName: Button.displayName,\n * });\n *\n *\n * @param children the children of the calling component\n * @param componentName the displayName of the calling component\n */\nexport function expectsIconWrapper({\n children,\n componentName,\n}: Omit<ContainsExactChildrenProps, 'restrictions'>) {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n const childrenComponents = Children.toArray(\n children as ReactNode | ReactNode[],\n );\n\n childrenComponents.forEach((child) => {\n if (isValidElement(child)) {\n // icons should never be a direct child of the parent\n // @ts-expect-error Accessing undocumented / untyped properties of React components\n if (child.type?.name?.startsWith('Svg')) {\n throw new Error(\n `${componentName} is using an icon without the required Icon wrapper`,\n );\n }\n }\n });\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { ClassValue } from 'clsx';
2
- import { ForwardedRef } from 'react';
3
- import { ContextValue } from 'react-aria-components';
4
2
  import { ClassNameValue } from 'tailwind-merge';
5
3
  import { TVVariants, TVCompoundVariants, TVDefaultVariants, TVReturnType, TVCompoundSlots } from 'tailwind-variants';
4
+ import { ForwardedRef } from 'react';
5
+ import { ContextValue } from 'react-aria-components';
6
6
 
7
7
  declare const twMerge: (...classLists: ClassNameValue[]) => string;
8
8
  declare function cn(...inputs: ClassValue[]): string;
package/dist/lib/utils.js CHANGED
@@ -1,2 +1,2 @@
1
- import {clsx}from'clsx';import {validators,extendTailwindMerge}from'tailwind-merge';import {createTV}from'tailwind-variants';const a={classGroups:{icon:[{icon:["",validators.isAny]}],fg:[{fg:["",validators.isAny]}]},conflictingClassGroups:{fg:["icon","text-color"]},theme:{color:["current","surface-default","surface-raised","surface-overlay","transparent-dark","transparent-light","interactive-default","interactive-hover-light","interactive-hover-dark","interactive-disabled","static-light","static-dark","interactive","interactive-hover","highlight-bold","highlight-hover","highlight-subtle","info-bold","info-hover","info-subtle","advisory-bold","advisory-hover","advisory-subtle","normal-bold","normal-hover","normal-subtle","serious-bold","serious-hover","serious-subtle","critical-bold","critical-hover","critical-subtle","default-light","default-dark","inverse-dark","inverse-light","disabled","highlight","info","advisory","normal","serious","critical","classification-missing","classification-unclass","classification-cui","classification-confidential","classification-secret","classification-top-secret"],font:["primary","display"],text:["header-xxl","header-xl","header-l","header-m","header-s","header-xs","body-xl","body-l","body-m","body-s","body-xs","body-xxs","button-xl","button-l","button-m","button-s","button-xs"],radius:["none","small","medium","large","round"],shadow:["elevation-default","elevation-overlay","elevation-raised"],spacing:["none","0","xxs","xs","s","m","l","xl","xxl","oversized"]}},l=extendTailwindMerge({extend:a});function g(...s){return l(clsx(s))}const h=/((?:[^:]*:)+)([^:]+)/;function d(s){if(!s)return "";const e={};for(const t of s.split(" ")){const[,o,n]=h.exec(t)??["","BASE",t];e[o]=e[o]??[],e[o].push(n);}const r=[];for(const t of Object.keys(e))e[t]=l(e[t]).split(" ");for(const t of Object.keys(e))t==="BASE"?r.push(e[t]):r.push(e[t]?.map(o=>`${t}${o}`));return r.flat().join(" ")}const E=createTV({twMergeConfig:a});function T(s){const e=E(s);return Object.assign(t=>{const o=e(t);return typeof o=="string"?d(o):Object.entries(o).reduce((n,[c,u])=>(n[c]=V=>d(u(V)),n),{})},e)}function b(s){return !!s&&"slots"in s}export{g as cn,b as isSlottedContextValue,d as mergeVariants,T as tv,l as twMerge};//# sourceMappingURL=utils.js.map
1
+ import {clsx}from'clsx';import {validators,extendTailwindMerge}from'tailwind-merge';import {createTV}from'tailwind-variants';const a={classGroups:{icon:[{icon:["",validators.isAny]}],fg:[{fg:["",validators.isAny]}]},conflictingClassGroups:{fg:["icon","text-color"]},theme:{color:["current","surface-default","surface-raised","surface-overlay","transparent-dark","transparent-light","interactive-default","interactive-hover-light","interactive-hover-dark","interactive-disabled","static-light","static-dark","interactive","interactive-hover","highlight-bold","highlight-hover","highlight-subtle","info-bold","info-hover","info-subtle","advisory-bold","advisory-hover","advisory-subtle","normal-bold","normal-hover","normal-subtle","serious-bold","serious-hover","serious-subtle","critical-bold","critical-hover","critical-subtle","default-light","default-dark","inverse-dark","inverse-light","disabled","highlight","info","advisory","normal","serious","critical","classification-missing","classification-unclass","classification-cui","classification-confidential","classification-secret","classification-top-secret"],font:["primary","display"],text:["header-xxl","header-xl","header-l","header-m","header-s","header-xs","body-xl","body-l","body-m","body-s","body-xs","body-xxs","button-xl","button-l","button-m","button-s","button-xs"],radius:["none","small","medium","large","round"],shadow:["elevation-default","elevation-overlay","elevation-raised"],spacing:["none","0","xxs","xs","s","m","l","xl","xxl","oversized"]}},l=extendTailwindMerge({extend:a});function g(...s){return l(clsx(s))}const h=/((?:[^:]*:)+)([^:]+)/;function d(s){if(!s)return "";const e={};for(const t of s.split(" ")){const[,o,n]=h.exec(t)??["","BASE",t];e[o]=e[o]??[],e[o].push(n);}const r=[];for(const t of Object.keys(e))e[t]=l(e[t]).split(" ");for(const t of Object.keys(e))t==="BASE"?r.push(e[t]):r.push(e[t]?.map(o=>`${t}${o}`));return r.flat().join(" ")}const E=createTV({twMergeConfig:a});function T(s){const e=E(s);return Object.assign((t=>{const o=e(t);return typeof o=="string"?d(o):Object.entries(o).reduce((n,[c,u])=>(n[c]=V=>d(u(V)),n),{})}),e)}function b(s){return !!s&&"slots"in s}export{g as cn,b as isSlottedContextValue,d as mergeVariants,T as tv,l as twMerge};//# sourceMappingURL=utils.js.map
2
2
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/utils.ts"],"names":["twMergeConfig","validators","twMerge","extendTailwindMerge","cn","inputs","clsx","PREFIX_REGEX","mergeVariants","className","prefixMap","cls","prefix","finalClassNames","key","s","_tv","createTV","tv","options","configuredStateMachine","props","classNamesOrSlots","acc","slot","callback","slotProps","isSlottedContextValue","context"],"mappings":"6HAgCA,MAAMA,EAAgB,CACpB,WAAA,CAAa,CACX,IAAA,CAAM,CAAC,CAAE,IAAA,CAAM,CAAC,EAAA,CAAIC,UAAAA,CAAW,KAAK,CAAE,CAAC,EACvC,EAAA,CAAI,CAAC,CAAE,EAAA,CAAI,CAAC,GAAIA,UAAAA,CAAW,KAAK,CAAE,CAAC,CACrC,EACA,sBAAA,CAAwB,CACtB,EAAA,CAAI,CAAC,OAAQ,YAAY,CAC3B,EACA,KAAA,CAAO,CACL,MAAO,CACL,SAAA,CACA,iBAAA,CACA,gBAAA,CACA,kBACA,kBAAA,CACA,mBAAA,CACA,sBACA,yBAAA,CACA,wBAAA,CACA,uBACA,cAAA,CACA,aAAA,CACA,aAAA,CACA,mBAAA,CACA,iBACA,iBAAA,CACA,kBAAA,CACA,YACA,YAAA,CACA,aAAA,CACA,gBACA,gBAAA,CACA,iBAAA,CACA,cACA,cAAA,CACA,eAAA,CACA,eACA,eAAA,CACA,gBAAA,CACA,gBACA,gBAAA,CACA,iBAAA,CACA,gBACA,cAAA,CACA,cAAA,CACA,eAAA,CACA,UAAA,CACA,YACA,MAAA,CACA,UAAA,CACA,SACA,SAAA,CACA,UAAA,CACA,yBACA,wBAAA,CACA,oBAAA,CACA,6BAAA,CACA,uBAAA,CACA,2BACF,CAAA,CACA,IAAA,CAAM,CAAC,SAAA,CAAW,SAAS,EAC3B,IAAA,CAAM,CACJ,YAAA,CACA,WAAA,CACA,WACA,UAAA,CACA,UAAA,CACA,YACA,SAAA,CACA,QAAA,CACA,SACA,QAAA,CACA,SAAA,CACA,WACA,WAAA,CACA,UAAA,CACA,WACA,UAAA,CACA,WACF,EACA,MAAA,CAAQ,CAAC,OAAQ,OAAA,CAAS,QAAA,CAAU,OAAA,CAAS,OAAO,EACpD,MAAA,CAAQ,CAAC,oBAAqB,mBAAA,CAAqB,kBAAkB,EACrE,OAAA,CAAS,CACP,MAAA,CACA,GAAA,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EAAK,CAAE,KAAK,GAAG,CACxC,CAEA,MAAMG,CAAAA,CAAMC,SAAS,CACnB,aAAA,CAAAjB,CACF,CAAC,EAKM,SAASkB,CAAAA,CAsBdC,EAQmC,CACnC,MAAMC,EAAyBJ,CAAAA,CAAgCG,CAAO,EAwBtE,OAAO,MAAA,CAAO,OAvBgBE,CAAAA,EAAU,CACtC,MAAMC,CAAAA,CAAoBF,CAAAA,CAAuBC,CAAK,CAAA,CAEtD,OAAO,OAAOC,CAAAA,EAAsB,SAChCd,CAAAA,CAAcc,CAAiB,EAC/B,MAAA,CAAO,OAAA,CACLA,CAIF,CAAA,CAAE,MAAA,CACA,CACEC,CAAAA,CACA,CAACC,CAAAA,CAAMC,CAAQ,KAEfF,CAAAA,CAAIC,CAAI,EAAKE,CAAAA,EAAclB,CAAAA,CAAciB,CAAAA,CAASC,CAAS,CAAC,CAAA,CAErDH,CAAAA,CAAAA,CAET,EACF,CACN,EAE0CH,CAAsB,CAClE,CAcO,SAASO,CAAAA,CACdC,EACwC,CACxC,OAAO,CAAC,CAACA,CAAAA,EAAW,UAAWA,CACjC","file":"utils.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type ClassValue, clsx } from 'clsx';\nimport type { ForwardedRef } from 'react';\nimport type { ContextValue } from 'react-aria-components';\nimport {\n type ClassNameValue,\n extendTailwindMerge,\n validators,\n} from 'tailwind-merge';\nimport {\n type TVCompoundSlots,\n type TVCompoundVariants,\n type TVDefaultVariants,\n type TVProps,\n type TVReturnType,\n type TVVariants,\n createTV,\n} from 'tailwind-variants';\n\ntype AdditionalClassGroupIds = 'icon' | 'icon-size' | 'fg';\n\nconst twMergeConfig = {\n classGroups: {\n icon: [{ icon: ['', validators.isAny] }],\n fg: [{ fg: ['', validators.isAny] }],\n },\n conflictingClassGroups: {\n fg: ['icon', 'text-color'],\n },\n theme: {\n color: [\n 'current',\n 'surface-default',\n 'surface-raised',\n 'surface-overlay',\n 'transparent-dark',\n 'transparent-light',\n 'interactive-default',\n 'interactive-hover-light',\n 'interactive-hover-dark',\n 'interactive-disabled',\n 'static-light',\n 'static-dark',\n 'interactive',\n 'interactive-hover',\n 'highlight-bold',\n 'highlight-hover',\n 'highlight-subtle',\n 'info-bold',\n 'info-hover',\n 'info-subtle',\n 'advisory-bold',\n 'advisory-hover',\n 'advisory-subtle',\n 'normal-bold',\n 'normal-hover',\n 'normal-subtle',\n 'serious-bold',\n 'serious-hover',\n 'serious-subtle',\n 'critical-bold',\n 'critical-hover',\n 'critical-subtle',\n 'default-light',\n 'default-dark',\n 'inverse-dark',\n 'inverse-light',\n 'disabled',\n 'highlight',\n 'info',\n 'advisory',\n 'normal',\n 'serious',\n 'critical',\n 'classification-missing',\n 'classification-unclass',\n 'classification-cui',\n 'classification-confidential',\n 'classification-secret',\n 'classification-top-secret',\n ],\n font: ['primary', 'display'],\n text: [\n 'header-xxl',\n 'header-xl',\n 'header-l',\n 'header-m',\n 'header-s',\n 'header-xs',\n 'body-xl',\n 'body-l',\n 'body-m',\n 'body-s',\n 'body-xs',\n 'body-xxs',\n 'button-xl',\n 'button-l',\n 'button-m',\n 'button-s',\n 'button-xs',\n ],\n radius: ['none', 'small', 'medium', 'large', 'round'],\n shadow: ['elevation-default', 'elevation-overlay', 'elevation-raised'],\n spacing: [\n 'none',\n '0',\n 'xxs',\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n 'xxl',\n 'oversized',\n ],\n },\n} as const; // TODO: satisfies ?\n\nexport const twMerge = extendTailwindMerge<AdditionalClassGroupIds>({\n extend: twMergeConfig,\n});\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nconst PREFIX_REGEX = /((?:[^:]*:)+)([^:]+)/;\n\nexport function mergeVariants(className: string) {\n if (!className) {\n return '';\n }\n\n // First build up a map of all prefixes.\n const prefixMap: Record<string, string[]> = {};\n\n for (const cls of className.split(' ')) {\n const [, prefix, className] = PREFIX_REGEX.exec(cls) ?? ['', 'BASE', cls];\n\n prefixMap[prefix] = prefixMap[prefix] ?? [];\n\n prefixMap[prefix].push(className);\n }\n\n const finalClassNames = [];\n\n for (const key of Object.keys(prefixMap)) {\n prefixMap[key] = twMerge(prefixMap[key]).split(' ');\n }\n\n for (const prefix of Object.keys(prefixMap)) {\n if (prefix === 'BASE') {\n finalClassNames.push(prefixMap[prefix]);\n } else {\n finalClassNames.push(prefixMap[prefix]?.map((s) => `${prefix}${s}`));\n }\n }\n\n return finalClassNames.flat().join(' ');\n}\n\nconst _tv = createTV({\n twMergeConfig,\n});\n\n// Copied from Tailwind Variants due to not being exported\ntype TVSlots = Record<string, ClassNameValue> | undefined;\n\nexport function tv<\n V extends TVVariants<S, B, EV>,\n // biome-ignore lint/style/useNamingConvention: Keeping consistent with OG implementation within TV\n CV extends TVCompoundVariants<V, S, B, EV, ES>,\n // biome-ignore lint/style/useNamingConvention: Keeping consistent with OG implementation within TV\n DV extends TVDefaultVariants<V, S, EV, ES>,\n B extends ClassNameValue = undefined,\n S extends TVSlots = undefined,\n // @ts-expect-error\n E extends TVReturnType = TVReturnType<\n V,\n S,\n B,\n // @ts-expect-error Keeping consistent with OG implementation within TV\n EV extends undefined ? object : EV,\n // @ts-expect-error Keeping consistent with OG implementation within TV\n ES extends undefined ? object : ES\n >,\n // biome-ignore lint/style/useNamingConvention: Keeping consistent with OG implementation within TV\n EV extends TVVariants<ES, B, E['variants'], ES> = E['variants'],\n // biome-ignore lint/style/useNamingConvention: Keeping consistent with OG implementation within TV\n ES extends TVSlots = E['slots'] extends TVSlots ? E['slots'] : undefined,\n>(options: {\n extend?: E;\n base?: B;\n slots?: S;\n variants?: V;\n compoundVariants?: CV;\n compoundSlots?: TVCompoundSlots<V, S, B>;\n defaultVariants?: DV;\n}): TVReturnType<V, S, B, EV, ES, E> {\n const configuredStateMachine = _tv<V, CV, DV, B, S, E, EV, ES>(options);\n const wrappedStateMachine = ((props) => {\n const classNamesOrSlots = configuredStateMachine(props);\n\n return typeof classNamesOrSlots === 'string'\n ? mergeVariants(classNamesOrSlots)\n : Object.entries(\n classNamesOrSlots as Record<\n string,\n (slotProps?: TVProps<V, S, EV, ES>) => string\n >,\n ).reduce(\n (\n acc: Record<string, (slotProps?: TVProps<V, S, EV, ES>) => string>,\n [slot, callback],\n ) => {\n acc[slot] = (slotProps) => mergeVariants(callback(slotProps));\n\n return acc;\n },\n {},\n );\n }) as TVReturnType<V, S, B, EV, ES, E>;\n\n return Object.assign(wrappedStateMachine, configuredStateMachine);\n}\n\n// Types copied from RAC due to not being exported\ntype WithRef<T, E> = T & {\n ref?: ForwardedRef<E>;\n};\n\ninterface SlottedValue<T> {\n slots?: Record<string | symbol, T>;\n}\n\n/**\n * A helper to narrow the type of Context Value\n */\nexport function isSlottedContextValue<T, E>(\n context: ContextValue<T, E>,\n): context is SlottedValue<WithRef<T, E>> {\n return !!context && 'slots' in context;\n}\n"]}
1
+ {"version":3,"sources":["../../src/lib/utils.ts"],"names":["twMergeConfig","validators","twMerge","extendTailwindMerge","cn","inputs","clsx","PREFIX_REGEX","mergeVariants","className","prefixMap","cls","prefix","finalClassNames","key","s","_tv","createTV","tv","options","configuredStateMachine","props","classNamesOrSlots","acc","slot","callback","slotProps","isSlottedContextValue","context"],"mappings":"6HAgCA,MAAMA,EAAgB,CACpB,WAAA,CAAa,CACX,IAAA,CAAM,CAAC,CAAE,IAAA,CAAM,CAAC,EAAA,CAAIC,UAAAA,CAAW,KAAK,CAAE,CAAC,EACvC,EAAA,CAAI,CAAC,CAAE,EAAA,CAAI,CAAC,GAAIA,UAAA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MC,CAAAA,CAAoBF,CAAAA,CAAuBC,CAAK,CAAA,CAEtD,OAAO,OAAOC,CAAAA,EAAsB,SAChCd,CAAAA,CAAcc,CAAiB,EAC/B,MAAA,CAAO,OAAA,CACLA,CAIF,CAAA,CAAE,MAAA,CACA,CACEC,CAAAA,CACA,CAACC,CAAAA,CAAMC,CAAQ,KAEfF,CAAAA,CAAIC,CAAI,EAAKE,CAAAA,EAAclB,CAAAA,CAAciB,CAAAA,CAASC,CAAS,CAAC,CAAA,CAErDH,CAAAA,CAAAA,CAET,EACF,CACN,GAE0CH,CAAsB,CAClE,CAcO,SAASO,CAAAA,CACdC,EACwC,CACxC,OAAO,CAAC,CAACA,CAAAA,EAAW,UAAWA,CACjC","file":"utils.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type ClassValue, clsx } from 'clsx';\nimport {\n type ClassNameValue,\n extendTailwindMerge,\n validators,\n} from 'tailwind-merge';\nimport {\n createTV,\n type TVCompoundSlots,\n type TVCompoundVariants,\n type TVDefaultVariants,\n type TVProps,\n type TVReturnType,\n type TVVariants,\n} from 'tailwind-variants';\nimport type { ForwardedRef } from 'react';\nimport type { ContextValue } from 'react-aria-components';\n\ntype AdditionalClassGroupIds = 'icon' | 'icon-size' | 'fg';\n\nconst twMergeConfig = {\n classGroups: {\n icon: [{ icon: ['', validators.isAny] }],\n fg: [{ fg: ['', validators.isAny] }],\n },\n conflictingClassGroups: {\n fg: ['icon', 'text-color'],\n },\n theme: {\n color: [\n 'current',\n 'surface-default',\n 'surface-raised',\n 'surface-overlay',\n 'transparent-dark',\n 'transparent-light',\n 'interactive-default',\n 'interactive-hover-light',\n 'interactive-hover-dark',\n 'interactive-disabled',\n 'static-light',\n 'static-dark',\n 'interactive',\n 'interactive-hover',\n 'highlight-bold',\n 'highlight-hover',\n 'highlight-subtle',\n 'info-bold',\n 'info-hover',\n 'info-subtle',\n 'advisory-bold',\n 'advisory-hover',\n 'advisory-subtle',\n 'normal-bold',\n 'normal-hover',\n 'normal-subtle',\n 'serious-bold',\n 'serious-hover',\n 'serious-subtle',\n 'critical-bold',\n 'critical-hover',\n 'critical-subtle',\n 'default-light',\n 'default-dark',\n 'inverse-dark',\n 'inverse-light',\n 'disabled',\n 'highlight',\n 'info',\n 'advisory',\n 'normal',\n 'serious',\n 'critical',\n 'classification-missing',\n 'classification-unclass',\n 'classification-cui',\n 'classification-confidential',\n 'classification-secret',\n 'classification-top-secret',\n ],\n font: ['primary', 'display'],\n text: [\n 'header-xxl',\n 'header-xl',\n 'header-l',\n 'header-m',\n 'header-s',\n 'header-xs',\n 'body-xl',\n 'body-l',\n 'body-m',\n 'body-s',\n 'body-xs',\n 'body-xxs',\n 'button-xl',\n 'button-l',\n 'button-m',\n 'button-s',\n 'button-xs',\n ],\n radius: ['none', 'small', 'medium', 'large', 'round'],\n shadow: ['elevation-default', 'elevation-overlay', 'elevation-raised'],\n spacing: [\n 'none',\n '0',\n 'xxs',\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n 'xxl',\n 'oversized',\n ],\n },\n} as const; // TODO: satisfies ?\n\nexport const twMerge = extendTailwindMerge<AdditionalClassGroupIds>({\n extend: twMergeConfig,\n});\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nconst PREFIX_REGEX = /((?:[^:]*:)+)([^:]+)/;\n\nexport function mergeVariants(className: string) {\n if (!className) {\n return '';\n }\n\n // First build up a map of all prefixes.\n const prefixMap: Record<string, string[]> = {};\n\n for (const cls of className.split(' ')) {\n const [, prefix, className] = PREFIX_REGEX.exec(cls) ?? ['', 'BASE', cls];\n\n prefixMap[prefix] = prefixMap[prefix] ?? [];\n\n prefixMap[prefix].push(className);\n }\n\n const finalClassNames = [];\n\n for (const key of Object.keys(prefixMap)) {\n prefixMap[key] = twMerge(prefixMap[key]).split(' ');\n }\n\n for (const prefix of Object.keys(prefixMap)) {\n if (prefix === 'BASE') {\n finalClassNames.push(prefixMap[prefix]);\n } else {\n finalClassNames.push(prefixMap[prefix]?.map((s) => `${prefix}${s}`));\n }\n }\n\n return finalClassNames.flat().join(' ');\n}\n\nconst _tv = createTV({\n twMergeConfig,\n});\n\n// Copied from Tailwind Variants due to not being exported\ntype TVSlots = Record<string, ClassNameValue> | undefined;\n\nexport function tv<\n V extends TVVariants<S, B, EV>,\n // biome-ignore lint/style/useNamingConvention: Keeping consistent with OG implementation within TV\n CV extends TVCompoundVariants<V, S, B, EV, ES>,\n // biome-ignore lint/style/useNamingConvention: Keeping consistent with OG implementation within TV\n DV extends TVDefaultVariants<V, S, EV, ES>,\n B extends ClassNameValue = undefined,\n S extends TVSlots = undefined,\n // @ts-expect-error\n E extends TVReturnType = TVReturnType<\n V,\n S,\n B,\n // @ts-expect-error Keeping consistent with OG implementation within TV\n EV extends undefined ? object : EV,\n // @ts-expect-error Keeping consistent with OG implementation within TV\n ES extends undefined ? object : ES\n >,\n // biome-ignore lint/style/useNamingConvention: Keeping consistent with OG implementation within TV\n EV extends TVVariants<ES, B, E['variants'], ES> = E['variants'],\n // biome-ignore lint/style/useNamingConvention: Keeping consistent with OG implementation within TV\n ES extends TVSlots = E['slots'] extends TVSlots ? E['slots'] : undefined,\n>(options: {\n extend?: E;\n base?: B;\n slots?: S;\n variants?: V;\n compoundVariants?: CV;\n compoundSlots?: TVCompoundSlots<V, S, B>;\n defaultVariants?: DV;\n}): TVReturnType<V, S, B, EV, ES, E> {\n const configuredStateMachine = _tv<V, CV, DV, B, S, E, EV, ES>(options);\n const wrappedStateMachine = ((props) => {\n const classNamesOrSlots = configuredStateMachine(props);\n\n return typeof classNamesOrSlots === 'string'\n ? mergeVariants(classNamesOrSlots)\n : Object.entries(\n classNamesOrSlots as Record<\n string,\n (slotProps?: TVProps<V, S, EV, ES>) => string\n >,\n ).reduce(\n (\n acc: Record<string, (slotProps?: TVProps<V, S, EV, ES>) => string>,\n [slot, callback],\n ) => {\n acc[slot] = (slotProps) => mergeVariants(callback(slotProps));\n\n return acc;\n },\n {},\n );\n }) as TVReturnType<V, S, B, EV, ES, E>;\n\n return Object.assign(wrappedStateMachine, configuredStateMachine);\n}\n\n// Types copied from RAC due to not being exported\ntype WithRef<T, E> = T & {\n ref?: ForwardedRef<E>;\n};\n\ninterface SlottedValue<T> {\n slots?: Record<string | symbol, T>;\n}\n\n/**\n * A helper to narrow the type of Context Value\n */\nexport function isSlottedContextValue<T, E>(\n context: ContextValue<T, E>,\n): context is SlottedValue<WithRef<T, E>> {\n return !!context && 'slots' in context;\n}\n"]}