@proyecto-viviana/solid-stately 0.2.7 → 0.4.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/README.md +30 -283
- package/dist/autocomplete/createAutocompleteState.d.ts +2 -2
- package/dist/autocomplete/index.d.ts +1 -1
- package/dist/calendar/IncompleteDate.d.ts +61 -0
- package/dist/calendar/createCalendarState.d.ts +41 -16
- package/dist/calendar/createDateFieldState.d.ts +39 -9
- package/dist/calendar/createDatePickerState.d.ts +60 -0
- package/dist/calendar/createRangeCalendarState.d.ts +37 -10
- package/dist/calendar/createTimeFieldState.d.ts +34 -7
- package/dist/calendar/index.d.ts +7 -6
- package/dist/checkbox/createCheckboxGroupState.d.ts +6 -6
- package/dist/checkbox/index.d.ts +1 -1
- package/dist/collections/ListCollection.d.ts +1 -1
- package/dist/collections/createListState.d.ts +11 -8
- package/dist/collections/createMenuState.d.ts +7 -7
- package/dist/collections/createSelectionState.d.ts +22 -10
- package/dist/collections/getChildNodes.d.ts +11 -0
- package/dist/collections/index.d.ts +6 -5
- package/dist/collections/types.d.ts +12 -12
- package/dist/color/Color.d.ts +1 -1
- package/dist/color/createColorAreaState.d.ts +4 -2
- package/dist/color/createColorFieldState.d.ts +38 -12
- package/dist/color/createColorSliderState.d.ts +9 -2
- package/dist/color/createColorWheelState.d.ts +13 -2
- package/dist/color/getColorChannels.d.ts +1 -1
- package/dist/color/index.d.ts +6 -6
- package/dist/color/types.d.ts +4 -4
- package/dist/combobox/createComboBoxState.d.ts +34 -13
- package/dist/combobox/index.d.ts +1 -1
- package/dist/data/createAsyncList.d.ts +4 -4
- package/dist/data/createListData.d.ts +2 -2
- package/dist/data/createTreeData.d.ts +6 -2
- package/dist/data/index.d.ts +3 -3
- package/dist/datepicker/index.d.ts +2 -4
- package/dist/disclosure/createDisclosureState.d.ts +2 -2
- package/dist/disclosure/index.d.ts +1 -1
- package/dist/dnd/createDragState.d.ts +2 -2
- package/dist/dnd/createDraggableCollectionState.d.ts +2 -2
- package/dist/dnd/createDropState.d.ts +2 -2
- package/dist/dnd/createDroppableCollectionState.d.ts +3 -3
- package/dist/dnd/index.d.ts +5 -5
- package/dist/dnd/types.d.ts +19 -17
- package/dist/form/createFormValidationState.d.ts +3 -3
- package/dist/form/index.d.ts +1 -1
- package/dist/grid/createGridState.d.ts +2 -2
- package/dist/grid/index.d.ts +2 -2
- package/dist/grid/types.d.ts +27 -11
- package/dist/index.d.ts +31 -30
- package/dist/index.js +9077 -7246
- package/dist/index.js.map +1 -1
- package/dist/menu/index.d.ts +2 -2
- package/dist/numberfield/createNumberFieldState.d.ts +2 -2
- package/dist/numberfield/index.d.ts +1 -1
- package/dist/overlays/createOverlayTriggerState.d.ts +2 -2
- package/dist/overlays/index.d.ts +1 -1
- package/dist/radio/createRadioGroupState.d.ts +7 -7
- package/dist/radio/index.d.ts +1 -1
- package/dist/searchfield/createSearchFieldState.d.ts +2 -2
- package/dist/searchfield/index.d.ts +2 -2
- package/dist/select/createSelectState.d.ts +14 -8
- package/dist/select/index.d.ts +1 -1
- package/dist/selection/Selection.d.ts +16 -0
- package/dist/selection/SelectionManager.d.ts +110 -0
- package/dist/selection/createMultipleSelectionState.d.ts +59 -0
- package/dist/selection/index.d.ts +6 -5
- package/dist/slider/createSliderState.d.ts +3 -3
- package/dist/slider/index.d.ts +2 -2
- package/dist/steplist/createStepListState.d.ts +48 -0
- package/dist/steplist/index.d.ts +1 -0
- package/dist/table/TableCollection.d.ts +33 -3
- package/dist/table/createTableColumnResizeState.d.ts +54 -0
- package/dist/table/createTableState.d.ts +2 -2
- package/dist/table/createTreeGridState.d.ts +15 -0
- package/dist/table/index.d.ts +6 -3
- package/dist/table/types.d.ts +68 -10
- package/dist/tabs/createTabListState.d.ts +5 -5
- package/dist/tabs/index.d.ts +1 -1
- package/dist/textfield/createTextFieldState.d.ts +2 -2
- package/dist/textfield/index.d.ts +1 -1
- package/dist/toast/createToastState.d.ts +24 -2
- package/dist/toast/index.d.ts +1 -1
- package/dist/toggle/createToggleGroupState.d.ts +4 -4
- package/dist/toggle/createToggleState.d.ts +2 -2
- package/dist/toggle/index.d.ts +2 -2
- package/dist/tooltip/createTooltipTriggerState.d.ts +2 -2
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tree/TreeCollection.d.ts +2 -2
- package/dist/tree/createTreeState.d.ts +2 -2
- package/dist/tree/index.d.ts +3 -3
- package/dist/tree/types.d.ts +27 -13
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/reactivity.d.ts +1 -1
- package/package.json +29 -30
- package/src/autocomplete/createAutocompleteState.d.ts +19 -17
- package/src/autocomplete/createAutocompleteState.ts +24 -30
- package/src/autocomplete/index.d.ts +6 -2
- package/src/autocomplete/index.ts +1 -1
- package/src/calendar/IncompleteDate.ts +430 -0
- package/src/calendar/createCalendarState.d.ts +139 -117
- package/src/calendar/createCalendarState.ts +308 -94
- package/src/calendar/createDateFieldState.d.ts +130 -95
- package/src/calendar/createDateFieldState.ts +447 -334
- package/src/calendar/createDatePickerState.ts +347 -0
- package/src/calendar/createRangeCalendarState.d.ts +154 -129
- package/src/calendar/createRangeCalendarState.ts +411 -85
- package/src/calendar/createTimeFieldState.d.ts +81 -79
- package/src/calendar/createTimeFieldState.ts +187 -108
- package/src/calendar/index.d.ts +80 -7
- package/src/calendar/index.ts +23 -12
- package/src/checkbox/createCheckboxGroupState.d.ts +57 -55
- package/src/checkbox/createCheckboxGroupState.ts +20 -29
- package/src/checkbox/index.d.ts +6 -2
- package/src/checkbox/index.ts +1 -1
- package/src/collections/ListCollection.d.ts +25 -22
- package/src/collections/ListCollection.ts +6 -6
- package/src/collections/createListState.d.ts +73 -58
- package/src/collections/createListState.ts +67 -35
- package/src/collections/createMenuState.d.ts +36 -31
- package/src/collections/createMenuState.ts +21 -12
- package/src/collections/createSelectionState.d.ts +78 -65
- package/src/collections/createSelectionState.ts +66 -52
- package/src/collections/getChildNodes.ts +98 -0
- package/src/collections/index.d.ts +38 -6
- package/src/collections/index.ts +14 -10
- package/src/collections/types.d.ts +101 -101
- package/src/collections/types.ts +12 -12
- package/src/color/Color.d.ts +20 -5
- package/src/color/Color.ts +357 -254
- package/src/color/createColorAreaState.d.ts +67 -65
- package/src/color/createColorAreaState.ts +21 -13
- package/src/color/createColorFieldState.d.ts +46 -44
- package/src/color/createColorFieldState.ts +285 -149
- package/src/color/createColorSliderState.d.ts +58 -56
- package/src/color/createColorSliderState.ts +45 -14
- package/src/color/createColorWheelState.d.ts +42 -40
- package/src/color/createColorWheelState.ts +101 -64
- package/src/color/getColorChannels.ts +7 -5
- package/src/color/index.d.ts +36 -7
- package/src/color/index.ts +6 -9
- package/src/color/types.d.ts +68 -63
- package/src/color/types.ts +11 -19
- package/src/combobox/createComboBoxState.d.ts +107 -105
- package/src/combobox/createComboBoxState.ts +184 -89
- package/src/combobox/index.d.ts +10 -2
- package/src/combobox/index.ts +1 -1
- package/src/data/createAsyncList.ts +89 -63
- package/src/data/createListData.ts +67 -67
- package/src/data/createTreeData.ts +304 -91
- package/src/data/index.ts +3 -3
- package/src/datepicker/index.ts +6 -10
- package/src/disclosure/createDisclosureState.d.ts +47 -43
- package/src/disclosure/createDisclosureState.ts +7 -21
- package/src/disclosure/index.d.ts +10 -2
- package/src/disclosure/index.ts +1 -1
- package/src/dnd/createDragState.d.ts +51 -42
- package/src/dnd/createDragState.ts +12 -14
- package/src/dnd/createDraggableCollectionState.d.ts +52 -41
- package/src/dnd/createDraggableCollectionState.ts +14 -21
- package/src/dnd/createDropState.d.ts +64 -45
- package/src/dnd/createDropState.ts +22 -32
- package/src/dnd/createDroppableCollectionState.d.ts +88 -59
- package/src/dnd/createDroppableCollectionState.ts +40 -43
- package/src/dnd/index.d.ts +55 -6
- package/src/dnd/index.ts +6 -18
- package/src/dnd/types.d.ts +170 -157
- package/src/dnd/types.ts +24 -22
- package/src/form/createFormValidationState.d.ts +47 -45
- package/src/form/createFormValidationState.ts +30 -63
- package/src/form/index.d.ts +16 -2
- package/src/form/index.ts +1 -1
- package/src/grid/createGridState.d.ts +7 -4
- package/src/grid/createGridState.ts +78 -51
- package/src/grid/index.d.ts +3 -3
- package/src/grid/index.ts +2 -8
- package/src/grid/types.d.ts +136 -129
- package/src/grid/types.ts +34 -18
- package/src/index.d.ts +311 -26
- package/src/index.ts +59 -89
- package/src/menu/index.ts +2 -4
- package/src/numberfield/createNumberFieldState.d.ts +56 -54
- package/src/numberfield/createNumberFieldState.ts +26 -31
- package/src/numberfield/index.d.ts +6 -2
- package/src/numberfield/index.ts +1 -1
- package/src/overlays/createOverlayTriggerState.d.ts +22 -20
- package/src/overlays/createOverlayTriggerState.ts +3 -4
- package/src/overlays/index.d.ts +6 -2
- package/src/overlays/index.ts +1 -1
- package/src/radio/createRadioGroupState.d.ts +54 -52
- package/src/radio/createRadioGroupState.ts +27 -29
- package/src/radio/index.d.ts +7 -2
- package/src/radio/index.ts +1 -1
- package/src/searchfield/createSearchFieldState.d.ts +16 -14
- package/src/searchfield/createSearchFieldState.ts +5 -11
- package/src/searchfield/index.d.ts +3 -3
- package/src/searchfield/index.ts +2 -5
- package/src/select/createSelectState.d.ts +63 -61
- package/src/select/createSelectState.ts +42 -29
- package/src/select/index.d.ts +2 -2
- package/src/select/index.ts +1 -5
- package/src/selection/Selection.ts +28 -0
- package/src/selection/SelectionManager.ts +526 -0
- package/src/selection/createMultipleSelectionState.ts +247 -0
- package/src/selection/index.ts +12 -7
- package/src/slider/createSliderState.d.ts +60 -60
- package/src/slider/createSliderState.ts +55 -33
- package/src/slider/index.d.ts +3 -3
- package/src/slider/index.ts +2 -6
- package/src/ssr/index.d.ts +1 -1
- package/src/ssr/index.ts +2 -2
- package/src/steplist/createStepListState.ts +191 -0
- package/src/steplist/index.ts +5 -0
- package/src/table/TableCollection.d.ts +42 -40
- package/src/table/TableCollection.ts +266 -99
- package/src/table/createTableColumnResizeState.ts +242 -0
- package/src/table/createTableState.d.ts +7 -4
- package/src/table/createTableState.ts +30 -7
- package/src/table/createTreeGridState.ts +146 -0
- package/src/table/index.d.ts +14 -4
- package/src/table/index.ts +13 -3
- package/src/table/types.d.ts +98 -92
- package/src/table/types.ts +83 -13
- package/src/tabs/createTabListState.d.ts +59 -57
- package/src/tabs/createTabListState.ts +34 -39
- package/src/tabs/index.d.ts +8 -2
- package/src/tabs/index.ts +1 -1
- package/src/textfield/createTextFieldState.d.ts +16 -14
- package/src/textfield/createTextFieldState.ts +7 -18
- package/src/textfield/index.d.ts +6 -2
- package/src/textfield/index.ts +1 -1
- package/src/toast/createToastState.d.ts +92 -86
- package/src/toast/createToastState.ts +90 -52
- package/src/toast/index.d.ts +12 -2
- package/src/toast/index.ts +2 -1
- package/src/toggle/createToggleGroupState.ts +11 -21
- package/src/toggle/createToggleState.d.ts +19 -19
- package/src/toggle/createToggleState.ts +2 -16
- package/src/toggle/index.d.ts +2 -2
- package/src/toggle/index.ts +2 -6
- package/src/tooltip/createTooltipTriggerState.d.ts +17 -17
- package/src/tooltip/createTooltipTriggerState.ts +12 -11
- package/src/tooltip/index.d.ts +7 -2
- package/src/tooltip/index.ts +1 -1
- package/src/tree/TreeCollection.d.ts +26 -23
- package/src/tree/TreeCollection.ts +29 -22
- package/src/tree/createTreeState.d.ts +7 -4
- package/src/tree/createTreeState.ts +70 -41
- package/src/tree/index.d.ts +10 -4
- package/src/tree/index.ts +3 -3
- package/src/tree/types.d.ts +131 -126
- package/src/tree/types.ts +30 -13
- package/src/utils/index.d.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/src/utils/reactivity.d.ts +2 -2
- package/src/utils/reactivity.ts +3 -3
package/src/tree/types.d.ts
CHANGED
|
@@ -2,156 +2,161 @@
|
|
|
2
2
|
* Tree collection types for Tree components.
|
|
3
3
|
* Based on @react-stately/tree.
|
|
4
4
|
*/
|
|
5
|
-
import type { Key, FocusStrategy } from
|
|
6
|
-
import type { GridNode, GridCollection } from
|
|
5
|
+
import type { Key, FocusStrategy } from "../collections/types";
|
|
6
|
+
import type { GridNode, GridCollection } from "../grid/types";
|
|
7
7
|
/**
|
|
8
8
|
* Represents a node in a tree collection.
|
|
9
9
|
* Extends GridNode with tree-specific properties.
|
|
10
10
|
*/
|
|
11
11
|
export interface TreeNode<T = unknown> extends GridNode<T> {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
/** Whether this node has child nodes that can be expanded. */
|
|
13
|
+
hasChildNodes: boolean;
|
|
14
|
+
/** Child nodes of this tree item. */
|
|
15
|
+
childNodes: TreeNode<T>[];
|
|
16
|
+
/** The level of nesting (0 for root items). */
|
|
17
|
+
level: number;
|
|
18
|
+
/** The key of the parent node, if any. */
|
|
19
|
+
parentKey?: Key | null;
|
|
20
|
+
/** Whether this node is expandable. */
|
|
21
|
+
isExpandable?: boolean;
|
|
22
|
+
/** Whether this node is currently expanded (only meaningful if expandable). */
|
|
23
|
+
isExpanded?: boolean;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* A collection of tree nodes with tree-specific navigation.
|
|
27
27
|
* Only includes visible nodes (respects expanded state).
|
|
28
28
|
*/
|
|
29
|
-
export interface TreeCollection<T = unknown> extends Omit<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
export interface TreeCollection<T = unknown> extends Omit<
|
|
30
|
+
GridCollection<T>,
|
|
31
|
+
"rows" | "columns" | "headerRows" | "columnCount" | "getCell"
|
|
32
|
+
> {
|
|
33
|
+
/** All visible rows in the tree (respects expanded state). */
|
|
34
|
+
readonly rows: TreeNode<T>[];
|
|
35
|
+
/** Number of visible rows. */
|
|
36
|
+
readonly rowCount: number;
|
|
37
|
+
/** Get all keys in the collection (visible only). */
|
|
38
|
+
getKeys(): Iterable<Key>;
|
|
39
|
+
/** Get a node by its key (any node, visible or not). */
|
|
40
|
+
getItem(key: Key): TreeNode<T> | null;
|
|
41
|
+
/** Get a node by index (visible nodes only). */
|
|
42
|
+
at(index: number): TreeNode<T> | null;
|
|
43
|
+
/** Get the key before the given key (visible nodes only). */
|
|
44
|
+
getKeyBefore(key: Key): Key | null;
|
|
45
|
+
/** Get the key after the given key (visible nodes only). */
|
|
46
|
+
getKeyAfter(key: Key): Key | null;
|
|
47
|
+
/** Get the first key in the collection. */
|
|
48
|
+
getFirstKey(): Key | null;
|
|
49
|
+
/** Get the last key in the collection. */
|
|
50
|
+
getLastKey(): Key | null;
|
|
51
|
+
/** Get the children of a node. */
|
|
52
|
+
getChildren(key: Key): Iterable<TreeNode<T>>;
|
|
53
|
+
/** Get the text value for a key. */
|
|
54
|
+
getTextValue(key: Key): string;
|
|
55
|
+
/** Get the parent key for a node. */
|
|
56
|
+
getParentKey(key: Key): Key | null;
|
|
57
|
+
/** Iterator over visible nodes. */
|
|
58
|
+
[Symbol.iterator](): Iterator<TreeNode<T>>;
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
61
|
* State for a tree component.
|
|
59
62
|
* Extends grid state with expansion management.
|
|
60
63
|
*/
|
|
61
64
|
export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
65
|
+
/** The tree collection (only visible nodes). */
|
|
66
|
+
readonly collection: C;
|
|
67
|
+
/** Keys of disabled items. */
|
|
68
|
+
readonly disabledKeys: Set<Key>;
|
|
69
|
+
/** Keys of expanded items. */
|
|
70
|
+
readonly expandedKeys: Set<Key>;
|
|
71
|
+
/** Whether keyboard navigation is disabled. */
|
|
72
|
+
readonly isKeyboardNavigationDisabled: boolean;
|
|
73
|
+
/** Currently focused key. */
|
|
74
|
+
readonly focusedKey: Key | null;
|
|
75
|
+
/** Focus strategy for child focus. */
|
|
76
|
+
readonly childFocusStrategy: FocusStrategy | null;
|
|
77
|
+
/** Whether the tree is focused. */
|
|
78
|
+
readonly isFocused: boolean;
|
|
79
|
+
/** The selection mode. */
|
|
80
|
+
readonly selectionMode: "none" | "single" | "multiple";
|
|
81
|
+
/** How selection behaves when pressing an item. */
|
|
82
|
+
readonly selectionBehavior: "toggle" | "replace";
|
|
83
|
+
/** The currently selected keys. */
|
|
84
|
+
readonly selectedKeys: "all" | Set<Key>;
|
|
85
|
+
/** Check if a key is selected. */
|
|
86
|
+
isSelected(key: Key): boolean;
|
|
87
|
+
/** Check if a key is disabled. */
|
|
88
|
+
isDisabled(key: Key): boolean;
|
|
89
|
+
/** Check if a key is expanded. */
|
|
90
|
+
isExpanded(key: Key): boolean;
|
|
91
|
+
/** Set the focused key. */
|
|
92
|
+
setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
|
|
93
|
+
/** Set focused state. */
|
|
94
|
+
setFocused(isFocused: boolean): void;
|
|
95
|
+
/** Toggle selection for a key. */
|
|
96
|
+
toggleSelection(key: Key): void;
|
|
97
|
+
/** Replace selection with a key. */
|
|
98
|
+
replaceSelection(key: Key): void;
|
|
99
|
+
/** Extend selection to a key (shift-click). */
|
|
100
|
+
extendSelection(toKey: Key): void;
|
|
101
|
+
/** Select all visible items. */
|
|
102
|
+
selectAll(): void;
|
|
103
|
+
/** Clear selection. */
|
|
104
|
+
clearSelection(): void;
|
|
105
|
+
/** Toggle select all. */
|
|
106
|
+
toggleSelectAll(): void;
|
|
107
|
+
/** Toggle expansion for a key. */
|
|
108
|
+
toggleKey(key: Key): void;
|
|
109
|
+
/** Expand a key. */
|
|
110
|
+
expandKey(key: Key): void;
|
|
111
|
+
/** Collapse a key. */
|
|
112
|
+
collapseKey(key: Key): void;
|
|
113
|
+
/** Set the expanded keys. */
|
|
114
|
+
setExpandedKeys(keys: Set<Key>): void;
|
|
115
|
+
/** Set keyboard navigation disabled. */
|
|
116
|
+
setKeyboardNavigationDisabled(isDisabled: boolean): void;
|
|
112
117
|
}
|
|
113
118
|
/**
|
|
114
119
|
* Options for creating tree state.
|
|
115
120
|
*/
|
|
116
121
|
export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollection<T>> {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
122
|
+
/** The tree collection builder - receives expanded keys and returns collection. */
|
|
123
|
+
collectionFactory: (expandedKeys: Set<Key>) => C;
|
|
124
|
+
/** Keys of disabled items. */
|
|
125
|
+
disabledKeys?: Iterable<Key>;
|
|
126
|
+
/** Disabled behavior: 'selection' only or 'all' interactions. */
|
|
127
|
+
disabledBehavior?: "selection" | "all";
|
|
128
|
+
/** Selection mode. */
|
|
129
|
+
selectionMode?: "none" | "single" | "multiple";
|
|
130
|
+
/** Selection behavior. */
|
|
131
|
+
selectionBehavior?: "toggle" | "replace";
|
|
132
|
+
/** Whether empty selection is disallowed. */
|
|
133
|
+
disallowEmptySelection?: boolean;
|
|
134
|
+
/** Currently selected keys (controlled). */
|
|
135
|
+
selectedKeys?: "all" | Iterable<Key>;
|
|
136
|
+
/** Default selected keys (uncontrolled). */
|
|
137
|
+
defaultSelectedKeys?: "all" | Iterable<Key>;
|
|
138
|
+
/** Handler for selection changes. */
|
|
139
|
+
onSelectionChange?: (keys: "all" | Set<Key>) => void;
|
|
140
|
+
/** Currently expanded keys (controlled). */
|
|
141
|
+
expandedKeys?: Iterable<Key>;
|
|
142
|
+
/** Default expanded keys (uncontrolled). */
|
|
143
|
+
defaultExpandedKeys?: Iterable<Key>;
|
|
144
|
+
/** Handler for expansion changes. */
|
|
145
|
+
onExpandedChange?: (keys: Set<Key>) => void;
|
|
141
146
|
}
|
|
142
147
|
/**
|
|
143
148
|
* Item representation for building tree collections.
|
|
144
149
|
*/
|
|
145
150
|
export interface TreeItemData<T = unknown> {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
/** Unique key for this item. */
|
|
152
|
+
key: Key;
|
|
153
|
+
/** The data value for this item. */
|
|
154
|
+
value: T;
|
|
155
|
+
/** Text content for accessibility and search. */
|
|
156
|
+
textValue?: string;
|
|
157
|
+
/** Child items (makes this item expandable). */
|
|
158
|
+
children?: TreeItemData<T>[];
|
|
159
|
+
/** Whether this item is disabled. */
|
|
160
|
+
isDisabled?: boolean;
|
|
156
161
|
}
|
|
157
|
-
//# sourceMappingURL=types.d.ts.map
|
|
162
|
+
//# sourceMappingURL=types.d.ts.map
|
package/src/tree/types.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Based on @react-stately/tree.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { Key, FocusStrategy } from
|
|
7
|
-
import type { GridNode, GridCollection } from
|
|
6
|
+
import type { Key, FocusStrategy, Selection, SelectionBehavior } from "../collections/types";
|
|
7
|
+
import type { GridNode, GridCollection } from "../grid/types";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Represents a node in a tree collection.
|
|
@@ -29,7 +29,10 @@ export interface TreeNode<T = unknown> extends GridNode<T> {
|
|
|
29
29
|
* A collection of tree nodes with tree-specific navigation.
|
|
30
30
|
* Only includes visible nodes (respects expanded state).
|
|
31
31
|
*/
|
|
32
|
-
export interface TreeCollection<T = unknown> extends Omit<
|
|
32
|
+
export interface TreeCollection<T = unknown> extends Omit<
|
|
33
|
+
GridCollection<T>,
|
|
34
|
+
"rows" | "columns" | "headerRows" | "columnCount" | "getCell"
|
|
35
|
+
> {
|
|
33
36
|
/** All visible rows in the tree (respects expanded state). */
|
|
34
37
|
readonly rows: TreeNode<T>[];
|
|
35
38
|
/** Number of visible rows. */
|
|
@@ -78,6 +81,8 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
|
|
|
78
81
|
readonly collection: C;
|
|
79
82
|
/** Keys of disabled items. */
|
|
80
83
|
readonly disabledKeys: Set<Key>;
|
|
84
|
+
/** Whether `disabledKeys` applies to all interactions, or only selection. */
|
|
85
|
+
readonly disabledBehavior: "selection" | "all";
|
|
81
86
|
/** Keys of expanded items. */
|
|
82
87
|
readonly expandedKeys: Set<Key>;
|
|
83
88
|
/** Whether keyboard navigation is disabled. */
|
|
@@ -89,9 +94,13 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
|
|
|
89
94
|
/** Whether the tree is focused. */
|
|
90
95
|
readonly isFocused: boolean;
|
|
91
96
|
/** The selection mode. */
|
|
92
|
-
readonly selectionMode:
|
|
97
|
+
readonly selectionMode: "none" | "single" | "multiple";
|
|
98
|
+
/** How selection behaves when pressing an item. */
|
|
99
|
+
readonly selectionBehavior: SelectionBehavior;
|
|
100
|
+
/** Whether empty selection is disallowed. */
|
|
101
|
+
readonly disallowEmptySelection: boolean;
|
|
93
102
|
/** The currently selected keys. */
|
|
94
|
-
readonly selectedKeys:
|
|
103
|
+
readonly selectedKeys: Selection;
|
|
95
104
|
|
|
96
105
|
/** Check if a key is selected. */
|
|
97
106
|
isSelected(key: Key): boolean;
|
|
@@ -107,6 +116,10 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
|
|
|
107
116
|
toggleSelection(key: Key): void;
|
|
108
117
|
/** Replace selection with a key. */
|
|
109
118
|
replaceSelection(key: Key): void;
|
|
119
|
+
/** Set the selected keys directly. */
|
|
120
|
+
setSelectedKeys(keys: Selection | Iterable<Key>): void;
|
|
121
|
+
/** Set how selection behaves when pressing an item. */
|
|
122
|
+
setSelectionBehavior(behavior: SelectionBehavior): void;
|
|
110
123
|
/** Extend selection to a key (shift-click). */
|
|
111
124
|
extendSelection(toKey: Key): void;
|
|
112
125
|
/** Select all visible items. */
|
|
@@ -136,19 +149,19 @@ export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollectio
|
|
|
136
149
|
/** Keys of disabled items. */
|
|
137
150
|
disabledKeys?: Iterable<Key>;
|
|
138
151
|
/** Disabled behavior: 'selection' only or 'all' interactions. */
|
|
139
|
-
disabledBehavior?:
|
|
152
|
+
disabledBehavior?: "selection" | "all";
|
|
140
153
|
/** Selection mode. */
|
|
141
|
-
selectionMode?:
|
|
154
|
+
selectionMode?: "none" | "single" | "multiple";
|
|
142
155
|
/** Selection behavior. */
|
|
143
|
-
selectionBehavior?:
|
|
156
|
+
selectionBehavior?: SelectionBehavior;
|
|
144
157
|
/** Whether empty selection is disallowed. */
|
|
145
158
|
disallowEmptySelection?: boolean;
|
|
146
159
|
/** Currently selected keys (controlled). */
|
|
147
|
-
selectedKeys?:
|
|
160
|
+
selectedKeys?: Selection | Iterable<Key>;
|
|
148
161
|
/** Default selected keys (uncontrolled). */
|
|
149
|
-
defaultSelectedKeys?:
|
|
162
|
+
defaultSelectedKeys?: Selection | Iterable<Key>;
|
|
150
163
|
/** Handler for selection changes. */
|
|
151
|
-
onSelectionChange?: (keys:
|
|
164
|
+
onSelectionChange?: (keys: "all" | Set<Key>) => void;
|
|
152
165
|
/** Currently expanded keys (controlled). */
|
|
153
166
|
expandedKeys?: Iterable<Key>;
|
|
154
167
|
/** Default expanded keys (uncontrolled). */
|
|
@@ -162,13 +175,17 @@ export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollectio
|
|
|
162
175
|
*/
|
|
163
176
|
export interface TreeItemData<T = unknown> {
|
|
164
177
|
/** Unique key for this item. */
|
|
165
|
-
key
|
|
178
|
+
key?: Key;
|
|
179
|
+
/** S2/React Aria-compatible unique id alias. */
|
|
180
|
+
id?: Key;
|
|
166
181
|
/** The data value for this item. */
|
|
167
|
-
value
|
|
182
|
+
value?: T;
|
|
168
183
|
/** Text content for accessibility and search. */
|
|
169
184
|
textValue?: string;
|
|
170
185
|
/** Child items (makes this item expandable). */
|
|
171
186
|
children?: TreeItemData<T>[];
|
|
187
|
+
/** Whether this item has children that may not be loaded yet. */
|
|
188
|
+
hasChildItems?: boolean;
|
|
172
189
|
/** Whether this item is disabled. */
|
|
173
190
|
isDisabled?: boolean;
|
|
174
191
|
}
|
package/src/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from "./reactivity";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
package/src/utils/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from
|
|
1
|
+
export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from "./reactivity";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides type-safe utilities for working with SolidJS reactivity patterns.
|
|
5
5
|
*/
|
|
6
|
-
import { Accessor } from
|
|
6
|
+
import { Accessor } from "solid-js";
|
|
7
7
|
/**
|
|
8
8
|
* A value that may be either a raw value or an accessor function.
|
|
9
9
|
* This is a common pattern in SolidJS for props that may be reactive.
|
|
@@ -25,4 +25,4 @@ export type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;
|
|
|
25
25
|
* Checks if a value is an accessor function.
|
|
26
26
|
*/
|
|
27
27
|
export declare function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T>;
|
|
28
|
-
//# sourceMappingURL=reactivity.d.ts.map
|
|
28
|
+
//# sourceMappingURL=reactivity.d.ts.map
|
package/src/utils/reactivity.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides type-safe utilities for working with SolidJS reactivity patterns.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Accessor } from
|
|
7
|
+
import { Accessor } from "solid-js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* A value that may be either a raw value or an accessor function.
|
|
@@ -20,7 +20,7 @@ export type MaybeAccessor<T> = T | Accessor<T>;
|
|
|
20
20
|
* @param value - The value or accessor to unwrap.
|
|
21
21
|
*/
|
|
22
22
|
export function access<T>(value: MaybeAccessor<T>): T {
|
|
23
|
-
return typeof value ===
|
|
23
|
+
return typeof value === "function" ? (value as Accessor<T>)() : value;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -32,5 +32,5 @@ export type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;
|
|
|
32
32
|
* Checks if a value is an accessor function.
|
|
33
33
|
*/
|
|
34
34
|
export function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T> {
|
|
35
|
-
return typeof value ===
|
|
35
|
+
return typeof value === "function";
|
|
36
36
|
}
|