@accelint/design-toolkit 3.0.0 → 5.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.
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/accordion/index.js.map +1 -1
- package/dist/components/accordion/styles.d.ts +1 -1
- package/dist/components/accordion/styles.js +1 -1
- package/dist/components/accordion/styles.js.map +1 -1
- package/dist/components/accordion/types.d.ts +1 -1
- package/dist/components/action-bar/index.d.ts +10 -0
- package/dist/components/action-bar/index.js +2 -0
- package/dist/components/action-bar/index.js.map +1 -0
- package/dist/components/action-bar/styles.d.ts +5 -0
- package/dist/components/action-bar/styles.js +2 -0
- package/dist/components/action-bar/styles.js.map +1 -0
- package/dist/components/action-bar/types.d.ts +5 -0
- package/dist/components/action-bar/types.js +2 -0
- package/dist/components/action-bar/types.js.map +1 -0
- package/dist/components/avatar/index.d.ts +1 -1
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/avatar/styles.d.ts +1 -1
- package/dist/components/avatar/styles.js +1 -1
- package/dist/components/avatar/styles.js.map +1 -1
- package/dist/components/avatar/types.d.ts +1 -1
- package/dist/components/badge/index.d.ts +1 -1
- package/dist/components/badge/index.js.map +1 -1
- package/dist/components/badge/styles.d.ts +1 -1
- package/dist/components/badge/styles.js +1 -1
- package/dist/components/badge/styles.js.map +1 -1
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button/styles.d.ts +3 -3
- package/dist/components/button/styles.js +1 -1
- package/dist/components/button/styles.js.map +1 -1
- package/dist/components/button/types.d.ts +1 -1
- package/dist/components/checkbox/styles.d.ts +1 -1
- package/dist/components/checkbox/styles.js +1 -1
- package/dist/components/checkbox/styles.js.map +1 -1
- package/dist/components/chip/index.d.ts +1 -1
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip/styles.d.ts +4 -4
- package/dist/components/chip/styles.js +1 -1
- package/dist/components/chip/styles.js.map +1 -1
- package/dist/components/classification-badge/index.d.ts +1 -1
- package/dist/components/classification-badge/index.js.map +1 -1
- package/dist/components/classification-badge/styles.js +1 -1
- package/dist/components/classification-badge/styles.js.map +1 -1
- package/dist/components/classification-banner/index.d.ts +1 -1
- package/dist/components/classification-banner/index.js.map +1 -1
- package/dist/components/classification-banner/styles.js +1 -1
- package/dist/components/classification-banner/styles.js.map +1 -1
- package/dist/components/color-picker/styles.d.ts +1 -1
- package/dist/components/color-picker/styles.js +1 -1
- package/dist/components/color-picker/styles.js.map +1 -1
- package/dist/components/combobox-field/index.d.ts +1 -1
- package/dist/components/combobox-field/index.js.map +1 -1
- package/dist/components/combobox-field/styles.d.ts +3 -3
- package/dist/components/combobox-field/styles.js +1 -1
- package/dist/components/combobox-field/styles.js.map +1 -1
- package/dist/components/combobox-field/types.d.ts +1 -1
- package/dist/components/date-field/index.d.ts +1 -3
- package/dist/components/date-field/index.js +1 -1
- package/dist/components/date-field/index.js.map +1 -1
- package/dist/components/date-field/styles.d.ts +41 -51
- package/dist/components/date-field/styles.js +1 -1
- package/dist/components/date-field/styles.js.map +1 -1
- package/dist/components/date-field/types.d.ts +12 -15
- package/dist/components/details-list/index.d.ts +1 -1
- package/dist/components/details-list/index.js +1 -1
- package/dist/components/details-list/index.js.map +1 -1
- package/dist/components/details-list/styles.d.ts +1 -1
- package/dist/components/details-list/styles.js +1 -1
- package/dist/components/details-list/styles.js.map +1 -1
- package/dist/components/dialog/index.d.ts +28 -38
- package/dist/components/dialog/index.js +1 -1
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/dialog/styles.d.ts +60 -0
- package/dist/components/dialog/styles.js +2 -0
- package/dist/components/dialog/styles.js.map +1 -0
- package/dist/components/dialog/types.d.ts +14 -0
- package/dist/components/dialog/types.js +2 -0
- package/dist/components/dialog/types.js.map +1 -0
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/index.js +1 -1
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/drawer/styles.d.ts +2 -2
- package/dist/components/drawer/styles.js +1 -1
- package/dist/components/drawer/styles.js.map +1 -1
- package/dist/components/drawer/types.d.ts +1 -1
- package/dist/components/hero/index.js +1 -1
- package/dist/components/hero/index.js.map +1 -1
- package/dist/components/hero/styles.d.ts +1 -1
- package/dist/components/hero/styles.js +1 -1
- package/dist/components/hero/styles.js.map +1 -1
- package/dist/components/hotkey/index.d.ts +1 -1
- package/dist/components/hotkey/index.js.map +1 -1
- package/dist/components/hotkey/styles.d.ts +1 -1
- package/dist/components/hotkey/styles.js +1 -1
- package/dist/components/hotkey/styles.js.map +1 -1
- package/dist/components/icon/index.d.ts +1 -1
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/icon/styles.d.ts +1 -1
- package/dist/components/input/index.d.ts +1 -1
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/styles.d.ts +1 -1
- package/dist/components/input/styles.js +1 -1
- package/dist/components/input/styles.js.map +1 -1
- package/dist/components/label/index.d.ts +1 -1
- package/dist/components/label/index.js.map +1 -1
- package/dist/components/label/styles.d.ts +1 -1
- package/dist/components/label/styles.js +1 -1
- package/dist/components/label/styles.js.map +1 -1
- package/dist/components/lines/index.d.ts +9 -0
- package/dist/components/lines/index.js +2 -0
- package/dist/components/lines/index.js.map +1 -0
- package/dist/components/lines/styles.d.ts +32 -0
- package/dist/components/lines/styles.js +2 -0
- package/dist/components/lines/styles.js.map +1 -0
- package/dist/components/lines/types.d.ts +10 -0
- package/dist/components/lines/types.js +2 -0
- package/dist/components/lines/types.js.map +1 -0
- package/dist/components/link/index.d.ts +17 -0
- package/dist/components/link/index.js +2 -0
- package/dist/components/link/index.js.map +1 -0
- package/dist/components/link/styles.d.ts +5 -0
- package/dist/components/link/styles.js +2 -0
- package/dist/components/link/styles.js.map +1 -0
- package/dist/components/link/types.d.ts +9 -0
- package/dist/components/link/types.js +2 -0
- package/dist/components/link/types.js.map +1 -0
- package/dist/components/menu/index.js +1 -1
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/menu/styles.d.ts +1 -1
- package/dist/components/menu/styles.js +1 -1
- package/dist/components/menu/styles.js.map +1 -1
- package/dist/components/options/index.js.map +1 -1
- package/dist/components/options/styles.d.ts +3 -3
- package/dist/components/options/styles.js +1 -1
- package/dist/components/options/styles.js.map +1 -1
- package/dist/components/options/types.d.ts +1 -1
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/popover/styles.d.ts +1 -1
- package/dist/components/popover/styles.js +1 -1
- package/dist/components/popover/styles.js.map +1 -1
- package/dist/components/query-builder/action-element.js.map +1 -1
- package/dist/components/query-builder/group.js +1 -1
- package/dist/components/query-builder/group.js.map +1 -1
- package/dist/components/query-builder/index.js +1 -1
- package/dist/components/query-builder/index.js.map +1 -1
- package/dist/components/query-builder/value-editor.js.map +1 -1
- package/dist/components/query-builder/value-selector.js.map +1 -1
- package/dist/components/radio/styles.d.ts +1 -1
- package/dist/components/radio/styles.js +1 -1
- package/dist/components/radio/styles.js.map +1 -1
- package/dist/components/search-field/index.d.ts +3 -3
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/search-field/styles.d.ts +1 -1
- package/dist/components/search-field/styles.js +1 -1
- package/dist/components/search-field/styles.js.map +1 -1
- package/dist/components/select-field/index.d.ts +1 -1
- package/dist/components/select-field/index.js +1 -1
- package/dist/components/select-field/index.js.map +1 -1
- package/dist/components/select-field/styles.d.ts +4 -4
- package/dist/components/select-field/styles.js +1 -1
- package/dist/components/select-field/styles.js.map +1 -1
- package/dist/components/select-field/types.d.ts +1 -1
- package/dist/components/sidenav/events.d.ts +8 -0
- package/dist/components/sidenav/events.js +2 -0
- package/dist/components/sidenav/events.js.map +1 -0
- package/dist/components/sidenav/index.d.ts +51 -0
- package/dist/components/sidenav/index.js +2 -0
- package/dist/components/sidenav/index.js.map +1 -0
- package/dist/components/sidenav/styles.d.ts +114 -0
- package/dist/components/sidenav/styles.js +2 -0
- package/dist/components/sidenav/styles.js.map +1 -0
- package/dist/components/sidenav/types.d.ts +38 -0
- package/dist/components/sidenav/types.js +2 -0
- package/dist/components/sidenav/types.js.map +1 -0
- package/dist/components/skeleton/styles.d.ts +2 -2
- package/dist/components/skeleton/styles.js +1 -1
- package/dist/components/skeleton/styles.js.map +1 -1
- package/dist/components/slider/index.d.ts +4 -43
- package/dist/components/slider/index.js +1 -1
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/styles.d.ts +84 -0
- package/dist/components/slider/styles.js +2 -0
- package/dist/components/slider/styles.js.map +1 -0
- package/dist/components/slider/types.d.ts +22 -0
- package/dist/components/slider/types.js +2 -0
- package/dist/components/slider/types.js.map +1 -0
- package/dist/components/switch/index.d.ts +1 -1
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/styles.d.ts +1 -1
- package/dist/components/switch/styles.js +1 -1
- package/dist/components/switch/styles.js.map +1 -1
- package/dist/components/tabs/index.d.ts +37 -36
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/tabs/styles.d.ts +48 -0
- package/dist/components/tabs/styles.js +2 -0
- package/dist/components/tabs/styles.js.map +1 -0
- package/dist/components/tabs/types.d.ts +6 -0
- package/dist/components/tabs/types.js +2 -0
- package/dist/components/tabs/types.js.map +1 -0
- package/dist/components/text-area-field/index.d.ts +1 -1
- package/dist/components/text-area-field/index.js.map +1 -1
- package/dist/components/text-area-field/styles.d.ts +4 -4
- package/dist/components/text-area-field/styles.js +1 -1
- package/dist/components/text-area-field/styles.js.map +1 -1
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/text-field/styles.d.ts +4 -4
- package/dist/components/text-field/styles.js +1 -1
- package/dist/components/text-field/styles.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tooltip/styles.d.ts +1 -1
- package/dist/components/tooltip/styles.js +1 -1
- package/dist/components/tooltip/styles.js.map +1 -1
- package/dist/components/tooltip/types.d.ts +3 -1
- package/dist/components/tree/index.d.ts +51 -0
- package/dist/components/tree/index.js +2 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/components/tree/styles.d.ts +128 -0
- package/dist/components/tree/styles.js +2 -0
- package/dist/components/tree/styles.js.map +1 -0
- package/dist/components/tree/types.d.ts +41 -0
- package/dist/components/tree/types.js +2 -0
- package/dist/components/tree/types.js.map +1 -0
- package/dist/components/view-stack/index.js.map +1 -1
- package/dist/foundation/token-data.d.ts +17 -0
- package/dist/foundation/token-data.js +2 -0
- package/dist/foundation/token-data.js.map +1 -0
- package/dist/hooks/use-tree/actions/cache.d.ts +78 -0
- package/dist/hooks/use-tree/actions/cache.js +2 -0
- package/dist/hooks/use-tree/actions/cache.js.map +1 -0
- package/dist/hooks/use-tree/actions/index.d.ts +38 -0
- package/dist/hooks/use-tree/actions/index.js +2 -0
- package/dist/hooks/use-tree/actions/index.js.map +1 -0
- package/dist/hooks/use-tree/state/index.d.ts +8 -0
- package/dist/hooks/use-tree/state/index.js +2 -0
- package/dist/hooks/use-tree/state/index.js.map +1 -0
- package/dist/hooks/use-tree/state/utils.d.ts +7 -0
- package/dist/hooks/use-tree/state/utils.js +2 -0
- package/dist/hooks/use-tree/state/utils.js.map +1 -0
- package/dist/hooks/use-tree/types.d.ts +171 -0
- package/dist/hooks/use-tree/types.js +2 -0
- package/dist/hooks/use-tree/types.js.map +1 -0
- package/dist/icons/catalog.js +1 -1
- package/dist/icons/catalog.js.map +1 -1
- package/dist/index.css +12 -18
- package/dist/index.d.ts +35 -8
- package/dist/index.js +1 -1
- package/dist/lib/react.d.ts +22 -8
- package/dist/lib/react.js +8 -4
- package/dist/lib/react.js.map +1 -1
- package/dist/lib/utils.d.ts +15 -5
- package/dist/lib/utils.js +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/providers/theme-provider.d.ts +22 -0
- package/dist/providers/theme-provider.js +2 -0
- package/dist/providers/theme-provider.js.map +1 -0
- package/dist/styles.css +2071 -1007
- package/dist/tokens/themes.css +741 -53
- package/dist/tokens/tokens.css +133 -65
- package/dist/tokens/tokens.d.ts +449 -1
- package/dist/tokens/tokens.js +2 -0
- package/dist/tokens/tokens.js.map +1 -0
- package/dist/tokens/types.d.ts +299 -0
- package/dist/tokens/types.js +2 -0
- package/dist/tokens/types.js.map +1 -0
- package/dist/variants/variants.css +19 -1
- package/package.json +20 -9
- package/dist/tokens/index.d.ts +0 -123
- package/dist/tokens/index.js +0 -2
- 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
|
}
|
|
@@ -182,17 +176,17 @@ body {
|
|
|
182
176
|
/*
|
|
183
177
|
* Scrollbars
|
|
184
178
|
*/
|
|
185
|
-
|
|
179
|
+
::-webkit-scrollbar {
|
|
186
180
|
width: var(--spacing-l);
|
|
187
181
|
height: var(--spacing-l);
|
|
188
182
|
}
|
|
189
183
|
|
|
190
|
-
|
|
191
|
-
background: var(--
|
|
184
|
+
::-webkit-scrollbar-track {
|
|
185
|
+
background: var(--bg-interactive-muted-hover);
|
|
192
186
|
}
|
|
193
187
|
|
|
194
|
-
|
|
195
|
-
background-color: var(--
|
|
188
|
+
::-webkit-scrollbar-thumb{
|
|
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(--
|
|
214
|
-
repeating-linear-gradient(to right, var(--
|
|
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(--
|
|
229
|
-
repeating-linear-gradient(to right, var(--
|
|
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(--
|
|
244
|
-
repeating-linear-gradient(to right, var(--
|
|
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';
|
|
@@ -29,12 +32,14 @@ export { ComboBoxField, ComboBoxFieldContext } from './components/combobox-field
|
|
|
29
32
|
export { ComboBoxStyles } from './components/combobox-field/styles.js';
|
|
30
33
|
export { ComboBoxFieldProps } from './components/combobox-field/types.js';
|
|
31
34
|
export { DateField } from './components/date-field/index.js';
|
|
32
|
-
export { DateFieldStyles,
|
|
33
|
-
export { DateFieldProps
|
|
35
|
+
export { DateFieldStyles, DateFieldStylesDefaults } from './components/date-field/styles.js';
|
|
36
|
+
export { DateFieldProps } from './components/date-field/types.js';
|
|
34
37
|
export { DetailsList, DetailsListContext } from './components/details-list/index.js';
|
|
35
38
|
export { DetailsListStyles, DetailsListStylesDefaults } from './components/details-list/styles.js';
|
|
36
39
|
export { DetailsListLabelProps, DetailsListProps, DetailsListValueProps } from './components/details-list/types.js';
|
|
37
|
-
export { Dialog,
|
|
40
|
+
export { Dialog, DialogContext } from './components/dialog/index.js';
|
|
41
|
+
export { DialogStyles } from './components/dialog/styles.js';
|
|
42
|
+
export { DialogProps } from './components/dialog/types.js';
|
|
38
43
|
export { DrawerEventNamespace, DrawerEventTypes } from './components/drawer/events.js';
|
|
39
44
|
export { Drawer, DrawerContext, DrawerEventHandlers } from './components/drawer/index.js';
|
|
40
45
|
export { DrawerMenuStyles, DrawerMenuStylesDefaults, DrawerStyles, DrawerTitleStyles, DrawerTitleStylesDefaults } from './components/drawer/styles.js';
|
|
@@ -54,6 +59,12 @@ export { InputProps } from './components/input/types.js';
|
|
|
54
59
|
export { Label, LabelContext } from './components/label/index.js';
|
|
55
60
|
export { LabelStyles } from './components/label/styles.js';
|
|
56
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';
|
|
57
68
|
export { Menu, MenuContext } from './components/menu/index.js';
|
|
58
69
|
export { MenuStyles, MenuStylesDefaults } from './components/menu/styles.js';
|
|
59
70
|
export { MenuItemProps, MenuProps, MenuSectionProps } from './components/menu/types.js';
|
|
@@ -74,14 +85,22 @@ export { SearchFieldProps, SearchFieldStyleVariants } from './components/search-
|
|
|
74
85
|
export { SelectField, SelectFieldContext } from './components/select-field/index.js';
|
|
75
86
|
export { SelectFieldStyles } from './components/select-field/styles.js';
|
|
76
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, SidenavContentProps, SidenavContextValue, SidenavDividerProps, SidenavFooterProps, SidenavHeaderProps, SidenavItemProps, SidenavLinkProps, SidenavProps, SidenavTriggerProps } from './components/sidenav/types.js';
|
|
77
92
|
export { Skeleton } from './components/skeleton/index.js';
|
|
78
93
|
export { SkeletonStyles, SkeletonStylesDefaults } from './components/skeleton/styles.js';
|
|
79
94
|
export { SkeletonProps, SkeletonStyleVariants } from './components/skeleton/types.js';
|
|
80
|
-
export {
|
|
95
|
+
export { Slider } from './components/slider/index.js';
|
|
96
|
+
export { SliderStyles } from './components/slider/styles.js';
|
|
97
|
+
export { SliderProps } from './components/slider/types.js';
|
|
81
98
|
export { Switch, SwitchContext } from './components/switch/index.js';
|
|
82
99
|
export { SwitchStyles } from './components/switch/styles.js';
|
|
83
100
|
export { SwitchProps } from './components/switch/types.js';
|
|
84
|
-
export {
|
|
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';
|
|
85
104
|
export { TextAreaField, TextAreaFieldContext } from './components/text-area-field/index.js';
|
|
86
105
|
export { TextAreaStyles } from './components/text-area-field/styles.js';
|
|
87
106
|
export { TextAreaFieldProps } from './components/text-area-field/types.js';
|
|
@@ -91,13 +110,21 @@ export { TextFieldProps } from './components/text-field/types.js';
|
|
|
91
110
|
export { Tooltip, TooltipContext } from './components/tooltip/index.js';
|
|
92
111
|
export { TooltipStyles } from './components/tooltip/styles.js';
|
|
93
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';
|
|
94
116
|
export { ViewStackEventNamespace, ViewStackEventTypes } from './components/view-stack/events.js';
|
|
95
117
|
export { ViewStack, ViewStackContext, ViewStackEventHandlers } from './components/view-stack/index.js';
|
|
96
118
|
export { ViewStackBackEvent, ViewStackClearEvent, ViewStackContextValue, ViewStackEvent, ViewStackProps, ViewStackPushEvent, ViewStackResetEvent, ViewStackTriggerProps, ViewStackViewProps } from './components/view-stack/types.js';
|
|
97
|
-
export {
|
|
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';
|
|
98
123
|
export { AriaAttributes, AriaAttributesWithRef, ChildrenRenderProps, ClassNameRenderProps, ProviderProps, RenderProps, RenderPropsChildren, RenderPropsClassName, RenderPropsStyle, SlottedValue, StylePropRenderProps, StyleRenderProps } from './lib/types.js';
|
|
99
|
-
export { cn, isSlottedContextValue, tv, twMerge } from './lib/utils.js';
|
|
100
|
-
export {
|
|
124
|
+
export { cn, isSlottedContextValue, mergeVariants, tv, twMerge } from './lib/utils.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';
|
|
101
128
|
import 'react/jsx-runtime';
|
|
102
129
|
import 'react';
|
|
103
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,
|
|
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
|
package/dist/lib/react.d.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
2
|
-
${
|
|
3
|
-
`:"",
|
|
4
|
-
${
|
|
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
|
package/dist/lib/react.js.map
CHANGED
|
@@ -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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AAAA,CAAM,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA,CAAO,EAAA,CAEtDC,CAAAA,CACJ,CAAA,SAAA,EAAYhB,CAAa,CAAA;AAAA,EACtBa,CAAAA,CAAW,uBAAA,CAAyBN,CAAsB,CAAC,CAAA,EAC3DM,CAAAA,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,KA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AAMQ,EAAa,CAACC,CAAAA,CAAeC,IACjCA,CAAAA,CAAM,MAAA,CAAS,IAAKD,CAAK,CAAA;AAAA,EAAA,EAAUC,CAAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,CAAK,EAAA,CAE1DG,CAAAA,CAAc,IAAA,CACZ,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"]}
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
-
import * as tailwind_merge from 'tailwind-merge';
|
|
3
1
|
import { ClassValue } from 'clsx';
|
|
2
|
+
import { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
import { TVVariants, TVCompoundVariants, TVDefaultVariants, TVReturnType, TVCompoundSlots } from 'tailwind-variants';
|
|
4
4
|
import { ForwardedRef } from 'react';
|
|
5
5
|
import { ContextValue } from 'react-aria-components';
|
|
6
6
|
|
|
7
|
-
declare const twMerge: (...classLists:
|
|
7
|
+
declare const twMerge: (...classLists: ClassNameValue[]) => string;
|
|
8
8
|
declare function cn(...inputs: ClassValue[]): string;
|
|
9
|
-
declare
|
|
9
|
+
declare function mergeVariants(className: string): string;
|
|
10
|
+
type TVSlots = Record<string, ClassNameValue> | undefined;
|
|
11
|
+
declare function tv<V extends TVVariants<S, B, EV>, CV extends TVCompoundVariants<V, S, B, EV, ES>, DV extends TVDefaultVariants<V, S, EV, ES>, B extends ClassNameValue = undefined, S extends TVSlots = undefined, E extends TVReturnType = TVReturnType<V, S, B, EV extends undefined ? object : EV, ES extends undefined ? object : ES>, EV extends TVVariants<ES, B, E['variants'], ES> = E['variants'], ES extends TVSlots = E['slots'] extends TVSlots ? E['slots'] : undefined>(options: {
|
|
12
|
+
extend?: E;
|
|
13
|
+
base?: B;
|
|
14
|
+
slots?: S;
|
|
15
|
+
variants?: V;
|
|
16
|
+
compoundVariants?: CV;
|
|
17
|
+
compoundSlots?: TVCompoundSlots<V, S, B>;
|
|
18
|
+
defaultVariants?: DV;
|
|
19
|
+
}): TVReturnType<V, S, B, EV, ES, E>;
|
|
10
20
|
type WithRef<T, E> = T & {
|
|
11
21
|
ref?: ForwardedRef<E>;
|
|
12
22
|
};
|
|
@@ -18,4 +28,4 @@ interface SlottedValue<T> {
|
|
|
18
28
|
*/
|
|
19
29
|
declare function isSlottedContextValue<T, E>(context: ContextValue<T, E>): context is SlottedValue<WithRef<T, E>>;
|
|
20
30
|
|
|
21
|
-
export { cn, isSlottedContextValue, tv, twMerge };
|
|
31
|
+
export { cn, isSlottedContextValue, mergeVariants, tv, twMerge };
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {clsx}from'clsx';import {extendTailwindMerge
|
|
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
|
package/dist/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/utils.ts"],"names":["twMerge","extendTailwindMerge","validators","cn","inputs","clsx","tv","createTV","isSlottedContextValue","context"],"mappings":"mIAoBaA,CAAAA,CAAUC,mBAAAA,CAA6C,CAClE,MAAA,CAAQ,CACN,WAAA,CAAa,CACX,KAAM,CAAC,CAAE,IAAA,CAAM,CAAC,GAAIC,UAAAA,CAAW,KAAK,CAAE,CAAC,EACvC,EAAA,CAAI,CAAC,CAAE,EAAA,CAAI,CAAC,GAAIA,UAAAA,CAAW,KAAK,CAAE,CAAC,CACrC,CAAA,CACA,sBAAA,CAAwB,CACtB,EAAA,CAAI,CAAC,MAAA,CAAQ,YAAY,CAC3B,CAAA,CACA,MAAO,CACL,KAAA,CAAO,CACL,SAAA,CACA,iBAAA,CACA,iBACA,iBAAA,CACA,kBAAA,CACA,mBAAA,CACA,qBAAA,CACA,0BACA,wBAAA,CACA,sBAAA,CACA,cAAA,CACA,aAAA,CACA,cACA,mBAAA,CACA,gBAAA,CACA,iBAAA,CACA,kBAAA,CACA,YACA,YAAA,CACA,aAAA,CACA,gBACA,gBAAA,CACA,iBAAA,CACA,cACA,cAAA,CACA,eAAA,CACA,cAAA,CACA,eAAA,CACA,iBACA,eAAA,CACA,gBAAA,CACA,iBAAA,CACA,eAAA,CACA,eACA,cAAA,CACA,eAAA,CACA,UAAA,CACA,WAAA,CACA,OACA,UAAA,CACA,QAAA,CACA,UACA,UAAA,CACA,wBAAA,CACA,yBACA,oBAAA,CACA,6BAAA,CACA,uBAAA,CACA,2BACF,EACA,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,UAAA,CACA,WAAA,CACA,WACA,UAAA,CACA,UAAA,CACA,WACF,CAAA,CACA,OAAQ,CAAC,MAAA,CAAQ,OAAA,CAAS,QAAA,CAAU,QAAS,OAAO,CAAA,CACpD,OAAQ,CAAC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CACA,UAAA,CACA,UAAA,CACA,WACA,WAAA,CACA,SAAA,CACA,QAAA,CACA,QAAA,CACA,SACA,SAAA,CACA,UAAA,CACA,YACA,UAAA,CACA,UAAA,CACA,WACA,WACF,CAAA,CACA,MAAA,CAAQ,CAAC,OAAQ,OAAA,CAAS,QAAA,CAAU,OAAA,CAAS,OAAO,EACpD,MAAA,CAAQ,CAAC,mBAAA,CAAqB,mBAAA,CAAqB,kBAAkB,CAAA,CACrE,OAAA,CAAS,CACP,MAAA,CACA,GAAA,CACA,MACA,IAAA,CACA,GAAA,CACA,GAAA,CACA,GAAA,CACA,KACA,KAAA,CACA,WACF,CACF,CACF,CACF,CACF,CAAC,EAcM,SAASM,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 { extendTailwindMerge, validators } from 'tailwind-merge';\nimport { createTV } from 'tailwind-variants';\n\ntype AdditionalClassGroupIds = 'icon' | 'icon-size' | 'fg';\n\nexport const twMerge = extendTailwindMerge<AdditionalClassGroupIds>({\n extend: {\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 },\n});\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const tv = createTV({\n twMergeConfig: {\n extend: {\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 },\n },\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,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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AC,CAAA,CAAE,CAAC,EAIvE,OAAOF,CAAAA,CAAgB,IAAA,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,QAvBgBE,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,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"]}
|