@fluentui/react-table 9.0.0-alpha.11 → 9.0.0-alpha.13
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 +191 -1
- package/CHANGELOG.md +44 -2
- package/dist/index.d.ts +108 -58
- package/lib/components/DataGrid/DataGrid.types.js.map +1 -1
- package/lib/components/DataGrid/useDataGrid.js +27 -5
- package/lib/components/DataGrid/useDataGrid.js.map +1 -1
- package/lib/components/DataGrid/useDataGridContextValues.js +4 -1
- package/lib/components/DataGrid/useDataGridContextValues.js.map +1 -1
- package/lib/components/DataGridBody/useDataGridBody.js +12 -2
- package/lib/components/DataGridBody/useDataGridBody.js.map +1 -1
- package/lib/components/DataGridHeaderCell/useDataGridHeaderCell.js +24 -2
- package/lib/components/DataGridHeaderCell/useDataGridHeaderCell.js.map +1 -1
- package/lib/components/DataGridRow/DataGridRow.types.js.map +1 -1
- package/lib/components/DataGridRow/renderDataGridRow.js +9 -2
- package/lib/components/DataGridRow/renderDataGridRow.js.map +1 -1
- package/lib/components/DataGridRow/useDataGridRow.js +57 -4
- package/lib/components/DataGridRow/useDataGridRow.js.map +1 -1
- package/lib/components/DataGridRow/useDataGridRowStyles.js +7 -1
- package/lib/components/DataGridRow/useDataGridRowStyles.js.map +1 -1
- package/lib/components/DataGridSelectionCell/useDataGridSelectionCell.js +36 -1
- package/lib/components/DataGridSelectionCell/useDataGridSelectionCell.js.map +1 -1
- package/lib/components/Table/Table.types.js.map +1 -1
- package/lib/components/TableCell/TableCell.types.js.map +1 -1
- package/lib/components/TableCell/useTableCell.js +4 -2
- package/lib/components/TableCell/useTableCell.js.map +1 -1
- package/lib/components/TableCell/useTableCellStyles.js +31 -5
- package/lib/components/TableCell/useTableCellStyles.js.map +1 -1
- package/lib/components/TableCellActions/useTableCellActions.js +2 -3
- package/lib/components/TableCellActions/useTableCellActions.js.map +1 -1
- package/lib/components/TableCellActions/useTableCellActionsStyles.js +2 -8
- package/lib/components/TableCellActions/useTableCellActionsStyles.js.map +1 -1
- package/lib/components/TableCellLayout/TableCellLayout.types.js.map +1 -1
- package/lib/components/TableCellLayout/useTableCellLayout.js +3 -2
- package/lib/components/TableCellLayout/useTableCellLayout.js.map +1 -1
- package/lib/components/TableCellLayout/useTableCellLayoutStyles.js +20 -6
- package/lib/components/TableCellLayout/useTableCellLayoutStyles.js.map +1 -1
- package/lib/components/TableHeader/useTableHeader.js +1 -8
- package/lib/components/TableHeader/useTableHeader.js.map +1 -1
- package/lib/components/TableHeaderCell/TableHeaderCell.types.js.map +1 -1
- package/lib/components/TableHeaderCell/useTableHeaderCell.js +6 -2
- package/lib/components/TableHeaderCell/useTableHeaderCell.js.map +1 -1
- package/lib/components/TableHeaderCell/useTableHeaderCellStyles.js +6 -5
- package/lib/components/TableHeaderCell/useTableHeaderCellStyles.js.map +1 -1
- package/lib/components/TableRow/TableRow.types.js.map +1 -1
- package/lib/components/TableRow/useTableRow.js +3 -2
- package/lib/components/TableRow/useTableRow.js.map +1 -1
- package/lib/components/TableRow/useTableRowStyles.js +19 -30
- package/lib/components/TableRow/useTableRowStyles.js.map +1 -1
- package/lib/components/TableSelectionCell/TableSelectionCell.types.js.map +1 -1
- package/lib/components/TableSelectionCell/useTableSelectionCellStyles.js +3 -5
- package/lib/components/TableSelectionCell/useTableSelectionCellStyles.js.map +1 -1
- package/lib/contexts/columnIdContext.js +10 -0
- package/lib/contexts/columnIdContext.js.map +1 -0
- package/lib/contexts/dataGridContext.js +3 -0
- package/lib/contexts/dataGridContext.js.map +1 -1
- package/lib/contexts/rowIdContext.js +10 -0
- package/lib/contexts/rowIdContext.js.map +1 -0
- package/lib/hooks/index.js +3 -3
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/selectionManager.js +16 -16
- package/lib/hooks/selectionManager.js.map +1 -1
- package/lib/hooks/types.js.map +1 -1
- package/lib/hooks/{useTable.js → useTableFeatures.js} +4 -4
- package/lib/hooks/useTableFeatures.js.map +1 -0
- package/lib/hooks/{useSelection.js → useTableSelection.js} +16 -12
- package/lib/hooks/useTableSelection.js.map +1 -0
- package/lib/hooks/{useSort.js → useTableSort.js} +8 -8
- package/lib/hooks/useTableSort.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/components/DataGrid/useDataGrid.js +27 -5
- package/lib-commonjs/components/DataGrid/useDataGrid.js.map +1 -1
- package/lib-commonjs/components/DataGrid/useDataGridContextValues.js +4 -1
- package/lib-commonjs/components/DataGrid/useDataGridContextValues.js.map +1 -1
- package/lib-commonjs/components/DataGridBody/useDataGridBody.js +15 -2
- package/lib-commonjs/components/DataGridBody/useDataGridBody.js.map +1 -1
- package/lib-commonjs/components/DataGridHeaderCell/useDataGridHeaderCell.js +28 -2
- package/lib-commonjs/components/DataGridHeaderCell/useDataGridHeaderCell.js.map +1 -1
- package/lib-commonjs/components/DataGridRow/renderDataGridRow.js +10 -2
- package/lib-commonjs/components/DataGridRow/renderDataGridRow.js.map +1 -1
- package/lib-commonjs/components/DataGridRow/useDataGridRow.js +64 -4
- package/lib-commonjs/components/DataGridRow/useDataGridRow.js.map +1 -1
- package/lib-commonjs/components/DataGridRow/useDataGridRowStyles.js +7 -1
- package/lib-commonjs/components/DataGridRow/useDataGridRowStyles.js.map +1 -1
- package/lib-commonjs/components/DataGridSelectionCell/useDataGridSelectionCell.js +40 -1
- package/lib-commonjs/components/DataGridSelectionCell/useDataGridSelectionCell.js.map +1 -1
- package/lib-commonjs/components/TableCell/useTableCell.js +4 -2
- package/lib-commonjs/components/TableCell/useTableCell.js.map +1 -1
- package/lib-commonjs/components/TableCell/useTableCellStyles.js +32 -5
- package/lib-commonjs/components/TableCell/useTableCellStyles.js.map +1 -1
- package/lib-commonjs/components/TableCellActions/useTableCellActions.js +1 -3
- package/lib-commonjs/components/TableCellActions/useTableCellActions.js.map +1 -1
- package/lib-commonjs/components/TableCellActions/useTableCellActionsStyles.js +2 -9
- package/lib-commonjs/components/TableCellActions/useTableCellActionsStyles.js.map +1 -1
- package/lib-commonjs/components/TableCellLayout/useTableCellLayout.js +3 -2
- package/lib-commonjs/components/TableCellLayout/useTableCellLayout.js.map +1 -1
- package/lib-commonjs/components/TableCellLayout/useTableCellLayoutStyles.js +21 -6
- package/lib-commonjs/components/TableCellLayout/useTableCellLayoutStyles.js.map +1 -1
- package/lib-commonjs/components/TableHeader/useTableHeader.js +1 -9
- package/lib-commonjs/components/TableHeader/useTableHeader.js.map +1 -1
- package/lib-commonjs/components/TableHeaderCell/useTableHeaderCell.js +6 -2
- package/lib-commonjs/components/TableHeaderCell/useTableHeaderCell.js.map +1 -1
- package/lib-commonjs/components/TableHeaderCell/useTableHeaderCellStyles.js +6 -5
- package/lib-commonjs/components/TableHeaderCell/useTableHeaderCellStyles.js.map +1 -1
- package/lib-commonjs/components/TableRow/useTableRow.js +2 -1
- package/lib-commonjs/components/TableRow/useTableRow.js.map +1 -1
- package/lib-commonjs/components/TableRow/useTableRowStyles.js +19 -30
- package/lib-commonjs/components/TableRow/useTableRowStyles.js.map +1 -1
- package/lib-commonjs/components/TableSelectionCell/useTableSelectionCellStyles.js +3 -5
- package/lib-commonjs/components/TableSelectionCell/useTableSelectionCellStyles.js.map +1 -1
- package/lib-commonjs/contexts/columnIdContext.js +21 -0
- package/lib-commonjs/contexts/columnIdContext.js.map +1 -0
- package/lib-commonjs/contexts/dataGridContext.js +3 -0
- package/lib-commonjs/contexts/dataGridContext.js.map +1 -1
- package/lib-commonjs/contexts/rowIdContext.js +21 -0
- package/lib-commonjs/contexts/rowIdContext.js.map +1 -0
- package/lib-commonjs/hooks/index.js +3 -3
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/selectionManager.js +16 -16
- package/lib-commonjs/hooks/selectionManager.js.map +1 -1
- package/lib-commonjs/hooks/{useTable.js → useTableFeatures.js} +10 -10
- package/lib-commonjs/hooks/useTableFeatures.js.map +1 -0
- package/lib-commonjs/hooks/{useSelection.js → useTableSelection.js} +19 -15
- package/lib-commonjs/hooks/useTableSelection.js.map +1 -0
- package/lib-commonjs/hooks/{useSort.js → useTableSort.js} +11 -11
- package/lib-commonjs/hooks/useTableSort.js.map +1 -0
- package/lib-commonjs/index.js +7 -7
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +9 -9
- package/lib/hooks/useSelection.js.map +0 -1
- package/lib/hooks/useSort.js.map +0 -1
- package/lib/hooks/useTable.js.map +0 -1
- package/lib-commonjs/hooks/useSelection.js.map +0 -1
- package/lib-commonjs/hooks/useSort.js.map +0 -1
- package/lib-commonjs/hooks/useTable.js.map +0 -1
package/lib/hooks/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './types';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
2
|
+
export * from './useTableFeatures';
|
|
3
|
+
export * from './useTableSort';
|
|
4
|
+
export * from './useTableSelection';
|
|
5
5
|
export * from './createColumn';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
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,
|
|
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,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './types';\nexport * from './useTableFeatures';\nexport * from './useTableSort';\nexport * from './useTableSelection';\nexport * from './createColumn';\n"]}
|
|
@@ -4,7 +4,7 @@ export function createSelectionManager(mode, onSelectionChange = () => undefined
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
function createMultipleSelectionManager(onSelectionChange) {
|
|
7
|
-
const toggleAllItems = (itemIds, selectedItems) => {
|
|
7
|
+
const toggleAllItems = (e, itemIds, selectedItems) => {
|
|
8
8
|
const allItemsSelected = itemIds.every(itemId => selectedItems.has(itemId));
|
|
9
9
|
|
|
10
10
|
if (allItemsSelected) {
|
|
@@ -13,31 +13,31 @@ function createMultipleSelectionManager(onSelectionChange) {
|
|
|
13
13
|
itemIds.forEach(itemId => selectedItems.add(itemId));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
onSelectionChange(new Set(selectedItems));
|
|
16
|
+
onSelectionChange(e, new Set(selectedItems));
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const toggleItem = (itemId, selectedItems) => {
|
|
19
|
+
const toggleItem = (e, itemId, selectedItems) => {
|
|
20
20
|
if (selectedItems.has(itemId)) {
|
|
21
21
|
selectedItems.delete(itemId);
|
|
22
22
|
} else {
|
|
23
23
|
selectedItems.add(itemId);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
onSelectionChange(new Set(selectedItems));
|
|
26
|
+
onSelectionChange(e, new Set(selectedItems));
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const selectItem = (itemId, selectedItems) => {
|
|
29
|
+
const selectItem = (e, itemId, selectedItems) => {
|
|
30
30
|
selectedItems.add(itemId);
|
|
31
|
-
onSelectionChange(new Set(selectedItems));
|
|
31
|
+
onSelectionChange(e, new Set(selectedItems));
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
const deselectItem = (itemId, selectedItems) => {
|
|
34
|
+
const deselectItem = (e, itemId, selectedItems) => {
|
|
35
35
|
selectedItems.delete(itemId);
|
|
36
|
-
onSelectionChange(new Set(selectedItems));
|
|
36
|
+
onSelectionChange(e, new Set(selectedItems));
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const clearItems =
|
|
40
|
-
onSelectionChange(new Set());
|
|
39
|
+
const clearItems = e => {
|
|
40
|
+
onSelectionChange(e, new Set());
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
const isSelected = (itemId, selectedItems) => {
|
|
@@ -55,20 +55,20 @@ function createMultipleSelectionManager(onSelectionChange) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
function createSingleSelectionManager(onSelectionChange) {
|
|
58
|
-
const toggleItem = itemId => {
|
|
59
|
-
onSelectionChange(new Set([itemId]));
|
|
58
|
+
const toggleItem = (e, itemId) => {
|
|
59
|
+
onSelectionChange(e, new Set([itemId]));
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
const clearItems =
|
|
63
|
-
onSelectionChange(new Set());
|
|
62
|
+
const clearItems = e => {
|
|
63
|
+
onSelectionChange(e, new Set());
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
const isSelected = (itemId, selectedItems) => {
|
|
67
67
|
return selectedItems.has(itemId);
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
const selectItem = itemId => {
|
|
71
|
-
onSelectionChange(new Set([itemId]));
|
|
70
|
+
const selectItem = (e, itemId) => {
|
|
71
|
+
onSelectionChange(e, new Set([itemId]));
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/hooks/selectionManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/hooks/selectionManager.ts"],"names":[],"mappings":"AAoBA,OAAM,SAAU,sBAAV,CACJ,IADI,EAEJ,iBAAA,GAA+C,MAAM,SAFjD,EAE0D;EAE9D,MAAM,cAAc,GAAG,IAAI,KAAK,aAAT,GAAyB,8BAAzB,GAA0D,4BAAjF;EAEA,OAAO,cAAc,CAAC,iBAAD,CAArB;AACD;;AAED,SAAS,8BAAT,CAAwC,iBAAxC,EAAoF;EAClF,MAAM,cAAc,GAAuC,CAAC,CAAD,EAAI,OAAJ,EAAa,aAAb,KAA8B;IACvF,MAAM,gBAAgB,GAAG,OAAO,CAAC,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ACD,CAFD;;EAIA,OAAO;IACL,UADK;IAEL,UAFK;IAGL,YAHK;IAIL,UAJK;IAKL,UALK;IAML;EANK,CAAP;AAQD;;AAED,SAAS,4BAAT,CAAsC,iBAAtC,EAAkF;EAChF,MAAM,UAAU,GAAmC,CAAC,CAAD,EAAI,MAAJ,KAAc;IAC/D,iBAAiB,CAAC,CAAD,EAAI,IAAI,GAAJ,CAAQ,CAAC,MAAD,CAAR,CAAJ,CAAjB;EACD,CAFD;;EAIA,MAAM,UAAU,GAAmC,CAAC,IAAG;IACrD,iBAAiB,CAAC,CAAD,EAAI,IAAI,GAAJ,EAAJ,CAAjB;EACD,CAFD;;EAIA,MAAM,UAAU,GAAG,CAAC,MAAD,EAA0B,aAA1B,KAAiE;IAClF,OAAO,aAAa,CAAC,GAAd,CAAkB,MAAlB,CAAP;EACD,CAFD;;EAIA,MAAM,UAAU,GAAmC,CAAC,CAAD,EAAI,MAAJ,KAAc;IAC/D,iBAAiB,CAAC,CAAD,EAAI,IAAI,GAAJ,CAAQ,CAAC,MAAD,CAAR,CAAJ,CAAjB;EACD,CAFD;;EAIA,OAAO;IACL,YAAY,EAAE,UADT;IAEL,UAFK;IAGL,cAAc,EAAE,MAAK;MACnB,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;QACzC,MAAM,IAAI,KAAJ,CAAU,6EAAV,CAAN;MACD;;MAED,OAAO,SAAP;IACD,CATI;IAUL,UAVK;IAWL,UAXK;IAYL;EAZK,CAAP;AAcD","sourcesContent":["import * as React from 'react';\nimport { SelectionMode } from './types';\n\ntype OnSelectionChangeCallback = (e: React.SyntheticEvent | Event, selectedItems: Set<SelectionItemId>) => void;\n\nexport interface SelectionManager {\n toggleItem(e: React.SyntheticEvent | Event, id: SelectionItemId, selectedItems: Set<SelectionItemId>): void;\n selectItem(e: React.SyntheticEvent | Event, id: SelectionItemId, selectedItems: Set<SelectionItemId>): void;\n deselectItem(e: React.SyntheticEvent | Event, id: SelectionItemId, selectedItems: Set<SelectionItemId>): void;\n clearItems(e: React.SyntheticEvent | Event): void;\n isSelected(id: SelectionItemId, selectedItems: Set<SelectionItemId>): boolean;\n toggleAllItems(\n e: React.SyntheticEvent | Event,\n itemIds: SelectionItemId[],\n selectedItems: Set<SelectionItemId>,\n ): 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"],"sourceRoot":"../src/"}
|
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 * 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
|
|
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 OnSelectionChangeData {\n selectedItems: Set<RowId>;\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: (event: React.SyntheticEvent, columnId: ColumnId, sortDirection: SortDirection) => void;\n /**\n * Toggles the sort direction for specified column\n */\n toggleColumnSort: (event: React.SyntheticEvent, 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: (e: React.SyntheticEvent) => void;\n /**\n * Selects single row\n */\n selectRow: (e: React.SyntheticEvent, rowId: RowId) => void;\n /**\n * De-selects single row\n */\n deselectRow: (e: React.SyntheticEvent, rowId: RowId) => 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: 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 selectionMode: SelectionMode;\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 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 UseTableSelectionOptions {\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?(e: React.SyntheticEvent, data: OnSelectionChangeData): 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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defaultTableSelectionState } from './
|
|
2
|
-
import { defaultTableSortState } from './
|
|
1
|
+
import { defaultTableSelectionState } from './useTableSelection';
|
|
2
|
+
import { defaultTableSortState } from './useTableSort';
|
|
3
3
|
|
|
4
4
|
const defaultRowEnhancer = row => row;
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@ export const defaultTableState = {
|
|
|
11
11
|
items: [],
|
|
12
12
|
columns: []
|
|
13
13
|
};
|
|
14
|
-
export function
|
|
14
|
+
export function useTableFeatures(options, plugins = []) {
|
|
15
15
|
const {
|
|
16
16
|
items,
|
|
17
17
|
getRowId,
|
|
@@ -37,4 +37,4 @@ export function useTable(options, plugins = []) {
|
|
|
37
37
|
};
|
|
38
38
|
return plugins.reduce((state, plugin) => plugin(state), initialState);
|
|
39
39
|
}
|
|
40
|
-
//# sourceMappingURL=
|
|
40
|
+
//# sourceMappingURL=useTableFeatures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/hooks/useTableFeatures.ts"],"names":[],"mappings":"AACA,SAAS,0BAAT,QAA2C,qBAA3C;AACA,SAAS,qBAAT,QAAsC,gBAAtC;;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,gBAAV,CACJ,OADI,EAEJ,OAAA,GAA8B,EAF1B,EAE4B;EAEhC,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 './useTableSelection';\nimport { defaultTableSortState } from './useTableSort';\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 useTableFeatures<TItem>(\n options: UseTableOptions<TItem>,\n plugins: TableStatePlugin[] = [],\n): 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/"}
|
|
@@ -13,14 +13,15 @@ export const defaultTableSelectionState = {
|
|
|
13
13
|
selectedRows: /*#__PURE__*/new Set(),
|
|
14
14
|
someRowsSelected: false,
|
|
15
15
|
toggleAllRows: noop,
|
|
16
|
-
toggleRow: noop
|
|
16
|
+
toggleRow: noop,
|
|
17
|
+
selectionMode: 'multiselect'
|
|
17
18
|
};
|
|
18
|
-
export function
|
|
19
|
+
export function useTableSelection(options) {
|
|
19
20
|
// False positive, these plugin hooks are intended to be run on every render
|
|
20
21
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
21
|
-
return tableState =>
|
|
22
|
+
return tableState => useTableSelectionState(tableState, options);
|
|
22
23
|
}
|
|
23
|
-
export function
|
|
24
|
+
export function useTableSelectionState(tableState, options) {
|
|
24
25
|
const {
|
|
25
26
|
items,
|
|
26
27
|
getRowId
|
|
@@ -37,28 +38,31 @@ export function useSelectionState(tableState, options) {
|
|
|
37
38
|
state: selectedItems
|
|
38
39
|
});
|
|
39
40
|
const selectionManager = React.useMemo(() => {
|
|
40
|
-
return createSelectionManager(selectionMode, newSelectedItems => {
|
|
41
|
+
return createSelectionManager(selectionMode, (e, newSelectedItems) => {
|
|
41
42
|
setSelected(() => {
|
|
42
|
-
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(
|
|
43
|
+
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(e, {
|
|
44
|
+
selectedItems: newSelectedItems
|
|
45
|
+
});
|
|
43
46
|
return newSelectedItems;
|
|
44
47
|
});
|
|
45
48
|
});
|
|
46
49
|
}, [onSelectionChange, selectionMode, setSelected]);
|
|
47
|
-
const toggleAllRows = useEventCallback(
|
|
48
|
-
selectionManager.toggleAllItems(items.map((item, i) => {
|
|
50
|
+
const toggleAllRows = useEventCallback(e => {
|
|
51
|
+
selectionManager.toggleAllItems(e, items.map((item, i) => {
|
|
49
52
|
var _a;
|
|
50
53
|
|
|
51
54
|
return (_a = getRowId === null || getRowId === void 0 ? void 0 : getRowId(item)) !== null && _a !== void 0 ? _a : i;
|
|
52
55
|
}), selected);
|
|
53
56
|
});
|
|
54
|
-
const toggleRow = useEventCallback(rowId => selectionManager.toggleItem(rowId, selected));
|
|
55
|
-
const deselectRow = useEventCallback(rowId => selectionManager.deselectItem(rowId, selected));
|
|
56
|
-
const selectRow = useEventCallback(rowId => selectionManager.selectItem(rowId, selected));
|
|
57
|
+
const toggleRow = useEventCallback((e, rowId) => selectionManager.toggleItem(e, rowId, selected));
|
|
58
|
+
const deselectRow = useEventCallback((e, rowId) => selectionManager.deselectItem(e, rowId, selected));
|
|
59
|
+
const selectRow = useEventCallback((e, rowId) => selectionManager.selectItem(e, rowId, selected));
|
|
57
60
|
|
|
58
61
|
const isRowSelected = rowId => selectionManager.isSelected(rowId, selected);
|
|
59
62
|
|
|
60
63
|
return { ...tableState,
|
|
61
64
|
selection: {
|
|
65
|
+
selectionMode,
|
|
62
66
|
someRowsSelected: selected.size > 0,
|
|
63
67
|
allRowsSelected: selectionMode === 'single' ? selected.size > 0 : selected.size === items.length,
|
|
64
68
|
selectedRows: selected,
|
|
@@ -71,4 +75,4 @@ export function useSelectionState(tableState, options) {
|
|
|
71
75
|
}
|
|
72
76
|
};
|
|
73
77
|
}
|
|
74
|
-
//# sourceMappingURL=
|
|
78
|
+
//# sourceMappingURL=useTableSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/hooks/useTableSelection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,oBAAT,EAA+B,gBAA/B,QAAuD,2BAAvD;AACA,SAAS,sBAAT,QAAuC,oBAAvC;;AAGA,MAAM,IAAI,GAAG,MAAM,SAAnB;;AAEA,OAAO,MAAM,0BAA0B,GAAwB;EAC7D,eAAe,EAAE,KAD4C;EAE7D,SAAS,EAAE,IAFkD;EAG7D,WAAW,EAAE,IAHgD;EAI7D,aAAa,EAAE,MAAM,KAJwC;EAK7D,SAAS,EAAE,IALkD;EAM7D,YAAY,eAAE,IAAI,GAAJ,EAN+C;E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AQ,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,CAApB;IAAqB,CAA5C,CAFF,EAGE,QAHF;EAKD,CAN2E,CAA5E;EAQA,MAAM,SAAS,GAAqC,gBAAgB,CAAC,CAAC,CAAD,EAAI,KAAJ,KACnE,gBAAgB,CAAC,UAAjB,CAA4B,CAA5B,EAA+B,KAA/B,EAAsC,QAAtC,CADkE,CAApE;EAIA,MAAM,WAAW,GAAuC,gBAAgB,CAAC,CAAC,CAAD,EAAI,KAAJ,KACvE,gBAAgB,CAAC,YAAjB,CAA8B,CAA9B,EAAiC,KAAjC,EAAwC,QAAxC,CADsE,CAAxE;EAIA,MAAM,SAAS,GAAqC,gBAAgB,CAAC,CAAC,CAAD,EAAI,KAAJ,KACnE,gBAAgB,CAAC,UAAjB,CAA4B,CAA5B,EAA+B,KAA/B,EAAsC,QAAtC,CADkE,CAApE;;EAIA,MAAM,aAAa,GAA0C,KAAD,IAC1D,gBAAgB,CAAC,UAAjB,CAA4B,KAA5B,EAAmC,QAAnC,CADF;;EAGA,OAAO,EACL,GAAG,UADE;IAEL,SAAS,EAAE;MACT,aADS;MAET,gBAAgB,EAAE,QAAQ,CAAC,IAAT,GAAgB,CAFzB;MAGT,eAAe,EAAE,aAAa,KAAK,QAAlB,GAA6B,QAAQ,CAAC,IAAT,GAAgB,CAA7C,GAAiD,QAAQ,CAAC,IAAT,KAAkB,KAAK,CAAC,MAHjF;MAIT,YAAY,EAAE,QAJL;MAKT,SALS;MAMT,aANS;MAOT,SAAS,EAAE,gBAAgB,CAAC,UAPnB;MAQT,WARS;MAST,SATS;MAUT;IAVS;EAFN,CAAP;AAeD","sourcesContent":["import * as React from 'react';\nimport { useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { createSelectionManager } from './selectionManager';\nimport type { RowId, TableSelectionState, TableState, UseTableSelectionOptions } 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: UseTableSelectionOptions) {\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: TableState<TItem>) => useTableSelectionState(tableState, options);\n}\n\nexport function useTableSelectionState<TItem>(\n tableState: TableState<TItem>,\n options: UseTableSelectionOptions,\n): TableState<TItem> {\n const { items, getRowId } = tableState;\n const { selectionMode, defaultSelectedItems, selectedItems, onSelectionChange } = options;\n\n const [selected, setSelected] = useControllableState({\n initialState: new Set<RowId>(),\n defaultState: defaultSelectedItems,\n state: selectedItems,\n });\n\n const selectionManager = React.useMemo(() => {\n return createSelectionManager(selectionMode, (e, newSelectedItems) => {\n setSelected(() => {\n onSelectionChange?.(e as React.SyntheticEvent, { selectedItems: newSelectedItems });\n return newSelectedItems;\n });\n });\n }, [onSelectionChange, selectionMode, setSelected]);\n\n const toggleAllRows: TableSelectionState['toggleAllRows'] = useEventCallback(e => {\n selectionManager.toggleAllItems(\n e,\n items.map((item, i) => getRowId?.(item) ?? i),\n selected,\n );\n });\n\n const toggleRow: TableSelectionState['toggleRow'] = useEventCallback((e, rowId: RowId) =>\n selectionManager.toggleItem(e, rowId, selected),\n );\n\n const deselectRow: TableSelectionState['deselectRow'] = useEventCallback((e, rowId: RowId) =>\n selectionManager.deselectItem(e, rowId, selected),\n );\n\n const selectRow: TableSelectionState['selectRow'] = useEventCallback((e, rowId: RowId) =>\n selectionManager.selectItem(e, rowId, selected),\n );\n\n const isRowSelected: TableSelectionState['isRowSelected'] = (rowId: RowId) =>\n selectionManager.isSelected(rowId, selected);\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: selectionManager.clearItems,\n deselectRow,\n selectRow,\n isRowSelected,\n },\n };\n}\n"],"sourceRoot":"../src/"}
|
|
@@ -10,12 +10,12 @@ export const defaultTableSortState = {
|
|
|
10
10
|
sortDirection: 'ascending',
|
|
11
11
|
toggleColumnSort: noop
|
|
12
12
|
};
|
|
13
|
-
export function
|
|
13
|
+
export function useTableSort(options) {
|
|
14
14
|
// False positive, these plugin hooks are intended to be run on every render
|
|
15
15
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
16
|
-
return tableState =>
|
|
16
|
+
return tableState => useTableSortState(tableState, options);
|
|
17
17
|
}
|
|
18
|
-
export function
|
|
18
|
+
export function useTableSortState(tableState, options) {
|
|
19
19
|
const {
|
|
20
20
|
columns
|
|
21
21
|
} = tableState;
|
|
@@ -37,7 +37,7 @@ export function useSortState(tableState, options) {
|
|
|
37
37
|
sortDirection
|
|
38
38
|
} = sorted;
|
|
39
39
|
|
|
40
|
-
const toggleColumnSort = columnId => {
|
|
40
|
+
const toggleColumnSort = (e, columnId) => {
|
|
41
41
|
setSorted(s => {
|
|
42
42
|
const newState = { ...s,
|
|
43
43
|
sortColumn: columnId
|
|
@@ -49,17 +49,17 @@ export function useSortState(tableState, options) {
|
|
|
49
49
|
newState.sortDirection = 'ascending';
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(newState);
|
|
52
|
+
onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(e, newState);
|
|
53
53
|
return newState;
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
const setColumnSort = (nextSortColumn, nextSortDirection) => {
|
|
57
|
+
const setColumnSort = (e, nextSortColumn, nextSortDirection) => {
|
|
58
58
|
const newState = {
|
|
59
59
|
sortColumn: nextSortColumn,
|
|
60
60
|
sortDirection: nextSortDirection
|
|
61
61
|
};
|
|
62
|
-
onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(newState);
|
|
62
|
+
onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(e, newState);
|
|
63
63
|
setSorted(newState);
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -91,4 +91,4 @@ export function useSortState(tableState, options) {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
//# sourceMappingURL=
|
|
94
|
+
//# sourceMappingURL=useTableSort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/hooks/useTableSort.ts"],"names":[],"mappings":"AACA,SAAS,oBAAT,QAAqC,2BAArC;;AAGA,MAAM,IAAI,GAAG,MAAM,SAAnB;;AAEA,OAAO,MAAM,qBAAqB,GAA4B;EAC5D,gBAAgB,EAAE,MAAM,WADoC;EAE5D,aAAa,EAAE,IAF6C;EAG5D,IAAI,EAAwC,IAAtC,IAA4D,CAAC,GAAG,IAAJ,CAHN;EAI5D,UAAU,EAAE,SAJgD;EAK5D,aAAa,EAAE,WAL6C;EAM5D,gBAAgB,EAAE;AAN0C,CAAvD;AASP,OAAM,SAAU,YAAV,CAA8B,OAA9B,EAA0D;EAC9D;EACA;EACA,OAAQ,UAAD,IAAmC,iBAAiB,CAAC,UAAD,EAAa,OAAb,CAA3D;AACD;AAED,OAAM,SAAU,iBAAV,CACJ,UADI,EAEJ,OAFI,EAEwB;EAE5B,MAAM;IAAE;EAAF,IAAc,UAApB;EACA,MAAM;IAAE,SAAF;IAAa,gBAAb;IAA+B;EAA/B,IAAgD,OAAtD;EAEA,MAAM,CAAC,MAAD,EAAS,SAAT,IAAsB,oBAAoB,CAAY;IAC1D,YAAY,EAAE;MACZ,aAAa,EAAE,WADH;MAEZ,UAAU,EAAE;IAFA,CAD4C;IAK1D,YAAY,EA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,CAAb,GAAa,KAAA,CAAb,GAAA,aAAa,CAAE,OAAhB,CAAJ,EAA6B;QAC3B,OAAO,CAAP;MACD;;MAED,MAAM,GAAG,GAAG,aAAa,KAAK,WAAlB,GAAgC,CAAhC,GAAoC,CAAC,CAAjD;MACA,OAAO,aAAa,CAAC,OAAd,CAAsB,CAAC,CAAC,IAAxB,EAA8B,CAAC,CAAC,IAAhC,IAAwC,GAA/C;IACD,CARM,CAAP;EASD,CAVD;;EAYA,MAAM,gBAAgB,GAA+C,QAAD,IAAuB;IACzF,OAAO,UAAU,KAAK,QAAf,GAA0B,aAA1B,GAA0C,SAAjD;EACD,CAFD;;EAIA,OAAO,EACL,GAAG,UADE;IAEL,IAAI,EAAE;MACJ,IADI;MAEJ,UAFI;MAGJ,aAHI;MAIJ,aAJI;MAKJ,gBALI;MAMJ;IANI;EAFD,CAAP;AAWD","sourcesContent":["import * as React from 'react';\nimport { useControllableState } from '@fluentui/react-utilities';\nimport type { ColumnId, RowState, SortState, TableSortState, TableState, UseTableSortOptions } from './types';\n\nconst noop = () => undefined;\n\nexport const defaultTableSortState: TableSortState<unknown> = {\n getSortDirection: () => 'ascending',\n setColumnSort: noop,\n sort: <TRowState extends RowState<unknown>>(rows: TRowState[]) => [...rows],\n sortColumn: undefined,\n sortDirection: 'ascending',\n toggleColumnSort: noop,\n};\n\nexport function useTableSort<TItem>(options: UseTableSortOptions) {\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: TableState<TItem>) => useTableSortState(tableState, options);\n}\n\nexport function useTableSortState<TItem>(\n tableState: TableState<TItem>,\n options: UseTableSortOptions,\n): TableState<TItem> {\n const { columns } = tableState;\n const { sortState, defaultSortState, onSortChange } = options;\n\n const [sorted, setSorted] = useControllableState<SortState>({\n initialState: {\n sortDirection: 'ascending' as const,\n sortColumn: undefined,\n },\n defaultState: defaultSortState,\n state: sortState,\n });\n\n const { sortColumn, sortDirection } = sorted;\n\n const toggleColumnSort = (e: React.SyntheticEvent, columnId: ColumnId | undefined) => {\n setSorted(s => {\n const newState = { ...s, sortColumn: columnId };\n if (s.sortColumn === columnId) {\n newState.sortDirection = s.sortDirection === 'ascending' ? 'descending' : 'ascending';\n } else {\n newState.sortDirection = 'ascending';\n }\n\n onSortChange?.(e, newState);\n return newState;\n });\n };\n\n const setColumnSort: TableSortState<TItem>['setColumnSort'] = (e, nextSortColumn, nextSortDirection) => {\n const newState = { sortColumn: nextSortColumn, sortDirection: nextSortDirection };\n onSortChange?.(e, newState);\n setSorted(newState);\n };\n\n const sort = <TRowState extends RowState<TItem>>(rows: TRowState[]) => {\n return rows.slice().sort((a, b) => {\n const sortColumnDef = columns.find(column => column.columnId === sortColumn);\n if (!sortColumnDef?.compare) {\n return 0;\n }\n\n const mod = sortDirection === 'ascending' ? 1 : -1;\n return sortColumnDef.compare(a.item, b.item) * mod;\n });\n };\n\n const getSortDirection: TableSortState<TItem>['getSortDirection'] = (columnId: ColumnId) => {\n return sortColumn === columnId ? sortDirection : undefined;\n };\n\n return {\n ...tableState,\n sort: {\n sort,\n sortColumn,\n sortDirection,\n setColumnSort,\n toggleColumnSort,\n getSortDirection,\n },\n };\n}\n"],"sourceRoot":"../src/"}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { useTableFeatures, useTableSelection, useTableSort, 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';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/index.ts"],"names":[],"mappings":"AAAA,SAAS,
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/index.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,EAA2B,iBAA3B,EAA8C,YAA9C,EAA4D,YAA5D,QAAgF,SAAhF;AAcA,SACE,SADF,EAEE,mBAFF,EAGE,kBAHF,EAIE,2BAJF,EAKE,qBALF,EAME,wBANF,QAOO,aAPP;AAUA,SACE,QADF,EAEE,kBAFF,EAGE,iBAHF,EAIE,0BAJF,EAKE,oBALF,EAME,uBANF,QAOO,YAPP;AAUA,SACE,SADF,EAEE,kBAFF,EAGE,mBAHF,EAIE,2BAJF,EAKE,qBALF,EAME,wBANF,QAOO,aAPP;AAUA,SACE,KADF,EAEE,cAFF,EAGE,eAHF,EAIE,uBAJF,EAKE,iBALF,EAME,oBANF,QAOO,SAPP;AAUA,SACE,WADF,EAEE,qBAFF,EAGE,oBAHF,EAIE,6BAJF,EAKE,uBALF,EAME,0BANF,QAOO,eAPP;AAUA,SACE,eADF,EAEE,wBAFF,EAGE,yBAHF,EAIE,iCAJF,EAKE,2BALF,EAME,8BANF,QAOO,mBAPP;AAUA,SAAS,oBAAT,EAA+B,eAA/B,QAAsD,yBAAtD;AACA,SACE,kBADF,EAEE,oCAFF,EAGE,8BAHF,EAIE,iCAJF,EAKE,4BALF,QAMO,sBANP;AASA,SACE,gBADF,EAEE,0BAFF,EAGE,kCAHF,EAIE,4BAJF,EAKE,+BALF,QAMO,oBANP;AASA,SACE,eADF,EAEE,yBAFF,EAGE,iCAHF,EAIE,2BAJF,EAKE,8BALF,QAMO,mBANP;AASA,SACE,YADF,EAEE,sBAFF,EAGE,8BAHF,EAIE,wBAJF,EAKE,2BALF,QAMO,gBANP;AASA,SACE,WADF,EAEE,qBAFF,EAGE,6BAHF,EAIE,uBAJF,EAKE,0BALF,QAMO,eANP;AASA,SACE,YADF,EAEE,sBAFF,EAGE,8BAHF,EAIE,wBAJF,EAKE,2BALF,QAMO,gBANP;AASA,SACE,QADF,EAEE,kBAFF,EAGE,0BAHF,EAIE,oBAJF,EAKE,uBALF,QAMO,YANP;AAgBA,SACE,cADF,EAEE,wBAFF,EAGE,gCAHF,EAIE,0BAJF,EAKE,6BALF,QAMO,kBANP;AASA,SACE,kBADF,EAEE,4BAFF,EAGE,oCAHF,EAIE,8BAJF,EAKE,iCALF,QAMO,sBANP;AASA,SACE,qBADF,EAEE,uCAFF,EAGE,iCAHF,EAIE,oCAJF,EAKE,+BALF,QAMO,yBANP","sourcesContent":["export { useTableFeatures, useTableSelection, useTableSort, createColumn } from './hooks';\nexport type {\n UseTableOptions,\n TableState as HeadlessTableState,\n TableSelectionState,\n TableSortState,\n TableStatePlugin,\n RowState,\n RowId,\n ColumnDefinition,\n ColumnId,\n CreateColumnOptions,\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 { TableContextProvider, useTableContext } from './contexts/tableContext';\nexport {\n TableSelectionCell,\n useTableSelectionCellStyles_unstable,\n useTableSelectionCell_unstable,\n renderTableSelectionCell_unstable,\n tableSelectionCellClassNames,\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} from './DataGrid';\nexport type {\n DataGridProps,\n DataGridSlots,\n DataGridState,\n DataGridContextValues,\n DataGridContextValue,\n FocusMode,\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"],"sourceRoot":"../src/"}
|
|
@@ -9,7 +9,7 @@ const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
|
|
9
9
|
|
|
10
10
|
const useTable_1 = /*#__PURE__*/require("../Table/useTable");
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const hooks_1 = /*#__PURE__*/require("../../hooks");
|
|
13
13
|
/**
|
|
14
14
|
* Create the state required to render DataGrid.
|
|
15
15
|
*
|
|
@@ -25,25 +25,47 @@ const useDataGrid_unstable = (props, ref) => {
|
|
|
25
25
|
const {
|
|
26
26
|
items,
|
|
27
27
|
columns,
|
|
28
|
-
focusMode = 'none'
|
|
28
|
+
focusMode = 'none',
|
|
29
|
+
selectionMode,
|
|
30
|
+
onSortChange,
|
|
31
|
+
onSelectionChange,
|
|
32
|
+
defaultSortState,
|
|
33
|
+
sortState,
|
|
34
|
+
selectedItems,
|
|
35
|
+
defaultSelectedItems,
|
|
36
|
+
subtleSelection = false,
|
|
37
|
+
selectionAppearance = 'brand'
|
|
29
38
|
} = props;
|
|
30
39
|
const navigable = focusMode !== 'none';
|
|
31
40
|
const keyboardNavAttr = react_tabster_1.useArrowNavigationGroup({
|
|
32
41
|
axis: 'grid'
|
|
33
42
|
});
|
|
34
|
-
const tableState =
|
|
43
|
+
const tableState = hooks_1.useTableFeatures({
|
|
35
44
|
items,
|
|
36
45
|
columns
|
|
37
|
-
}, [
|
|
46
|
+
}, [hooks_1.useTableSort({
|
|
47
|
+
defaultSortState,
|
|
48
|
+
sortState,
|
|
49
|
+
onSortChange
|
|
50
|
+
}), hooks_1.useTableSelection({
|
|
51
|
+
defaultSelectedItems,
|
|
52
|
+
selectedItems,
|
|
53
|
+
onSelectionChange,
|
|
54
|
+
selectionMode: selectionMode !== null && selectionMode !== void 0 ? selectionMode : 'multiselect'
|
|
55
|
+
})]);
|
|
38
56
|
const baseTableState = useTable_1.useTable_unstable({
|
|
39
57
|
role: 'grid',
|
|
40
58
|
as: 'div',
|
|
59
|
+
noNativeElements: true,
|
|
41
60
|
...(navigable && keyboardNavAttr),
|
|
42
61
|
...props
|
|
43
62
|
}, ref);
|
|
44
63
|
return { ...baseTableState,
|
|
45
64
|
focusMode,
|
|
46
|
-
tableState
|
|
65
|
+
tableState,
|
|
66
|
+
selectableRows: !!selectionMode,
|
|
67
|
+
subtleSelection,
|
|
68
|
+
selectionAppearance
|
|
47
69
|
};
|
|
48
70
|
};
|
|
49
71
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGrid/useDataGrid.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;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AI,SAAS,IAAI,eAAjB,CAAnD;IAAsF,GAAG;EAAzF,CADqB,EAErB,GAFqB,CAAvB;EAKA,OAAO,EACL,GAAG,cADE;IAEL,SAFK;IAGL,UAHK;IAIL,cAAc,EAAE,CAAC,CAAC,aAJb;IAKL,eALK;IAML;EANK,CAAP;AAQD,CA9CM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","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 { useTableFeatures, useTableSort, useTableSelection } from '../../hooks';\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 {\n items,\n columns,\n focusMode = 'none',\n selectionMode,\n onSortChange,\n onSelectionChange,\n defaultSortState,\n sortState,\n selectedItems,\n defaultSelectedItems,\n subtleSelection = false,\n selectionAppearance = 'brand',\n } = props;\n\n const navigable = focusMode !== 'none';\n const keyboardNavAttr = useArrowNavigationGroup({ axis: 'grid' });\n\n const tableState = useTableFeatures({ items, columns }, [\n useTableSort({\n defaultSortState,\n sortState,\n onSortChange,\n }),\n useTableSelection({\n defaultSelectedItems,\n selectedItems,\n onSelectionChange,\n selectionMode: selectionMode ?? 'multiselect',\n }),\n ]);\n\n const baseTableState = useTable_unstable(\n { role: 'grid', as: 'div', noNativeElements: true, ...(navigable && keyboardNavAttr), ...props },\n ref,\n );\n\n return {\n ...baseTableState,\n focusMode,\n tableState,\n selectableRows: !!selectionMode,\n subtleSelection,\n selectionAppearance,\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -11,7 +11,10 @@ function useDataGridContextValues_unstable(state) {
|
|
|
11
11
|
const tableContextValues = useTableContextValues_1.useTableContextValues_unstable(state);
|
|
12
12
|
return { ...tableContextValues,
|
|
13
13
|
dataGrid: { ...state.tableState,
|
|
14
|
-
focusMode: state.focusMode
|
|
14
|
+
focusMode: state.focusMode,
|
|
15
|
+
selectableRows: state.selectableRows,
|
|
16
|
+
subtleSelection: state.subtleSelection,
|
|
17
|
+
selectionAppearance: state.selectionAppearance
|
|
15
18
|
}
|
|
16
19
|
};
|
|
17
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGrid/useDataGridContextValues.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,uBAAA,gBAAA,OAAA,CAAA,gCAAA,CAAA;;AAGA,SAAgB,iCAAhB,CAAkD,KAAlD,EAAsE;EACpE,MAAM,kBAAkB,GAAG,uBAAA,CAAA,8BAAA,CAA+B,KAA/B,CAA3B;EACA,OAAO,EACL,GAAG,kBADE;IAEL,QAAQ,EAAE,EACR,GAAG,KAAK,CAAC,UADD;MAER,SAAS,EAAE,KAAK,CAAC;
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGrid/useDataGridContextValues.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,uBAAA,gBAAA,OAAA,CAAA,gCAAA,CAAA;;AAGA,SAAgB,iCAAhB,CAAkD,KAAlD,EAAsE;EACpE,MAAM,kBAAkB,GAAG,uBAAA,CAAA,8BAAA,CAA+B,KAA/B,CAA3B;EACA,OAAO,EACL,GAAG,kBADE;IAEL,QAAQ,EAAE,EACR,GAAG,KAAK,CAAC,UADD;MAER,SAAS,EAAE,KAAK,CAAC,SAFT;MAGR,cAAc,EAAE,KAAK,CAAC,cAHd;MAIR,eAAe,EAAE,KAAK,CAAC,eAJf;MAKR,mBAAmB,EAAE,KAAK,CAAC;IALnB;EAFL,CAAP;AAUD;;AAZD,OAAA,CAAA,iCAAA,GAAA,iCAAA","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 selectableRows: state.selectableRows,\n subtleSelection: state.subtleSelection,\n selectionAppearance: state.selectionAppearance,\n },\n };\n}\n"],"sourceRoot":"../src/"}
|
|
@@ -5,9 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useDataGridBody_unstable = void 0;
|
|
7
7
|
|
|
8
|
+
const React = /*#__PURE__*/require("react");
|
|
9
|
+
|
|
8
10
|
const useTableBody_1 = /*#__PURE__*/require("../TableBody/useTableBody");
|
|
9
11
|
|
|
10
12
|
const dataGridContext_1 = /*#__PURE__*/require("../../contexts/dataGridContext");
|
|
13
|
+
|
|
14
|
+
const tableContext_1 = /*#__PURE__*/require("../../contexts/tableContext");
|
|
15
|
+
|
|
16
|
+
const rowIdContext_1 = /*#__PURE__*/require("../../contexts/rowIdContext");
|
|
11
17
|
/**
|
|
12
18
|
* Create the state required to render DataGridBody.
|
|
13
19
|
*
|
|
@@ -20,12 +26,19 @@ const dataGridContext_1 = /*#__PURE__*/require("../../contexts/dataGridContext")
|
|
|
20
26
|
|
|
21
27
|
|
|
22
28
|
const useDataGridBody_unstable = (props, ref) => {
|
|
29
|
+
const {
|
|
30
|
+
sortable
|
|
31
|
+
} = tableContext_1.useTableContext();
|
|
23
32
|
const getRows = dataGridContext_1.useDataGridContext_unstable(ctx => ctx.getRows);
|
|
24
|
-
const
|
|
33
|
+
const sort = dataGridContext_1.useDataGridContext_unstable(ctx => ctx.sort.sort);
|
|
34
|
+
const rows = sortable ? sort(getRows()) : getRows();
|
|
25
35
|
const {
|
|
26
36
|
children: renderRow
|
|
27
37
|
} = props;
|
|
28
|
-
const children = rows.map(row =>
|
|
38
|
+
const children = rows.map(row => React.createElement(rowIdContext_1.RowIdContextProvider, {
|
|
39
|
+
key: row.rowId,
|
|
40
|
+
value: row.rowId
|
|
41
|
+
}, renderRow(row)));
|
|
29
42
|
return useTableBody_1.useTableBody_unstable({ ...props,
|
|
30
43
|
children,
|
|
31
44
|
as: 'div'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridBody/useDataGridBody.
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridBody/useDataGridBody.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,cAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,gCAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;AAEA;;;;;;;;AAQG;;;AACI,MAAM,wBAAwB,GAAG,CAAC,KAAD,EAA2B,GAA3B,KAA6E;EACnH,MAAM;IAAE;EAAF,IAAe,cAAA,CAAA,eAAA,EAArB;EACA,MAAM,OAAO,GAAG,iBAAA,CAAA,2BAAA,CAA4B,GAAG,IAAI,GAAG,CAAC,OAAvC,CAAhB;EACA,MAAM,IAAI,GAAG,iBAAA,CAAA,2BAAA,CAA4B,GAAG,IAAI,GAAG,CAAC,IAAJ,CAAS,IAA5C,CAAb;EACA,MAAM,IAAI,GAAG,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAR,CAAP,GAAqB,OAAO,EAAjD;EAEA,MAAM;IAAE,QAAQ,EAAE;EAAZ,IAA0B,KAAhC;EACA,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAL,CAAS,GAAG,IAC3B,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,oBAAD,EAAqB;IAAC,GAAG,EAAE,GAAG,CAAC,KAAV;IAAiB,KAAK,EAAE,GAAG,CAAC;EAA5B,CAArB,EACG,SAAS,CAAC,GAAD,CADZ,CADe,CAAjB;EAKA,OAAO,cAAA,CAAA,qBAAA,CAAsB,EAAE,GAAG,KAAL;IAAY,QAAZ;IAAsB,EAAE,EAAE;EAA1B,CAAtB,EAAyD,GAAzD,CAAP;AACD,CAbM;;AAAM,OAAA,CAAA,wBAAA,GAAwB,wBAAxB","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';\nimport { useTableContext } from '../../contexts/tableContext';\nimport { RowIdContextProvider } from '../../contexts/rowIdContext';\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 { sortable } = useTableContext();\n const getRows = useDataGridContext_unstable(ctx => ctx.getRows);\n const sort = useDataGridContext_unstable(ctx => ctx.sort.sort);\n const rows = sortable ? sort(getRows()) : getRows();\n\n const { children: renderRow } = props;\n const children = rows.map(row => (\n <RowIdContextProvider key={row.rowId} value={row.rowId}>\n {renderRow(row)}\n </RowIdContextProvider>\n ));\n return useTableBody_unstable({ ...props, children, as: 'div' }, ref);\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -5,7 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useDataGridHeaderCell_unstable = void 0;
|
|
7
7
|
|
|
8
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
9
|
+
|
|
8
10
|
const useTableHeaderCell_1 = /*#__PURE__*/require("../TableHeaderCell/useTableHeaderCell");
|
|
11
|
+
|
|
12
|
+
const dataGridContext_1 = /*#__PURE__*/require("../../contexts/dataGridContext");
|
|
13
|
+
|
|
14
|
+
const columnIdContext_1 = /*#__PURE__*/require("../../contexts/columnIdContext");
|
|
15
|
+
|
|
16
|
+
const tableContext_1 = /*#__PURE__*/require("../../contexts/tableContext");
|
|
9
17
|
/**
|
|
10
18
|
* Create the state required to render DataGridHeaderCell.
|
|
11
19
|
*
|
|
@@ -18,8 +26,26 @@ const useTableHeaderCell_1 = /*#__PURE__*/require("../TableHeaderCell/useTableHe
|
|
|
18
26
|
|
|
19
27
|
|
|
20
28
|
const useDataGridHeaderCell_unstable = (props, ref) => {
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
const columnId = columnIdContext_1.useColumnIdContext();
|
|
30
|
+
const {
|
|
31
|
+
sortable
|
|
32
|
+
} = tableContext_1.useTableContext();
|
|
33
|
+
const toggleColumnSort = dataGridContext_1.useDataGridContext_unstable(ctx => ctx.sort.toggleColumnSort);
|
|
34
|
+
const sortDirection = dataGridContext_1.useDataGridContext_unstable(ctx => sortable ? ctx.sort.getSortDirection(columnId) : undefined);
|
|
35
|
+
const onClick = react_utilities_1.useEventCallback(e => {
|
|
36
|
+
var _a;
|
|
37
|
+
|
|
38
|
+
if (sortable) {
|
|
39
|
+
toggleColumnSort(e, columnId);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
43
|
+
});
|
|
44
|
+
return useTableHeaderCell_1.useTableHeaderCell_unstable({
|
|
45
|
+
sortDirection,
|
|
46
|
+
as: 'div',
|
|
47
|
+
...props,
|
|
48
|
+
onClick
|
|
23
49
|
}, ref);
|
|
24
50
|
};
|
|
25
51
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridHeaderCell/useDataGridHeaderCell.ts"],"names":[],"mappings":";;;;;;;AAEA,MAAA,oBAAA,gBAAA,OAAA,CAAA,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AAO,oBAAA,CAAA,2BAAA,CAA4B;IAAE,aAAF;IAAiB,EAAE,EAAE,KAArB;IAA4B,GAAG,KAA/B;IAAsC;EAAtC,CAA5B,EAA6E,GAA7E,CAAP;AACD,CAlBM;;AAAM,OAAA,CAAA,8BAAA,GAA8B,8BAA9B","sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport type { DataGridHeaderCellProps, DataGridHeaderCellState } from './DataGridHeaderCell.types';\nimport { useTableHeaderCell_unstable } from '../TableHeaderCell/useTableHeaderCell';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\nimport { useColumnIdContext } from '../../contexts/columnIdContext';\nimport { useTableContext } from '../../contexts/tableContext';\n\n/**\n * Create the state required to render DataGridHeaderCell.\n *\n * The returned state can be modified with hooks such as useDataGridHeaderCellStyles_unstable,\n * before being passed to renderDataGridHeaderCell_unstable.\n *\n * @param props - props from this instance of DataGridHeaderCell\n * @param ref - reference to root HTMLElement of DataGridHeaderCell\n */\nexport const useDataGridHeaderCell_unstable = (\n props: DataGridHeaderCellProps,\n ref: React.Ref<HTMLElement>,\n): DataGridHeaderCellState => {\n const columnId = useColumnIdContext();\n const { sortable } = useTableContext();\n const toggleColumnSort = useDataGridContext_unstable(ctx => ctx.sort.toggleColumnSort);\n const sortDirection = useDataGridContext_unstable(ctx =>\n sortable ? ctx.sort.getSortDirection(columnId) : undefined,\n );\n const onClick = useEventCallback((e: React.MouseEvent<HTMLTableHeaderCellElement>) => {\n if (sortable) {\n toggleColumnSort(e, columnId);\n }\n props.onClick?.(e);\n });\n\n return useTableHeaderCell_unstable({ sortDirection, as: 'div', ...props, onClick }, ref);\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -5,14 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.renderDataGridRow_unstable = void 0;
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const React = /*#__PURE__*/require("react");
|
|
9
|
+
|
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
9
11
|
/**
|
|
10
12
|
* Render the final JSX of DataGridRow
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
const renderDataGridRow_unstable = state => {
|
|
15
|
-
|
|
17
|
+
const {
|
|
18
|
+
slots,
|
|
19
|
+
slotProps
|
|
20
|
+
} = react_utilities_1.getSlots(state);
|
|
21
|
+
return React.createElement(slots.root, { ...slotProps.root
|
|
22
|
+
}, slots.selectionCell && React.createElement(slots.selectionCell, { ...slotProps.selectionCell
|
|
23
|
+
}), slotProps.root.children);
|
|
16
24
|
};
|
|
17
25
|
|
|
18
26
|
exports.renderDataGridRow_unstable = renderDataGridRow_unstable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridRow/renderDataGridRow.tsx"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-table/src/components/DataGridRow/renderDataGridRow.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,0BAA0B,GAAI,KAAD,IAA4B;EACpE,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,iBAAA,CAAA,QAAA,CAA2B,KAA3B,CAA7B;EAEA,OACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,KAAK,CAAC,aAAN,IAAuB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,aAAP,EAAoB,EAAA,GAAK,SAAS,CAAC;EAAf,CAApB,CAD1B,EAEG,SAAS,CAAC,IAAV,CAAe,QAFlB,CADF;AAMD,CATM;;AAAM,OAAA,CAAA,0BAAA,GAA0B,0BAA1B","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { DataGridRowState, DataGridRowSlots } from './DataGridRow.types';\n\n/**\n * Render the final JSX of DataGridRow\n */\nexport const renderDataGridRow_unstable = (state: DataGridRowState) => {\n const { slots, slotProps } = getSlots<DataGridRowSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n {slots.selectionCell && <slots.selectionCell {...slotProps.selectionCell} />}\n {slotProps.root.children}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
|