@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/table/types.d.ts
CHANGED
|
@@ -2,138 +2,144 @@
|
|
|
2
2
|
* Table state types for Table components.
|
|
3
3
|
* Based on @react-stately/table and @react-types/table.
|
|
4
4
|
*/
|
|
5
|
-
import type { Key } from
|
|
6
|
-
import type { GridState, GridCollection, GridNode } from
|
|
5
|
+
import type { Key } from "../collections/types";
|
|
6
|
+
import type { GridState, GridCollection, GridNode } from "../grid/types";
|
|
7
7
|
/**
|
|
8
8
|
* Sort direction for table columns.
|
|
9
9
|
*/
|
|
10
|
-
export type SortDirection =
|
|
10
|
+
export type SortDirection = "ascending" | "descending";
|
|
11
11
|
/**
|
|
12
12
|
* Describes which column to sort by and in what direction.
|
|
13
13
|
*/
|
|
14
14
|
export interface SortDescriptor {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
/** The key of the column to sort by. */
|
|
16
|
+
column: Key;
|
|
17
|
+
/** The direction to sort by. */
|
|
18
|
+
direction: SortDirection;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Interface for sortable components.
|
|
22
22
|
*/
|
|
23
23
|
export interface Sortable {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
/** The current sorted column and direction. */
|
|
25
|
+
sortDescriptor?: SortDescriptor;
|
|
26
|
+
/** Handler that is called when the sorted column or direction changes. */
|
|
27
|
+
onSortChange?: (descriptor: SortDescriptor) => void;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* A collection of table rows and columns.
|
|
31
31
|
* Extends GridCollection with table-specific metadata.
|
|
32
32
|
*/
|
|
33
33
|
export interface TableCollection<T = unknown> extends GridCollection<T> {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
/** A list of header row nodes in the table. */
|
|
35
|
+
readonly headerRows: GridNode<T>[];
|
|
36
|
+
/** A list of column nodes in the table. */
|
|
37
|
+
readonly columns: GridNode<T>[];
|
|
38
|
+
/** A set of column keys that serve as the row header. */
|
|
39
|
+
readonly rowHeaderColumnKeys: Set<Key>;
|
|
40
|
+
/** The node that makes up the header of the table. */
|
|
41
|
+
readonly head?: GridNode<T>;
|
|
42
|
+
/** The node that makes up the body of the table. */
|
|
43
|
+
readonly body: GridNode<T>;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* State for a table component.
|
|
47
47
|
* Extends GridState with table-specific functionality.
|
|
48
48
|
*/
|
|
49
|
-
export interface TableState<T, C extends TableCollection<T> = TableCollection<T>> extends Omit<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
export interface TableState<T, C extends TableCollection<T> = TableCollection<T>> extends Omit<
|
|
50
|
+
GridState<T, GridCollection<T>>,
|
|
51
|
+
"collection"
|
|
52
|
+
> {
|
|
53
|
+
/** The table collection. */
|
|
54
|
+
readonly collection: C;
|
|
55
|
+
/** Whether the row selection checkboxes should be displayed. */
|
|
56
|
+
readonly showSelectionCheckboxes: boolean;
|
|
57
|
+
/** The current sorted column and direction. */
|
|
58
|
+
readonly sortDescriptor: SortDescriptor | null;
|
|
59
|
+
/** Sort by the given column and direction. */
|
|
60
|
+
sort(columnKey: Key, direction?: SortDirection): void;
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
60
63
|
* Options for creating table state.
|
|
61
64
|
*/
|
|
62
|
-
export interface TableStateOptions<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
65
|
+
export interface TableStateOptions<
|
|
66
|
+
T,
|
|
67
|
+
C extends TableCollection<T> = TableCollection<T>,
|
|
68
|
+
> extends Sortable {
|
|
69
|
+
/** The table collection. */
|
|
70
|
+
collection: C;
|
|
71
|
+
/** Keys of disabled rows. */
|
|
72
|
+
disabledKeys?: Iterable<Key>;
|
|
73
|
+
/** Focus mode: 'row' or 'cell'. */
|
|
74
|
+
focusMode?: "row" | "cell";
|
|
75
|
+
/** Selection mode. */
|
|
76
|
+
selectionMode?: "none" | "single" | "multiple";
|
|
77
|
+
/** Selection behavior. */
|
|
78
|
+
selectionBehavior?: "toggle" | "replace";
|
|
79
|
+
/** Whether empty selection is disallowed. */
|
|
80
|
+
disallowEmptySelection?: boolean;
|
|
81
|
+
/** Currently selected keys (controlled). */
|
|
82
|
+
selectedKeys?: "all" | Iterable<Key>;
|
|
83
|
+
/** Default selected keys (uncontrolled). */
|
|
84
|
+
defaultSelectedKeys?: "all" | Iterable<Key>;
|
|
85
|
+
/** Handler for selection changes. */
|
|
86
|
+
onSelectionChange?: (keys: "all" | Set<Key>) => void;
|
|
87
|
+
/** Whether the row selection checkboxes should be displayed. */
|
|
88
|
+
showSelectionCheckboxes?: boolean;
|
|
83
89
|
}
|
|
84
90
|
/**
|
|
85
91
|
* Column definition for building table collections.
|
|
86
92
|
*/
|
|
87
93
|
export interface ColumnDefinition<T = unknown> {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
/** The key for the column. */
|
|
95
|
+
key: Key;
|
|
96
|
+
/** The display name or rendered content. */
|
|
97
|
+
name?: string;
|
|
98
|
+
/** Text value for accessibility. */
|
|
99
|
+
textValue?: string;
|
|
100
|
+
/** Whether this column is a row header. */
|
|
101
|
+
isRowHeader?: boolean;
|
|
102
|
+
/** Whether this column allows sorting. */
|
|
103
|
+
allowsSorting?: boolean;
|
|
104
|
+
/** Child columns (for column groups). */
|
|
105
|
+
children?: ColumnDefinition<T>[];
|
|
106
|
+
/** Width of the column. */
|
|
107
|
+
width?: number | string;
|
|
108
|
+
/** Minimum width of the column. */
|
|
109
|
+
minWidth?: number;
|
|
110
|
+
/** Maximum width of the column. */
|
|
111
|
+
maxWidth?: number;
|
|
106
112
|
}
|
|
107
113
|
/**
|
|
108
114
|
* Row definition for building table collections.
|
|
109
115
|
*/
|
|
110
116
|
export interface RowDefinition<T = unknown> {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
/** The key for the row. */
|
|
118
|
+
key: Key;
|
|
119
|
+
/** The data value for the row. */
|
|
120
|
+
value: T;
|
|
121
|
+
/** Text value for accessibility/search. */
|
|
122
|
+
textValue?: string;
|
|
123
|
+
/** Whether this row has child rows (for tree tables). */
|
|
124
|
+
hasChildRows?: boolean;
|
|
125
|
+
/** Child rows (for tree tables). */
|
|
126
|
+
childRows?: RowDefinition<T>[];
|
|
121
127
|
}
|
|
122
128
|
/**
|
|
123
129
|
* Options for building a table collection.
|
|
124
130
|
*/
|
|
125
131
|
export interface TableCollectionOptions<T = unknown> {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
/** Column definitions. */
|
|
133
|
+
columns: ColumnDefinition<T>[];
|
|
134
|
+
/** Row definitions or data items. */
|
|
135
|
+
rows: RowDefinition<T>[] | T[];
|
|
136
|
+
/** Function to get the key from a data item. */
|
|
137
|
+
getKey?: (item: T) => Key;
|
|
138
|
+
/** Function to get the text value from a data item. */
|
|
139
|
+
getTextValue?: (item: T, column: ColumnDefinition<T>) => string;
|
|
140
|
+
/** Whether to show selection checkboxes. */
|
|
141
|
+
showSelectionCheckboxes?: boolean;
|
|
142
|
+
/** Set of column keys that serve as row headers. */
|
|
143
|
+
rowHeaderColumnKeys?: Set<Key>;
|
|
138
144
|
}
|
|
139
|
-
//# sourceMappingURL=types.d.ts.map
|
|
145
|
+
//# sourceMappingURL=types.d.ts.map
|
package/src/table/types.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Based on @react-stately/table and @react-types/table.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { Key, FocusStrategy } from
|
|
7
|
-
import type { GridState, GridCollection, GridNode, GridNodeType } from
|
|
6
|
+
import type { Key, FocusStrategy } from "../collections/types";
|
|
7
|
+
import type { GridState, GridCollection, GridNode, GridNodeType } from "../grid/types";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Sort direction for table columns.
|
|
11
11
|
*/
|
|
12
|
-
export type SortDirection =
|
|
12
|
+
export type SortDirection = "ascending" | "descending";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Describes which column to sort by and in what direction.
|
|
@@ -46,14 +46,18 @@ export interface TableCollection<T = unknown> extends GridCollection<T> {
|
|
|
46
46
|
readonly head?: GridNode<T>;
|
|
47
47
|
/** The node that makes up the body of the table. */
|
|
48
48
|
readonly body: GridNode<T>;
|
|
49
|
+
/** The key of the column that renders the tree-grid expand/collapse affordance, if any. */
|
|
50
|
+
readonly treeColumn?: Key | null;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/**
|
|
52
54
|
* State for a table component.
|
|
53
55
|
* Extends GridState with table-specific functionality.
|
|
54
56
|
*/
|
|
55
|
-
export interface TableState<T, C extends TableCollection<T> = TableCollection<T>>
|
|
56
|
-
|
|
57
|
+
export interface TableState<T, C extends TableCollection<T> = TableCollection<T>> extends Omit<
|
|
58
|
+
GridState<T, GridCollection<T>>,
|
|
59
|
+
"collection"
|
|
60
|
+
> {
|
|
57
61
|
/** The table collection. */
|
|
58
62
|
readonly collection: C;
|
|
59
63
|
/** Whether the row selection checkboxes should be displayed. */
|
|
@@ -62,31 +66,88 @@ export interface TableState<T, C extends TableCollection<T> = TableCollection<T>
|
|
|
62
66
|
readonly sortDescriptor: SortDescriptor | null;
|
|
63
67
|
/** Sort by the given column and direction. */
|
|
64
68
|
sort(columnKey: Key, direction?: SortDirection): void;
|
|
69
|
+
/**
|
|
70
|
+
* The set of expanded row keys for tree grids. A plain table reports an empty set.
|
|
71
|
+
*/
|
|
72
|
+
readonly expandedKeys: "all" | Set<Key>;
|
|
73
|
+
/**
|
|
74
|
+
* The key of the column that renders the expand/collapse affordance, or `null` for a
|
|
75
|
+
* plain (non-tree) table.
|
|
76
|
+
*/
|
|
77
|
+
readonly treeColumn: Key | null;
|
|
78
|
+
/** Toggles the expanded state of a row by its key (no-op for a plain table). */
|
|
79
|
+
toggleKey(key: Key): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* State for a tree grid (expandable rows). Mirrors `@react-stately/table`'s
|
|
84
|
+
* `UNSTABLE_useTreeGridState` return value.
|
|
85
|
+
*/
|
|
86
|
+
export interface TreeGridState<
|
|
87
|
+
T,
|
|
88
|
+
C extends TableCollection<T> = TableCollection<T>,
|
|
89
|
+
> extends TableState<T, C> {
|
|
90
|
+
/** A set of keys for rows that are expanded. */
|
|
91
|
+
readonly expandedKeys: "all" | Set<Key>;
|
|
92
|
+
/** The key map containing nodes representing the collection's tree grid structure. */
|
|
93
|
+
readonly keyMap: Map<Key, GridNode<T>>;
|
|
94
|
+
/** The number of leaf columns provided by the user (excludes selection/drag columns). */
|
|
95
|
+
readonly userColumnCount: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Options for creating tree grid state. Mirrors `TreeGridStateProps` upstream; the
|
|
100
|
+
* expansion props keep the `UNSTABLE_` prefix while the feature is unstable.
|
|
101
|
+
*/
|
|
102
|
+
export interface TreeGridStateOptions<
|
|
103
|
+
T,
|
|
104
|
+
C extends TableCollection<T> = TableCollection<T>,
|
|
105
|
+
> extends Omit<TableStateOptions<T, C>, "collection"> {
|
|
106
|
+
/** Column definitions. */
|
|
107
|
+
columns: ColumnDefinition<T>[];
|
|
108
|
+
/** Row definitions (may contain `childRows` for nested rows). */
|
|
109
|
+
rows: RowDefinition<T>[];
|
|
110
|
+
/** Function to get the key from a data item. */
|
|
111
|
+
getKey?: (item: T) => Key;
|
|
112
|
+
/** Function to get the text value from a data item. */
|
|
113
|
+
getTextValue?: (item: T, column: ColumnDefinition<T>) => string;
|
|
114
|
+
/** Set of column keys that serve as row headers. */
|
|
115
|
+
rowHeaderColumnKeys?: Set<Key>;
|
|
116
|
+
/** The currently expanded keys in the collection (controlled). */
|
|
117
|
+
UNSTABLE_expandedKeys?: "all" | Iterable<Key>;
|
|
118
|
+
/** The initial expanded keys in the collection (uncontrolled). */
|
|
119
|
+
UNSTABLE_defaultExpandedKeys?: "all" | Iterable<Key>;
|
|
120
|
+
/** Handler that is called when rows are expanded or collapsed. */
|
|
121
|
+
UNSTABLE_onExpandedChange?: (keys: Set<Key>) => void;
|
|
65
122
|
}
|
|
66
123
|
|
|
67
124
|
/**
|
|
68
125
|
* Options for creating table state.
|
|
69
126
|
*/
|
|
70
|
-
export interface TableStateOptions<
|
|
71
|
-
|
|
127
|
+
export interface TableStateOptions<
|
|
128
|
+
T,
|
|
129
|
+
C extends TableCollection<T> = TableCollection<T>,
|
|
130
|
+
> extends Sortable {
|
|
72
131
|
/** The table collection. */
|
|
73
132
|
collection: C;
|
|
74
133
|
/** Keys of disabled rows. */
|
|
75
134
|
disabledKeys?: Iterable<Key>;
|
|
135
|
+
/** Whether `disabledKeys` applies to all interactions, or only selection. @default "all" */
|
|
136
|
+
disabledBehavior?: "selection" | "all";
|
|
76
137
|
/** Focus mode: 'row' or 'cell'. */
|
|
77
|
-
focusMode?:
|
|
138
|
+
focusMode?: "row" | "cell";
|
|
78
139
|
/** Selection mode. */
|
|
79
|
-
selectionMode?:
|
|
140
|
+
selectionMode?: "none" | "single" | "multiple";
|
|
80
141
|
/** Selection behavior. */
|
|
81
|
-
selectionBehavior?:
|
|
142
|
+
selectionBehavior?: "toggle" | "replace";
|
|
82
143
|
/** Whether empty selection is disallowed. */
|
|
83
144
|
disallowEmptySelection?: boolean;
|
|
84
145
|
/** Currently selected keys (controlled). */
|
|
85
|
-
selectedKeys?:
|
|
146
|
+
selectedKeys?: "all" | Iterable<Key>;
|
|
86
147
|
/** Default selected keys (uncontrolled). */
|
|
87
|
-
defaultSelectedKeys?:
|
|
148
|
+
defaultSelectedKeys?: "all" | Iterable<Key>;
|
|
88
149
|
/** Handler for selection changes. */
|
|
89
|
-
onSelectionChange?: (keys:
|
|
150
|
+
onSelectionChange?: (keys: "all" | Set<Key>) => void;
|
|
90
151
|
/** Whether the row selection checkboxes should be displayed. */
|
|
91
152
|
showSelectionCheckboxes?: boolean;
|
|
92
153
|
}
|
|
@@ -147,4 +208,13 @@ export interface TableCollectionOptions<T = unknown> {
|
|
|
147
208
|
showSelectionCheckboxes?: boolean;
|
|
148
209
|
/** Set of column keys that serve as row headers. */
|
|
149
210
|
rowHeaderColumnKeys?: Set<Key>;
|
|
211
|
+
/**
|
|
212
|
+
* The set of expanded row keys. Passing this (even an empty set) builds the collection
|
|
213
|
+
* in tree-grid mode: `childRows` are walked recursively, only rows whose ancestors are
|
|
214
|
+
* all expanded are flattened into the navigable body, and {@link TableCollection.treeColumn}
|
|
215
|
+
* resolves to a real column. Omit it for a plain (non-tree) table.
|
|
216
|
+
*/
|
|
217
|
+
expandedKeys?: "all" | Set<Key>;
|
|
218
|
+
/** Explicit tree column key. Defaults to the first row-header column in tree-grid mode. */
|
|
219
|
+
treeColumn?: Key | null;
|
|
150
220
|
}
|
|
@@ -2,67 +2,69 @@
|
|
|
2
2
|
* State management for tab components.
|
|
3
3
|
* Based on @react-stately/tabs.
|
|
4
4
|
*/
|
|
5
|
-
import { type Accessor } from
|
|
6
|
-
import { type MaybeAccessor } from
|
|
7
|
-
import type { Collection, CollectionNode, Key, FocusStrategy } from
|
|
8
|
-
export type KeyboardActivation =
|
|
9
|
-
export type TabOrientation =
|
|
5
|
+
import { type Accessor } from "solid-js";
|
|
6
|
+
import { type MaybeAccessor } from "../utils";
|
|
7
|
+
import type { Collection, CollectionNode, Key, FocusStrategy } from "../collections/types";
|
|
8
|
+
export type KeyboardActivation = "automatic" | "manual";
|
|
9
|
+
export type TabOrientation = "horizontal" | "vertical";
|
|
10
10
|
export interface TabListStateProps<T = unknown> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
/** The items in the tab list. */
|
|
12
|
+
items?: T[];
|
|
13
|
+
/** Function to get a key from an item. */
|
|
14
|
+
getKey?: (item: T) => Key;
|
|
15
|
+
/** Function to get text value from an item. */
|
|
16
|
+
getTextValue?: (item: T) => string;
|
|
17
|
+
/** Function to check if an item is disabled. */
|
|
18
|
+
getDisabled?: (item: T) => boolean;
|
|
19
|
+
/** Keys of disabled tabs. */
|
|
20
|
+
disabledKeys?: Iterable<Key>;
|
|
21
|
+
/** The currently selected tab key (controlled). */
|
|
22
|
+
selectedKey?: Key | null;
|
|
23
|
+
/** The default selected tab key (uncontrolled). */
|
|
24
|
+
defaultSelectedKey?: Key;
|
|
25
|
+
/** Handler for tab selection changes. */
|
|
26
|
+
onSelectionChange?: (key: Key) => void;
|
|
27
|
+
/** Whether the entire tab list is disabled. */
|
|
28
|
+
isDisabled?: boolean;
|
|
29
|
+
/** Whether tabs are activated automatically on focus or manually. */
|
|
30
|
+
keyboardActivation?: KeyboardActivation;
|
|
31
|
+
/** The orientation of the tab list. */
|
|
32
|
+
orientation?: TabOrientation;
|
|
33
33
|
}
|
|
34
34
|
export interface TabListState<T = unknown> {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
35
|
+
/** The collection of tabs. */
|
|
36
|
+
readonly collection: Accessor<Collection<T>>;
|
|
37
|
+
/** The currently selected tab key. */
|
|
38
|
+
readonly selectedKey: Accessor<Key | null>;
|
|
39
|
+
/** Set the selected tab key. */
|
|
40
|
+
setSelectedKey(key: Key): void;
|
|
41
|
+
/** The currently selected tab item. */
|
|
42
|
+
readonly selectedItem: Accessor<CollectionNode<T> | null>;
|
|
43
|
+
/** Whether the tab list is disabled. */
|
|
44
|
+
readonly isDisabled: Accessor<boolean>;
|
|
45
|
+
/** The keyboard activation mode. */
|
|
46
|
+
readonly keyboardActivation: Accessor<KeyboardActivation>;
|
|
47
|
+
/** The orientation of the tab list. */
|
|
48
|
+
readonly orientation: Accessor<TabOrientation>;
|
|
49
|
+
/** Whether a tab key is disabled. */
|
|
50
|
+
isKeyDisabled(key: Key): boolean;
|
|
51
|
+
/** The set of disabled keys. */
|
|
52
|
+
readonly disabledKeys: Accessor<Set<Key>>;
|
|
53
|
+
/** Whether the collection is focused. */
|
|
54
|
+
readonly isFocused: Accessor<boolean>;
|
|
55
|
+
/** Set the focused state. */
|
|
56
|
+
setFocused(isFocused: boolean): void;
|
|
57
|
+
/** The currently focused tab key. */
|
|
58
|
+
readonly focusedKey: Accessor<Key | null>;
|
|
59
|
+
/** Set the focused tab key. */
|
|
60
|
+
setFocusedKey(key: Key | null, childStrategy?: FocusStrategy): void;
|
|
61
|
+
/** The child focus strategy. */
|
|
62
|
+
readonly childFocusStrategy: Accessor<FocusStrategy | null>;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Creates state for a tab list component.
|
|
66
66
|
*/
|
|
67
|
-
export declare function createTabListState<T = unknown>(
|
|
68
|
-
|
|
67
|
+
export declare function createTabListState<T = unknown>(
|
|
68
|
+
props: MaybeAccessor<TabListStateProps<T>>,
|
|
69
|
+
): TabListState<T>;
|
|
70
|
+
//# sourceMappingURL=createTabListState.d.ts.map
|