@accelint/design-system 1.2.2 → 1.2.3
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/aria/index.js.map +1 -1
- package/dist/components/button/button.css.d.ts +25 -24
- package/dist/components/button/index.d.ts +9 -40
- package/dist/components/button/index.js +23 -17
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button/types.d.ts +3 -2
- package/dist/components/checkbox/checkbox.css.d.ts +23 -23
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/chip/chip.css.d.ts +18 -18
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/collection/index.d.ts +3 -3
- package/dist/components/collection/index.js.map +1 -1
- package/dist/components/combo-box/combo-box.css.d.ts +9 -9
- package/dist/components/combo-box/index.js +9 -5
- package/dist/components/combo-box/index.js.map +1 -1
- package/dist/components/date-field/date-field.css.d.ts +17 -17
- package/dist/components/date-field/index.js +8 -4
- package/dist/components/date-field/index.js.map +1 -1
- package/dist/components/date-input/date-input.css.d.ts +25 -25
- package/dist/components/date-input/index.js +19 -8
- package/dist/components/date-input/index.js.map +1 -1
- package/dist/components/dialog/dialog.css.d.ts +16 -15
- package/dist/components/dialog/index.d.ts +1 -0
- package/dist/components/dialog/index.js +7 -5
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/dialog/types.d.ts +1 -0
- package/dist/components/drawer/drawer.css.d.ts +17 -17
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/index.js +21 -8
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/drawer/types.d.ts +1 -1
- package/dist/components/element/index.d.ts +1 -1
- package/dist/components/element/index.js +7 -3
- package/dist/components/element/index.js.map +1 -1
- package/dist/components/element/types.d.ts +2 -0
- package/dist/components/group/group.css.d.ts +7 -7
- package/dist/components/group/index.js +6 -6
- package/dist/components/group/index.js.map +1 -1
- package/dist/components/icon/icon.css.d.ts +9 -9
- package/dist/components/icon/index.js +4 -4
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/index.d.ts +35 -35
- package/dist/components/input/index.js +17 -8
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/input.css.d.ts +20 -20
- package/dist/components/menu/index.d.ts +2 -2
- package/dist/components/menu/index.js +1 -1
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/menu/menu.css.d.ts +42 -42
- package/dist/components/merge-provider/index.js +15 -7
- package/dist/components/merge-provider/index.js.map +1 -1
- package/dist/components/merge-provider/types.d.ts +2 -0
- package/dist/components/number-field/index.d.ts +1 -1
- package/dist/components/number-field/index.js +8 -4
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/number-field/number-field.css.d.ts +12 -12
- package/dist/components/number-field/types.d.ts +1 -1
- package/dist/components/options/index.js +1 -1
- package/dist/components/options/index.js.map +1 -1
- package/dist/components/options/options.css.d.ts +44 -44
- package/dist/components/picker/index.js.map +1 -1
- package/dist/components/picker/picker.css.d.ts +18 -18
- package/dist/components/popover/index.js +8 -4
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/popover/popover.css.d.ts +12 -12
- package/dist/components/query-builder/action-element.js.map +1 -1
- package/dist/components/query-builder/dataset-sample.js.map +1 -1
- package/dist/components/query-builder/group.js.map +1 -1
- package/dist/components/query-builder/index.js.map +1 -1
- package/dist/components/query-builder/query-builder.css.d.ts +53 -53
- 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/index.js +12 -8
- package/dist/components/radio/index.js.map +1 -1
- package/dist/components/radio/radio.css.d.ts +22 -22
- package/dist/components/search-field/index.js +9 -5
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/search-field/search-field.css.d.ts +9 -9
- package/dist/components/select/index.js +5 -5
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/select/select.css.d.ts +12 -12
- package/dist/components/slider/index.js +48 -20
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/slider.css.d.ts +27 -27
- package/dist/components/switch/index.js +4 -4
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.css.d.ts +16 -16
- package/dist/components/tabs/index.js +32 -20
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/tabs/tabs.css.d.ts +25 -25
- package/dist/components/text-field/index.d.ts +3 -128
- package/dist/components/text-field/index.js +11 -7
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/text-field/text-field.css.d.ts +8 -8
- package/dist/components/textarea/index.js +16 -7
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/textarea/textarea.css.d.ts +22 -22
- package/dist/components/time-field/index.js +8 -4
- package/dist/components/time-field/index.js.map +1 -1
- package/dist/components/time-field/time-field.css.d.ts +17 -17
- package/dist/components/tooltip/index.js +17 -9
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tooltip/tooltip.css.d.ts +11 -11
- package/dist/components/tree/index.js +5 -2
- package/dist/components/tree/index.js.map +1 -1
- package/dist/components/tree/tree.css.d.ts +45 -45
- package/dist/hooks/index.d.ts +13 -13
- package/dist/hooks/use-collection-render/index.d.ts +1 -1
- package/dist/hooks/use-collection-render/index.js +2 -3
- package/dist/hooks/use-collection-render/index.js.map +1 -1
- package/dist/hooks/use-context-props/index.js.map +1 -1
- package/dist/hooks/use-defaults/index.d.ts +32 -80
- package/dist/hooks/use-defaults/index.js +1 -4
- package/dist/hooks/use-defaults/index.js.map +1 -1
- package/dist/hooks/use-defaults/types.d.ts +1 -1
- package/dist/hooks/use-theme/index.d.ts +2 -2
- package/dist/hooks/use-theme/index.js.map +1 -1
- package/dist/hooks/use-theme/types.d.ts +1 -1
- package/dist/hooks/use-tree/index.js +3 -2
- package/dist/hooks/use-tree/index.js.map +1 -1
- package/dist/hooks/use-tree/utils.js +6 -9
- package/dist/hooks/use-tree/utils.js.map +1 -1
- package/dist/hooks/use-update-effect/index.js.map +1 -1
- package/dist/index.css +32 -32
- package/dist/index.d.ts +39 -39
- package/dist/ladle/actions.js.map +1 -1
- package/dist/styles/theme.css.d.ts +200 -200
- package/dist/test/setup.js +778 -1276
- package/dist/test/setup.js.map +1 -1
- package/dist/utils/css/index.d.ts +1 -1
- package/dist/utils/css/index.js.map +1 -1
- package/dist/utils/props/index.d.ts +1 -2
- package/dist/utils/props/index.js +1 -2
- package/dist/utils/props/index.js.map +1 -1
- package/dist/vanilla.d.ts +29 -29
- package/package.json +49 -48
|
@@ -20,70 +20,70 @@ declare const treeContainers: {
|
|
|
20
20
|
};
|
|
21
21
|
declare const treeColorVars: {
|
|
22
22
|
bar: {
|
|
23
|
-
background: `var(--${string})
|
|
24
|
-
border: `var(--${string})
|
|
25
|
-
color: `var(--${string})
|
|
23
|
+
background: `var(--${string})`;
|
|
24
|
+
border: `var(--${string})`;
|
|
25
|
+
color: `var(--${string})`;
|
|
26
26
|
};
|
|
27
27
|
indicator: {
|
|
28
|
-
background: `var(--${string})
|
|
29
|
-
border: `var(--${string})
|
|
30
|
-
color: `var(--${string})
|
|
28
|
+
background: `var(--${string})`;
|
|
29
|
+
border: `var(--${string})`;
|
|
30
|
+
color: `var(--${string})`;
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
declare const treeSpaceVars: {
|
|
34
34
|
bar: {
|
|
35
|
-
x: `var(--${string})
|
|
36
|
-
y: `var(--${string})
|
|
35
|
+
x: `var(--${string})`;
|
|
36
|
+
y: `var(--${string})`;
|
|
37
37
|
};
|
|
38
38
|
description: {
|
|
39
|
-
x: `var(--${string})
|
|
40
|
-
y: `var(--${string})
|
|
39
|
+
x: `var(--${string})`;
|
|
40
|
+
y: `var(--${string})`;
|
|
41
41
|
};
|
|
42
42
|
empty: {
|
|
43
|
-
x: `var(--${string})
|
|
44
|
-
y: `var(--${string})
|
|
43
|
+
x: `var(--${string})`;
|
|
44
|
+
y: `var(--${string})`;
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
47
|
declare const treeStateVars: {
|
|
48
|
-
allowsDragging: `var(--${string})
|
|
49
|
-
allowsExpansion: `var(--${string})
|
|
50
|
-
allowsVisibility: `var(--${string})
|
|
51
|
-
showTreeLines: `var(--${string})
|
|
52
|
-
size: `var(--${string})
|
|
48
|
+
allowsDragging: `var(--${string})`;
|
|
49
|
+
allowsExpansion: `var(--${string})`;
|
|
50
|
+
allowsVisibility: `var(--${string})`;
|
|
51
|
+
showTreeLines: `var(--${string})`;
|
|
52
|
+
size: `var(--${string})`;
|
|
53
53
|
};
|
|
54
54
|
declare const treeGroupStateVars: {
|
|
55
|
-
count: `var(--${string})
|
|
56
|
-
layout: `var(--${string})
|
|
57
|
-
isDropTarget: `var(--${string})
|
|
58
|
-
isEmpty: `var(--${string})
|
|
59
|
-
isFocused: `var(--${string})
|
|
60
|
-
isFocusVisible: `var(--${string})
|
|
55
|
+
count: `var(--${string})`;
|
|
56
|
+
layout: `var(--${string})`;
|
|
57
|
+
isDropTarget: `var(--${string})`;
|
|
58
|
+
isEmpty: `var(--${string})`;
|
|
59
|
+
isFocused: `var(--${string})`;
|
|
60
|
+
isFocusVisible: `var(--${string})`;
|
|
61
61
|
};
|
|
62
62
|
declare const treeIndicatorStateVars: {
|
|
63
|
-
dropPosition: `var(--${string})
|
|
64
|
-
isDropTarget: `var(--${string})
|
|
63
|
+
dropPosition: `var(--${string})`;
|
|
64
|
+
isDropTarget: `var(--${string})`;
|
|
65
65
|
};
|
|
66
66
|
declare const treeItemStateVars: {
|
|
67
|
-
allowsDragging: `var(--${string})
|
|
68
|
-
count: `var(--${string})
|
|
69
|
-
index: `var(--${string})
|
|
70
|
-
selectionMode: `var(--${string})
|
|
71
|
-
selectionBehavior: `var(--${string})
|
|
72
|
-
isDisabled: `var(--${string})
|
|
73
|
-
isDragging: `var(--${string})
|
|
74
|
-
isDropTarget: `var(--${string})
|
|
75
|
-
isExpanded: `var(--${string})
|
|
76
|
-
isFirstChild: `var(--${string})
|
|
77
|
-
isFocused: `var(--${string})
|
|
78
|
-
isFocusVisible: `var(--${string})
|
|
79
|
-
isGroup: `var(--${string})
|
|
80
|
-
isHovered: `var(--${string})
|
|
81
|
-
isLastChild: `var(--${string})
|
|
82
|
-
isPressed: `var(--${string})
|
|
83
|
-
isReadOnly: `var(--${string})
|
|
84
|
-
isSelected: `var(--${string})
|
|
85
|
-
isViewable: `var(--${string})
|
|
86
|
-
isVisible: `var(--${string})
|
|
67
|
+
allowsDragging: `var(--${string})`;
|
|
68
|
+
count: `var(--${string})`;
|
|
69
|
+
index: `var(--${string})`;
|
|
70
|
+
selectionMode: `var(--${string})`;
|
|
71
|
+
selectionBehavior: `var(--${string})`;
|
|
72
|
+
isDisabled: `var(--${string})`;
|
|
73
|
+
isDragging: `var(--${string})`;
|
|
74
|
+
isDropTarget: `var(--${string})`;
|
|
75
|
+
isExpanded: `var(--${string})`;
|
|
76
|
+
isFirstChild: `var(--${string})`;
|
|
77
|
+
isFocused: `var(--${string})`;
|
|
78
|
+
isFocusVisible: `var(--${string})`;
|
|
79
|
+
isGroup: `var(--${string})`;
|
|
80
|
+
isHovered: `var(--${string})`;
|
|
81
|
+
isLastChild: `var(--${string})`;
|
|
82
|
+
isPressed: `var(--${string})`;
|
|
83
|
+
isReadOnly: `var(--${string})`;
|
|
84
|
+
isSelected: `var(--${string})`;
|
|
85
|
+
isViewable: `var(--${string})`;
|
|
86
|
+
isVisible: `var(--${string})`;
|
|
87
87
|
};
|
|
88
88
|
declare const treeClassNames: TreeClassNames;
|
|
89
89
|
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
export { useCollectionRender } from './use-collection-render/index.js';
|
|
2
2
|
export { useContextProps } from './use-context-props/index.js';
|
|
3
3
|
export { DefaultsProvider, useDefaultProps, useDefaults } from './use-defaults/index.js';
|
|
4
|
-
export { DefaultsContext, DefaultsProviderProps } from './use-defaults/types.js';
|
|
5
4
|
export { usePropagatingPress } from './use-propagating-press/index.js';
|
|
6
5
|
export { useSlot } from './use-slot/index.js';
|
|
7
6
|
export { ThemeProvider, useTheme } from './use-theme/index.js';
|
|
8
|
-
export { ThemeContext, ThemeProviderProps, ThemeVars } from './use-theme/types.js';
|
|
9
7
|
export { useTree } from './use-tree/index.js';
|
|
10
8
|
export { useUpdateEffect } from './use-update-effect/index.js';
|
|
9
|
+
export { DefaultsContext, DefaultsProviderProps } from './use-defaults/types.js';
|
|
10
|
+
export { ThemeContext, ThemeProviderProps, ThemeVars } from './use-theme/types.js';
|
|
11
11
|
import '@react-types/shared';
|
|
12
12
|
import 'react';
|
|
13
13
|
import 'react-aria-components';
|
|
14
14
|
import 'react/jsx-runtime';
|
|
15
|
+
import '../types/generic.js';
|
|
16
|
+
import '@react-aria/interactions';
|
|
17
|
+
import '../utils/css/index.js';
|
|
18
|
+
import '@vanilla-extract/css';
|
|
19
|
+
import '../types/deckgl.js';
|
|
20
|
+
import '../types/vanilla-extract.js';
|
|
21
|
+
import '../types/use-tree.js';
|
|
22
|
+
import '@react-stately/data';
|
|
15
23
|
import '../components/button/types.js';
|
|
16
24
|
import '../types/props.js';
|
|
17
25
|
import '../types/react-aria.js';
|
|
@@ -19,7 +27,6 @@ import '../components/icon/types.js';
|
|
|
19
27
|
import '../components/checkbox/types.js';
|
|
20
28
|
import 'type-fest';
|
|
21
29
|
import '../components/chip/types.js';
|
|
22
|
-
import '../types/generic.js';
|
|
23
30
|
import '../components/combo-box/types.js';
|
|
24
31
|
import '../components/input/types.js';
|
|
25
32
|
import '../components/options/types.js';
|
|
@@ -37,21 +44,14 @@ import '../components/number-field/types.js';
|
|
|
37
44
|
import '../components/picker/types.js';
|
|
38
45
|
import '../components/popover/types.js';
|
|
39
46
|
import '../components/radio/types.js';
|
|
40
|
-
import '../components/select/types.js';
|
|
41
|
-
import '../components/switch/types.js';
|
|
42
|
-
import '../components/textarea/types.js';
|
|
43
47
|
import '../components/search-field/types.js';
|
|
48
|
+
import '../components/select/types.js';
|
|
44
49
|
import '../components/slider/types.js';
|
|
50
|
+
import '../components/switch/types.js';
|
|
45
51
|
import '../components/text-field/types.js';
|
|
52
|
+
import '../components/textarea/types.js';
|
|
46
53
|
import '../components/time-field/types.js';
|
|
47
54
|
import '../components/tooltip/types.js';
|
|
48
55
|
import '../components/tree/types.js';
|
|
49
|
-
import '../types/use-tree.js';
|
|
50
|
-
import '@react-stately/data';
|
|
51
|
-
import '@react-aria/interactions';
|
|
52
|
-
import '../types/vanilla-extract.js';
|
|
53
|
-
import '@vanilla-extract/css';
|
|
54
|
-
import '../utils/css/index.js';
|
|
55
|
-
import '../types/deckgl.js';
|
|
56
56
|
import '../components/query-builder/types.js';
|
|
57
57
|
import 'react-querybuilder';
|
|
@@ -6,6 +6,6 @@ import { ReactNode } from 'react';
|
|
|
6
6
|
*
|
|
7
7
|
* Hook serves as the basis of the root and branch renderers for Collections: https://github.com/adobe/react-spectrum/blob/main/packages/react-aria-components/src/Collection.tsx#L139
|
|
8
8
|
*/
|
|
9
|
-
declare function useCollectionRender(collection: Collection<Node<
|
|
9
|
+
declare function useCollectionRender<T = object>(collection: Collection<Node<T>>, parent: Node<T> | null, renderDropIndicator?: (target: ItemDropTarget) => ReactNode): ReactNode;
|
|
10
10
|
|
|
11
11
|
export { useCollectionRender };
|
|
@@ -4,11 +4,10 @@ import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
4
4
|
|
|
5
5
|
function useCollectionRender(collection, parent, renderDropIndicator) {
|
|
6
6
|
return useCachedChildren({
|
|
7
|
-
|
|
8
|
-
items: parent ? collection.getChildren(parent.key) : collection,
|
|
7
|
+
items: parent ? collection.getChildren?.(parent.key) ?? [] : collection,
|
|
9
8
|
dependencies: [renderDropIndicator],
|
|
10
9
|
children(node) {
|
|
11
|
-
const rendered = node.render(node);
|
|
10
|
+
const rendered = node.render?.(node);
|
|
12
11
|
if (!renderDropIndicator || node.type !== "item") {
|
|
13
12
|
return rendered;
|
|
14
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-collection-render/index.tsx"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-collection-render/index.tsx"],"names":[],"mappings":";;;;AAsBO,SAAS,mBAAA,CACd,UAAA,EACA,MAAA,EACA,mBAAA,EACA;AACA,EAAA,OAAO,iBAAA,CAAkB;AAAA,IACvB,KAAA,EAAO,SAAU,UAAA,CAAW,WAAA,GAAc,OAAO,GAAG,CAAA,IAAK,EAAC,GAAK,UAAA;AAAA,IAC/D,YAAA,EAAc,CAAC,mBAAmB,CAAA;AAAA,IAClC,SAAS,IAAA,EAAM;AACb,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,MAAA,GAAS,IAAI,CAAA;AACnC,MAAA,IAAI,CAAC,mBAAA,IAAuB,IAAA,CAAK,IAAA,KAAS,MAAA,EAAQ;AAChD,QAAA,OAAO,QAAA;AAAA,MACT;AAEA,MAAA,MAAM,EAAE,KAAI,GAAI,IAAA;AAChB,MAAA,MAAM,QAAA,GAAW,UAAA,CAAW,WAAA,CAAY,GAAG,CAAA;AAE3C,MAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,QAAA,mBAAA,CAAoB,EAAE,IAAA,EAAM,MAAA,EAAQ,GAAA,EAAK,YAAA,EAAc,UAAU,CAAA;AAAA,QACjE,QAAA;AAAA,QAAA,CACC,QAAA,IAAY,IAAA,IACZ,UAAA,CAAW,OAAA,CAAQ,QAAQ,CAAA,EAAG,IAAA,KAAS,MAAA,KACvC,mBAAA,CAAoB,EAAE,IAAA,EAAM,MAAA,EAAQ,GAAA,EAAK,YAAA,EAAc,SAAS;AAAA,OAAA,EACpE,CAAA;AAAA,IAEJ;AAAA,GACD,CAAA;AACH","file":"index.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 { useCachedChildren } from '@react-aria/collections';\nimport type { Collection, ItemDropTarget, Node } from '@react-types/shared';\nimport type { ReactNode } from 'react';\n\n/**\n * Copied from RAC, unexported hook: https://github.com/adobe/react-spectrum/blob/main/packages/react-aria-components/src/Collection.tsx#L148\n *\n * Hook serves as the basis of the root and branch renderers for Collections: https://github.com/adobe/react-spectrum/blob/main/packages/react-aria-components/src/Collection.tsx#L139\n */\n\nexport function useCollectionRender<T = object>(\n collection: Collection<Node<T>>,\n parent: Node<T> | null,\n renderDropIndicator?: (target: ItemDropTarget) => ReactNode,\n) {\n return useCachedChildren({\n items: parent ? (collection.getChildren?.(parent.key) ?? []) : collection,\n dependencies: [renderDropIndicator],\n children(node) {\n const rendered = node.render?.(node);\n if (!renderDropIndicator || node.type !== 'item') {\n return rendered;\n }\n\n const { key } = node;\n const keyAfter = collection.getKeyAfter(key);\n\n return (\n <>\n {renderDropIndicator({ type: 'item', key, dropPosition: 'before' })}\n {rendered}\n {(keyAfter == null ||\n collection.getItem(keyAfter)?.type !== 'item') &&\n renderDropIndicator({ type: 'item', key, dropPosition: 'after' })}\n </>\n );\n },\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-context-props/index.ts"],"names":[],"mappings":";;;;;;AA8BO,SAAS,eAAA,CACd,KAAA,EACA,GAAA,EACA,OAAA,EAC0B;AAC1B,EAAA,MAAM,QAAS,iBAAA,CAAkB,OAAA,EAAS,KAAA,CAAM,IAAI,KAAK,EAAC;AAI1D,EAAA,MAAM,EAAE,GAAA,EAAK,UAAA,EAAY,GAAG,cAAa,GAAI,KAAA;AAE7C,EAAA,OAAO;AAAA,IACL,UAAA,CAAW,
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-context-props/index.ts"],"names":[],"mappings":";;;;;;AA8BO,SAAS,eAAA,CACd,KAAA,EACA,GAAA,EACA,OAAA,EAC0B;AAC1B,EAAA,MAAM,QAAS,iBAAA,CAAkB,OAAA,EAAS,KAAA,CAAM,IAAI,KAAK,EAAC;AAI1D,EAAA,MAAM,EAAE,GAAA,EAAK,UAAA,EAAY,GAAG,cAAa,GAAI,KAAA;AAE7C,EAAA,OAAO;AAAA,IACL,UAAA,CAAW,cAAwB,KAAe,CAAA;AAAA,IAClD,YAAA,CAAa,OAAA,CAAQ,MAAM,SAAA,CAAU,GAAA,EAAK,UAAU,CAAA,EAAG,CAAC,GAAA,EAAK,UAAU,CAAC,CAAC;AAAA,GAC3E;AACF","file":"index.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 { mergeRefs, useObjectRef } from '@react-aria/utils';\nimport {\n type Context,\n type ForwardedRef,\n type RefObject,\n useMemo,\n} from 'react';\nimport {\n type ContextValue,\n type SlotProps,\n useSlottedContext,\n} from 'react-aria-components';\nimport { mergeProps } from '../../utils/props';\n\n/**\n * Reimplementation of React Aria's useContextProps, to utilize our own\n * mergeProps which handles renderProps and classNames\n */\nexport function useContextProps<T, U extends SlotProps, E extends Element>(\n props: T & SlotProps,\n ref: ForwardedRef<E>,\n context: Context<ContextValue<U, E>>,\n): [T, RefObject<E | null>] {\n const value = (useSlottedContext(context, props.slot) ?? {}) as Partial<T> & {\n ref?: ForwardedRef<E>;\n };\n\n const { ref: contextRef, ...contextProps } = value;\n\n return [\n mergeProps(contextProps as object, props as object) as T,\n useObjectRef(useMemo(() => mergeRefs(ref, contextRef), [ref, contextRef])),\n ];\n}\n"]}
|
|
@@ -1,102 +1,54 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import { ButtonProps, LinkButtonProps, ToggleButtonProps } from '../../components/button/types.js';
|
|
4
|
-
import { CheckboxProps, CheckboxGroupProps } from '../../components/checkbox/types.js';
|
|
5
|
-
import { ChipProps, ChipGroupProps } from '../../components/chip/types.js';
|
|
6
|
-
import { ComboBoxProps } from '../../components/combo-box/types.js';
|
|
7
|
-
import { DateFieldProps } from '../../components/date-field/types.js';
|
|
8
|
-
import { DateInputProps } from '../../components/date-input/types.js';
|
|
9
|
-
import { DialogProps } from '../../components/dialog/types.js';
|
|
10
|
-
import { DrawerProps, DrawerTabProps, DrawerTabListProps } from '../../components/drawer/types.js';
|
|
11
|
-
import { IconProps } from '../../components/icon/types.js';
|
|
12
|
-
import { InputProps } from '../../components/input/types.js';
|
|
13
|
-
import { MenuProps, MenuListProps, MenuItemProps } from '../../components/menu/types.js';
|
|
14
|
-
import { NumberFieldProps } from '../../components/number-field/types.js';
|
|
15
|
-
import { OptionsProps, OptionsListProps, OptionsItemProps } from '../../components/options/types.js';
|
|
16
|
-
import { PickerProps } from '../../components/picker/types.js';
|
|
17
|
-
import { PopoverProps } from '../../components/popover/types.js';
|
|
18
|
-
import { OmitProtectedProps } from '../../types/props.js';
|
|
19
|
-
import { RadioProps, RadioGroupProps } from '../../components/radio/types.js';
|
|
20
|
-
import { SelectProps } from '../../components/select/types.js';
|
|
21
|
-
import { SwitchProps } from '../../components/switch/types.js';
|
|
22
|
-
import { TextAreaProps } from '../../components/textarea/types.js';
|
|
23
|
-
import { SearchFieldProps } from '../../components/search-field/types.js';
|
|
24
|
-
import { SliderProps, SliderBarProps, SliderInputProps, SliderOutputProps, SliderThumbProps, SliderTrackProps } from '../../components/slider/types.js';
|
|
25
|
-
import { TabProps, TabListProps, TabPanelProps, TabPanelsProps, TabsProps } from '../../components/tabs/types.js';
|
|
26
|
-
import { TextFieldProps } from '../../components/text-field/types.js';
|
|
27
|
-
import { TimeFieldProps } from '../../components/time-field/types.js';
|
|
28
|
-
import { TooltipProps, TooltipTargetProps } from '../../components/tooltip/types.js';
|
|
29
|
-
import { TreeProps } from '../../components/tree/types.js';
|
|
2
|
+
import { AsType } from '../../types/generic.js';
|
|
30
3
|
import { DefaultsProviderProps, DefaultsContext } from './types.js';
|
|
31
|
-
import '../../types/react-aria.js';
|
|
32
4
|
import 'react';
|
|
5
|
+
import 'react-aria-components';
|
|
6
|
+
import '../../components/button/types.js';
|
|
7
|
+
import '../../types/props.js';
|
|
8
|
+
import '../../types/react-aria.js';
|
|
9
|
+
import '../../components/icon/types.js';
|
|
10
|
+
import '../../components/checkbox/types.js';
|
|
33
11
|
import '@react-types/shared';
|
|
34
12
|
import 'type-fest';
|
|
35
|
-
import '../../types
|
|
13
|
+
import '../../components/chip/types.js';
|
|
14
|
+
import '../../components/combo-box/types.js';
|
|
15
|
+
import '../../components/input/types.js';
|
|
16
|
+
import '../../components/options/types.js';
|
|
17
|
+
import '../../components/date-field/types.js';
|
|
18
|
+
import '../../components/date-input/types.js';
|
|
36
19
|
import '@react-stately/datepicker';
|
|
20
|
+
import '../../components/dialog/types.js';
|
|
37
21
|
import '../../components/group/types.js';
|
|
22
|
+
import '../../components/drawer/types.js';
|
|
38
23
|
import '@react-aria/overlays';
|
|
39
24
|
import '@react-stately/overlays';
|
|
25
|
+
import '../../components/tabs/types.js';
|
|
26
|
+
import '../../components/menu/types.js';
|
|
27
|
+
import '../../components/number-field/types.js';
|
|
28
|
+
import '../../components/picker/types.js';
|
|
29
|
+
import '../../components/popover/types.js';
|
|
30
|
+
import '../../components/radio/types.js';
|
|
31
|
+
import '../../components/search-field/types.js';
|
|
32
|
+
import '../../components/select/types.js';
|
|
33
|
+
import '../../components/slider/types.js';
|
|
34
|
+
import '../../components/switch/types.js';
|
|
35
|
+
import '../../components/text-field/types.js';
|
|
36
|
+
import '../../components/textarea/types.js';
|
|
37
|
+
import '../../components/time-field/types.js';
|
|
38
|
+
import '../../components/tooltip/types.js';
|
|
39
|
+
import '../../components/tree/types.js';
|
|
40
40
|
import '../../types/use-tree.js';
|
|
41
41
|
import '@react-stately/data';
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Access globally established component prop defaults
|
|
45
45
|
*/
|
|
46
|
-
declare function useDefaults():
|
|
47
|
-
Button?: OmitProtectedProps<ButtonProps> | undefined;
|
|
48
|
-
Checkbox?: OmitProtectedProps<CheckboxProps> | undefined;
|
|
49
|
-
CheckboxGroup?: OmitProtectedProps<CheckboxGroupProps> | undefined;
|
|
50
|
-
Chip?: OmitProtectedProps<ChipProps> | undefined;
|
|
51
|
-
ChipGroup?: OmitProtectedProps<ChipGroupProps> | undefined;
|
|
52
|
-
ComboBox?: OmitProtectedProps<ComboBoxProps<object>> | undefined;
|
|
53
|
-
DateField?: OmitProtectedProps<DateFieldProps<react_aria_components.DateValue>> | undefined;
|
|
54
|
-
DateInput?: OmitProtectedProps<DateInputProps> | undefined;
|
|
55
|
-
Dialog?: OmitProtectedProps<DialogProps> | undefined;
|
|
56
|
-
Drawer?: OmitProtectedProps<DrawerProps> | undefined;
|
|
57
|
-
DrawerTab?: OmitProtectedProps<DrawerTabProps> | undefined;
|
|
58
|
-
DrawerTabList?: OmitProtectedProps<DrawerTabListProps<unknown>> | undefined;
|
|
59
|
-
Icon?: OmitProtectedProps<IconProps> | undefined;
|
|
60
|
-
Input?: OmitProtectedProps<InputProps> | undefined;
|
|
61
|
-
LinkButton?: OmitProtectedProps<LinkButtonProps> | undefined;
|
|
62
|
-
Menu?: OmitProtectedProps<MenuProps> | undefined;
|
|
63
|
-
MenuList?: OmitProtectedProps<MenuListProps<unknown>> | undefined;
|
|
64
|
-
MenuItem?: OmitProtectedProps<MenuItemProps<unknown>> | undefined;
|
|
65
|
-
NumberField?: OmitProtectedProps<NumberFieldProps> | undefined;
|
|
66
|
-
Options?: OmitProtectedProps<OptionsProps> | undefined;
|
|
67
|
-
OptionsList?: OmitProtectedProps<OptionsListProps<object>> | undefined;
|
|
68
|
-
OptionsItem?: OmitProtectedProps<OptionsItemProps<object>> | undefined;
|
|
69
|
-
Picker?: OmitProtectedProps<PickerProps<unknown>> | undefined;
|
|
70
|
-
Popover?: OmitProtectedProps<PopoverProps> | undefined;
|
|
71
|
-
Radio?: OmitProtectedProps<RadioProps> | undefined;
|
|
72
|
-
RadioGroup?: OmitProtectedProps<RadioGroupProps> | undefined;
|
|
73
|
-
SearchField?: OmitProtectedProps<SearchFieldProps> | undefined;
|
|
74
|
-
Select?: OmitProtectedProps<SelectProps<object>> | undefined;
|
|
75
|
-
Slider?: OmitProtectedProps<SliderProps> | undefined;
|
|
76
|
-
SliderBar?: OmitProtectedProps<SliderBarProps> | undefined;
|
|
77
|
-
SliderInput?: OmitProtectedProps<SliderInputProps> | undefined;
|
|
78
|
-
SliderOutput?: OmitProtectedProps<SliderOutputProps> | undefined;
|
|
79
|
-
SliderThumb?: OmitProtectedProps<SliderThumbProps> | undefined;
|
|
80
|
-
SliderTrack?: OmitProtectedProps<SliderTrackProps> | undefined;
|
|
81
|
-
Switch?: OmitProtectedProps<SwitchProps> | undefined;
|
|
82
|
-
Tab?: OmitProtectedProps<TabProps> | undefined;
|
|
83
|
-
TabList?: OmitProtectedProps<TabListProps<unknown>> | undefined;
|
|
84
|
-
TabPanel?: OmitProtectedProps<TabPanelProps> | undefined;
|
|
85
|
-
TabPanels?: OmitProtectedProps<TabPanelsProps> | undefined;
|
|
86
|
-
Tabs?: OmitProtectedProps<TabsProps> | undefined;
|
|
87
|
-
TextArea?: OmitProtectedProps<TextAreaProps> | undefined;
|
|
88
|
-
TextField?: OmitProtectedProps<TextFieldProps> | undefined;
|
|
89
|
-
TimeField?: OmitProtectedProps<TimeFieldProps<react_aria_components.TimeValue>> | undefined;
|
|
90
|
-
ToggleButton?: OmitProtectedProps<ToggleButtonProps> | undefined;
|
|
91
|
-
Tooltip?: OmitProtectedProps<TooltipProps> | undefined;
|
|
92
|
-
TooltipTarget?: OmitProtectedProps<TooltipTargetProps> | undefined;
|
|
93
|
-
Tree?: OmitProtectedProps<TreeProps<unknown>> | undefined;
|
|
94
|
-
};
|
|
46
|
+
declare function useDefaults(): DefaultsContext;
|
|
95
47
|
/**
|
|
96
48
|
* Select default props from context and merge with provided props
|
|
97
49
|
* with provided props taking precedence
|
|
98
50
|
*/
|
|
99
|
-
declare function useDefaultProps<K extends keyof DefaultsContext, P extends DefaultsContext[K]>(props: P
|
|
51
|
+
declare function useDefaultProps<K extends keyof DefaultsContext, P extends DefaultsContext[K]>(props: AsType<P>, key: K): P;
|
|
100
52
|
/**
|
|
101
53
|
* Set default props for any component, to be merged in with props at point
|
|
102
54
|
* of implementation. Global defaults take lower priority than props from
|
|
@@ -9,10 +9,7 @@ function useDefaults() {
|
|
|
9
9
|
}
|
|
10
10
|
function useDefaultProps(props, key) {
|
|
11
11
|
const defaults = useDefaults();
|
|
12
|
-
const defaultProps = useMemo(
|
|
13
|
-
() => defaults[key] ?? {},
|
|
14
|
-
[defaults, key]
|
|
15
|
-
);
|
|
12
|
+
const defaultProps = useMemo(() => defaults[key] ?? {}, [defaults, key]);
|
|
16
13
|
return useMemo(
|
|
17
14
|
() => mergeProps(defaultProps, props),
|
|
18
15
|
[defaultProps, props]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-defaults/index.tsx"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-defaults/index.tsx"],"names":[],"mappings":";;;;;AAiBA,IAAM,eAAA,GAAkB,aAAA,CAA+B,EAAE,CAAA;AAKlD,SAAS,WAAA,GAA+B;AAC7C,EAAA,OAAO,WAAW,eAAe,CAAA;AACnC;AAMO,SAAS,eAAA,CAGd,OAAkB,GAAA,EAAW;AAC7B,EAAA,MAAM,WAAW,WAAA,EAAY;AAE7B,EAAA,MAAM,YAAA,GAAe,OAAA,CAAQ,MAAM,QAAA,CAAS,GAAG,CAAA,IAAK,EAAC,EAAG,CAAC,QAAA,EAAU,GAAG,CAAC,CAAA;AAEvE,EAAA,OAAO,OAAA;AAAA,IACL,MAAM,UAAA,CAAW,YAAA,EAAc,KAAe,CAAA;AAAA,IAC9C,CAAC,cAAc,KAAK;AAAA,GACtB;AACF;AAUO,SAAS,gBAAA,CAAiB;AAAA,EAC/B,QAAA;AAAA,EACA,QAAA,EAAU;AACZ,CAAA,EAA0B;AACxB,EAAA,MAAM,WAAW,WAAA,EAAY;AAE7B,EAAA,MAAM,OAAA,GAAU,OAAA;AAAA,IACd,OAAO,EAAE,GAAG,QAAA,EAAU,GAAG,YAAA,EAAa,CAAA;AAAA,IACtC,CAAC,UAAU,YAAY;AAAA,GACzB;AAEA,EAAA,MAAM,EAAE,UAAS,GAAI,eAAA;AAErB,EAAA,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAS,KAAA,EAAO,OAAA,EAAU,QAAA,EAAS,CAAA;AAC7C","file":"index.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 { createContext, useContext, useMemo } from 'react';\nimport { mergeProps } from '../../utils/props';\nimport type { AsType } from '../../types/generic';\nimport type { DefaultsContext, DefaultsProviderProps } from './types';\n\nconst defaultsContext = createContext<DefaultsContext>({});\n\n/**\n * Access globally established component prop defaults\n */\nexport function useDefaults(): DefaultsContext {\n return useContext(defaultsContext);\n}\n\n/**\n * Select default props from context and merge with provided props\n * with provided props taking precedence\n */\nexport function useDefaultProps<\n K extends keyof DefaultsContext,\n P extends DefaultsContext[K],\n>(props: AsType<P>, key: K): P {\n const defaults = useDefaults();\n\n const defaultProps = useMemo(() => defaults[key] ?? {}, [defaults, key]);\n\n return useMemo(\n () => mergeProps(defaultProps, props as object) as P,\n [defaultProps, props],\n );\n}\n\n/**\n * Set default props for any component, to be merged in with props at point\n * of implementation. Global defaults take lower priority than props from\n * composition context or props attached to instance\n *\n * Nested instances of this provider will shallow merge defaults from parent\n * context, with the defaults prop taking precedence\n */\nexport function DefaultsProvider({\n children,\n defaults: defaultsProp,\n}: DefaultsProviderProps) {\n const defaults = useDefaults();\n\n const context = useMemo(\n () => ({ ...defaults, ...defaultsProp }),\n [defaults, defaultsProp],\n );\n\n const { Provider } = defaultsContext;\n\n return <Provider value={context}>{children}</Provider>;\n}\n"]}
|
|
@@ -27,10 +27,10 @@ import { TimeFieldProps } from '../../components/time-field/types.js';
|
|
|
27
27
|
import { TooltipProps, TooltipTargetProps } from '../../components/tooltip/types.js';
|
|
28
28
|
import { TreeProps } from '../../components/tree/types.js';
|
|
29
29
|
import { OmitProtectedProps } from '../../types/props.js';
|
|
30
|
+
import '../../types/generic.js';
|
|
30
31
|
import '../../types/react-aria.js';
|
|
31
32
|
import '@react-types/shared';
|
|
32
33
|
import 'type-fest';
|
|
33
|
-
import '../../types/generic.js';
|
|
34
34
|
import '@react-stately/datepicker';
|
|
35
35
|
import '../../components/group/types.js';
|
|
36
36
|
import '@react-aria/overlays';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { Contract } from '../../types/vanilla-extract.js';
|
|
3
2
|
import { computeContract } from '../../utils/css/index.js';
|
|
3
|
+
import { Contract } from '../../types/vanilla-extract.js';
|
|
4
4
|
import { ThemeProviderProps, ThemeContext } from './types.js';
|
|
5
5
|
import '@vanilla-extract/css';
|
|
6
6
|
import '../../types/deckgl.js';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '../../components/button/types.js';
|
|
9
9
|
import 'react-aria-components';
|
|
10
|
+
import '../../types/generic.js';
|
|
10
11
|
import '../../types/props.js';
|
|
11
12
|
import '../../types/react-aria.js';
|
|
12
13
|
import '../../components/icon/types.js';
|
|
@@ -14,7 +15,6 @@ import '../../components/checkbox/types.js';
|
|
|
14
15
|
import '@react-types/shared';
|
|
15
16
|
import 'type-fest';
|
|
16
17
|
import '../../components/chip/types.js';
|
|
17
|
-
import '../../types/generic.js';
|
|
18
18
|
import '../../components/combo-box/types.js';
|
|
19
19
|
import '../../components/input/types.js';
|
|
20
20
|
import '../../components/options/types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-theme/index.tsx"],"names":[],"mappings":";;;;;;;;;AA+BA,IAAM,eAA6B,EAAC;AACpC,IAAM,YAAA,GAAe,cAA4B,YAAY,CAAA;AAC7D,IAAM,eAAA,GAAkB,cAA0C,IAAI,CAAA;AAyB/D,SAAS,SACd,QAAA,EAGA;AACA,EAAA,MAAM,KAAA,GAAQ,WAAW,YAAY,CAAA;AACrC,EAAA,MAAM,GAAA,GAAM,WAAW,eAAe,CAAA;AAEtC,EAAA,OAAO,OAAA;AAAA,IACL,OAAO;AAAA,MACL,GAAG,KAAA;AAAA,MACH,GAAI,CAAC,CAAC,QAAA,IAAY,CAAC,CAAC,GAAA,GAChB;AAAA,QACE,QAAA,EAAU,eAAA,CAAgB,QAAA,EAAU,GAAG;AAAA,UAEzC;AAAC,KACP,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,QAAA,EAAU,GAAG;AAAA,GACvB;AACF;AAEA,SAAS,qBAAA,CACP,UAAA,EACA,OAAA,EACA,YAAA,EACA;AACA,EAAA,OAAO,UAAA,KAAe,CAAC,OAAA,IAAW,YAAA,CAAA;AACpC;AAEO,SAAS,aAAA,CAAc;AAAA,EAC5B,QAAA;AAAA,EACA,SAAA,EAAW,aAAA;AAAA,EACX,OAAA;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AA,EAAA,EAAgB,KAAA,EAAO,KAAA,EACtB,8BAAC,WAAA,EAAA,EAAY,KAAA,EAAO,GAAA,EAAM,QAAA,EAAS,GACrC,CAAA,EACF,CAAA;AAEJ","file":"index.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 { useLayoutEffect } from '@react-aria/utils';\nimport { clsx } from 'clsx';\nimport { createContext, useContext, useMemo, useRef, useState } from 'react';\nimport {\n defaultElevations,\n defaultFocus,\n defaultGenericColors,\n defaultRadius,\n defaultSemanticColors,\n defaultSizes,\n defaultSpace,\n defaultTypography,\n defaultZIndex,\n} from '../../styles/theme.css';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-theme/index.tsx"],"names":[],"mappings":";;;;;;;;;AA+BA,IAAM,eAA6B,EAAC;AACpC,IAAM,YAAA,GAAe,cAA4B,YAAY,CAAA;AAC7D,IAAM,eAAA,GAAkB,cAA0C,IAAI,CAAA;AAyB/D,SAAS,SACd,QAAA,EAGA;AACA,EAAA,MAAM,KAAA,GAAQ,WAAW,YAAY,CAAA;AACrC,EAAA,MAAM,GAAA,GAAM,WAAW,eAAe,CAAA;AAEtC,EAAA,OAAO,OAAA;AAAA,IACL,OAAO;AAAA,MACL,GAAG,KAAA;AAAA,MACH,GAAI,CAAC,CAAC,QAAA,IAAY,CAAC,CAAC,GAAA,GAChB;AAAA,QACE,QAAA,EAAU,eAAA,CAAgB,QAAA,EAAU,GAAG;AAAA,UAEzC;AAAC,KACP,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,QA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K,CAAC,CAAA;AAErB,EAAA,MAAM,EAAE,QAAA,EAAU,eAAA,EAAgB,GAAI,YAAA;AACtC,EAAA,MAAM,EAAE,QAAA,EAAU,WAAA,EAAY,GAAI,eAAA;AAElC,EAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAU,SAAA,EAAsB,OACnC,QAAA,kBAAA,GAAA,CAAC,eAAA,EAAA,EAAgB,KAAA,EAAO,KAAA,EACtB,8BAAC,WAAA,EAAA,EAAY,KAAA,EAAO,GAAA,EAAM,QAAA,EAAS,GACrC,CAAA,EACF,CAAA;AAEJ","file":"index.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 { useLayoutEffect } from '@react-aria/utils';\nimport { clsx } from 'clsx';\nimport { createContext, useContext, useMemo, useRef, useState } from 'react';\nimport {\n defaultElevations,\n defaultFocus,\n defaultGenericColors,\n defaultRadius,\n defaultSemanticColors,\n defaultSizes,\n defaultSpace,\n defaultTypography,\n defaultZIndex,\n} from '../../styles/theme.css';\nimport { computeContract } from '../../utils/css';\nimport { root } from './use-theme.css';\nimport type { Contract } from '../../types/vanilla-extract';\nimport type { ThemeContext, ThemeProviderProps } from './types';\n\nconst defaultTheme: ThemeContext = {};\nconst themeContext = createContext<ThemeContext>(defaultTheme);\nconst themeCssContext = createContext<CSSStyleDeclaration | null>(null);\n\n/**\n * Computes CSS values into DeckGL compatible formats using the optionally provided contract\n *\n * This function allows for the reuse of CSS contract tokens within React context for non-CSS\n * use cases. This ensures synchronized theming across the entire rendering stack\n *\n * @example\n * ```\n * import { genericColorVars, useTheme, type RGBA } from '@accelint/design-system';\n *\n * const theme = useTheme({\n * colors: {\n * generic: genericColorVars,\n * },\n * });\n *\n * new ArrowPathLayer({\n * id: 'layer-id',\n * // ...\n * getColor: theme.contract?.colors.generic.neutral.v01 as RGBA,\n * }),\n * ```\n */\nexport function useTheme<T extends Contract>(\n contract?: T,\n): ThemeContext & {\n contract?: ReturnType<typeof computeContract<T>>;\n} {\n const theme = useContext(themeContext);\n const css = useContext(themeCssContext);\n\n return useMemo(\n () => ({\n ...theme,\n ...(!!contract && !!css\n ? {\n contract: computeContract(contract, css),\n }\n : {}),\n }),\n [theme, contract, css],\n );\n}\n\nfunction localInheritOrDefault(\n localClass?: string,\n inherit?: boolean,\n defaultClass?: string,\n) {\n return localClass ?? (!inherit && defaultClass);\n}\n\nexport function ThemeProvider({\n children,\n className: classNameProp,\n inherit,\n style: styleProp,\n theme: themeProp = defaultTheme,\n vars,\n}: ThemeProviderProps) {\n const ref = useRef<HTMLDivElement>(null);\n const [css, setCss] = useState<CSSStyleDeclaration | null>(null);\n const parent = useTheme();\n\n const className = useMemo(\n () =>\n clsx(\n root,\n classNameProp,\n inherit && parent.className,\n themeProp.className,\n localInheritOrDefault(\n vars?.colors?.generic,\n inherit,\n defaultGenericColors,\n ),\n localInheritOrDefault(\n vars?.colors?.semantic,\n inherit,\n defaultSemanticColors,\n ),\n localInheritOrDefault(vars?.elevation, inherit, defaultElevations),\n localInheritOrDefault(vars?.focus, inherit, defaultFocus),\n localInheritOrDefault(vars?.radius, inherit, defaultRadius),\n localInheritOrDefault(vars?.sizes, inherit, defaultSizes),\n localInheritOrDefault(vars?.space, inherit, defaultSpace),\n localInheritOrDefault(vars?.typography, inherit, defaultTypography),\n localInheritOrDefault(vars?.zIndex, inherit, defaultZIndex),\n ),\n [\n classNameProp,\n inherit,\n parent.className,\n themeProp.className,\n vars?.colors?.generic,\n vars?.colors?.semantic,\n vars?.elevation,\n vars?.focus,\n vars?.radius,\n vars?.sizes,\n vars?.space,\n vars?.typography,\n vars?.zIndex,\n ],\n );\n\n const style = useMemo(\n () => ({\n ...(inherit ? parent.style : {}),\n ...themeProp.style,\n ...styleProp,\n }),\n [inherit, parent.style, themeProp.style, styleProp],\n );\n\n const theme = useMemo(\n () => ({\n ...(inherit ? parent : themeProp),\n className,\n style,\n }),\n [inherit, parent, themeProp, className, style],\n );\n\n useLayoutEffect(() => {\n if (ref.current) {\n setCss(window.getComputedStyle(ref.current));\n }\n }, [className, style]);\n\n const { Provider: ClassesProvider } = themeContext;\n const { Provider: CssProvider } = themeCssContext;\n\n return (\n <div ref={ref} className={className} style={style}>\n <ClassesProvider value={theme}>\n <CssProvider value={css}>{children}</CssProvider>\n </ClassesProvider>\n </div>\n );\n}\n"]}
|
|
@@ -28,11 +28,11 @@ import { TimeFieldClassNames } from '../../components/time-field/types.js';
|
|
|
28
28
|
import { TooltipClassNames } from '../../components/tooltip/types.js';
|
|
29
29
|
import { TreeClassNames } from '../../components/tree/types.js';
|
|
30
30
|
import 'react-aria-components';
|
|
31
|
+
import '../../types/generic.js';
|
|
31
32
|
import '../../types/props.js';
|
|
32
33
|
import '../../types/react-aria.js';
|
|
33
34
|
import '@react-types/shared';
|
|
34
35
|
import 'type-fest';
|
|
35
|
-
import '../../types/generic.js';
|
|
36
36
|
import '@react-stately/datepicker';
|
|
37
37
|
import '@react-aria/overlays';
|
|
38
38
|
import '@react-stately/overlays';
|
|
@@ -35,8 +35,9 @@ function useTree({
|
|
|
35
35
|
if (node.key === rootKey) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const currentNode = getItem2(node.key);
|
|
39
|
+
lookup2[node.key] = currentNode;
|
|
40
|
+
return currentNode;
|
|
40
41
|
}
|
|
41
42
|
);
|
|
42
43
|
if (allowsVisibility) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-tree/index.ts"],"names":["lookup","tree","getItem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U,CAAA;AAAA,YACnD,IAAA,CAAK;AAAA;AACP,SACF;AAAA,QACA,CAAC,EAAE,GAAA,EAAK,KAAA,EAAM,KAAM;AAClB,UAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,YAAA;AAAA,UACF;AAEA,UAAA,IAAI,CAAC,MAAM,UAAA,EAAY;AACrB,YAAA,MAAA,CAAO,GAAA,EAAK,EAAE,UAAA,EAAY,KAAA,CAAM,YAAY,CAAA;AAAA,UAC9C;AAAA,QACF;AAAA,OACF;AAAA,IACF,CAAA;AAAA,IACA,CAAC,gBAAA,EAAkB,IAAA,EAAM,OAAA,EAAS,MAAM;AAAA,GAC1C;AAEA,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,MAAM,EAAE,KAAA,EAAO,CAAA,EAAG,YAAA,EAAc,GAAG,MAAK,GAAI,IAAA;AAE5C,IAAA,OAAO;AAAA,MACL,OAAA,EAAS;AAAA,QACP,GAAG,IAAA;AAAA,QACH,OAAA;AAAA,QACA,gBAAA;AAAA,QACA,gBAAA;AAAA,QACA,gBAAA;AAAA,QACA,gBAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,eAAA;AAAA,MACA,gBAAA;AAAA,MACA,MAAA;AAAA,MACA,YAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF,CAAA,EAAG;AAAA,IACD,IAAA;AAAA,IACA,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH","file":"index.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 { useTreeData } from '@react-stately/data';\nimport type { Key } from '@react-types/shared';\nimport isEqual from 'lodash/isEqual';\nimport { useCallback, useId, useMemo, useRef } from 'react';\nimport type {\n TreeActions,\n TreeNode,\n TreeNodes,\n UseTreeOptions,\n UseTreeResult,\n} from '../../types/use-tree';\nimport { useUpdateEffect } from '../use-update-effect';\nimport { getChildren, getKey, mapTree, toggleVisibility } from './utils';\n\nexport function useTree<T>({\n allowsExpansion = true,\n allowsVisibility = false,\n nodes,\n selectionMode = 'none',\n onSelectionChange,\n onUpdate,\n}: UseTreeOptions<T>): UseTreeResult<T> {\n const rootKey = useId();\n\n const list = useTreeData({\n initialItems: nodes,\n getChildren,\n getKey,\n });\n\n useUpdateEffect(() => {\n if (selectionMode === 'none' && list.selectedKeys.size) {\n list.setSelectedKeys(new Set());\n }\n }, [selectionMode, list.selectedKeys.size]);\n\n /**\n * useTreeData doesn't update the state of TreeNode.value when updates\n * are made to children.\n *\n * Given the structure:\n * Foo\n * - Bar\n * - Cat\n *\n * There will be TreeNodes for each item, with a value that represents\n * the original node passed in. If an update occurs to one of the child\n * nodes (Bar, Cat), then Foo node's value is NOT updated to reflect that\n * change. This means that each node is the source of truth only for itself\n * and not any of its children.\n *\n * To provide a completely accurate tree, we need to override the getItem\n * and update methods, as well as replace the list.items with a tree that\n * is completely accurate at all times. This requires storing (depth first)\n * each node in a lookup, so that parent node's values can be updated to\n * reflect the current state of their children.\n */\n const { lookup, tree, getItem, update } = useMemo(() => {\n const lookup: Record<Key, TreeNode<T>> = {};\n\n let tree = mapTree(\n {\n key: rootKey,\n children: list.items,\n } as TreeNode<T>,\n (node) => {\n if (node.key === rootKey) {\n return;\n }\n\n node = lookup[node.key] = getItem(node.key);\n\n return node;\n },\n );\n\n if (allowsVisibility) {\n tree = mapTree(\n {\n key: rootKey,\n children: toggleVisibility(tree.children),\n } as TreeNode<T>,\n (node) => {\n if (node.key === rootKey) {\n return;\n }\n\n lookup[node.key] = node;\n\n return node;\n },\n );\n }\n\n function getItem(key: Key): TreeNode<T> {\n let node = lookup[key];\n\n if (node) {\n return node;\n }\n\n node = list.getItem(key) as TreeNode<T>;\n\n if (!node) {\n throw new Error(`Key of ${key} does not exist in tree`);\n }\n\n if ('nodes' in node.value) {\n return {\n ...node,\n value: {\n ...node.value,\n nodes: node.children.flatMap((child) => {\n const value = lookup[child.key]?.value;\n\n if (value) {\n return [value];\n }\n\n return [];\n }),\n },\n };\n }\n\n return node;\n }\n\n function update(key: Key, patch: Partial<TreeNodes<T>>) {\n const node = getItem(key);\n\n let value: TreeNode<T>['value'];\n\n if ('nodes' in node.value) {\n value = {\n ...node.value,\n ...patch,\n // Disallow a parent update to change child values\n nodes: node.children.flatMap((child) => {\n const value = lookup[child.key]?.value;\n\n if (value) {\n return [value];\n }\n\n return [];\n }),\n };\n } else {\n value = {\n ...node.value,\n ...patch,\n };\n }\n\n /**\n * We must immediately update the state of the lookup due to the\n * possibility of a queue of state changes and we can't allow for\n * a parent to update and wipe out a previous child update\n */\n lookup[key] = {\n ...node,\n value,\n };\n\n list.update(key, value);\n }\n\n return { lookup, tree, getItem, update };\n }, [rootKey, list, allowsVisibility]);\n\n const treeRef = useRef(tree);\n\n /**\n * Because tree is a computed value and there are so many methods\n * that update list.items, it's far simpler to fire the onUpdate\n * during the render cycle. However, this means that onUpdate can\n * only be used for side effect purposes and should not trigger\n * state updates\n */\n useUpdateEffect(() => {\n if (isEqual(treeRef.current, tree)) {\n return;\n }\n\n treeRef.current = tree;\n\n onUpdate?.(tree.children.map(({ value }) => value));\n }, [tree]);\n\n const previousExpansionValuesRef = useRef<\n {\n key: Key;\n patch: { isExpanded?: boolean };\n }[]\n >([]);\n\n const revertIsExpanded = useCallback(() => {\n if (!previousExpansionValuesRef.current.length) {\n return;\n }\n\n for (const { key, patch } of previousExpansionValuesRef.current) {\n update(key, patch);\n }\n\n previousExpansionValuesRef.current = [];\n }, [update]);\n\n const toggleIsExpanded = useCallback<TreeActions<T>['toggleIsExpanded']>(\n (selection = 'all', isExpanded = undefined, isRevertable = false) => {\n if (!(allowsExpansion || isRevertable)) {\n return;\n }\n\n if (!isRevertable) {\n previousExpansionValuesRef.current = [];\n }\n\n function toggle({ key, value }: TreeNode<T>) {\n if (key === rootKey || !('nodes' in value)) {\n return;\n }\n\n if (isRevertable) {\n previousExpansionValuesRef.current.push({\n key,\n patch: { isExpanded: value.isExpanded },\n });\n }\n\n update(key, { isExpanded: isExpanded ?? !value.isExpanded });\n }\n\n if (selection === 'all') {\n return mapTree(tree, toggle);\n }\n\n mapTree(tree, (node) => {\n if (!selection.has(node.key)) {\n return;\n }\n\n toggle(node);\n });\n },\n [allowsExpansion, tree, rootKey, update],\n );\n\n const toggleIsSelected = useCallback<TreeActions<T>['toggleIsSelected']>(\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO: refactor\n (selection = 'all', isSelected = undefined) => {\n if (\n selectionMode === 'none' ||\n (selectionMode === 'single' &&\n (selection === 'all' || selection.size > 1))\n ) {\n return;\n }\n\n const all = Object.values(lookup);\n\n let keys =\n selection === 'all' ? new Set(all.map(({ key }) => key)) : selection;\n\n if (isSelected != null) {\n keys = isSelected ? keys : new Set();\n\n list.setSelectedKeys(keys);\n\n return onSelectionChange?.(\n (selection === 'all' || keys.size === all.length) && isSelected\n ? 'all'\n : keys,\n );\n }\n\n keys = new Set([\n ...(selectionMode === 'multiple'\n ? [...list.selectedKeys].filter(\n (key) => !(selection as Set<Key>).has(key),\n )\n : []),\n ...[...keys].filter((key) => !list.selectedKeys.has(key)),\n ]);\n\n list.setSelectedKeys(keys);\n\n onSelectionChange?.(\n selection === 'all' && keys.size === all.length ? 'all' : keys,\n );\n },\n [selectionMode, lookup, list, onSelectionChange],\n );\n\n const toggleIsViewable = useCallback<TreeActions<T>['toggleIsViewable']>(\n (selection = 'all', isViewable = undefined) => {\n if (!allowsVisibility) {\n return;\n }\n\n if (selection === 'all') {\n return mapTree(tree, ({ key, value }) => {\n if (key === rootKey) {\n return;\n }\n\n if (!value.isReadOnly) {\n update(key, {\n isViewable: isViewable ?? !value.isViewable,\n });\n }\n });\n }\n\n mapTree(\n {\n key: rootKey,\n children: Array.from(selection).reduce(\n (acc, key) => toggleVisibility(acc, key, isViewable),\n tree.children,\n ),\n } as TreeNode<T>,\n ({ key, value }) => {\n if (key === rootKey) {\n return;\n }\n\n if (!value.isReadOnly) {\n update(key, { isViewable: value.isViewable });\n }\n },\n );\n },\n [allowsVisibility, tree, rootKey, update],\n );\n\n return useMemo(() => {\n const { items: _, selectedKeys, ...rest } = list;\n\n return {\n actions: {\n ...rest,\n getItem,\n revertIsExpanded,\n toggleIsExpanded,\n toggleIsSelected,\n toggleIsViewable,\n update,\n },\n allowsExpansion,\n allowsVisibility,\n lookup,\n selectedKeys,\n selectionMode,\n tree,\n };\n }, [\n list,\n allowsExpansion,\n allowsVisibility,\n lookup,\n selectionMode,\n tree,\n getItem,\n revertIsExpanded,\n toggleIsExpanded,\n toggleIsSelected,\n toggleIsViewable,\n update,\n ]);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-tree/index.ts"],"names":["lookup","tree","getItem","update","value"],"mappings":";;;;;;;AA0BO,SAAS,OAAA,CAAW;AAAA,EACzB,eAAA,GAAkB,IAAA;AAAA,EAClB,gBAAA,GAAmB,KAAA;AAAA,EACnB,KAAA;AAAA,EACA,aAAA,GAAgB,MAAA;AAAA,EAChB,iBAAA;AAAA,EACA;AACF,CAAA,EAAwC;AACtC,EAAA,MAAM,UAAU,KAAA,EAAM;AAEtB,EAAA,MAAM,OAAO,WAAA,CAAY;AAAA,IACvB,YAAA,EAAc,KAAA;AAAA,IACd,WAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,eAAA,CAAgB,MAAM;AACpB,IA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,EAAkB,IAAA,EAAM,OAAA,EAAS,MAAM;AAAA,GAC1C;AAEA,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,MAAM,EAAE,KAAA,EAAO,CAAA,EAAG,YAAA,EAAc,GAAG,MAAK,GAAI,IAAA;AAE5C,IAAA,OAAO;AAAA,MACL,OAAA,EAAS;AAAA,QACP,GAAG,IAAA;AAAA,QACH,OAAA;AAAA,QACA,gBAAA;AAAA,QACA,gBAAA;AAAA,QACA,gBAAA;AAAA,QACA,gBAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,eAAA;AAAA,MACA,gBAAA;AAAA,MACA,MAAA;AAAA,MACA,YAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF,CAAA,EAAG;AAAA,IACD,IAAA;AAAA,IACA,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH","file":"index.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 { useTreeData } from '@react-stately/data';\nimport isEqual from 'lodash/isEqual';\nimport { useCallback, useId, useMemo, useRef } from 'react';\nimport { useUpdateEffect } from '../use-update-effect';\nimport { getChildren, getKey, mapTree, toggleVisibility } from './utils';\nimport type { Key } from '@react-types/shared';\nimport type {\n TreeActions,\n TreeNode,\n TreeNodes,\n UseTreeOptions,\n UseTreeResult,\n} from '../../types/use-tree';\n\nexport function useTree<T>({\n allowsExpansion = true,\n allowsVisibility = false,\n nodes,\n selectionMode = 'none',\n onSelectionChange,\n onUpdate,\n}: UseTreeOptions<T>): UseTreeResult<T> {\n const rootKey = useId();\n\n const list = useTreeData({\n initialItems: nodes,\n getChildren,\n getKey,\n });\n\n useUpdateEffect(() => {\n if (selectionMode === 'none' && list.selectedKeys.size) {\n list.setSelectedKeys(new Set());\n }\n }, [selectionMode, list.selectedKeys.size]);\n\n /**\n * useTreeData doesn't update the state of TreeNode.value when updates\n * are made to children.\n *\n * Given the structure:\n * Foo\n * - Bar\n * - Cat\n *\n * There will be TreeNodes for each item, with a value that represents\n * the original node passed in. If an update occurs to one of the child\n * nodes (Bar, Cat), then Foo node's value is NOT updated to reflect that\n * change. This means that each node is the source of truth only for itself\n * and not any of its children.\n *\n * To provide a completely accurate tree, we need to override the getItem\n * and update methods, as well as replace the list.items with a tree that\n * is completely accurate at all times. This requires storing (depth first)\n * each node in a lookup, so that parent node's values can be updated to\n * reflect the current state of their children.\n */\n const { lookup, tree, getItem, update } = useMemo(() => {\n const lookup: Record<Key, TreeNode<T>> = {};\n\n let tree = mapTree(\n {\n key: rootKey,\n children: list.items,\n } as TreeNode<T>,\n (node) => {\n if (node.key === rootKey) {\n return;\n }\n\n const currentNode = getItem(node.key);\n lookup[node.key] = currentNode;\n\n return currentNode;\n },\n );\n\n if (allowsVisibility) {\n tree = mapTree(\n {\n key: rootKey,\n children: toggleVisibility(tree.children),\n } as TreeNode<T>,\n (node) => {\n if (node.key === rootKey) {\n return;\n }\n\n lookup[node.key] = node;\n\n return node;\n },\n );\n }\n\n function getItem(key: Key): TreeNode<T> {\n let node = lookup[key];\n\n if (node) {\n return node;\n }\n\n node = list.getItem(key) as TreeNode<T>;\n\n if (!node) {\n throw new Error(`Key of ${key} does not exist in tree`);\n }\n\n if ('nodes' in node.value) {\n return {\n ...node,\n value: {\n ...node.value,\n nodes: node.children.flatMap((child) => {\n const value = lookup[child.key]?.value;\n\n if (value) {\n return [value];\n }\n\n return [];\n }),\n },\n };\n }\n\n return node;\n }\n\n function update(key: Key, patch: Partial<TreeNodes<T>>) {\n const node = getItem(key);\n\n let value: TreeNode<T>['value'];\n\n if ('nodes' in node.value) {\n value = {\n ...node.value,\n ...patch,\n // Disallow a parent update to change child values\n nodes: node.children.flatMap((child) => {\n const value = lookup[child.key]?.value;\n\n if (value) {\n return [value];\n }\n\n return [];\n }),\n };\n } else {\n value = {\n ...node.value,\n ...patch,\n };\n }\n\n /**\n * We must immediately update the state of the lookup due to the\n * possibility of a queue of state changes and we can't allow for\n * a parent to update and wipe out a previous child update\n */\n lookup[key] = {\n ...node,\n value,\n };\n\n list.update(key, value);\n }\n\n return { lookup, tree, getItem, update };\n }, [rootKey, list, allowsVisibility]);\n\n const treeRef = useRef(tree);\n\n /**\n * Because tree is a computed value and there are so many methods\n * that update list.items, it's far simpler to fire the onUpdate\n * during the render cycle. However, this means that onUpdate can\n * only be used for side effect purposes and should not trigger\n * state updates\n */\n useUpdateEffect(() => {\n if (isEqual(treeRef.current, tree)) {\n return;\n }\n\n treeRef.current = tree;\n\n onUpdate?.(tree.children.map(({ value }) => value));\n }, [tree]);\n\n const previousExpansionValuesRef = useRef<\n {\n key: Key;\n patch: { isExpanded?: boolean };\n }[]\n >([]);\n\n const revertIsExpanded = useCallback(() => {\n if (!previousExpansionValuesRef.current.length) {\n return;\n }\n\n for (const { key, patch } of previousExpansionValuesRef.current) {\n update(key, patch);\n }\n\n previousExpansionValuesRef.current = [];\n }, [update]);\n\n const toggleIsExpanded = useCallback<TreeActions<T>['toggleIsExpanded']>(\n (selection = 'all', isExpanded = undefined, isRevertable = false) => {\n if (!(allowsExpansion || isRevertable)) {\n return;\n }\n\n if (!isRevertable) {\n previousExpansionValuesRef.current = [];\n }\n\n function toggle({ key, value }: TreeNode<T>) {\n if (key === rootKey || !('nodes' in value)) {\n return;\n }\n\n if (isRevertable) {\n previousExpansionValuesRef.current.push({\n key,\n patch: { isExpanded: value.isExpanded },\n });\n }\n\n update(key, { isExpanded: isExpanded ?? !value.isExpanded });\n }\n\n if (selection === 'all') {\n return mapTree(tree, toggle);\n }\n\n mapTree(tree, (node) => {\n if (!selection.has(node.key)) {\n return;\n }\n\n toggle(node);\n });\n },\n [allowsExpansion, tree, rootKey, update],\n );\n\n const toggleIsSelected = useCallback<TreeActions<T>['toggleIsSelected']>(\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO: refactor\n (selection = 'all', isSelected = undefined) => {\n if (\n selectionMode === 'none' ||\n (selectionMode === 'single' &&\n (selection === 'all' || selection.size > 1))\n ) {\n return;\n }\n\n const all = Object.values(lookup);\n\n let keys =\n selection === 'all' ? new Set(all.map(({ key }) => key)) : selection;\n\n if (isSelected != null) {\n keys = isSelected ? keys : new Set();\n\n list.setSelectedKeys(keys);\n\n return onSelectionChange?.(\n (selection === 'all' || keys.size === all.length) && isSelected\n ? 'all'\n : keys,\n );\n }\n\n keys = new Set([\n ...(selectionMode === 'multiple'\n ? [...list.selectedKeys].filter(\n (key) => !(selection as Set<Key>).has(key),\n )\n : []),\n ...[...keys].filter((key) => !list.selectedKeys.has(key)),\n ]);\n\n list.setSelectedKeys(keys);\n\n onSelectionChange?.(\n selection === 'all' && keys.size === all.length ? 'all' : keys,\n );\n },\n [selectionMode, lookup, list, onSelectionChange],\n );\n\n const toggleIsViewable = useCallback<TreeActions<T>['toggleIsViewable']>(\n (selection = 'all', isViewable = undefined) => {\n if (!allowsVisibility) {\n return;\n }\n\n if (selection === 'all') {\n return mapTree(tree, ({ key, value }) => {\n if (key === rootKey) {\n return;\n }\n\n if (!value.isReadOnly) {\n update(key, {\n isViewable: isViewable ?? !value.isViewable,\n });\n }\n });\n }\n\n mapTree(\n {\n key: rootKey,\n children: Array.from(selection).reduce(\n (acc, key) => toggleVisibility(acc, key, isViewable),\n tree.children,\n ),\n } as TreeNode<T>,\n ({ key, value }) => {\n if (key === rootKey) {\n return;\n }\n\n if (!value.isReadOnly) {\n update(key, { isViewable: value.isViewable });\n }\n },\n );\n },\n [allowsVisibility, tree, rootKey, update],\n );\n\n return useMemo(() => {\n const { items: _, selectedKeys, ...rest } = list;\n\n return {\n actions: {\n ...rest,\n getItem,\n revertIsExpanded,\n toggleIsExpanded,\n toggleIsSelected,\n toggleIsViewable,\n update,\n },\n allowsExpansion,\n allowsVisibility,\n lookup,\n selectedKeys,\n selectionMode,\n tree,\n };\n }, [\n list,\n allowsExpansion,\n allowsVisibility,\n lookup,\n selectionMode,\n tree,\n getItem,\n revertIsExpanded,\n toggleIsExpanded,\n toggleIsSelected,\n toggleIsViewable,\n update,\n ]);\n}\n"]}
|