@fluentui/react-table 9.18.5 → 9.18.6

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 (85) hide show
  1. package/CHANGELOG.md +32 -11
  2. package/dist/index.d.ts +18 -19
  3. package/lib/components/DataGridBody/renderDataGridBody.js.map +1 -1
  4. package/lib/components/DataGridCell/renderDataGridCell.js.map +1 -1
  5. package/lib/components/DataGridHeader/renderDataGridHeader.js.map +1 -1
  6. package/lib/components/DataGridHeaderCell/renderDataGridHeaderCell.js.map +1 -1
  7. package/lib/components/DataGridRow/renderDataGridRow.js.map +1 -1
  8. package/lib/components/DataGridRow/useDataGridRow.js +1 -6
  9. package/lib/components/DataGridRow/useDataGridRow.js.map +1 -1
  10. package/lib/components/DataGridRow/useDataGridRowStyles.styles.js +3 -10
  11. package/lib/components/DataGridRow/useDataGridRowStyles.styles.js.map +1 -1
  12. package/lib/components/DataGridRow/useDataGridRowStyles.styles.raw.js +1 -18
  13. package/lib/components/DataGridRow/useDataGridRowStyles.styles.raw.js.map +1 -1
  14. package/lib/components/DataGridSelectionCell/renderDataGridSelectionCell.js.map +1 -1
  15. package/lib/components/DataGridSelectionCell/useDataGridSelectionCell.js +1 -0
  16. package/lib/components/DataGridSelectionCell/useDataGridSelectionCell.js.map +1 -1
  17. package/lib/components/Table/renderTable.js.map +1 -1
  18. package/lib/components/TableBody/renderTableBody.js.map +1 -1
  19. package/lib/components/TableCell/renderTableCell.js.map +1 -1
  20. package/lib/components/TableCellActions/renderTableCellActions.js.map +1 -1
  21. package/lib/components/TableCellLayout/renderTableCellLayout.js.map +1 -1
  22. package/lib/components/TableHeader/renderTableHeader.js.map +1 -1
  23. package/lib/components/TableHeaderCell/renderTableHeaderCell.js.map +1 -1
  24. package/lib/components/TableResizeHandle/renderTableResizeHandle.js.map +1 -1
  25. package/lib/components/TableRow/renderTableRow.js.map +1 -1
  26. package/lib/components/TableSelectionCell/renderTableSelectionCell.js.map +1 -1
  27. package/lib/contexts/columnIdContext.js.map +1 -1
  28. package/lib/contexts/dataGridContext.js.map +1 -1
  29. package/lib/contexts/rowIdContext.js.map +1 -1
  30. package/lib/contexts/tableContext.js.map +1 -1
  31. package/lib/contexts/tableHeaderContext.js.map +1 -1
  32. package/lib/hooks/createColumn.js +1 -0
  33. package/lib/hooks/createColumn.js.map +1 -1
  34. package/lib/hooks/useKeyboardResizing.js +1 -1
  35. package/lib/hooks/useKeyboardResizing.js.map +1 -1
  36. package/lib/hooks/useMeasureElement.js.map +1 -1
  37. package/lib/hooks/useTableColumnResizeMouseHandler.js.map +1 -1
  38. package/lib/hooks/useTableColumnSizing.js.map +1 -1
  39. package/lib/hooks/useTableSelection.js.map +1 -1
  40. package/lib/hooks/useTableSort.js.map +1 -1
  41. package/lib/utils/columnResizeUtils.js +10 -1
  42. package/lib/utils/columnResizeUtils.js.map +1 -1
  43. package/lib/utils/isColumnSortable.js.map +1 -1
  44. package/lib-commonjs/components/DataGridBody/renderDataGridBody.js.map +1 -1
  45. package/lib-commonjs/components/DataGridCell/renderDataGridCell.js.map +1 -1
  46. package/lib-commonjs/components/DataGridHeader/renderDataGridHeader.js.map +1 -1
  47. package/lib-commonjs/components/DataGridHeaderCell/renderDataGridHeaderCell.js.map +1 -1
  48. package/lib-commonjs/components/DataGridRow/renderDataGridRow.js.map +1 -1
  49. package/lib-commonjs/components/DataGridRow/useDataGridRow.js +1 -6
  50. package/lib-commonjs/components/DataGridRow/useDataGridRow.js.map +1 -1
  51. package/lib-commonjs/components/DataGridRow/useDataGridRowStyles.styles.js +1 -10
  52. package/lib-commonjs/components/DataGridRow/useDataGridRowStyles.styles.js.map +1 -1
  53. package/lib-commonjs/components/DataGridRow/useDataGridRowStyles.styles.raw.js +1 -18
  54. package/lib-commonjs/components/DataGridRow/useDataGridRowStyles.styles.raw.js.map +1 -1
  55. package/lib-commonjs/components/DataGridSelectionCell/renderDataGridSelectionCell.js.map +1 -1
  56. package/lib-commonjs/components/DataGridSelectionCell/useDataGridSelectionCell.js +1 -0
  57. package/lib-commonjs/components/DataGridSelectionCell/useDataGridSelectionCell.js.map +1 -1
  58. package/lib-commonjs/components/Table/renderTable.js.map +1 -1
  59. package/lib-commonjs/components/TableBody/renderTableBody.js.map +1 -1
  60. package/lib-commonjs/components/TableCell/renderTableCell.js.map +1 -1
  61. package/lib-commonjs/components/TableCellActions/renderTableCellActions.js.map +1 -1
  62. package/lib-commonjs/components/TableCellLayout/renderTableCellLayout.js.map +1 -1
  63. package/lib-commonjs/components/TableHeader/renderTableHeader.js.map +1 -1
  64. package/lib-commonjs/components/TableHeaderCell/renderTableHeaderCell.js.map +1 -1
  65. package/lib-commonjs/components/TableResizeHandle/renderTableResizeHandle.js.map +1 -1
  66. package/lib-commonjs/components/TableRow/renderTableRow.js.map +1 -1
  67. package/lib-commonjs/components/TableSelectionCell/renderTableSelectionCell.js.map +1 -1
  68. package/lib-commonjs/contexts/columnIdContext.js.map +1 -1
  69. package/lib-commonjs/contexts/dataGridContext.js.map +1 -1
  70. package/lib-commonjs/contexts/rowIdContext.js.map +1 -1
  71. package/lib-commonjs/contexts/tableContext.js.map +1 -1
  72. package/lib-commonjs/contexts/tableHeaderContext.js.map +1 -1
  73. package/lib-commonjs/hooks/createColumn.js +2 -0
  74. package/lib-commonjs/hooks/createColumn.js.map +1 -1
  75. package/lib-commonjs/hooks/useKeyboardResizing.js +1 -1
  76. package/lib-commonjs/hooks/useKeyboardResizing.js.map +1 -1
  77. package/lib-commonjs/hooks/useMeasureElement.js.map +1 -1
  78. package/lib-commonjs/hooks/useTableColumnResizeMouseHandler.js.map +1 -1
  79. package/lib-commonjs/hooks/useTableColumnSizing.js.map +1 -1
  80. package/lib-commonjs/hooks/useTableSelection.js.map +1 -1
  81. package/lib-commonjs/hooks/useTableSort.js.map +1 -1
  82. package/lib-commonjs/utils/columnResizeUtils.js +10 -1
  83. package/lib-commonjs/utils/columnResizeUtils.js.map +1 -1
  84. package/lib-commonjs/utils/isColumnSortable.js.map +1 -1
  85. package/package.json +14 -14
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DataGridRow/useDataGridRowStyles.styles.ts"],"sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nimport { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';\nimport type { DataGridRowSlots, DataGridRowState } from './DataGridRow.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { useTableRowStyles_unstable } from '../TableRow/useTableRowStyles.styles';\nimport { useIsInTableHeader } from '../../contexts/tableHeaderContext';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\nimport { tableSelectionCellClassNames } from '../TableSelectionCell/useTableSelectionCellStyles.styles';\n\nexport const dataGridRowClassNames: SlotClassNames<DataGridRowSlots> = {\n root: 'fui-DataGridRow',\n selectionCell: 'fui-DataGridRow__selectionCell',\n};\n\nconst useStyles = makeStyles({\n singleSelectHeader: {\n ...createCustomFocusIndicatorStyle(\n {\n [`& .${tableSelectionCellClassNames.root}`]: {\n opacity: 0,\n },\n },\n { selector: 'focus-within' },\n ),\n\n ':hover': {\n [`& .${tableSelectionCellClassNames.root}`]: {\n opacity: 0,\n },\n },\n },\n\n subtleSelection: {\n ...createCustomFocusIndicatorStyle(\n {\n [`& .${tableSelectionCellClassNames.root}`]: {\n opacity: 1,\n },\n },\n { selector: 'focus-within' },\n ),\n\n ':hover': {\n [`& .${tableSelectionCellClassNames.root}`]: {\n opacity: 1,\n },\n },\n },\n});\n\n/**\n * Apply styling to the DataGridRow slots based on the state\n */\nexport const useDataGridRowStyles_unstable = (state: DataGridRowState): DataGridRowState => {\n 'use no memo';\n\n const isHeader = useIsInTableHeader();\n const isSingleSelect = useDataGridContext_unstable(ctx => ctx.selection.selectionMode === 'single');\n const isSubtle = useDataGridContext_unstable(ctx => ctx.subtleSelection);\n const styles = useStyles();\n\n useTableRowStyles_unstable(state);\n state.root.className = mergeClasses(\n dataGridRowClassNames.root,\n state.root.className,\n isSubtle && styles.subtleSelection,\n isHeader && isSingleSelect && styles.singleSelectHeader,\n );\n if (state.selectionCell) {\n state.selectionCell.className = mergeClasses(dataGridRowClassNames.selectionCell, state.selectionCell.className);\n }\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","createCustomFocusIndicatorStyle","useTableRowStyles_unstable","useIsInTableHeader","useDataGridContext_unstable","tableSelectionCellClassNames","dataGridRowClassNames","root","selectionCell","useStyles","singleSelectHeader","opacity","selector","subtleSelection","useDataGridRowStyles_unstable","state","isHeader","isSingleSelect","ctx","selection","selectionMode","isSubtle","styles","className"],"mappings":";;;;;;;;;;;IASaO,qBAAAA;;;iCA4CAQ;eAAAA;;;uBArD4B,iBAAiB;8BACV,0BAA0B;yCAG/B,uCAAuC;oCAC/C,oCAAoC;iCAC3B,iCAAiC;mDAChC,2DAA2D;AAEjG,8BAAgE;IACrEP,MAAM;IACNC,eAAe;AACjB,EAAE;AAEF,MAAMC,gBAAYV,iBAAAA,EAAW;IAC3BW,oBAAoB;QAClB,OAAGT,6CAAAA,EACD;YACE,CAAC,CAAC,GAAG,EAAEI,+DAAAA,CAA6BE,IAAI,EAAE,CAAC,EAAE;gBAC3CI,SAAS;YACX;QACF,GACA;YAAEC,UAAU;QAAe,EAC5B;QAED,UAAU;YACR,CAAC,CAAC,GAAG,EAAEP,+DAAAA,CAA6BE,IAAI,EAAE,CAAC,EAAE;gBAC3CI,SAAS;YACX;QACF;IACF;IAEAE,iBAAiB;QACf,OAAGZ,6CAAAA,EACD;YACE,CAAC,CAAC,GAAG,EAAEI,+DAAAA,CAA6BE,IAAI,EAAE,CAAC,EAAE;gBAC3CI,SAAS;YACX;QACF,GACA;YAAEC,UAAU;QAAe,EAC5B;QAED,UAAU;YACR,CAAC,CAAC,GAAG,EAAEP,+DAAAA,CAA6BE,IAAI,EAAE,CAAC,EAAE;gBAC3CI,SAAS;YACX;QACF;IACF;AACF;AAKO,sCAAsC,CAACI;IAC5C;IAEA,MAAMC,eAAWb,sCAAAA;IACjB,MAAMc,qBAAiBb,4CAAAA,EAA4Bc,CAAAA,MAAOA,IAAIC,SAAS,CAACC,aAAa,KAAK;IAC1F,MAAMC,eAAWjB,4CAAAA,EAA4Bc,CAAAA,MAAOA,IAAIL,eAAe;IACvE,MAAMS,SAASb;QAEfP,mDAAAA,EAA2Ba;IAC3BA,MAAMR,IAAI,CAACgB,SAAS,OAAGvB,mBAAAA,EACrBM,sBAAsBC,IAAI,EAC1BQ,MAAMR,IAAI,CAACgB,SAAS,EACpBF,YAAYC,OAAOT,eAAe,EAClCG,YAAYC,kBAAkBK,OAAOZ,kBAAkB;IAEzD,IAAIK,MAAMP,aAAa,EAAE;QACvBO,MAAMP,aAAa,CAACe,SAAS,OAAGvB,mBAAAA,EAAaM,sBAAsBE,aAAa,EAAEO,MAAMP,aAAa,CAACe,SAAS;IACjH;IAEA,OAAOR;AACT,EAAE"}
1
+ {"version":3,"sources":["../src/components/DataGridRow/useDataGridRowStyles.styles.ts"],"sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nimport { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';\nimport type { DataGridRowSlots, DataGridRowState } from './DataGridRow.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { useTableRowStyles_unstable } from '../TableRow/useTableRowStyles.styles';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\nimport { tableSelectionCellClassNames } from '../TableSelectionCell/useTableSelectionCellStyles.styles';\n\nexport const dataGridRowClassNames: SlotClassNames<DataGridRowSlots> = {\n root: 'fui-DataGridRow',\n selectionCell: 'fui-DataGridRow__selectionCell',\n};\n\nconst useStyles = makeStyles({\n subtleSelection: {\n ...createCustomFocusIndicatorStyle(\n {\n [`& .${tableSelectionCellClassNames.root}`]: {\n opacity: 1,\n },\n },\n { selector: 'focus-within' },\n ),\n\n ':hover': {\n [`& .${tableSelectionCellClassNames.root}`]: {\n opacity: 1,\n },\n },\n },\n});\n\n/**\n * Apply styling to the DataGridRow slots based on the state\n */\nexport const useDataGridRowStyles_unstable = (state: DataGridRowState): DataGridRowState => {\n 'use no memo';\n\n const isSubtle = useDataGridContext_unstable(ctx => ctx.subtleSelection);\n const styles = useStyles();\n\n useTableRowStyles_unstable(state);\n state.root.className = mergeClasses(\n dataGridRowClassNames.root,\n state.root.className,\n isSubtle && styles.subtleSelection,\n );\n if (state.selectionCell) {\n state.selectionCell.className = mergeClasses(dataGridRowClassNames.selectionCell, state.selectionCell.className);\n }\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","createCustomFocusIndicatorStyle","useTableRowStyles_unstable","useDataGridContext_unstable","tableSelectionCellClassNames","dataGridRowClassNames","root","selectionCell","useStyles","subtleSelection","opacity","selector","useDataGridRowStyles_unstable","state","isSubtle","ctx","styles","className"],"mappings":";;;;;;;;;;;IAQaM,qBAAAA;;;IA2BAO,6BAAAA;;;;uBAnC4B,iBAAiB;8BACV,0BAA0B;yCAG/B,uCAAuC;iCACtC,iCAAiC;mDAChC,2DAA2D;AAEjG,8BAAgE;IACrEN,MAAM;IACNC,eAAe;AACjB,EAAE;AAEF,MAAMC,gBAAYT,iBAAAA,EAAW;IAC3BU,iBAAiB;QACf,OAAGR,6CAAAA,EACD;YACE,CAAC,CAAC,GAAG,EAAEG,+DAAAA,CAA6BE,IAAI,EAAE,CAAC,EAAE;gBAC3CI,SAAS;YACX;QACF,GACA;YAAEC,UAAU;QAAe,EAC5B;QAED,UAAU;YACR,CAAC,CAAC,GAAG,EAAEP,+DAAAA,CAA6BE,IAAI,EAAE,CAAC,EAAE;gBAC3CI,SAAS;YACX;QACF;IACF;AACF;AAKO,sCAAsC,CAACG;IAC5C;IAEA,MAAMC,eAAWX,4CAAAA,EAA4BY,CAAAA,MAAOA,IAAIN,eAAe;IACvE,MAAMO,SAASR;QAEfN,mDAAAA,EAA2BW;IAC3BA,MAAMP,IAAI,CAACW,SAAS,OAAGjB,mBAAAA,EACrBK,sBAAsBC,IAAI,EAC1BO,MAAMP,IAAI,CAACW,SAAS,EACpBH,YAAYE,OAAOP,eAAe;IAEpC,IAAII,MAAMN,aAAa,EAAE;QACvBM,MAAMN,aAAa,CAACU,SAAS,OAAGjB,mBAAAA,EAAaK,sBAAsBE,aAAa,EAAEM,MAAMN,aAAa,CAACU,SAAS;IACjH;IAEA,OAAOJ;AACT,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DataGridSelectionCell/renderDataGridSelectionCell.tsx"],"sourcesContent":["import type { DataGridSelectionCellState } from './DataGridSelectionCell.types';\nimport { renderTableSelectionCell_unstable } from '../TableSelectionCell/renderTableSelectionCell';\n\n/**\n * Render the final JSX of DataGridSelectionCell\n */\nexport const renderDataGridSelectionCell_unstable = (state: DataGridSelectionCellState) => {\n return renderTableSelectionCell_unstable(state);\n};\n"],"names":["renderTableSelectionCell_unstable","renderDataGridSelectionCell_unstable","state"],"mappings":";;;;;;;;;;0CACkD,iDAAiD;AAK5F,MAAMC,uCAAuC,CAACC;IACnD,WAAOF,2DAAAA,EAAkCE;AAC3C,EAAE"}
1
+ {"version":3,"sources":["../src/components/DataGridSelectionCell/renderDataGridSelectionCell.tsx"],"sourcesContent":["import type { JSXElement } from '@fluentui/react-utilities';\nimport type { DataGridSelectionCellState } from './DataGridSelectionCell.types';\nimport { renderTableSelectionCell_unstable } from '../TableSelectionCell/renderTableSelectionCell';\n\n/**\n * Render the final JSX of DataGridSelectionCell\n */\nexport const renderDataGridSelectionCell_unstable = (state: DataGridSelectionCellState): JSXElement => {\n return renderTableSelectionCell_unstable(state);\n};\n"],"names":["renderTableSelectionCell_unstable","renderDataGridSelectionCell_unstable","state"],"mappings":";;;;;;;;;;0CAEkD,iDAAiD;AAK5F,MAAMC,uCAAuC,CAACC;IACnD,WAAOF,2DAAAA,EAAkCE;AAC3C,EAAE"}
@@ -42,6 +42,7 @@ const useDataGridSelectionCell_unstable = (props, ref)=>{
42
42
  invisible: isHeader && type === 'radio',
43
43
  'aria-selected': checked === 'mixed' ? undefined : checked,
44
44
  subtle,
45
+ radioIndicator: isHeader ? null : undefined,
45
46
  ...props,
46
47
  onClick
47
48
  }, ref);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DataGridSelectionCell/useDataGridSelectionCell.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\nimport { useTableRowIdContext } from '../../contexts/rowIdContext';\nimport { useIsInTableHeader } from '../../contexts/tableHeaderContext';\nimport { useTableSelectionCell_unstable } from '../TableSelectionCell/useTableSelectionCell';\nimport type { DataGridSelectionCellProps, DataGridSelectionCellState } from './DataGridSelectionCell.types';\n\n/**\n * Create the state required to render DataGridSelectionCell.\n *\n * The returned state can be modified with hooks such as useDataGridSelectionCellStyles_unstable,\n * before being passed to renderDataGridSelectionCell_unstable.\n *\n * @param props - props from this instance of DataGridSelectionCell\n * @param ref - reference to root HTMLElement of DataGridSelectionCell\n */\nexport const useDataGridSelectionCell_unstable = (\n props: DataGridSelectionCellProps,\n ref: React.Ref<HTMLElement>,\n): DataGridSelectionCellState => {\n const isHeader = useIsInTableHeader();\n const rowId = useTableRowIdContext();\n const subtle = useDataGridContext_unstable(ctx => ctx.subtleSelection);\n const checked = useDataGridContext_unstable(ctx => {\n if (isHeader && ctx.selection.selectionMode === 'multiselect') {\n return ctx.selection.allRowsSelected ? true : ctx.selection.someRowsSelected ? 'mixed' : false;\n }\n\n return ctx.selection.isRowSelected(rowId);\n });\n\n const toggleAllRows = useDataGridContext_unstable(ctx => ctx.selection.toggleAllRows);\n const type = useDataGridContext_unstable(ctx =>\n ctx.selection.selectionMode === 'multiselect' ? 'checkbox' : 'radio',\n );\n\n const onClick = useEventCallback((e: React.MouseEvent<HTMLTableCellElement>) => {\n if (isHeader) {\n toggleAllRows(e);\n }\n\n props.onClick?.(e);\n });\n\n return useTableSelectionCell_unstable(\n {\n as: 'div',\n role: 'gridcell',\n checked,\n type,\n invisible: isHeader && type === 'radio',\n 'aria-selected': checked === 'mixed' ? undefined : checked,\n subtle,\n ...props,\n onClick,\n },\n ref,\n );\n};\n"],"names":["React","useEventCallback","useDataGridContext_unstable","useTableRowIdContext","useIsInTableHeader","useTableSelectionCell_unstable","useDataGridSelectionCell_unstable","props","ref","isHeader","rowId","subtle","ctx","subtleSelection","checked","selection","selectionMode","allRowsSelected","someRowsSelected","isRowSelected","toggleAllRows","type","onClick","e","as","role","invisible","undefined"],"mappings":";;;;+BAiBaM;;;;;;;iEAjBU,QAAQ;gCACE,4BAA4B;iCACjB,iCAAiC;8BACxC,8BAA8B;oCAChC,oCAAoC;uCACxB,8CAA8C;AAYtF,0CAA0C,CAC/CC,OACAC;IAEA,MAAMC,eAAWL,sCAAAA;IACjB,MAAMM,YAAQP,kCAAAA;IACd,MAAMQ,SAAST,gDAAAA,EAA4BU,CAAAA,MAAOA,IAAIC,eAAe;IACrE,MAAMC,cAAUZ,4CAAAA,EAA4BU,CAAAA;QAC1C,IAAIH,YAAYG,IAAIG,SAAS,CAACC,aAAa,KAAK,eAAe;YAC7D,OAAOJ,IAAIG,SAAS,CAACE,eAAe,GAAG,OAAOL,IAAIG,SAAS,CAACG,gBAAgB,GAAG,UAAU;QAC3F;QAEA,OAAON,IAAIG,SAAS,CAACI,aAAa,CAACT;IACrC;IAEA,MAAMU,oBAAgBlB,4CAAAA,EAA4BU,CAAAA,MAAOA,IAAIG,SAAS,CAACK,aAAa;IACpF,MAAMC,WAAOnB,4CAAAA,EAA4BU,CAAAA,MACvCA,IAAIG,SAAS,CAACC,aAAa,KAAK,gBAAgB,aAAa;IAG/D,MAAMM,cAAUrB,gCAAAA,EAAiB,CAACsB;YAKhChB;QAJA,IAAIE,UAAU;YACZW,cAAcG;QAChB;SAEAhB,iBAAAA,MAAMe,OAAAA,AAAO,MAAA,QAAbf,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAAA,IAAAA,CAAAA,OAAgBgB;IAClB;IAEA,WAAOlB,qDAAAA,EACL;QACEmB,IAAI;QACJC,MAAM;QACNX;QACAO;QACAK,WAAWjB,YAAYY,SAAS;QAChC,iBAAiBP,YAAY,UAAUa,YAAYb;QACnDH;QACA,GAAGJ,KAAK;QACRe;IACF,GACAd;AAEJ,EAAE"}
