@fluentui/react-table 9.4.1 → 9.4.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/CHANGELOG.json +113 -9
- package/CHANGELOG.md +39 -10
- package/dist/index.d.ts +4 -23
- package/lib/components/DataGrid/DataGrid.types.js.map +1 -1
- package/lib/hooks/types.js.map +1 -1
- package/lib/hooks/useTableSelection.js +15 -38
- package/lib/hooks/useTableSelection.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/hooks/useTableSelection.js +14 -38
- package/lib-commonjs/hooks/useTableSelection.js.map +1 -1
- package/package.json +9 -9
- package/lib/hooks/selectionManager.js +0 -77
- package/lib/hooks/selectionManager.js.map +0 -1
- package/lib-commonjs/hooks/selectionManager.js +0 -86
- package/lib-commonjs/hooks/selectionManager.js.map +0 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,111 @@
|
|
|
2
2
|
"name": "@fluentui/react-table",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Wed, 28 Jun 2023 11:08:34 GMT",
|
|
6
|
+
"tag": "@fluentui/react-table_v9.4.3",
|
|
7
|
+
"version": "9.4.3",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
12
|
+
"package": "@fluentui/react-table",
|
|
13
|
+
"commit": "f154811cb3580595c319de809ea51a798dfd4555",
|
|
14
|
+
"comment": "uses useSelection from react-utilities instead of local implementation"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui/react-table",
|
|
19
|
+
"comment": "Bump @fluentui/react-aria to v9.3.25",
|
|
20
|
+
"commit": "08de131d5f3346e001dcd8d2f0f3809c698f16d7"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@fluentui/react-table",
|
|
25
|
+
"comment": "Bump @fluentui/react-avatar to v9.5.9",
|
|
26
|
+
"commit": "08de131d5f3346e001dcd8d2f0f3809c698f16d7"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "beachball",
|
|
30
|
+
"package": "@fluentui/react-table",
|
|
31
|
+
"comment": "Bump @fluentui/react-checkbox to v9.1.21",
|
|
32
|
+
"commit": "08de131d5f3346e001dcd8d2f0f3809c698f16d7"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "beachball",
|
|
36
|
+
"package": "@fluentui/react-table",
|
|
37
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.25",
|
|
38
|
+
"commit": "08de131d5f3346e001dcd8d2f0f3809c698f16d7"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"author": "beachball",
|
|
42
|
+
"package": "@fluentui/react-table",
|
|
43
|
+
"comment": "Bump @fluentui/react-radio to v9.1.21",
|
|
44
|
+
"commit": "08de131d5f3346e001dcd8d2f0f3809c698f16d7"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"author": "beachball",
|
|
48
|
+
"package": "@fluentui/react-table",
|
|
49
|
+
"comment": "Bump @fluentui/react-tabster to v9.9.1",
|
|
50
|
+
"commit": "08de131d5f3346e001dcd8d2f0f3809c698f16d7"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"author": "beachball",
|
|
54
|
+
"package": "@fluentui/react-table",
|
|
55
|
+
"comment": "Bump @fluentui/react-utilities to v9.10.0",
|
|
56
|
+
"commit": "08de131d5f3346e001dcd8d2f0f3809c698f16d7"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"author": "beachball",
|
|
60
|
+
"package": "@fluentui/react-table",
|
|
61
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.9",
|
|
62
|
+
"commit": "08de131d5f3346e001dcd8d2f0f3809c698f16d7"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"none": [
|
|
66
|
+
{
|
|
67
|
+
"author": "martinhochel@microsoft.com",
|
|
68
|
+
"package": "@fluentui/react-table",
|
|
69
|
+
"commit": "fbe878e9c9785588197481f172c42c2c0a230292",
|
|
70
|
+
"comment": "fix: update .npmignore to unify v8 packages and exclude project.json"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"date": "Tue, 27 Jun 2023 11:21:23 GMT",
|
|
77
|
+
"tag": "@fluentui/react-table_v9.4.2",
|
|
78
|
+
"version": "9.4.2",
|
|
79
|
+
"comments": {
|
|
80
|
+
"patch": [
|
|
81
|
+
{
|
|
82
|
+
"author": "beachball",
|
|
83
|
+
"package": "@fluentui/react-table",
|
|
84
|
+
"comment": "Bump @fluentui/react-avatar to v9.5.8",
|
|
85
|
+
"commit": "1c7e6451a11fb9c59e344df616394a320e8031c4"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"author": "beachball",
|
|
89
|
+
"package": "@fluentui/react-table",
|
|
90
|
+
"comment": "Bump @fluentui/react-checkbox to v9.1.20",
|
|
91
|
+
"commit": "1c7e6451a11fb9c59e344df616394a320e8031c4"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"author": "beachball",
|
|
95
|
+
"package": "@fluentui/react-table",
|
|
96
|
+
"comment": "Bump @fluentui/react-radio to v9.1.20",
|
|
97
|
+
"commit": "1c7e6451a11fb9c59e344df616394a320e8031c4"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"author": "beachball",
|
|
101
|
+
"package": "@fluentui/react-table",
|
|
102
|
+
"comment": "Bump @fluentui/react-tabster to v9.9.0",
|
|
103
|
+
"commit": "1c7e6451a11fb9c59e344df616394a320e8031c4"
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"date": "Mon, 26 Jun 2023 09:53:55 GMT",
|
|
6
110
|
"tag": "@fluentui/react-table_v9.4.1",
|
|
7
111
|
"version": "9.4.1",
|
|
8
112
|
"comments": {
|
|
@@ -11,49 +115,49 @@
|
|
|
11
115
|
"author": "beachball",
|
|
12
116
|
"package": "@fluentui/react-table",
|
|
13
117
|
"comment": "Bump @fluentui/react-aria to v9.3.24",
|
|
14
|
-
"commit": "
|
|
118
|
+
"commit": "3e47257676ace0598b9ed336a54befd4d063c332"
|
|
15
119
|
},
|
|
16
120
|
{
|
|
17
121
|
"author": "beachball",
|
|
18
122
|
"package": "@fluentui/react-table",
|
|
19
123
|
"comment": "Bump @fluentui/react-avatar to v9.5.7",
|
|
20
|
-
"commit": "
|
|
124
|
+
"commit": "3e47257676ace0598b9ed336a54befd4d063c332"
|
|
21
125
|
},
|
|
22
126
|
{
|
|
23
127
|
"author": "beachball",
|
|
24
128
|
"package": "@fluentui/react-table",
|
|
25
129
|
"comment": "Bump @fluentui/react-checkbox to v9.1.19",
|
|
26
|
-
"commit": "
|
|
130
|
+
"commit": "3e47257676ace0598b9ed336a54befd4d063c332"
|
|
27
131
|
},
|
|
28
132
|
{
|
|
29
133
|
"author": "beachball",
|
|
30
134
|
"package": "@fluentui/react-table",
|
|
31
135
|
"comment": "Bump @fluentui/react-context-selector to v9.1.24",
|
|
32
|
-
"commit": "
|
|
136
|
+
"commit": "3e47257676ace0598b9ed336a54befd4d063c332"
|
|
33
137
|
},
|
|
34
138
|
{
|
|
35
139
|
"author": "beachball",
|
|
36
140
|
"package": "@fluentui/react-table",
|
|
37
141
|
"comment": "Bump @fluentui/react-radio to v9.1.19",
|
|
38
|
-
"commit": "
|
|
142
|
+
"commit": "3e47257676ace0598b9ed336a54befd4d063c332"
|
|
39
143
|
},
|
|
40
144
|
{
|
|
41
145
|
"author": "beachball",
|
|
42
146
|
"package": "@fluentui/react-table",
|
|
43
147
|
"comment": "Bump @fluentui/react-tabster to v9.8.1",
|
|
44
|
-
"commit": "
|
|
148
|
+
"commit": "3e47257676ace0598b9ed336a54befd4d063c332"
|
|
45
149
|
},
|
|
46
150
|
{
|
|
47
151
|
"author": "beachball",
|
|
48
152
|
"package": "@fluentui/react-table",
|
|
49
153
|
"comment": "Bump @fluentui/react-utilities to v9.9.4",
|
|
50
|
-
"commit": "
|
|
154
|
+
"commit": "3e47257676ace0598b9ed336a54befd4d063c332"
|
|
51
155
|
},
|
|
52
156
|
{
|
|
53
157
|
"author": "beachball",
|
|
54
158
|
"package": "@fluentui/react-table",
|
|
55
159
|
"comment": "Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.8",
|
|
56
|
-
"commit": "
|
|
160
|
+
"commit": "3e47257676ace0598b9ed336a54befd4d063c332"
|
|
57
161
|
}
|
|
58
162
|
]
|
|
59
163
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,53 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-table
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 28 Jun 2023 11:08:34 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.4.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-table_v9.4.3)
|
|
8
|
+
|
|
9
|
+
Wed, 28 Jun 2023 11:08:34 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-table_v9.4.2..@fluentui/react-table_v9.4.3)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- uses useSelection from react-utilities instead of local implementation ([PR #28335](https://github.com/microsoft/fluentui/pull/28335) by bernardo.sunderhus@gmail.com)
|
|
15
|
+
- Bump @fluentui/react-aria to v9.3.25 ([PR #28320](https://github.com/microsoft/fluentui/pull/28320) by beachball)
|
|
16
|
+
- Bump @fluentui/react-avatar to v9.5.9 ([PR #28320](https://github.com/microsoft/fluentui/pull/28320) by beachball)
|
|
17
|
+
- Bump @fluentui/react-checkbox to v9.1.21 ([PR #28320](https://github.com/microsoft/fluentui/pull/28320) by beachball)
|
|
18
|
+
- Bump @fluentui/react-context-selector to v9.1.25 ([PR #28320](https://github.com/microsoft/fluentui/pull/28320) by beachball)
|
|
19
|
+
- Bump @fluentui/react-radio to v9.1.21 ([PR #28320](https://github.com/microsoft/fluentui/pull/28320) by beachball)
|
|
20
|
+
- Bump @fluentui/react-tabster to v9.9.1 ([PR #28320](https://github.com/microsoft/fluentui/pull/28320) by beachball)
|
|
21
|
+
- Bump @fluentui/react-utilities to v9.10.0 ([PR #28320](https://github.com/microsoft/fluentui/pull/28320) by beachball)
|
|
22
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.9 ([PR #28320](https://github.com/microsoft/fluentui/pull/28320) by beachball)
|
|
23
|
+
|
|
24
|
+
## [9.4.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-table_v9.4.2)
|
|
25
|
+
|
|
26
|
+
Tue, 27 Jun 2023 11:21:23 GMT
|
|
27
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-table_v9.4.1..@fluentui/react-table_v9.4.2)
|
|
28
|
+
|
|
29
|
+
### Patches
|
|
30
|
+
|
|
31
|
+
- Bump @fluentui/react-avatar to v9.5.8 ([PR #28291](https://github.com/microsoft/fluentui/pull/28291) by beachball)
|
|
32
|
+
- Bump @fluentui/react-checkbox to v9.1.20 ([PR #28291](https://github.com/microsoft/fluentui/pull/28291) by beachball)
|
|
33
|
+
- Bump @fluentui/react-radio to v9.1.20 ([PR #28291](https://github.com/microsoft/fluentui/pull/28291) by beachball)
|
|
34
|
+
- Bump @fluentui/react-tabster to v9.9.0 ([PR #28291](https://github.com/microsoft/fluentui/pull/28291) by beachball)
|
|
35
|
+
|
|
7
36
|
## [9.4.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-table_v9.4.1)
|
|
8
37
|
|
|
9
|
-
Mon, 26 Jun 2023 09:
|
|
38
|
+
Mon, 26 Jun 2023 09:53:55 GMT
|
|
10
39
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-table_v9.4.0..@fluentui/react-table_v9.4.1)
|
|
11
40
|
|
|
12
41
|
### Patches
|
|
13
42
|
|
|
14
|
-
- Bump @fluentui/react-aria to v9.3.24 ([PR #
|
|
15
|
-
- Bump @fluentui/react-avatar to v9.5.7 ([PR #
|
|
16
|
-
- Bump @fluentui/react-checkbox to v9.1.19 ([PR #
|
|
17
|
-
- Bump @fluentui/react-context-selector to v9.1.24 ([PR #
|
|
18
|
-
- Bump @fluentui/react-radio to v9.1.19 ([PR #
|
|
19
|
-
- Bump @fluentui/react-tabster to v9.8.1 ([PR #
|
|
20
|
-
- Bump @fluentui/react-utilities to v9.9.4 ([PR #
|
|
21
|
-
- Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.8 ([PR #
|
|
43
|
+
- Bump @fluentui/react-aria to v9.3.24 ([PR #28296](https://github.com/microsoft/fluentui/pull/28296) by beachball)
|
|
44
|
+
- Bump @fluentui/react-avatar to v9.5.7 ([PR #28296](https://github.com/microsoft/fluentui/pull/28296) by beachball)
|
|
45
|
+
- Bump @fluentui/react-checkbox to v9.1.19 ([PR #28296](https://github.com/microsoft/fluentui/pull/28296) by beachball)
|
|
46
|
+
- Bump @fluentui/react-context-selector to v9.1.24 ([PR #28296](https://github.com/microsoft/fluentui/pull/28296) by beachball)
|
|
47
|
+
- Bump @fluentui/react-radio to v9.1.19 ([PR #28296](https://github.com/microsoft/fluentui/pull/28296) by beachball)
|
|
48
|
+
- Bump @fluentui/react-tabster to v9.8.1 ([PR #28296](https://github.com/microsoft/fluentui/pull/28296) by beachball)
|
|
49
|
+
- Bump @fluentui/react-utilities to v9.9.4 ([PR #28296](https://github.com/microsoft/fluentui/pull/28296) by beachball)
|
|
50
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.8 ([PR #28296](https://github.com/microsoft/fluentui/pull/28296) by beachball)
|
|
22
51
|
|
|
23
52
|
## [9.4.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-table_v9.4.0)
|
|
24
53
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
|
10
10
|
import type { Radio } from '@fluentui/react-radio';
|
|
11
11
|
import * as React_2 from 'react';
|
|
12
12
|
import { ReactNode } from 'react';
|
|
13
|
+
import { SelectionHookParams } from '@fluentui/react-utilities';
|
|
14
|
+
import { SelectionMode as SelectionMode_2 } from '@fluentui/react-utilities';
|
|
13
15
|
import type { Slot } from '@fluentui/react-utilities';
|
|
14
16
|
import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
15
17
|
|
|
@@ -176,7 +178,7 @@ export declare type DataGridHeaderState = TableHeaderState;
|
|
|
176
178
|
/**
|
|
177
179
|
* DataGrid Props
|
|
178
180
|
*/
|
|
179
|
-
export declare type DataGridProps = TableProps & Pick<DataGridContextValue, 'items' | 'columns' | 'getRowId'> & Pick<Partial<DataGridContextValue>, 'focusMode' | 'subtleSelection' | 'selectionAppearance' | 'resizableColumns'> & Pick<UseTableSortOptions, 'sortState' | 'defaultSortState'> & Pick<
|
|
181
|
+
export declare type DataGridProps = TableProps & Pick<DataGridContextValue, 'items' | 'columns' | 'getRowId'> & Pick<Partial<DataGridContextValue>, 'focusMode' | 'subtleSelection' | 'selectionAppearance' | 'resizableColumns'> & Pick<UseTableSortOptions, 'sortState' | 'defaultSortState'> & Pick<SelectionHookParams, 'defaultSelectedItems' | 'selectedItems'> & {
|
|
180
182
|
onSortChange?: (e: React_2.MouseEvent, sortState: SortState) => void;
|
|
181
183
|
onSelectionChange?: (e: React_2.MouseEvent | React_2.KeyboardEvent, data: OnSelectionChangeData) => void;
|
|
182
184
|
/**
|
|
@@ -357,8 +359,6 @@ declare type RowEnhancer<TItem, TRowState extends TableRowData<TItem> = TableRow
|
|
|
357
359
|
|
|
358
360
|
export declare type RowRenderFunction<TItem = unknown> = (row: TableRowData<TItem>, ...rest: unknown[]) => React_2.ReactNode;
|
|
359
361
|
|
|
360
|
-
declare type SelectionMode_2 = 'single' | 'multiselect';
|
|
361
|
-
|
|
362
362
|
export declare type SortDirection = 'ascending' | 'descending';
|
|
363
363
|
|
|
364
364
|
declare interface SortState {
|
|
@@ -1117,7 +1117,7 @@ export declare const useTableRowIdContext: () => TableRowId;
|
|
|
1117
1117
|
*/
|
|
1118
1118
|
export declare const useTableRowStyles_unstable: (state: TableRowState) => TableRowState;
|
|
1119
1119
|
|
|
1120
|
-
export declare function useTableSelection<TItem>(options:
|
|
1120
|
+
export declare function useTableSelection<TItem>(options: SelectionHookParams): (tableState: TableFeaturesState<TItem>) => TableFeaturesState<TItem>;
|
|
1121
1121
|
|
|
1122
1122
|
/**
|
|
1123
1123
|
* Create the state required to render TableSelectionCell.
|
|
@@ -1135,25 +1135,6 @@ export declare const useTableSelectionCell_unstable: (props: TableSelectionCellP
|
|
|
1135
1135
|
*/
|
|
1136
1136
|
export declare const useTableSelectionCellStyles_unstable: (state: TableSelectionCellState) => TableSelectionCellState;
|
|
1137
1137
|
|
|
1138
|
-
export declare interface UseTableSelectionOptions {
|
|
1139
|
-
/**
|
|
1140
|
-
* Can be multi or single select
|
|
1141
|
-
*/
|
|
1142
|
-
selectionMode: SelectionMode_2;
|
|
1143
|
-
/**
|
|
1144
|
-
* Used in uncontrolled mode to set initial selected rows on mount
|
|
1145
|
-
*/
|
|
1146
|
-
defaultSelectedItems?: Iterable<TableRowId>;
|
|
1147
|
-
/**
|
|
1148
|
-
* Used to control row selection
|
|
1149
|
-
*/
|
|
1150
|
-
selectedItems?: Iterable<TableRowId>;
|
|
1151
|
-
/**
|
|
1152
|
-
* Called when selection changes
|
|
1153
|
-
*/
|
|
1154
|
-
onSelectionChange?(e: React_2.SyntheticEvent, data: OnSelectionChangeData): void;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
1138
|
export declare function useTableSort<TItem>(options: UseTableSortOptions): (tableState: TableFeaturesState<TItem>) => TableFeaturesState<TItem>;
|
|
1158
1139
|
|
|
1159
1140
|
declare interface UseTableSortOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DataGrid.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { TableContextValues, TableProps, TableSlots, TableState } from '../Table/Table.types';\nimport type {\n SortState,\n TableFeaturesState,\n UseTableSortOptions,\n
|
|
1
|
+
{"version":3,"sources":["DataGrid.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { TableContextValues, TableProps, TableSlots, TableState } from '../Table/Table.types';\nimport type {\n SortState,\n TableFeaturesState,\n UseTableSortOptions,\n OnSelectionChangeData,\n TableColumnSizingOptions,\n TableColumnId,\n} from '../../hooks';\nimport { TableRowProps } from '../TableRow/TableRow.types';\nimport { SelectionHookParams, SelectionMode } from '@fluentui/react-utilities';\n\nexport type DataGridSlots = TableSlots;\n\nexport type DataGridFocusMode = 'none' | 'cell' | 'row_unstable';\n\nexport type DataGridContextValues = TableContextValues & {\n dataGrid: DataGridContextValue;\n};\n\n// Use any here since we can't know the user types\n// The user is responsible for narrowing the type downstream\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type DataGridContextValue = TableFeaturesState<any> & {\n /**\n * How focus navigation will work in the datagrid\n * @default cell\n */\n focusMode: DataGridFocusMode;\n\n /**\n * Lets child components know if rows selection is enabled\n * @see selectionMode prop enables row selection on the component\n */\n selectableRows: boolean;\n\n /**\n * Enables subtle selection style\n * @default false\n */\n subtleSelection: boolean;\n\n /**\n * Row appearance when selected\n * @default brand\n */\n selectionAppearance: TableRowProps['appearance'];\n\n /**\n * Enables column resizing\n */\n resizableColumns?: boolean;\n};\n\n/**\n * DataGrid Props\n */\nexport type DataGridProps = TableProps &\n Pick<DataGridContextValue, 'items' | 'columns' | 'getRowId'> &\n Pick<Partial<DataGridContextValue>, 'focusMode' | 'subtleSelection' | 'selectionAppearance' | 'resizableColumns'> &\n Pick<UseTableSortOptions, 'sortState' | 'defaultSortState'> &\n Pick<SelectionHookParams, 'defaultSelectedItems' | 'selectedItems'> & {\n onSortChange?: (e: React.MouseEvent, sortState: SortState) => void;\n onSelectionChange?: (e: React.MouseEvent | React.KeyboardEvent, data: OnSelectionChangeData) => void;\n /**\n * Enables row selection and sets the selection mode\n * @default false\n */\n selectionMode?: SelectionMode;\n /**\n * Options for column resizing\n */\n columnSizingOptions?: TableColumnSizingOptions;\n /**\n * A callback triggered when a column is resized.\n */\n onColumnResize?: (\n e: KeyboardEvent | TouchEvent | MouseEvent | undefined,\n data: { columnId: TableColumnId; width: number },\n ) => void;\n /**\n * For column resizing. Allows for a container size to be adjusted by a number of pixels, to make\n * sure the columns don't overflow the table.\n * By default, this value is calculated internally based on other props, but can be overriden.\n */\n containerWidthOffset?: number;\n };\n\n/**\n * State used in rendering DataGrid\n */\nexport type DataGridState = TableState & { tableState: TableFeaturesState<unknown> } & Pick<\n DataGridContextValue,\n 'focusMode' | 'selectableRows' | 'subtleSelection' | 'selectionAppearance' | 'getRowId' | 'resizableColumns'\n >;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
package/lib/hooks/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\nimport { SortDirection } from '../components/Table/Table.types';\nimport { TableHeaderCellProps } from '../components/TableHeaderCell/TableHeaderCell.types';\n\nexport type TableRowId = string | number;\nexport type TableColumnId = string | number;\
|
|
1
|
+
{"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\nimport { SortDirection } from '../components/Table/Table.types';\nimport { TableHeaderCellProps } from '../components/TableHeaderCell/TableHeaderCell.types';\nimport { SelectionMode } from '@fluentui/react-utilities';\n\nexport type TableRowId = string | number;\nexport type TableColumnId = string | number;\n\nexport interface SortState {\n sortColumn: TableColumnId | undefined;\n sortDirection: SortDirection;\n}\n\nexport interface OnSelectionChangeData {\n selectedItems: Set<TableRowId>;\n}\n\nexport interface CreateTableColumnOptions<TItem> extends Partial<TableColumnDefinition<TItem>> {\n columnId: TableColumnId;\n}\n\nexport interface TableColumnDefinition<TItem> {\n columnId: TableColumnId;\n compare: (a: TItem, b: TItem) => number;\n renderHeaderCell: () => React.ReactNode;\n renderCell: (item: TItem) => React.ReactNode;\n}\n\nexport type RowEnhancer<TItem, TRowState extends TableRowData<TItem> = TableRowData<TItem>> = (\n row: TableRowData<TItem>,\n) => TRowState;\n\nexport interface TableSortState<TItem> {\n /**\n * Current sort direction\n */\n sortDirection: SortDirection;\n /**\n * Column id of the currently sorted column\n */\n sortColumn: TableColumnId | undefined;\n /**\n * Set the sort direction for the specified column\n */\n setColumnSort: (event: React.SyntheticEvent, columnId: TableColumnId, sortDirection: SortDirection) => void;\n /**\n * Toggles the sort direction for specified column\n */\n toggleColumnSort: (event: React.SyntheticEvent, columnId: TableColumnId) => void;\n /**\n * Returns the sort direction if a column is sorted,\n * returns undefined if the column is not sorted\n */\n getSortDirection: (columnId: TableColumnId) => SortDirection | undefined;\n\n /**\n * Sorts rows and returns a **shallow** copy of original items\n */\n sort: <TRowState extends TableRowData<TItem>>(rows: TRowState[]) => TRowState[];\n}\n\nexport interface TableSelectionState {\n /**\n * Clears all selected rows\n */\n clearRows: (e: React.SyntheticEvent) => void;\n /**\n * Selects single row\n */\n selectRow: (e: React.SyntheticEvent, rowId: TableRowId) => void;\n /**\n * De-selects single row\n */\n deselectRow: (e: React.SyntheticEvent, rowId: TableRowId) => void;\n /**\n * Toggle selection of all rows\n */\n toggleAllRows: (e: React.SyntheticEvent) => void;\n /**\n * Toggle selection of single row\n */\n toggleRow: (e: React.SyntheticEvent, rowId: TableRowId) => void;\n /**\n * Collection of row ids corresponding to selected rows\n */\n selectedRows: Set<TableRowId>;\n /**\n * Whether all rows are selected\n */\n allRowsSelected: boolean;\n /**\n * Whether some rows are selected\n */\n someRowsSelected: boolean;\n\n /**\n * Checks if a given rowId is selected\n */\n isRowSelected: (rowId: TableRowId) => boolean;\n\n selectionMode: SelectionMode;\n}\n\nexport interface TableRowData<TItem> {\n /**\n * User provided data\n */\n item: TItem;\n /**\n * The row id, defaults to index position in the collection\n */\n rowId: TableRowId;\n}\n\nexport interface TableFeaturesState<TItem> extends Pick<UseTableFeaturesOptions<TItem>, 'items' | 'getRowId'> {\n /**\n * The row data for rendering\n * @param rowEnhancer - Enhances the row with extra user data\n */\n getRows: <TRowState extends TableRowData<TItem> = TableRowData<TItem>>(\n rowEnhancer?: RowEnhancer<TItem, TRowState>,\n ) => TRowState[];\n /**\n * State and actions to manage row selection\n */\n selection: TableSelectionState;\n /**\n * State and actions to manage row sorting\n */\n sort: TableSortState<TItem>;\n /**\n * Table columns\n */\n columns: TableColumnDefinition<TItem>[];\n /**\n * State and actions to manage column resizing\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n columnSizing_unstable: TableColumnSizingState;\n /**\n * A React.Ref object to be set as a ref for the table.\n * Used with column resizing.\n */\n tableRef: React.Ref<HTMLDivElement>;\n}\n\nexport interface UseTableSortOptions {\n /**\n * Used to control sorting\n */\n sortState?: SortState;\n /**\n * Used in uncontrolled mode to set initial sort column and direction on mount\n */\n defaultSortState?: SortState;\n /**\n * Called when sort changes\n */\n onSortChange?(e: React.SyntheticEvent, state: SortState): void;\n}\n\nexport interface UseTableFeaturesOptions<TItem> {\n columns: TableColumnDefinition<TItem>[];\n items: TItem[];\n getRowId?: (item: TItem) => TableRowId;\n}\n\nexport type TableFeaturePlugin = <TItem>(tableState: TableFeaturesState<TItem>) => TableFeaturesState<TItem>;\n\nexport interface ColumnWidthState {\n columnId: TableColumnId;\n width: number;\n minWidth: number;\n idealWidth: number;\n padding: number;\n}\n\nexport type ColumnSizingTableHeaderCellProps = Pick<TableHeaderCellProps, 'style' | 'aside'>;\nexport type ColumnSizingTableCellProps = Pick<TableHeaderCellProps, 'style'>;\n\nexport type EnableKeyboardModeOnChangeCallback = (columnId: TableColumnId, isKeyboardMode: boolean) => void;\n\nexport interface TableColumnSizingState {\n getOnMouseDown: (columnId: TableColumnId) => (e: React.MouseEvent | React.TouchEvent) => void;\n setColumnWidth: (columnId: TableColumnId, newSize: number) => void;\n getColumnWidths: () => ColumnWidthState[];\n getTableHeaderCellProps: (columnId: TableColumnId) => ColumnSizingTableHeaderCellProps;\n getTableCellProps: (columnId: TableColumnId) => ColumnSizingTableCellProps;\n enableKeyboardMode: (\n columnId: TableColumnId,\n onChange?: EnableKeyboardModeOnChangeCallback,\n ) => (e: React.MouseEvent | React.TouchEvent) => void;\n}\n\nexport type ColumnResizeState = {\n getColumnWidth: (columnId: TableColumnId) => number;\n setColumnWidth: (\n e: KeyboardEvent | TouchEvent | MouseEvent | undefined,\n data: { columnId: TableColumnId; width: number },\n ) => void;\n getColumnById: (columnId: TableColumnId) => ColumnWidthState | undefined;\n getColumns: () => ColumnWidthState[];\n};\n\nexport type TableColumnSizingOptions = Record<\n TableColumnId,\n Partial<Pick<ColumnWidthState, 'minWidth' | 'idealWidth' | 'padding'>> & { defaultWidth?: number }\n>;\n\nexport type UseTableColumnSizingParams = {\n columnSizingOptions?: TableColumnSizingOptions;\n onColumnResize?: (\n e: KeyboardEvent | TouchEvent | MouseEvent | undefined,\n data: { columnId: TableColumnId; width: number },\n ) => void;\n containerWidthOffset?: number;\n};\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useControllableState, useEventCallback } from '@fluentui/react-utilities';
|
|
3
|
-
import { createSelectionManager } from './selectionManager';
|
|
1
|
+
import { useEventCallback, useSelection } from '@fluentui/react-utilities';
|
|
4
2
|
const noop = ()=>undefined;
|
|
5
3
|
export const defaultTableSelectionState = {
|
|
6
4
|
allRowsSelected: false,
|
|
@@ -21,40 +19,24 @@ export function useTableSelection(options) {
|
|
|
21
19
|
}
|
|
22
20
|
export function useTableSelectionState(tableState, options) {
|
|
23
21
|
const { items , getRowId } = tableState;
|
|
24
|
-
const { selectionMode , defaultSelectedItems , selectedItems , onSelectionChange } = options;
|
|
25
|
-
const [selected,
|
|
26
|
-
initialState: new Set(),
|
|
27
|
-
defaultState: React.useMemo(()=>defaultSelectedItems && createSetFromIterable(defaultSelectedItems), [
|
|
28
|
-
defaultSelectedItems
|
|
29
|
-
]),
|
|
30
|
-
state: React.useMemo(()=>selectedItems && createSetFromIterable(selectedItems), [
|
|
31
|
-
selectedItems
|
|
32
|
-
])
|
|
33
|
-
});
|
|
34
|
-
const selectionManager = React.useMemo(()=>{
|
|
35
|
-
return createSelectionManager(selectionMode, (e, newSelectedItems)=>{
|
|
36
|
-
setSelected(()=>{
|
|
37
|
-
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(e, {
|
|
38
|
-
selectedItems: newSelectedItems
|
|
39
|
-
});
|
|
40
|
-
return newSelectedItems;
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}, [
|
|
44
|
-
onSelectionChange,
|
|
22
|
+
const { selectionMode: selectionMode , defaultSelectedItems , selectedItems , onSelectionChange } = options;
|
|
23
|
+
const [selected, selectionMethods] = useSelection({
|
|
45
24
|
selectionMode,
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
defaultSelectedItems,
|
|
26
|
+
selectedItems,
|
|
27
|
+
onSelectionChange
|
|
28
|
+
});
|
|
48
29
|
const toggleAllRows = useEventCallback((e)=>{
|
|
49
30
|
var _getRowId;
|
|
50
|
-
|
|
31
|
+
selectionMethods.toggleAllItems(e, items.map((item, i)=>{
|
|
51
32
|
return (_getRowId = getRowId === null || getRowId === void 0 ? void 0 : getRowId(item)) !== null && _getRowId !== void 0 ? _getRowId : i;
|
|
52
|
-
})
|
|
33
|
+
}));
|
|
53
34
|
});
|
|
54
|
-
const toggleRow = useEventCallback((e, rowId)=>
|
|
55
|
-
const deselectRow = useEventCallback((e, rowId)=>
|
|
56
|
-
const selectRow = useEventCallback((e, rowId)=>
|
|
57
|
-
const isRowSelected = (rowId)=>
|
|
35
|
+
const toggleRow = useEventCallback((e, rowId)=>selectionMethods.toggleItem(e, rowId));
|
|
36
|
+
const deselectRow = useEventCallback((e, rowId)=>selectionMethods.deselectItem(e, rowId));
|
|
37
|
+
const selectRow = useEventCallback((e, rowId)=>selectionMethods.selectItem(e, rowId));
|
|
38
|
+
const isRowSelected = (rowId)=>selectionMethods.isSelected(rowId);
|
|
39
|
+
const clearRows = useEventCallback((e)=>selectionMethods.clearItems(e));
|
|
58
40
|
return {
|
|
59
41
|
...tableState,
|
|
60
42
|
selection: {
|
|
@@ -64,15 +46,10 @@ export function useTableSelectionState(tableState, options) {
|
|
|
64
46
|
selectedRows: selected,
|
|
65
47
|
toggleRow,
|
|
66
48
|
toggleAllRows,
|
|
67
|
-
clearRows
|
|
49
|
+
clearRows,
|
|
68
50
|
deselectRow,
|
|
69
51
|
selectRow,
|
|
70
52
|
isRowSelected
|
|
71
53
|
}
|
|
72
54
|
};
|
|
73
55
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Creates a set from a given iterable, in case the iterable is a set itself, returns the given set instead.
|
|
76
|
-
*/ function createSetFromIterable(iterable) {
|
|
77
|
-
return iterable instanceof Set ? iterable : new Set(iterable);
|
|
78
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTableSelection.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["useTableSelection.ts"],"sourcesContent":["import { SelectionHookParams, useEventCallback, useSelection } from '@fluentui/react-utilities';\nimport type { TableRowId, TableSelectionState, TableFeaturesState } from './types';\n\nconst noop = () => undefined;\n\nexport const defaultTableSelectionState: TableSelectionState = {\n allRowsSelected: false,\n clearRows: noop,\n deselectRow: noop,\n isRowSelected: () => false,\n selectRow: noop,\n selectedRows: new Set(),\n someRowsSelected: false,\n toggleAllRows: noop,\n toggleRow: noop,\n selectionMode: 'multiselect',\n};\n\nexport function useTableSelection<TItem>(options: SelectionHookParams) {\n // False positive, these plugin hooks are intended to be run on every render\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return (tableState: TableFeaturesState<TItem>) => useTableSelectionState(tableState, options);\n}\n\nexport function useTableSelectionState<TItem>(\n tableState: TableFeaturesState<TItem>,\n options: SelectionHookParams,\n): TableFeaturesState<TItem> {\n const { items, getRowId } = tableState;\n const { selectionMode: selectionMode, defaultSelectedItems, selectedItems, onSelectionChange } = options;\n\n const [selected, selectionMethods] = useSelection({\n selectionMode,\n defaultSelectedItems,\n selectedItems,\n onSelectionChange,\n });\n\n const toggleAllRows: TableSelectionState['toggleAllRows'] = useEventCallback(e => {\n selectionMethods.toggleAllItems(\n e,\n items.map((item, i) => getRowId?.(item) ?? i),\n );\n });\n\n const toggleRow: TableSelectionState['toggleRow'] = useEventCallback((e, rowId: TableRowId) =>\n selectionMethods.toggleItem(e, rowId),\n );\n\n const deselectRow: TableSelectionState['deselectRow'] = useEventCallback((e, rowId: TableRowId) =>\n selectionMethods.deselectItem(e, rowId),\n );\n\n const selectRow: TableSelectionState['selectRow'] = useEventCallback((e, rowId: TableRowId) =>\n selectionMethods.selectItem(e, rowId),\n );\n\n const isRowSelected: TableSelectionState['isRowSelected'] = (rowId: TableRowId) => selectionMethods.isSelected(rowId);\n\n const clearRows: TableSelectionState['clearRows'] = useEventCallback(e => selectionMethods.clearItems(e));\n\n return {\n ...tableState,\n selection: {\n selectionMode,\n someRowsSelected: selected.size > 0,\n allRowsSelected: selectionMode === 'single' ? selected.size > 0 : selected.size === items.length,\n selectedRows: selected,\n toggleRow,\n toggleAllRows,\n clearRows,\n deselectRow,\n selectRow,\n isRowSelected,\n },\n };\n}\n"],"names":["useEventCallback","useSelection","noop","undefined","defaultTableSelectionState","allRowsSelected","clearRows","deselectRow","isRowSelected","selectRow","selectedRows","Set","someRowsSelected","toggleAllRows","toggleRow","selectionMode","useTableSelection","options","tableState","useTableSelectionState","items","getRowId","defaultSelectedItems","selectedItems","onSelectionChange","selected","selectionMethods","e","toggleAllItems","map","item","i","rowId","toggleItem","deselectItem","selectItem","isSelected","clearItems","selection","size","length"],"mappings":"AAAA,SAA8BA,gBAAgB,EAAEC,YAAY,QAAQ,4BAA4B;AAGhG,MAAMC,OAAO,IAAMC;AAEnB,OAAO,MAAMC,6BAAkD;IAC7DC,iBAAiB,KAAK;IACtBC,WAAWJ;IACXK,aAAaL;IACbM,eAAe,IAAM,KAAK;IAC1BC,WAAWP;IACXQ,cAAc,IAAIC;IAClBC,kBAAkB,KAAK;IACvBC,eAAeX;IACfY,WAAWZ;IACXa,eAAe;AACjB,EAAE;AAEF,OAAO,SAASC,kBAAyBC,OAA4B,EAAE;IACrE,4EAA4E;IAC5E,sDAAsD;IACtD,OAAO,CAACC,aAA0CC,uBAAuBD,YAAYD;AACvF,CAAC;AAED,OAAO,SAASE,uBACdD,UAAqC,EACrCD,OAA4B,EACD;IAC3B,MAAM,EAAEG,MAAK,EAAEC,SAAQ,EAAE,GAAGH;IAC5B,MAAM,EAAEH,eAAeA,cAAa,EAAEO,qBAAoB,EAAEC,cAAa,EAAEC,kBAAiB,EAAE,GAAGP;IAEjG,MAAM,CAACQ,UAAUC,iBAAiB,GAAGzB,aAAa;QAChDc;QACAO;QACAC;QACAC;IACF;IAEA,MAAMX,gBAAsDb,iBAAiB2B,CAAAA,IAAK;YAGvDN;QAFzBK,iBAAiBE,cAAc,CAC7BD,GACAP,MAAMS,GAAG,CAAC,CAACC,MAAMC;YAAMV,OAAAA,CAAAA,YAAAA,qBAAAA,sBAAAA,KAAAA,IAAAA,SAAWS,mBAAXT,uBAAAA,YAAoBU,CAAC;;IAEhD;IAEA,MAAMjB,YAA8Cd,iBAAiB,CAAC2B,GAAGK,QACvEN,iBAAiBO,UAAU,CAACN,GAAGK;IAGjC,MAAMzB,cAAkDP,iBAAiB,CAAC2B,GAAGK,QAC3EN,iBAAiBQ,YAAY,CAACP,GAAGK;IAGnC,MAAMvB,YAA8CT,iBAAiB,CAAC2B,GAAGK,QACvEN,iBAAiBS,UAAU,CAACR,GAAGK;IAGjC,MAAMxB,gBAAsD,CAACwB,QAAsBN,iBAAiBU,UAAU,CAACJ;IAE/G,MAAM1B,YAA8CN,iBAAiB2B,CAAAA,IAAKD,iBAAiBW,UAAU,CAACV;IAEtG,OAAO;QACL,GAAGT,UAAU;QACboB,WAAW;YACTvB;YACAH,kBAAkBa,SAASc,IAAI,GAAG;YAClClC,iBAAiBU,kBAAkB,WAAWU,SAASc,IAAI,GAAG,IAAId,SAASc,IAAI,KAAKnB,MAAMoB,MAAM;YAChG9B,cAAce;YACdX;YACAD;YACAP;YACAC;YACAE;YACAD;QACF;IACF;AACF,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n useTableFeatures,\n useTableSelection,\n useTableSort,\n createTableColumn,\n useTableColumnSizing_unstable,\n} from './hooks';\n\nexport type {\n CreateTableColumnOptions,\n UseTableFeaturesOptions,\n TableColumnDefinition,\n TableColumnId,\n TableFeaturesState,\n TableRowData,\n TableRowId,\n TableSelectionState,\n TableSortState,\n TableFeaturePlugin,\n TableColumnSizingOptions,\n UseTableSelectionOptions,\n} from './hooks';\n\nexport {\n TableCell,\n tableCellClassNames,\n tableCellClassName,\n useTableCellStyles_unstable,\n useTableCell_unstable,\n renderTableCell_unstable,\n} from './TableCell';\nexport type { TableCellProps, TableCellState, TableCellSlots } from './TableCell';\n\nexport {\n TableRow,\n tableRowClassNames,\n tableRowClassName,\n useTableRowStyles_unstable,\n useTableRow_unstable,\n renderTableRow_unstable,\n} from './TableRow';\nexport type { TableRowProps, TableRowState, TableRowSlots } from './TableRow';\n\nexport {\n TableBody,\n tableBodyClassName,\n tableBodyClassNames,\n useTableBodyStyles_unstable,\n useTableBody_unstable,\n renderTableBody_unstable,\n} from './TableBody';\nexport type { TableBodyProps, TableBodyState, TableBodySlots } from './TableBody';\n\nexport {\n Table,\n tableClassName,\n tableClassNames,\n useTableStyles_unstable,\n useTable_unstable,\n renderTable_unstable,\n} from './Table';\nexport type { TableProps, TableSlots, TableState, TableContextValue, TableContextValues, SortDirection } from './Table';\n\nexport {\n TableHeader,\n tableHeaderClassNames,\n tableHeaderClassName,\n useTableHeaderStyles_unstable,\n useTableHeader_unstable,\n renderTableHeader_unstable,\n} from './TableHeader';\nexport type { TableHeaderProps, TableHeaderSlots, TableHeaderState } from './TableHeader';\n\nexport {\n TableHeaderCell,\n tableHeaderCellClassName,\n tableHeaderCellClassNames,\n useTableHeaderCellStyles_unstable,\n useTableHeaderCell_unstable,\n renderTableHeaderCell_unstable,\n} from './TableHeaderCell';\nexport type { TableHeaderCellProps, TableHeaderCellSlots, TableHeaderCellState } from './TableHeaderCell';\n\nexport {\n TableResizeHandle,\n tableResizeHandleClassNames,\n useTableResizeHandleStyles_unstable,\n useTableResizeHandle_unstable,\n renderTableResizeHandle_unstable,\n} from './TableResizeHandle';\nexport type { TableResizeHandleProps, TableResizeHandleSlots, TableResizeHandleState } from './TableResizeHandle';\n\nexport { TableContextProvider, useTableContext } from './contexts/tableContext';\nexport { useTableRowIdContext, TableRowIdContextProvider } from './contexts/rowIdContext';\nexport {\n TableSelectionCell,\n useTableSelectionCellStyles_unstable,\n useTableSelectionCell_unstable,\n renderTableSelectionCell_unstable,\n tableSelectionCellClassNames,\n CELL_WIDTH as TABLE_SELECTION_CELL_WIDTH,\n} from './TableSelectionCell';\n\nexport type { TableSelectionCellProps, TableSelectionCellState, TableSelectionCellSlots } from './TableSelectionCell';\nexport {\n TableCellActions,\n tableCellActionsClassNames,\n useTableCellActionsStyles_unstable,\n useTableCellActions_unstable,\n renderTableCellActions_unstable,\n} from './TableCellActions';\n\nexport type { TableCellActionsProps, TableCellActionsSlots, TableCellActionsState } from './TableCellActions';\nexport {\n TableCellLayout,\n tableCellLayoutClassNames,\n useTableCellLayoutStyles_unstable,\n useTableCellLayout_unstable,\n renderTableCellLayout_unstable,\n} from './TableCellLayout';\nexport type { TableCellLayoutProps, TableCellLayoutSlots, TableCellLayoutState } from './TableCellLayout';\n\nexport {\n DataGridCell,\n dataGridCellClassNames,\n useDataGridCellStyles_unstable,\n useDataGridCell_unstable,\n renderDataGridCell_unstable,\n} from './DataGridCell';\nexport type { DataGridCellProps, DataGridCellState, DataGridCellSlots } from './DataGridCell';\n\nexport {\n DataGridRow,\n dataGridRowClassNames,\n useDataGridRowStyles_unstable,\n useDataGridRow_unstable,\n renderDataGridRow_unstable,\n} from './DataGridRow';\nexport type { DataGridRowProps, DataGridRowState, DataGridRowSlots, CellRenderFunction } from './DataGridRow';\n\nexport {\n DataGridBody,\n dataGridBodyClassNames,\n useDataGridBodyStyles_unstable,\n useDataGridBody_unstable,\n renderDataGridBody_unstable,\n} from './DataGridBody';\nexport type { DataGridBodyProps, DataGridBodyState, DataGridBodySlots, RowRenderFunction } from './DataGridBody';\n\nexport {\n DataGrid,\n dataGridClassNames,\n useDataGridStyles_unstable,\n useDataGrid_unstable,\n renderDataGrid_unstable,\n useDataGridContextValues_unstable,\n} from './DataGrid';\nexport type {\n DataGridProps,\n DataGridSlots,\n DataGridState,\n DataGridContextValues,\n DataGridContextValue,\n DataGridFocusMode,\n} from './DataGrid';\n\nexport {\n DataGridHeader,\n dataGridHeaderClassNames,\n useDataGridHeaderStyles_unstable,\n useDataGridHeader_unstable,\n renderDataGridHeader_unstable,\n} from './DataGridHeader';\nexport type { DataGridHeaderProps, DataGridHeaderSlots, DataGridHeaderState } from './DataGridHeader';\n\nexport {\n DataGridHeaderCell,\n dataGridHeaderCellClassNames,\n useDataGridHeaderCellStyles_unstable,\n useDataGridHeaderCell_unstable,\n renderDataGridHeaderCell_unstable,\n} from './DataGridHeaderCell';\nexport type { DataGridHeaderCellProps, DataGridHeaderCellSlots, DataGridHeaderCellState } from './DataGridHeaderCell';\n\nexport {\n DataGridSelectionCell,\n useDataGridSelectionCellStyles_unstable,\n useDataGridSelectionCell_unstable,\n renderDataGridSelectionCell_unstable,\n dataGridSelectionCellClassNames,\n} from './DataGridSelectionCell';\n\nexport type {\n DataGridSelectionCellProps,\n DataGridSelectionCellState,\n DataGridSelectionCellSlots,\n} from './DataGridSelectionCell';\n"],"names":["useTableFeatures","useTableSelection","useTableSort","createTableColumn","useTableColumnSizing_unstable","TableCell","tableCellClassNames","tableCellClassName","useTableCellStyles_unstable","useTableCell_unstable","renderTableCell_unstable","TableRow","tableRowClassNames","tableRowClassName","useTableRowStyles_unstable","useTableRow_unstable","renderTableRow_unstable","TableBody","tableBodyClassName","tableBodyClassNames","useTableBodyStyles_unstable","useTableBody_unstable","renderTableBody_unstable","Table","tableClassName","tableClassNames","useTableStyles_unstable","useTable_unstable","renderTable_unstable","TableHeader","tableHeaderClassNames","tableHeaderClassName","useTableHeaderStyles_unstable","useTableHeader_unstable","renderTableHeader_unstable","TableHeaderCell","tableHeaderCellClassName","tableHeaderCellClassNames","useTableHeaderCellStyles_unstable","useTableHeaderCell_unstable","renderTableHeaderCell_unstable","TableResizeHandle","tableResizeHandleClassNames","useTableResizeHandleStyles_unstable","useTableResizeHandle_unstable","renderTableResizeHandle_unstable","TableContextProvider","useTableContext","useTableRowIdContext","TableRowIdContextProvider","TableSelectionCell","useTableSelectionCellStyles_unstable","useTableSelectionCell_unstable","renderTableSelectionCell_unstable","tableSelectionCellClassNames","CELL_WIDTH","TABLE_SELECTION_CELL_WIDTH","TableCellActions","tableCellActionsClassNames","useTableCellActionsStyles_unstable","useTableCellActions_unstable","renderTableCellActions_unstable","TableCellLayout","tableCellLayoutClassNames","useTableCellLayoutStyles_unstable","useTableCellLayout_unstable","renderTableCellLayout_unstable","DataGridCell","dataGridCellClassNames","useDataGridCellStyles_unstable","useDataGridCell_unstable","renderDataGridCell_unstable","DataGridRow","dataGridRowClassNames","useDataGridRowStyles_unstable","useDataGridRow_unstable","renderDataGridRow_unstable","DataGridBody","dataGridBodyClassNames","useDataGridBodyStyles_unstable","useDataGridBody_unstable","renderDataGridBody_unstable","DataGrid","dataGridClassNames","useDataGridStyles_unstable","useDataGrid_unstable","renderDataGrid_unstable","useDataGridContextValues_unstable","DataGridHeader","dataGridHeaderClassNames","useDataGridHeaderStyles_unstable","useDataGridHeader_unstable","renderDataGridHeader_unstable","DataGridHeaderCell","dataGridHeaderCellClassNames","useDataGridHeaderCellStyles_unstable","useDataGridHeaderCell_unstable","renderDataGridHeaderCell_unstable","DataGridSelectionCell","useDataGridSelectionCellStyles_unstable","useDataGridSelectionCell_unstable","renderDataGridSelectionCell_unstable","dataGridSelectionCellClassNames"],"mappings":"AAAA,SACEA,gBAAgB,EAChBC,iBAAiB,EACjBC,YAAY,EACZC,iBAAiB,EACjBC,6BAA6B,QACxB,UAAU;AAiBjB,SACEC,SAAS,EACTC,mBAAmB,EACnBC,kBAAkB,EAClBC,2BAA2B,EAC3BC,qBAAqB,EACrBC,wBAAwB,QACnB,cAAc;AAGrB,SACEC,QAAQ,EACRC,kBAAkB,EAClBC,iBAAiB,EACjBC,0BAA0B,EAC1BC,oBAAoB,EACpBC,uBAAuB,QAClB,aAAa;AAGpB,SACEC,SAAS,EACTC,kBAAkB,EAClBC,mBAAmB,EACnBC,2BAA2B,EAC3BC,qBAAqB,EACrBC,wBAAwB,QACnB,cAAc;AAGrB,SACEC,KAAK,EACLC,cAAc,EACdC,eAAe,EACfC,uBAAuB,EACvBC,iBAAiB,EACjBC,oBAAoB,QACf,UAAU;AAGjB,SACEC,WAAW,EACXC,qBAAqB,EACrBC,oBAAoB,EACpBC,6BAA6B,EAC7BC,uBAAuB,EACvBC,0BAA0B,QACrB,gBAAgB;AAGvB,SACEC,eAAe,EACfC,wBAAwB,EACxBC,yBAAyB,EACzBC,iCAAiC,EACjCC,2BAA2B,EAC3BC,8BAA8B,QACzB,oBAAoB;AAG3B,SACEC,iBAAiB,EACjBC,2BAA2B,EAC3BC,mCAAmC,EACnCC,6BAA6B,EAC7BC,gCAAgC,QAC3B,sBAAsB;AAG7B,SAASC,oBAAoB,EAAEC,eAAe,QAAQ,0BAA0B;AAChF,SAASC,oBAAoB,EAAEC,yBAAyB,QAAQ,0BAA0B;AAC1F,SACEC,kBAAkB,EAClBC,oCAAoC,EACpCC,8BAA8B,EAC9BC,iCAAiC,EACjCC,4BAA4B,EAC5BC,cAAcC,0BAA0B,QACnC,uBAAuB;AAG9B,SACEC,gBAAgB,EAChBC,0BAA0B,EAC1BC,kCAAkC,EAClCC,4BAA4B,EAC5BC,+BAA+B,QAC1B,qBAAqB;AAG5B,SACEC,eAAe,EACfC,yBAAyB,EACzBC,iCAAiC,EACjCC,2BAA2B,EAC3BC,8BAA8B,QACzB,oBAAoB;AAG3B,SACEC,YAAY,EACZC,sBAAsB,EACtBC,8BAA8B,EAC9BC,wBAAwB,EACxBC,2BAA2B,QACtB,iBAAiB;AAGxB,SACEC,WAAW,EACXC,qBAAqB,EACrBC,6BAA6B,EAC7BC,uBAAuB,EACvBC,0BAA0B,QACrB,gBAAgB;AAGvB,SACEC,YAAY,EACZC,sBAAsB,EACtBC,8BAA8B,EAC9BC,wBAAwB,EACxBC,2BAA2B,QACtB,iBAAiB;AAGxB,SACEC,QAAQ,EACRC,kBAAkB,EAClBC,0BAA0B,EAC1BC,oBAAoB,EACpBC,uBAAuB,EACvBC,iCAAiC,QAC5B,aAAa;AAUpB,SACEC,cAAc,EACdC,wBAAwB,EACxBC,gCAAgC,EAChCC,0BAA0B,EAC1BC,6BAA6B,QACxB,mBAAmB;AAG1B,SACEC,kBAAkB,EAClBC,4BAA4B,EAC5BC,oCAAoC,EACpCC,8BAA8B,EAC9BC,iCAAiC,QAC5B,uBAAuB;AAG9B,SACEC,qBAAqB,EACrBC,uCAAuC,EACvCC,iCAAiC,EACjCC,oCAAoC,EACpCC,+BAA+B,QAC1B,0BAA0B"}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n useTableFeatures,\n useTableSelection,\n useTableSort,\n createTableColumn,\n useTableColumnSizing_unstable,\n} from './hooks';\n\nexport type {\n CreateTableColumnOptions,\n UseTableFeaturesOptions,\n TableColumnDefinition,\n TableColumnId,\n TableFeaturesState,\n TableRowData,\n TableRowId,\n TableSelectionState,\n TableSortState,\n TableFeaturePlugin,\n TableColumnSizingOptions,\n} from './hooks';\n\nexport {\n TableCell,\n tableCellClassNames,\n tableCellClassName,\n useTableCellStyles_unstable,\n useTableCell_unstable,\n renderTableCell_unstable,\n} from './TableCell';\nexport type { TableCellProps, TableCellState, TableCellSlots } from './TableCell';\n\nexport {\n TableRow,\n tableRowClassNames,\n tableRowClassName,\n useTableRowStyles_unstable,\n useTableRow_unstable,\n renderTableRow_unstable,\n} from './TableRow';\nexport type { TableRowProps, TableRowState, TableRowSlots } from './TableRow';\n\nexport {\n TableBody,\n tableBodyClassName,\n tableBodyClassNames,\n useTableBodyStyles_unstable,\n useTableBody_unstable,\n renderTableBody_unstable,\n} from './TableBody';\nexport type { TableBodyProps, TableBodyState, TableBodySlots } from './TableBody';\n\nexport {\n Table,\n tableClassName,\n tableClassNames,\n useTableStyles_unstable,\n useTable_unstable,\n renderTable_unstable,\n} from './Table';\nexport type { TableProps, TableSlots, TableState, TableContextValue, TableContextValues, SortDirection } from './Table';\n\nexport {\n TableHeader,\n tableHeaderClassNames,\n tableHeaderClassName,\n useTableHeaderStyles_unstable,\n useTableHeader_unstable,\n renderTableHeader_unstable,\n} from './TableHeader';\nexport type { TableHeaderProps, TableHeaderSlots, TableHeaderState } from './TableHeader';\n\nexport {\n TableHeaderCell,\n tableHeaderCellClassName,\n tableHeaderCellClassNames,\n useTableHeaderCellStyles_unstable,\n useTableHeaderCell_unstable,\n renderTableHeaderCell_unstable,\n} from './TableHeaderCell';\nexport type { TableHeaderCellProps, TableHeaderCellSlots, TableHeaderCellState } from './TableHeaderCell';\n\nexport {\n TableResizeHandle,\n tableResizeHandleClassNames,\n useTableResizeHandleStyles_unstable,\n useTableResizeHandle_unstable,\n renderTableResizeHandle_unstable,\n} from './TableResizeHandle';\nexport type { TableResizeHandleProps, TableResizeHandleSlots, TableResizeHandleState } from './TableResizeHandle';\n\nexport { TableContextProvider, useTableContext } from './contexts/tableContext';\nexport { useTableRowIdContext, TableRowIdContextProvider } from './contexts/rowIdContext';\nexport {\n TableSelectionCell,\n useTableSelectionCellStyles_unstable,\n useTableSelectionCell_unstable,\n renderTableSelectionCell_unstable,\n tableSelectionCellClassNames,\n CELL_WIDTH as TABLE_SELECTION_CELL_WIDTH,\n} from './TableSelectionCell';\n\nexport type { TableSelectionCellProps, TableSelectionCellState, TableSelectionCellSlots } from './TableSelectionCell';\nexport {\n TableCellActions,\n tableCellActionsClassNames,\n useTableCellActionsStyles_unstable,\n useTableCellActions_unstable,\n renderTableCellActions_unstable,\n} from './TableCellActions';\n\nexport type { TableCellActionsProps, TableCellActionsSlots, TableCellActionsState } from './TableCellActions';\nexport {\n TableCellLayout,\n tableCellLayoutClassNames,\n useTableCellLayoutStyles_unstable,\n useTableCellLayout_unstable,\n renderTableCellLayout_unstable,\n} from './TableCellLayout';\nexport type { TableCellLayoutProps, TableCellLayoutSlots, TableCellLayoutState } from './TableCellLayout';\n\nexport {\n DataGridCell,\n dataGridCellClassNames,\n useDataGridCellStyles_unstable,\n useDataGridCell_unstable,\n renderDataGridCell_unstable,\n} from './DataGridCell';\nexport type { DataGridCellProps, DataGridCellState, DataGridCellSlots } from './DataGridCell';\n\nexport {\n DataGridRow,\n dataGridRowClassNames,\n useDataGridRowStyles_unstable,\n useDataGridRow_unstable,\n renderDataGridRow_unstable,\n} from './DataGridRow';\nexport type { DataGridRowProps, DataGridRowState, DataGridRowSlots, CellRenderFunction } from './DataGridRow';\n\nexport {\n DataGridBody,\n dataGridBodyClassNames,\n useDataGridBodyStyles_unstable,\n useDataGridBody_unstable,\n renderDataGridBody_unstable,\n} from './DataGridBody';\nexport type { DataGridBodyProps, DataGridBodyState, DataGridBodySlots, RowRenderFunction } from './DataGridBody';\n\nexport {\n DataGrid,\n dataGridClassNames,\n useDataGridStyles_unstable,\n useDataGrid_unstable,\n renderDataGrid_unstable,\n useDataGridContextValues_unstable,\n} from './DataGrid';\nexport type {\n DataGridProps,\n DataGridSlots,\n DataGridState,\n DataGridContextValues,\n DataGridContextValue,\n DataGridFocusMode,\n} from './DataGrid';\n\nexport {\n DataGridHeader,\n dataGridHeaderClassNames,\n useDataGridHeaderStyles_unstable,\n useDataGridHeader_unstable,\n renderDataGridHeader_unstable,\n} from './DataGridHeader';\nexport type { DataGridHeaderProps, DataGridHeaderSlots, DataGridHeaderState } from './DataGridHeader';\n\nexport {\n DataGridHeaderCell,\n dataGridHeaderCellClassNames,\n useDataGridHeaderCellStyles_unstable,\n useDataGridHeaderCell_unstable,\n renderDataGridHeaderCell_unstable,\n} from './DataGridHeaderCell';\nexport type { DataGridHeaderCellProps, DataGridHeaderCellSlots, DataGridHeaderCellState } from './DataGridHeaderCell';\n\nexport {\n DataGridSelectionCell,\n useDataGridSelectionCellStyles_unstable,\n useDataGridSelectionCell_unstable,\n renderDataGridSelectionCell_unstable,\n dataGridSelectionCellClassNames,\n} from './DataGridSelectionCell';\n\nexport type {\n DataGridSelectionCellProps,\n DataGridSelectionCellState,\n DataGridSelectionCellSlots,\n} from './DataGridSelectionCell';\n"],"names":["useTableFeatures","useTableSelection","useTableSort","createTableColumn","useTableColumnSizing_unstable","TableCell","tableCellClassNames","tableCellClassName","useTableCellStyles_unstable","useTableCell_unstable","renderTableCell_unstable","TableRow","tableRowClassNames","tableRowClassName","useTableRowStyles_unstable","useTableRow_unstable","renderTableRow_unstable","TableBody","tableBodyClassName","tableBodyClassNames","useTableBodyStyles_unstable","useTableBody_unstable","renderTableBody_unstable","Table","tableClassName","tableClassNames","useTableStyles_unstable","useTable_unstable","renderTable_unstable","TableHeader","tableHeaderClassNames","tableHeaderClassName","useTableHeaderStyles_unstable","useTableHeader_unstable","renderTableHeader_unstable","TableHeaderCell","tableHeaderCellClassName","tableHeaderCellClassNames","useTableHeaderCellStyles_unstable","useTableHeaderCell_unstable","renderTableHeaderCell_unstable","TableResizeHandle","tableResizeHandleClassNames","useTableResizeHandleStyles_unstable","useTableResizeHandle_unstable","renderTableResizeHandle_unstable","TableContextProvider","useTableContext","useTableRowIdContext","TableRowIdContextProvider","TableSelectionCell","useTableSelectionCellStyles_unstable","useTableSelectionCell_unstable","renderTableSelectionCell_unstable","tableSelectionCellClassNames","CELL_WIDTH","TABLE_SELECTION_CELL_WIDTH","TableCellActions","tableCellActionsClassNames","useTableCellActionsStyles_unstable","useTableCellActions_unstable","renderTableCellActions_unstable","TableCellLayout","tableCellLayoutClassNames","useTableCellLayoutStyles_unstable","useTableCellLayout_unstable","renderTableCellLayout_unstable","DataGridCell","dataGridCellClassNames","useDataGridCellStyles_unstable","useDataGridCell_unstable","renderDataGridCell_unstable","DataGridRow","dataGridRowClassNames","useDataGridRowStyles_unstable","useDataGridRow_unstable","renderDataGridRow_unstable","DataGridBody","dataGridBodyClassNames","useDataGridBodyStyles_unstable","useDataGridBody_unstable","renderDataGridBody_unstable","DataGrid","dataGridClassNames","useDataGridStyles_unstable","useDataGrid_unstable","renderDataGrid_unstable","useDataGridContextValues_unstable","DataGridHeader","dataGridHeaderClassNames","useDataGridHeaderStyles_unstable","useDataGridHeader_unstable","renderDataGridHeader_unstable","DataGridHeaderCell","dataGridHeaderCellClassNames","useDataGridHeaderCellStyles_unstable","useDataGridHeaderCell_unstable","renderDataGridHeaderCell_unstable","DataGridSelectionCell","useDataGridSelectionCellStyles_unstable","useDataGridSelectionCell_unstable","renderDataGridSelectionCell_unstable","dataGridSelectionCellClassNames"],"mappings":"AAAA,SACEA,gBAAgB,EAChBC,iBAAiB,EACjBC,YAAY,EACZC,iBAAiB,EACjBC,6BAA6B,QACxB,UAAU;AAgBjB,SACEC,SAAS,EACTC,mBAAmB,EACnBC,kBAAkB,EAClBC,2BAA2B,EAC3BC,qBAAqB,EACrBC,wBAAwB,QACnB,cAAc;AAGrB,SACEC,QAAQ,EACRC,kBAAkB,EAClBC,iBAAiB,EACjBC,0BAA0B,EAC1BC,oBAAoB,EACpBC,uBAAuB,QAClB,aAAa;AAGpB,SACEC,SAAS,EACTC,kBAAkB,EAClBC,mBAAmB,EACnBC,2BAA2B,EAC3BC,qBAAqB,EACrBC,wBAAwB,QACnB,cAAc;AAGrB,SACEC,KAAK,EACLC,cAAc,EACdC,eAAe,EACfC,uBAAuB,EACvBC,iBAAiB,EACjBC,oBAAoB,QACf,UAAU;AAGjB,SACEC,WAAW,EACXC,qBAAqB,EACrBC,oBAAoB,EACpBC,6BAA6B,EAC7BC,uBAAuB,EACvBC,0BAA0B,QACrB,gBAAgB;AAGvB,SACEC,eAAe,EACfC,wBAAwB,EACxBC,yBAAyB,EACzBC,iCAAiC,EACjCC,2BAA2B,EAC3BC,8BAA8B,QACzB,oBAAoB;AAG3B,SACEC,iBAAiB,EACjBC,2BAA2B,EAC3BC,mCAAmC,EACnCC,6BAA6B,EAC7BC,gCAAgC,QAC3B,sBAAsB;AAG7B,SAASC,oBAAoB,EAAEC,eAAe,QAAQ,0BAA0B;AAChF,SAASC,oBAAoB,EAAEC,yBAAyB,QAAQ,0BAA0B;AAC1F,SACEC,kBAAkB,EAClBC,oCAAoC,EACpCC,8BAA8B,EAC9BC,iCAAiC,EACjCC,4BAA4B,EAC5BC,cAAcC,0BAA0B,QACnC,uBAAuB;AAG9B,SACEC,gBAAgB,EAChBC,0BAA0B,EAC1BC,kCAAkC,EAClCC,4BAA4B,EAC5BC,+BAA+B,QAC1B,qBAAqB;AAG5B,SACEC,eAAe,EACfC,yBAAyB,EACzBC,iCAAiC,EACjCC,2BAA2B,EAC3BC,8BAA8B,QACzB,oBAAoB;AAG3B,SACEC,YAAY,EACZC,sBAAsB,EACtBC,8BAA8B,EAC9BC,wBAAwB,EACxBC,2BAA2B,QACtB,iBAAiB;AAGxB,SACEC,WAAW,EACXC,qBAAqB,EACrBC,6BAA6B,EAC7BC,uBAAuB,EACvBC,0BAA0B,QACrB,gBAAgB;AAGvB,SACEC,YAAY,EACZC,sBAAsB,EACtBC,8BAA8B,EAC9BC,wBAAwB,EACxBC,2BAA2B,QACtB,iBAAiB;AAGxB,SACEC,QAAQ,EACRC,kBAAkB,EAClBC,0BAA0B,EAC1BC,oBAAoB,EACpBC,uBAAuB,EACvBC,iCAAiC,QAC5B,aAAa;AAUpB,SACEC,cAAc,EACdC,wBAAwB,EACxBC,gCAAgC,EAChCC,0BAA0B,EAC1BC,6BAA6B,QACxB,mBAAmB;AAG1B,SACEC,kBAAkB,EAClBC,4BAA4B,EAC5BC,oCAAoC,EACpCC,8BAA8B,EAC9BC,iCAAiC,QAC5B,uBAAuB;AAG9B,SACEC,qBAAqB,EACrBC,uCAAuC,EACvCC,iCAAiC,EACjCC,oCAAoC,EACpCC,+BAA+B,QAC1B,0BAA0B"}
|
|
@@ -13,10 +13,7 @@ _export(exports, {
|
|
|
13
13
|
useTableSelection: ()=>useTableSelection,
|
|
14
14
|
useTableSelectionState: ()=>useTableSelectionState
|
|
15
15
|
});
|
|
16
|
-
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
17
|
-
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
18
16
|
const _reactUtilities = require("@fluentui/react-utilities");
|
|
19
|
-
const _selectionManager = require("./selectionManager");
|
|
20
17
|
const noop = ()=>undefined;
|
|
21
18
|
const defaultTableSelectionState = {
|
|
22
19
|
allRowsSelected: false,
|
|
@@ -37,40 +34,24 @@ function useTableSelection(options) {
|
|
|
37
34
|
}
|
|
38
35
|
function useTableSelectionState(tableState, options) {
|
|
39
36
|
const { items , getRowId } = tableState;
|
|
40
|
-
const { selectionMode , defaultSelectedItems , selectedItems , onSelectionChange } = options;
|
|
41
|
-
const [selected,
|
|
42
|
-
initialState: new Set(),
|
|
43
|
-
defaultState: _react.useMemo(()=>defaultSelectedItems && createSetFromIterable(defaultSelectedItems), [
|
|
44
|
-
defaultSelectedItems
|
|
45
|
-
]),
|
|
46
|
-
state: _react.useMemo(()=>selectedItems && createSetFromIterable(selectedItems), [
|
|
47
|
-
selectedItems
|
|
48
|
-
])
|
|
49
|
-
});
|
|
50
|
-
const selectionManager = _react.useMemo(()=>{
|
|
51
|
-
return (0, _selectionManager.createSelectionManager)(selectionMode, (e, newSelectedItems)=>{
|
|
52
|
-
setSelected(()=>{
|
|
53
|
-
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(e, {
|
|
54
|
-
selectedItems: newSelectedItems
|
|
55
|
-
});
|
|
56
|
-
return newSelectedItems;
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}, [
|
|
60
|
-
onSelectionChange,
|
|
37
|
+
const { selectionMode: selectionMode , defaultSelectedItems , selectedItems , onSelectionChange } = options;
|
|
38
|
+
const [selected, selectionMethods] = (0, _reactUtilities.useSelection)({
|
|
61
39
|
selectionMode,
|
|
62
|
-
|
|
63
|
-
|
|
40
|
+
defaultSelectedItems,
|
|
41
|
+
selectedItems,
|
|
42
|
+
onSelectionChange
|
|
43
|
+
});
|
|
64
44
|
const toggleAllRows = (0, _reactUtilities.useEventCallback)((e)=>{
|
|
65
45
|
var _getRowId;
|
|
66
|
-
|
|
46
|
+
selectionMethods.toggleAllItems(e, items.map((item, i)=>{
|
|
67
47
|
return (_getRowId = getRowId === null || getRowId === void 0 ? void 0 : getRowId(item)) !== null && _getRowId !== void 0 ? _getRowId : i;
|
|
68
|
-
})
|
|
48
|
+
}));
|
|
69
49
|
});
|
|
70
|
-
const toggleRow = (0, _reactUtilities.useEventCallback)((e, rowId)=>
|
|
71
|
-
const deselectRow = (0, _reactUtilities.useEventCallback)((e, rowId)=>
|
|
72
|
-
const selectRow = (0, _reactUtilities.useEventCallback)((e, rowId)=>
|
|
73
|
-
const isRowSelected = (rowId)=>
|
|
50
|
+
const toggleRow = (0, _reactUtilities.useEventCallback)((e, rowId)=>selectionMethods.toggleItem(e, rowId));
|
|
51
|
+
const deselectRow = (0, _reactUtilities.useEventCallback)((e, rowId)=>selectionMethods.deselectItem(e, rowId));
|
|
52
|
+
const selectRow = (0, _reactUtilities.useEventCallback)((e, rowId)=>selectionMethods.selectItem(e, rowId));
|
|
53
|
+
const isRowSelected = (rowId)=>selectionMethods.isSelected(rowId);
|
|
54
|
+
const clearRows = (0, _reactUtilities.useEventCallback)((e)=>selectionMethods.clearItems(e));
|
|
74
55
|
return {
|
|
75
56
|
...tableState,
|
|
76
57
|
selection: {
|
|
@@ -80,15 +61,10 @@ function useTableSelectionState(tableState, options) {
|
|
|
80
61
|
selectedRows: selected,
|
|
81
62
|
toggleRow,
|
|
82
63
|
toggleAllRows,
|
|
83
|
-
clearRows
|
|
64
|
+
clearRows,
|
|
84
65
|
deselectRow,
|
|
85
66
|
selectRow,
|
|
86
67
|
isRowSelected
|
|
87
68
|
}
|
|
88
69
|
};
|
|
89
70
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Creates a set from a given iterable, in case the iterable is a set itself, returns the given set instead.
|
|
92
|
-
*/ function createSetFromIterable(iterable) {
|
|
93
|
-
return iterable instanceof Set ? iterable : new Set(iterable);
|
|
94
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTableSelection.js"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["useTableSelection.js"],"sourcesContent":["import { useEventCallback, useSelection } from '@fluentui/react-utilities';\nconst noop = ()=>undefined;\nexport const defaultTableSelectionState = {\n allRowsSelected: false,\n clearRows: noop,\n deselectRow: noop,\n isRowSelected: ()=>false,\n selectRow: noop,\n selectedRows: new Set(),\n someRowsSelected: false,\n toggleAllRows: noop,\n toggleRow: noop,\n selectionMode: 'multiselect'\n};\nexport function useTableSelection(options) {\n // False positive, these plugin hooks are intended to be run on every render\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return (tableState)=>useTableSelectionState(tableState, options);\n}\nexport function useTableSelectionState(tableState, options) {\n const { items , getRowId } = tableState;\n const { selectionMode: selectionMode , defaultSelectedItems , selectedItems , onSelectionChange } = options;\n const [selected, selectionMethods] = useSelection({\n selectionMode,\n defaultSelectedItems,\n selectedItems,\n onSelectionChange\n });\n const toggleAllRows = useEventCallback((e)=>{\n var _getRowId;\n selectionMethods.toggleAllItems(e, items.map((item, i)=>{\n return (_getRowId = getRowId === null || getRowId === void 0 ? void 0 : getRowId(item)) !== null && _getRowId !== void 0 ? _getRowId : i;\n }));\n });\n const toggleRow = useEventCallback((e, rowId)=>selectionMethods.toggleItem(e, rowId));\n const deselectRow = useEventCallback((e, rowId)=>selectionMethods.deselectItem(e, rowId));\n const selectRow = useEventCallback((e, rowId)=>selectionMethods.selectItem(e, rowId));\n const isRowSelected = (rowId)=>selectionMethods.isSelected(rowId);\n const clearRows = useEventCallback((e)=>selectionMethods.clearItems(e));\n return {\n ...tableState,\n selection: {\n selectionMode,\n someRowsSelected: selected.size > 0,\n allRowsSelected: selectionMode === 'single' ? selected.size > 0 : selected.size === items.length,\n selectedRows: selected,\n toggleRow,\n toggleAllRows,\n clearRows,\n deselectRow,\n selectRow,\n isRowSelected\n }\n };\n}\n"],"names":["defaultTableSelectionState","useTableSelection","useTableSelectionState","noop","undefined","allRowsSelected","clearRows","deselectRow","isRowSelected","selectRow","selectedRows","Set","someRowsSelected","toggleAllRows","toggleRow","selectionMode","options","tableState","items","getRowId","defaultSelectedItems","selectedItems","onSelectionChange","selected","selectionMethods","useSelection","useEventCallback","e","_getRowId","toggleAllItems","map","item","i","rowId","toggleItem","deselectItem","selectItem","isSelected","clearItems","selection","size","length"],"mappings":";;;;;;;;;;;IAEaA,0BAA0B,MAA1BA;IAYGC,iBAAiB,MAAjBA;IAKAC,sBAAsB,MAAtBA;;gCAnB+B;AAC/C,MAAMC,OAAO,IAAIC;AACV,MAAMJ,6BAA6B;IACtCK,iBAAiB,KAAK;IACtBC,WAAWH;IACXI,aAAaJ;IACbK,eAAe,IAAI,KAAK;IACxBC,WAAWN;IACXO,cAAc,IAAIC;IAClBC,kBAAkB,KAAK;IACvBC,eAAeV;IACfW,WAAWX;IACXY,eAAe;AACnB;AACO,SAASd,kBAAkBe,OAAO,EAAE;IACvC,4EAA4E;IAC5E,sDAAsD;IACtD,OAAO,CAACC,aAAaf,uBAAuBe,YAAYD;AAC5D;AACO,SAASd,uBAAuBe,UAAU,EAAED,OAAO,EAAE;IACxD,MAAM,EAAEE,MAAK,EAAGC,SAAQ,EAAG,GAAGF;IAC9B,MAAM,EAAEF,eAAeA,cAAa,EAAGK,qBAAoB,EAAGC,cAAa,EAAGC,kBAAiB,EAAG,GAAGN;IACrG,MAAM,CAACO,UAAUC,iBAAiB,GAAGC,IAAAA,4BAAY,EAAC;QAC9CV;QACAK;QACAC;QACAC;IACJ;IACA,MAAMT,gBAAgBa,IAAAA,gCAAgB,EAAC,CAACC,IAAI;QACxC,IAAIC;QACJJ,iBAAiBK,cAAc,CAACF,GAAGT,MAAMY,GAAG,CAAC,CAACC,MAAMC,IAAI;YACpD,OAAO,AAACJ,CAAAA,YAAYT,aAAa,IAAI,IAAIA,aAAa,KAAK,IAAI,KAAK,IAAIA,SAASY,KAAK,AAAD,MAAO,IAAI,IAAIH,cAAc,KAAK,IAAIA,YAAYI,CAAC;QAC5I;IACJ;IACA,MAAMlB,YAAYY,IAAAA,gCAAgB,EAAC,CAACC,GAAGM,QAAQT,iBAAiBU,UAAU,CAACP,GAAGM;IAC9E,MAAM1B,cAAcmB,IAAAA,gCAAgB,EAAC,CAACC,GAAGM,QAAQT,iBAAiBW,YAAY,CAACR,GAAGM;IAClF,MAAMxB,YAAYiB,IAAAA,gCAAgB,EAAC,CAACC,GAAGM,QAAQT,iBAAiBY,UAAU,CAACT,GAAGM;IAC9E,MAAMzB,gBAAgB,CAACyB,QAAQT,iBAAiBa,UAAU,CAACJ;IAC3D,MAAM3B,YAAYoB,IAAAA,gCAAgB,EAAC,CAACC,IAAIH,iBAAiBc,UAAU,CAACX;IACpE,OAAO;QACH,GAAGV,UAAU;QACbsB,WAAW;YACPxB;YACAH,kBAAkBW,SAASiB,IAAI,GAAG;YAClCnC,iBAAiBU,kBAAkB,WAAWQ,SAASiB,IAAI,GAAG,IAAIjB,SAASiB,IAAI,KAAKtB,MAAMuB,MAAM;YAChG/B,cAAca;YACdT;YACAD;YACAP;YACAC;YACAE;YACAD;QACJ;IACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-table",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.3",
|
|
4
4
|
"description": "React components for building web experiences",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@fluentui/keyboard-keys": "^9.0.3",
|
|
39
|
-
"@fluentui/react-aria": "^9.3.
|
|
40
|
-
"@fluentui/react-avatar": "^9.5.
|
|
41
|
-
"@fluentui/react-checkbox": "^9.1.
|
|
42
|
-
"@fluentui/react-context-selector": "^9.1.
|
|
39
|
+
"@fluentui/react-aria": "^9.3.25",
|
|
40
|
+
"@fluentui/react-avatar": "^9.5.9",
|
|
41
|
+
"@fluentui/react-checkbox": "^9.1.21",
|
|
42
|
+
"@fluentui/react-context-selector": "^9.1.25",
|
|
43
43
|
"@fluentui/react-icons": "^2.0.203",
|
|
44
|
-
"@fluentui/react-radio": "^9.1.
|
|
44
|
+
"@fluentui/react-radio": "^9.1.21",
|
|
45
45
|
"@fluentui/react-shared-contexts": "^9.5.1",
|
|
46
|
-
"@fluentui/react-tabster": "^9.
|
|
46
|
+
"@fluentui/react-tabster": "^9.9.1",
|
|
47
47
|
"@fluentui/react-theme": "^9.1.9",
|
|
48
|
-
"@fluentui/react-utilities": "^9.
|
|
49
|
-
"@fluentui/react-jsx-runtime": "9.0.0-alpha.
|
|
48
|
+
"@fluentui/react-utilities": "^9.10.0",
|
|
49
|
+
"@fluentui/react-jsx-runtime": "9.0.0-alpha.9",
|
|
50
50
|
"@griffel/react": "^1.5.7",
|
|
51
51
|
"@swc/helpers": "^0.4.14"
|
|
52
52
|
},
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export function createSelectionManager(mode, onSelectionChange = ()=>undefined) {
|
|
3
|
-
const managerFactory = mode === 'multiselect' ? createMultipleSelectionManager : createSingleSelectionManager;
|
|
4
|
-
return managerFactory(onSelectionChange);
|
|
5
|
-
}
|
|
6
|
-
function createMultipleSelectionManager(onSelectionChange) {
|
|
7
|
-
const toggleAllItems = (e, itemIds, selectedItems)=>{
|
|
8
|
-
const allItemsSelected = itemIds.every((itemId)=>selectedItems.has(itemId));
|
|
9
|
-
if (allItemsSelected) {
|
|
10
|
-
selectedItems.clear();
|
|
11
|
-
} else {
|
|
12
|
-
itemIds.forEach((itemId)=>selectedItems.add(itemId));
|
|
13
|
-
}
|
|
14
|
-
onSelectionChange(e, new Set(selectedItems));
|
|
15
|
-
};
|
|
16
|
-
const toggleItem = (e, itemId, selectedItems)=>{
|
|
17
|
-
if (selectedItems.has(itemId)) {
|
|
18
|
-
selectedItems.delete(itemId);
|
|
19
|
-
} else {
|
|
20
|
-
selectedItems.add(itemId);
|
|
21
|
-
}
|
|
22
|
-
onSelectionChange(e, new Set(selectedItems));
|
|
23
|
-
};
|
|
24
|
-
const selectItem = (e, itemId, selectedItems)=>{
|
|
25
|
-
selectedItems.add(itemId);
|
|
26
|
-
onSelectionChange(e, new Set(selectedItems));
|
|
27
|
-
};
|
|
28
|
-
const deselectItem = (e, itemId, selectedItems)=>{
|
|
29
|
-
selectedItems.delete(itemId);
|
|
30
|
-
onSelectionChange(e, new Set(selectedItems));
|
|
31
|
-
};
|
|
32
|
-
const clearItems = (e)=>{
|
|
33
|
-
onSelectionChange(e, new Set());
|
|
34
|
-
};
|
|
35
|
-
const isSelected = (itemId, selectedItems)=>{
|
|
36
|
-
return selectedItems.has(itemId);
|
|
37
|
-
};
|
|
38
|
-
return {
|
|
39
|
-
toggleItem,
|
|
40
|
-
selectItem,
|
|
41
|
-
deselectItem,
|
|
42
|
-
clearItems,
|
|
43
|
-
isSelected,
|
|
44
|
-
toggleAllItems
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function createSingleSelectionManager(onSelectionChange) {
|
|
48
|
-
const toggleItem = (e, itemId)=>{
|
|
49
|
-
onSelectionChange(e, new Set([
|
|
50
|
-
itemId
|
|
51
|
-
]));
|
|
52
|
-
};
|
|
53
|
-
const clearItems = (e)=>{
|
|
54
|
-
onSelectionChange(e, new Set());
|
|
55
|
-
};
|
|
56
|
-
const isSelected = (itemId, selectedItems)=>{
|
|
57
|
-
return selectedItems.has(itemId);
|
|
58
|
-
};
|
|
59
|
-
const selectItem = (e, itemId)=>{
|
|
60
|
-
onSelectionChange(e, new Set([
|
|
61
|
-
itemId
|
|
62
|
-
]));
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
deselectItem: clearItems,
|
|
66
|
-
selectItem,
|
|
67
|
-
toggleAllItems: ()=>{
|
|
68
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
69
|
-
throw new Error('[react-table]: `toggleAllItems` should not be used in single selection mode');
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
},
|
|
73
|
-
toggleItem,
|
|
74
|
-
clearItems,
|
|
75
|
-
isSelected
|
|
76
|
-
};
|
|
77
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["selectionManager.ts"],"sourcesContent":["import * as React from 'react';\nimport { SelectionMode } from './types';\n\ntype OnSelectionChangeCallback = (e: React.SyntheticEvent, selectedItems: Set<SelectionItemId>) => void;\n\nexport interface SelectionManager {\n toggleItem(e: React.SyntheticEvent, id: SelectionItemId, selectedItems: Set<SelectionItemId>): void;\n selectItem(e: React.SyntheticEvent, id: SelectionItemId, selectedItems: Set<SelectionItemId>): void;\n deselectItem(e: React.SyntheticEvent, id: SelectionItemId, selectedItems: Set<SelectionItemId>): void;\n clearItems(e: React.SyntheticEvent): void;\n isSelected(id: SelectionItemId, selectedItems: Set<SelectionItemId>): boolean;\n toggleAllItems(e: React.SyntheticEvent, itemIds: SelectionItemId[], selectedItems: Set<SelectionItemId>): void;\n}\n\nexport type SelectionItemId = string | number;\n\nexport function createSelectionManager(\n mode: SelectionMode,\n onSelectionChange: OnSelectionChangeCallback = () => undefined,\n): SelectionManager {\n const managerFactory = mode === 'multiselect' ? createMultipleSelectionManager : createSingleSelectionManager;\n\n return managerFactory(onSelectionChange);\n}\n\nfunction createMultipleSelectionManager(onSelectionChange: OnSelectionChangeCallback): SelectionManager {\n const toggleAllItems: SelectionManager['toggleAllItems'] = (e, itemIds, selectedItems) => {\n const allItemsSelected = itemIds.every(itemId => selectedItems.has(itemId));\n\n if (allItemsSelected) {\n selectedItems.clear();\n } else {\n itemIds.forEach(itemId => selectedItems.add(itemId));\n }\n\n onSelectionChange(e, new Set(selectedItems));\n };\n\n const toggleItem: SelectionManager['toggleItem'] = (e, itemId, selectedItems) => {\n if (selectedItems.has(itemId)) {\n selectedItems.delete(itemId);\n } else {\n selectedItems.add(itemId);\n }\n\n onSelectionChange(e, new Set(selectedItems));\n };\n\n const selectItem: SelectionManager['selectItem'] = (e, itemId, selectedItems) => {\n selectedItems.add(itemId);\n onSelectionChange(e, new Set(selectedItems));\n };\n\n const deselectItem: SelectionManager['deselectItem'] = (e, itemId, selectedItems) => {\n selectedItems.delete(itemId);\n onSelectionChange(e, new Set(selectedItems));\n };\n\n const clearItems: SelectionManager['clearItems'] = e => {\n onSelectionChange(e, new Set());\n };\n\n const isSelected = (itemId: SelectionItemId, selectedItems: Set<SelectionItemId>) => {\n return selectedItems.has(itemId);\n };\n\n return {\n toggleItem,\n selectItem,\n deselectItem,\n clearItems,\n isSelected,\n toggleAllItems,\n };\n}\n\nfunction createSingleSelectionManager(onSelectionChange: OnSelectionChangeCallback): SelectionManager {\n const toggleItem: SelectionManager['toggleItem'] = (e, itemId) => {\n onSelectionChange(e, new Set([itemId]));\n };\n\n const clearItems: SelectionManager['clearItems'] = e => {\n onSelectionChange(e, new Set<SelectionItemId>());\n };\n\n const isSelected = (itemId: SelectionItemId, selectedItems: Set<SelectionItemId>) => {\n return selectedItems.has(itemId);\n };\n\n const selectItem: SelectionManager['selectItem'] = (e, itemId) => {\n onSelectionChange(e, new Set([itemId]));\n };\n\n return {\n deselectItem: clearItems,\n selectItem,\n toggleAllItems: () => {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('[react-table]: `toggleAllItems` should not be used in single selection mode');\n }\n\n return undefined;\n },\n toggleItem,\n clearItems,\n isSelected,\n };\n}\n"],"names":["React","createSelectionManager","mode","onSelectionChange","undefined","managerFactory","createMultipleSelectionManager","createSingleSelectionManager","toggleAllItems","e","itemIds","selectedItems","allItemsSelected","every","itemId","has","clear","forEach","add","Set","toggleItem","delete","selectItem","deselectItem","clearItems","isSelected","process","env","NODE_ENV","Error"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAgB/B,OAAO,SAASC,uBACdC,IAAmB,EACnBC,oBAA+C,IAAMC,SAAS,EAC5C;IAClB,MAAMC,iBAAiBH,SAAS,gBAAgBI,iCAAiCC,4BAA4B;IAE7G,OAAOF,eAAeF;AACxB,CAAC;AAED,SAASG,+BAA+BH,iBAA4C,EAAoB;IACtG,MAAMK,iBAAqD,CAACC,GAAGC,SAASC,gBAAkB;QACxF,MAAMC,mBAAmBF,QAAQG,KAAK,CAACC,CAAAA,SAAUH,cAAcI,GAAG,CAACD;QAEnE,IAAIF,kBAAkB;YACpBD,cAAcK,KAAK;QACrB,OAAO;YACLN,QAAQO,OAAO,CAACH,CAAAA,SAAUH,cAAcO,GAAG,CAACJ;QAC9C,CAAC;QAEDX,kBAAkBM,GAAG,IAAIU,IAAIR;IAC/B;IAEA,MAAMS,aAA6C,CAACX,GAAGK,QAAQH,gBAAkB;QAC/E,IAAIA,cAAcI,GAAG,CAACD,SAAS;YAC7BH,cAAcU,MAAM,CAACP;QACvB,OAAO;YACLH,cAAcO,GAAG,CAACJ;QACpB,CAAC;QAEDX,kBAAkBM,GAAG,IAAIU,IAAIR;IAC/B;IAEA,MAAMW,aAA6C,CAACb,GAAGK,QAAQH,gBAAkB;QAC/EA,cAAcO,GAAG,CAACJ;QAClBX,kBAAkBM,GAAG,IAAIU,IAAIR;IAC/B;IAEA,MAAMY,eAAiD,CAACd,GAAGK,QAAQH,gBAAkB;QACnFA,cAAcU,MAAM,CAACP;QACrBX,kBAAkBM,GAAG,IAAIU,IAAIR;IAC/B;IAEA,MAAMa,aAA6Cf,CAAAA,IAAK;QACtDN,kBAAkBM,GAAG,IAAIU;IAC3B;IAEA,MAAMM,aAAa,CAACX,QAAyBH,gBAAwC;QACnF,OAAOA,cAAcI,GAAG,CAACD;IAC3B;IAEA,OAAO;QACLM;QACAE;QACAC;QACAC;QACAC;QACAjB;IACF;AACF;AAEA,SAASD,6BAA6BJ,iBAA4C,EAAoB;IACpG,MAAMiB,aAA6C,CAACX,GAAGK,SAAW;QAChEX,kBAAkBM,GAAG,IAAIU,IAAI;YAACL;SAAO;IACvC;IAEA,MAAMU,aAA6Cf,CAAAA,IAAK;QACtDN,kBAAkBM,GAAG,IAAIU;IAC3B;IAEA,MAAMM,aAAa,CAACX,QAAyBH,gBAAwC;QACnF,OAAOA,cAAcI,GAAG,CAACD;IAC3B;IAEA,MAAMQ,aAA6C,CAACb,GAAGK,SAAW;QAChEX,kBAAkBM,GAAG,IAAIU,IAAI;YAACL;SAAO;IACvC;IAEA,OAAO;QACLS,cAAcC;QACdF;QACAd,gBAAgB,IAAM;YACpB,IAAIkB,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;gBACzC,MAAM,IAAIC,MAAM,+EAA+E;YACjG,CAAC;YAED,OAAOzB;QACT;QACAgB;QACAI;QACAC;IACF;AACF"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "createSelectionManager", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>createSelectionManager
|
|
8
|
-
});
|
|
9
|
-
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
10
|
-
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
11
|
-
function createSelectionManager(mode, onSelectionChange = ()=>undefined) {
|
|
12
|
-
const managerFactory = mode === 'multiselect' ? createMultipleSelectionManager : createSingleSelectionManager;
|
|
13
|
-
return managerFactory(onSelectionChange);
|
|
14
|
-
}
|
|
15
|
-
function createMultipleSelectionManager(onSelectionChange) {
|
|
16
|
-
const toggleAllItems = (e, itemIds, selectedItems)=>{
|
|
17
|
-
const allItemsSelected = itemIds.every((itemId)=>selectedItems.has(itemId));
|
|
18
|
-
if (allItemsSelected) {
|
|
19
|
-
selectedItems.clear();
|
|
20
|
-
} else {
|
|
21
|
-
itemIds.forEach((itemId)=>selectedItems.add(itemId));
|
|
22
|
-
}
|
|
23
|
-
onSelectionChange(e, new Set(selectedItems));
|
|
24
|
-
};
|
|
25
|
-
const toggleItem = (e, itemId, selectedItems)=>{
|
|
26
|
-
if (selectedItems.has(itemId)) {
|
|
27
|
-
selectedItems.delete(itemId);
|
|
28
|
-
} else {
|
|
29
|
-
selectedItems.add(itemId);
|
|
30
|
-
}
|
|
31
|
-
onSelectionChange(e, new Set(selectedItems));
|
|
32
|
-
};
|
|
33
|
-
const selectItem = (e, itemId, selectedItems)=>{
|
|
34
|
-
selectedItems.add(itemId);
|
|
35
|
-
onSelectionChange(e, new Set(selectedItems));
|
|
36
|
-
};
|
|
37
|
-
const deselectItem = (e, itemId, selectedItems)=>{
|
|
38
|
-
selectedItems.delete(itemId);
|
|
39
|
-
onSelectionChange(e, new Set(selectedItems));
|
|
40
|
-
};
|
|
41
|
-
const clearItems = (e)=>{
|
|
42
|
-
onSelectionChange(e, new Set());
|
|
43
|
-
};
|
|
44
|
-
const isSelected = (itemId, selectedItems)=>{
|
|
45
|
-
return selectedItems.has(itemId);
|
|
46
|
-
};
|
|
47
|
-
return {
|
|
48
|
-
toggleItem,
|
|
49
|
-
selectItem,
|
|
50
|
-
deselectItem,
|
|
51
|
-
clearItems,
|
|
52
|
-
isSelected,
|
|
53
|
-
toggleAllItems
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function createSingleSelectionManager(onSelectionChange) {
|
|
57
|
-
const toggleItem = (e, itemId)=>{
|
|
58
|
-
onSelectionChange(e, new Set([
|
|
59
|
-
itemId
|
|
60
|
-
]));
|
|
61
|
-
};
|
|
62
|
-
const clearItems = (e)=>{
|
|
63
|
-
onSelectionChange(e, new Set());
|
|
64
|
-
};
|
|
65
|
-
const isSelected = (itemId, selectedItems)=>{
|
|
66
|
-
return selectedItems.has(itemId);
|
|
67
|
-
};
|
|
68
|
-
const selectItem = (e, itemId)=>{
|
|
69
|
-
onSelectionChange(e, new Set([
|
|
70
|
-
itemId
|
|
71
|
-
]));
|
|
72
|
-
};
|
|
73
|
-
return {
|
|
74
|
-
deselectItem: clearItems,
|
|
75
|
-
selectItem,
|
|
76
|
-
toggleAllItems: ()=>{
|
|
77
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
78
|
-
throw new Error('[react-table]: `toggleAllItems` should not be used in single selection mode');
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
81
|
-
},
|
|
82
|
-
toggleItem,
|
|
83
|
-
clearItems,
|
|
84
|
-
isSelected
|
|
85
|
-
};
|
|
86
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["selectionManager.js"],"sourcesContent":["import * as React from 'react';\nexport function createSelectionManager(mode, onSelectionChange = ()=>undefined) {\n const managerFactory = mode === 'multiselect' ? createMultipleSelectionManager : createSingleSelectionManager;\n return managerFactory(onSelectionChange);\n}\nfunction createMultipleSelectionManager(onSelectionChange) {\n const toggleAllItems = (e, itemIds, selectedItems)=>{\n const allItemsSelected = itemIds.every((itemId)=>selectedItems.has(itemId));\n if (allItemsSelected) {\n selectedItems.clear();\n } else {\n itemIds.forEach((itemId)=>selectedItems.add(itemId));\n }\n onSelectionChange(e, new Set(selectedItems));\n };\n const toggleItem = (e, itemId, selectedItems)=>{\n if (selectedItems.has(itemId)) {\n selectedItems.delete(itemId);\n } else {\n selectedItems.add(itemId);\n }\n onSelectionChange(e, new Set(selectedItems));\n };\n const selectItem = (e, itemId, selectedItems)=>{\n selectedItems.add(itemId);\n onSelectionChange(e, new Set(selectedItems));\n };\n const deselectItem = (e, itemId, selectedItems)=>{\n selectedItems.delete(itemId);\n onSelectionChange(e, new Set(selectedItems));\n };\n const clearItems = (e)=>{\n onSelectionChange(e, new Set());\n };\n const isSelected = (itemId, selectedItems)=>{\n return selectedItems.has(itemId);\n };\n return {\n toggleItem,\n selectItem,\n deselectItem,\n clearItems,\n isSelected,\n toggleAllItems\n };\n}\nfunction createSingleSelectionManager(onSelectionChange) {\n const toggleItem = (e, itemId)=>{\n onSelectionChange(e, new Set([\n itemId\n ]));\n };\n const clearItems = (e)=>{\n onSelectionChange(e, new Set());\n };\n const isSelected = (itemId, selectedItems)=>{\n return selectedItems.has(itemId);\n };\n const selectItem = (e, itemId)=>{\n onSelectionChange(e, new Set([\n itemId\n ]));\n };\n return {\n deselectItem: clearItems,\n selectItem,\n toggleAllItems: ()=>{\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('[react-table]: `toggleAllItems` should not be used in single selection mode');\n }\n return undefined;\n },\n toggleItem,\n clearItems,\n isSelected\n };\n}\n"],"names":["createSelectionManager","mode","onSelectionChange","undefined","managerFactory","createMultipleSelectionManager","createSingleSelectionManager","toggleAllItems","e","itemIds","selectedItems","allItemsSelected","every","itemId","has","clear","forEach","add","Set","toggleItem","delete","selectItem","deselectItem","clearItems","isSelected","process","env","NODE_ENV","Error"],"mappings":";;;;+BACgBA;;aAAAA;;;6DADO;AAChB,SAASA,uBAAuBC,IAAI,EAAEC,oBAAoB,IAAIC,SAAS,EAAE;IAC5E,MAAMC,iBAAiBH,SAAS,gBAAgBI,iCAAiCC,4BAA4B;IAC7G,OAAOF,eAAeF;AAC1B;AACA,SAASG,+BAA+BH,iBAAiB,EAAE;IACvD,MAAMK,iBAAiB,CAACC,GAAGC,SAASC,gBAAgB;QAChD,MAAMC,mBAAmBF,QAAQG,KAAK,CAAC,CAACC,SAASH,cAAcI,GAAG,CAACD;QACnE,IAAIF,kBAAkB;YAClBD,cAAcK,KAAK;QACvB,OAAO;YACHN,QAAQO,OAAO,CAAC,CAACH,SAASH,cAAcO,GAAG,CAACJ;QAChD,CAAC;QACDX,kBAAkBM,GAAG,IAAIU,IAAIR;IACjC;IACA,MAAMS,aAAa,CAACX,GAAGK,QAAQH,gBAAgB;QAC3C,IAAIA,cAAcI,GAAG,CAACD,SAAS;YAC3BH,cAAcU,MAAM,CAACP;QACzB,OAAO;YACHH,cAAcO,GAAG,CAACJ;QACtB,CAAC;QACDX,kBAAkBM,GAAG,IAAIU,IAAIR;IACjC;IACA,MAAMW,aAAa,CAACb,GAAGK,QAAQH,gBAAgB;QAC3CA,cAAcO,GAAG,CAACJ;QAClBX,kBAAkBM,GAAG,IAAIU,IAAIR;IACjC;IACA,MAAMY,eAAe,CAACd,GAAGK,QAAQH,gBAAgB;QAC7CA,cAAcU,MAAM,CAACP;QACrBX,kBAAkBM,GAAG,IAAIU,IAAIR;IACjC;IACA,MAAMa,aAAa,CAACf,IAAI;QACpBN,kBAAkBM,GAAG,IAAIU;IAC7B;IACA,MAAMM,aAAa,CAACX,QAAQH,gBAAgB;QACxC,OAAOA,cAAcI,GAAG,CAACD;IAC7B;IACA,OAAO;QACHM;QACAE;QACAC;QACAC;QACAC;QACAjB;IACJ;AACJ;AACA,SAASD,6BAA6BJ,iBAAiB,EAAE;IACrD,MAAMiB,aAAa,CAACX,GAAGK,SAAS;QAC5BX,kBAAkBM,GAAG,IAAIU,IAAI;YACzBL;SACH;IACL;IACA,MAAMU,aAAa,CAACf,IAAI;QACpBN,kBAAkBM,GAAG,IAAIU;IAC7B;IACA,MAAMM,aAAa,CAACX,QAAQH,gBAAgB;QACxC,OAAOA,cAAcI,GAAG,CAACD;IAC7B;IACA,MAAMQ,aAAa,CAACb,GAAGK,SAAS;QAC5BX,kBAAkBM,GAAG,IAAIU,IAAI;YACzBL;SACH;IACL;IACA,OAAO;QACHS,cAAcC;QACdF;QACAd,gBAAgB,IAAI;YAChB,IAAIkB,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;gBACvC,MAAM,IAAIC,MAAM,+EAA+E;YACnG,CAAC;YACD,OAAOzB;QACX;QACAgB;QACAI;QACAC;IACJ;AACJ"}
|