@fluentui/react-table 9.0.0-alpha.4 → 9.0.0-alpha.5

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 CHANGED
@@ -2,7 +2,64 @@
2
2
  "name": "@fluentui/react-table",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 03 Oct 2022 22:22:51 GMT",
5
+ "date": "Thu, 13 Oct 2022 10:59:38 GMT",
6
+ "tag": "@fluentui/react-table_v9.0.0-alpha.5",
7
+ "version": "9.0.0-alpha.5",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "olfedias@microsoft.com",
12
+ "package": "@fluentui/react-table",
13
+ "commit": "1a527d440e0497ef8046b3ce240492241e7a04ac",
14
+ "comment": "chore: Update Griffel to latest version"
15
+ },
16
+ {
17
+ "author": "lingfangao@hotmail.com",
18
+ "package": "@fluentui/react-table",
19
+ "commit": "33559052b672f787b021bd2fbc9826e88ce2a2de",
20
+ "comment": "BREAKING: refactor `useTable` to be composable"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-table",
25
+ "comment": "Bump @fluentui/react-aria to v9.2.2",
26
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-table",
31
+ "comment": "Bump @fluentui/react-avatar to v9.2.1",
32
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
33
+ },
34
+ {
35
+ "author": "beachball",
36
+ "package": "@fluentui/react-table",
37
+ "comment": "Bump @fluentui/react-checkbox to v9.0.8",
38
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
39
+ },
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui/react-table",
43
+ "comment": "Bump @fluentui/react-tabster to v9.1.3",
44
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
45
+ },
46
+ {
47
+ "author": "beachball",
48
+ "package": "@fluentui/react-table",
49
+ "comment": "Bump @fluentui/react-utilities to v9.1.1",
50
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
51
+ },
52
+ {
53
+ "author": "beachball",
54
+ "package": "@fluentui/react-table",
55
+ "comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.15",
56
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
57
+ }
58
+ ]
59
+ }
60
+ },
61
+ {
62
+ "date": "Mon, 03 Oct 2022 22:24:41 GMT",
6
63
  "tag": "@fluentui/react-table_v9.0.0-alpha.4",
7
64
  "version": "9.0.0-alpha.4",
8
65
  "comments": {
@@ -23,25 +80,25 @@
23
80
  "author": "beachball",
24
81
  "package": "@fluentui/react-table",
25
82
  "comment": "Bump @fluentui/react-aria to v9.2.1",
26
- "commit": "b0b7f99bbbb05b0bd136432983a74fea252c7163"
83
+ "commit": "67a8c98b8d53cd2fa14d668cf639b867b68ad18a"
27
84
  },
28
85
  {
29
86
  "author": "beachball",
30
87
  "package": "@fluentui/react-table",
31
88
  "comment": "Bump @fluentui/react-avatar to v9.2.0",
32
- "commit": "b0b7f99bbbb05b0bd136432983a74fea252c7163"
89
+ "commit": "67a8c98b8d53cd2fa14d668cf639b867b68ad18a"
33
90
  },
34
91
  {
35
92
  "author": "beachball",
36
93
  "package": "@fluentui/react-table",
37
94
  "comment": "Bump @fluentui/react-checkbox to v9.0.7",
38
- "commit": "b0b7f99bbbb05b0bd136432983a74fea252c7163"
95
+ "commit": "67a8c98b8d53cd2fa14d668cf639b867b68ad18a"
39
96
  },
40
97
  {
41
98
  "author": "beachball",
42
99
  "package": "@fluentui/react-table",
43
100
  "comment": "Bump @fluentui/react-tabster to v9.1.2",
44
- "commit": "b0b7f99bbbb05b0bd136432983a74fea252c7163"
101
+ "commit": "67a8c98b8d53cd2fa14d668cf639b867b68ad18a"
45
102
  }
46
103
  ],