1
+ {"version":3,"sources":["../src/components/DataGridSelectionCell/useDataGridSelectionCell.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\nimport { useTableRowIdContext } from '../../contexts/rowIdContext';\nimport { useIsInTableHeader } from '../../contexts/tableHeaderContext';\nimport { useTableSelectionCell_unstable } from '../TableSelectionCell/useTableSelectionCell';\nimport type { DataGridSelectionCellProps, DataGridSelectionCellState } from './DataGridSelectionCell.types';\n\n/**\n * Create the state required to render DataGridSelectionCell.\n *\n * The returned state can be modified with hooks such as useDataGridSelectionCellStyles_unstable,\n * before being passed to renderDataGridSelectionCell_unstable.\n *\n * @param props - props from this instance of DataGridSelectionCell\n * @param ref - reference to root HTMLElement of DataGridSelectionCell\n */\nexport const useDataGridSelectionCell_unstable = (\n props: DataGridSelectionCellProps,\n ref: React.Ref<HTMLElement>,\n): DataGridSelectionCellState => {\n const isHeader = useIsInTableHeader();\n const rowId = useTableRowIdContext();\n const subtle = useDataGridContext_unstable(ctx => ctx.subtleSelection);\n const checked = useDataGridContext_unstable(ctx => {\n if (isHeader && ctx.selection.selectionMode === 'multiselect') {\n return ctx.selection.allRowsSelected ? true : ctx.selection.someRowsSelected ? 'mixed' : false;\n }\n\n return ctx.selection.isRowSelected(rowId);\n });\n\n const toggleAllRows = useDataGridContext_unstable(ctx => ctx.selection.toggleAllRows);\n const type = useDataGridContext_unstable(ctx =>\n ctx.selection.selectionMode === 'multiselect' ? 'checkbox' : 'radio',\n );\n\n const onClick = useEventCallback((e: React.MouseEvent<HTMLTableCellElement>) => {\n if (isHeader) {\n toggleAllRows(e);\n }\n\n props.onClick?.(e);\n });\n\n return useTableSelectionCell_unstable(\n {\n as: 'div',\n role: 'gridcell',\n checked,\n type,\n invisible: isHeader && type === 'radio',\n 'aria-selected': checked === 'mixed' ? undefined : checked,\n subtle,\n radioIndicator: isHeader ? null : undefined,\n ...props,\n onClick,\n },\n ref,\n );\n};\n"],"names":["React","useEventCallback","useDataGridContext_unstable","useTableRowIdContext","useIsInTableHeader","useTableSelectionCell_unstable","useDataGridSelectionCell_unstable","props","ref","isHeader","rowId","subtle","ctx","subtleSelection","checked","selection","selectionMode","allRowsSelected","someRowsSelected","isRowSelected","toggleAllRows","type","onClick","e","as","role","invisible","undefined","radioIndicator"],"mappings":";;;;+BAiBaM;;;;;;;iEAjBU,QAAQ;gCACE,4BAA4B;iCACjB,iCAAiC;8BACxC,8BAA8B;oCAChC,oCAAoC;uCACxB,8CAA8C;AAYtF,0CAA0C,CAC/CC,OACAC;IAEA,MAAMC,eAAWL,sCAAAA;IACjB,MAAMM,YAAQP,kCAAAA;IACd,MAAMQ,SAAST,gDAAAA,EAA4BU,CAAAA,MAAOA,IAAIC,eAAe;IACrE,MAAMC,cAAUZ,4CAAAA,EAA4BU,CAAAA;QAC1C,IAAIH,YAAYG,IAAIG,SAAS,CAACC,aAAa,KAAK,eAAe;YAC7D,OAAOJ,IAAIG,SAAS,CAACE,eAAe,GAAG,OAAOL,IAAIG,SAAS,CAACG,gBAAgB,GAAG,UAAU;QAC3F;QAEA,OAAON,IAAIG,SAAS,CAACI,aAAa,CAACT;IACrC;IAEA,MAAMU,oBAAgBlB,4CAAAA,EAA4BU,CAAAA,MAAOA,IAAIG,SAAS,CAACK,aAAa;IACpF,MAAMC,WAAOnB,4CAAAA,EAA4BU,CAAAA,MACvCA,IAAIG,SAAS,CAACC,aAAa,KAAK,gBAAgB,aAAa;IAG/D,MAAMM,cAAUrB,gCAAAA,EAAiB,CAACsB;YAKhChB;QAJA,IAAIE,UAAU;YACZW,cAAcG;QAChB;SAEAhB,iBAAAA,MAAMe,OAAAA,AAAO,MAAA,QAAbf,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAAA,IAAAA,CAAAA,OAAgBgB;IAClB;IAEA,WAAOlB,qDAAAA,EACL;QACEmB,IAAI;QACJC,MAAM;QACNX;QACAO;QACAK,WAAWjB,YAAYY,SAAS;QAChC,iBAAiBP,YAAY,UAAUa,YAAYb;QACnDH;QACAiB,gBAAgBnB,WAAW,OAAOkB;QAClC,GAAGpB,KAAK;QACRe;IACF,GACAd;AAEJ,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Table/renderTable.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { TableState, TableSlots, TableContextValues } from './Table.types';\nimport { TableContextProvider } from '../../contexts/tableContext';\n\n/**\n * Render the final JSX of Table\n */\nexport const renderTable_unstable = (state: TableState, contextValues: TableContextValues) => {\n assertSlots<TableSlots>(state);\n\n return (\n <TableContextProvider value={contextValues.table}>\n <state.root />\n </TableContextProvider>\n );\n};\n"],"names":["assertSlots","TableContextProvider","renderTable_unstable","state","contextValues","value","table","root"],"mappings":";;;;+BASaE;;;;;;4BARb,gDAAiD;gCACrB,4BAA4B;8BAEnB,8BAA8B;AAK5D,6BAA6B,CAACC,OAAmBC;QACtDJ,2BAAAA,EAAwBG;IAExB,OAAA,WAAA,OACE,eAAA,EAACF,kCAAAA,EAAAA;QAAqBI,OAAOD,cAAcE,KAAK;kBAC9C,WAAA,OAAA,eAAA,EAACH,MAAMI,IAAI,EAAA,CAAA;;AAGjB,EAAE"}
1
+ {"version":3,"sources":["../src/components/Table/renderTable.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TableState, TableSlots, TableContextValues } from './Table.types';\nimport { TableContextProvider } from '../../contexts/tableContext';\n\n/**\n * Render the final JSX of Table\n */\nexport const renderTable_unstable = (state: TableState, contextValues: TableContextValues): JSXElement => {\n assertSlots<TableSlots>(state);\n\n return (\n <TableContextProvider value={contextValues.table}>\n <state.root />\n </TableContextProvider>\n );\n};\n"],"names":["assertSlots","TableContextProvider","renderTable_unstable","state","contextValues","value","table","root"],"mappings":";;;;+BAUaE;;;;;;4BATb,gDAAiD;gCACrB,4BAA4B;8BAGnB,8BAA8B;AAK5D,6BAA6B,CAACC,OAAmBC;QACtDJ,2BAAAA,EAAwBG;IAExB,OAAA,WAAA,OACE,eAAA,EAACF,kCAAAA,EAAAA;QAAqBI,OAAOD,cAAcE,KAAK;kBAC9C,WAAA,OAAA,eAAA,EAACH,MAAMI,IAAI,EAAA,CAAA;;AAGjB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TableBody/renderTableBody.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { TableBodyState, TableBodySlots } from './TableBody.types';\n\n/**\n * Render the final JSX of TableBody\n */\nexport const renderTableBody_unstable = (state: TableBodyState) => {\n assertSlots<TableBodySlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableBody_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAMjD,MAAMC,2BAA2B,CAACC;QACvCF,2BAAAA,EAA4BE;IAE5B,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
1
+ {"version":3,"sources":["../src/components/TableBody/renderTableBody.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TableBodyState, TableBodySlots } from './TableBody.types';\n\n/**\n * Render the final JSX of TableBody\n */\nexport const renderTableBody_unstable = (state: TableBodyState): JSXElement => {\n assertSlots<TableBodySlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableBody_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAOjD,MAAMC,2BAA2B,CAACC;QACvCF,2BAAAA,EAA4BE;IAE5B,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TableCell/renderTableCell.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { TableCellState, TableCellSlots } from './TableCell.types';\n\n/**\n * Render the final JSX of TableCell\n */\nexport const renderTableCell_unstable = (state: TableCellState) => {\n assertSlots<TableCellSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableCell_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAMjD,MAAMC,2BAA2B,CAACC;QACvCF,2BAAAA,EAA4BE;IAE5B,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
1
+ {"version":3,"sources":["../src/components/TableCell/renderTableCell.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TableCellState, TableCellSlots } from './TableCell.types';\n\n/**\n * Render the final JSX of TableCell\n */\nexport const renderTableCell_unstable = (state: TableCellState): JSXElement => {\n assertSlots<TableCellSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableCell_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAOjD,MAAMC,2BAA2B,CAACC;QACvCF,2BAAAA,EAA4BE;IAE5B,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TableCellActions/renderTableCellActions.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { TableCellActionsState, TableCellActionsSlots } from './TableCellActions.types';\n\n/**\n * Render the final JSX of TableCellActions\n */\nexport const renderTableCellActions_unstable = (state: TableCellActionsState) => {\n assertSlots<TableCellActionsSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableCellActions_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAMjD,MAAMC,kCAAkC,CAACC;QAC9CF,2BAAAA,EAAmCE;IAEnC,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
1
+ {"version":3,"sources":["../src/components/TableCellActions/renderTableCellActions.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TableCellActionsState, TableCellActionsSlots } from './TableCellActions.types';\n\n/**\n * Render the final JSX of TableCellActions\n */\nexport const renderTableCellActions_unstable = (state: TableCellActionsState): JSXElement => {\n assertSlots<TableCellActionsSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableCellActions_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAOjD,MAAMC,kCAAkC,CAACC;QAC9CF,2BAAAA,EAAmCE;IAEnC,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TableCellLayout/renderTableCellLayout.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport { AvatarContextProvider } from '@fluentui/react-avatar';\nimport type { TableCellLayoutState, TableCellLayoutSlots, TableCellLayoutContextValues } from './TableCellLayout.types';\n\n/**\n * Render the final JSX of TableCellLayout\n */\nexport const renderTableCellLayout_unstable = (\n state: TableCellLayoutState,\n contextValues: TableCellLayoutContextValues,\n) => {\n assertSlots<TableCellLayoutSlots>(state);\n\n return (\n <state.root>\n {state.media && (\n <AvatarContextProvider value={contextValues.avatar}>\n <state.media />\n </AvatarContextProvider>\n )}\n\n {state.content && (\n <state.content>\n {state.main && <state.main>{state.root.children}</state.main>}\n {state.description && <state.description />}\n </state.content>\n )}\n </state.root>\n );\n};\n"],"names":["assertSlots","AvatarContextProvider","renderTableCellLayout_unstable","state","contextValues","root","media","value","avatar","content","main","children","description"],"mappings":";;;;+BASaE;;;;;;4BARb,iCAAiD;gCACrB,4BAA4B;6BAClB,yBAAyB;AAMxD,uCAAuC,CAC5CC,OACAC;QAEAJ,2BAAAA,EAAkCG;IAElC,OAAA,WAAA,OACE,gBAAA,EAACA,MAAME,IAAI,EAAA;;YACRF,MAAMG,KAAK,IAAA,WAAA,OACV,eAAA,EAACL,kCAAAA,EAAAA;gBAAsBM,OAAOH,cAAcI,MAAM;0BAChD,WAAA,OAAA,eAAA,EAACL,MAAMG,KAAK,EAAA,CAAA;;YAIfH,MAAMM,OAAO,IAAA,WAAA,OACZ,gBAAA,EAACN,MAAMM,OAAO,EAAA;;oBACXN,MAAMO,IAAI,IAAA,WAAA,OAAI,eAAA,EAACP,MAAMO,IAAI,EAAA;kCAAEP,MAAME,IAAI,CAACM,QAAQ;;oBAC9CR,MAAMS,WAAW,IAAA,WAAA,OAAI,eAAA,EAACT,MAAMS,WAAW,EAAA,CAAA;;;;;AAKlD,EAAE"}
1
+ {"version":3,"sources":["../src/components/TableCellLayout/renderTableCellLayout.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { AvatarContextProvider } from '@fluentui/react-avatar';\nimport type { TableCellLayoutState, TableCellLayoutSlots, TableCellLayoutContextValues } from './TableCellLayout.types';\n\n/**\n * Render the final JSX of TableCellLayout\n */\nexport const renderTableCellLayout_unstable = (\n state: TableCellLayoutState,\n contextValues: TableCellLayoutContextValues,\n): JSXElement => {\n assertSlots<TableCellLayoutSlots>(state);\n\n return (\n <state.root>\n {state.media && (\n <AvatarContextProvider value={contextValues.avatar}>\n <state.media />\n </AvatarContextProvider>\n )}\n\n {state.content && (\n <state.content>\n {state.main && <state.main>{state.root.children}</state.main>}\n {state.description && <state.description />}\n </state.content>\n )}\n </state.root>\n );\n};\n"],"names":["assertSlots","AvatarContextProvider","renderTableCellLayout_unstable","state","contextValues","root","media","value","avatar","content","main","children","description"],"mappings":";;;;+BAUaE;;;;;;4BATb,iCAAiD;gCACrB,4BAA4B;6BAElB,yBAAyB;AAMxD,uCAAuC,CAC5CC,OACAC;QAEAJ,2BAAAA,EAAkCG;IAElC,OAAA,WAAA,OACE,gBAAA,EAACA,MAAME,IAAI,EAAA;;YACRF,MAAMG,KAAK,IAAA,WAAA,OACV,eAAA,EAACL,kCAAAA,EAAAA;gBAAsBM,OAAOH,cAAcI,MAAM;0BAChD,WAAA,OAAA,eAAA,EAACL,MAAMG,KAAK,EAAA,CAAA;;YAIfH,MAAMM,OAAO,IAAA,WAAA,OACZ,gBAAA,EAACN,MAAMM,OAAO,EAAA;;oBACXN,MAAMO,IAAI,IAAA,WAAA,OAAI,eAAA,EAACP,MAAMO,IAAI,EAAA;kCAAEP,MAAME,IAAI,CAACM,QAAQ;;oBAC9CR,MAAMS,WAAW,IAAA,WAAA,OAAI,eAAA,EAACT,MAAMS,WAAW,EAAA,CAAA;;;;;AAKlD,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TableHeader/renderTableHeader.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport { TableHeaderContextProvider } from '../../contexts/tableHeaderContext';\nimport type { TableHeaderState, TableHeaderSlots } from './TableHeader.types';\n\n/**\n * Render the final JSX of TableHeader\n */\nexport const renderTableHeader_unstable = (state: TableHeaderState) => {\n assertSlots<TableHeaderSlots>(state);\n\n return (\n <TableHeaderContextProvider value=\"\">\n <state.root />\n </TableHeaderContextProvider>\n );\n};\n"],"names":["assertSlots","TableHeaderContextProvider","renderTableHeader_unstable","state","value","root"],"mappings":";;;;+BASaE;;;;;;4BARb,gDAAiD;gCACrB,4BAA4B;oCACb,oCAAoC;AAMxE,mCAAmC,CAACC;QACzCH,2BAAAA,EAA8BG;IAE9B,OAAA,WAAA,OACE,eAAA,EAACF,8CAAAA,EAAAA;QAA2BG,OAAM;kBAChC,WAAA,OAAA,eAAA,EAACD,MAAME,IAAI,EAAA,CAAA;;AAGjB,EAAE"}
1
+ {"version":3,"sources":["../src/components/TableHeader/renderTableHeader.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { TableHeaderContextProvider } from '../../contexts/tableHeaderContext';\nimport type { TableHeaderState, TableHeaderSlots } from './TableHeader.types';\n\n/**\n * Render the final JSX of TableHeader\n */\nexport const renderTableHeader_unstable = (state: TableHeaderState): JSXElement => {\n assertSlots<TableHeaderSlots>(state);\n\n return (\n <TableHeaderContextProvider value=\"\">\n <state.root />\n </TableHeaderContextProvider>\n );\n};\n"],"names":["assertSlots","TableHeaderContextProvider","renderTableHeader_unstable","state","value","root"],"mappings":";;;;+BAUaE;;;;;;4BATb,gDAAiD;gCACrB,4BAA4B;oCAEb,oCAAoC;AAMxE,mCAAmC,CAACC;QACzCH,2BAAAA,EAA8BG;IAE9B,OAAA,WAAA,OACE,eAAA,EAACF,8CAAAA,EAAAA;QAA2BG,OAAM;kBAChC,WAAA,OAAA,eAAA,EAACD,MAAME,IAAI,EAAA,CAAA;;AAGjB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TableHeaderCell/renderTableHeaderCell.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { TableHeaderCellState, TableHeaderCellSlots } from './TableHeaderCell.types';\n\n/**\n * Render the final JSX of TableHeaderCell\n */\nexport const renderTableHeaderCell_unstable = (state: TableHeaderCellState) => {\n assertSlots<TableHeaderCellSlots>(state);\n\n return (\n <state.root>\n <state.button>\n {state.root.children}\n {state.sortIcon && <state.sortIcon />}\n </state.button>\n {state.aside && <state.aside />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderTableHeaderCell_unstable","state","root","button","children","sortIcon","aside"],"mappings":";;;;+BAQaC;;;;;;4BAPb,iCAAiD;gCACrB,4BAA4B;AAMjD,uCAAuC,CAACC;QAC7CF,2BAAAA,EAAkCE;IAElC,OAAA,WAAA,OACE,gBAAA,EAACA,MAAMC,IAAI,EAAA;;8BACT,gBAAA,EAACD,MAAME,MAAM,EAAA;;oBACVF,MAAMC,IAAI,CAACE,QAAQ;oBACnBH,MAAMI,QAAQ,IAAA,WAAA,OAAI,eAAA,EAACJ,MAAMI,QAAQ,EAAA,CAAA;;;YAEnCJ,MAAMK,KAAK,IAAA,WAAA,OAAI,eAAA,EAACL,MAAMK,KAAK,EAAA,CAAA;;;AAGlC,EAAE"}
1
+ {"version":3,"sources":["../src/components/TableHeaderCell/renderTableHeaderCell.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TableHeaderCellState, TableHeaderCellSlots } from './TableHeaderCell.types';\n\n/**\n * Render the final JSX of TableHeaderCell\n */\nexport const renderTableHeaderCell_unstable = (state: TableHeaderCellState): JSXElement => {\n assertSlots<TableHeaderCellSlots>(state);\n\n return (\n <state.root>\n <state.button>\n {state.root.children}\n {state.sortIcon && <state.sortIcon />}\n </state.button>\n {state.aside && <state.aside />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderTableHeaderCell_unstable","state","root","button","children","sortIcon","aside"],"mappings":";;;;+BASaC;;;;;;4BARb,iCAAiD;gCACrB,4BAA4B;AAOjD,uCAAuC,CAACC;QAC7CF,2BAAAA,EAAkCE;IAElC,OAAA,WAAA,OACE,gBAAA,EAACA,MAAMC,IAAI,EAAA;;8BACT,gBAAA,EAACD,MAAME,MAAM,EAAA;;oBACVF,MAAMC,IAAI,CAACE,QAAQ;oBACnBH,MAAMI,QAAQ,IAAA,WAAA,OAAI,eAAA,EAACJ,MAAMI,QAAQ,EAAA,CAAA;;;YAEnCJ,MAAMK,KAAK,IAAA,WAAA,OAAI,eAAA,EAACL,MAAMK,KAAK,EAAA,CAAA;;;AAGlC,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TableResizeHandle/renderTableResizeHandle.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { TableResizeHandleState, TableResizeHandleSlots } from './TableResizeHandle.types';\n\n/**\n * Render the final JSX of TableResizeHandle\n */\nexport const renderTableResizeHandle_unstable = (state: TableResizeHandleState) => {\n assertSlots<TableResizeHandleSlots>(state);\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableResizeHandle_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAMjD,MAAMC,mCAAmC,CAACC;QAC/CF,2BAAAA,EAAoCE;IACpC,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
1
+ {"version":3,"sources":["../src/components/TableResizeHandle/renderTableResizeHandle.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TableResizeHandleState, TableResizeHandleSlots } from './TableResizeHandle.types';\n\n/**\n * Render the final JSX of TableResizeHandle\n */\nexport const renderTableResizeHandle_unstable = (state: TableResizeHandleState): JSXElement => {\n assertSlots<TableResizeHandleSlots>(state);\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableResizeHandle_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAOjD,MAAMC,mCAAmC,CAACC;QAC/CF,2BAAAA,EAAoCE;IACpC,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TableRow/renderTableRow.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { TableRowState, TableRowSlots } from './TableRow.types';\n\n/**\n * Render the final JSX of TableRow\n */\nexport const renderTableRow_unstable = (state: TableRowState) => {\n assertSlots<TableRowSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableRow_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAMjD,MAAMC,0BAA0B,CAACC;QACtCF,2BAAAA,EAA2BE;IAE3B,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
1
+ {"version":3,"sources":["../src/components/TableRow/renderTableRow.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TableRowState, TableRowSlots } from './TableRow.types';\n\n/**\n * Render the final JSX of TableRow\n */\nexport const renderTableRow_unstable = (state: TableRowState): JSXElement => {\n assertSlots<TableRowSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderTableRow_unstable","state","root"],"mappings":";;;;;;;;;;4BACA,gDAAiD;gCACrB,4BAA4B;AAOjD,MAAMC,0BAA0B,CAACC;QACtCF,2BAAAA,EAA2BE;IAE3B,OAAA,WAAA,OAAO,eAAA,EAACA,MAAMC,IAAI,EAAA,CAAA;AACpB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/TableSelectionCell/renderTableSelectionCell.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } 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 assertSlots<TableSelectionCellSlots>(state);\n\n return (\n <state.root>\n {state.type === 'checkbox' && state.checkboxIndicator && <state.checkboxIndicator />}\n\n {state.type === 'radio' && state.radioIndicator && <state.radioIndicator />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderTableSelectionCell_unstable","state","root","type","checkboxIndicator","radioIndicator"],"mappings":";;;;+BAQaC;;;;;;4BAPb,iCAAiD;gCACrB,4BAA4B;AAMjD,0CAA0C,CAACC;QAChDF,2BAAAA,EAAqCE;IAErC,OAAA,WAAA,OACE,gBAAA,EAACA,MAAMC,IAAI,EAAA;;YACRD,MAAME,IAAI,KAAK,cAAcF,MAAMG,iBAAiB,IAAA,WAAA,OAAI,eAAA,EAACH,MAAMG,iBAAiB,EAAA,CAAA;YAEhFH,MAAME,IAAI,KAAK,WAAWF,MAAMI,cAAc,IAAA,WAAA,OAAI,eAAA,EAACJ,MAAMI,cAAc,EAAA,CAAA;;;AAG9E,EAAE"}
1
+ {"version":3,"sources":["../src/components/TableSelectionCell/renderTableSelectionCell.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } 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): JSXElement => {\n assertSlots<TableSelectionCellSlots>(state);\n\n return (\n <state.root>\n {state.type === 'checkbox' && state.checkboxIndicator && <state.checkboxIndicator />}\n\n {state.type === 'radio' && state.radioIndicator && <state.radioIndicator />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderTableSelectionCell_unstable","state","root","type","checkboxIndicator","radioIndicator"],"mappings":";;;;+BASaC;;;;;;4BARb,iCAAiD;gCACrB,4BAA4B;AAOjD,0CAA0C,CAACC;QAChDF,2BAAAA,EAAqCE;IAErC,OAAA,WAAA,OACE,gBAAA,EAACA,MAAMC,IAAI,EAAA;;YACRD,MAAME,IAAI,KAAK,cAAcF,MAAMG,iBAAiB,IAAA,WAAA,OAAI,eAAA,EAACH,MAAMG,iBAAiB,EAAA,CAAA;YAEhFH,MAAME,IAAI,KAAK,WAAWF,MAAMI,cAAc,IAAA,WAAA,OAAI,eAAA,EAACJ,MAAMI,cAAc,EAAA,CAAA;;;AAG9E,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contexts/columnIdContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { TableColumnId } from '../hooks/';\n\nconst columnIdContext = React.createContext<TableColumnId | undefined>(undefined);\n\nexport const columnIdContextDefaultValue = '';\n\nexport const useColumnIdContext = () => React.useContext(columnIdContext) ?? columnIdContextDefaultValue;\n\nexport const ColumnIdContextProvider = columnIdContext.Provider;\n"],"names":["React","columnIdContext","createContext","undefined","columnIdContextDefaultValue","useColumnIdContext","useContext","ColumnIdContextProvider","Provider"],"mappings":";;;;;;;;;;;2BASaO;;;+BAJAH;;;sBAEAC;;;;;iEAPU,QAAQ;AAG/B,MAAMJ,gCAAkBD,OAAME,aAAa,CAA4BC;AAEhE,MAAMC,8BAA8B,GAAG;AAEvC,MAAMC,qBAAqB;QAAML;WAAAA,CAAAA,oBAAAA,OAAMM,UAAU,CAACL,gBAAAA,MAAAA,QAAjBD,sBAAAA,KAAAA,IAAAA,oBAAqCI;EAA4B;AAElG,MAAMG,0BAA0BN,gBAAgBO,QAAQ,CAAC"}
1
+ {"version":3,"sources":["../src/contexts/columnIdContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { TableColumnId } from '../hooks/';\n\nconst columnIdContext = React.createContext<TableColumnId | undefined>(undefined);\n\nexport const columnIdContextDefaultValue = '';\n\nexport const useColumnIdContext = (): TableColumnId => React.useContext(columnIdContext) ?? columnIdContextDefaultValue;\n\nexport const ColumnIdContextProvider = columnIdContext.Provider;\n"],"names":["React","columnIdContext","createContext","undefined","columnIdContextDefaultValue","useColumnIdContext","useContext","ColumnIdContextProvider","Provider"],"mappings":";;;;;;;;;;;2BASaO;;;+BAJAH;;;sBAEAC;;;;;iEAPU,QAAQ;AAG/B,MAAMJ,gCAAkBD,OAAME,aAAa,CAA4BC;AAEhE,MAAMC,8BAA8B,GAAG;AAEvC,MAAMC,qBAAqB;QAAqBL;WAAAA,CAAAA,oBAAAA,OAAMM,UAAU,CAACL,gBAAAA,MAAAA,QAAjBD,sBAAAA,KAAAA,IAAAA,oBAAqCI;EAA4B;AAEjH,MAAMG,0BAA0BN,gBAAgBO,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contexts/dataGridContext.ts"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { ContextSelector } from '@fluentui/react-context-selector';\nimport { TabsterDOMAttribute } from '@fluentui/react-tabster';\nimport { DataGridContextValue } from '../components/DataGrid/DataGrid.types';\nimport { defaultTableState } from '../hooks';\n\nconst dataGridContext = createContext<DataGridContextValue | undefined>(undefined);\n\nexport const dataGridContextDefaultValue: DataGridContextValue = {\n ...defaultTableState,\n subtleSelection: false,\n selectableRows: false,\n selectionAppearance: 'brand',\n focusMode: 'none',\n compositeRowTabsterAttribute: {} as TabsterDOMAttribute,\n};\n\nexport const DataGridContextProvider = dataGridContext.Provider;\n\nexport const useDataGridContext_unstable = <T>(selector: ContextSelector<DataGridContextValue, T>) =>\n useContextSelector(dataGridContext, (ctx = dataGridContextDefaultValue) => selector(ctx));\n"],"names":["createContext","useContextSelector","defaultTableState","dataGridContext","undefined","dataGridContextDefaultValue","subtleSelection","selectableRows","selectionAppearance","focusMode","compositeRowTabsterAttribute","DataGridContextProvider","Provider","useDataGridContext_unstable","selector","ctx"],"mappings":";;;;;;;;;;;2BAiBaW;;;+BATAN;;;+BAWAQ;;;;sCAnBqC,mCAAmC;uBAInD,WAAW;AAE7C,MAAMV,sBAAkBH,mCAAAA,EAAgDI;AAEjE,MAAMC,8BAAoD;IAC/D,GAAGH,wBAAiB;IACpBI,iBAAiB;IACjBC,gBAAgB;IAChBC,qBAAqB;IACrBC,WAAW;IACXC,8BAA8B,CAAC;AACjC,EAAE;AAEK,MAAMC,0BAA0BR,gBAAgBS,QAAQ,CAAC;AAEzD,MAAMC,8BAA8B,CAAIC,eAC7Cb,wCAAAA,EAAmBE,iBAAiB,CAACY,MAAMV,2BAA2B,GAAKS,SAASC,MAAM"}
1
+ {"version":3,"sources":["../src/contexts/dataGridContext.ts"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { ContextSelector } from '@fluentui/react-context-selector';\nimport { TabsterDOMAttribute } from '@fluentui/react-tabster';\nimport { DataGridContextValue } from '../components/DataGrid/DataGrid.types';\nimport { defaultTableState } from '../hooks';\n\nconst dataGridContext = createContext<DataGridContextValue | undefined>(undefined);\n\nexport const dataGridContextDefaultValue: DataGridContextValue = {\n ...defaultTableState,\n subtleSelection: false,\n selectableRows: false,\n selectionAppearance: 'brand',\n focusMode: 'none',\n compositeRowTabsterAttribute: {} as TabsterDOMAttribute,\n};\n\nexport const DataGridContextProvider = dataGridContext.Provider;\n\nexport const useDataGridContext_unstable = <T>(selector: ContextSelector<DataGridContextValue, T>): T =>\n useContextSelector(dataGridContext, (ctx = dataGridContextDefaultValue) => selector(ctx));\n"],"names":["createContext","useContextSelector","defaultTableState","dataGridContext","undefined","dataGridContextDefaultValue","subtleSelection","selectableRows","selectionAppearance","focusMode","compositeRowTabsterAttribute","DataGridContextProvider","Provider","useDataGridContext_unstable","selector","ctx"],"mappings":";;;;;;;;;;;2BAiBaW;;;+BATAN;;;+BAWAQ;;;;sCAnBqC,mCAAmC;uBAInD,WAAW;AAE7C,MAAMV,sBAAkBH,mCAAAA,EAAgDI;AAEjE,MAAMC,8BAAoD;IAC/D,GAAGH,wBAAiB;IACpBI,iBAAiB;IACjBC,gBAAgB;IAChBC,qBAAqB;IACrBC,WAAW;IACXC,8BAA8B,CAAC;AACjC,EAAE;AAEK,MAAMC,0BAA0BR,gBAAgBS,QAAQ,CAAC;AAEzD,MAAMC,8BAA8B,CAAIC,eAC7Cb,wCAAAA,EAAmBE,iBAAiB,CAACY,MAAMV,2BAA2B,GAAKS,SAASC,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contexts/rowIdContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { TableRowId } from '../hooks/';\n\nconst rowIdContext = React.createContext<TableRowId | undefined>(undefined);\n\nexport const tableRowIdContextDefaultValue = '';\n\nexport const useTableRowIdContext = () => React.useContext(rowIdContext) ?? tableRowIdContextDefaultValue;\n\nexport const TableRowIdContextProvider = rowIdContext.Provider;\n"],"names":["React","rowIdContext","createContext","undefined","tableRowIdContextDefaultValue","useTableRowIdContext","useContext","TableRowIdContextProvider","Provider"],"mappings":";;;;;;;;;;;6BASaO;;;iCAJAH;;;wBAEAC;;;;;iEAPU,QAAQ;AAG/B,MAAMJ,6BAAeD,OAAME,aAAa,CAAyBC;AAE1D,MAAMC,gCAAgC,GAAG;AAEzC,MAAMC,uBAAuB;QAAML;WAAAA,CAAAA,oBAAAA,OAAMM,UAAU,CAACL,aAAAA,MAAAA,QAAjBD,sBAAAA,KAAAA,IAAAA,oBAAkCI;EAA8B;AAEnG,MAAMG,4BAA4BN,aAAaO,QAAQ,CAAC"}
1
+ {"version":3,"sources":["../src/contexts/rowIdContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { TableRowId } from '../hooks/';\n\nconst rowIdContext = React.createContext<TableRowId | undefined>(undefined);\n\nexport const tableRowIdContextDefaultValue = '';\n\nexport const useTableRowIdContext = (): TableRowId => React.useContext(rowIdContext) ?? tableRowIdContextDefaultValue;\n\nexport const TableRowIdContextProvider = rowIdContext.Provider;\n"],"names":["React","rowIdContext","createContext","undefined","tableRowIdContextDefaultValue","useTableRowIdContext","useContext","TableRowIdContextProvider","Provider"],"mappings":";;;;;;;;;;;6BASaO;;;iCAJAH;;;wBAEAC;;;;;iEAPU,QAAQ;AAG/B,MAAMJ,6BAAeD,OAAME,aAAa,CAAyBC;AAE1D,MAAMC,gCAAgC,GAAG;AAEzC,MAAMC,uBAAuB;QAAkBL;WAAAA,CAAAA,oBAAAA,OAAMM,UAAU,CAACL,aAAAA,MAAAA,QAAjBD,sBAAAA,KAAAA,IAAAA,oBAAkCI;EAA8B;AAE/G,MAAMG,4BAA4BN,aAAaO,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contexts/tableContext.ts"],"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"],"names":["React","tableContext","createContext","undefined","tableContextDefaultValue","size","noNativeElements","sortable","TableContextProvider","Provider","useTableContext","useContext"],"mappings":";;;;;;;;;;;wBAWaQ;;;4BANAJ;;;mBAOAM;;;;;iEAZU,QAAQ;AAG/B,MAAMT,6BAAeD,OAAME,aAAa,CAAgCC;AAEjE,MAAMC,2BAA8C;IACzDC,MAAM;IACNC,kBAAkB;IAClBC,UAAU;AACZ,EAAE;AAEK,MAAMC,uBAAuBP,aAAaQ,QAAQ,CAAC;AACnD,MAAMC,kBAAkB;QAAMV;WAAAA,CAAAA,oBAAAA,OAAMW,UAAU,CAACV,aAAAA,MAAAA,QAAjBD,sBAAAA,KAAAA,IAAAA,oBAAkCI;EAAyB"}
1
+ {"version":3,"sources":["../src/contexts/tableContext.ts"],"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 = (): TableContextValue => React.useContext(tableContext) ?? tableContextDefaultValue;\n"],"names":["React","tableContext","createContext","undefined","tableContextDefaultValue","size","noNativeElements","sortable","TableContextProvider","Provider","useTableContext","useContext"],"mappings":";;;;;;;;;;;wBAWaQ;;;4BANAJ;;;mBAOAM;;;;;iEAZU,QAAQ;AAG/B,MAAMT,6BAAeD,OAAME,aAAa,CAAgCC;AAEjE,MAAMC,2BAA8C;IACzDC,MAAM;IACNC,kBAAkB;IAClBC,UAAU;AACZ,EAAE;AAEK,MAAMC,uBAAuBP,aAAaQ,QAAQ,CAAC;AACnD,MAAMC,kBAAkB;QAAyBV;WAAAA,CAAAA,oBAAAA,OAAMW,UAAU,CAACV,aAAAA,MAAAA,QAAjBD,sBAAAA,KAAAA,IAAAA,oBAAkCI;EAAyB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contexts/tableHeaderContext.ts"],"sourcesContent":["import * as React from 'react';\n\nconst tableHeaderContext = React.createContext<string | undefined>(undefined);\n\nconst tableHeaderContextDefaultValue = '';\n\nexport const TableHeaderContextProvider = tableHeaderContext.Provider;\nexport const useIsInTableHeader = () => React.useContext(tableHeaderContext) === tableHeaderContextDefaultValue;\n"],"names":["React","tableHeaderContext","createContext","undefined","tableHeaderContextDefaultValue","TableHeaderContextProvider","Provider","useIsInTableHeader","useContext"],"mappings":";;;;;;;;;;;8BAMaK;;;sBACAE;;;;;iEAPU,QAAQ;AAE/B,MAAMN,mCAAqBD,OAAME,aAAa,CAAqBC;AAEnE,MAAMC,iCAAiC;AAEhC,MAAMC,6BAA6BJ,mBAAmBK,QAAQ,CAAC;AAC/D,MAAMC,qBAAqB,IAAMP,OAAMQ,UAAU,CAACP,wBAAwBG,+BAA+B"}
1
+ {"version":3,"sources":["../src/contexts/tableHeaderContext.ts"],"sourcesContent":["import * as React from 'react';\n\nconst tableHeaderContext = React.createContext<string | undefined>(undefined);\n\nconst tableHeaderContextDefaultValue = '';\n\nexport const TableHeaderContextProvider = tableHeaderContext.Provider;\nexport const useIsInTableHeader = (): boolean =>\n React.useContext(tableHeaderContext) === tableHeaderContextDefaultValue;\n"],"names":["React","tableHeaderContext","createContext","undefined","tableHeaderContextDefaultValue","TableHeaderContextProvider","Provider","useIsInTableHeader","useContext"],"mappings":";;;;;;;;;;;8BAMaK;;;sBACAE;;;;;iEAPU,QAAQ;AAE/B,MAAMN,mCAAqBD,OAAME,aAAa,CAAqBC;AAEnE,MAAMC,iCAAiC;AAEhC,MAAMC,6BAA6BJ,mBAAmBK,QAAQ,CAAC;AAC/D,MAAMC,qBAAqB,IAChCP,OAAMQ,UAAU,CAACP,wBAAwBG,+BAA+B"}
@@ -8,6 +8,8 @@ Object.defineProperty(exports, "createTableColumn", {
8
8
  return createTableColumn;
9
9
  }
10
10
  });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
11
13
  const defaultCompare = ()=>0;
12
14
  const defaultRenderCell = ()=>{
13
15
  if (process.env.NODE_ENV !== 'production') {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/createColumn.ts"],"sourcesContent":["import { CreateTableColumnOptions } from './types';\n\nconst defaultCompare = () => 0;\n\nconst defaultRenderCell = () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('@fluentui/react-table: You are using the default column renderCell function that renders null');\n }\n\n return null;\n};\n\nconst defaultRenderHeaderCell = () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('@fluentui/react-table: You are using the default column renderHeaderCell function that renders null');\n }\n\n return null;\n};\n\n/**\n * Helper function to create column definition with defaults\n * @param options - column definition options\n * @returns - column definition with defaults\n */\nexport function createTableColumn<TItem>(options: CreateTableColumnOptions<TItem>) {\n const {\n columnId,\n renderCell = defaultRenderCell,\n renderHeaderCell = defaultRenderHeaderCell,\n compare = defaultCompare,\n } = options;\n\n return {\n columnId,\n renderCell,\n renderHeaderCell,\n compare,\n };\n}\n"],"names":["defaultCompare","defaultRenderCell","process","env","NODE_ENV","console","warn","defaultRenderHeaderCell","createTableColumn","options","columnId","renderCell","renderHeaderCell","compare"],"mappings":";;;;;;;eA2BgBQ;;;AAzBhB,MAAMR,iBAAiB,IAAM;AAE7B,MAAMC,oBAAoB;IACxB,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,sCAAsC;QACtCC,QAAQC,IAAI,CAAC;IACf;IAEA,OAAO;AACT;AAEA,MAAMC,0BAA0B;IAC9B,IAAIL,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,sCAAsC;QACtCC,QAAQC,IAAI,CAAC;IACf;IAEA,OAAO;AACT;AAOO,2BAAkCG,OAAwC;IAC/E,MAAM,EACJC,QAAQ,EACRC,aAAaV,iBAAiB,EAC9BW,mBAAmBL,uBAAuB,EAC1CM,UAAUb,cAAc,EACzB,GAAGS;IAEJ,OAAO;QACLC;QACAC;QACAC;QACAC;IACF;AACF"}
