@fluentui/react-table 9.0.0-alpha.1 → 9.0.0-alpha.2

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.
Files changed (195) hide show
  1. package/CHANGELOG.json +135 -4
  2. package/CHANGELOG.md +31 -5
  3. package/dist/index.d.ts +312 -21
  4. package/lib/TableCellActions.js +2 -0
  5. package/lib/TableCellActions.js.map +1 -0
  6. package/lib/TableCellLayout.js +2 -0
  7. package/lib/TableCellLayout.js.map +1 -0
  8. package/lib/TableCellPrimaryLayout.js +2 -0
  9. package/lib/TableCellPrimaryLayout.js.map +1 -0
  10. package/lib/TableSelectionCell.js +2 -0
  11. package/lib/TableSelectionCell.js.map +1 -0
  12. package/lib/components/Table/Table.types.js.map +1 -1
  13. package/lib/components/Table/useTableContextValues.js +7 -5
  14. package/lib/components/Table/useTableContextValues.js.map +1 -1
  15. package/lib/components/Table/useTableStyles.js +7 -2
  16. package/lib/components/Table/useTableStyles.js.map +1 -1
  17. package/lib/components/TableBody/useTableBody.js +3 -1
  18. package/lib/components/TableBody/useTableBody.js.map +1 -1
  19. package/lib/components/TableBody/useTableBodyStyles.js +12 -2
  20. package/lib/components/TableBody/useTableBodyStyles.js.map +1 -1
  21. package/lib/components/TableCell/TableCell.types.js.map +1 -1
  22. package/lib/components/TableCell/renderTableCell.js +2 -4
  23. package/lib/components/TableCell/renderTableCell.js.map +1 -1
  24. package/lib/components/TableCell/useTableCell.js +5 -5
  25. package/lib/components/TableCell/useTableCell.js.map +1 -1
  26. package/lib/components/TableCell/useTableCellStyles.js +6 -20
  27. package/lib/components/TableCell/useTableCellStyles.js.map +1 -1
  28. package/lib/components/TableCellActions/TableCellActions.js +15 -0
  29. package/lib/components/TableCellActions/TableCellActions.js.map +1 -0
  30. package/lib/components/TableCellActions/TableCellActions.types.js +2 -0
  31. package/lib/components/TableCellActions/TableCellActions.types.js.map +1 -0
  32. package/lib/components/TableCellActions/index.js +6 -0
  33. package/lib/components/TableCellActions/index.js.map +1 -0
  34. package/lib/components/TableCellActions/renderTableCellActions.js +16 -0
  35. package/lib/components/TableCellActions/renderTableCellActions.js.map +1 -0
  36. package/lib/components/TableCellActions/useTableCellActions.js +24 -0
  37. package/lib/components/TableCellActions/useTableCellActions.js.map +1 -0
  38. package/lib/components/TableCellActions/useTableCellActionsStyles.js +39 -0
  39. package/lib/components/TableCellActions/useTableCellActionsStyles.js.map +1 -0
  40. package/lib/components/TableCellLayout/TableCellLayout.js +15 -0
  41. package/lib/components/TableCellLayout/TableCellLayout.js.map +1 -0
  42. package/lib/components/TableCellLayout/TableCellLayout.types.js +2 -0
  43. package/lib/components/TableCellLayout/TableCellLayout.types.js.map +1 -0
  44. package/lib/components/TableCellLayout/index.js +6 -0
  45. package/lib/components/TableCellLayout/index.js.map +1 -0
  46. package/lib/components/TableCellLayout/renderTableCellLayout.js +19 -0
  47. package/lib/components/TableCellLayout/renderTableCellLayout.js.map +1 -0
  48. package/lib/components/TableCellLayout/useTableCellLayout.js +36 -0
  49. package/lib/components/TableCellLayout/useTableCellLayout.js.map +1 -0
  50. package/lib/components/TableCellLayout/useTableCellLayoutStyles.js +74 -0
  51. package/lib/components/TableCellLayout/useTableCellLayoutStyles.js.map +1 -0
  52. package/lib/components/TableHeader/useTableHeader.js +4 -2
  53. package/lib/components/TableHeader/useTableHeader.js.map +1 -1
  54. package/lib/components/TableHeader/useTableHeaderStyles.js +12 -2
  55. package/lib/components/TableHeader/useTableHeaderStyles.js.map +1 -1
  56. package/lib/components/TableHeaderCell/useTableHeaderCell.js +4 -2
  57. package/lib/components/TableHeaderCell/useTableHeaderCell.js.map +1 -1
  58. package/lib/components/TableHeaderCell/useTableHeaderCellStyles.js +10 -9
  59. package/lib/components/TableHeaderCell/useTableHeaderCellStyles.js.map +1 -1
  60. package/lib/components/TableRow/useTableRow.js +4 -2
  61. package/lib/components/TableRow/useTableRow.js.map +1 -1
  62. package/lib/components/TableRow/useTableRowStyles.js +9 -7
  63. package/lib/components/TableRow/useTableRowStyles.js.map +1 -1
  64. package/lib/components/TableSelectionCell/TableSelectionCell.js +15 -0
  65. package/lib/components/TableSelectionCell/TableSelectionCell.js.map +1 -0
  66. package/lib/components/TableSelectionCell/TableSelectionCell.types.js +2 -0
  67. package/lib/components/TableSelectionCell/TableSelectionCell.types.js.map +1 -0
  68. package/lib/components/TableSelectionCell/index.js +6 -0
  69. package/lib/components/TableSelectionCell/index.js.map +1 -0
  70. package/lib/components/TableSelectionCell/renderTableSelectionCell.js +17 -0
  71. package/lib/components/TableSelectionCell/renderTableSelectionCell.js.map +1 -0
  72. package/lib/components/TableSelectionCell/useTableSelectionCell.js +42 -0
  73. package/lib/components/TableSelectionCell/useTableSelectionCell.js.map +1 -0
  74. package/lib/components/TableSelectionCell/useTableSelectionCellStyles.js +55 -0
  75. package/lib/components/TableSelectionCell/useTableSelectionCellStyles.js.map +1 -0
  76. package/lib/contexts/tableContext.js +7 -3
  77. package/lib/contexts/tableContext.js.map +1 -1
  78. package/lib/hooks/index.js +3 -0
  79. package/lib/hooks/index.js.map +1 -0
  80. package/lib/hooks/selectionManager.js +89 -0
  81. package/lib/hooks/selectionManager.js.map +1 -0
  82. package/lib/hooks/types.js +2 -0
  83. package/lib/hooks/types.js.map +1 -0
  84. package/lib/hooks/useSelection.js +47 -0
  85. package/lib/hooks/useSelection.js.map +1 -0
  86. package/lib/hooks/useSort.js +72 -0
  87. package/lib/hooks/useSort.js.map +1 -0
  88. package/lib/hooks/useTable.js +87 -0
  89. package/lib/hooks/useTable.js.map +1 -0
  90. package/lib/index.js +4 -0
  91. package/lib/index.js.map +1 -1
  92. package/lib/navigationModes/cell.js +250 -0
  93. package/lib/navigationModes/cell.js.map +1 -0
  94. package/lib/navigationModes/composite.js +208 -0
  95. package/lib/navigationModes/composite.js.map +1 -0
  96. package/lib/navigationModes/index.js +3 -0
  97. package/lib/navigationModes/index.js.map +1 -0
  98. package/lib/navigationModes/useNavigationMode.js +42 -0
  99. package/lib/navigationModes/useNavigationMode.js.map +1 -0
  100. package/lib-commonjs/TableCellActions.js +10 -0
  101. package/lib-commonjs/TableCellActions.js.map +1 -0
  102. package/lib-commonjs/TableCellLayout.js +10 -0
  103. package/lib-commonjs/TableCellLayout.js.map +1 -0
  104. package/lib-commonjs/TableCellPrimaryLayout.js +10 -0
  105. package/lib-commonjs/TableCellPrimaryLayout.js.map +1 -0
  106. package/lib-commonjs/TableSelectionCell.js +10 -0
  107. package/lib-commonjs/TableSelectionCell.js.map +1 -0
  108. package/lib-commonjs/components/Table/useTableContextValues.js +8 -5
  109. package/lib-commonjs/components/Table/useTableContextValues.js.map +1 -1
  110. package/lib-commonjs/components/Table/useTableStyles.js +8 -2
  111. package/lib-commonjs/components/Table/useTableStyles.js.map +1 -1
  112. package/lib-commonjs/components/TableBody/useTableBody.js +3 -1
  113. package/lib-commonjs/components/TableBody/useTableBody.js.map +1 -1
  114. package/lib-commonjs/components/TableBody/useTableBodyStyles.js +10 -1
  115. package/lib-commonjs/components/TableBody/useTableBodyStyles.js.map +1 -1
  116. package/lib-commonjs/components/TableCell/renderTableCell.js +2 -4
  117. package/lib-commonjs/components/TableCell/renderTableCell.js.map +1 -1
  118. package/lib-commonjs/components/TableCell/useTableCell.js +4 -4
  119. package/lib-commonjs/components/TableCell/useTableCell.js.map +1 -1
  120. package/lib-commonjs/components/TableCell/useTableCellStyles.js +6 -20
  121. package/lib-commonjs/components/TableCell/useTableCellStyles.js.map +1 -1
  122. package/lib-commonjs/components/TableCellActions/TableCellActions.js +26 -0
  123. package/lib-commonjs/components/TableCellActions/TableCellActions.js.map +1 -0
  124. package/lib-commonjs/components/TableCellActions/TableCellActions.types.js +6 -0
  125. package/lib-commonjs/components/TableCellActions/TableCellActions.types.js.map +1 -0
  126. package/lib-commonjs/components/TableCellActions/index.js +18 -0
  127. package/lib-commonjs/components/TableCellActions/index.js.map +1 -0
  128. package/lib-commonjs/components/TableCellActions/renderTableCellActions.js +27 -0
  129. package/lib-commonjs/components/TableCellActions/renderTableCellActions.js.map +1 -0
  130. package/lib-commonjs/components/TableCellActions/useTableCellActions.js +35 -0
  131. package/lib-commonjs/components/TableCellActions/useTableCellActions.js.map +1 -0
  132. package/lib-commonjs/components/TableCellActions/useTableCellActionsStyles.js +51 -0
  133. package/lib-commonjs/components/TableCellActions/useTableCellActionsStyles.js.map +1 -0
  134. package/lib-commonjs/components/TableCellLayout/TableCellLayout.js +26 -0
  135. package/lib-commonjs/components/TableCellLayout/TableCellLayout.js.map +1 -0
  136. package/lib-commonjs/components/TableCellLayout/TableCellLayout.types.js +6 -0
  137. package/lib-commonjs/components/TableCellLayout/TableCellLayout.types.js.map +1 -0
  138. package/lib-commonjs/components/TableCellLayout/index.js +18 -0
  139. package/lib-commonjs/components/TableCellLayout/index.js.map +1 -0
  140. package/lib-commonjs/components/TableCellLayout/renderTableCellLayout.js +30 -0
  141. package/lib-commonjs/components/TableCellLayout/renderTableCellLayout.js.map +1 -0
  142. package/lib-commonjs/components/TableCellLayout/useTableCellLayout.js +46 -0
  143. package/lib-commonjs/components/TableCellLayout/useTableCellLayout.js.map +1 -0
  144. package/lib-commonjs/components/TableCellLayout/useTableCellLayoutStyles.js +85 -0
  145. package/lib-commonjs/components/TableCellLayout/useTableCellLayoutStyles.js.map +1 -0
  146. package/lib-commonjs/components/TableHeader/useTableHeader.js +4 -2
  147. package/lib-commonjs/components/TableHeader/useTableHeader.js.map +1 -1
  148. package/lib-commonjs/components/TableHeader/useTableHeaderStyles.js +11 -1
  149. package/lib-commonjs/components/TableHeader/useTableHeaderStyles.js.map +1 -1
  150. package/lib-commonjs/components/TableHeaderCell/useTableHeaderCell.js +4 -2
  151. package/lib-commonjs/components/TableHeaderCell/useTableHeaderCell.js.map +1 -1
  152. package/lib-commonjs/components/TableHeaderCell/useTableHeaderCellStyles.js +10 -9
  153. package/lib-commonjs/components/TableHeaderCell/useTableHeaderCellStyles.js.map +1 -1
  154. package/lib-commonjs/components/TableRow/useTableRow.js +4 -2
  155. package/lib-commonjs/components/TableRow/useTableRow.js.map +1 -1
  156. package/lib-commonjs/components/TableRow/useTableRowStyles.js +10 -7
  157. package/lib-commonjs/components/TableRow/useTableRowStyles.js.map +1 -1
  158. package/lib-commonjs/components/TableSelectionCell/TableSelectionCell.js +26 -0
  159. package/lib-commonjs/components/TableSelectionCell/TableSelectionCell.js.map +1 -0
  160. package/lib-commonjs/components/TableSelectionCell/TableSelectionCell.types.js +6 -0
  161. package/lib-commonjs/components/TableSelectionCell/TableSelectionCell.types.js.map +1 -0
  162. package/lib-commonjs/components/TableSelectionCell/index.js +18 -0
  163. package/lib-commonjs/components/TableSelectionCell/index.js.map +1 -0
  164. package/lib-commonjs/components/TableSelectionCell/renderTableSelectionCell.js +28 -0
  165. package/lib-commonjs/components/TableSelectionCell/renderTableSelectionCell.js.map +1 -0
  166. package/lib-commonjs/components/TableSelectionCell/useTableSelectionCell.js +56 -0
  167. package/lib-commonjs/components/TableSelectionCell/useTableSelectionCell.js.map +1 -0
  168. package/lib-commonjs/components/TableSelectionCell/useTableSelectionCellStyles.js +65 -0
  169. package/lib-commonjs/components/TableSelectionCell/useTableSelectionCellStyles.js.map +1 -0
  170. package/lib-commonjs/contexts/tableContext.js +7 -3
  171. package/lib-commonjs/contexts/tableContext.js.map +1 -1
  172. package/lib-commonjs/hooks/index.js +12 -0
  173. package/lib-commonjs/hooks/index.js.map +1 -0
  174. package/lib-commonjs/hooks/selectionManager.js +98 -0
  175. package/lib-commonjs/hooks/selectionManager.js.map +1 -0
  176. package/lib-commonjs/hooks/types.js +6 -0
  177. package/lib-commonjs/hooks/types.js.map +1 -0
  178. package/lib-commonjs/hooks/useSelection.js +59 -0
  179. package/lib-commonjs/hooks/useSelection.js.map +1 -0
  180. package/lib-commonjs/hooks/useSort.js +82 -0
  181. package/lib-commonjs/hooks/useSort.js.map +1 -0
  182. package/lib-commonjs/hooks/useTable.js +99 -0
  183. package/lib-commonjs/hooks/useTable.js.map +1 -0
  184. package/lib-commonjs/index.js +110 -1
  185. package/lib-commonjs/index.js.map +1 -1
  186. package/lib-commonjs/navigationModes/cell.js +259 -0
  187. package/lib-commonjs/navigationModes/cell.js.map +1 -0
  188. package/lib-commonjs/navigationModes/composite.js +217 -0
  189. package/lib-commonjs/navigationModes/composite.js.map +1 -0
  190. package/lib-commonjs/navigationModes/index.js +16 -0
  191. package/lib-commonjs/navigationModes/index.js.map +1 -0
  192. package/lib-commonjs/navigationModes/useNavigationMode.js +55 -0
  193. package/lib-commonjs/navigationModes/useNavigationMode.js.map +1 -0
  194. package/package.json +9 -9
  195. package/dist/tsdoc-metadata.json +0 -11
