@fluentui/react-table 9.0.0-alpha.10 → 9.0.0-alpha.11
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 +90 -1
- package/CHANGELOG.md +22 -2
- package/dist/index.d.ts +50 -6
- package/lib/components/DataGrid/DataGrid.types.js.map +1 -1
- package/lib/components/DataGrid/renderDataGrid.js +5 -1
- package/lib/components/DataGrid/renderDataGrid.js.map +1 -1
- package/lib/components/DataGrid/useDataGrid.js +24 -2
- package/lib/components/DataGrid/useDataGrid.js.map +1 -1
- package/lib/components/DataGrid/useDataGridContextValues.js +6 -1
- package/lib/components/DataGrid/useDataGridContextValues.js.map +1 -1
- package/lib/components/DataGridBody/DataGridBody.types.js.map +1 -1
- package/lib/components/DataGridBody/useDataGridBody.js +8 -0
- package/lib/components/DataGridBody/useDataGridBody.js.map +1 -1
- package/lib/components/DataGridCell/useDataGridCell.js +7 -2
- package/lib/components/DataGridCell/useDataGridCell.js.map +1 -1
- package/lib/components/DataGridRow/DataGridRow.types.js.map +1 -1
- package/lib/components/DataGridRow/useDataGridRow.js +7 -0
- package/lib/components/DataGridRow/useDataGridRow.js.map +1 -1
- package/lib/components/DataGridSelectionCell/useDataGridSelectionCell.js +4 -2
- package/lib/components/DataGridSelectionCell/useDataGridSelectionCell.js.map +1 -1
- package/lib/contexts/dataGridContext.js +9 -0
- package/lib/contexts/dataGridContext.js.map +1 -0
- package/lib/hooks/createColumn.js +41 -0
- package/lib/hooks/createColumn.js.map +1 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/types.js.map +1 -1
- package/lib/hooks/useTable.js +8 -0
- package/lib/hooks/useTable.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/components/DataGrid/renderDataGrid.js +7 -1
- package/lib-commonjs/components/DataGrid/renderDataGrid.js.map +1 -1
- package/lib-commonjs/components/DataGrid/useDataGrid.js +26 -2
- package/lib-commonjs/components/DataGrid/useDataGrid.js.map +1 -1
- package/lib-commonjs/components/DataGrid/useDataGridContextValues.js +6 -1
- package/lib-commonjs/components/DataGrid/useDataGridContextValues.js.map +1 -1
- package/lib-commonjs/components/DataGridBody/useDataGridBody.js +9 -0
- package/lib-commonjs/components/DataGridBody/useDataGridBody.js.map +1 -1
- package/lib-commonjs/components/DataGridCell/useDataGridCell.js +8 -2
- package/lib-commonjs/components/DataGridCell/useDataGridCell.js.map +1 -1
- package/lib-commonjs/components/DataGridRow/useDataGridRow.js +8 -0
- package/lib-commonjs/components/DataGridRow/useDataGridRow.js.map +1 -1
- package/lib-commonjs/components/DataGridSelectionCell/useDataGridSelectionCell.js +4 -2
- package/lib-commonjs/components/DataGridSelectionCell/useDataGridSelectionCell.js.map +1 -1
- package/lib-commonjs/contexts/dataGridContext.js +21 -0
- package/lib-commonjs/contexts/dataGridContext.js.map +1 -0
- package/lib-commonjs/hooks/createColumn.js +50 -0
- package/lib-commonjs/hooks/createColumn.js.map +1 -0
- package/lib-commonjs/hooks/index.js +2 -0
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useTable.js +10 -1
- package/lib-commonjs/hooks/useTable.js.map +1 -1
- package/lib-commonjs/index.js +8 -2
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +10 -9
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,96 @@
|
|
|
2
2
|
"name": "@fluentui/react-table",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Fri, 11 Nov 2022 14:53:28 GMT",
|
|
6
|
+
"tag": "@fluentui/react-table_v9.0.0-alpha.11",
|
|
7
|
+
"version": "9.0.0-alpha.11",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"author": "martinhochel@microsoft.com",
|
|
12
|
+
"package": "@fluentui/react-table",
|
|
13
|
+
"commit": "87859b052155ca206ef3540a2a9623803f6e2b93",
|
|
14
|
+
"comment": "test: replace deprecated module.parent with require.main within isConformance"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"prerelease": [
|
|
18
|
+
{
|
|
19
|
+
"author": "lingfangao@hotmail.com",
|
|
20
|
+
"package": "@fluentui/react-table",
|
|
21
|
+
"commit": "48c85202ce3c230fdc83bde3ce494f952632b16f",
|
|
22
|
+
"comment": "feat: Implement child render function for DataGrid rows"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"author": "lingfangao@hotmail.com",
|
|
26
|
+
"package": "@fluentui/react-table",
|
|
27
|
+
"commit": "3088a39d2d18156388378ac9a629e48277347ae7",
|
|
28
|
+
"comment": "feat: Implement `focusMode` prop for DataGrid, apply role=\"grid\" correctly"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"author": "lingfangao@hotmail.com",
|
|
32
|
+
"package": "@fluentui/react-table",
|
|
33
|
+
"commit": "6645c490bdc0ae1147e46890bef10759934457d3",
|
|
34
|
+
"comment": "BREAKING: ColumnDefinition type is stricter, use createColumn to create column definition. Implments render function for DataGridRow."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"author": "beachball",
|
|
38
|
+
"package": "@fluentui/react-table",
|
|
39
|
+
"comment": "Bump @fluentui/react-aria to v9.3.1",
|
|
40
|
+
"commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"author": "beachball",
|
|
44
|
+
"package": "@fluentui/react-table",
|
|
45
|
+
"comment": "Bump @fluentui/react-avatar to v9.2.6",
|
|
46
|
+
"commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"author": "beachball",
|
|
50
|
+
"package": "@fluentui/react-table",
|
|
51
|
+
"comment": "Bump @fluentui/react-checkbox to v9.0.12",
|
|
52
|
+
"commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"author": "beachball",
|
|
56
|
+
"package": "@fluentui/react-table",
|
|
57
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.1",
|
|
58
|
+
"commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"author": "beachball",
|
|
62
|
+
"package": "@fluentui/react-table",
|
|
63
|
+
"comment": "Bump @fluentui/react-radio to v9.0.11",
|
|
64
|
+
"commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"author": "beachball",
|
|
68
|
+
"package": "@fluentui/react-table",
|
|
69
|
+
"comment": "Bump @fluentui/react-tabster to v9.3.0",
|
|
70
|
+
"commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"author": "beachball",
|
|
74
|
+
"package": "@fluentui/react-table",
|
|
75
|
+
"comment": "Bump @fluentui/react-theme to v9.1.2",
|
|
76
|
+
"commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"author": "beachball",
|
|
80
|
+
"package": "@fluentui/react-table",
|
|
81
|
+
"comment": "Bump @fluentui/react-utilities to v9.2.1",
|
|
82
|
+
"commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"author": "beachball",
|
|
86
|
+
"package": "@fluentui/react-table",
|
|
87
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.18",
|
|
88
|
+
"commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"date": "Wed, 02 Nov 2022 14:27:34 GMT",
|
|
6
95
|
"tag": "@fluentui/react-table_v9.0.0-alpha.10",
|
|
7
96
|
"version": "9.0.0-alpha.10",
|
|
8
97
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-table
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 11 Nov 2022 14:53:28 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-alpha.11](https://github.com/microsoft/fluentui/tree/@fluentui/react-table_v9.0.0-alpha.11)
|
|
8
|
+
|
|
9
|
+
Fri, 11 Nov 2022 14:53:28 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-table_v9.0.0-alpha.10..@fluentui/react-table_v9.0.0-alpha.11)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- feat: Implement child render function for DataGrid rows ([PR #25476](https://github.com/microsoft/fluentui/pull/25476) by lingfangao@hotmail.com)
|
|
15
|
+
- feat: Implement `focusMode` prop for DataGrid, apply role="grid" correctly ([PR #25530](https://github.com/microsoft/fluentui/pull/25530) by lingfangao@hotmail.com)
|
|
16
|
+
- BREAKING: ColumnDefinition type is stricter, use createColumn to create column definition. Implments render function for DataGridRow. ([PR #25495](https://github.com/microsoft/fluentui/pull/25495) by lingfangao@hotmail.com)
|
|
17
|
+
- Bump @fluentui/react-aria to v9.3.1 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
|
|
18
|
+
- Bump @fluentui/react-avatar to v9.2.6 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
|
|
19
|
+
- Bump @fluentui/react-checkbox to v9.0.12 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
|
|
20
|
+
- Bump @fluentui/react-context-selector to v9.1.1 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
|
|
21
|
+
- Bump @fluentui/react-radio to v9.0.11 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
|
|
22
|
+
- Bump @fluentui/react-tabster to v9.3.0 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
|
|
23
|
+
- Bump @fluentui/react-theme to v9.1.2 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
|
|
24
|
+
- Bump @fluentui/react-utilities to v9.2.1 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
|
|
25
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.18 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
|
|
26
|
+
|
|
7
27
|
## [9.0.0-alpha.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-table_v9.0.0-alpha.10)
|
|
8
28
|
|
|
9
|
-
Wed, 02 Nov 2022 14:27:
|
|
29
|
+
Wed, 02 Nov 2022 14:27:34 GMT
|
|
10
30
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-table_v9.0.0-alpha.9..@fluentui/react-table_v9.0.0-alpha.10)
|
|
11
31
|
|
|
12
32
|
### Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -9,16 +9,37 @@ import type { ComponentState } from '@fluentui/react-utilities';
|
|
|
9
9
|
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
|
+
import { ReactNode } from 'react';
|
|
12
13
|
import type { Slot } from '@fluentui/react-utilities';
|
|
13
14
|
import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
14
15
|
|
|
16
|
+
export declare type CellRenderFunction = (column: ColumnDefinition<any>) => React_2.ReactNode;
|
|
17
|
+
|
|
15
18
|
export declare interface ColumnDefinition<TItem> {
|
|
16
19
|
columnId: ColumnId;
|
|
17
|
-
compare
|
|
20
|
+
compare: (a: TItem, b: TItem) => number;
|
|
21
|
+
renderHeaderCell: () => React_2.ReactNode;
|
|
22
|
+
renderCell: (item: TItem) => React_2.ReactNode;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
export declare type ColumnId = string | number;
|
|
21
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Helper function to create column definition with defaults
|
|
29
|
+
* @param options - column definition options
|
|
30
|
+
* @returns - column definition with defaults
|
|
31
|
+
*/
|
|
32
|
+
export declare function createColumn<TItem>(options: CreateColumnOptions<TItem>): {
|
|
33
|
+
columnId: ColumnId;
|
|
34
|
+
renderCell: (item: TItem) => ReactNode;
|
|
35
|
+
renderHeaderCell: () => ReactNode;
|
|
36
|
+
compare: (a: TItem, b: TItem) => number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export declare interface CreateColumnOptions<TItem> extends Partial<ColumnDefinition<TItem>> {
|
|
40
|
+
columnId: ColumnId;
|
|
41
|
+
}
|
|
42
|
+
|
|
22
43
|
/**
|
|
23
44
|
* DataGrid component - TODO: add more docs
|
|
24
45
|
*/
|
|
@@ -34,7 +55,12 @@ export declare const dataGridBodyClassNames: SlotClassNames<DataGridBodySlots>;
|
|
|
34
55
|
/**
|
|
35
56
|
* DataGridBody Props
|
|
36
57
|
*/
|
|
37
|
-
export declare type DataGridBodyProps = TableBodyProps
|
|
58
|
+
export declare type DataGridBodyProps = Omit<TableBodyProps, 'children'> & {
|
|
59
|
+
/**
|
|
60
|
+
* Render function for rows
|
|
61
|
+
*/
|
|
62
|
+
children: RowRenderFunction;
|
|
63
|
+
};
|
|
38
64
|
|
|
39
65
|
export declare type DataGridBodySlots = TableBodySlots;
|
|
40
66
|
|
|
@@ -64,7 +90,17 @@ export declare type DataGridCellState = TableCellState;
|
|
|
64
90
|
|
|
65
91
|
export declare const dataGridClassNames: SlotClassNames<DataGridSlots>;
|
|
66
92
|
|
|
67
|
-
export declare type
|
|
93
|
+
export declare type DataGridContextValue = HeadlessTableState<any> & {
|
|
94
|
+
/**
|
|
95
|
+
* How focus navigation will work in the datagrid
|
|
96
|
+
* @default none
|
|
97
|
+
*/
|
|
98
|
+
focusMode: FocusMode;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export declare type DataGridContextValues = TableContextValues & {
|
|
102
|
+
dataGrid: DataGridContextValue;
|
|
103
|
+
};
|
|
68
104
|
|
|
69
105
|
/**
|
|
70
106
|
* DataGridHeader component - TODO: add more docs
|
|
@@ -107,7 +143,7 @@ export declare type DataGridHeaderState = TableHeaderState;
|
|
|
107
143
|
/**
|
|
108
144
|
* DataGrid Props
|
|
109
145
|
*/
|
|
110
|
-
export declare type DataGridProps = TableProps
|
|
146
|
+
export declare type DataGridProps = TableProps & Pick<DataGridContextValue, 'items' | 'columns'> & Pick<Partial<DataGridContextValue>, 'focusMode'>;
|
|
111
147
|
|
|
112
148
|
/**
|
|
113
149
|
* DataGridRow component - TODO: add more docs
|
|
@@ -119,7 +155,9 @@ export declare const dataGridRowClassNames: SlotClassNames<DataGridRowSlots>;
|
|
|
119
155
|
/**
|
|
120
156
|
* DataGridRow Props
|
|
121
157
|
*/
|
|
122
|
-
export declare type DataGridRowProps = TableRowProps
|
|
158
|
+
export declare type DataGridRowProps = Omit<TableRowProps, 'children'> & {
|
|
159
|
+
children: CellRenderFunction;
|
|
160
|
+
};
|
|
123
161
|
|
|
124
162
|
export declare type DataGridRowSlots = TableRowSlots;
|
|
125
163
|
|
|
@@ -152,7 +190,11 @@ export declare type DataGridSlots = TableSlots;
|
|
|
152
190
|
/**
|
|
153
191
|
* State used in rendering DataGrid
|
|
154
192
|
*/
|
|
155
|
-
export declare type DataGridState = TableState
|
|
193
|
+
export declare type DataGridState = TableState & {
|
|
194
|
+
tableState: HeadlessTableState<unknown>;
|
|
195
|
+
} & Pick<DataGridContextValue, 'focusMode'>;
|
|
196
|
+
|
|
197
|
+
export declare type FocusMode = 'none' | 'cell';
|
|
156
198
|
|
|
157
199
|
export declare interface HeadlessTableState<TItem> extends Pick<UseTableOptions<TItem>, 'items' | 'getRowId'> {
|
|
158
200
|
/**
|
|
@@ -258,6 +300,8 @@ declare type RowEnhancer<TItem, TRowState extends RowState<TItem> = RowState<TIt
|
|
|
258
300
|
|
|
259
301
|
export declare type RowId = string | number;
|
|
260
302
|
|
|
303
|
+
export declare type RowRenderFunction<TItem = any> = (row: RowState<TItem>) => React_2.ReactNode;
|
|
304
|
+
|
|
261
305
|
export declare interface RowState<TItem> {
|
|
262
306
|
/**
|
|
263
307
|
* User provided data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGrid.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/components/DataGrid/DataGrid.types.ts"],"names":[],"mappings":"","sourcesContent":["import { TableContextValues, TableProps, TableSlots, TableState } from '../Table/Table.types';\n\nexport type DataGridSlots = TableSlots;\n\nexport type DataGridContextValues = TableContextValues;\n\n/**\n * DataGrid Props\n */\nexport type DataGridProps = TableProps
|
|
1
|
+
{"version":3,"file":"DataGrid.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/components/DataGrid/DataGrid.types.ts"],"names":[],"mappings":"","sourcesContent":["import { TableContextValues, TableProps, TableSlots, TableState } from '../Table/Table.types';\nimport { TableState as HeadlessTableState } from '../../hooks';\n\nexport type DataGridSlots = TableSlots;\n\nexport type FocusMode = 'none' | 'cell';\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 = HeadlessTableState<any> & {\n /**\n * How focus navigation will work in the datagrid\n * @default none\n */\n focusMode: FocusMode;\n};\n\n/**\n * DataGrid Props\n */\nexport type DataGridProps = TableProps &\n Pick<DataGridContextValue, 'items' | 'columns'> &\n Pick<Partial<DataGridContextValue>, 'focusMode'>;\n\n/**\n * State used in rendering DataGrid\n */\nexport type DataGridState = TableState & { tableState: HeadlessTableState<unknown> } & Pick<\n DataGridContextValue,\n 'focusMode'\n >;\n"]}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { renderTable_unstable } from '../Table/renderTable';
|
|
3
|
+
import { DataGridContextProvider } from '../../contexts/dataGridContext';
|
|
2
4
|
/**
|
|
3
5
|
* Render the final JSX of DataGrid
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
export const renderDataGrid_unstable = (state, contextValues) => {
|
|
7
|
-
return
|
|
9
|
+
return /*#__PURE__*/React.createElement(DataGridContextProvider, {
|
|
10
|
+
value: contextValues.dataGrid
|
|
11
|
+
}, renderTable_unstable(state, contextValues));
|
|
8
12
|
};
|
|
9
13
|
//# sourceMappingURL=renderDataGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGrid/renderDataGrid.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGrid/renderDataGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,SAAS,oBAAT,QAAqC,sBAArC;AACA,SAAS,uBAAT,QAAwC,gCAAxC;AAEA;;AAEG;;AACH,OAAO,MAAM,uBAAuB,GAAG,CAAC,KAAD,EAAuB,aAAvB,KAA+D;EACpG,oBACE,KAAA,CAAA,aAAA,CAAC,uBAAD,EAAwB;IAAC,KAAK,EAAE,aAAa,CAAC;EAAtB,CAAxB,EACG,oBAAoB,CAAC,KAAD,EAAQ,aAAR,CADvB,CADF;AAKD,CANM","sourcesContent":["import * as React from 'react';\nimport type { DataGridContextValues, DataGridState } from './DataGrid.types';\nimport { renderTable_unstable } from '../Table/renderTable';\nimport { DataGridContextProvider } from '../../contexts/dataGridContext';\n\n/**\n * Render the final JSX of DataGrid\n */\nexport const renderDataGrid_unstable = (state: DataGridState, contextValues: DataGridContextValues) => {\n return (\n <DataGridContextProvider value={contextValues.dataGrid}>\n {renderTable_unstable(state, contextValues)}\n </DataGridContextProvider>\n );\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
1
2
|
import { useTable_unstable } from '../Table/useTable';
|
|
3
|
+
import { useTable } from '../../hooks/useTable';
|
|
2
4
|
/**
|
|
3
5
|
* Create the state required to render DataGrid.
|
|
4
6
|
*
|
|
@@ -10,8 +12,28 @@ import { useTable_unstable } from '../Table/useTable';
|
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
export const useDataGrid_unstable = (props, ref) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const {
|
|
16
|
+
items,
|
|
17
|
+
columns,
|
|
18
|
+
focusMode = 'none'
|
|
19
|
+
} = props;
|
|
20
|
+
const navigable = focusMode !== 'none';
|
|
21
|
+
const keyboardNavAttr = useArrowNavigationGroup({
|
|
22
|
+
axis: 'grid'
|
|
23
|
+
});
|
|
24
|
+
const tableState = useTable({
|
|
25
|
+
items,
|
|
26
|
+
columns
|
|
27
|
+
}, []);
|
|
28
|
+
const baseTableState = useTable_unstable({
|
|
29
|
+
role: 'grid',
|
|
30
|
+
as: 'div',
|
|
31
|
+
...(navigable && keyboardNavAttr),
|
|
32
|
+
...props
|
|
15
33
|
}, ref);
|
|
34
|
+
return { ...baseTableState,
|
|
35
|
+
focusMode,
|
|
36
|
+
tableState
|
|
37
|
+
};
|
|
16
38
|
};
|
|
17
39
|
//# sourceMappingURL=useDataGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGrid/useDataGrid.ts"],"names":[],"mappings":"AAEA,SAAS,iBAAT,QAAkC,mBAAlC;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,oBAAoB,GAAG,CAAC,KAAD,EAAuB,GAAvB,KAAqE;EACvG,
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGrid/useDataGrid.ts"],"names":[],"mappings":"AACA,SAAS,uBAAT,QAAwC,yBAAxC;AAEA,SAAS,iBAAT,QAAkC,mBAAlC;AACA,SAAS,QAAT,QAAyB,sBAAzB;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,oBAAoB,GAAG,CAAC,KAAD,EAAuB,GAAvB,KAAqE;EACvG,MAAM;IAAE,KAAF;IAAS,OAAT;IAAkB,SAAS,GAAG;EAA9B,IAAyC,KAA/C;EACA,MAAM,SAAS,GAAG,SAAS,KAAK,MAAhC;EACA,MAAM,eAAe,GAAG,uBAAuB,CAAC;IAAE,IAAI,EAAE;EAAR,CAAD,CAA/C;EACA,MAAM,UAAU,GAAG,QAAQ,CAAC;IAAE,KAAF;IAAS;EAAT,CAAD,EAAqB,EAArB,CAA3B;EACA,MAAM,cAAc,GAAG,iBAAiB,CACtC;IAAE,IAAI,EAAE,MAAR;IAAgB,EAAE,EAAE,KAApB;IAA2B,IAAI,SAAS,IAAI,eAAjB,CAA3B;IAA8D,GAAG;EAAjE,CADsC,EAEtC,GAFsC,CAAxC;EAKA,OAAO,EACL,GAAG,cADE;IAEL,SAFK;IAGL;EAHK,CAAP;AAKD,CAfM","sourcesContent":["import * as React from 'react';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport type { DataGridProps, DataGridState } from './DataGrid.types';\nimport { useTable_unstable } from '../Table/useTable';\nimport { useTable } from '../../hooks/useTable';\n\n/**\n * Create the state required to render DataGrid.\n *\n * The returned state can be modified with hooks such as useDataGridStyles_unstable,\n * before being passed to renderDataGrid_unstable.\n *\n * @param props - props from this instance of DataGrid\n * @param ref - reference to root HTMLElement of DataGrid\n */\nexport const useDataGrid_unstable = (props: DataGridProps, ref: React.Ref<HTMLElement>): DataGridState => {\n const { items, columns, focusMode = 'none' } = props;\n const navigable = focusMode !== 'none';\n const keyboardNavAttr = useArrowNavigationGroup({ axis: 'grid' });\n const tableState = useTable({ items, columns }, []);\n const baseTableState = useTable_unstable(\n { role: 'grid', as: 'div', ...(navigable && keyboardNavAttr), ...props },\n ref,\n );\n\n return {\n ...baseTableState,\n focusMode,\n tableState,\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { useTableContextValues_unstable } from '../Table/useTableContextValues';
|
|
2
2
|
export function useDataGridContextValues_unstable(state) {
|
|
3
|
-
|
|
3
|
+
const tableContextValues = useTableContextValues_unstable(state);
|
|
4
|
+
return { ...tableContextValues,
|
|
5
|
+
dataGrid: { ...state.tableState,
|
|
6
|
+
focusMode: state.focusMode
|
|
7
|
+
}
|
|
8
|
+
};
|
|
4
9
|
}
|
|
5
10
|
//# sourceMappingURL=useDataGridContextValues.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGrid/useDataGridContextValues.ts"],"names":[],"mappings":"AAAA,SAAS,8BAAT,QAA+C,gCAA/C;AAGA,OAAM,SAAU,iCAAV,CAA4C,KAA5C,EAAgE;EACpE,
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGrid/useDataGridContextValues.ts"],"names":[],"mappings":"AAAA,SAAS,8BAAT,QAA+C,gCAA/C;AAGA,OAAM,SAAU,iCAAV,CAA4C,KAA5C,EAAgE;EACpE,MAAM,kBAAkB,GAAG,8BAA8B,CAAC,KAAD,CAAzD;EACA,OAAO,EACL,GAAG,kBADE;IAEL,QAAQ,EAAE,EACR,GAAG,KAAK,CAAC,UADD;MAER,SAAS,EAAE,KAAK,CAAC;IAFT;EAFL,CAAP;AAOD","sourcesContent":["import { useTableContextValues_unstable } from '../Table/useTableContextValues';\nimport { DataGridContextValues, DataGridState } from './DataGrid.types';\n\nexport function useDataGridContextValues_unstable(state: DataGridState): DataGridContextValues {\n const tableContextValues = useTableContextValues_unstable(state);\n return {\n ...tableContextValues,\n dataGrid: {\n ...state.tableState,\n focusMode: state.focusMode,\n },\n };\n}\n"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridBody.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/components/DataGridBody/DataGridBody.types.ts"],"names":[],"mappings":"","sourcesContent":["import { TableBodySlots, TableBodyProps, TableBodyState } from '../TableBody/TableBody.types';\n\nexport type DataGridBodySlots = TableBodySlots;\n\n/**\n * DataGridBody Props\n */\nexport type DataGridBodyProps = TableBodyProps;\n\n/**\n * State used in rendering DataGridBody\n */\nexport type DataGridBodyState = TableBodyState;\n"]}
|
|
1
|
+
{"version":3,"file":"DataGridBody.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/components/DataGridBody/DataGridBody.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { RowState } from '../../hooks';\nimport type { TableBodySlots, TableBodyProps, TableBodyState } from '../TableBody/TableBody.types';\n\nexport type DataGridBodySlots = TableBodySlots;\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 RowRenderFunction<TItem = any> = (row: RowState<TItem>) => React.ReactNode;\n\n/**\n * DataGridBody Props\n */\nexport type DataGridBodyProps = Omit<TableBodyProps, 'children'> & {\n /**\n * Render function for rows\n */\n children: RowRenderFunction;\n};\n\n/**\n * State used in rendering DataGridBody\n */\nexport type DataGridBodyState = TableBodyState;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useTableBody_unstable } from '../TableBody/useTableBody';
|
|
2
|
+
import { useDataGridContext_unstable } from '../../contexts/dataGridContext';
|
|
2
3
|
/**
|
|
3
4
|
* Create the state required to render DataGridBody.
|
|
4
5
|
*
|
|
@@ -10,7 +11,14 @@ import { useTableBody_unstable } from '../TableBody/useTableBody';
|
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
export const useDataGridBody_unstable = (props, ref) => {
|
|
14
|
+
const getRows = useDataGridContext_unstable(ctx => ctx.getRows);
|
|
15
|
+
const rows = getRows();
|
|
16
|
+
const {
|
|
17
|
+
children: renderRow
|
|
18
|
+
} = props;
|
|
19
|
+
const children = rows.map(row => renderRow(row));
|
|
13
20
|
return useTableBody_unstable({ ...props,
|
|
21
|
+
children,
|
|
14
22
|
as: 'div'
|
|
15
23
|
}, ref);
|
|
16
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridBody/useDataGridBody.ts"],"names":[],"mappings":"AAEA,SAAS,qBAAT,QAAsC,2BAAtC;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,wBAAwB,GAAG,CAAC,KAAD,EAA2B,GAA3B,KAA6E;EACnH,OAAO,qBAAqB,CAAC,EAAE,GAAG,KAAL;IAAY,EAAE,EAAE;
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridBody/useDataGridBody.ts"],"names":[],"mappings":"AAEA,SAAS,qBAAT,QAAsC,2BAAtC;AACA,SAAS,2BAAT,QAA4C,gCAA5C;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,wBAAwB,GAAG,CAAC,KAAD,EAA2B,GAA3B,KAA6E;EACnH,MAAM,OAAO,GAAG,2BAA2B,CAAC,GAAG,IAAI,GAAG,CAAC,OAAZ,CAA3C;EACA,MAAM,IAAI,GAAG,OAAO,EAApB;EAEA,MAAM;IAAE,QAAQ,EAAE;EAAZ,IAA0B,KAAhC;EACA,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAL,CAAS,GAAG,IAAI,SAAS,CAAC,GAAD,CAAzB,CAAjB;EACA,OAAO,qBAAqB,CAAC,EAAE,GAAG,KAAL;IAAY,QAAZ;IAAsB,EAAE,EAAE;EAA1B,CAAD,EAAoC,GAApC,CAA5B;AACD,CAPM","sourcesContent":["import * as React from 'react';\nimport type { DataGridBodyProps, DataGridBodyState } from './DataGridBody.types';\nimport { useTableBody_unstable } from '../TableBody/useTableBody';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\n\n/**\n * Create the state required to render DataGridBody.\n *\n * The returned state can be modified with hooks such as useDataGridBodyStyles_unstable,\n * before being passed to renderDataGridBody_unstable.\n *\n * @param props - props from this instance of DataGridBody\n * @param ref - reference to root HTMLElement of DataGridBody\n */\nexport const useDataGridBody_unstable = (props: DataGridBodyProps, ref: React.Ref<HTMLElement>): DataGridBodyState => {\n const getRows = useDataGridContext_unstable(ctx => ctx.getRows);\n const rows = getRows();\n\n const { children: renderRow } = props;\n const children = rows.map(row => renderRow(row));\n return useTableBody_unstable({ ...props, children, as: 'div' }, ref);\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useTableCell_unstable } from '../TableCell/useTableCell';
|
|
2
|
+
import { useDataGridContext_unstable } from '../../contexts/dataGridContext';
|
|
2
3
|
/**
|
|
3
4
|
* Create the state required to render DataGridCell.
|
|
4
5
|
*
|
|
@@ -10,8 +11,12 @@ import { useTableCell_unstable } from '../TableCell/useTableCell';
|
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
export const useDataGridCell_unstable = (props, ref) => {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
const tabbable = useDataGridContext_unstable(ctx => ctx.focusMode !== 'none');
|
|
15
|
+
return useTableCell_unstable({
|
|
16
|
+
as: 'div',
|
|
17
|
+
role: 'gridcell',
|
|
18
|
+
tabIndex: tabbable ? 0 : undefined,
|
|
19
|
+
...props
|
|
15
20
|
}, ref);
|
|
16
21
|
};
|
|
17
22
|
//# sourceMappingURL=useDataGridCell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridCell/useDataGridCell.ts"],"names":[],"mappings":"AAEA,SAAS,qBAAT,QAAsC,2BAAtC;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,wBAAwB,GAAG,CAAC,KAAD,EAA2B,GAA3B,KAA6E;EACnH,OAAO,qBAAqB,CAAC,EAAE,
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridCell/useDataGridCell.ts"],"names":[],"mappings":"AAEA,SAAS,qBAAT,QAAsC,2BAAtC;AACA,SAAS,2BAAT,QAA4C,gCAA5C;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,wBAAwB,GAAG,CAAC,KAAD,EAA2B,GAA3B,KAA6E;EACnH,MAAM,QAAQ,GAAG,2BAA2B,CAAC,GAAG,IAAI,GAAG,CAAC,SAAJ,KAAkB,MAA1B,CAA5C;EACA,OAAO,qBAAqB,CAAC;IAAE,EAAE,EAAE,KAAN;IAAa,IAAI,EAAE,UAAnB;IAA+B,QAAQ,EAAE,QAAQ,GAAG,CAAH,GAAO,SAAxD;IAAmE,GAAG;EAAtE,CAAD,EAAgF,GAAhF,CAA5B;AACD,CAHM","sourcesContent":["import * as React from 'react';\nimport type { DataGridCellProps, DataGridCellState } from './DataGridCell.types';\nimport { useTableCell_unstable } from '../TableCell/useTableCell';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\n\n/**\n * Create the state required to render DataGridCell.\n *\n * The returned state can be modified with hooks such as useDataGridCellStyles_unstable,\n * before being passed to renderDataGridCell_unstable.\n *\n * @param props - props from this instance of DataGridCell\n * @param ref - reference to root HTMLElement of DataGridCell\n */\nexport const useDataGridCell_unstable = (props: DataGridCellProps, ref: React.Ref<HTMLElement>): DataGridCellState => {\n const tabbable = useDataGridContext_unstable(ctx => ctx.focusMode !== 'none');\n return useTableCell_unstable({ as: 'div', role: 'gridcell', tabIndex: tabbable ? 0 : undefined, ...props }, ref);\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridRow.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/components/DataGridRow/DataGridRow.types.ts"],"names":[],"mappings":"","sourcesContent":["import { TableRowProps, TableRowSlots, TableRowState } from '../TableRow/TableRow.types';\n\nexport type DataGridRowSlots = TableRowSlots;\n\n/**\n * DataGridRow Props\n */\nexport type DataGridRowProps = TableRowProps;\n\n/**\n * State used in rendering DataGridRow\n */\nexport type DataGridRowState = TableRowState;\n"]}
|
|
1
|
+
{"version":3,"file":"DataGridRow.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/components/DataGridRow/DataGridRow.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { ColumnDefinition } from '../../hooks';\nimport { TableRowProps, TableRowSlots, TableRowState } from '../TableRow/TableRow.types';\n\nexport type DataGridRowSlots = TableRowSlots;\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 CellRenderFunction = (column: ColumnDefinition<any>) => React.ReactNode;\n\n/**\n * DataGridRow Props\n */\nexport type DataGridRowProps = Omit<TableRowProps, 'children'> & {\n children: CellRenderFunction;\n};\n\n/**\n * State used in rendering DataGridRow\n */\nexport type DataGridRowState = TableRowState;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useTableRow_unstable } from '../TableRow/useTableRow';
|
|
2
|
+
import { useDataGridContext_unstable } from '../../contexts/dataGridContext';
|
|
2
3
|
/**
|
|
3
4
|
* Create the state required to render DataGridRow.
|
|
4
5
|
*
|
|
@@ -10,7 +11,13 @@ import { useTableRow_unstable } from '../TableRow/useTableRow';
|
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
export const useDataGridRow_unstable = (props, ref) => {
|
|
14
|
+
const columnDefs = useDataGridContext_unstable(ctx => ctx.columns);
|
|
15
|
+
const cellRenderFunction = props.children;
|
|
16
|
+
const children = columnDefs.map(columnDef => {
|
|
17
|
+
return cellRenderFunction(columnDef);
|
|
18
|
+
});
|
|
13
19
|
return useTableRow_unstable({ ...props,
|
|
20
|
+
children,
|
|
14
21
|
as: 'div'
|
|
15
22
|
}, ref);
|
|
16
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridRow/useDataGridRow.ts"],"names":[],"mappings":"AAEA,SAAS,oBAAT,QAAqC,yBAArC;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,uBAAuB,GAAG,CAAC,KAAD,EAA0B,GAA1B,KAA2E;EAChH,OAAO,oBAAoB,CAAC,EAAE,GAAG,KAAL;IAAY,EAAE,EAAE;
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridRow/useDataGridRow.ts"],"names":[],"mappings":"AAEA,SAAS,oBAAT,QAAqC,yBAArC;AACA,SAAS,2BAAT,QAA4C,gCAA5C;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,uBAAuB,GAAG,CAAC,KAAD,EAA0B,GAA1B,KAA2E;EAChH,MAAM,UAAU,GAAG,2BAA2B,CAAC,GAAG,IAAI,GAAG,CAAC,OAAZ,CAA9C;EAEA,MAAM,kBAAkB,GAAG,KAAK,CAAC,QAAjC;EACA,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAX,CAAe,SAAS,IAAG;IAC1C,OAAO,kBAAkB,CAAC,SAAD,CAAzB;EACD,CAFgB,CAAjB;EAIA,OAAO,oBAAoB,CAAC,EAAE,GAAG,KAAL;IAAY,QAAZ;IAAsB,EAAE,EAAE;EAA1B,CAAD,EAAoC,GAApC,CAA3B;AACD,CATM","sourcesContent":["import * as React from 'react';\nimport type { DataGridRowProps, DataGridRowState } from './DataGridRow.types';\nimport { useTableRow_unstable } from '../TableRow/useTableRow';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\n\n/**\n * Create the state required to render DataGridRow.\n *\n * The returned state can be modified with hooks such as useDataGridRowStyles_unstable,\n * before being passed to renderDataGridRow_unstable.\n *\n * @param props - props from this instance of DataGridRow\n * @param ref - reference to root HTMLElement of DataGridRow\n */\nexport const useDataGridRow_unstable = (props: DataGridRowProps, ref: React.Ref<HTMLElement>): DataGridRowState => {\n const columnDefs = useDataGridContext_unstable(ctx => ctx.columns);\n\n const cellRenderFunction = props.children;\n const children = columnDefs.map(columnDef => {\n return cellRenderFunction(columnDef);\n });\n\n return useTableRow_unstable({ ...props, children, as: 'div' }, ref);\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -10,8 +10,10 @@ import { useTableSelectionCell_unstable } from '../TableSelectionCell/useTableSe
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
export const useDataGridSelectionCell_unstable = (props, ref) => {
|
|
13
|
-
return useTableSelectionCell_unstable({
|
|
14
|
-
as: 'div'
|
|
13
|
+
return useTableSelectionCell_unstable({
|
|
14
|
+
as: 'div',
|
|
15
|
+
role: 'gridcell',
|
|
16
|
+
...props
|
|
15
17
|
}, ref);
|
|
16
18
|
};
|
|
17
19
|
//# sourceMappingURL=useDataGridSelectionCell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridSelectionCell/useDataGridSelectionCell.ts"],"names":[],"mappings":"AACA,SAAS,8BAAT,QAA+C,6CAA/C;AAGA;;;;;;;;AAQG;;AACH,OAAO,MAAM,iCAAiC,GAAG,CAC/C,KAD+C,EAE/C,GAF+C,KAGjB;EAC9B,OAAO,8BAA8B,CAAC,EAAE,
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridSelectionCell/useDataGridSelectionCell.ts"],"names":[],"mappings":"AACA,SAAS,8BAAT,QAA+C,6CAA/C;AAGA;;;;;;;;AAQG;;AACH,OAAO,MAAM,iCAAiC,GAAG,CAC/C,KAD+C,EAE/C,GAF+C,KAGjB;EAC9B,OAAO,8BAA8B,CAAC;IAAE,EAAE,EAAE,KAAN;IAAa,IAAI,EAAE,UAAnB;IAA+B,GAAG;EAAlC,CAAD,EAA4C,GAA5C,CAArC;AACD,CALM","sourcesContent":["import * as React from 'react';\nimport { useTableSelectionCell_unstable } from '../TableSelectionCell/useTableSelectionCell';\nimport type { DataGridSelectionCellProps, DataGridSelectionCellState } from './DataGridSelectionCell.types';\n\n/**\n * Create the state required to render DataGridSelectionCell.\n *\n * The returned state can be modified with hooks such as useDataGridSelectionCellStyles_unstable,\n * before being passed to renderDataGridSelectionCell_unstable.\n *\n * @param props - props from this instance of DataGridSelectionCell\n * @param ref - reference to root HTMLElement of DataGridSelectionCell\n */\nexport const useDataGridSelectionCell_unstable = (\n props: DataGridSelectionCellProps,\n ref: React.Ref<HTMLElement>,\n): DataGridSelectionCellState => {\n return useTableSelectionCell_unstable({ as: 'div', role: 'gridcell', ...props }, ref);\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext, useContextSelector } from '@fluentui/react-context-selector';
|
|
2
|
+
import { defaultTableState } from '../hooks';
|
|
3
|
+
const dataGridContext = /*#__PURE__*/createContext(undefined);
|
|
4
|
+
const dataGridContextDefaultValue = { ...defaultTableState,
|
|
5
|
+
focusMode: 'none'
|
|
6
|
+
};
|
|
7
|
+
export const DataGridContextProvider = dataGridContext.Provider;
|
|
8
|
+
export const useDataGridContext_unstable = selector => useContextSelector(dataGridContext, (ctx = dataGridContextDefaultValue) => selector(ctx));
|
|
9
|
+
//# sourceMappingURL=dataGridContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/contexts/dataGridContext.ts"],"names":[],"mappings":"AAAA,SAAS,aAAT,EAAwB,kBAAxB,QAAkD,kCAAlD;AAGA,SAAS,iBAAT,QAAkC,UAAlC;AAEA,MAAM,eAAe,gBAAG,aAAa,CAAmC,SAAnC,CAArC;AAEA,MAAM,2BAA2B,GAAyB,EACxD,GAAG,iBADqD;EAExD,SAAS,EAAE;AAF6C,CAA1D;AAKA,OAAO,MAAM,uBAAuB,GAAG,eAAe,CAAC,QAAhD;AAEP,OAAO,MAAM,2BAA2B,GAAO,QAAJ,IACzC,kBAAkB,CAAC,eAAD,EAAkB,CAAC,GAAG,GAAG,2BAAP,KAAuC,QAAQ,CAAC,GAAD,CAAjE,CADb","sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { ContextSelector } from '@fluentui/react-context-selector';\nimport { DataGridContextValue } from '../components/DataGrid/DataGrid.types';\nimport { defaultTableState } from '../hooks';\n\nconst dataGridContext = createContext<DataGridContextValue | undefined>(undefined);\n\nconst dataGridContextDefaultValue: DataGridContextValue = {\n ...defaultTableState,\n focusMode: 'none',\n};\n\nexport const DataGridContextProvider = dataGridContext.Provider;\n\nexport const useDataGridContext_unstable = <T>(selector: ContextSelector<DataGridContextValue, T>) =>\n useContextSelector(dataGridContext, (ctx = dataGridContextDefaultValue) => selector(ctx));\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const defaultCompare = () => 0;
|
|
2
|
+
|
|
3
|
+
const defaultRenderCell = () => {
|
|
4
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5
|
+
// eslint-disable-next-line no-console
|
|
6
|
+
console.warn('@fluentui/react-table: You are using the default column renderCell function that renders null');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const defaultRenderHeaderCell = () => {
|
|
13
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn('@fluentui/react-table: You are using the default column renderHeaderCell function that renders null');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Helper function to create column definition with defaults
|
|
22
|
+
* @param options - column definition options
|
|
23
|
+
* @returns - column definition with defaults
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export function createColumn(options) {
|
|
28
|
+
const {
|
|
29
|
+
columnId,
|
|
30
|
+
renderCell = defaultRenderCell,
|
|
31
|
+
renderHeaderCell = defaultRenderHeaderCell,
|
|
32
|
+
compare = defaultCompare
|
|
33
|
+
} = options;
|
|
34
|
+
return {
|
|
35
|
+
columnId,
|
|
36
|
+
renderCell,
|
|
37
|
+
renderHeaderCell,
|
|
38
|
+
compare
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=createColumn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/hooks/createColumn.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG,MAAM,CAA7B;;AAEA,MAAM,iBAAiB,GAAG,MAAK;EAC7B,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;IACzC;IACA,OAAO,CAAC,IAAR,CAAa,+FAAb;EACD;;EAED,OAAO,IAAP;AACD,CAPD;;AASA,MAAM,uBAAuB,GAAG,MAAK;EACnC,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;IACzC;IACA,OAAO,CAAC,IAAR,CAAa,qGAAb;EACD;;EAED,OAAO,IAAP;AACD,CAPD;AASA;;;;AAIG;;;AACH,OAAM,SAAU,YAAV,CAA8B,OAA9B,EAAiE;EACrE,MAAM;IACJ,QADI;IAEJ,UAAU,GAAG,iBAFT;IAGJ,gBAAgB,GAAG,uBAHf;IAIJ,OAAO,GAAG;EAJN,IAKF,OALJ;EAOA,OAAO;IACL,QADK;IAEL,UAFK;IAGL,gBAHK;IAIL;EAJK,CAAP;AAMD","sourcesContent":["import { CreateColumnOptions } from './types';\n\nconst defaultCompare = () => 0;\n\nconst defaultRenderCell = () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('@fluentui/react-table: You are using the default column renderCell function that renders null');\n }\n\n return null;\n};\n\nconst defaultRenderHeaderCell = () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('@fluentui/react-table: You are using the default column renderHeaderCell function that renders null');\n }\n\n return null;\n};\n\n/**\n * Helper function to create column definition with defaults\n * @param options - column definition options\n * @returns - column definition with defaults\n */\nexport function createColumn<TItem>(options: CreateColumnOptions<TItem>) {\n const {\n columnId,\n renderCell = defaultRenderCell,\n renderHeaderCell = defaultRenderHeaderCell,\n compare = defaultCompare,\n } = options;\n\n return {\n columnId,\n renderCell,\n renderHeaderCell,\n compare,\n };\n}\n"],"sourceRoot":"../src/"}
|
package/lib/hooks/index.js
CHANGED
package/lib/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './types';\nexport * from './useTable';\nexport * from './useSort';\nexport * from './useSelection';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './types';\nexport * from './useTable';\nexport * from './useSort';\nexport * from './useSelection';\nexport * from './createColumn';\n"]}
|
package/lib/hooks/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/hooks/types.ts"],"names":[],"mappings":"","sourcesContent":["import { SortDirection } from '../components/Table/Table.types';\n\nexport type RowId = string | number;\nexport type ColumnId = string | number;\nexport type SelectionMode = 'single' | 'multiselect';\n\nexport interface SortState {\n sortColumn: ColumnId | undefined;\n sortDirection: SortDirection;\n}\n\nexport interface ColumnDefinition<TItem> {\n columnId: ColumnId;\n compare
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["packages/react-components/react-table/src/hooks/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { SortDirection } from '../components/Table/Table.types';\n\nexport type RowId = string | number;\nexport type ColumnId = string | number;\nexport type SelectionMode = 'single' | 'multiselect';\n\nexport interface SortState {\n sortColumn: ColumnId | undefined;\n sortDirection: SortDirection;\n}\n\nexport interface CreateColumnOptions<TItem> extends Partial<ColumnDefinition<TItem>> {\n columnId: ColumnId;\n}\n\nexport interface ColumnDefinition<TItem> {\n columnId: ColumnId;\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 RowState<TItem> = RowState<TItem>> = (\n row: RowState<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: ColumnId | undefined;\n /**\n * Set the sort direction for the specified column\n */\n setColumnSort: (columnId: ColumnId, sortDirection: SortDirection) => void;\n /**\n * Toggles the sort direction for specified column\n */\n toggleColumnSort: (columnId: ColumnId) => 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: ColumnId) => SortDirection | undefined;\n\n /**\n * Sorts rows and returns a **shallow** copy of original items\n */\n sort: <TRowState extends RowState<TItem>>(rows: TRowState[]) => TRowState[];\n}\n\nexport interface TableSelectionState {\n /**\n * Clears all selected rows\n */\n clearRows: () => void;\n /**\n * Selects single row\n */\n selectRow: (rowId: RowId) => void;\n /**\n * De-selects single row\n */\n deselectRow: (rowId: RowId) => void;\n /**\n * Toggle selection of all rows\n */\n toggleAllRows: () => void;\n /**\n * Toggle selection of single row\n */\n toggleRow: (rowId: RowId) => void;\n /**\n * Collection of row ids corresponding to selected rows\n */\n selectedRows: Set<RowId>;\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: RowId) => boolean;\n}\n\nexport interface RowState<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: RowId;\n}\n\nexport interface TableState<TItem> extends Pick<UseTableOptions<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 RowState<TItem> = RowState<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: ColumnDefinition<TItem>[];\n}\n\nexport interface UseSortOptions {\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?: (state: SortState) => void;\n}\n\nexport interface UseSelectionOptions {\n /**\n * Can be multi or single select\n */\n selectionMode: SelectionMode;\n /**\n * Used in uncontrolled mode to set initial selected rows on mount\n */\n defaultSelectedItems?: Set<RowId>;\n /**\n * Used to control row selection\n */\n selectedItems?: Set<RowId>;\n /**\n * Called when selection changes\n */\n onSelectionChange?: (selectedItems: Set<RowId>) => void;\n}\n\nexport interface UseTableOptions<TItem> {\n columns: ColumnDefinition<TItem>[];\n items: TItem[];\n getRowId?: (item: TItem) => RowId;\n}\n\nexport type TableStatePlugin = <TItem>(tableState: TableState<TItem>) => TableState<TItem>;\n"]}
|
package/lib/hooks/useTable.js
CHANGED
|
@@ -3,6 +3,14 @@ import { defaultTableSortState } from './useSort';
|
|
|
3
3
|
|
|
4
4
|
const defaultRowEnhancer = row => row;
|
|
5
5
|
|
|
6
|
+
export const defaultTableState = {
|
|
7
|
+
selection: defaultTableSelectionState,
|
|
8
|
+
sort: defaultTableSortState,
|
|
9
|
+
getRows: () => [],
|
|
10
|
+
getRowId: () => '',
|
|
11
|
+
items: [],
|
|
12
|
+
columns: []
|
|
13
|
+
};
|
|
6
14
|
export function useTable(options, plugins = []) {
|
|
7
15
|
const {
|
|
8
16
|
items,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/hooks/useTable.ts"],"names":[],"mappings":"AACA,SAAS,0BAAT,QAA2C,gBAA3C;AACA,SAAS,qBAAT,QAAsC,WAAtC;;AAEA,MAAM,kBAAkB,GAA4C,GAAG,IAAI,GAA3E;;AAEA,OAAM,SAAU,QAAV,CAA0B,OAA1B,EAA2D,OAAA,GAA8B,EAAzF,EAA2F;EAC/F,MAAM;IAAE,KAAF;IAAS,QAAT;IAAmB;EAAnB,IAA+B,OAArC;;EAEA,MAAM,OAAO,GAAG,CACd,WAAA,GAAc,kBADA,KAEX,KAAK,CAAC,GAAN,CAAU,CAAC,IAAD,EAAO,CAAP,KAAY;IAAA,IAAA,EAAA;;IAAC,OAAA,WAAW,CAAC;MAAE,IAAF;MAAQ,KAAK,EAAE,CAAA,EAAA,GAAA,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAQ,KAAA,CAAR,GAAA,QAAQ,CAAG,IAAH,CAAR,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,EAAhB,GAAoB;IAAnC,CAAD,CAAX;EAAmD,CAA1E,CAFL;;EAIA,MAAM,YAAY,GAAsB;IACtC,QADsC;IAEtC,KAFsC;IAGtC,OAHsC;IAItC,OAJsC;IAKtC,SAAS,EAAE,0BAL2B;IAMtC,IAAI,EAAE;EANgC,CAAxC;EASA,OAAO,OAAO,CAAC,MAAR,CAAe,CAAC,KAAD,EAAQ,MAAR,KAAmB,MAAM,CAAC,KAAD,CAAxC,EAAiD,YAAjD,CAAP;AACD","sourcesContent":["import type { UseTableOptions, TableState, RowState, RowEnhancer, TableStatePlugin, TableSortState } from './types';\nimport { defaultTableSelectionState } from './useSelection';\nimport { defaultTableSortState } from './useSort';\n\nconst defaultRowEnhancer: RowEnhancer<unknown, RowState<unknown>> = row => row;\n\nexport function useTable<TItem>(options: UseTableOptions<TItem>, plugins: TableStatePlugin[] = []): TableState<TItem> {\n const { items, getRowId, columns } = options;\n\n const getRows = <TRowState extends RowState<TItem>>(\n rowEnhancer = defaultRowEnhancer as RowEnhancer<TItem, TRowState>,\n ) => items.map((item, i) => rowEnhancer({ item, rowId: getRowId?.(item) ?? i }));\n\n const initialState: TableState<TItem> = {\n getRowId,\n items,\n columns,\n getRows,\n selection: defaultTableSelectionState,\n sort: defaultTableSortState as TableSortState<TItem>,\n };\n\n return plugins.reduce((state, plugin) => plugin(state), initialState);\n}\n"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/hooks/useTable.ts"],"names":[],"mappings":"AACA,SAAS,0BAAT,QAA2C,gBAA3C;AACA,SAAS,qBAAT,QAAsC,WAAtC;;AAEA,MAAM,kBAAkB,GAA4C,GAAG,IAAI,GAA3E;;AAEA,OAAO,MAAM,iBAAiB,GAAwB;EACpD,SAAS,EAAE,0BADyC;EAEpD,IAAI,EAAE,qBAF8C;EAGpD,OAAO,EAAE,MAAM,EAHqC;EAIpD,QAAQ,EAAE,MAAM,EAJoC;EAKpD,KAAK,EAAE,EAL6C;EAMpD,OAAO,EAAE;AAN2C,CAA/C;AASP,OAAM,SAAU,QAAV,CAA0B,OAA1B,EAA2D,OAAA,GAA8B,EAAzF,EAA2F;EAC/F,MAAM;IAAE,KAAF;IAAS,QAAT;IAAmB;EAAnB,IAA+B,OAArC;;EAEA,MAAM,OAAO,GAAG,CACd,WAAA,GAAc,kBADA,KAEX,KAAK,CAAC,GAAN,CAAU,CAAC,IAAD,EAAO,CAAP,KAAY;IAAA,IAAA,EAAA;;IAAC,OAAA,WAAW,CAAC;MAAE,IAAF;MAAQ,KAAK,EAAE,CAAA,EAAA,GAAA,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAQ,KAAA,CAAR,GAAA,QAAQ,CAAG,IAAH,CAAR,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,EAAhB,GAAoB;IAAnC,CAAD,CAAX;EAAmD,CAA1E,CAFL;;EAIA,MAAM,YAAY,GAAsB;IACtC,QADsC;IAEtC,KAFsC;IAGtC,OAHsC;IAItC,OAJsC;IAKtC,SAAS,EAAE,0BAL2B;IAMtC,IAAI,EAAE;EANgC,CAAxC;EASA,OAAO,OAAO,CAAC,MAAR,CAAe,CAAC,KAAD,EAAQ,MAAR,KAAmB,MAAM,CAAC,KAAD,CAAxC,EAAiD,YAAjD,CAAP;AACD","sourcesContent":["import type { UseTableOptions, TableState, RowState, RowEnhancer, TableStatePlugin, TableSortState } from './types';\nimport { defaultTableSelectionState } from './useSelection';\nimport { defaultTableSortState } from './useSort';\n\nconst defaultRowEnhancer: RowEnhancer<unknown, RowState<unknown>> = row => row;\n\nexport const defaultTableState: TableState<unknown> = {\n selection: defaultTableSelectionState,\n sort: defaultTableSortState,\n getRows: () => [],\n getRowId: () => '',\n items: [],\n columns: [],\n};\n\nexport function useTable<TItem>(options: UseTableOptions<TItem>, plugins: TableStatePlugin[] = []): TableState<TItem> {\n const { items, getRowId, columns } = options;\n\n const getRows = <TRowState extends RowState<TItem>>(\n rowEnhancer = defaultRowEnhancer as RowEnhancer<TItem, TRowState>,\n ) => items.map((item, i) => rowEnhancer({ item, rowId: getRowId?.(item) ?? i }));\n\n const initialState: TableState<TItem> = {\n getRowId,\n items,\n columns,\n getRows,\n selection: defaultTableSelectionState,\n sort: defaultTableSortState as TableSortState<TItem>,\n };\n\n return plugins.reduce((state, plugin) => plugin(state), initialState);\n}\n"],"sourceRoot":"../src/"}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useTable, useSelection, useSort } from './hooks';
|
|
1
|
+
export { useTable, useSelection, useSort, createColumn } from './hooks';
|
|
2
2
|
export { TableCell, tableCellClassNames, tableCellClassName, useTableCellStyles_unstable, useTableCell_unstable, renderTableCell_unstable } from './TableCell';
|
|
3
3
|
export { TableRow, tableRowClassNames, tableRowClassName, useTableRowStyles_unstable, useTableRow_unstable, renderTableRow_unstable } from './TableRow';
|
|
4
4
|
export { TableBody, tableBodyClassName, tableBodyClassNames, useTableBodyStyles_unstable, useTableBody_unstable, renderTableBody_unstable } from './TableBody';
|