1
+ {"version":3,"sources":["../src/hooks/createColumn.ts"],"sourcesContent":["import * as React from 'react';\nimport { CreateTableColumnOptions, TableColumnId } from './types';\n\nconst defaultCompare = () => 0;\n\nconst defaultRenderCell = () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('@fluentui/react-table: You are using the default column renderCell function that renders null');\n }\n\n return null;\n};\n\nconst defaultRenderHeaderCell = () => {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('@fluentui/react-table: You are using the default column renderHeaderCell function that renders null');\n }\n\n return null;\n};\n\n/**\n * Helper function to create column definition with defaults\n * @param options - column definition options\n * @returns - column definition with defaults\n */\nexport function createTableColumn<TItem>(options: CreateTableColumnOptions<TItem>): {\n columnId: TableColumnId;\n renderCell: (item: TItem) => React.ReactNode;\n renderHeaderCell: (data?: unknown) => React.ReactNode;\n compare: (a: TItem, b: TItem) => number;\n} {\n const {\n columnId,\n renderCell = defaultRenderCell,\n renderHeaderCell = defaultRenderHeaderCell,\n compare = defaultCompare,\n } = options;\n\n return {\n columnId,\n renderCell,\n renderHeaderCell,\n compare,\n };\n}\n"],"names":["React","defaultCompare","defaultRenderCell","process","env","NODE_ENV","console","warn","defaultRenderHeaderCell","createTableColumn","options","columnId","renderCell","renderHeaderCell","compare"],"mappings":";;;;;;;eA4BgBS;;;;iEA5BO,QAAQ;AAG/B,MAAMR,iBAAiB,IAAM;AAE7B,MAAMC,oBAAoB;IACxB,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,sCAAsC;QACtCC,QAAQC,IAAI,CAAC;IACf;IAEA,OAAO;AACT;AAEA,MAAMC,0BAA0B;IAC9B,IAAIL,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,sCAAsC;QACtCC,QAAQC,IAAI,CAAC;IACf;IAEA,OAAO;AACT;AAOO,2BAAkCG,OAAwC;IAM/E,MAAM,EACJC,QAAQ,EACRC,aAAaV,iBAAiB,EAC9BW,mBAAmBL,uBAAuB,EAC1CM,UAAUb,cAAc,EACzB,GAAGS;IAEJ,OAAO;QACLC;QACAC;QACAC;QACAC;IACF;AACF"}
@@ -18,7 +18,7 @@ const PRECISION_MODIFIER = _keyboardkeys.Shift;
18
18
  const PRECISION_FACTOR = 1 / 4;