@@ -9,6 +9,8 @@ const react_1 = /*#__PURE__*/require("@griffel/react");
9
9
 
10
10
  const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
11
11
 
12
+ const useTableCellActionsStyles_1 = /*#__PURE__*/require("../TableCellActions/useTableCellActionsStyles");
13
+
12
14
  exports.tableRowClassName = 'fui-TableRow';
13
15
  exports.tableRowClassNames = {
14
16
  root: exports.tableRowClassName
@@ -19,29 +21,30 @@ exports.tableRowClassNames = {
19
21
 
20
22
  const useStyles = /*#__PURE__*/react_1.__styles({
21
23
  "root": {
22
- "mc9l5x": "f22iagw",
24
+ "mc9l5x": "f1u0rzck",
23
25
  "sj55zd": "f19n0e5",
24
- "Jwef8y": "f1knas48"
26
+ "Jwef8y": "f1knas48",
27
+ "Bpt6rm4": "f1uorfem"
25
28
  },
26
29
  "medium": {
27
- "sshi5w": "f5pgtk9",
30
+ "Bqenvij": "f1ft4266",
28
31
  "Bn0qgzm": "f1vxd6vx",
29
32
  "oivjwe": "fg706s2",
30
33
  "B9xav0g": "frpde29"
31
34
  },
32
35
  "small": {
33
- "sshi5w": "fcep9tg",
36
+ "Bqenvij": "fbsu25e",
34
37
  "Bn0qgzm": "f1vxd6vx",
35
38
  "oivjwe": "fg706s2",
36
39
  "B9xav0g": "frpde29"
37
40
  },
38
41
  "smaller": {
39
- "sshi5w": "f1pha7fy",
42
+ "Bqenvij": "frvgh55",
40
43
  "Be2twd7": "fy9rknc"
41
44
  }
42
45
  }, {
43
- "d": [".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".f5pgtk9{min-height:44px;}", ".f1vxd6vx{border-bottom-width:var(--strokeWidthThin);}", ".fg706s2{border-bottom-style:solid;}", ".frpde29{border-bottom-color:var(--colorNeutralStroke2);}", ".fcep9tg{min-height:34px;}", ".f1pha7fy{min-height:24px;}", ".fy9rknc{font-size:var(--fontSizeBase200);}"],
44
- "h": [".f1knas48:hover{background-color:var(--colorNeutralBackground1Hover);}"]
46
+ "d": [".f1u0rzck{display:table-row;}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".f1ft4266{height:44px;}", ".f1vxd6vx{border-bottom-width:var(--strokeWidthThin);}", ".fg706s2{border-bottom-style:solid;}", ".frpde29{border-bottom-color:var(--colorNeutralStroke2);}", ".fbsu25e{height:34px;}", ".frvgh55{height:24px;}", ".fy9rknc{font-size:var(--fontSizeBase200);}"],
47
+ "h": [".f1knas48:hover{background-color:var(--colorNeutralBackground1Hover);}", ".f1uorfem:hover .fui-TableCellActions{opacity:1;}"]
45
48
  });
46
49
  /**
47
50
  * Apply styling to the TableRow slots based on the state
@@ -1 +1 @@
1
- {"version":3,"sources":["components/TableRow/useTableRowStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAIa,OAAA,CAAA,iBAAA,GAAoB,cAApB;AACA,OAAA,CAAA,kBAAA,GAAoD;EAC/D,IAAI,EAAE,OAAA,CAAA;AADyD,CAApD;AAIb;;AAEG;;AACH,MAAM,SAAS,gBAAG,OAAA,SAAA;EAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;EAAA;AAAA,EAAlB;AAyBA;;AAEG;;;AACI,MAAM,0BAA0B,GAAI,KAAD,IAAwC;EAChF,MAAM,MAAM,GAAG,SAAS,EAAxB;EACA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,OAAA,CAAA,YAAA,CAAa,OAAA,CAAA,kBAAA,CAAmB,IAAhC,EAAsC,MAAM,CAAC,IAA7C,EAAmD,MAAM,CAAC,KAAK,CAAC,IAAP,CAAzD,EAAuE,KAAK,CAAC,IAAN,CAAW,SAAlF,CAAvB;EAEA,OAAO,KAAP;AACD,CALM;;AAAM,OAAA,CAAA,0BAAA,GAA0B,0BAA1B","sourcesContent":["import { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { TableRowSlots, TableRowState } from './TableRow.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const tableRowClassName = 'fui-TableRow';\nexport const tableRowClassNames: SlotClassNames<TableRowSlots> = {\n root: tableRowClassName,\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n display: 'flex',\n color: tokens.colorNeutralForeground1,\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground1Hover,\n },\n },\n\n medium: {\n minHeight: '44px',\n ...shorthands.borderBottom(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStroke2),\n },\n\n small: {\n minHeight: '34px',\n ...shorthands.borderBottom(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStroke2),\n },\n\n smaller: {\n minHeight: '24px',\n fontSize: tokens.fontSizeBase200,\n },\n});\n\n/**\n * Apply styling to the TableRow slots based on the state\n */\nexport const useTableRowStyles_unstable = (state: TableRowState): TableRowState => {\n const styles = useStyles();\n state.root.className = mergeClasses(tableRowClassNames.root, styles.root, styles[state.size], state.root.className);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["components/TableRow/useTableRowStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAGA,MAAA,2BAAA,gBAAA,OAAA,CAAA,+CAAA,CAAA;;AAEa,OAAA,CAAA,iBAAA,GAAoB,cAApB;AACA,OAAA,CAAA,kBAAA,GAAoD;EAC/D,IAAI,EAAE,OAAA,CAAA;AADyD,CAApD;AAIb;;AAEG;;AACH,MAAM,SAAS,gBAAG,OAAA,SAAA;EAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;EAAA;AAAA,EAAlB;AA4BA;;AAEG;;;AACI,MAAM,0BAA0B,GAAI,KAAD,IAAwC;EAChF,MAAM,MAAM,GAAG,SAAS,EAAxB;EACA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,OAAA,CAAA,YAAA,CAAa,OAAA,CAAA,kBAAA,CAAmB,IAAhC,EAAsC,MAAM,CAAC,IAA7C,EAAmD,MAAM,CAAC,KAAK,CAAC,IAAP,CAAzD,EAAuE,KAAK,CAAC,IAAN,CAAW,SAAlF,CAAvB;EAEA,OAAO,KAAP;AACD,CALM;;AAAM,OAAA,CAAA,0BAAA,GAA0B,0BAA1B","sourcesContent":["import { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { TableRowSlots, TableRowState } from './TableRow.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { tableCellActionsClassNames } from '../TableCellActions/useTableCellActionsStyles';\n\nexport const tableRowClassName = 'fui-TableRow';\nexport const tableRowClassNames: SlotClassNames<TableRowSlots> = {\n root: tableRowClassName,\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n display: 'table-row',\n color: tokens.colorNeutralForeground1,\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground1Hover,\n [`& .${tableCellActionsClassNames.root}`]: {\n opacity: 1,\n },\n },\n },\n\n medium: {\n height: '44px',\n ...shorthands.borderBottom(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStroke2),\n },\n\n small: {\n height: '34px',\n ...shorthands.borderBottom(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStroke2),\n },\n\n smaller: {\n height: '24px',\n fontSize: tokens.fontSizeBase200,\n },\n});\n\n/**\n * Apply styling to the TableRow slots based on the state\n */\nexport const useTableRowStyles_unstable = (state: TableRowState): TableRowState => {\n const styles = useStyles();\n state.root.className = mergeClasses(tableRowClassNames.root, styles.root, styles[state.size], state.root.className);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TableSelectionCell = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const useTableSelectionCell_1 = /*#__PURE__*/require("./useTableSelectionCell");
11
+
12
+ const renderTableSelectionCell_1 = /*#__PURE__*/require("./renderTableSelectionCell");
13
+
14
+ const useTableSelectionCellStyles_1 = /*#__PURE__*/require("./useTableSelectionCellStyles");
15
+ /**
16
+ * TableSelectionCell component - TODO: add more docs
17
+ */
18
+
19
+
20
+ exports.TableSelectionCell = /*#__PURE__*/React.forwardRef((props, ref) => {
21
+ const state = useTableSelectionCell_1.useTableSelectionCell_unstable(props, ref);
22
+ useTableSelectionCellStyles_1.useTableSelectionCellStyles_unstable(state);
23
+ return renderTableSelectionCell_1.renderTableSelectionCell_unstable(state);
24
+ });
25
+ exports.TableSelectionCell.displayName = 'TableSelectionCell';
26
+ //# sourceMappingURL=TableSelectionCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/TableSelectionCell/TableSelectionCell.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,0BAAA,gBAAA,OAAA,CAAA,4BAAA,CAAA;;AACA,MAAA,6BAAA,gBAAA,OAAA,CAAA,+BAAA,CAAA;AAIA;;AAEG;;;AACU,OAAA,CAAA,kBAAA,gBAAmE,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EAC9G,MAAM,KAAK,GAAG,uBAAA,CAAA,8BAAA,CAA+B,KAA/B,EAAsC,GAAtC,CAAd;EAEA,6BAAA,CAAA,oCAAA,CAAqC,KAArC;EACA,OAAO,0BAAA,CAAA,iCAAA,CAAkC,KAAlC,CAAP;AACD,CAL+E,CAAnE;AAOb,OAAA,CAAA,kBAAA,CAAmB,WAAnB,GAAiC,oBAAjC","sourcesContent":["import * as React from 'react';\nimport { useTableSelectionCell_unstable } from './useTableSelectionCell';\nimport { renderTableSelectionCell_unstable } from './renderTableSelectionCell';\nimport { useTableSelectionCellStyles_unstable } from './useTableSelectionCellStyles';\nimport type { TableSelectionCellProps } from './TableSelectionCell.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * TableSelectionCell component - TODO: add more docs\n */\nexport const TableSelectionCell: ForwardRefComponent<TableSelectionCellProps> = React.forwardRef((props, ref) => {\n const state = useTableSelectionCell_unstable(props, ref);\n\n useTableSelectionCellStyles_unstable(state);\n return renderTableSelectionCell_unstable(state);\n});\n\nTableSelectionCell.displayName = 'TableSelectionCell';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=TableSelectionCell.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./TableSelectionCell"), exports);
10
+
11
+ tslib_1.__exportStar(require("./TableSelectionCell.types"), exports);
12
+
13
+ tslib_1.__exportStar(require("./renderTableSelectionCell"), exports);
14
+
15
+ tslib_1.__exportStar(require("./useTableSelectionCell"), exports);
16
+
17
+ tslib_1.__exportStar(require("./useTableSelectionCellStyles"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/TableSelectionCell/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './TableSelectionCell';\nexport * from './TableSelectionCell.types';\nexport * from './renderTableSelectionCell';\nexport * from './useTableSelectionCell';\nexport * from './useTableSelectionCellStyles';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renderTableSelectionCell_unstable = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+ /**
12
+ * Render the final JSX of TableSelectionCell
13
+ */
14
+
15
+
16
+ const renderTableSelectionCell_unstable = state => {
17
+ const {
18
+ slots,
19
+ slotProps
20
+ } = react_utilities_1.getSlots(state);
21
+ return React.createElement(slots.root, { ...slotProps.root
22
+ }, state.type === 'checkbox' && slots.checkboxIndicator && React.createElement(slots.checkboxIndicator, { ...slotProps.checkboxIndicator
23
+ }), state.type === 'radio' && slots.radioIndicator && React.createElement(slots.radioIndicator, { ...slotProps.radioIndicator
24
+ }));
25
+ };
26
+
27
+ exports.renderTableSelectionCell_unstable = renderTableSelectionCell_unstable;
28
+ //# sourceMappingURL=renderTableSelectionCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/TableSelectionCell/renderTableSelectionCell.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,iCAAiC,GAAI,KAAD,IAAmC;EAClF,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,iBAAA,CAAA,QAAA,CAAkC,KAAlC,CAA7B;EAEA,OACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,KAAK,CAAC,IAAN,KAAe,UAAf,IAA6B,KAAK,CAAC,iBAAnC,IACC,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,iBAAP,EAAwB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAxB,CAFJ,EAIG,KAAK,CAAC,IAAN,KAAe,OAAf,IAA0B,KAAK,CAAC,cAAhC,IAAkD,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,cAAP,EAAqB,EAAA,GAAK,SAAS,CAAC;EAAf,CAArB,CAJrD,CADF;AAQD,CAXM;;AAAM,OAAA,CAAA,iCAAA,GAAiC,iCAAjC","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { TableSelectionCellState, TableSelectionCellSlots } from './TableSelectionCell.types';\n\n/**\n * Render the final JSX of TableSelectionCell\n */\nexport const renderTableSelectionCell_unstable = (state: TableSelectionCellState) => {\n const { slots, slotProps } = getSlots<TableSelectionCellSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n {state.type === 'checkbox' && slots.checkboxIndicator && (\n <slots.checkboxIndicator {...slotProps.checkboxIndicator} />\n )}\n {state.type === 'radio' && slots.radioIndicator && <slots.radioIndicator {...slotProps.radioIndicator} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useTableSelectionCell_unstable = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+
12
+ const react_checkbox_1 = /*#__PURE__*/require("@fluentui/react-checkbox");
13
+
14
+ const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
15
+
16
+ const useTableCell_1 = /*#__PURE__*/require("../TableCell/useTableCell");
17
+ /**
18
+ * Create the state required to render TableSelectionCell.
19
+ *
20
+ * The returned state can be modified with hooks such as useTableSelectionCellStyles_unstable,
21
+ * before being passed to renderTableSelectionCell_unstable.
22
+ *
23
+ * @param props - props from this instance of TableSelectionCell
24
+ * @param ref - reference to root HTMLElement of TableSelectionCell
25
+ */
26
+
27
+
28
+ const useTableSelectionCell_unstable = (props, ref) => {
29
+ var _a, _b;
30
+
31
+ const tableCellState = useTableCell_1.useTableCell_unstable(props, ref);
32
+ const type = (_a = props.type) !== null && _a !== void 0 ? _a : 'checkbox';
33
+ return { ...tableCellState,
34
+ components: { ...tableCellState.components,
35
+ checkboxIndicator: react_checkbox_1.Checkbox,
36
+ radioIndicator: 'span'
37
+ },
38
+ checkboxIndicator: react_utilities_1.resolveShorthand(props.checkboxIndicator, {
39
+ required: type === 'checkbox',
40
+ defaultProps: {
41
+ checked: props.checked
42
+ }
43
+ }),
44
+ radioIndicator: react_utilities_1.resolveShorthand(props.radioIndicator, {
45
+ required: type === 'radio',
46
+ defaultProps: {
47
+ children: React.createElement(react_icons_1.CheckmarkFilled, null)
48
+ }
49
+ }),
50
+ type,
51
+ checked: (_b = props.checked) !== null && _b !== void 0 ? _b : false
52
+ };
53
+ };
54
+
55
+ exports.useTableSelectionCell_unstable = useTableSelectionCell_unstable;
56
+ //# sourceMappingURL=useTableSelectionCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/TableSelectionCell/useTableSelectionCell.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,0BAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAEA,MAAA,cAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAEA;;;;;;;;AAQG;;;AACI,MAAM,8BAA8B,GAAG,CAC5C,KAD4C,EAE5C,GAF4C,KAGjB;;;EAC3B,MAAM,cAAc,GAAG,cAAA,CAAA,qBAAA,CAAsB,KAAtB,EAA6B,GAA7B,CAAvB;EACA,MAAM,IAAI,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,IAAN,MAAU,IAAV,IAAU,EAAA,KAAA,KAAA,CAAV,GAAU,EAAV,GAAc,UAA3B;EAEA,OAAO,EACL,GAAG,cADE;IAEL,UAAU,EAAE,EACV,GAAG,cAAc,CAAC,UADR;MAEV,iBAAiB,EAAE,gBAAA,CAAA,QAFT;MAGV,cAAc,EAAE;IAHN,CAFP;IAOL,iBAAiB,EAAE,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,iBAAvB,EAA0C;MAC3D,QAAQ,EAAE,IAAI,KAAK,UADwC;MAE3D,YAAY,EAAE;QAAE,OAAO,EAAE,KAAK,CAAC;MAAjB;IAF6C,CAA1C,CAPd;IAWL,cAAc,EAAE,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,cAAvB,EAAuC;MACrD,QAAQ,EAAE,IAAI,KAAK,OADkC;MAErD,YAAY,EAAE;QAAE,QAAQ,EAAE,KAAA,CAAA,aAAA,CAAC,aAAA,CAAA,eAAD,EAAgB,IAAhB;MAAZ;IAFuC,CAAvC,CAXX;IAeL,IAfK;IAgBL,OAAO,EAAE,CAAA,EAAA,GAAA,KAAK,CAAC,OAAN,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB;EAhBrB,CAAP;AAkBD,CAzBM;;AAAM,OAAA,CAAA,8BAAA,GAA8B,8BAA9B","sourcesContent":["import * as React from 'react';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { Checkbox } from '@fluentui/react-checkbox';\nimport { CheckmarkFilled } from '@fluentui/react-icons';\nimport type { TableSelectionCellProps, TableSelectionCellState } from './TableSelectionCell.types';\nimport { useTableCell_unstable } from '../TableCell/useTableCell';\n\n/**\n * Create the state required to render TableSelectionCell.\n *\n * The returned state can be modified with hooks such as useTableSelectionCellStyles_unstable,\n * before being passed to renderTableSelectionCell_unstable.\n *\n * @param props - props from this instance of TableSelectionCell\n * @param ref - reference to root HTMLElement of TableSelectionCell\n */\nexport const useTableSelectionCell_unstable = (\n props: TableSelectionCellProps,\n ref: React.Ref<HTMLElement>,\n): TableSelectionCellState => {\n const tableCellState = useTableCell_unstable(props, ref);\n const type = props.type ?? 'checkbox';\n\n return {\n ...tableCellState,\n components: {\n ...tableCellState.components,\n checkboxIndicator: Checkbox,\n radioIndicator: 'span',\n },\n checkboxIndicator: resolveShorthand(props.checkboxIndicator, {\n required: type === 'checkbox',\n defaultProps: { checked: props.checked },\n }),\n radioIndicator: resolveShorthand(props.radioIndicator, {\n required: type === 'radio',\n defaultProps: { children: <CheckmarkFilled /> },\n }),\n type,\n checked: props.checked ?? false,\n };\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useTableSelectionCellStyles_unstable = exports.tableSelectionCellClassNames = void 0;
7
+
8
+ const react_1 = /*#__PURE__*/require("@griffel/react");
9
+
10
+ exports.tableSelectionCellClassNames = {
11
+ root: 'fui-TableSelectionCell',
12
+ checkboxIndicator: 'fui-TableSelectionCell__checkboxIndicator',
13
+ radioIndicator: 'fui-TableSelectionCell__radioIndicator'
14
+ };
15
+ /**
16
+ * Styles for the root slot
17
+ */
18
+
19
+ const useStyles = /*#__PURE__*/react_1.__styles({
20
+ "root": {
21
+ "a9b677": "fksc0bp",
22
+ "fsow6f": "f17mccla",
23
+ "Huce71": "fz5stix",
24
+ "z8tnut": "f1g0x7ka",
25
+ "z189sj": ["fhxju0i", "f1cnd47f"],
26
+ "Byoj8tv": "f1qch9an",
27
+ "uwmqm3": ["f1cnd47f", "fhxju0i"],
28
+ "mc9l5x": "f15pt5es"
29
+ },
30
+ "radioIndicator": {
31
+ "mc9l5x": "f22iagw",
32
+ "Bh6795r": "fqerorx",
33
+ "Bt984gj": "f122n59",
34
+ "Brf1p80": "f4d9j23",
35
+ "B5pe6w7": "f1cqkysu",
36
+ "p4uzdd": "f1sgf1mg"
37
+ },
38
+ "hidden": {
39
+ "Bcdw1i0": "fd7fpy0"
40
+ }
41
+ }, {
42
+ "d": [".fksc0bp{width:44px;}", ".f17mccla{text-align:center;}", ".fz5stix{white-space:nowrap;}", ".f1g0x7ka{padding-top:0;}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f1qch9an{padding-bottom:0;}", ".f15pt5es{display:table-cell;}", ".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".fqerorx{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".f4d9j23{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;}", ".f1cqkysu svg{width:16px;}", ".f1sgf1mg svg{height:16px;}", ".fd7fpy0{visibility:hidden;}"]
43
+ });
44
+ /**
45
+ * Apply styling to the TableSelectionCell slots based on the state
46
+ */
47
+
48
+
49
+ const useTableSelectionCellStyles_unstable = state => {
50
+ const styles = useStyles();
51
+ state.root.className = react_1.mergeClasses(exports.tableSelectionCellClassNames.root, styles.root, state.root.className);
52
+
53
+ if (state.checkboxIndicator) {
54
+ state.checkboxIndicator.className = react_1.mergeClasses(exports.tableSelectionCellClassNames.checkboxIndicator, state.checkboxIndicator.className);
55
+ }
56
+
57
+ if (state.radioIndicator) {
58
+ state.radioIndicator.className = react_1.mergeClasses(exports.tableSelectionCellClassNames.radioIndicator, styles.radioIndicator, state.checked === false && styles.hidden, state.radioIndicator.className);
59
+ }
60
+
61
+ return state;
62
+ };
63
+
64
+ exports.useTableSelectionCellStyles_unstable = useTableSelectionCellStyles_unstable;
65
+ //# sourceMappingURL=useTableSelectionCellStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/TableSelectionCell/useTableSelectionCellStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAIa,OAAA,CAAA,4BAAA,GAAwE;EACnF,IAAI,EAAE,wBAD6E;EAEnF,iBAAiB,EAAE,2CAFgE;EAGnF,cAAc,EAAE;AAHmE,CAAxE;AAMb;;AAEG;;AACH,MAAM,SAAS,gBAAG,OAAA,SAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAAlB;AAyBA;;AAEG;;;AACI,MAAM,oCAAoC,GAAI,KAAD,IAA4D;EAC9G,MAAM,MAAM,GAAG,SAAS,EAAxB;EACA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,OAAA,CAAA,YAAA,CAAa,OAAA,CAAA,4BAAA,CAA6B,IAA1C,EAAgD,MAAM,CAAC,IAAvD,EAA6D,KAAK,CAAC,IAAN,CAAW,SAAxE,CAAvB;;EACA,IAAI,KAAK,CAAC,iBAAV,EAA6B;IAC3B,KAAK,CAAC,iBAAN,CAAwB,SAAxB,GAAoC,OAAA,CAAA,YAAA,CAClC,OAAA,CAAA,4BAAA,CAA6B,iBADK,EAElC,KAAK,CAAC,iBAAN,CAAwB,SAFU,CAApC;EAID;;EAED,IAAI,KAAK,CAAC,cAAV,EAA0B;IACxB,KAAK,CAAC,cAAN,CAAqB,SAArB,GAAiC,OAAA,CAAA,YAAA,CAC/B,OAAA,CAAA,4BAAA,CAA6B,cADE,EAE/B,MAAM,CAAC,cAFwB,EAG/B,KAAK,CAAC,OAAN,KAAkB,KAAlB,IAA2B,MAAM,CAAC,MAHH,EAI/B,KAAK,CAAC,cAAN,CAAqB,SAJU,CAAjC;EAMD;;EAED,OAAO,KAAP;AACD,CApBM;;AAAM,OAAA,CAAA,oCAAA,GAAoC,oCAApC","sourcesContent":["import { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { TableSelectionCellSlots, TableSelectionCellState } from './TableSelectionCell.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const tableSelectionCellClassNames: SlotClassNames<TableSelectionCellSlots> = {\n root: 'fui-TableSelectionCell',\n checkboxIndicator: 'fui-TableSelectionCell__checkboxIndicator',\n radioIndicator: 'fui-TableSelectionCell__radioIndicator',\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n width: '44px',\n textAlign: 'center',\n whiteSpace: 'nowrap',\n ...shorthands.padding(0),\n display: 'table-cell',\n },\n\n radioIndicator: {\n display: 'flex',\n flexGrow: 1,\n alignItems: 'center',\n justifyContent: 'center',\n '& svg': {\n width: '16px',\n height: '16px',\n },\n },\n\n hidden: {\n visibility: 'hidden',\n },\n});\n\n/**\n * Apply styling to the TableSelectionCell slots based on the state\n */\nexport const useTableSelectionCellStyles_unstable = (state: TableSelectionCellState): TableSelectionCellState => {\n const styles = useStyles();\n state.root.className = mergeClasses(tableSelectionCellClassNames.root, styles.root, state.root.className);\n if (state.checkboxIndicator) {\n state.checkboxIndicator.className = mergeClasses(\n tableSelectionCellClassNames.checkboxIndicator,\n state.checkboxIndicator.className,\n );\n }\n\n if (state.radioIndicator) {\n state.radioIndicator.className = mergeClasses(\n tableSelectionCellClassNames.radioIndicator,\n styles.radioIndicator,\n state.checked === false && styles.hidden,\n state.radioIndicator.className,\n );\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useTableContext = exports.TableContextProvider = exports.tableContextDefaultValue = void 0;
7
7
 
8
- const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
8
+ const React = /*#__PURE__*/require("react");
9
9
 
10
- const tableContext = /*#__PURE__*/react_context_selector_1.createContext(undefined);
10
+ const tableContext = /*#__PURE__*/React.createContext(undefined);
11
11
  exports.tableContextDefaultValue = {
12
12
  size: 'medium',
13
13
  noNativeElements: false,
@@ -15,7 +15,11 @@ exports.tableContextDefaultValue = {
15
15
  };
16
16
  exports.TableContextProvider = tableContext.Provider;
17
17
 
18
- const useTableContext = selector => react_context_selector_1.useContextSelector(tableContext, (ctx = exports.tableContextDefaultValue) => selector(ctx));
18
+ const useTableContext = () => {
19
+ var _a;
20
+
21
+ return (_a = React.useContext(tableContext)) !== null && _a !== void 0 ? _a : exports.tableContextDefaultValue;
22
+ };
19
23
 
20
24
  exports.useTableContext = useTableContext;
21
25
  //# sourceMappingURL=tableContext.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["contexts/tableContext.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AAGA,MAAM,YAAY,gBAAG,wBAAA,CAAA,aAAA,CAA6C,SAA7C,CAArB;AAEa,OAAA,CAAA,wBAAA,GAA8C;EACzD,IAAI,EAAE,QADmD;EAEzD,gBAAgB,EAAE,KAFuC;EAGzD,QAAQ,EAAE;AAH+C,CAA9C;AAMA,OAAA,CAAA,oBAAA,GAAuB,YAAY,CAAC,QAApC;;AACN,MAAM,eAAe,GAAO,QAAJ,IAC7B,wBAAA,CAAA,kBAAA,CAAmB,YAAnB,EAAiC,CAAC,GAAG,GAAG,OAAA,CAAA,wBAAP,KAAoC,QAAQ,CAAC,GAAD,CAA7E,CADK;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","sourcesContent":["import { createContext, useContextSelector, ContextSelector } from '@fluentui/react-context-selector';\nimport { TableContextValue } from '../components/Table/Table.types';\n\nconst tableContext = createContext<TableContextValue | undefined>(undefined);\n\nexport const tableContextDefaultValue: TableContextValue = {\n size: 'medium',\n noNativeElements: false,\n sortable: false,\n};\n\nexport const TableContextProvider = tableContext.Provider;\nexport const useTableContext = <T>(selector: ContextSelector<TableContextValue, T>) =>\n useContextSelector(tableContext, (ctx = tableContextDefaultValue) => selector(ctx));\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["contexts/tableContext.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAGA,MAAM,YAAY,gBAAG,KAAK,CAAC,aAAN,CAAmD,SAAnD,CAArB;AAEa,OAAA,CAAA,wBAAA,GAA8C;EACzD,IAAI,EAAE,QADmD;EAEzD,gBAAgB,EAAE,KAFuC;EAGzD,QAAQ,EAAE;AAH+C,CAA9C;AAMA,OAAA,CAAA,oBAAA,GAAuB,YAAY,CAAC,QAApC;;AACN,MAAM,eAAe,GAAG,MAAK;EAAA,IAAA,EAAA;;EAAC,OAAA,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,CAAiB,YAAjB,CAAA,MAA8B,IAA9B,IAA8B,EAAA,KAAA,KAAA,CAA9B,GAA8B,EAA9B,GAAkC,OAAA,CAAA,wBAAlC;AAA0D,CAAxF;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","sourcesContent":["import * as React from 'react';\nimport { TableContextValue } from '../components/Table/Table.types';\n\nconst tableContext = React.createContext<TableContextValue | undefined>(undefined);\n\nexport const tableContextDefaultValue: TableContextValue = {\n size: 'medium',\n noNativeElements: false,\n sortable: false,\n};\n\nexport const TableContextProvider = tableContext.Provider;\nexport const useTableContext = () => React.useContext(tableContext) ?? tableContextDefaultValue;\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./types"), exports);
10
+
11
+ tslib_1.__exportStar(require("./useTable"), exports);
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["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/"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSelectionManager = void 0;
7
+
8
+ function createSelectionManager(mode, onSelectionChange = () => undefined) {
9
+ const managerFactory = mode === 'multiselect' ? createMultipleSelectionManager : createSingleSelectionManager;
10
+ return managerFactory(onSelectionChange);
11
+ }
12
+
13
+ exports.createSelectionManager = createSelectionManager;
14
+
15
+ function createMultipleSelectionManager(onSelectionChange) {
16
+ const toggleAllItems = (itemIds, selectedItems) => {
17
+ const allItemsSelected = itemIds.every(itemId => selectedItems.has(itemId));
18
+
19
+ if (allItemsSelected) {
20
+ selectedItems.clear();
21
+ } else {
22
+ itemIds.forEach(itemId => selectedItems.add(itemId));
23
+ }
24
+
25
+ onSelectionChange(new Set(selectedItems));
26
+ };
27
+
28
+ const toggleItem = (itemId, selectedItems) => {
29
+ if (selectedItems.has(itemId)) {
30
+ selectedItems.delete(itemId);
31
+ } else {
32
+ selectedItems.add(itemId);
33
+ }
34
+
35
+ onSelectionChange(new Set(selectedItems));
36
+ };
37
+
38
+ const selectItem = (itemId, selectedItems) => {
39
+ selectedItems.add(itemId);
40
+ onSelectionChange(new Set(selectedItems));
41
+ };
42
+
43
+ const deselectItem = (itemId, selectedItems) => {
44
+ selectedItems.delete(itemId);
45
+ onSelectionChange(new Set(selectedItems));
46
+ };
47
+
48
+ const clearItems = () => {
49
+ onSelectionChange(new Set());
50
+ };
51
+
52
+ const isSelected = (itemId, selectedItems) => {
53
+ return selectedItems.has(itemId);
54
+ };
55
+
56
+ return {
57
+ toggleItem,
58
+ selectItem,
59
+ deselectItem,
60
+ clearItems,
61
+ isSelected,
62
+ toggleAllItems
63
+ };
64
+ }
65
+
66
+ function createSingleSelectionManager(onSelectionChange) {
67
+ const toggleItem = itemId => {
68
+ onSelectionChange(new Set([itemId]));
69
+ };
70
+
71
+ const clearItems = () => {
72
+ onSelectionChange(new Set());
73
+ };
74
+
75
+ const isSelected = (itemId, selectedItems) => {
76
+ return selectedItems.has(itemId);
77
+ };
78
+
79
+ const selectItem = itemId => {
80
+ onSelectionChange(new Set([itemId]));
81
+ };
82
+
83
+ return {
84
+ deselectItem: clearItems,
85
+ selectItem,
86
+ toggleAllItems: () => {
87
+ if (process.env.NODE_ENV !== 'production') {
88
+ throw new Error('[react-table]: `toggleAllItems` should not be used in single selection mode');
89
+ }
90
+
91
+ return undefined;
92
+ },
93
+ toggleItem,
94
+ clearItems,
95
+ isSelected
96
+ };
97
+ }
98
+ //# sourceMappingURL=selectionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["hooks/selectionManager.ts"],"names":[],"mappings":";;;;;;;AAeA,SAAgB,sBAAhB,CACE,IADF,EAEE,iBAAA,GAA+C,MAAM,SAFvD,EAEgE;EAE9D,MAAM,cAAc,GAAG,IAAI,KAAK,aAAT,GAAyB,8BAAzB,GAA0D,4BAAjF;EAEA,OAAO,cAAc,CAAC,iBAAD,CAArB;AACD;;AAPD,OAAA,CAAA,sBAAA,GAAA,sBAAA;;AASA,SAAS,8BAAT,CAAwC,iBAAxC,EAAoF;EAClF,MAAM,cAAc,GAAG,CAAC,OAAD,EAA6B,aAA7B,KAAoE;IACzF,MAAM,gBAAgB,GAAG,OAAO,CAAC,KAAR,CAAc,MAAM,IAAI,aAAa,CAAC,GAAd,CAAkB,MAAlB,CAAxB,CAAzB;;IAEA,IAAI,gBAAJ,EAAsB;MACpB,aAAa,CAAC,KAAd;IACD,CAFD,MAEO;MACL,OAAO,CAAC,OAAR,CAAgB,MAAM,IAAI,aAAa,CAAC,GAAd,CAAkB,MAAlB,CAA1B;IACD;;IAED,iBAAiB,CAAC,IAAI,GAAJ,CAAQ,aAAR,CAAD,CAAjB;EACD,CAVD;;EAYA,MAAM,UAAU,GAAG,CAAC,MAAD,EAA0B,aAA1B,KAAiE;IAClF,IAAI,aAAa,CAAC,GAAd,CAAkB,MAAlB,CAAJ,EAA+B;MAC7B,aAAa,CAAC,MAAd,CAAqB,MAArB;IACD,CAFD,MAEO;MACL,aAAa,CAAC,GAAd,CAAkB,MAAlB;IACD;;IAED,iBAAiB,CAAC,IAAI,GAAJ,CAAQ,aAAR,CAAD,CAAjB;EACD,CARD;;EAUA,MAAM,UAAU,GAAG,CAAC,MAAD,EAA0B,aAA1B,KAAiE;IAClF,aAAa,CAAC,GAAd,CAAkB,MAAlB;IACA,iBAAiB,CAAC,IAAI,GAAJ,CAAQ,aAAR,CAAD,CAAjB;EACD,CAHD;;EAKA,MAAM,YAAY,GAAG,CAAC,MAAD,EAA0B,aAA1B,KAAiE;IACpF,aAAa,CAAC,MAAd,CAAqB,MAArB;IACA,iBAAiB,CAAC,IAAI,GAAJ,CAAQ,aAAR,CAAD,CAAjB;EACD,CAHD;;EAKA,MAAM,UAAU,GAAG,MAAK;IACtB,iBAAiB,CAAC,IAAI,GAAJ,EAAD,CAAjB;EACD,CAFD;;EAIA,MAAM,UAAU,GAAG,CAAC,MAAD,EAA0B,aAA1B,KAAiE;IAClF,OAAO,aAAa,CAAC,GAAd,CAAkB,MAAlB,CAAP;EACD,CAFD;;EAIA,OAAO;IACL,UADK;IAEL,UAFK;IAGL,YAHK;IAIL,UAJK;IAKL,UALK;IAML;EANK,CAAP;AAQD;;AAED,SAAS,4BAAT,CAAsC,iBAAtC,EAAkF;EAChF,MAAM,UAAU,GAAI,MAAD,IAA4B;IAC7C,iBAAiB,CAAC,IAAI,GAAJ,CAAQ,CAAC,MAAD,CAAR,CAAD,CAAjB;EACD,CAFD;;EAIA,MAAM,UAAU,GAAG,MAAK;IACtB,iBAAiB,CAAC,IAAI,GAAJ,EAAD,CAAjB;EACD,CAFD;;EAIA,MAAM,UAAU,GAAG,CAAC,MAAD,EAA0B,aAA1B,KAAiE;IAClF,OAAO,aAAa,CAAC,GAAd,CAAkB,MAAlB,CAAP;EACD,CAFD;;EAIA,MAAM,UAAU,GAAI,MAAD,IAA4B;IAC7C,iBAAiB,CAAC,IAAI,GAAJ,CAAQ,CAAC,MAAD,CAAR,CAAD,CAAjB;EACD,CAFD;;EAIA,OAAO;IACL,YAAY,EAAE,UADT;IAEL,UAFK;IAGL,cAAc,EAAE,MAAK;MACnB,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;QACzC,MAAM,IAAI,KAAJ,CAAU,6EAAV,CAAN;MACD;;MAED,OAAO,SAAP;IACD,CATI;IAUL,UAVK;IAWL,UAXK;IAYL;EAZK,CAAP;AAcD","sourcesContent":["import { SelectionMode } from './types';\n\ntype OnSelectionChangeCallback = (selectedItems: Set<SelectionItemId>) => void;\n\nexport interface SelectionManager {\n toggleItem(id: SelectionItemId, selectedItems: Set<SelectionItemId>): void;\n selectItem(id: SelectionItemId, selectedItems: Set<SelectionItemId>): void;\n deselectItem(id: SelectionItemId, selectedItems: Set<SelectionItemId>): void;\n clearItems(): void;\n isSelected(id: SelectionItemId, selectedItems: Set<SelectionItemId>): boolean;\n toggleAllItems(itemIds: SelectionItemId[], selectedItems: Set<SelectionItemId>): void;\n}\n\nexport type SelectionItemId = string | number;\n\nexport function createSelectionManager(\n mode: SelectionMode,\n onSelectionChange: OnSelectionChangeCallback = () => undefined,\n): SelectionManager {\n const managerFactory = mode === 'multiselect' ? createMultipleSelectionManager : createSingleSelectionManager;\n\n return managerFactory(onSelectionChange);\n}\n\nfunction createMultipleSelectionManager(onSelectionChange: OnSelectionChangeCallback): SelectionManager {\n const toggleAllItems = (itemIds: SelectionItemId[], selectedItems: Set<SelectionItemId>) => {\n const allItemsSelected = itemIds.every(itemId => selectedItems.has(itemId));\n\n if (allItemsSelected) {\n selectedItems.clear();\n } else {\n itemIds.forEach(itemId => selectedItems.add(itemId));\n }\n\n onSelectionChange(new Set(selectedItems));\n };\n\n const toggleItem = (itemId: SelectionItemId, selectedItems: Set<SelectionItemId>) => {\n if (selectedItems.has(itemId)) {\n selectedItems.delete(itemId);\n } else {\n selectedItems.add(itemId);\n }\n\n onSelectionChange(new Set(selectedItems));\n };\n\n const selectItem = (itemId: SelectionItemId, selectedItems: Set<SelectionItemId>) => {\n selectedItems.add(itemId);\n onSelectionChange(new Set(selectedItems));\n };\n\n const deselectItem = (itemId: SelectionItemId, selectedItems: Set<SelectionItemId>) => {\n selectedItems.delete(itemId);\n onSelectionChange(new Set(selectedItems));\n };\n\n const clearItems = () => {\n onSelectionChange(new Set());\n };\n\n const isSelected = (itemId: SelectionItemId, selectedItems: Set<SelectionItemId>) => {\n return selectedItems.has(itemId);\n };\n\n return {\n toggleItem,\n selectItem,\n deselectItem,\n clearItems,\n isSelected,\n toggleAllItems,\n };\n}\n\nfunction createSingleSelectionManager(onSelectionChange: OnSelectionChangeCallback): SelectionManager {\n const toggleItem = (itemId: SelectionItemId) => {\n onSelectionChange(new Set([itemId]));\n };\n\n const clearItems = () => {\n onSelectionChange(new Set<SelectionItemId>());\n };\n\n const isSelected = (itemId: SelectionItemId, selectedItems: Set<SelectionItemId>) => {\n return selectedItems.has(itemId);\n };\n\n const selectItem = (itemId: SelectionItemId) => {\n onSelectionChange(new Set([itemId]));\n };\n\n return {\n deselectItem: clearItems,\n selectItem,\n toggleAllItems: () => {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('[react-table]: `toggleAllItems` should not be used in single selection mode');\n }\n\n return undefined;\n },\n toggleItem,\n clearItems,\n isSelected,\n };\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSelection = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+
12
+ const selectionManager_1 = /*#__PURE__*/require("./selectionManager");
13
+
14
+ function useSelection(options) {
15
+ const {
16
+ selectionMode,
17
+ items,
18
+ getRowId,
19
+ defaultSelectedItems,
20
+ selectedItems,
21
+ onSelectionChange
22
+ } = options;
23
+ const [selected, setSelected] = react_utilities_1.useControllableState({
24
+ initialState: new Set(),
25
+ defaultState: defaultSelectedItems,
26
+ state: selectedItems
27
+ });
28
+ const selectionManager = React.useMemo(() => {
29
+ return selectionManager_1.createSelectionManager(selectionMode, newSelectedItems => {
30
+ setSelected(() => {
31
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(newSelectedItems);
32
+ return newSelectedItems;
33
+ });
34
+ });
35
+ }, [onSelectionChange, selectionMode, setSelected]);
36
+ const toggleAllRows = react_utilities_1.useEventCallback(() => {
37
+ selectionManager.toggleAllItems(items.map((item, i) => getRowId(item, i)), selected);
38
+ });
39
+ const toggleRow = react_utilities_1.useEventCallback(rowId => selectionManager.toggleItem(rowId, selected));
40
+ const deselectRow = react_utilities_1.useEventCallback(rowId => selectionManager.deselectItem(rowId, selected));
41
+ const selectRow = react_utilities_1.useEventCallback(rowId => selectionManager.selectItem(rowId, selected));
42
+
43
+ const isRowSelected = rowId => selectionManager.isSelected(rowId, selected);
44
+
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
55
+ };
56
+ }
57
+
58
+ exports.useSelection = useSelection;
59
+ //# sourceMappingURL=useSelection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["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/"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSort = void 0;
7
+
8
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
9
+
10
+ function useSort(options) {
11
+ const {
12
+ columns,
13
+ sortState,
14
+ defaultSortState,
15
+ onSortChange
16
+ } = options;
17
+ const [sorted, setSorted] = react_utilities_1.useControllableState({
18
+ initialState: {
19
+ sortDirection: 'ascending',
20
+ sortColumn: undefined
21
+ },
22
+ defaultState: defaultSortState,
23
+ state: sortState
24
+ });
25
+ const {
26
+ sortColumn,
27
+ sortDirection
28
+ } = sorted;
29
+
30
+ const toggleColumnSort = columnId => {
31
+ setSorted(s => {
32
+ const newState = { ...s,
33
+ sortColumn: columnId
34
+ };
35
+
36
+ if (s.sortColumn === columnId) {
37
+ newState.sortDirection = s.sortDirection === 'ascending' ? 'descending' : 'ascending';
38
+ } else {
39
+ newState.sortDirection = 'ascending';
40
+ }
41
+
42
+ onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(newState);
43
+ return newState;
44
+ });
45
+ };
46
+
47
+ const setColumnSort = (nextSortColumn, nextSortDirection) => {
48
+ const newState = {
49
+ sortColumn: nextSortColumn,
50
+ sortDirection: nextSortDirection
51
+ };
52
+ onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(newState);
53
+ setSorted(newState);
54
+ };
55
+
56
+ const sort = items => items.slice().sort((a, b) => {
57
+ const sortColumnDef = columns.find(column => column.columnId === sortColumn);
58
+
59
+ if (!(sortColumnDef === null || sortColumnDef === void 0 ? void 0 : sortColumnDef.compare)) {
60
+ return 0;
61
+ }
62
+
63
+ const mod = sortDirection === 'ascending' ? 1 : -1;
64
+ return sortColumnDef.compare(a, b) * mod;
65
+ });
66
+
67
+ const getSortDirection = columnId => {
68
+ return sortColumn === columnId ? sortDirection : undefined;
69
+ };
70
+
71
+ return {
72
+ sortColumn,
73
+ sortDirection,
74
+ sort,
75
+ setColumnSort,
76
+ toggleColumnSort,
77
+ getSortDirection
78
+ };
79
+ }
80
+
81
+ exports.useSort = useSort;
82
+ //# sourceMappingURL=useSort.js.map