47
104
  "none": [
package/CHANGELOG.md CHANGED
@@ -1,22 +1,38 @@
1
1
  # Change Log - @fluentui/react-table
2
2
 
3
- This log was last generated on Mon, 03 Oct 2022 22:22:51 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 13 Oct 2022 10:59:38 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-alpha.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-table_v9.0.0-alpha.5)
8
+
9
+ Thu, 13 Oct 2022 10:59:38 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-table_v9.0.0-alpha.4..@fluentui/react-table_v9.0.0-alpha.5)
11
+
12
+ ### Changes
13
+
14
+ - chore: Update Griffel to latest version ([PR #25075](https://github.com/microsoft/fluentui/pull/25075) by olfedias@microsoft.com)
15
+ - BREAKING: refactor `useTable` to be composable ([PR #24947](https://github.com/microsoft/fluentui/pull/24947) by lingfangao@hotmail.com)
16
+ - Bump @fluentui/react-aria to v9.2.2 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
17
+ - Bump @fluentui/react-avatar to v9.2.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
18
+ - Bump @fluentui/react-checkbox to v9.0.8 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
19
+ - Bump @fluentui/react-tabster to v9.1.3 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
20
+ - Bump @fluentui/react-utilities to v9.1.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
21
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.15 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
22
+
7
23
  ## [9.0.0-alpha.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-table_v9.0.0-alpha.4)
8
24
 
9
- Mon, 03 Oct 2022 22:22:51 GMT
25
+ Mon, 03 Oct 2022 22:24:41 GMT
10
26
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-table_v9.0.0-alpha.3..@fluentui/react-table_v9.0.0-alpha.4)
11
27
 
12
28
  ### Changes
13
29
 
14
30
  - feat: `noNativeElements` renders a flex layout ([PR #24913](https://github.com/microsoft/fluentui/pull/24913) by lingfangao@hotmail.com)
15
31
  - feat: Use AvatarContext to override avatar size ([PR #24807](https://github.com/microsoft/fluentui/pull/24807) by lingfangao@hotmail.com)
16
- - Bump @fluentui/react-aria to v9.2.1 ([PR #25016](https://github.com/microsoft/fluentui/pull/25016) by beachball)
17
- - Bump @fluentui/react-avatar to v9.2.0 ([PR #25016](https://github.com/microsoft/fluentui/pull/25016) by beachball)
18
- - Bump @fluentui/react-checkbox to v9.0.7 ([PR #25016](https://github.com/microsoft/fluentui/pull/25016) by beachball)
19
- - Bump @fluentui/react-tabster to v9.1.2 ([PR #25016](https://github.com/microsoft/fluentui/pull/25016) by beachball)
32
+ - Bump @fluentui/react-aria to v9.2.1 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
33
+ - Bump @fluentui/react-avatar to v9.2.0 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
34
+ - Bump @fluentui/react-checkbox to v9.0.7 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
35
+ - Bump @fluentui/react-tabster to v9.1.2 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
20
36
 
21
37
  ## [9.0.0-alpha.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-table_v9.0.0-alpha.3)
22
38
 
package/dist/index.d.ts CHANGED
@@ -18,12 +18,25 @@ export declare interface ColumnDefinition<TItem> {
18
18
 
19
19
  export declare type ColumnId = string | number;
20
20
 
21
- declare type OnSelectionChangeCallback = (selectedItems: Set<RowId>) => void;
22
-
23
- declare type OnSortChangeCallback = (state: {
24
- sortColumn: ColumnId | undefined;
25
- sortDirection: SortDirection;
26
- }) => void;
21
+ export declare interface HeadlessTableState<TItem> extends Pick<UseTableOptions<TItem>, 'items' | 'getRowId'> {
22
+ /**
23
+ * The row data for rendering
24
+ * @param rowEnhancer - Enhances the row with extra user data
25
+ */
26
+ getRows: <TRowState extends RowState<TItem> = RowState<TItem>>(rowEnhancer?: RowEnhancer<TItem, TRowState>) => TRowState[];
27
+ /**
28
+ * State and actions to manage row selection
29
+ */
30
+ selection: TableSelectionState;
31
+ /**
32
+ * State and actions to manage row sorting
33
+ */
34
+ sort: TableSortState<TItem>;
35
+ /**
36
+ * Table columns
37
+ */
38
+ columns: ColumnDefinition<TItem>[];
39
+ }
27
40
 
28
41
  /**
29
42
  * Render the final JSX of Table
@@ -70,10 +83,7 @@ export declare const renderTableRow_unstable: (state: TableRowState) => JSX.Elem
70
83
  */
71
84
  export declare const renderTableSelectionCell_unstable: (state: TableSelectionCellState) => JSX.Element;
72
85
 
73
- declare type RowEnhancer<TItem, TRowState extends RowState<TItem> = RowState<TItem>> = (row: RowState<TItem>, state: {
74
- selection: TableSelectionState;
75
- sort: TableSortState;
76
- }) => TRowState;
86
+ declare type RowEnhancer<TItem, TRowState extends RowState<TItem> = RowState<TItem>> = (row: RowState<TItem>) => TRowState;
77
87
 
78
88
  export declare type RowId = string | number;
79
89
 
@@ -388,7 +398,7 @@ export declare interface TableSelectionState {
388
398
  /**
389
399
  * Collection of row ids corresponding to selected rows
390
400
  */
391
- selectedRows: RowId[];
401
+ selectedRows: Set<RowId>;
392
402
  /**
393
403
  * Whether all rows are selected
394
404
  */
@@ -407,7 +417,7 @@ export declare type TableSlots = {
407
417
  root: Slot<'table', 'div'>;
408
418
  };
409
419
 
410
- export declare interface TableSortState {
420
+ export declare interface TableSortState<TItem> {
411
421
  /**
412
422
  * Current sort direction
413
423
  */
@@ -429,6 +439,10 @@ export declare interface TableSortState {
429
439
  * returns undefined if the column is not sorted
430
440
  */
431
441
  getSortDirection: (columnId: ColumnId) => SortDirection | undefined;
442
+ /**
443
+ * Sorts rows and returns a **shallow** copy of original items
444
+ */
445
+ sort: (rows: RowState<TItem>[]) => RowState<TItem>[];
432
446
  }
433
447
 
434
448
  /**
@@ -436,22 +450,47 @@ export declare interface TableSortState {
436
450
  */
437
451
  export declare type TableState = ComponentState<TableSlots> & Pick<Required<TableProps>, 'size' | 'noNativeElements'> & TableContextValue;
438
452
 
439
- declare interface TableState_2<TItem, TRowState extends RowState<TItem> = RowState<TItem>> {
453
+ export declare type TableStatePlugin = <TItem>(tableState: HeadlessTableState<TItem>) => HeadlessTableState<TItem>;
454
+
455
+ export declare function useSelection<TItem>(options: UseSelectionOptions): (tableState: HeadlessTableState<TItem>) => HeadlessTableState<TItem>;
456
+
457
+ declare interface UseSelectionOptions {
440
458
  /**
441
- * The row data for rendering
459
+ * Can be multi or single select
442
460
  */
443
- rows: TRowState[];
461
+ selectionMode: SelectionMode_2;
444
462
  /**
445
- * State and actions to manage row selection
463
+ * Used in uncontrolled mode to set initial selected rows on mount
446
464
  */
447
- selection: TableSelectionState;
465
+ defaultSelectedItems?: Set<RowId>;
448
466
  /**
449
- * State and actions to manage row sorting
467
+ * Used to control row selection
468
+ */
469
+ selectedItems?: Set<RowId>;
470
+ /**
471
+ * Called when selection changes
450
472
  */
451
- sort: TableSortState;
473
+ onSelectionChange?: (selectedItems: Set<RowId>) => void;
452
474
  }
453
475
 
454
- export declare function useTable<TItem, TRowState extends RowState<TItem> = RowState<TItem>>(options: UseTableOptions<TItem, TRowState>): TableState_2<TItem, TRowState>;
476
+ export declare function useSort<TItem>(options: UseSortOptions): (tableState: HeadlessTableState<TItem>) => HeadlessTableState<TItem>;
477
+
478
+ declare interface UseSortOptions {
479
+ /**
480
+ * Used to control sorting
481
+ */
482
+ sortState?: SortState;
483
+ /**
484
+ * Used in uncontrolled mode to set initial sort column and direction on mount
485
+ */
486
+ defaultSortState?: SortState;
487
+ /**
488
+ * Called when sort changes
489
+ */
490
+ onSortChange?: (state: SortState) => void;
491
+ }
492
+
493
+ export declare function useTable<TItem>(options: UseTableOptions<TItem>, plugins?: TableStatePlugin[]): HeadlessTableState<TItem>;
455
494
 
456
495
  /**
457
496
  * Create the state required to render Table.
@@ -562,36 +601,10 @@ export declare const useTableHeaderCellStyles_unstable: (state: TableHeaderCellS
562
601
  */
563
602
  export declare const useTableHeaderStyles_unstable: (state: TableHeaderState) => TableHeaderState;
564
603
 
565
- export declare interface UseTableOptions<TItem, TRowState extends RowState<TItem> = RowState<TItem>> {
604
+ export declare interface UseTableOptions<TItem> {
566
605
  columns: ColumnDefinition<TItem>[];
567
606
  items: TItem[];
568
- selectionMode?: SelectionMode_2;
569
- /**
570
- * Used in uncontrolled mode to set initial selected rows on mount
571
- */
572
- defaultSelectedRows?: Set<RowId>;
573
- /**
574
- * Used to control row selection
575
- */
576
- selectedRows?: Set<RowId>;
577
- /**
578
- * Called when selection changes
579
- */
580
- onSelectionChange?: OnSelectionChangeCallback;
581
- /**
582
- * Used to control sorting
583
- */
584
- sortState?: SortState;
585
- /**
586
- * Used in uncontrolled mode to set initial sort column and direction on mount
587
- */
588
- defaultSortState?: SortState;
589
- /**
590
- * Called when sort changes
591
- */
592
- onSortChange?: OnSortChangeCallback;
593
607
  getRowId?: (item: TItem) => RowId;
594
- rowEnhancer?: RowEnhancer<TItem, TRowState>;
595
608
  }
596
609
 
597
610
  /**
@@ -1,3 +1,5 @@
1
1
  export * from './types';
2
2
  export * from './useTable';
3
+ export * from './useSort';
4
+ export * from './useSelection';
3
5
  //# sourceMappingURL=index.js.map
@@ -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","sourcesContent":["export * from './types';\nexport * from './useTable';\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","sourcesContent":["export * from './types';\nexport * from './useTable';\nexport * from './useSort';\nexport * from './useSelection';\n"]}
@@ -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 GetRowIdInternal<TItem> = (rowId: TItem, index: number) => RowId;\nexport type SelectionMode = 'single' | 'multiselect';\nexport type OnSelectionChangeCallback = (selectedItems: Set<RowId>) => void;\nexport type OnSortChangeCallback = (state: { sortColumn: ColumnId | undefined; sortDirection: SortDirection }) => void;\n\nexport interface SortState {\n sortColumn: ColumnId | undefined;\n sortDirection: SortDirection;\n}\n\nexport interface ColumnDefinition<TItem> {\n columnId: ColumnId;\n compare?: (a: TItem, b: TItem) => number;\n}\n\nexport type RowEnhancer<TItem, TRowState extends RowState<TItem> = RowState<TItem>> = (\n row: RowState<TItem>,\n state: { selection: TableSelectionState; sort: TableSortState },\n) => TRowState;\n\nexport interface TableSortStateInternal<TItem> {\n sortDirection: SortDirection;\n sortColumn: ColumnId | undefined;\n setColumnSort: (columnId: ColumnId, sortDirection: SortDirection) => void;\n toggleColumnSort: (columnId: ColumnId) => void;\n getSortDirection: (columnId: ColumnId) => SortDirection | undefined;\n /**\n * Returns a sorted **shallow** copy of original items\n */\n sort: (items: TItem[]) => TItem[];\n}\n\nexport interface UseTableOptions<TItem, TRowState extends RowState<TItem> = RowState<TItem>> {\n columns: ColumnDefinition<TItem>[];\n items: TItem[];\n selectionMode?: SelectionMode;\n /**\n * Used in uncontrolled mode to set initial selected rows on mount\n */\n defaultSelectedRows?: Set<RowId>;\n /**\n * Used to control row selection\n */\n selectedRows?: Set<RowId>;\n /**\n * Called when selection changes\n */\n onSelectionChange?: OnSelectionChangeCallback;\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?: OnSortChangeCallback;\n getRowId?: (item: TItem) => RowId;\n rowEnhancer?: RowEnhancer<TItem, TRowState>;\n}\n\nexport interface TableSelectionStateInternal {\n clearRows: () => void;\n deselectRow: (rowId: RowId) => void;\n selectRow: (rowId: RowId) => void;\n toggleAllRows: () => void;\n toggleRow: (rowId: RowId) => void;\n isRowSelected: (rowId: RowId) => boolean;\n selectedRows: Set<RowId>;\n allRowsSelected: boolean;\n someRowsSelected: boolean;\n}\n\nexport interface TableSortState {\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\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: 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, TRowState extends RowState<TItem> = RowState<TItem>> {\n /**\n * The row data for rendering\n */\n rows: 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;\n}\n"]}
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?: (a: TItem, b: TItem) => number;\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: (rows: RowState<TItem>[]) => RowState<TItem>[];\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"]}
@@ -1,11 +1,32 @@
1
1
  import * as React from 'react';
2
2
  import { useControllableState, useEventCallback } from '@fluentui/react-utilities';
3
3
  import { createSelectionManager } from './selectionManager';
4
+
5
+ const noop = () => undefined;
6
+
7
+ export const defaultTableSelectionState = {
8
+ allRowsSelected: false,
9
+ clearRows: noop,
10
+ deselectRow: noop,
11
+ isRowSelected: () => false,
12
+ selectRow: noop,
13
+ selectedRows: /*#__PURE__*/new Set(),
14
+ someRowsSelected: false,
15
+ toggleAllRows: noop,
16
+ toggleRow: noop
17
+ };
4
18
  export function useSelection(options) {
19
+ // False positive, these plugin hooks are intended to be run on every render
20
+ // eslint-disable-next-line react-hooks/rules-of-hooks
21
+ return tableState => useSelectionState(tableState, options);
22
+ }
23
+ export function useSelectionState(tableState, options) {
5
24
  const {
6
- selectionMode,
7
25
  items,
8
- getRowId,
26
+ getRowId
27
+ } = tableState;
28
+ const {
29
+ selectionMode,
9
30
  defaultSelectedItems,
10
31
  selectedItems,
11
32
  onSelectionChange
@@ -24,7 +45,11 @@ export function useSelection(options) {
24
45
  });
25
46
  }, [onSelectionChange, selectionMode, setSelected]);
26
47
  const toggleAllRows = useEventCallback(() => {
27
- selectionManager.toggleAllItems(items.map((item, i) => getRowId(item, i)), selected);
48
+ selectionManager.toggleAllItems(items.map((item, i) => {
49
+ var _a;
50
+
51
+ return (_a = getRowId === null || getRowId === void 0 ? void 0 : getRowId(item)) !== null && _a !== void 0 ? _a : i;
52
+ }), selected);
28
53
  });
29
54
  const toggleRow = useEventCallback(rowId => selectionManager.toggleItem(rowId, selected));
30
55
  const deselectRow = useEventCallback(rowId => selectionManager.deselectItem(rowId, selected));
@@ -32,16 +57,18 @@ export function useSelection(options) {
32
57
 
33
58
  const isRowSelected = rowId => selectionManager.isSelected(rowId, selected);
34
59
 
35
- return {
36
- someRowsSelected: selected.size > 0,
37
- allRowsSelected: selectionMode === 'single' ? selected.size > 0 : selected.size === items.length,
38
- selectedRows: selected,
39
- toggleRow,
40
- toggleAllRows,
41
- clearRows: selectionManager.clearItems,
42
- deselectRow,
43
- selectRow,
44
- isRowSelected
60
+ return { ...tableState,
61
+ selection: {
62
+ someRowsSelected: selected.size > 0,
63
+ allRowsSelected: selectionMode === 'single' ? selected.size > 0 : selected.size === items.length,
64
+ selectedRows: selected,
65
+ toggleRow,
66
+ toggleAllRows,
67
+ clearRows: selectionManager.clearItems,
68
+ deselectRow,
69
+ selectRow,
70
+ isRowSelected
71
+ }
45
72
  };
46
73
  }
47
74
  //# sourceMappingURL=useSelection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-table/src/hooks/useSelection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,oBAAT,EAA+B,gBAA/B,QAAuD,2BAAvD;AACA,SAAS,sBAAT,QAAuC,oBAAvC;AAkBA,OAAM,SAAU,YAAV,CAA8B,OAA9B,EAAiE;EACrE,MAAM;IAAE,aAAF;IAAiB,KAAjB;IAAwB,QAAxB;IAAkC,oBAAlC;IAAwD,aAAxD;IAAuE;EAAvE,IAA6F,OAAnG;EAEA,MAAM,CAAC,QAAD,EAAW,WAAX,IAA0B,oBAAoB,CAAC;IACnD,YAAY,EAAE,IAAI,GAAJ,EADqC;IAEnD,YAAY,EAAE,oBAFqC;IAGnD,KAAK,EAAE;EAH4C,CAAD,CAApD;EAMA,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAN,CAAc,MAAK;IAC1C,OAAO,sBAAsB,CAAC,aAAD,EAAgB,gBAAgB,IAAG;MAC9D,WAAW,CAAC,MAAK;QACf,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAG,gBAAH,CAAjB;QACA,OAAO,gBAAP;MACD,CAHU,CAAX;IAID,CAL4B,CAA7B;EAMD,CAPwB,EAOtB,CAAC,iBAAD,EAAoB,aAApB,EAAmC,WAAnC,CAPsB,CAAzB;EASA,MAAM,aAAa,GAAiD,gBAAgB,CAAC,MAAK;IACxF,gBAAgB,CAAC,cAAjB,CACE,KAAK,CAAC,GAAN,CAAU,CAAC,IAAD,EAAO,CAAP,KAAa,QAAQ,CAAC,IAAD,EAAO,CAAP,CAA/B,CADF,EAEE,QAFF;EAID,CALmF,CAApF;EAOA,MAAM,SAAS,GAA6C,gBAAgB,CAAE,KAAD,IAC3E,gBAAgB,CAAC,UAAjB,CAA4B,KAA5B,EAAmC,QAAnC,CAD0E,CAA5E;EAIA,MAAM,WAAW,GAA+C,gBAAgB,CAAE,KAAD,IAC/E,gBAAgB,CAAC,YAAjB,CAA8B,KAA9B,EAAqC,QAArC,CAD8E,CAAhF;EAIA,MAAM,SAAS,GAA6C,gBAAgB,CAAE,KAAD,IAC3E,gBAAgB,CAAC,UAAjB,CAA4B,KAA5B,EAAmC,QAAnC,CAD0E,CAA5E;;EAIA,MAAM,aAAa,GAAkD,KAAD,IAClE,gBAAgB,CAAC,UAAjB,CAA4B,KAA5B,EAAmC,QAAnC,CADF;;EAGA,OAAO;IACL,gBAAgB,EAAE,QAAQ,CAAC,IAAT,GAAgB,CAD7B;IAEL,eAAe,EAAE,aAAa,KAAK,QAAlB,GAA6B,QAAQ,CAAC,IAAT,GAAgB,CAA7C,GAAiD,QAAQ,CAAC,IAAT,KAAkB,KAAK,CAAC,MAFrF;IAGL,YAAY,EAAE,QAHT;IAIL,SAJK;IAKL,aALK;IAML,SAAS,EAAE,gBAAgB,CAAC,UANvB;IAOL,WAPK;IAQL,SARK;IASL;EATK,CAAP;AAWD","sourcesContent":["import * as React from 'react';\nimport { useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { createSelectionManager } from './selectionManager';\nimport type {\n GetRowIdInternal,\n OnSelectionChangeCallback,\n RowId,\n SelectionMode,\n TableSelectionStateInternal,\n} from './types';\n\ninterface UseSelectionOptions<TItem> {\n selectionMode: SelectionMode;\n items: TItem[];\n getRowId: GetRowIdInternal<TItem>;\n defaultSelectedItems?: Set<RowId>;\n selectedItems?: Set<RowId>;\n onSelectionChange?: OnSelectionChangeCallback;\n}\n\nexport function useSelection<TItem>(options: UseSelectionOptions<TItem>): TableSelectionStateInternal {\n const { selectionMode, items, getRowId, 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, newSelectedItems => {\n setSelected(() => {\n onSelectionChange?.(newSelectedItems);\n return newSelectedItems;\n });\n });\n }, [onSelectionChange, selectionMode, setSelected]);\n\n const toggleAllRows: TableSelectionStateInternal['toggleAllRows'] = useEventCallback(() => {\n selectionManager.toggleAllItems(\n items.map((item, i) => getRowId(item, i)),\n selected,\n );\n });\n\n const toggleRow: TableSelectionStateInternal['toggleRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.toggleItem(rowId, selected),\n );\n\n const deselectRow: TableSelectionStateInternal['deselectRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.deselectItem(rowId, selected),\n );\n\n const selectRow: TableSelectionStateInternal['selectRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.selectItem(rowId, selected),\n );\n\n const isRowSelected: TableSelectionStateInternal['isRowSelected'] = (rowId: RowId) =>\n selectionManager.isSelected(rowId, selected);\n\n return {\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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-table/src/hooks/useSelection.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;EAO7D,gBAAgB,EAAE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EAAA,KAAA,KAAA,CAAhB,GAAgB,EAAhB,GAAoB,CAApB;IAAqB,CAA5C,CADF,EAEE,QAFF;EAID,CAL2E,CAA5E;EAOA,MAAM,SAAS,GAAqC,gBAAgB,CAAE,KAAD,IACnE,gBAAgB,CAAC,UAAjB,CAA4B,KAA5B,EAAmC,QAAnC,CADkE,CAApE;EAIA,MAAM,WAAW,GAAuC,gBAAgB,CAAE,KAAD,IACvE,gBAAgB,CAAC,YAAjB,CAA8B,KAA9B,EAAqC,QAArC,CADsE,CAAxE;EAIA,MAAM,SAAS,GAAqC,gBAAgB,CAAE,KAAD,IACnE,gBAAgB,CAAC,UAAjB,CAA4B,KAA5B,EAAmC,QAAnC,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,gBAAgB,EAAE,QAAQ,CAAC,IAAT,GAAgB,CADzB;MAET,eAAe,EAAE,aAAa,KAAK,QAAlB,GAA6B,QAAQ,CAAC,IAAT,GAAgB,CAA7C,GAAiD,QAAQ,CAAC,IAAT,KAAkB,KAAK,CAAC,MAFjF;MAGT,YAAY,EAAE,QAHL;MAIT,SAJS;MAKT,aALS;MAMT,SAAS,EAAE,gBAAgB,CAAC,UANnB;MAOT,WAPS;MAQT,SARS;MAST;IATS;EAFN,CAAP;AAcD","sourcesContent":["import * as React from 'react';\nimport { useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { createSelectionManager } from './selectionManager';\nimport type { RowId, TableSelectionState, TableState, UseSelectionOptions } 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};\n\nexport function useSelection<TItem>(options: UseSelectionOptions) {\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>) => useSelectionState(tableState, options);\n}\n\nexport function useSelectionState<TItem>(\n tableState: TableState<TItem>,\n options: UseSelectionOptions,\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, newSelectedItems => {\n setSelected(() => {\n onSelectionChange?.(newSelectedItems);\n return newSelectedItems;\n });\n });\n }, [onSelectionChange, selectionMode, setSelected]);\n\n const toggleAllRows: TableSelectionState['toggleAllRows'] = useEventCallback(() => {\n selectionManager.toggleAllItems(\n items.map((item, i) => getRowId?.(item) ?? i),\n selected,\n );\n });\n\n const toggleRow: TableSelectionState['toggleRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.toggleItem(rowId, selected),\n );\n\n const deselectRow: TableSelectionState['deselectRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.deselectItem(rowId, selected),\n );\n\n const selectRow: TableSelectionState['selectRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.selectItem(rowId, selected),\n );\n\n const isRowSelected: TableSelectionState['isRowSelected'] = (rowId: RowId) =>\n selectionManager.isSelected(rowId, selected);\n\n return {\n ...tableState,\n selection: {\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/"}
@@ -1,7 +1,25 @@
1
1
  import { useControllableState } from '@fluentui/react-utilities';
2
+
3
+ const noop = () => undefined;
4
+
5
+ export const defaultTableSortState = {
6
+ getSortDirection: () => 'ascending',
7
+ setColumnSort: noop,
8
+ sort: rows => [...rows],
9
+ sortColumn: undefined,
10
+ sortDirection: 'ascending',
11
+ toggleColumnSort: noop
12
+ };
2
13
  export function useSort(options) {
14
+ // False positive, these plugin hooks are intended to be run on every render
15
+ // eslint-disable-next-line react-hooks/rules-of-hooks
16
+ return tableState => useSortState(tableState, options);
17
+ }
18
+ export function useSortState(tableState, options) {
19
+ const {
20
+ columns
21
+ } = tableState;
3
22
  const {
4
- columns,
5
23
  sortState,
6
24
  defaultSortState,
7
25
  onSortChange
@@ -45,28 +63,32 @@ export function useSort(options) {
45
63
  setSorted(newState);
46
64
  };
47
65
 
48
- const sort = items => items.slice().sort((a, b) => {
49
- const sortColumnDef = columns.find(column => column.columnId === sortColumn);
66
+ const sort = rows => {
67
+ return rows.slice().sort((a, b) => {
68
+ const sortColumnDef = columns.find(column => column.columnId === sortColumn);
50
69
 
51
- if (!(sortColumnDef === null || sortColumnDef === void 0 ? void 0 : sortColumnDef.compare)) {
52
- return 0;
53
- }
70
+ if (!(sortColumnDef === null || sortColumnDef === void 0 ? void 0 : sortColumnDef.compare)) {
71
+ return 0;
72
+ }
54
73
 
55
- const mod = sortDirection === 'ascending' ? 1 : -1;
56
- return sortColumnDef.compare(a, b) * mod;
57
- });
74
+ const mod = sortDirection === 'ascending' ? 1 : -1;
75
+ return sortColumnDef.compare(a.item, b.item) * mod;
76
+ });
77
+ };
58
78
 
59
79
  const getSortDirection = columnId => {
60
80
  return sortColumn === columnId ? sortDirection : undefined;
61
81
  };
62
82
 
63
- return {
64
- sortColumn,
65
- sortDirection,
66
- sort,
67
- setColumnSort,
68
- toggleColumnSort,
69
- getSortDirection
83
+ return { ...tableState,
84
+ sort: {
85
+ sort,
86
+ sortColumn,
87
+ sortDirection,
88
+ setColumnSort,
89
+ toggleColumnSort,
90
+ getSortDirection
91
+ }
70
92
  };
71
93
  }
72
94
  //# sourceMappingURL=useSort.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["pack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,CAAT;EACD,CAJD;;EAMA,MAAM,IAAI,GAAI,KAAD,IACX,KAAK,CAAC,KAAN,GAAc,IAAd,CAAmB,CAAC,CAAD,EAAI,CAAJ,KAAS;IAC1B,MAAM,aAAa,GAAG,OAAO,CAAC,IAAR,CAAa,MAAM,IAAI,MAAM,CAAC,QAAP,KAAoB,UAA3C,CAAtB;;IACA,IAAI,EAAC,aAAa,KAAA,IAAb,IAAA,aAAa,KAAA,KAAA,CAAb,GAAa,KAAA,CAAb,GAAA,aAAa,CAAE,OAAhB,CAAJ,EAA6B;MAC3B,OAAO,CAAP;IACD;;IAED,MAAM,GAAG,GAAG,aAAa,KAAK,WAAlB,GAAgC,CAAhC,GAAoC,CAAC,CAAjD;IACA,OAAO,aAAa,CAAC,OAAd,CAAsB,CAAtB,EAAyB,CAAzB,IAA8B,GAArC;EACD,CARD,CADF;;EAWA,MAAM,gBAAgB,GAAuD,QAAD,IAAuB;IACjG,OAAO,UAAU,KAAK,QAAf,GAA0B,aAA1B,GAA0C,SAAjD;EACD,CAFD;;EAIA,OAAO;IACL,UADK;IAEL,aAFK;IAGL,IAHK;IAIL,aAJK;IAKL,gBALK;IAML;EANK,CAAP;AAQD","sourcesContent":["import { useControllableState } from '@fluentui/react-utilities';\nimport type { ColumnDefinition, ColumnId, OnSortChangeCallback, SortState, TableSortStateInternal } from './types';\n\ninterface UseSortOptions<TItem> {\n columns: ColumnDefinition<TItem>[];\n sortState?: SortState;\n defaultSortState?: SortState;\n onSortChange?: OnSortChangeCallback;\n}\n\nexport function useSort<TItem>(options: UseSortOptions<TItem>): TableSortStateInternal<TItem> {\n const { columns, 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 = (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?.(newState);\n return newState;\n });\n };\n\n const setColumnSort: TableSortStateInternal<TItem>['setColumnSort'] = (nextSortColumn, nextSortDirection) => {\n const newState = { sortColumn: nextSortColumn, sortDirection: nextSortDirection };\n onSortChange?.(newState);\n setSorted(newState);\n };\n\n const sort = (items: TItem[]) =>\n items.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, b) * mod;\n });\n\n const getSortDirection: TableSortStateInternal<TItem>['getSortDirection'] = (columnId: ColumnId) => {\n return sortColumn === columnId ? sortDirection : undefined;\n };\n\n return {\n sortColumn,\n sortDirection,\n sort,\n setColumnSort,\n toggleColumnSort,\n getSortDirection,\n };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-table/src/hooks/useSort.ts"],"names":[],"mappings":"AAAA,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,EAAG,IAAD,IAA+B,CAAC,GAAG,IAAJ,CAHuB;EAI5D,UAAU,EAAE,SAJgD;EAK5D,aAAa,EAAE,WAL6C;EAM5D,gBAAgB,EAAE;AAN0C,CAAvD;AASP,OAAM,SAAU,OAAV,CAAyB,OAAzB,EAAgD;EACpD;EACA;EACA,OAAQ,UAAD,IAAmC,YAAY,CAAC,UAAD,EAAa,OAAb,CAAtD;AACD;AAED,OAAM,SAAU,YAAV,CAA8B,UAA9B,EAA6D,OAA7D,EAAoF;EACxF,MAAM;IAAE;EAAF,IAAc,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AS;MAChC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAR,CAAa,MAAM,IAAI,MAAM,CAAC,QAAP,KAAoB,UAA3C,CAAtB;;MACA,IAAI,EAAC,aAAa,KAAA,IAAb,IAAA,aAAa,KAAA,KAAA,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 { useControllableState } from '@fluentui/react-utilities';\nimport type { ColumnId, RowState, SortState, TableSortState, TableState, UseSortOptions } from './types';\n\nconst noop = () => undefined;\n\nexport const defaultTableSortState: TableSortState<unknown> = {\n getSortDirection: () => 'ascending',\n setColumnSort: noop,\n sort: (rows: RowState<unknown>[]) => [...rows],\n sortColumn: undefined,\n sortDirection: 'ascending',\n toggleColumnSort: noop,\n};\n\nexport function useSort<TItem>(options: UseSortOptions) {\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>) => useSortState(tableState, options);\n}\n\nexport function useSortState<TItem>(tableState: TableState<TItem>, options: UseSortOptions): 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 = (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?.(newState);\n return newState;\n });\n };\n\n const setColumnSort: TableSortState<TItem>['setColumnSort'] = (nextSortColumn, nextSortDirection) => {\n const newState = { sortColumn: nextSortColumn, sortDirection: nextSortDirection };\n onSortChange?.(newState);\n setSorted(newState);\n };\n\n const sort = (rows: RowState<TItem>[]) => {\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/"}
@@ -1,87 +1,32 @@
1
- import * as React from 'react';
2
- import { useSelection } from './useSelection';
3
- import { useSort } from './useSort';
4
- export function useTable(options) {
1
+ import { defaultTableSelectionState } from './useSelection';
2
+ import { defaultTableSortState } from './useSort';
3
+
4
+ const defaultRowEnhancer = row => row;
5
+
6
+ export function useTable(options, plugins = []) {
5
7
  const {
6
- items: baseItems,
7
- columns,
8
- getRowId: getUserRowId = () => undefined,
9
- selectionMode = 'multiselect',
10
- rowEnhancer = row => row,
11
- defaultSelectedRows,
12
- selectedRows: userSelectedRows,
13
- onSelectionChange,
14
- sortState: userSortState,
15
- defaultSortState,
16
- onSortChange
8
+ items,
9
+ getRowId,
10
+ columns
17
11
  } = options;
18
- const getRowId = React.useCallback((item, index) => {
12
+
13
+ const getRows = (rowEnhancer = defaultRowEnhancer) => items.map((item, i) => {
19
14
  var _a;
20
15
 
21
- return (_a = getUserRowId(item)) !== null && _a !== void 0 ? _a : index;
22
- }, [getUserRowId]);
23
- const {
24
- sortColumn,
25
- sortDirection,
26
- toggleColumnSort,
27
- setColumnSort,
28
- getSortDirection,
29
- sort
30
- } = useSort({
31
- columns,
32
- sortState: userSortState,
33
- defaultSortState,
34
- onSortChange
35
- });
36
- const sortState = React.useMemo(() => ({
37
- sortColumn,
38
- sortDirection,
39
- setColumnSort,
40
- toggleColumnSort,
41
- getSortDirection
42
- }), [sortColumn, sortDirection, setColumnSort, toggleColumnSort, getSortDirection]);
43
- const {
44
- isRowSelected,
45
- toggleRow,
46
- toggleAllRows,
47
- clearRows,
48
- selectedRows,
49
- allRowsSelected,
50
- someRowsSelected,
51
- selectRow,
52
- deselectRow
53
- } = useSelection({
54
- selectionMode,
55
- items: baseItems,
56
- getRowId,
57
- defaultSelectedItems: defaultSelectedRows,
58
- selectedItems: userSelectedRows,
59
- onSelectionChange
60
- });
61
- const selectionState = React.useMemo(() => ({
62
- isRowSelected,
63
- clearRows,
64
- deselectRow,
65
- selectRow,
66
- toggleAllRows,
67
- toggleRow,
68
- selectedRows: Array.from(selectedRows),
69
- allRowsSelected,
70
- someRowsSelected
71
- }), [isRowSelected, clearRows, deselectRow, selectRow, toggleAllRows, toggleRow, selectedRows, allRowsSelected, someRowsSelected]);
72
- const rows = React.useMemo(() => sort(baseItems).map((item, i) => {
73
16
  return rowEnhancer({
74
17
  item,
75
- rowId: getRowId(item, i)
76
- }, {
77
- selection: selectionState,
78
- sort: sortState
18
+ rowId: (_a = getRowId === null || getRowId === void 0 ? void 0 : getRowId(item)) !== null && _a !== void 0 ? _a : i
79
19
  });
80
- }), [baseItems, getRowId, sort, rowEnhancer, selectionState, sortState]);
81
- return {
82
- rows,
83
- selection: selectionState,
84
- sort: sortState
20
+ });
21
+
22
+ const initialState = {
23
+ getRowId,
24
+ items,
25
+ columns,
26
+ getRows,
27
+ selection: defaultTableSelectionState,
28
+ sort: defaultTableSortState
85
29
  };
30
+ return plugins.reduce((state, plugin) => plugin(state), initialState);
86
31
  }
87
32
  //# sourceMappingURL=useTable.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-table/src/hooks/useTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AASA,SAAS,YAAT,QAA6B,gBAA7B;AACA,SAAS,OAAT,QAAwB,WAAxB;AAEA,OAAM,SAAU,QAAV,CACJ,OADI,EACsC;EAE1C,MAAM;IACJ,KAAK,EAAE,SADH;IAEJ,OAFI;IAGJ,QAAQ,EAAE,YAAY,GAAG,MAAM,SAH3B;IAIJ,aAAa,GAAG,aAJZ;IAKJ,WAAW,GAAI,GAAD,IAA0B,GALpC;IAMJ,mBANI;IAOJ,YAAY,EAAE,gBAPV;IAQJ,iBARI;IASJ,SAAS,EAAE,aATP;IAUJ,gBAVI;IAWJ;EAXI,IAYF,OAZJ;EAcA,MAAM,QAAQ,GAA4B,KAAK,CAAC,WAAN,CACxC,CAAC,IAAD,EAAc,KAAd,KAA+B;IAAA,IAAA,EAAA;;IAAC,OAAA,CAAA,EAAA,GAAA,YAAY,CAAC,IAAD,CAAZ,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,EAAlB,GAAsB,KAAtB;EAA2B,CADnB,EAExC,CAAC,YAAD,CAFwC,CAA1C;EAIA,MAAM;IAAE,UAAF;IAAc,aAAd;IAA6B,gBAA7B;IAA+C,aAA/C;IAA8D,gBAA9D;IAAgF;EAAhF,IAAyF,OAAO,CAAC;IACrG,OADqG;IAErG,SAAS,EAAE,aAF0F;IAGrG,gBAHqG;IAIrG;EAJqG,CAAD,CAAtG;EAMA,MAAM,SAAS,GAAmB,KAAK,CAAC,OAAN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N;IAGL,IAAI,EAAE;EAHD,CAAP;AAKD","sourcesContent":["import * as React from 'react';\nimport type {\n UseTableOptions,\n TableState,\n RowState,\n TableSelectionState,\n TableSortState,\n GetRowIdInternal,\n} from './types';\nimport { useSelection } from './useSelection';\nimport { useSort } from './useSort';\n\nexport function useTable<TItem, TRowState extends RowState<TItem> = RowState<TItem>>(\n options: UseTableOptions<TItem, TRowState>,\n): TableState<TItem, TRowState> {\n const {\n items: baseItems,\n columns,\n getRowId: getUserRowId = () => undefined,\n selectionMode = 'multiselect',\n rowEnhancer = (row: RowState<TItem>) => row as TRowState,\n defaultSelectedRows,\n selectedRows: userSelectedRows,\n onSelectionChange,\n sortState: userSortState,\n defaultSortState,\n onSortChange,\n } = options;\n\n const getRowId: GetRowIdInternal<TItem> = React.useCallback(\n (item: TItem, index: number) => getUserRowId(item) ?? index,\n [getUserRowId],\n );\n const { sortColumn, sortDirection, toggleColumnSort, setColumnSort, getSortDirection, sort } = useSort({\n columns,\n sortState: userSortState,\n defaultSortState,\n onSortChange,\n });\n const sortState: TableSortState = React.useMemo(\n () => ({\n sortColumn,\n sortDirection,\n setColumnSort,\n toggleColumnSort,\n getSortDirection,\n }),\n [sortColumn, sortDirection, setColumnSort, toggleColumnSort, getSortDirection],\n );\n\n const {\n isRowSelected,\n toggleRow,\n toggleAllRows,\n clearRows,\n selectedRows,\n allRowsSelected,\n someRowsSelected,\n selectRow,\n deselectRow,\n } = useSelection({\n selectionMode,\n items: baseItems,\n getRowId,\n defaultSelectedItems: defaultSelectedRows,\n selectedItems: userSelectedRows,\n onSelectionChange,\n });\n\n const selectionState: TableSelectionState = React.useMemo(\n () => ({\n isRowSelected,\n clearRows,\n deselectRow,\n selectRow,\n toggleAllRows,\n toggleRow,\n selectedRows: Array.from(selectedRows),\n allRowsSelected,\n someRowsSelected,\n }),\n [\n isRowSelected,\n clearRows,\n deselectRow,\n selectRow,\n toggleAllRows,\n toggleRow,\n selectedRows,\n allRowsSelected,\n someRowsSelected,\n ],\n );\n\n const rows = React.useMemo(\n () =>\n sort(baseItems).map((item, i) => {\n return rowEnhancer(\n {\n item,\n rowId: getRowId(item, i),\n },\n { selection: selectionState, sort: sortState },\n );\n }),\n [baseItems, getRowId, sort, rowEnhancer, selectionState, sortState],\n );\n\n return {\n rows,\n selection: selectionState,\n sort: sortState,\n };\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,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/"}
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { useTable } from './hooks';
1
+ export { useTable, useSelection, useSort } 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,QAAT,QAAyB,SAAzB;AAWA,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","sourcesContent":["export { useTable } from './hooks';\nexport type {\n UseTableOptions,\n TableSelectionState,\n TableSortState,\n ColumnDefinition,\n RowState,\n RowId,\n ColumnId,\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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-table/src/index.ts"],"names":[],"mappings":"AAAA,SAAS,QAAT,EAAmB,YAAnB,EAAiC,OAAjC,QAAgD,SAAhD;AAaA,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","sourcesContent":["export { useTable, useSelection, useSort } 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} 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"],"sourceRoot":"../src/"}
@@ -9,4 +9,8 @@ const tslib_1 = /*#__PURE__*/require("tslib");
9
9
  tslib_1.__exportStar(require("./types"), exports);
10
10
 
11
11
  tslib_1.__exportStar(require("./useTable"), exports);
12
+
13
+ tslib_1.__exportStar(require("./useSort"), exports);
14
+
15
+ tslib_1.__exportStar(require("./useSelection"), exports);
12
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-table/src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './types';\nexport * from './useTable';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-table/src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,WAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './types';\nexport * from './useTable';\nexport * from './useSort';\nexport * from './useSelection';\n"],"sourceRoot":"../src/"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useSelection = void 0;
6
+ exports.useSelectionState = exports.useSelection = exports.defaultTableSelectionState = void 0;
7
7
 
8
8
  const React = /*#__PURE__*/require("react");
9
9
 
@@ -11,11 +11,35 @@ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
11
 
12
12
  const selectionManager_1 = /*#__PURE__*/require("./selectionManager");
13
13
 
14
+ const noop = () => undefined;
15
+
16
+ exports.defaultTableSelectionState = {
17
+ allRowsSelected: false,
18
+ clearRows: noop,
19
+ deselectRow: noop,
20
+ isRowSelected: () => false,
21
+ selectRow: noop,
22
+ selectedRows: /*#__PURE__*/new Set(),
23
+ someRowsSelected: false,
24
+ toggleAllRows: noop,
25
+ toggleRow: noop
26
+ };
27
+
14
28
  function useSelection(options) {
29
+ // False positive, these plugin hooks are intended to be run on every render
30
+ // eslint-disable-next-line react-hooks/rules-of-hooks
31
+ return tableState => useSelectionState(tableState, options);
32
+ }
33
+
34
+ exports.useSelection = useSelection;
35
+
36
+ function useSelectionState(tableState, options) {
15
37
  const {
16
- selectionMode,
17
38
  items,
18
- getRowId,
39
+ getRowId
40
+ } = tableState;
41
+ const {
42
+ selectionMode,
19
43
  defaultSelectedItems,
20
44
  selectedItems,
21
45
  onSelectionChange
@@ -34,7 +58,11 @@ function useSelection(options) {
34
58
  });
35
59
  }, [onSelectionChange, selectionMode, setSelected]);
36
60
  const toggleAllRows = react_utilities_1.useEventCallback(() => {
37
- selectionManager.toggleAllItems(items.map((item, i) => getRowId(item, i)), selected);
61
+ selectionManager.toggleAllItems(items.map((item, i) => {
62
+ var _a;
63
+
64
+ return (_a = getRowId === null || getRowId === void 0 ? void 0 : getRowId(item)) !== null && _a !== void 0 ? _a : i;
65
+ }), selected);
38
66
  });
39
67
  const toggleRow = react_utilities_1.useEventCallback(rowId => selectionManager.toggleItem(rowId, selected));
40
68
  const deselectRow = react_utilities_1.useEventCallback(rowId => selectionManager.deselectItem(rowId, selected));
@@ -42,18 +70,20 @@ function useSelection(options) {
42
70
 
43
71
  const isRowSelected = rowId => selectionManager.isSelected(rowId, selected);
44
72
 
45
- return {
46
- someRowsSelected: selected.size > 0,
47
- allRowsSelected: selectionMode === 'single' ? selected.size > 0 : selected.size === items.length,
48
- selectedRows: selected,
49
- toggleRow,
50
- toggleAllRows,
51
- clearRows: selectionManager.clearItems,
52
- deselectRow,
53
- selectRow,
54
- isRowSelected
73
+ return { ...tableState,
74
+ selection: {
75
+ someRowsSelected: selected.size > 0,
76
+ allRowsSelected: selectionMode === 'single' ? selected.size > 0 : selected.size === items.length,
77
+ selectedRows: selected,
78
+ toggleRow,
79
+ toggleAllRows,
80
+ clearRows: selectionManager.clearItems,
81
+ deselectRow,
82
+ selectRow,
83
+ isRowSelected
84
+ }
55
85
  };
56
86
  }
57
87
 
58
- exports.useSelection = useSelection;
88
+ exports.useSelectionState = useSelectionState;
59
89
  //# sourceMappingURL=useSelection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-table/src/hooks/useSelection.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;;AAkBA,SAAgB,YAAhB,CAAoC,OAApC,EAAuE;EACrE,MAAM;IAAE,aAAF;IAAiB,KAAjB;IAAwB,QAAxB;IAAkC,oBAAlC;IAAwD,aAAxD;IAAuE;EAAvE,IAA6F,OAAnG;EAEA,MAAM,CAAC,QAAD,EAAW,WAAX,IAA0B,iBAAA,CAAA,oBAAA,CAAqB;IACnD,YAAY,EAAE,IAAI,GAAJ,EADqC;IAEnD,YAAY,EAAE,oBAFqC;IAGnD,KAAK,EAAE;EAH4C,CAArB,CAAhC;EAMA,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAN,CAAc,MAAK;IAC1C,OAAO,kBAAA,CAAA,sBAAA,CAAuB,aAAvB,EAAsC,gBAAgB,IAAG;MAC9D,WAAW,CAAC,MAAK;QACf,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAG,gBAAH,CAAjB;QACA,OAAO,gBAAP;MACD,CAHU,CAAX;IAID,CALM,CAAP;EAMD,CAPwB,EAOtB,CAAC,iBAAD,EAAoB,aAApB,EAAmC,WAAnC,CAPsB,CAAzB;EASA,MAAM,aAAa,GAAiD,iBAAA,CAAA,gBAAA,CAAiB,MAAK;IACxF,gBAAgB,CAAC,cAAjB,CACE,KAAK,CAAC,GAAN,CAAU,CAAC,IAAD,EAAO,CAAP,KAAa,QAAQ,CAAC,IAAD,EAAO,CAAP,CAA/B,CADF,EAEE,QAFF;EAID,CALmE,CAApE;EAOA,MAAM,SAAS,GAA6C,iBAAA,CAAA,gBAAA,CAAkB,KAAD,IAC3E,gBAAgB,CAAC,UAAjB,CAA4B,KAA5B,EAAmC,QAAnC,CAD0D,CAA5D;EAIA,MAAM,WAAW,GAA+C,iBAAA,CAAA,gBAAA,CAAkB,KAAD,IAC/E,gBAAgB,CAAC,YAAjB,CAA8B,KAA9B,EAAqC,QAArC,CAD8D,CAAhE;EAIA,MAAM,SAAS,GAA6C,iBAAA,CAAA,gBAAA,CAAkB,KAAD,IAC3E,gBAAgB,CAAC,UAAjB,CAA4B,KAA5B,EAAmC,QAAnC,CAD0D,CAA5D;;EAIA,MAAM,aAAa,GAAkD,KAAD,IAClE,gBAAgB,CAAC,UAAjB,CAA4B,KAA5B,EAAmC,QAAnC,CADF;;EAGA,OAAO;IACL,gBAAgB,EAAE,QAAQ,CAAC,IAAT,GAAgB,CAD7B;IAEL,eAAe,EAAE,aAAa,KAAK,QAAlB,GAA6B,QAAQ,CAAC,IAAT,GAAgB,CAA7C,GAAiD,QAAQ,CAAC,IAAT,KAAkB,KAAK,CAAC,MAFrF;IAGL,YAAY,EAAE,QAHT;IAIL,SAJK;IAKL,aALK;IAML,SAAS,EAAE,gBAAgB,CAAC,UANvB;IAOL,WAPK;IAQL,SARK;IASL;EATK,CAAP;AAWD;;AAnDD,OAAA,CAAA,YAAA,GAAA,YAAA","sourcesContent":["import * as React from 'react';\nimport { useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { createSelectionManager } from './selectionManager';\nimport type {\n GetRowIdInternal,\n OnSelectionChangeCallback,\n RowId,\n SelectionMode,\n TableSelectionStateInternal,\n} from './types';\n\ninterface UseSelectionOptions<TItem> {\n selectionMode: SelectionMode;\n items: TItem[];\n getRowId: GetRowIdInternal<TItem>;\n defaultSelectedItems?: Set<RowId>;\n selectedItems?: Set<RowId>;\n onSelectionChange?: OnSelectionChangeCallback;\n}\n\nexport function useSelection<TItem>(options: UseSelectionOptions<TItem>): TableSelectionStateInternal {\n const { selectionMode, items, getRowId, 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, newSelectedItems => {\n setSelected(() => {\n onSelectionChange?.(newSelectedItems);\n return newSelectedItems;\n });\n });\n }, [onSelectionChange, selectionMode, setSelected]);\n\n const toggleAllRows: TableSelectionStateInternal['toggleAllRows'] = useEventCallback(() => {\n selectionManager.toggleAllItems(\n items.map((item, i) => getRowId(item, i)),\n selected,\n );\n });\n\n const toggleRow: TableSelectionStateInternal['toggleRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.toggleItem(rowId, selected),\n );\n\n const deselectRow: TableSelectionStateInternal['deselectRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.deselectItem(rowId, selected),\n );\n\n const selectRow: TableSelectionStateInternal['selectRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.selectItem(rowId, selected),\n );\n\n const isRowSelected: TableSelectionStateInternal['isRowSelected'] = (rowId: RowId) =>\n selectionManager.isSelected(rowId, selected);\n\n return {\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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-table/src/hooks/useSelection.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CA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,SAJS;MAKT,aALS;MAMT,SAAS,EAAE,gBAAgB,CAAC,UANnB;MAOT,WAPS;MAQT,SARS;MAST;IATS;EAFN,CAAP;AAcD;;AA1DD,OAAA,CAAA,iBAAA,GAAA,iBAAA","sourcesContent":["import * as React from 'react';\nimport { useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { createSelectionManager } from './selectionManager';\nimport type { RowId, TableSelectionState, TableState, UseSelectionOptions } 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};\n\nexport function useSelection<TItem>(options: UseSelectionOptions) {\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>) => useSelectionState(tableState, options);\n}\n\nexport function useSelectionState<TItem>(\n tableState: TableState<TItem>,\n options: UseSelectionOptions,\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, newSelectedItems => {\n setSelected(() => {\n onSelectionChange?.(newSelectedItems);\n return newSelectedItems;\n });\n });\n }, [onSelectionChange, selectionMode, setSelected]);\n\n const toggleAllRows: TableSelectionState['toggleAllRows'] = useEventCallback(() => {\n selectionManager.toggleAllItems(\n items.map((item, i) => getRowId?.(item) ?? i),\n selected,\n );\n });\n\n const toggleRow: TableSelectionState['toggleRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.toggleItem(rowId, selected),\n );\n\n const deselectRow: TableSelectionState['deselectRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.deselectItem(rowId, selected),\n );\n\n const selectRow: TableSelectionState['selectRow'] = useEventCallback((rowId: RowId) =>\n selectionManager.selectItem(rowId, selected),\n );\n\n const isRowSelected: TableSelectionState['isRowSelected'] = (rowId: RowId) =>\n selectionManager.isSelected(rowId, selected);\n\n return {\n ...tableState,\n selection: {\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/"}
@@ -3,13 +3,34 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useSort = void 0;
6
+ exports.useSortState = exports.useSort = exports.defaultTableSortState = void 0;
7
7
 
8
8
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
9
9
 
10
+ const noop = () => undefined;
11
+
12
+ exports.defaultTableSortState = {
13
+ getSortDirection: () => 'ascending',
14
+ setColumnSort: noop,
15
+ sort: rows => [...rows],
16
+ sortColumn: undefined,
17
+ sortDirection: 'ascending',
18
+ toggleColumnSort: noop
19
+ };
20
+
10
21
  function useSort(options) {
22
+ // False positive, these plugin hooks are intended to be run on every render
23
+ // eslint-disable-next-line react-hooks/rules-of-hooks
24
+ return tableState => useSortState(tableState, options);
25
+ }
26
+
27
+ exports.useSort = useSort;
28
+
29
+ function useSortState(tableState, options) {
30
+ const {
31
+ columns
32
+ } = tableState;
11
33
  const {
12
- columns,
13
34
  sortState,
14
35
  defaultSortState,
15
36
  onSortChange
@@ -53,30 +74,34 @@ function useSort(options) {
53
74
  setSorted(newState);
54
75
  };
55
76
 
56
- const sort = items => items.slice().sort((a, b) => {
57
- const sortColumnDef = columns.find(column => column.columnId === sortColumn);
77
+ const sort = rows => {
78
+ return rows.slice().sort((a, b) => {
79
+ const sortColumnDef = columns.find(column => column.columnId === sortColumn);
58
80
 
59
- if (!(sortColumnDef === null || sortColumnDef === void 0 ? void 0 : sortColumnDef.compare)) {
60
- return 0;
61
- }
81
+ if (!(sortColumnDef === null || sortColumnDef === void 0 ? void 0 : sortColumnDef.compare)) {
82
+ return 0;
83
+ }
62
84
 
63
- const mod = sortDirection === 'ascending' ? 1 : -1;
64
- return sortColumnDef.compare(a, b) * mod;
65
- });
85
+ const mod = sortDirection === 'ascending' ? 1 : -1;
86
+ return sortColumnDef.compare(a.item, b.item) * mod;
87
+ });
88
+ };
66
89
 
67
90
  const getSortDirection = columnId => {
68
91
  return sortColumn === columnId ? sortDirection : undefined;
69
92
  };
70
93
 
71
- return {
72
- sortColumn,
73
- sortDirection,
74
- sort,
75
- setColumnSort,
76
- toggleColumnSort,
77
- getSortDirection
94
+ return { ...tableState,
95
+ sort: {
96
+ sort,
97
+ sortColumn,
98
+ sortDirection,
99
+ setColumnSort,
100
+ toggleColumnSort,
101
+ getSortDirection
102
+ }
78
103
  };
79
104
  }
80
105
 
81
- exports.useSort = useSort;
106
+ exports.useSortState = useSortState;
82
107
  //# sourceMappingURL=useSort.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-table/src/hooks/useSort.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAUA,SAAgB,OAAhB,CAA+B,OAA/B,EAA6D;EAC3D,MAAM;IAAE,OAAF;IAAW,SAAX;IAAsB,gBAAtB;IAAwC;EAAxC,IAAyD,OAA/D;EAEA,MAAM,CAAC,MAAD,EAAS,SAAT,IAAsB,iBAAA,CAAA,oBAAA,CAAgC;IAC1D,YAAY,EAAE;MACZ,aAAa,EAAE,WADH;MAEZ,UAAU,EAAE;IAFA,CAD4C;IAK1D,YAAY,EAAE,gBAL4C;IAM1D,KAAK,EAAE;EANmD,CAAhC,CAA5B;EASA,MAAM;IAAE,UAAF;IAAc;EAAd,IAAgC,MAAtC;;EAEA,MAAM,gBAAgB,GAAI,QAAD,IAAmC;IAC1D,SAAS,CA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AA8B,GAArC;EACD,CARD,CADF;;EAWA,MAAM,gBAAgB,GAAuD,QAAD,IAAuB;IACjG,OAAO,UAAU,KAAK,QAAf,GAA0B,aAA1B,GAA0C,SAAjD;EACD,CAFD;;EAIA,OAAO;IACL,UADK;IAEL,aAFK;IAGL,IAHK;IAIL,aAJK;IAKL,gBALK;IAML;EANK,CAAP;AAQD;;AAzDD,OAAA,CAAA,OAAA,GAAA,OAAA","sourcesContent":["import { useControllableState } from '@fluentui/react-utilities';\nimport type { ColumnDefinition, ColumnId, OnSortChangeCallback, SortState, TableSortStateInternal } from './types';\n\ninterface UseSortOptions<TItem> {\n columns: ColumnDefinition<TItem>[];\n sortState?: SortState;\n defaultSortState?: SortState;\n onSortChange?: OnSortChangeCallback;\n}\n\nexport function useSort<TItem>(options: UseSortOptions<TItem>): TableSortStateInternal<TItem> {\n const { columns, 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 = (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?.(newState);\n return newState;\n });\n };\n\n const setColumnSort: TableSortStateInternal<TItem>['setColumnSort'] = (nextSortColumn, nextSortDirection) => {\n const newState = { sortColumn: nextSortColumn, sortDirection: nextSortDirection };\n onSortChange?.(newState);\n setSorted(newState);\n };\n\n const sort = (items: TItem[]) =>\n items.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, b) * mod;\n });\n\n const getSortDirection: TableSortStateInternal<TItem>['getSortDirection'] = (columnId: ColumnId) => {\n return sortColumn === columnId ? sortDirection : undefined;\n };\n\n return {\n sortColumn,\n sortDirection,\n sort,\n setColumnSort,\n toggleColumnSort,\n getSortDirection,\n };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-table/src/hooks/useSort.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAGA,MAAM,IAAI,GAAG,MAAM,SAAnB;;AAEa,OAAA,CAAA,qBAAA,GAAiD;EAC5D,gBAAgB,EAAE,MAAM,WADoC;EAE5D,aAAa,EAAE,IAF6C;EAG5D,IAAI,EAAG,IAAD,IAA+B,CAAC,GAAG,IAAJ,CAHuB;EAI5D,UAAU,EAAE,SAJgD;EAK5D,aAAa,EAAE,WAL6C;EAM5D,gBAAgB,EAAE;AAN0C,CAAjD;;AASb,SAAgB,OAAhB,CAA+B,OAA/B,EAAsD;EACpD;EACA;EACA,OAAQ,UAAD,IAAmC,YAAY,CAAC,UAAD,EAAa,OAAb,CAAtD;AACD;;AAJD,OAAA,CAAA,OAAA,GAAA,OAAA;;AAMA,SAAgB,YAAhB,CAAoC,UAApC,EAAmE,OAAnE,EAA0F;EACxF,MAAM;IAAE;EAAF,IAAc,UAApB;EACA,MAAM;IAAE,SAAF;IAAa,gBAAb;IAA+B;EAA/B,IAAgD,OAAtD;EAEA,MAAM,CAAC,MAAD,EAAS,SAAT,IAAsB,iBAAA,CAAA,oBAAA,CAAgC;IAC1D,YAAY,EAAE;MACZ,aAAa,EAAE,WADH;MAEZ,UAAU,EAAE;IAFA,CAD4C;IAK1D,YAAY,EAAE,gBAL4C;IAM1D,KAAK,EAAE;EANmD,CAAhC,CAA5B;EASA,MAAM;IAAE,UAAF;IAAc;EAAd,IAAgC,MAAtC;;EAEA,MAAM,gBAAgB,GAAI,QAAD,IAAmC;IAC1D,SAAS,CAAC,CAAC,IAAG;MACZ,MA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AC,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;;AA9DD,OAAA,CAAA,YAAA,GAAA,YAAA","sourcesContent":["import { useControllableState } from '@fluentui/react-utilities';\nimport type { ColumnId, RowState, SortState, TableSortState, TableState, UseSortOptions } from './types';\n\nconst noop = () => undefined;\n\nexport const defaultTableSortState: TableSortState<unknown> = {\n getSortDirection: () => 'ascending',\n setColumnSort: noop,\n sort: (rows: RowState<unknown>[]) => [...rows],\n sortColumn: undefined,\n sortDirection: 'ascending',\n toggleColumnSort: noop,\n};\n\nexport function useSort<TItem>(options: UseSortOptions) {\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>) => useSortState(tableState, options);\n}\n\nexport function useSortState<TItem>(tableState: TableState<TItem>, options: UseSortOptions): 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 = (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?.(newState);\n return newState;\n });\n };\n\n const setColumnSort: TableSortState<TItem>['setColumnSort'] = (nextSortColumn, nextSortDirection) => {\n const newState = { sortColumn: nextSortColumn, sortDirection: nextSortDirection };\n onSortChange?.(newState);\n setSorted(newState);\n };\n\n const sort = (rows: RowState<TItem>[]) => {\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/"}
@@ -5,94 +5,37 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useTable = void 0;
7
7
 
8
- const React = /*#__PURE__*/require("react");
9
-
10
8
  const useSelection_1 = /*#__PURE__*/require("./useSelection");
11
9
 
12
10
  const useSort_1 = /*#__PURE__*/require("./useSort");
13
11
 
14
- function useTable(options) {
12
+ const defaultRowEnhancer = row => row;
13
+
14
+ function useTable(options, plugins = []) {
15
15
  const {
16
- items: baseItems,
17
- columns,
18
- getRowId: getUserRowId = () => undefined,
19
- selectionMode = 'multiselect',
20
- rowEnhancer = row => row,
21
- defaultSelectedRows,
22
- selectedRows: userSelectedRows,
23
- onSelectionChange,
24
- sortState: userSortState,
25
- defaultSortState,
26
- onSortChange
16
+ items,
17
+ getRowId,
18
+ columns
27
19
  } = options;
28
- const getRowId = React.useCallback((item, index) => {
20
+
21
+ const getRows = (rowEnhancer = defaultRowEnhancer) => items.map((item, i) => {
29
22
  var _a;
30
23
 
31
- return (_a = getUserRowId(item)) !== null && _a !== void 0 ? _a : index;
32
- }, [getUserRowId]);
33
- const {
34
- sortColumn,
35
- sortDirection,
36
- toggleColumnSort,
37
- setColumnSort,
38
- getSortDirection,
39
- sort
40
- } = useSort_1.useSort({
41
- columns,
42
- sortState: userSortState,
43
- defaultSortState,
44
- onSortChange
45
- });
46
- const sortState = React.useMemo(() => ({
47
- sortColumn,
48
- sortDirection,
49
- setColumnSort,
50
- toggleColumnSort,
51
- getSortDirection
52
- }), [sortColumn, sortDirection, setColumnSort, toggleColumnSort, getSortDirection]);
53
- const {
54
- isRowSelected,
55
- toggleRow,
56
- toggleAllRows,
57
- clearRows,
58
- selectedRows,
59
- allRowsSelected,
60
- someRowsSelected,
61
- selectRow,
62
- deselectRow
63
- } = useSelection_1.useSelection({
64
- selectionMode,
65
- items: baseItems,
66
- getRowId,
67
- defaultSelectedItems: defaultSelectedRows,
68
- selectedItems: userSelectedRows,
69
- onSelectionChange
70
- });
71
- const selectionState = React.useMemo(() => ({
72
- isRowSelected,
73
- clearRows,
74
- deselectRow,
75
- selectRow,
76
- toggleAllRows,
77
- toggleRow,
78
- selectedRows: Array.from(selectedRows),
79
- allRowsSelected,
80
- someRowsSelected
81
- }), [isRowSelected, clearRows, deselectRow, selectRow, toggleAllRows, toggleRow, selectedRows, allRowsSelected, someRowsSelected]);
82
- const rows = React.useMemo(() => sort(baseItems).map((item, i) => {
83
24
  return rowEnhancer({
84
25
  item,
85
- rowId: getRowId(item, i)
86
- }, {
87
- selection: selectionState,
88
- sort: sortState
26
+ rowId: (_a = getRowId === null || getRowId === void 0 ? void 0 : getRowId(item)) !== null && _a !== void 0 ? _a : i
89
27
  });
90
- }), [baseItems, getRowId, sort, rowEnhancer, selectionState, sortState]);
91
- return {
92
- rows,
93
- selection: selectionState,
94
- sort: sortState
28
+ });
29
+
30
+ const initialState = {
31
+ getRowId,
32
+ items,
33
+ columns,
34
+ getRows,
35
+ selection: useSelection_1.defaultTableSelectionState,
36
+ sort: useSort_1.defaultTableSortState
95
37
  };
38
+ return plugins.reduce((state, plugin) => plugin(state), initialState);
96
39
  }
97
40
 
98
41
  exports.useTable = useTable;
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-table/src/hooks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I;IAGJ,aAHI;IAIJ,SAJI;IAKJ,YALI;IAMJ,eANI;IAOJ,gBAPI;IAQJ,SARI;IASJ;EATI,IAUF,cAAA,CAAA,YAAA,CAAa;IACf,aADe;IAEf,KAAK,EAAE,SAFQ;IAGf,QAHe;IAIf,oBAAoB,EAAE,mBAJP;IAKf,aAAa,EAAE,gBALA;IAMf;EANe,CAAb,CAVJ;EAmBA,MAAM,cAAc,GAAwB,KAAK,CAAC,OAAN,CAC1C,OAAO;IACL,aADK;IAEL,SAFK;IAGL,WAHK;IAIL,SAJK;IAKL,aALK;IAML,SANK;IAOL,YAAY,EAAE,KAAK,CAAC,IAAN,CAAW,YAAX,CAPT;IAQL,eARK;IASL;EATK,CAAP,CAD0C,EAY1C,CACE,aADF,EAEE,SAFF,EAGE,WAHF,EAIE,SAJF,EAKE,aALF,EAME,SANF,EAOE,YAPF,EAQE,eARF,EASE,gBATF,CAZ0C,CAA5C;EAyBA,MAAM,IAAI,GAAG,KAAK,CAAC,OAAN,CACX,MACE,IAAI,CAAC,SAAD,CAAJ,CAAgB,GAAhB,CAAoB,CAAC,IAAD,EAAO,CAAP,KAAY;IAC9B,OAAO,WAAW,CAChB;MACE,IADF;MAEE,KAAK,EAAE,QAAQ,CAAC,IAAD,EAAO,CAAP;IAFjB,CADgB,EAKhB;MAAE,SAAS,EAAE,cAAb;MAA6B,IAAI,EAAE;IAAnC,CALgB,CAAlB;EAOD,CARD,CAFS,EAWX,CAAC,SAAD,EAAY,QAAZ,EAAsB,IAAtB,EAA4B,WAA5B,EAAyC,cAAzC,EAAyD,SAAzD,CAXW,CAAb;EAcA,OAAO;IACL,IADK;IAEL,SAAS,EAAE,cAFN;IAGL,IAAI,EAAE;EAHD,CAAP;AAKD;;AArGD,OAAA,CAAA,QAAA,GAAA,QAAA","sourcesContent":["import * as React from 'react';\nimport type {\n UseTableOptions,\n TableState,\n RowState,\n TableSelectionState,\n TableSortState,\n GetRowIdInternal,\n} from './types';\nimport { useSelection } from './useSelection';\nimport { useSort } from './useSort';\n\nexport function useTable<TItem, TRowState extends RowState<TItem> = RowState<TItem>>(\n options: UseTableOptions<TItem, TRowState>,\n): TableState<TItem, TRowState> {\n const {\n items: baseItems,\n columns,\n getRowId: getUserRowId = () => undefined,\n selectionMode = 'multiselect',\n rowEnhancer = (row: RowState<TItem>) => row as TRowState,\n defaultSelectedRows,\n selectedRows: userSelectedRows,\n onSelectionChange,\n sortState: userSortState,\n defaultSortState,\n onSortChange,\n } = options;\n\n const getRowId: GetRowIdInternal<TItem> = React.useCallback(\n (item: TItem, index: number) => getUserRowId(item) ?? index,\n [getUserRowId],\n );\n const { sortColumn, sortDirection, toggleColumnSort, setColumnSort, getSortDirection, sort } = useSort({\n columns,\n sortState: userSortState,\n defaultSortState,\n onSortChange,\n });\n const sortState: TableSortState = React.useMemo(\n () => ({\n sortColumn,\n sortDirection,\n setColumnSort,\n toggleColumnSort,\n getSortDirection,\n }),\n [sortColumn, sortDirection, setColumnSort, toggleColumnSort, getSortDirection],\n );\n\n const {\n isRowSelected,\n toggleRow,\n toggleAllRows,\n clearRows,\n selectedRows,\n allRowsSelected,\n someRowsSelected,\n selectRow,\n deselectRow,\n } = useSelection({\n selectionMode,\n items: baseItems,\n getRowId,\n defaultSelectedItems: defaultSelectedRows,\n selectedItems: userSelectedRows,\n onSelectionChange,\n });\n\n const selectionState: TableSelectionState = React.useMemo(\n () => ({\n isRowSelected,\n clearRows,\n deselectRow,\n selectRow,\n toggleAllRows,\n toggleRow,\n selectedRows: Array.from(selectedRows),\n allRowsSelected,\n someRowsSelected,\n }),\n [\n isRowSelected,\n clearRows,\n deselectRow,\n selectRow,\n toggleAllRows,\n toggleRow,\n selectedRows,\n allRowsSelected,\n someRowsSelected,\n ],\n );\n\n const rows = React.useMemo(\n () =>\n sort(baseItems).map((item, i) => {\n return rowEnhancer(\n {\n item,\n rowId: getRowId(item, i),\n },\n { selection: selectionState, sort: sortState },\n );\n }),\n [baseItems, getRowId, sort, rowEnhancer, selectionState, sortState],\n );\n\n return {\n rows,\n selection: selectionState,\n sort: sortState,\n };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-table/src/hooks/useTable.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,SAAA,gBAAA,OAAA,CAAA,WAAA,CAAA;;AAEA,MAAM,kBAAkB,GAA4C,GAAG,IAAI,GAA3E;;AAEA,SAAgB,QAAhB,CAAgC,OAAhC,EAAiE,OAAA,GAA8B,EAA/F,EAAiG;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,cAAA,CAAA,0BAL2B;IAMtC,IAAI,EAAE,SAAA,CAAA;EANgC,CAAxC;EASA,OAAO,OAAO,CAAC,MAAR,CAAe,CAAC,KAAD,EAAQ,MAAR,KAAmB,MAAM,CAAC,KAAD,CAAxC,EAAiD,YAAjD,CAAP;AACD;;AAjBD,OAAA,CAAA,QAAA,GAAA,QAAA","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/"}
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TableCellLayout = exports.renderTableCellActions_unstable = exports.useTableCellActions_unstable = exports.useTableCellActionsStyles_unstable = exports.tableCellActionsClassNames = exports.TableCellActions = exports.tableSelectionCellClassNames = exports.renderTableSelectionCell_unstable = exports.useTableSelectionCell_unstable = exports.useTableSelectionCellStyles_unstable = exports.TableSelectionCell = exports.useTableContext = exports.TableContextProvider = exports.renderTableHeaderCell_unstable = exports.useTableHeaderCell_unstable = exports.useTableHeaderCellStyles_unstable = exports.tableHeaderCellClassNames = exports.tableHeaderCellClassName = exports.TableHeaderCell = exports.renderTableHeader_unstable = exports.useTableHeader_unstable = exports.useTableHeaderStyles_unstable = exports.tableHeaderClassName = exports.tableHeaderClassNames = exports.TableHeader = exports.renderTable_unstable = exports.useTable_unstable = exports.useTableStyles_unstable = exports.tableClassNames = exports.tableClassName = exports.Table = exports.renderTableBody_unstable = exports.useTableBody_unstable = exports.useTableBodyStyles_unstable = exports.tableBodyClassNames = exports.tableBodyClassName = exports.TableBody = exports.renderTableRow_unstable = exports.useTableRow_unstable = exports.useTableRowStyles_unstable = exports.tableRowClassName = exports.tableRowClassNames = exports.TableRow = exports.renderTableCell_unstable = exports.useTableCell_unstable = exports.useTableCellStyles_unstable = exports.tableCellClassName = exports.tableCellClassNames = exports.TableCell = exports.useTable = void 0;
7
- exports.renderTableCellLayout_unstable = exports.useTableCellLayout_unstable = exports.useTableCellLayoutStyles_unstable = exports.tableCellLayoutClassNames = void 0;
6
+ exports.useTableCellActions_unstable = exports.useTableCellActionsStyles_unstable = exports.tableCellActionsClassNames = exports.TableCellActions = exports.tableSelectionCellClassNames = exports.renderTableSelectionCell_unstable = exports.useTableSelectionCell_unstable = exports.useTableSelectionCellStyles_unstable = exports.TableSelectionCell = exports.useTableContext = exports.TableContextProvider = exports.renderTableHeaderCell_unstable = exports.useTableHeaderCell_unstable = exports.useTableHeaderCellStyles_unstable = exports.tableHeaderCellClassNames = exports.tableHeaderCellClassName = exports.TableHeaderCell = exports.renderTableHeader_unstable = exports.useTableHeader_unstable = exports.useTableHeaderStyles_unstable = exports.tableHeaderClassName = exports.tableHeaderClassNames = exports.TableHeader = exports.renderTable_unstable = exports.useTable_unstable = exports.useTableStyles_unstable = exports.tableClassNames = exports.tableClassName = exports.Table = exports.renderTableBody_unstable = exports.useTableBody_unstable = exports.useTableBodyStyles_unstable = exports.tableBodyClassNames = exports.tableBodyClassName = exports.TableBody = exports.renderTableRow_unstable = exports.useTableRow_unstable = exports.useTableRowStyles_unstable = exports.tableRowClassName = exports.tableRowClassNames = exports.TableRow = exports.renderTableCell_unstable = exports.useTableCell_unstable = exports.useTableCellStyles_unstable = exports.tableCellClassName = exports.tableCellClassNames = exports.TableCell = exports.useSort = exports.useSelection = exports.useTable = void 0;
7
+ exports.renderTableCellLayout_unstable = exports.useTableCellLayout_unstable = exports.useTableCellLayoutStyles_unstable = exports.tableCellLayoutClassNames = exports.TableCellLayout = exports.renderTableCellActions_unstable = void 0;
8
8
 
9
9
  var hooks_1 = /*#__PURE__*/require("./hooks");
10
10
 
@@ -14,6 +14,18 @@ Object.defineProperty(exports, "useTable", {
14
14
  return hooks_1.useTable;
15
15
  }
16
16
  });
17
+ Object.defineProperty(exports, "useSelection", {
18
+ enumerable: true,
19
+ get: function () {
20
+ return hooks_1.useSelection;
21
+ }
22
+ });
23
+ Object.defineProperty(exports, "useSort", {
24
+ enumerable: true,
25
+ get: function () {
26
+ return hooks_1.useSort;
27
+ }
28
+ });
17
29
 
18
30
  var TableCell_1 = /*#__PURE__*/require("./TableCell");
19
31
 
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-table/src/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,UAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,QAAA;EAAQ;AAAR,CAAA;;AAWT,IAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACE,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,WAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,WAAA,CAAA,SAAA;EAAS;AAAT,CAAA;AACA,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,qBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,WAAA,CAAA,mBAAA;EAAmB;AAAnB,CAAA;AACA,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,WAAA,CAAA,kBAAA;EAAkB;AAAlB,CAAA;AACA,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,6BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,WAAA,CAAA,2BAAA;EAA2B;AAA3B,CAAA;AACA,MAAA,CAAA,cA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AA,OAAA,EAAA,2BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,iBAAA,CAAA,yBAAA;EAAyB;AAAzB,CAAA;AACA,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,mCAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,iBAAA,CAAA,iCAAA;EAAiC;AAAjC,CAAA;AACA,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,6BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,iBAAA,CAAA,2BAAA;EAA2B;AAA3B,CAAA;AACA,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,gCAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,iBAAA,CAAA,8BAAA;EAA8B;AAA9B,CAAA","sourcesContent":["export { useTable } from './hooks';\nexport type {\n UseTableOptions,\n TableSelectionState,\n TableSortState,\n ColumnDefinition,\n RowState,\n RowId,\n ColumnId,\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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-table/src/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,UAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,QAAA;E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A;IAAA,OAAA,iBAAA,CAAA,iCAAA;EAAiC;AAAjC,CAAA;AACA,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,6BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,iBAAA,CAAA,2BAAA;EAA2B;AAA3B,CAAA;AACA,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,gCAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,iBAAA,CAAA,8BAAA;EAA8B;AAA9B,CAAA","sourcesContent":["export { useTable, useSelection, useSort } 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} 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"],"sourceRoot":"../src/"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-table",
3
- "version": "9.0.0-alpha.4",
3
+ "version": "9.0.0-alpha.5",
4
4
  "description": "React components for building web experiences",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -26,18 +26,18 @@
26
26
  "devDependencies": {
27
27
  "@fluentui/eslint-plugin": "*",
28
28
  "@fluentui/react-conformance": "*",
29
- "@fluentui/react-conformance-griffel": "9.0.0-beta.14",
29
+ "@fluentui/react-conformance-griffel": "9.0.0-beta.15",
30
30
  "@fluentui/scripts": "^1.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@fluentui/react-aria": "^9.2.1",
34
- "@fluentui/react-avatar": "^9.2.0",
35
- "@fluentui/react-checkbox": "^9.0.7",
33
+ "@fluentui/react-aria": "^9.2.2",
34
+ "@fluentui/react-avatar": "^9.2.1",
35
+ "@fluentui/react-checkbox": "^9.0.8",
36
36
  "@fluentui/react-icons": "^2.0.175",
37
- "@fluentui/react-tabster": "^9.1.2",
37
+ "@fluentui/react-tabster": "^9.1.3",
38
38
  "@fluentui/react-theme": "^9.1.0",
39
- "@fluentui/react-utilities": "^9.1.0",
40
- "@griffel/react": "^1.3.0",
39
+ "@fluentui/react-utilities": "^9.1.1",
40
+ "@griffel/react": "^1.4.0",
41
41
  "tslib": "^2.1.0"
42
42
  },
43
43
  "peerDependencies": {