19
19
  function useKeyboardResizing(columnResizeState) {
20
20
  const [columnId, setColumnId] = _react.useState();
21
- const onChangeRef = _react.useRef();
21
+ const onChangeRef = _react.useRef(undefined);
22
22
  const { findPrevFocusable } = (0, _reacttabster.useFocusFinders)();
23
23
  const columnResizeStateRef = _react.useRef(columnResizeState);
24
24
  _react.useEffect(()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useKeyboardResizing.ts"],"sourcesContent":["import * as React from 'react';\nimport { ArrowLeft, ArrowRight, Enter, Escape, Shift, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { ColumnResizeState, EnableKeyboardModeOnChangeCallback, TableColumnId } from './types';\nimport { useFocusFinders, useTabsterAttributes } from '@fluentui/react-tabster';\n\nconst STEP = 20;\nconst PRECISION_MODIFIER = Shift;\nconst PRECISION_FACTOR = 1 / 4;\n\nexport function useKeyboardResizing(columnResizeState: ColumnResizeState) {\n const [columnId, setColumnId] = React.useState<TableColumnId>();\n const onChangeRef = React.useRef<EnableKeyboardModeOnChangeCallback>();\n const { findPrevFocusable } = useFocusFinders();\n\n const columnResizeStateRef = React.useRef<ColumnResizeState>(columnResizeState);\n React.useEffect(() => {\n columnResizeStateRef.current = columnResizeState;\n }, [columnResizeState]);\n\n const [resizeHandleRefs] = React.useState(() => new Map<TableColumnId, React.RefObject<HTMLDivElement>>());\n\n const keyboardHandler = useEventCallback((event: React.KeyboardEvent) => {\n if (!columnId) {\n return;\n }\n\n const width = columnResizeStateRef.current.getColumnWidth(columnId);\n const precisionModifier = event.getModifierState(PRECISION_MODIFIER);\n\n const stopEvent = () => {\n event.preventDefault();\n event.stopPropagation();\n };\n\n switch (event.key) {\n case ArrowLeft:\n stopEvent();\n columnResizeStateRef.current.setColumnWidth(event.nativeEvent, {\n columnId,\n width: width - (precisionModifier ? STEP * PRECISION_FACTOR : STEP),\n });\n return;\n\n case ArrowRight:\n stopEvent();\n columnResizeStateRef.current.setColumnWidth(event.nativeEvent, {\n columnId,\n width: width + (precisionModifier ? STEP * PRECISION_FACTOR : STEP),\n });\n return;\n\n case Space:\n case Enter:\n case Escape:\n stopEvent();\n // Just blur here, the onBlur handler will take care of the rest (disableInteractiveMode).\n resizeHandleRefs.get(columnId)?.current?.blur();\n break;\n }\n });\n\n const enableInteractiveMode = React.useCallback(\n (colId: TableColumnId) => {\n setColumnId(colId);\n onChangeRef.current?.(colId, true);\n\n const handle = resizeHandleRefs.get(colId)?.current;\n if (handle) {\n handle.setAttribute('tabindex', '-1');\n handle.tabIndex = -1;\n handle.focus();\n }\n },\n [resizeHandleRefs],\n );\n\n const disableInteractiveMode = React.useCallback(() => {\n if (!columnId) {\n return;\n }\n // Notify the onChange listener that we are disabling interactive mode.\n onChangeRef.current?.(columnId, false);\n // Find the previous focusable element (table header button) and focus it.\n const el = resizeHandleRefs.get(columnId)?.current;\n if (el) {\n findPrevFocusable(el)?.focus(); // Focus the previous focusable element (header button).\n el.removeAttribute('tabindex');\n }\n\n setColumnId(undefined);\n }, [columnId, findPrevFocusable, resizeHandleRefs]);\n\n const toggleInteractiveMode = (colId: TableColumnId, onChange?: EnableKeyboardModeOnChangeCallback) => {\n onChangeRef.current = onChange;\n if (!columnId) {\n enableInteractiveMode(colId);\n } else if (colId && columnId !== colId) {\n enableInteractiveMode(colId);\n setColumnId(colId);\n } else {\n disableInteractiveMode();\n }\n };\n\n const getKeyboardResizingRef = React.useCallback(\n (colId: TableColumnId) => {\n const ref = resizeHandleRefs.get(colId) || React.createRef<HTMLDivElement>();\n resizeHandleRefs.set(colId, ref);\n return ref;\n },\n [resizeHandleRefs],\n );\n\n // This makes sure the left and right arrow keys are ignored in tabster,\n // so that they can be used for resizing.\n const tabsterAttrs = useTabsterAttributes({\n focusable: {\n ignoreKeydown: {\n ArrowLeft: true,\n ArrowRight: true,\n },\n },\n });\n\n return {\n toggleInteractiveMode,\n columnId,\n getKeyboardResizingProps: React.useCallback(\n (colId: TableColumnId, currentWidth: number) => ({\n onKeyDown: keyboardHandler,\n onBlur: disableInteractiveMode,\n ref: getKeyboardResizingRef(colId),\n role: 'separator',\n 'aria-label': 'Resize column',\n 'aria-valuetext': `${currentWidth} pixels`,\n 'aria-hidden': colId === columnId ? false : true,\n tabIndex: colId === columnId ? 0 : undefined,\n ...tabsterAttrs,\n }),\n [columnId, disableInteractiveMode, getKeyboardResizingRef, keyboardHandler, tabsterAttrs],\n ),\n };\n}\n"],"names":["React","ArrowLeft","ArrowRight","Enter","Escape","Shift","Space","useEventCallback","useFocusFinders","useTabsterAttributes","STEP","PRECISION_MODIFIER","PRECISION_FACTOR","useKeyboardResizing","columnResizeState","columnId","setColumnId","useState","onChangeRef","useRef","findPrevFocusable","columnResizeStateRef","useEffect","current","resizeHandleRefs","Map","keyboardHandler","event","width","getColumnWidth","precisionModifier","getModifierState","stopEvent","preventDefault","stopPropagation","key","setColumnWidth","nativeEvent","get","blur","enableInteractiveMode","useCallback","colId","handle","setAttribute","tabIndex","focus","disableInteractiveMode","el","removeAttribute","undefined","toggleInteractiveMode","onChange","getKeyboardResizingRef","ref","createRef","set","tabsterAttrs","focusable","ignoreKeydown","getKeyboardResizingProps","currentWidth","onKeyDown","onBlur","role"],"mappings":";;;;+BAUgBa;;;;;;;iEAVO,QAAQ;8BACoC,0BAA0B;gCAC5D,4BAA4B;8BAEP,0BAA0B;AAEhF,MAAMH,OAAO;AACb,MAAMC,qBAAqBN,mBAAAA;AAC3B,MAAMO,mBAAmB,IAAI;AAEtB,6BAA6BE,iBAAoC;IACtE,MAAM,CAACC,UAAUC,YAAY,GAAGhB,OA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U;YACbyB,sBAAsBE;QACxB,OAAO,IAAIA,SAAS3B,aAAa2B,OAAO;YACtCF,sBAAsBE;YACtB1B,YAAY0B;QACd,OAAO;YACLK;QACF;IACF;IAEA,MAAMM,yBAAyBrD,OAAMyC,WAAW,CAC9C,CAACC;QACC,MAAMY,MAAM9B,iBAAiBc,GAAG,CAACI,wBAAU1C,OAAMuD,SAAS;QAC1D/B,iBAAiBgC,GAAG,CAACd,OAAOY;QAC5B,OAAOA;IACT,GACA;QAAC9B;KAAiB;IAGpB,wEAAwE;IACxE,yCAAyC;IACzC,MAAMiC,mBAAehD,kCAAAA,EAAqB;QACxCiD,WAAW;YACTC,eAAe;gBACb1D,WAAW;gBACXC,YAAY;YACd;QACF;IACF;IAEA,OAAO;QACLiD;QACApC;QACA6C,0BAA0B5D,OAAMyC,WAAW,CACzC,CAACC,OAAsBmB,eAA0B,CAAA;gBAC/CC,WAAWpC;gBACXqC,QAAQhB;gBACRO,KAAKD,uBAAuBX;gBAC5BsB,MAAM;gBACN,cAAc;gBACd,kBAAkB,GAAGH,aAAa,OAAO,CAAC;gBAC1C,eAAenB,UAAU3B,WAAW,QAAQ;gBAC5C8B,UAAUH,UAAU3B,WAAW,IAAImC;gBACnC,GAAGO,YAAY;aACjB,CAAA,EACA;YAAC1C;YAAUgC;YAAwBM;YAAwB3B;YAAiB+B;SAAa;IAE7F;AACF"}
1
+ {"version":3,"sources":["../src/hooks/useKeyboardResizing.ts"],"sourcesContent":["import * as React from 'react';\nimport { ArrowLeft, ArrowRight, Enter, Escape, Shift, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { ColumnResizeState, EnableKeyboardModeOnChangeCallback, TableColumnId } from './types';\nimport { useFocusFinders, useTabsterAttributes } from '@fluentui/react-tabster';\n\nconst STEP = 20;\nconst PRECISION_MODIFIER = Shift;\nconst PRECISION_FACTOR = 1 / 4;\n\nexport function useKeyboardResizing(columnResizeState: ColumnResizeState): {\n toggleInteractiveMode: (colId: TableColumnId, onChange?: EnableKeyboardModeOnChangeCallback) => void;\n columnId: TableColumnId | undefined;\n getKeyboardResizingProps: (\n colId: TableColumnId,\n currentWidth: number,\n ) => {\n onKeyDown: (event: React.KeyboardEvent) => void;\n onBlur: () => void;\n ref: React.RefObject<HTMLDivElement>;\n role: string;\n 'aria-label': string;\n 'aria-valuetext': string;\n 'aria-hidden': boolean;\n tabIndex?: number;\n };\n} {\n const [columnId, setColumnId] = React.useState<TableColumnId>();\n const onChangeRef = React.useRef<EnableKeyboardModeOnChangeCallback>(undefined);\n const { findPrevFocusable } = useFocusFinders();\n\n const columnResizeStateRef = React.useRef<ColumnResizeState>(columnResizeState);\n React.useEffect(() => {\n columnResizeStateRef.current = columnResizeState;\n }, [columnResizeState]);\n\n const [resizeHandleRefs] = React.useState(() => new Map<TableColumnId, React.RefObject<HTMLDivElement | null>>());\n\n const keyboardHandler = useEventCallback((event: React.KeyboardEvent) => {\n if (!columnId) {\n return;\n }\n\n const width = columnResizeStateRef.current.getColumnWidth(columnId);\n const precisionModifier = event.getModifierState(PRECISION_MODIFIER);\n\n const stopEvent = () => {\n event.preventDefault();\n event.stopPropagation();\n };\n\n switch (event.key) {\n case ArrowLeft:\n stopEvent();\n columnResizeStateRef.current.setColumnWidth(event.nativeEvent, {\n columnId,\n width: width - (precisionModifier ? STEP * PRECISION_FACTOR : STEP),\n });\n return;\n\n case ArrowRight:\n stopEvent();\n columnResizeStateRef.current.setColumnWidth(event.nativeEvent, {\n columnId,\n width: width + (precisionModifier ? STEP * PRECISION_FACTOR : STEP),\n });\n return;\n\n case Space:\n case Enter:\n case Escape:\n stopEvent();\n // Just blur here, the onBlur handler will take care of the rest (disableInteractiveMode).\n resizeHandleRefs.get(columnId)?.current?.blur();\n break;\n }\n });\n\n const enableInteractiveMode = React.useCallback(\n (colId: TableColumnId) => {\n setColumnId(colId);\n onChangeRef.current?.(colId, true);\n\n const handle = resizeHandleRefs.get(colId)?.current;\n if (handle) {\n handle.setAttribute('tabindex', '-1');\n handle.tabIndex = -1;\n handle.focus();\n }\n },\n [resizeHandleRefs],\n );\n\n const disableInteractiveMode = React.useCallback(() => {\n if (!columnId) {\n return;\n }\n // Notify the onChange listener that we are disabling interactive mode.\n onChangeRef.current?.(columnId, false);\n // Find the previous focusable element (table header button) and focus it.\n const el = resizeHandleRefs.get(columnId)?.current;\n if (el) {\n findPrevFocusable(el)?.focus(); // Focus the previous focusable element (header button).\n el.removeAttribute('tabindex');\n }\n\n setColumnId(undefined);\n }, [columnId, findPrevFocusable, resizeHandleRefs]);\n\n const toggleInteractiveMode = (colId: TableColumnId, onChange?: EnableKeyboardModeOnChangeCallback) => {\n onChangeRef.current = onChange;\n if (!columnId) {\n enableInteractiveMode(colId);\n } else if (colId && columnId !== colId) {\n enableInteractiveMode(colId);\n setColumnId(colId);\n } else {\n disableInteractiveMode();\n }\n };\n\n const getKeyboardResizingRef = React.useCallback(\n (colId: TableColumnId) => {\n const ref = resizeHandleRefs.get(colId) || React.createRef<HTMLDivElement>();\n resizeHandleRefs.set(colId, ref);\n return ref;\n },\n [resizeHandleRefs],\n );\n\n // This makes sure the left and right arrow keys are ignored in tabster,\n // so that they can be used for resizing.\n const tabsterAttrs = useTabsterAttributes({\n focusable: {\n ignoreKeydown: {\n ArrowLeft: true,\n ArrowRight: true,\n },\n },\n });\n\n return {\n toggleInteractiveMode,\n columnId,\n getKeyboardResizingProps: React.useCallback(\n (colId: TableColumnId, currentWidth: number) => ({\n onKeyDown: keyboardHandler,\n onBlur: disableInteractiveMode,\n ref: getKeyboardResizingRef(colId) as React.RefObject<HTMLDivElement>,\n role: 'separator',\n 'aria-label': 'Resize column',\n 'aria-valuetext': `${currentWidth} pixels`,\n 'aria-hidden': colId === columnId ? false : true,\n tabIndex: colId === columnId ? 0 : undefined,\n ...tabsterAttrs,\n }),\n [columnId, disableInteractiveMode, getKeyboardResizingRef, keyboardHandler, tabsterAttrs],\n ),\n };\n}\n"],"names":["React","ArrowLeft","ArrowRight","Enter","Escape","Shift","Space","useEventCallback","useFocusFinders","useTabsterAttributes","STEP","PRECISION_MODIFIER","PRECISION_FACTOR","useKeyboardResizing","columnResizeState","columnId","setColumnId","useState","onChangeRef","useRef","undefined","findPrevFocusable","columnResizeStateRef","useEffect","current","resizeHandleRefs","Map","keyboardHandler","event","width","getColumnWidth","precisionModifier","getModifierState","stopEvent","preventDefault","stopPropagation","key","setColumnWidth","nativeEvent","get","blur","enableInteractiveMode","useCallback","colId","handle","setAttribute","tabIndex","focus","disableInteractiveMode","el","removeAttribute","toggleInteractiveMode","onChange","getKeyboardResizingRef","ref","createRef","set","tabsterAttrs","focusable","ignoreKeydown","getKeyboardResizingProps","currentWidth","onKeyDown","onBlur","role"],"mappings":";;;;+BAUgBa;;;;;;;iEAVO,QAAQ;8BACoC,0BAA0B;gCAC5D,4BAA4B;8BAEP,0BAA0B;AAEhF,MAAMH,OAAO;AACb,MAAMC,qBAAqBN,mBAAAA;AAC3B,MAAMO,mBAAmB,IAAI;AAEtB,6BAA6BE,iBAAoC;IAiBtE,MAAM,CAACC,UAAUC,YAAY,GAAGhB,OAAMiB,QAAQ;IAC9C,MAAMC,cAAclB,OAAMmB,MAAM,CAAqCC;IACrE,MAAM,EAAEC,iBAAiB,EAAE,OAAGb,6BAAAA;IAE9B,MAAMc,uBAAuBtB,OAAMmB,MAAM,CAAoBL;IAC7Dd,OAAMuB,SAAS,CAAC;QACdD,qBAAqBE,OAAO,GAAGV;IACjC,GAAG;QAACA;KAAkB;IAEtB,MAAM,CAACW,iBAAiB,GAAGzB,OAAMiB,QAAQ,CAAC,IAAM,IAAIS;IAEpD,MAAMC,sBAAkBpB,gCAAAA,EAAiB,CAACqB;QACxC,IAAI,CAACb,UAAU;YACb;QACF;QAEA,MAAMc,QAAQP,qBAAqBE,OAAO,CAACM,cAAc,CAACf;QAC1D,MAAMgB,oBAAoBH,MAAMI,gBAAgB,CAACrB;QAEjD,MAAMsB,YAAY;YAChBL,MAAMM,cAAc;YACpB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BkB,eAA0B,CAAA;gBAC/CC,WAAWnC;gBACXoC,QAAQf;gBACRM,KAAKD,uBAAuBV;gBAC5BqB,MAAM;gBACN,cAAc;gBACd,kBAAkB,GAAGH,aAAa,OAAO,CAAC;gBAC1C,eAAelB,UAAU5B,WAAW,QAAQ;gBAC5C+B,UAAUH,UAAU5B,WAAW,IAAIK;gBACnC,GAAGqC,YAAY;aACjB,CAAA,EACA;YAAC1C;YAAUiC;YAAwBK;YAAwB1B;YAAiB8B;SAAa;IAE7F;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useMeasureElement.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\n/**\n * Provides a way of reporting element width.\n * Returns\n * `width` - current element width (0 by default),\n * `measureElementRef` - a ref function to be passed as `ref` to the element you want to measure\n */\nexport function useMeasureElement<TElement extends HTMLElement = HTMLElement>() {\n const [width, setWidth] = React.useState(0);\n\n const container = React.useRef<HTMLElement | undefined>(undefined);\n\n const resizeObserverRef = React.useRef<ResizeObserver | null>(null);\n\n const { targetDocument } = useFluent();\n\n // the handler for resize observer\n const handleResize = React.useCallback(() => {\n const containerWidth = container.current?.getBoundingClientRect().width;\n setWidth(containerWidth || 0);\n }, []);\n\n const measureElementRef = React.useCallback(\n (el: TElement | null) => {\n if (!targetDocument) {\n return;\n }\n\n // if the element is removed, stop observing it\n if (!el && resizeObserverRef.current && container.current) {\n resizeObserverRef.current.unobserve(container.current);\n }\n\n container.current = undefined;\n\n if (el?.parentElement) {\n container.current = el.parentElement;\n handleResize();\n resizeObserverRef.current?.observe(container.current);\n }\n },\n [targetDocument, handleResize],\n );\n\n React.useEffect(() => {\n resizeObserverRef.current = createResizeObserverFromDocument(targetDocument, handleResize);\n\n if (!container.current || !resizeObserverRef.current) {\n return;\n }\n\n resizeObserverRef.current.observe(container.current);\n\n return () => {\n resizeObserverRef.current?.disconnect();\n };\n }, [handleResize, targetDocument]);\n\n return { width, measureElementRef };\n}\n\n/**\n * FIXME - TS 3.8/3.9 don't have ResizeObserver types by default, move this to a shared utility once we bump the minbar\n * A utility method that creates a ResizeObserver from a target document\n * @param targetDocument - document to use to create the ResizeObserver\n * @param callback - https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#callback\n * @returns a ResizeObserver instance or null if the global does not exist on the document\n */\nexport function createResizeObserverFromDocument(\n targetDocument: Document | null | undefined,\n callback: ResizeObserverCallback,\n) {\n if (!targetDocument?.defaultView?.ResizeObserver) {\n return null;\n }\n\n return new targetDocument.defaultView.ResizeObserver(callback);\n}\n"],"names":["React","useFluent_unstable","useFluent","useMeasureElement","width","setWidth","useState","container","useRef","undefined","resizeObserverRef","targetDocument","handleResize","useCallback","containerWidth","current","getBoundingClientRect","measureElementRef","el","unobserve","parentElement","observe","useEffect","createResizeObserverFromDocument","disconnect","callback","defaultView","ResizeObserver"],"mappings":";;;;;;;;;;;oCAsEgBuB;eAAAA;;IA7DApB,iBAAAA;;;;;iEATO,QAAQ;qCACiB,kCAAkC;AAQ3E;IACL,MAAM,CAACC,OAAOC,SAAS,GAAGL,OAAMM,QAAQ,CAAC;IAEzC,MAAMC,YAAYP,OAAMQ,MAAM,CAA0BC;IAExD,MAAMC,oBAAoBV,OAAMQ,MAAM,CAAwB;IAE9D,MAAM,EAAEG,cAAc,EAAE,OAAGT,uCAAAA;IAE3B,kCAAkC;IAClC,MAAMU,eAAeZ,OAAMa,WAAW,CAAC;YACdN;QAAvB,MAAMO,iBAAAA,CAAiBP,qBAAAA,UAAUQ,OAAAA,AAAO,MAAA,QAAjBR,uBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,mBAAmBS,qBAAqB,GAAGZ,KAAK;QACvEC,SAASS,kBAAkB;IAC7B,GAAG,EAAE;IAEL,MAAMG,oBAAoBjB,OAAMa,WAAW,CACzC,CAACK;QACC,IAAI,CAACP,gBAAgB;YACnB;QACF;QAEA,+CAA+C;QAC/C,IAAI,CAACO,MA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* as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\n/**\n * Provides a way of reporting element width.\n * Returns\n * `width` - current element width (0 by default),\n * `measureElementRef` - a ref function to be passed as `ref` to the element you want to measure\n */\nexport function useMeasureElement<TElement extends HTMLElement = HTMLElement>(): {\n width: number;\n measureElementRef: (el: TElement | null) => void;\n} {\n const [width, setWidth] = React.useState(0);\n\n const container = React.useRef<HTMLElement | undefined>(undefined);\n\n const resizeObserverRef = React.useRef<ResizeObserver | null>(null);\n\n const { targetDocument } = useFluent();\n\n // the handler for resize observer\n const handleResize = React.useCallback(() => {\n const containerWidth = container.current?.getBoundingClientRect().width;\n setWidth(containerWidth || 0);\n }, []);\n\n const measureElementRef = React.useCallback(\n (el: TElement | null) => {\n if (!targetDocument) {\n return;\n }\n\n // if the element is removed, stop observing it\n if (!el && resizeObserverRef.current && container.current) {\n resizeObserverRef.current.unobserve(container.current);\n }\n\n container.current = undefined;\n\n if (el?.parentElement) {\n container.current = el.parentElement;\n handleResize();\n resizeObserverRef.current?.observe(container.current);\n }\n },\n [targetDocument, handleResize],\n );\n\n React.useEffect(() => {\n resizeObserverRef.current = createResizeObserverFromDocument(targetDocument, handleResize);\n\n if (!container.current || !resizeObserverRef.current) {\n return;\n }\n\n resizeObserverRef.current.observe(container.current);\n\n return () => {\n resizeObserverRef.current?.disconnect();\n };\n }, [handleResize, targetDocument]);\n\n return { width, measureElementRef };\n}\n\n/**\n * FIXME - TS 3.8/3.9 don't have ResizeObserver types by default, move this to a shared utility once we bump the minbar\n * A utility method that creates a ResizeObserver from a target document\n * @param targetDocument - document to use to create the ResizeObserver\n * @param callback - https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#callback\n * @returns a ResizeObserver instance or null if the global does not exist on the document\n */\nexport function createResizeObserverFromDocument(\n targetDocument: Document | null | undefined,\n callback: ResizeObserverCallback,\n): ResizeObserver | null {\n if (!targetDocument?.defaultView?.ResizeObserver) {\n return null;\n }\n\n return new targetDocument.defaultView.ResizeObserver(callback);\n}\n"],"names":["React","useFluent_unstable","useFluent","useMeasureElement","width","setWidth","useState","container","useRef","undefined","resizeObserverRef","targetDocument","handleResize","useCallback","containerWidth","current","getBoundingClientRect","measureElementRef","el","unobserve","parentElement","observe","useEffect","createResizeObserverFromDocument","disconnect","callback","defaultView","ResizeObserver"],"mappings":";;;;;;;;;;;oCAyEgBuB;eAAAA;;IAhEApB,iBAAAA;;;;;iEATO,QAAQ;qCACiB,kCAAkC;AAQ3E;IAIL,MAAM,CAACC,OAAOC,SAAS,GAAGL,OAAMM,QAAQ,CAAC;IAEzC,MAAMC,YAAYP,OAAMQ,MAAM,CAA0BC;IAExD,MAAMC,oBAAoBV,OAAMQ,MAAM,CAAwB;IAE9D,MAAM,EAAEG,cAAc,EAAE,OAAGT,uCAAAA;IAE3B,kCAAkC;IAClC,MAAMU,eAAeZ,OAAMa,WAAW,CAAC;YACdN;QAAvB,MAAMO,iBAAAA,CAAiBP,qBAAAA,UAAUQ,OAAAA,AAAO,MAAA,QAAjBR,uBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,mBAAmBS,qBAAqB,GAAGZ,KAAK;QACvEC,SAASS,kBAAkB;IAC7B,GAAG,EAAE;IAEL,MAAMG,oBAAoBjB,OAAMa,WAAW,CACzC,CAACK;QACC,IAAI,CAACP,gBAAgB;YACnB;QACF;QAEA,+CAA+C;QAC/C,IAAI,CAACO,MAAMR,kBAAkBK,OAAO,IAAIR,UAAUQ,OAAO,EAAE;YACzDL,kBAAkBK,OAAO,CAACI,SAAS,CAACZ,UAAUQ,OAAO;QACvD;QAEAR,UAAUQ,OAAO,GAAGN;QAEpB,IAAIS,OAAAA,QAAAA,OAAAA,KAAAA,IAAAA,KAAAA,IAAAA,GAAIE,aAAa,EAAE;gBAGrBV;YAFAH,UAAUQ,OAAO,GAAGG,GAAGE,aAAa;YACpCR;aACAF,6BAAAA,kBAAkBK,OAAAA,AAAO,MAAA,QAAzBL,+BAAAA,KAAAA,IAAAA,KAAAA,IAAAA,2BAA2BW,OAAO,CAACd,UAAUQ,OAAO;QACtD;IACF,GACA;QAACJ;QAAgBC;KAAa;IAGhCZ,OAAMsB,SAAS,CAAC;QACdZ,kBAAkBK,OAAO,GAAGQ,iCAAiCZ,gBAAgBC;QAE7E,IAAI,CAACL,UAAUQ,OAAO,IAAI,CAACL,kBAAkBK,OAAO,EAAE;YACpD;QACF;QAEAL,kBAAkBK,OAAO,CAACM,OAAO,CAACd,UAAUQ,OAAO;QAEnD,OAAO;gBACLL;aAAAA,6BAAAA,kBAAkBK,OAAAA,AAAO,MAAA,QAAzBL,+BAAAA,KAAAA,IAAAA,KAAAA,IAAAA,2BAA2Bc,UAAU;QACvC;IACF,GAAG;QAACZ;QAAcD;KAAe;IAEjC,OAAO;QAAEP;QAAOa;IAAkB;AACpC;AASO,0CACLN,cAA2C,EAC3Cc,QAAgC;QAE3Bd;IAAL,IAAI,EAACA,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,8BAAAA,eAAgBe,WAAAA,AAAW,MAAA,QAA3Bf,gCAAAA,KAAAA,IAAAA,KAAAA,IAAAA,4BAA6BgB,cAAAA,AAAc,GAAE;QAChD,OAAO;IACT;IAEA,OAAO,IAAIhB,eAAee,WAAW,CAACC,cAAc,CAACF;AACvD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useTableColumnResizeMouseHandler.ts"],"sourcesContent":["import * as React from 'react';\nimport { TableColumnId, ColumnResizeState } from './types';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n NativeTouchOrMouseEvent,\n ReactTouchOrMouseEvent,\n getEventClientCoords,\n isMouseEvent,\n isTouchEvent,\n useAnimationFrame,\n} from '@fluentui/react-utilities';\n\nexport function useTableColumnResizeMouseHandler(columnResizeState: ColumnResizeState) {\n const mouseX = React.useRef(0);\n const currentWidth = React.useRef(0);\n const colId = React.useRef<TableColumnId | undefined>(undefined);\n const [dragging, setDragging] = React.useState<boolean>(false);\n\n const { targetDocument } = useFluent();\n\n const { getColumnWidth, setColumnWidth } = columnResizeState;\n\n const recalculatePosition = React.useCallback(\n (e: NativeTouchOrMouseEvent) => {\n const { clientX } = getEventClientCoords(e);\n const dx = clientX - mouseX.current;\n\n // Update the local width for the column and set it\n currentWidth.current += dx;\n colId.current && setColumnWidth(e, { columnId: colId.current, width: currentWidth.current });\n mouseX.current = clientX;\n },\n [setColumnWidth],\n );\n\n const [requestRecalcFrame] = useAnimationFrame();\n\n const onDrag = React.useCallback(\n (e: NativeTouchOrMouseEvent) => {\n // Using requestAnimationFrame here drastically improves resizing experience on slower CPUs\n requestRecalcFrame(() => recalculatePosition(e));\n },\n [requestRecalcFrame, recalculatePosition],\n );\n\n const onDragEnd = React.useCallback(\n (event: NativeTouchOrMouseEvent) => {\n if (isMouseEvent(event)) {\n targetDocument?.removeEventListener('mouseup', onDragEnd);\n targetDocument?.removeEventListener('mousemove', onDrag);\n }\n if (isTouchEvent(event)) {\n targetDocument?.removeEventListener('touchend', onDragEnd);\n targetDocument?.removeEventListener('touchmove', onDrag);\n }\n setDragging(false);\n },\n [onDrag, targetDocument],\n );\n\n const getOnMouseDown = React.useCallback(\n (columnId: TableColumnId) => (event: ReactTouchOrMouseEvent) => {\n // Keep the width locally so that we decouple the calculation of the next with from rendering.\n // This makes the whole experience much faster and more precise\n currentWidth.current = getColumnWidth(columnId);\n mouseX.current = getEventClientCoords(event).clientX;\n colId.current = columnId;\n\n if (isMouseEvent(event)) {\n // ignore other buttons than primary mouse button\n if (event.target !== event.currentTarget || event.button !== 0) {\n return;\n }\n targetDocument?.addEventListener('mouseup', onDragEnd);\n targetDocument?.addEventListener('mousemove', onDrag);\n setDragging(true);\n }\n\n if (isTouchEvent(event)) {\n targetDocument?.addEventListener('touchend', onDragEnd);\n targetDocument?.addEventListener('touchmove', onDrag);\n setDragging(true);\n }\n },\n [getColumnWidth, onDrag, onDragEnd, targetDocument],\n );\n\n return {\n getOnMouseDown,\n dragging,\n };\n}\n"],"names":["React","useFluent_unstable","useFluent","getEventClientCoords","isMouseEvent","isTouchEvent","useAnimationFrame","useTableColumnResizeMouseHandler","columnResizeState","mouseX","useRef","currentWidth","colId","undefined","dragging","setDragging","useState","targetDocument","getColumnWidth","setColumnWidth","recalculatePosition","useCallback","e","clientX","dx","current","columnId","width","requestRecalcFrame","onDrag","onDragEnd","event","removeEventListener","getOnMouseDown","target","currentTarget","button","addEventListener"],"mappings":";;;;+BAYgBO;;;;;;;iEAZO,QAAQ;qCAEiB,kCAAkC;gCAQ3E,4BAA4B;AAE5B,0CAA0CC,iBAAoC;IACnF,MAAMC,SAAST,OAAMU,MAAM,CAAC;IAC5B,MAAMC,eAAeX,OAAMU,MAAM,CAAC;IAClC,MAAME,QAAQZ,OAAMU,MAAM,CAA4BG;IACtD,MAAM,CAACC,UAAUC,YAAY,GAAGf,OAAMgB,QAAQ,CAAU;IAExD,MAAM,EAAEC,cAAc,EAAE,OAAGf,uCAAAA;IAE3B,MAAM,EAAEgB,cAAc,EAAEC,cAAc,EAAE,GAAGX;IAE3C,MAAMY,sBAAsBpB,OAAMqB,WAAW,CAC3C,CAACC;QACC,MAAM,EAAEC,OAAO,EAAE,OAAGpB,oCAAAA,EAAqBmB;QACzC,MAAME,KAAKD,UAAUd,OAAOgB,OAAO;QAEnC,mDAAmD;QACnDd,aAAac,OAAO,IAAID;QACxBZ,MAAMa,OAAO,IAAIN,eAAeG,GAAG;YAAEI,UAAUd,MAAMa,OAAO;YAAEE,OAAOhB,aAAac,OAAO;QAAC;QAC1FhB,OAAOgB,OAAO,GAAGF;IACnB,GACA;QAACJ;KAAe;IAGlB,MAAM,CAACS,mBAAmB,OAAGtB,iCAAAA;IAE7B,MAAMuB,SAAS7B,OAAMqB,WAAW,CAC9B,CAACC;QACC,2FAA2F;QAC3FM,mBAAmB,IAAMR,oBAAoBE;IAC/C,GACA;QAACM;QAAoBR;KAAoB;IAG3C,MAAMU,Y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,YAAYP;gBAC7Cb,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBoB,gBAAgB,CAAC,aAAaR;gBAC9Cd,YAAY;YACd;QACF,GACA;QAACG;QAAgBW;QAAQC;QAAWb;KAAe;IAGrD,OAAO;QACLgB;QACAnB;IACF;AACF"}
1
+ {"version":3,"sources":["../src/hooks/useTableColumnResizeMouseHandler.ts"],"sourcesContent":["import * as React from 'react';\nimport { TableColumnId, ColumnResizeState } from './types';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n NativeTouchOrMouseEvent,\n ReactTouchOrMouseEvent,\n getEventClientCoords,\n isMouseEvent,\n isTouchEvent,\n useAnimationFrame,\n} from '@fluentui/react-utilities';\n\nexport function useTableColumnResizeMouseHandler(columnResizeState: ColumnResizeState): {\n getOnMouseDown: (columnId: TableColumnId) => (event: ReactTouchOrMouseEvent) => void;\n dragging: boolean;\n} {\n const mouseX = React.useRef(0);\n const currentWidth = React.useRef(0);\n const colId = React.useRef<TableColumnId | undefined>(undefined);\n const [dragging, setDragging] = React.useState<boolean>(false);\n\n const { targetDocument } = useFluent();\n\n const { getColumnWidth, setColumnWidth } = columnResizeState;\n\n const recalculatePosition = React.useCallback(\n (e: NativeTouchOrMouseEvent) => {\n const { clientX } = getEventClientCoords(e);\n const dx = clientX - mouseX.current;\n\n // Update the local width for the column and set it\n currentWidth.current += dx;\n colId.current && setColumnWidth(e, { columnId: colId.current, width: currentWidth.current });\n mouseX.current = clientX;\n },\n [setColumnWidth],\n );\n\n const [requestRecalcFrame] = useAnimationFrame();\n\n const onDrag = React.useCallback(\n (e: NativeTouchOrMouseEvent) => {\n // Using requestAnimationFrame here drastically improves resizing experience on slower CPUs\n requestRecalcFrame(() => recalculatePosition(e));\n },\n [requestRecalcFrame, recalculatePosition],\n );\n\n const onDragEnd = React.useCallback(\n (event: NativeTouchOrMouseEvent) => {\n if (isMouseEvent(event)) {\n targetDocument?.removeEventListener('mouseup', onDragEnd);\n targetDocument?.removeEventListener('mousemove', onDrag);\n }\n if (isTouchEvent(event)) {\n targetDocument?.removeEventListener('touchend', onDragEnd);\n targetDocument?.removeEventListener('touchmove', onDrag);\n }\n setDragging(false);\n },\n [onDrag, targetDocument],\n );\n\n const getOnMouseDown = React.useCallback(\n (columnId: TableColumnId) => (event: ReactTouchOrMouseEvent) => {\n // Keep the width locally so that we decouple the calculation of the next with from rendering.\n // This makes the whole experience much faster and more precise\n currentWidth.current = getColumnWidth(columnId);\n mouseX.current = getEventClientCoords(event).clientX;\n colId.current = columnId;\n\n if (isMouseEvent(event)) {\n // ignore other buttons than primary mouse button\n if (event.target !== event.currentTarget || event.button !== 0) {\n return;\n }\n targetDocument?.addEventListener('mouseup', onDragEnd);\n targetDocument?.addEventListener('mousemove', onDrag);\n setDragging(true);\n }\n\n if (isTouchEvent(event)) {\n targetDocument?.addEventListener('touchend', onDragEnd);\n targetDocument?.addEventListener('touchmove', onDrag);\n setDragging(true);\n }\n },\n [getColumnWidth, onDrag, onDragEnd, targetDocument],\n );\n\n return {\n getOnMouseDown,\n dragging,\n };\n}\n"],"names":["React","useFluent_unstable","useFluent","getEventClientCoords","isMouseEvent","isTouchEvent","useAnimationFrame","useTableColumnResizeMouseHandler","columnResizeState","mouseX","useRef","currentWidth","colId","undefined","dragging","setDragging","useState","targetDocument","getColumnWidth","setColumnWidth","recalculatePosition","useCallback","e","clientX","dx","current","columnId","width","requestRecalcFrame","onDrag","onDragEnd","event","removeEventListener","getOnMouseDown","target","currentTarget","button","addEventListener"],"mappings":";;;;+BAYgBO;;;;;;;iEAZO,QAAQ;qCAEiB,kCAAkC;gCAQ3E,4BAA4B;AAE5B,0CAA0CC,iBAAoC;IAInF,MAAMC,SAAST,OAAMU,MAAM,CAAC;IAC5B,MAAMC,eAAeX,OAAMU,MAAM,CAAC;IAClC,MAAME,QAAQZ,OAAMU,MAAM,CAA4BG;IACtD,MAAM,CAACC,UAAUC,YAAY,GAAGf,OAAM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,CAACK,WAA4B,CAACK;YAC5B,8FAA8F;YAC9F,+DAA+D;YAC/DpB,aAAac,OAAO,GAAGP,eAAeQ;YACtCjB,OAAOgB,OAAO,OAAGtB,oCAAAA,EAAqB4B,OAAOR,OAAO;YACpDX,MAAMa,OAAO,GAAGC;YAEhB,QAAItB,4BAAAA,EAAa2B,QAAQ;gBACvB,iDAAiD;gBACjD,IAAIA,MAAMG,MAAM,KAAKH,MAAMI,aAAa,IAAIJ,MAAMK,MAAM,KAAK,GAAG;oBAC9D;gBACF;gBACAnB,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBoB,gBAAgB,CAAC,WAAWP;gBAC5Cb,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBoB,gBAAgB,CAAC,aAAaR;gBAC9Cd,YAAY;YACd;YAEA,QAAIV,4BAAAA,EAAa0B,QAAQ;gBACvBd,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBoB,gBAAgB,CAAC,YAAYP;gBAC7Cb,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBoB,gBAAgB,CAAC,aAAaR;gBAC9Cd,YAAY;YACd;QACF,GACA;QAACG;QAAgBW;QAAQC;QAAWb;KAAe;IAGrD,OAAO;QACLgB;QACAnB;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useTableColumnSizing.tsx"],"sourcesContent":["import * as React from 'react';\nimport { TableResizeHandle } from '../TableResizeHandle';\nimport {\n ColumnWidthState,\n EnableKeyboardModeOnChangeCallback,\n TableColumnId,\n TableColumnSizingState,\n TableFeaturesState,\n UseTableColumnSizingParams,\n} from './types';\n\nimport { useMeasureElement } from './useMeasureElement';\nimport { useTableColumnResizeMouseHandler } from './useTableColumnResizeMouseHandler';\nimport { useTableColumnResizeState } from './useTableColumnResizeState';\nimport { useKeyboardResizing } from './useKeyboardResizing';\n\nexport const defaultColumnSizingState: TableColumnSizingState = {\n getColumnWidths: () => [],\n getOnMouseDown: () => () => null,\n setColumnWidth: () => null,\n getTableProps: () => ({}),\n getTableHeaderCellProps: () => ({ style: {}, columnId: '' }),\n getTableCellProps: () => ({ style: {}, columnId: '' }),\n enableKeyboardMode: () => () => null,\n};\n\nexport function useTableColumnSizing_unstable<TItem>(params?: UseTableColumnSizingParams) {\n 'use no memo';\n\n // False positive, these plugin hooks are intended to be run on every render\n\n return (tableState: TableFeaturesState<TItem>) =>\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useTableColumnSizingState(tableState, { autoFitColumns: true, ...params });\n}\n\nfunction getColumnStyles(column: ColumnWidthState, dragging?: boolean): React.CSSProperties {\n const width = column.width;\n\n return {\n // native styles\n width,\n // non-native element styles (flex layout)\n minWidth: width,\n maxWidth: width,\n // Fixed the unwanted sort: https://github.com/microsoft/fluentui/issues/27803\n ...(dragging ? { pointerEvents: 'none' } : {}),\n };\n}\n\nfunction useTableColumnSizingState<TItem>(\n tableState: TableFeaturesState<TItem>,\n params: UseTableColumnSizingParams = {},\n): TableFeaturesState<TItem> {\n const { columns } = tableState;\n\n // Gets the container width\n const { width, measureElementRef } = useMeasureElement();\n // Creates the state based on columns and available containerWidth\n const columnResizeState = useTableColumnResizeState(columns, width + (params?.containerWidthOffset || 0), params);\n // Creates the mouse handler and attaches the state to it\n const mouseHandler = useTableColumnResizeMouseHandler(columnResizeState);\n // Creates the keyboard handler for resizing columns\n const { toggleInteractiveMode, getKeyboardResizingProps } = useKeyboardResizing(columnResizeState);\n\n const { autoFitColumns } = params;\n\n const enableKeyboardMode = React.useCallback(\n (columnId: TableColumnId, onChange?: EnableKeyboardModeOnChangeCallback) =>\n (e: React.MouseEvent | React.TouchEvent) => {\n e.preventDefault();\n e.nativeEvent.stopPropagation();\n toggleInteractiveMode(columnId, onChange);\n },\n [toggleInteractiveMode],\n );\n\n const { getColumnById, setColumnWidth, getColumns } = columnResizeState;\n const { getOnMouseDown, dragging } = mouseHandler;\n return {\n ...tableState,\n tableRef: measureElementRef,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n columnSizing_unstable: {\n getOnMouseDown,\n setColumnWidth: (columnId: TableColumnId, w: number) => setColumnWidth(undefined, { columnId, width: w }),\n getColumnWidths: getColumns,\n getTableProps: (props = {}) => {\n return {\n ...props,\n style: {\n minWidth: 'fit-content',\n ...(props.style || {}),\n },\n };\n },\n getTableHeaderCellProps: React.useCallback(\n (columnId: TableColumnId) => {\n const col = getColumnById(columnId);\n const isLastColumn = columns[columns.length - 1]?.columnId === columnId;\n\n const aside =\n isLastColumn && autoFitColumns ? null : (\n <TableResizeHandle\n onMouseDown={getOnMouseDown(columnId)}\n onTouchStart={getOnMouseDown(columnId)}\n {...getKeyboardResizingProps(columnId, col?.width || 0)}\n />\n );\n\n return col\n ? {\n style: getColumnStyles(col, dragging),\n aside,\n }\n : {};\n },\n [getColumnById, columns, dragging, getKeyboardResizingProps, getOnMouseDown, autoFitColumns],\n ),\n getTableCellProps: React.useCallback(\n (columnId: TableColumnId) => {\n const col = getColumnById(columnId);\n return col ? { style: getColumnStyles(col) } : {};\n },\n [getColumnById],\n ),\n enableKeyboardMode,\n },\n };\n}\n"],"names":["React","TableResizeHandle","useMeasureElement","useTableColumnResizeMouseHandler","useTableColumnResizeState","useKeyboardResizing","defaultColumnSizingState","getColumnWidths","getOnMouseDown","setColumnWidth","getTableProps","getTableHeaderCellProps","style","columnId","getTableCellProps","enableKeyboardMode","useTableColumnSizing_unstable","params","tableState","useTableColumnSizingState","autoFitColumns","getColumnStyles","column","dragging","width","minWidth","maxWidth","pointerEvents","columns","measureElementRef","columnResizeState","containerWidthOffset","mouseHandler","toggleInteractiveMode","getKeyboardResizingProps","useCallback","onChange","e","preventDefault","nativeEvent","stopPropagation","getColumnById","getColumns","tableRef","columnSizing_unstable","w","undefined","props","col","isLastColumn","length","aside","onMouseDown","onTouchStart"],"mappings":";;;;;;;;;;;4BAgBaM;eAA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AA,IAAAA,KAAAA,IAAAA,IAAKxB,KAAAA,AAAK,KAAI,EAAE;;gBAI7D,OAAOwB,MACH;oBACEpC,OAAOS,gBAAgB2B,KAAKzB;oBAC5B4B;gBACF,IACA,CAAC;YACP,GACA;gBAACV;gBAAeb;gBAASL;gBAAUW;gBAA0B1B;gBAAgBY;aAAe;YAE9FN,mBAAmBd,OAAMmC,WAAW,CAClC,CAACtB;gBACC,MAAMmC,MAAMP,cAAc5B;gBAC1B,OAAOmC,MAAM;oBAAEpC,OAAOS,gBAAgB2B;gBAAK,IAAI,CAAC;YAClD,GACA;gBAACP;aAAc;YAEjB1B;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/hooks/useTableColumnSizing.tsx"],"sourcesContent":["import * as React from 'react';\nimport { TableResizeHandle } from '../TableResizeHandle';\nimport {\n ColumnWidthState,\n EnableKeyboardModeOnChangeCallback,\n TableColumnId,\n TableColumnSizingState,\n TableFeaturesState,\n UseTableColumnSizingParams,\n} from './types';\n\nimport { useMeasureElement } from './useMeasureElement';\nimport { useTableColumnResizeMouseHandler } from './useTableColumnResizeMouseHandler';\nimport { useTableColumnResizeState } from './useTableColumnResizeState';\nimport { useKeyboardResizing } from './useKeyboardResizing';\n\nexport const defaultColumnSizingState: TableColumnSizingState = {\n getColumnWidths: () => [],\n getOnMouseDown: () => () => null,\n setColumnWidth: () => null,\n getTableProps: () => ({}),\n getTableHeaderCellProps: () => ({ style: {}, columnId: '' }),\n getTableCellProps: () => ({ style: {}, columnId: '' }),\n enableKeyboardMode: () => () => null,\n};\n\nexport function useTableColumnSizing_unstable<TItem>(params?: UseTableColumnSizingParams) {\n 'use no memo';\n\n // False positive, these plugin hooks are intended to be run on every render\n\n return (tableState: TableFeaturesState<TItem>): TableFeaturesState<TItem> =>\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useTableColumnSizingState(tableState, { autoFitColumns: true, ...params });\n}\n\nfunction getColumnStyles(column: ColumnWidthState, dragging?: boolean): React.CSSProperties {\n const width = column.width;\n\n return {\n // native styles\n width,\n // non-native element styles (flex layout)\n minWidth: width,\n maxWidth: width,\n // Fixed the unwanted sort: https://github.com/microsoft/fluentui/issues/27803\n ...(dragging ? { pointerEvents: 'none' } : {}),\n };\n}\n\nfunction useTableColumnSizingState<TItem>(\n tableState: TableFeaturesState<TItem>,\n params: UseTableColumnSizingParams = {},\n): TableFeaturesState<TItem> {\n const { columns } = tableState;\n\n // Gets the container width\n const { width, measureElementRef } = useMeasureElement();\n // Creates the state based on columns and available containerWidth\n const columnResizeState = useTableColumnResizeState(columns, width + (params?.containerWidthOffset || 0), params);\n // Creates the mouse handler and attaches the state to it\n const mouseHandler = useTableColumnResizeMouseHandler(columnResizeState);\n // Creates the keyboard handler for resizing columns\n const { toggleInteractiveMode, getKeyboardResizingProps } = useKeyboardResizing(columnResizeState);\n\n const { autoFitColumns } = params;\n\n const enableKeyboardMode = React.useCallback(\n (columnId: TableColumnId, onChange?: EnableKeyboardModeOnChangeCallback) =>\n (e: React.MouseEvent | React.TouchEvent) => {\n e.preventDefault();\n e.nativeEvent.stopPropagation();\n toggleInteractiveMode(columnId, onChange);\n },\n [toggleInteractiveMode],\n );\n\n const { getColumnById, setColumnWidth, getColumns } = columnResizeState;\n const { getOnMouseDown, dragging } = mouseHandler;\n return {\n ...tableState,\n tableRef: measureElementRef,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n columnSizing_unstable: {\n getOnMouseDown,\n setColumnWidth: (columnId: TableColumnId, w: number) => setColumnWidth(undefined, { columnId, width: w }),\n getColumnWidths: getColumns,\n getTableProps: (props = {}) => {\n return {\n ...props,\n style: {\n minWidth: 'fit-content',\n ...(props.style || {}),\n },\n };\n },\n getTableHeaderCellProps: React.useCallback(\n (columnId: TableColumnId) => {\n const col = getColumnById(columnId);\n const isLastColumn = columns[columns.length - 1]?.columnId === columnId;\n\n const aside =\n isLastColumn && autoFitColumns ? null : (\n <TableResizeHandle\n onMouseDown={getOnMouseDown(columnId)}\n onTouchStart={getOnMouseDown(columnId)}\n {...getKeyboardResizingProps(columnId, col?.width || 0)}\n />\n );\n\n return col\n ? {\n style: getColumnStyles(col, dragging),\n aside,\n }\n : {};\n },\n [getColumnById, columns, dragging, getKeyboardResizingProps, getOnMouseDown, autoFitColumns],\n ),\n getTableCellProps: React.useCallback(\n (columnId: TableColumnId) => {\n const col = getColumnById(columnId);\n return col ? { style: getColumnStyles(col) } : {};\n },\n [getColumnById],\n ),\n enableKeyboardMode,\n },\n };\n}\n"],"names":["React","TableResizeHandle","useMeasureElement","useTableColumnResizeMouseHandler","useTableColumnResizeState","useKeyboardResizing","defaultColumnSizingState","getColumnWidths","getOnMouseDown","setColumnWidth","getTableProps","getTableHeaderCellProps","style","columnId","getTableCellProps","enableKeyboardMode","useTableColumnSizing_unstable","params","tableState","useTableColumnSizingState","autoFitColumns","getColumnStyles","column","dragging","width","minWidth","maxWidth","pointerEvents","columns","measureElementRef","columnResizeState","containerWidthOffset","mouseHandler","toggleInteractiveMode","getKeyboardResizingProps","useCallback","onChange","e","preventDefault","nativeEvent","stopPropagation","getColumnById","getColumns","tableRef","columnSizing_unstable","w","undefined","props","col","isLastColumn","length","aside","onMouseDown","onTouchStart"],"mappings":";;;;;;;;;;;4BAgBaM;eAAAA;;IAUGU,6BAAAA;;;;;iEA1BO,QAAQ;mCACG,uBAAuB;mCAUvB,sBAAsB;kDACP,qCAAqC;2CAC5C,8BAA8B;qCACpC,wBAAwB;AAErD,iCAAyD;IAC9DT,iBAAiB,IAAM,EAAE;IACzBC,gBAAgB,IAAM,IAAM;IAC5BC,gBAAgB,IAAM;IACtBC,eAAe,IAAO,CAAA,EAAC,CAAA;IACvBC,yBAAyB,IAAO,CAAA;YAAEC,OAAO,CAAC;YAAGC,UAAU;SAAG,CAAA;IAC1DC,mBAAmB,IAAO,CAAA;YAAEF,OAAO,CAAC;YAAGC,UAAU;SAAG,CAAA;IACpDE,oBAAoB,IAAM,IAAM;AAClC,EAAE;AAEK,uCAA8CE,MAAmC;I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],"sourcesContent":["import * as React from 'react';\nimport { SelectionHookParams, useEventCallback, useSelection } from '@fluentui/react-utilities';\nimport type { TableRowId, TableSelectionState, TableFeaturesState } from './types';\n\nconst noop = () => undefined;\n\nexport const defaultTableSelectionState: TableSelectionState = {\n allRowsSelected: false,\n clearRows: noop,\n deselectRow: noop,\n isRowSelected: () => false,\n selectRow: noop,\n selectedRows: new Set(),\n someRowsSelected: false,\n toggleAllRows: noop,\n toggleRow: noop,\n selectionMode: 'multiselect',\n};\n\nexport function useTableSelection<TItem>(options: SelectionHookParams) {\n 'use no memo';\n\n // False positive, these plugin hooks are intended to be run on every render\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return (tableState: TableFeaturesState<TItem>) => useTableSelectionState(tableState, options);\n}\n\nexport function useTableSelectionState<TItem>(\n tableState: TableFeaturesState<TItem>,\n options: SelectionHookParams,\n): TableFeaturesState<TItem> {\n const { items, getRowId } = tableState;\n const { selectionMode: selectionMode, defaultSelectedItems, selectedItems, onSelectionChange } = options;\n\n const [selected, selectionMethods] = useSelection({\n selectionMode,\n defaultSelectedItems,\n selectedItems,\n onSelectionChange,\n });\n\n // Selection state can contain obselete items (i.e. rows that are removed)\n const selectableRowIds = React.useMemo(() => {\n const rowIds = new Set<TableRowId>();\n for (let i = 0; i < items.length; i++) {\n rowIds.add(getRowId?.(items[i]) ?? i);\n }\n\n return rowIds;\n }, [items, getRowId]);\n\n const allRowsSelected = React.useMemo(() => {\n if (selectionMode === 'single') {\n const selectedRow = Array.from(selected)[0];\n return selectableRowIds.has(selectedRow);\n }\n\n // multiselect case\n if (selected.size < selectableRowIds.size) {\n return false;\n }\n\n if (selectableRowIds.size === 0) {\n return false;\n }\n\n let res = true;\n selectableRowIds.forEach(selectableRowId => {\n if (!selected.has(selectableRowId)) {\n res = false;\n }\n });\n\n return res;\n }, [selectableRowIds, selected, selectionMode]);\n\n const someRowsSelected = React.useMemo(() => {\n if (selected.size <= 0) {\n return false;\n }\n\n let res = false;\n selectableRowIds.forEach(selectableRowId => {\n if (selected.has(selectableRowId)) {\n res = true;\n }\n });\n\n return res;\n }, [selectableRowIds, selected]);\n\n const toggleAllRows: TableSelectionState['toggleAllRows'] = useEventCallback(e => {\n selectionMethods.toggleAllItems(\n e,\n items.map((item, i) => getRowId?.(item) ?? i),\n );\n });\n\n const toggleRow: TableSelectionState['toggleRow'] = useEventCallback((e, rowId: TableRowId) =>\n selectionMethods.toggleItem(e, rowId),\n );\n\n const deselectRow: TableSelectionState['deselectRow'] = useEventCallback((e, rowId: TableRowId) =>\n selectionMethods.deselectItem(e, rowId),\n );\n\n const selectRow: TableSelectionState['selectRow'] = useEventCallback((e, rowId: TableRowId) =>\n selectionMethods.selectItem(e, rowId),\n );\n\n const isRowSelected: TableSelectionState['isRowSelected'] = (rowId: TableRowId) => selectionMethods.isSelected(rowId);\n\n const clearRows: TableSelectionState['clearRows'] = useEventCallback(e => selectionMethods.clearItems(e));\n\n return {\n ...tableState,\n selection: {\n selectionMode,\n someRowsSelected,\n allRowsSelected,\n selectedRows: selected,\n toggleRow,\n toggleAllRows,\n clearRows,\n deselectRow,\n selectRow,\n isRowSelected,\n },\n };\n}\n"],"names":["React","useEventCallback","useSelection","noop","undefined","defaultTableSelectionState","allRowsSelected","clearRows","deselectRow","isRowSelected","selectRow","selectedRows","Set","someRowsSelected","toggleAllRows","toggleRow","selectionMode","useTableSelection","options","tableState","useTableSelectionState","items","getRowId","defaultSelectedItems","selectedItems","onSelectionChange","selected","selectionMethods","selectableRowIds","useMemo","rowIds","i","length","add","selectedRow","Array","from","has","size","res","forEach","selectableRowId","e","toggleAllItems","map","item","rowId","toggleItem","deselectItem","selectItem","isSelected","clearItems","selection"],"mappings":";;;;;;;;;;;8BAMaK;eAAAA;;qBAaGY;;;0BAQAG;eAAAA;;;;iEA3BO,QAAQ;gCACqC,4BAA4B;AAGhG,MAAMjB,OAAO,IAAMC;AAEZ,mCAAwD;IAC7DE,iBAAiB;IACjBC,WAAWJ;IACXK,aAAaL;I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"}
1
+ {"version":3,"sources":["../src/hooks/useTableSelection.ts"],"sourcesContent":["import * as React from 'react';\nimport { SelectionHookParams, useEventCallback, useSelection } from '@fluentui/react-utilities';\nimport type { TableRowId, TableSelectionState, TableFeaturesState } from './types';\n\nconst noop = (): void => undefined;\n\nexport const defaultTableSelectionState: TableSelectionState = {\n allRowsSelected: false,\n clearRows: noop,\n deselectRow: noop,\n isRowSelected: () => false,\n selectRow: noop,\n selectedRows: new Set(),\n someRowsSelected: false,\n toggleAllRows: noop,\n toggleRow: noop,\n selectionMode: 'multiselect',\n};\n\nexport function useTableSelection<TItem>(\n options: SelectionHookParams,\n): (tableState: TableFeaturesState<TItem>) => TableFeaturesState<TItem> {\n 'use no memo';\n\n // False positive, these plugin hooks are intended to be run on every render\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return (tableState: TableFeaturesState<TItem>) => useTableSelectionState(tableState, options);\n}\n\nexport function useTableSelectionState<TItem>(\n tableState: TableFeaturesState<TItem>,\n options: SelectionHookParams,\n): TableFeaturesState<TItem> {\n const { items, getRowId } = tableState;\n const { selectionMode: selectionMode, defaultSelectedItems, selectedItems, onSelectionChange } = options;\n\n const [selected, selectionMethods] = useSelection({\n selectionMode,\n defaultSelectedItems,\n selectedItems,\n onSelectionChange,\n });\n\n // Selection state can contain obselete items (i.e. rows that are removed)\n const selectableRowIds = React.useMemo(() => {\n const rowIds = new Set<TableRowId>();\n for (let i = 0; i < items.length; i++) {\n rowIds.add(getRowId?.(items[i]) ?? i);\n }\n\n return rowIds;\n }, [items, getRowId]);\n\n const allRowsSelected = React.useMemo(() => {\n if (selectionMode === 'single') {\n const selectedRow = Array.from(selected)[0];\n return selectableRowIds.has(selectedRow);\n }\n\n // multiselect case\n if (selected.size < selectableRowIds.size) {\n return false;\n }\n\n if (selectableRowIds.size === 0) {\n return false;\n }\n\n let res = true;\n selectableRowIds.forEach(selectableRowId => {\n if (!selected.has(selectableRowId)) {\n res = false;\n }\n });\n\n return res;\n }, [selectableRowIds, selected, selectionMode]);\n\n const someRowsSelected = React.useMemo(() => {\n if (selected.size <= 0) {\n return false;\n }\n\n let res = false;\n selectableRowIds.forEach(selectableRowId => {\n if (selected.has(selectableRowId)) {\n res = true;\n }\n });\n\n return res;\n }, [selectableRowIds, selected]);\n\n const toggleAllRows: TableSelectionState['toggleAllRows'] = useEventCallback(e => {\n selectionMethods.toggleAllItems(\n e,\n items.map((item, i) => getRowId?.(item) ?? i),\n );\n });\n\n const toggleRow: TableSelectionState['toggleRow'] = useEventCallback((e, rowId: TableRowId) =>\n selectionMethods.toggleItem(e, rowId),\n );\n\n const deselectRow: TableSelectionState['deselectRow'] = useEventCallback((e, rowId: TableRowId) =>\n selectionMethods.deselectItem(e, rowId),\n );\n\n const selectRow: TableSelectionState['selectRow'] = useEventCallback((e, rowId: TableRowId) =>\n selectionMethods.selectItem(e, rowId),\n );\n\n const isRowSelected: TableSelectionState['isRowSelected'] = (rowId: TableRowId) => selectionMethods.isSelected(rowId);\n\n const clearRows: TableSelectionState['clearRows'] = useEventCallback(e => selectionMethods.clearItems(e));\n\n return {\n ...tableState,\n selection: {\n selectionMode,\n someRowsSelected,\n allRowsSelected,\n selectedRows: selected,\n toggleRow,\n toggleAllRows,\n clearRows,\n deselectRow,\n selectRow,\n isRowSelected,\n },\n };\n}\n"],"names":["React","useEventCallback","useSelection","noop","undefined","defaultTableSelectionState","allRowsSelected","clearRows","deselectRow","isRowSelected","selectRow","selectedRows","Set","someRowsSelected","toggleAllRows","toggleRow","selectionMode","useTableSelection","options","tableState","useTableSelectionState","items","getRowId","defaultSelectedItems","selectedItems","onSelectionChange","selected","selectionMethods","selectableRowIds","useMemo","rowIds","i","length","add","selectedRow","Array","from","has","size","res","forEach","selectableRowId","e","toggleAllItems","map","item","rowId","toggleItem","deselectItem","selectItem","isSelected","clearItems","selection"],"mappings":";;;;;;;;;;;8BAMaK;eAAAA;;qBAaGY;;;0BAUAG;eAAAA;;;;iEA7BO,QAAQ;gCACqC,4BAA4B;A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,WAAW;YACTpC;YACAH;YACAP;YACAK,cAAce;YACdX;YACAD;YACAP;YACAC;YACAE;YACAD;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useTableSort.ts"],"sourcesContent":["import * as React from 'react';\nimport { useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport type {\n TableColumnId,\n TableRowData,\n SortState,\n TableSortState,\n TableFeaturesState,\n UseTableSortOptions,\n} from './types';\n\nconst noop = () => undefined;\n\nexport const defaultTableSortState: TableSortState<unknown> = {\n getSortDirection: () => 'ascending',\n setColumnSort: noop,\n sort: <TRowState extends TableRowData<unknown>>(rows: TRowState[]) => [...rows],\n sortColumn: undefined,\n sortDirection: 'ascending',\n toggleColumnSort: noop,\n};\n\nexport function useTableSort<TItem>(options: UseTableSortOptions) {\n 'use no memo';\n\n // False positive, these plugin hooks are intended to be run on every render\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return (tableState: TableFeaturesState<TItem>) => useTableSortState(tableState, options);\n}\n\nexport function useTableSortState<TItem>(\n tableState: TableFeaturesState<TItem>,\n options: UseTableSortOptions,\n): TableFeaturesState<TItem> {\n const { columns } = tableState;\n const { sortState, defaultSortState, onSortChange: onSortChangeProp = noop } = 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 onSortChange = useEventCallback(onSortChangeProp);\n\n const toggleColumnSort = React.useCallback(\n (e: React.SyntheticEvent, columnId: TableColumnId | undefined) => {\n setSorted(s => {\n const newState = { ...s, sortColumn: columnId };\n if (s.sortColumn === columnId) {\n newState.sortDirection = s.sortDirection === 'ascending' ? 'descending' : 'ascending';\n } else {\n newState.sortDirection = 'ascending';\n }\n\n onSortChange?.(e, newState);\n return newState;\n });\n },\n [onSortChange, setSorted],\n );\n\n const setColumnSort: TableSortState<TItem>['setColumnSort'] = (e, nextSortColumn, nextSortDirection) => {\n const newState = { sortColumn: nextSortColumn, sortDirection: nextSortDirection };\n onSortChange?.(e, newState);\n setSorted(newState);\n };\n\n const sort = React.useCallback(\n <TRowState extends TableRowData<TItem>>(rows: TRowState[]) => {\n return rows.slice().sort((a, b) => {\n const sortColumnDef = columns.find(column => column.columnId === sortColumn);\n if (!sortColumnDef?.compare) {\n return 0;\n }\n\n const mod = sortDirection === 'ascending' ? 1 : -1;\n return sortColumnDef.compare(a.item, b.item) * mod;\n });\n },\n [columns, sortColumn, sortDirection],\n );\n\n const getSortDirection: TableSortState<TItem>['getSortDirection'] = (columnId: TableColumnId) => {\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"],"names":["React","useControllableState","useEventCallback","noop","undefined","defaultTableSortState","getSortDirection","setColumnSort","sort","rows","sortColumn","sortDirection","toggleColumnSort","useTableSort","options","tableState","useTableSortState","columns","sortState","defaultSortState","onSortChange","onSortChangeProp","sorted","setSorted","initialState","defaultState","state","useCallback","e","columnId","s","newState","nextSortColumn","nextSortDirection","slice","a","b","sortColumnDef","find","column","compare","mod","item"],"mappings":";;;;;;;;;;;yBAaaK;eAAAA;;gBASGQ;;;IAQAG,iBAAAA;;;;;iEA9BO,QAAQ;gCACwB,4BAA4B;AAUnF,MAAMb,OAAO,IAAMC;AAEZ,8BAAuD;IAC5DE,kBAAkB,IAAM;IACxBC,eAAeJ;IACfK,MAAM,CAA0CC,OAAsB;eAAIA;SAAK;IAC/EC,YAAYN;IACZO,eAAe;IACfC,kBAAkBT;AACpB,EAAE;AAEK,SAASU,aAAoBC,OAA4B;IAC9D;IAEA,4EAA4E;IAC5E,sDAAsD;IACtD,OAAO,CAACC,aAA0CC,kBAAkBD,YAAYD;AAClF;AAEO,2BACLC,UAAqC,EACrCD,OAA4B;IAE5B,MAAM,EAAEG,OAA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,OAAAA,AAAO,GAAE;gBAC3B,OAAO;YACT;YAEA,MAAMC,MAAM9B,kBAAkB,cAAc,IAAI,CAAC;YACjD,OAAO0B,cAAcG,OAAO,CAACL,EAAEO,IAAI,EAAEN,EAAEM,IAAI,IAAID;QACjD;IACF,GACA;QAACxB;QAASP;QAAYC;KAAc;IAGtC,MAAML,mBAA8D,CAACuB;QACnE,OAAOnB,eAAemB,WAAWlB,gBAAgBP;IACnD;IAEA,OAAO;QACL,GAAGW,UAAU;QACbP,MAAM;YACJA;YACAE;YACAC;YACAJ;YACAK;YACAN;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/hooks/useTableSort.ts"],"sourcesContent":["import * as React from 'react';\nimport { useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport type {\n TableColumnId,\n TableRowData,\n SortState,\n TableSortState,\n TableFeaturesState,\n UseTableSortOptions,\n} from './types';\n\nconst noop = (): void => undefined;\n\nexport const defaultTableSortState: TableSortState<unknown> = {\n getSortDirection: () => 'ascending',\n setColumnSort: noop,\n sort: <TRowState extends TableRowData<unknown>>(rows: TRowState[]) => [...rows],\n sortColumn: undefined,\n sortDirection: 'ascending',\n toggleColumnSort: noop,\n};\n\nexport function useTableSort<TItem>(options: UseTableSortOptions) {\n 'use no memo';\n\n // False positive, these plugin hooks are intended to be run on every render\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return (tableState: TableFeaturesState<TItem>): TableFeaturesState<TItem> => useTableSortState(tableState, options);\n}\n\nexport function useTableSortState<TItem>(\n tableState: TableFeaturesState<TItem>,\n options: UseTableSortOptions,\n): TableFeaturesState<TItem> {\n const { columns } = tableState;\n const { sortState, defaultSortState, onSortChange: onSortChangeProp = noop } = 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 onSortChange = useEventCallback(onSortChangeProp);\n\n const toggleColumnSort = React.useCallback(\n (e: React.SyntheticEvent, columnId: TableColumnId | undefined) => {\n setSorted(s => {\n const newState = { ...s, sortColumn: columnId };\n if (s.sortColumn === columnId) {\n newState.sortDirection = s.sortDirection === 'ascending' ? 'descending' : 'ascending';\n } else {\n newState.sortDirection = 'ascending';\n }\n\n onSortChange?.(e, newState);\n return newState;\n });\n },\n [onSortChange, setSorted],\n );\n\n const setColumnSort: TableSortState<TItem>['setColumnSort'] = (e, nextSortColumn, nextSortDirection) => {\n const newState = { sortColumn: nextSortColumn, sortDirection: nextSortDirection };\n onSortChange?.(e, newState);\n setSorted(newState);\n };\n\n const sort = React.useCallback(\n <TRowState extends TableRowData<TItem>>(rows: TRowState[]) => {\n return rows.slice().sort((a, b) => {\n const sortColumnDef = columns.find(column => column.columnId === sortColumn);\n if (!sortColumnDef?.compare) {\n return 0;\n }\n\n const mod = sortDirection === 'ascending' ? 1 : -1;\n return sortColumnDef.compare(a.item, b.item) * mod;\n });\n },\n [columns, sortColumn, sortDirection],\n );\n\n const getSortDirection: TableSortState<TItem>['getSortDirection'] = (columnId: TableColumnId) => {\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"],"names":["React","useControllableState","useEventCallback","noop","undefined","defaultTableSortState","getSortDirection","setColumnSort","sort","rows","sortColumn","sortDirection","toggleColumnSort","useTableSort","options","tableState","useTableSortState","columns","sortState","defaultSortState","onSortChange","onSortChangeProp","sorted","setSorted","initialState","defaultState","state","useCallback","e","columnId","s","newState","nextSortColumn","nextSortDirection","slice","a","b","sortColumnDef","find","column","compare","mod","item"],"mappings":";;;;;;;;;;;yBAaaK;eAAAA;;gBASGQ;;;IAQAG,iBAAAA;;;;;iEA9BO,QAAQ;gCACwB,4BAA4B;AAUnF,MAAMb,OAAO,IAAYC;AAElB,8BAAuD;IAC5DE,kBAAkB,IAAM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Q;IACZ;IAEA,MAAMvB,OAAOR,OAAM2B,WAAW,CAC5B,CAAwClB;QACtC,OAAOA,KAAKyB,KAAK,GAAG1B,IAAI,CAAC,CAAC2B,GAAGC;YAC3B,MAAMC,gBAAgBpB,QAAQqB,IAAI,CAACC,CAAAA,SAAUA,OAAOV,QAAQ,KAAKnB;YACjE,IAAI,EAAC2B,kBAAAA,QAAAA,kBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,cAAeG,OAAAA,AAAO,GAAE;gBAC3B,OAAO;YACT;YAEA,MAAMC,MAAM9B,kBAAkB,cAAc,IAAI,CAAC;YACjD,OAAO0B,cAAcG,OAAO,CAACL,EAAEO,IAAI,EAAEN,EAAEM,IAAI,IAAID;QACjD;IACF,GACA;QAACxB;QAASP;QAAYC;KAAc;IAGtC,MAAML,mBAA8D,CAACuB;QACnE,OAAOnB,eAAemB,WAAWlB,gBAAgBP;IACnD;IAEA,OAAO;QACL,GAAGW,UAAU;QACbP,MAAM;YACJA;YACAE;YACAC;YACAJ;YACAK;YACAN;QACF;IACF;AACF"}
@@ -133,13 +133,18 @@ function adjustColumnWidthsToFitContainer(state, containerWidth) {
133
133
  // We start at the beginning and assign the columns their ideal width
134
134
  while(i < newState.length && difference > 0){
135
135
  const currentCol = getColumnByIndex(newState, i);
136
+ if (!currentCol) {
137
+ break;
138
+ }
136
139
  const colAdjustment = Math.min(currentCol.idealWidth - currentCol.width, difference);
137
140
  newState = setColumnProperty(newState, currentCol.columnId, 'width', currentCol.width + colAdjustment);
138
141
  difference -= colAdjustment;
139
142
  // if there is still empty space, after all columns are their ideal sizes, assign it to the last column
140
143
  if (i === newState.length - 1 && difference !== 0) {
141
144
  const lastCol = getColumnByIndex(newState, i);
142
- newState = setColumnProperty(newState, lastCol.columnId, 'width', lastCol.width + difference);
145
+ if (lastCol) {
146
+ newState = setColumnProperty(newState, lastCol.columnId, 'width', lastCol.width + difference);
147
+ }
143
148
  }
144
149
  i++;
145
150
  }
@@ -149,6 +154,10 @@ function adjustColumnWidthsToFitContainer(state, containerWidth) {
149
154
  let j = newState.length - 1;
150
155
  while(j >= 0 && difference > 0){
151
156
  const currentCol = getColumnByIndex(newState, j);
157
+ if (!currentCol) {
158
+ j--;
159
+ continue;
160
+ }
152
161
  if (currentCol.width > currentCol.minWidth) {
153
162
  const colAdjustment = Math.min(currentCol.width - currentCol.minWidth, difference);
154
163
  difference -= colAdjustment;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/columnResizeUtils.ts"],"sourcesContent":["import { TableColumnDefinition, ColumnWidthState, TableColumnId, TableColumnSizingOptions } from '../hooks';\n\nconst DEFAULT_WIDTH = 150;\nconst DEFAULT_MIN_WIDTH = 100;\n\n/**\n * This function takes the column definitions and the curent ColumnWidthState and returns new state.\n * - It uses existing state for existing columns.\n * - It removes any state for columns no longer present.\n * - It checks if any column has been replaced and returns updated state if so\n * - It returns old state if no changes in the state have been made (so that react doesn't call effects)\n * @param columns\n * @param state\n * @returns\n */\n\nexport function columnDefinitionsToState<T>(\n columns: TableColumnDefinition<T>[],\n state: ColumnWidthState[] = [],\n columnSizingOptions: TableColumnSizingOptions = {},\n): ColumnWidthState[] {\n let updated = false;\n const stateMap = new Map(state.map(s => [s.columnId, s]));\n\n const updatedState = columns.map(column => {\n const existingColumnState = stateMap.get(column.columnId);\n\n if (existingColumnState) {\n const {\n idealWidth = existingColumnState.idealWidth,\n minWidth = existingColumnState.minWidth,\n padding = existingColumnState.padding,\n } = columnSizingOptions[column.columnId] ?? {};\n\n if (\n idealWidth !== existingColumnState.idealWidth ||\n minWidth !== existingColumnState.minWidth ||\n padding !== existingColumnState.padding\n ) {\n updated = true;\n return {\n ...existingColumnState,\n idealWidth,\n width: idealWidth,\n minWidth,\n padding,\n };\n }\n return existingColumnState;\n }\n\n const {\n defaultWidth,\n idealWidth = DEFAULT_WIDTH,\n minWidth = DEFAULT_MIN_WIDTH,\n padding,\n } = columnSizingOptions[column.columnId] ?? {};\n\n updated = true;\n return {\n columnId: column.columnId,\n width: Math.max(defaultWidth ?? idealWidth, minWidth),\n minWidth,\n idealWidth: Math.max(defaultWidth ?? idealWidth, minWidth),\n padding: padding ?? 16,\n };\n });\n\n // If the length of the new state changed (column was added or removed) or any of\n // the individual states has a new reference (column was replaced),\n // we have to reset the column widths to their ideal width (because the column which was last may not be last now).\n // Then the adjustColumnWidthsToFitContainer can do its job and properly stretch the last column.\n if (updatedState.length !== state.length || updated) {\n const column = updatedState.find(col => col.width > col.idealWidth);\n if (column) {\n column.width = column.idealWidth;\n }\n\n updated = true;\n }\n\n return updated ? updatedState : state;\n}\n\nexport function getColumnById(state: ColumnWidthState[], columnId: TableColumnId) {\n return state.find(c => c.columnId === columnId);\n}\n\nexport function getColumnByIndex(state: ColumnWidthState[], index: number) {\n return state[index];\n}\n\nexport function getTotalWidth(state: ColumnWidthState[]): number {\n return state.reduce((sum, column) => sum + column.width + column.padding, 0);\n}\n\nexport function getLength(state: ColumnWidthState[]) {\n return state.length;\n}\n\nexport function getColumnWidth(state: ColumnWidthState[], columnId: TableColumnId): number {\n const column = getColumnById(state, columnId);\n return column?.width ?? 0;\n}\n\n/**\n * This function takes the current state and returns an updated state, so that it can be set.\n * The reason for this is that we can update the state multiple times before commiting to render.\n * This is an optimization and also prevents flickering.\n * It also returns new copy of the state only if the value is different than the one currently in\n * the state, further preventing unnecessary updates.\n * @param localState\n * @param columnId\n * @param property\n * @param value\n * @returns\n */\nexport function setColumnProperty(\n localState: ColumnWidthState[],\n columnId: TableColumnId,\n property: keyof ColumnWidthState,\n value: number,\n) {\n const currentColumn = getColumnById(localState, columnId);\n\n if (!currentColumn || currentColumn?.[property] === value) {\n return localState;\n }\n\n const updatedColumn = { ...currentColumn, [property]: value };\n\n const newState = localState.reduce((acc, current) => {\n if (current.columnId === updatedColumn.columnId) {\n return [...acc, updatedColumn];\n }\n return [...acc, current];\n }, [] as ColumnWidthState[]);\n\n return newState;\n}\n\n/**\n * This function takes the state and container width and makes sure the each column in the state\n * is its optimal width, and that the columns\n * a) fit to the container\n * b) always fill the whole container\n * @param state\n * @param containerWidth\n * @returns\n */\nexport function adjustColumnWidthsToFitContainer(state: ColumnWidthState[], containerWidth: number) {\n let newState = state;\n const totalWidth = getTotalWidth(newState);\n\n // The total width is smaller, we are expanding columns\n if (totalWidth < containerWidth) {\n let difference = containerWidth - totalWidth;\n let i = 0;\n // We start at the beginning and assign the columns their ideal width\n while (i < newState.length && difference > 0) {\n const currentCol = getColumnByIndex(newState, i);\n const colAdjustment = Math.min(currentCol.idealWidth - currentCol.width, difference);\n newState = setColumnProperty(newState, currentCol.columnId, 'width', currentCol.width + colAdjustment);\n difference -= colAdjustment;\n\n // if there is still empty space, after all columns are their ideal sizes, assign it to the last column\n if (i === newState.length - 1 && difference !== 0) {\n const lastCol = getColumnByIndex(newState, i);\n newState = setColumnProperty(newState, lastCol.columnId, 'width', lastCol.width + difference);\n }\n\n i++;\n }\n }\n\n // The total width is larger than container, we need to squash the columns\n else if (totalWidth >= containerWidth) {\n let difference = totalWidth - containerWidth;\n // We start with the last column\n let j = newState.length - 1;\n while (j >= 0 && difference > 0) {\n const currentCol = getColumnByIndex(newState, j);\n if (currentCol.width > currentCol.minWidth) {\n const colAdjustment = Math.min(currentCol.width - currentCol.minWidth, difference);\n difference -= colAdjustment;\n newState = setColumnProperty(newState, currentCol.columnId, 'width', currentCol.width - colAdjustment);\n }\n j--;\n }\n }\n\n return newState;\n}\n"],"names":["DEFAULT_WIDTH","DEFAULT_MIN_WIDTH","columnDefinitionsToState","columns","state","columnSizingOptions","updated","stateMap","Map","map","s","columnId","updatedState","column","existingColumnState","get","idealWidth","minWidth","padding","width","defaultWidth","Math","max","length","find","col","getColumnById","c","getColumnByIndex","index","getTotalWidth","reduce","sum","getLength","getColumnWidth","setColumnProperty","localState","property","value","currentColumn","updatedColumn","newState","acc","current","adjustColumnWidthsToFitContainer","containerWidth","totalWidth","difference","i","currentCol","colAdjustment","min","lastCol","j"],"mappings":";;;;;;;;;;;IAsJgB4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D;QAC9B,gCAAgC;QAChC,IAAIQ,IAAIZ,SAASlB,MAAM,GAAG;QAC1B,MAAO8B,KAAK,KAAKN,aAAa,EAAG;YAC/B,MAAME,aAAarB,iBAAiBa,UAAUY;YAC9C,IAAIJ,WAAW9B,KAAK,GAAG8B,WAAWhC,QAAQ,EAAE;gBAC1C,MAAMiC,gBAAgB7B,KAAK8B,GAAG,CAACF,WAAW9B,KAAK,GAAG8B,WAAWhC,QAAQ,EAAE8B;gBACvEA,cAAcG;gBACdT,WAAWN,kBAAkBM,UAAUQ,WAAWtC,QAAQ,EAAE,SAASsC,WAAW9B,KAAK,GAAG+B;YAC1F;YACAG;QACF;IACF;IAEA,OAAOZ;AACT"}
1
+ {"version":3,"sources":["../src/utils/columnResizeUtils.ts"],"sourcesContent":["import { TableColumnDefinition, ColumnWidthState, TableColumnId, TableColumnSizingOptions } from '../hooks';\n\nconst DEFAULT_WIDTH = 150;\nconst DEFAULT_MIN_WIDTH = 100;\n\n/**\n * This function takes the column definitions and the curent ColumnWidthState and returns new state.\n * - It uses existing state for existing columns.\n * - It removes any state for columns no longer present.\n * - It checks if any column has been replaced and returns updated state if so\n * - It returns old state if no changes in the state have been made (so that react doesn't call effects)\n * @param columns\n * @param state\n * @returns\n */\n\nexport function columnDefinitionsToState<T>(\n columns: TableColumnDefinition<T>[],\n state: ColumnWidthState[] = [],\n columnSizingOptions: TableColumnSizingOptions = {},\n): ColumnWidthState[] {\n let updated = false;\n const stateMap = new Map(state.map(s => [s.columnId, s]));\n\n const updatedState = columns.map(column => {\n const existingColumnState = stateMap.get(column.columnId);\n\n if (existingColumnState) {\n const {\n idealWidth = existingColumnState.idealWidth,\n minWidth = existingColumnState.minWidth,\n padding = existingColumnState.padding,\n } = columnSizingOptions[column.columnId] ?? {};\n\n if (\n idealWidth !== existingColumnState.idealWidth ||\n minWidth !== existingColumnState.minWidth ||\n padding !== existingColumnState.padding\n ) {\n updated = true;\n return {\n ...existingColumnState,\n idealWidth,\n width: idealWidth,\n minWidth,\n padding,\n };\n }\n return existingColumnState;\n }\n\n const {\n defaultWidth,\n idealWidth = DEFAULT_WIDTH,\n minWidth = DEFAULT_MIN_WIDTH,\n padding,\n } = columnSizingOptions[column.columnId] ?? {};\n\n updated = true;\n return {\n columnId: column.columnId,\n width: Math.max(defaultWidth ?? idealWidth, minWidth),\n minWidth,\n idealWidth: Math.max(defaultWidth ?? idealWidth, minWidth),\n padding: padding ?? 16,\n };\n });\n\n // If the length of the new state changed (column was added or removed) or any of\n // the individual states has a new reference (column was replaced),\n // we have to reset the column widths to their ideal width (because the column which was last may not be last now).\n // Then the adjustColumnWidthsToFitContainer can do its job and properly stretch the last column.\n if (updatedState.length !== state.length || updated) {\n const column = updatedState.find(col => col.width > col.idealWidth);\n if (column) {\n column.width = column.idealWidth;\n }\n\n updated = true;\n }\n\n return updated ? updatedState : state;\n}\n\nexport function getColumnById(state: ColumnWidthState[], columnId: TableColumnId): ColumnWidthState | undefined {\n return state.find(c => c.columnId === columnId);\n}\n\nexport function getColumnByIndex(state: ColumnWidthState[], index: number): ColumnWidthState | undefined {\n return state[index];\n}\n\nexport function getTotalWidth(state: ColumnWidthState[]): number {\n return state.reduce((sum, column) => sum + column.width + column.padding, 0);\n}\n\nexport function getLength(state: ColumnWidthState[]): number {\n return state.length;\n}\n\nexport function getColumnWidth(state: ColumnWidthState[], columnId: TableColumnId): number {\n const column = getColumnById(state, columnId);\n return column?.width ?? 0;\n}\n\n/**\n * This function takes the current state and returns an updated state, so that it can be set.\n * The reason for this is that we can update the state multiple times before commiting to render.\n * This is an optimization and also prevents flickering.\n * It also returns new copy of the state only if the value is different than the one currently in\n * the state, further preventing unnecessary updates.\n * @param localState\n * @param columnId\n * @param property\n * @param value\n * @returns\n */\nexport function setColumnProperty(\n localState: ColumnWidthState[],\n columnId: TableColumnId,\n property: keyof ColumnWidthState,\n value: number,\n): ColumnWidthState[] {\n const currentColumn = getColumnById(localState, columnId);\n\n if (!currentColumn || currentColumn?.[property] === value) {\n return localState;\n }\n\n const updatedColumn = { ...currentColumn, [property]: value };\n\n const newState = localState.reduce((acc, current) => {\n if (current.columnId === updatedColumn.columnId) {\n return [...acc, updatedColumn];\n }\n return [...acc, current];\n }, [] as ColumnWidthState[]);\n\n return newState;\n}\n\n/**\n * This function takes the state and container width and makes sure the each column in the state\n * is its optimal width, and that the columns\n * a) fit to the container\n * b) always fill the whole container\n * @param state\n * @param containerWidth\n * @returns\n */\nexport function adjustColumnWidthsToFitContainer(\n state: ColumnWidthState[],\n containerWidth: number,\n): ColumnWidthState[] {\n let newState = state;\n const totalWidth = getTotalWidth(newState);\n\n // The total width is smaller, we are expanding columns\n if (totalWidth < containerWidth) {\n let difference = containerWidth - totalWidth;\n let i = 0;\n // We start at the beginning and assign the columns their ideal width\n while (i < newState.length && difference > 0) {\n const currentCol = getColumnByIndex(newState, i);\n if (!currentCol) {\n break;\n }\n const colAdjustment = Math.min(currentCol.idealWidth - currentCol.width, difference);\n newState = setColumnProperty(newState, currentCol.columnId, 'width', currentCol.width + colAdjustment);\n difference -= colAdjustment;\n\n // if there is still empty space, after all columns are their ideal sizes, assign it to the last column\n if (i === newState.length - 1 && difference !== 0) {\n const lastCol = getColumnByIndex(newState, i);\n if (lastCol) {\n newState = setColumnProperty(newState, lastCol.columnId, 'width', lastCol.width + difference);\n }\n }\n\n i++;\n }\n }\n\n // The total width is larger than container, we need to squash the columns\n else if (totalWidth >= containerWidth) {\n let difference = totalWidth - containerWidth;\n // We start with the last column\n let j = newState.length - 1;\n while (j >= 0 && difference > 0) {\n const currentCol = getColumnByIndex(newState, j);\n if (!currentCol) {\n j--;\n continue;\n }\n if (currentCol.width > currentCol.minWidth) {\n const colAdjustment = Math.min(currentCol.width - currentCol.minWidth, difference);\n difference -= colAdjustment;\n newState = setColumnProperty(newState, currentCol.columnId, 'width', currentCol.width - colAdjustment);\n }\n j--;\n }\n }\n\n return newState;\n}\n"],"names":["DEFAULT_WIDTH","DEFAULT_MIN_WIDTH","columnDefinitionsToState","columns","state","columnSizingOptions","updated","stateMap","Map","map","s","columnId","updatedState","column","existingColumnState","get","idealWidth","minWidth","padding","width","defaultWidth","Math","max","length","find","col","getColumnById","c","getColumnByIndex","index","getTotalWidth","reduce","sum","getLength","getColumnWidth","setColumnProperty","localState","property","value","currentColumn","updatedColumn","newState","acc","current","adjustColumnWidthsToFitContainer","containerWidth","totalWidth","difference","i","currentCol","colAdjustment","min","lastCol","j"],"mappings":";;;;;;;;;;;IAsJgB4C,gCAAAA;;;IAtIA1C,wBAAAA;;;iBAoEAwB;;;oBAIAE;;;kBAYAM;;;aAJAD;;;iBAJAH;;;IAyBAK,iBAAAA;;;;AAnHhB,MAAMnC,gBAAgB;AACtB,MAAMC,oBAAoB;AAanB,kCACLE,OAAmC,EACnCC,QAA4B,EAAE,EAC9BC,sBAAgD,CAAC,CAAC;IAElD,IAAIC,UAAU;IACd,MAAMC,WAAW,IAAIC,IAAIJ,MAAMK,GAAG,CAACC,CAAAA,IAAK;YAACA,EAAEC,QAAQ;YAAED;SAAE;IAEvD,MAAME,eAAeT,QAAQM,GAAG,CAACI,CAAAA;QAC/B,MAAMC,sBAAsBP,SAASQ,GAAG,CAACF,OAAOF,QAAQ;QAExD,IAAIG,qBAAqB;gBAKnBT;YAJJ,MAAM,EACJW,aAAaF,oBAAoBE,UAAU,EAC3CC,WAAWH,oBAAoBG,QAAQ,EACvCC,UAAUJ,oBAAoBI,OAAO,EACtC,GAAGb,CAAAA,uCAAAA,mBAAmB,CAACQ,OAAOF,SAAQ,AAAC,MAAA,QAApCN,yCAAAA,KAAAA,IAAAA,uCAAwC,CAAC;YAE7C,IACEW,eAAeF,oBAAoBE,UAAU,IAC7CC,aAAaH,oBAAoBG,QAAQ,IACzCC,YAAYJ,oBAAoBI,OAAO,EACvC;gBACAZ,UAAU;gBACV,OAAO;oBACL,GAAGQ,mBAAmB;oBACtBE;oBACAG,OAAOH;oBACPC;oBACAC;gBACF;YACF;YACA,OAAOJ;QACT;YAOIT;QALJ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