@fluentui/react-table 9.8.8 → 9.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +177 -1
- package/CHANGELOG.md +47 -2
- package/dist/index.d.ts +7 -2
- package/lib/components/DataGrid/useDataGrid.js +2 -2
- package/lib/components/DataGrid/useDataGrid.js.map +1 -1
- package/lib/components/DataGridHeaderCell/DataGridHeaderCell.types.js.map +1 -1
- package/lib/components/DataGridHeaderCell/useDataGridHeaderCell.js +13 -3
- package/lib/components/DataGridHeaderCell/useDataGridHeaderCell.js.map +1 -1
- package/lib/components/DataGridRow/useDataGridRow.js +4 -4
- package/lib/components/DataGridRow/useDataGridRow.js.map +1 -1
- package/lib/components/DataGridSelectionCell/useDataGridSelectionCell.js +2 -2
- package/lib/components/DataGridSelectionCell/useDataGridSelectionCell.js.map +1 -1
- package/lib/components/TableHeaderCell/TableHeaderCell.types.js.map +1 -1
- package/lib/components/TableHeaderCell/useTableHeaderCell.js +2 -1
- package/lib/components/TableHeaderCell/useTableHeaderCell.js.map +1 -1
- package/lib/components/TableResizeHandle/useTableResizeHandle.js +2 -2
- package/lib/components/TableResizeHandle/useTableResizeHandle.js.map +1 -1
- package/lib/contexts/columnIdContext.js +4 -2
- package/lib/contexts/columnIdContext.js.map +1 -1
- package/lib/contexts/rowIdContext.js +4 -2
- package/lib/contexts/rowIdContext.js.map +1 -1
- package/lib/contexts/tableContext.js +4 -2
- package/lib/contexts/tableContext.js.map +1 -1
- package/lib/hooks/types.js.map +1 -1
- package/lib/hooks/useKeyboardResizing.js +4 -4
- package/lib/hooks/useKeyboardResizing.js.map +1 -1
- package/lib/hooks/useMeasureElement.js +1 -4
- package/lib/hooks/useMeasureElement.js.map +1 -1
- package/lib/hooks/useTableColumnResizeMouseHandler.js +11 -17
- package/lib/hooks/useTableColumnResizeMouseHandler.js.map +1 -1
- package/lib/hooks/useTableColumnSizing.js +3 -4
- package/lib/hooks/useTableColumnSizing.js.map +1 -1
- package/lib/hooks/useTableFeatures.js +2 -3
- package/lib/hooks/useTableFeatures.js.map +1 -1
- package/lib/hooks/useTableSelection.js +3 -5
- package/lib/hooks/useTableSelection.js.map +1 -1
- package/lib/hooks/useTableSort.js +3 -6
- package/lib/hooks/useTableSort.js.map +1 -1
- package/lib/utils/columnResizeUtils.js +2 -4
- package/lib/utils/columnResizeUtils.js.map +1 -1
- package/lib/utils/isColumnSortable.js +3 -0
- package/lib/utils/isColumnSortable.js.map +1 -0
- package/lib-commonjs/components/DataGrid/useDataGrid.js +2 -2
- package/lib-commonjs/components/DataGrid/useDataGrid.js.map +1 -1
- package/lib-commonjs/components/DataGridHeaderCell/useDataGridHeaderCell.js +13 -3
- package/lib-commonjs/components/DataGridHeaderCell/useDataGridHeaderCell.js.map +1 -1
- package/lib-commonjs/components/DataGridRow/useDataGridRow.js +4 -4
- package/lib-commonjs/components/DataGridRow/useDataGridRow.js.map +1 -1
- package/lib-commonjs/components/DataGridSelectionCell/useDataGridSelectionCell.js +2 -2
- package/lib-commonjs/components/DataGridSelectionCell/useDataGridSelectionCell.js.map +1 -1
- package/lib-commonjs/components/TableHeaderCell/useTableHeaderCell.js +2 -1
- package/lib-commonjs/components/TableHeaderCell/useTableHeaderCell.js.map +1 -1
- package/lib-commonjs/components/TableResizeHandle/useTableResizeHandle.js +2 -2
- package/lib-commonjs/components/TableResizeHandle/useTableResizeHandle.js.map +1 -1
- package/lib-commonjs/contexts/columnIdContext.js +4 -2
- package/lib-commonjs/contexts/columnIdContext.js.map +1 -1
- package/lib-commonjs/contexts/rowIdContext.js +4 -2
- package/lib-commonjs/contexts/rowIdContext.js.map +1 -1
- package/lib-commonjs/contexts/tableContext.js +4 -2
- package/lib-commonjs/contexts/tableContext.js.map +1 -1
- package/lib-commonjs/hooks/useKeyboardResizing.js +4 -4
- package/lib-commonjs/hooks/useKeyboardResizing.js.map +1 -1
- package/lib-commonjs/hooks/useMeasureElement.js +1 -4
- package/lib-commonjs/hooks/useMeasureElement.js.map +1 -1
- package/lib-commonjs/hooks/useTableColumnResizeMouseHandler.js +11 -17
- package/lib-commonjs/hooks/useTableColumnResizeMouseHandler.js.map +1 -1
- package/lib-commonjs/hooks/useTableColumnSizing.js +3 -4
- package/lib-commonjs/hooks/useTableColumnSizing.js.map +1 -1
- package/lib-commonjs/hooks/useTableFeatures.js +2 -3
- package/lib-commonjs/hooks/useTableFeatures.js.map +1 -1
- package/lib-commonjs/hooks/useTableSelection.js +3 -5
- package/lib-commonjs/hooks/useTableSelection.js.map +1 -1
- package/lib-commonjs/hooks/useTableSort.js +3 -6
- package/lib-commonjs/hooks/useTableSort.js.map +1 -1
- package/lib-commonjs/utils/columnResizeUtils.js +2 -4
- package/lib-commonjs/utils/columnResizeUtils.js.map +1 -1
- package/lib-commonjs/utils/isColumnSortable.js +13 -0
- package/lib-commonjs/utils/isColumnSortable.js.map +1 -0
- package/package.json +13 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["isColumnSortable.ts"],"sourcesContent":["import { TableColumnDefinition } from '../hooks/types';\n\nexport function isColumnSortable(column: TableColumnDefinition<unknown>) {\n return column.compare.length > 0;\n}\n"],"names":["isColumnSortable","column","compare","length"],"mappings":"AAEA,OAAO,SAASA,iBAAiBC,MAAsC;IACrE,OAAOA,OAAOC,OAAO,CAACC,MAAM,GAAG;AACjC"}
|
|
@@ -50,8 +50,8 @@ const useDataGrid_unstable = (props, ref)=>{
|
|
|
50
50
|
const innerRef = _react.useRef(null);
|
|
51
51
|
const { findFirstFocusable, findLastFocusable } = (0, _reacttabster.useFocusFinders)();
|
|
52
52
|
const onKeyDown = (0, _reactutilities.useEventCallback)((e)=>{
|
|
53
|
-
var _props_onKeyDown
|
|
54
|
-
(_props_onKeyDown =
|
|
53
|
+
var _props_onKeyDown;
|
|
54
|
+
(_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, e);
|
|
55
55
|
focusMode === 'composite' && onCompositeKeyDown(e);
|
|
56
56
|
// handle ctrl+home and ctrl+end
|
|
57
57
|
if (!innerRef.current || !e.ctrlKey || e.defaultPrevented) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useDataGrid.js"],"sourcesContent":["import * as React from 'react';\nimport { useArrowNavigationGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport { useTable_unstable } from '../Table/useTable';\nimport { useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { End, Home } from '@fluentui/keyboard-keys';\nimport { useTableFeatures, useTableSort, useTableSelection, useTableColumnSizing_unstable, useTableCompositeNavigation } from '../../hooks';\nimport { CELL_WIDTH } from '../TableSelectionCell';\n/**\n * Create the state required to render DataGrid.\n *\n * The returned state can be modified with hooks such as useDataGridStyles_unstable,\n * before being passed to renderDataGrid_unstable.\n *\n * @param props - props from this instance of DataGrid\n * @param ref - reference to root HTMLElement of DataGrid\n */ export const useDataGrid_unstable = (props, ref)=>{\n const { items, columns, focusMode = 'cell', selectionMode, onSortChange, onSelectionChange, defaultSortState, sortState, selectedItems, defaultSelectedItems, subtleSelection = false, selectionAppearance = 'brand', getRowId, resizableColumns, columnSizingOptions, onColumnResize, containerWidthOffset } = props;\n const widthOffset = containerWidthOffset !== null && containerWidthOffset !== void 0 ? containerWidthOffset : selectionMode ? -CELL_WIDTH : 0;\n const gridTabsterAttribute = useArrowNavigationGroup({\n axis: 'grid'\n });\n const { onTableKeyDown: onCompositeKeyDown, tableTabsterAttribute: compositeTabsterAttribute, tableRowTabsterAttribute: compositeRowTabsterAttribute } = useTableCompositeNavigation();\n const tableState = useTableFeatures({\n items,\n columns,\n getRowId\n }, [\n useTableSort({\n defaultSortState,\n sortState,\n onSortChange\n }),\n useTableSelection({\n defaultSelectedItems,\n selectedItems,\n onSelectionChange,\n selectionMode: selectionMode !== null && selectionMode !== void 0 ? selectionMode : 'multiselect'\n }),\n useTableColumnSizing_unstable({\n onColumnResize,\n columnSizingOptions,\n // The selection cell is not part of the columns, therefore its width needs to be subtracted\n // from the container to make sure the columns don't overflow the table.\n containerWidthOffset: widthOffset\n })\n ]);\n const innerRef = React.useRef(null);\n const { findFirstFocusable, findLastFocusable } = useFocusFinders();\n const onKeyDown = useEventCallback((e)=>{\n var _props_onKeyDown
|
|
1
|
+
{"version":3,"sources":["useDataGrid.js"],"sourcesContent":["import * as React from 'react';\nimport { useArrowNavigationGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport { useTable_unstable } from '../Table/useTable';\nimport { useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { End, Home } from '@fluentui/keyboard-keys';\nimport { useTableFeatures, useTableSort, useTableSelection, useTableColumnSizing_unstable, useTableCompositeNavigation } from '../../hooks';\nimport { CELL_WIDTH } from '../TableSelectionCell';\n/**\n * Create the state required to render DataGrid.\n *\n * The returned state can be modified with hooks such as useDataGridStyles_unstable,\n * before being passed to renderDataGrid_unstable.\n *\n * @param props - props from this instance of DataGrid\n * @param ref - reference to root HTMLElement of DataGrid\n */ export const useDataGrid_unstable = (props, ref)=>{\n const { items, columns, focusMode = 'cell', selectionMode, onSortChange, onSelectionChange, defaultSortState, sortState, selectedItems, defaultSelectedItems, subtleSelection = false, selectionAppearance = 'brand', getRowId, resizableColumns, columnSizingOptions, onColumnResize, containerWidthOffset } = props;\n const widthOffset = containerWidthOffset !== null && containerWidthOffset !== void 0 ? containerWidthOffset : selectionMode ? -CELL_WIDTH : 0;\n const gridTabsterAttribute = useArrowNavigationGroup({\n axis: 'grid'\n });\n const { onTableKeyDown: onCompositeKeyDown, tableTabsterAttribute: compositeTabsterAttribute, tableRowTabsterAttribute: compositeRowTabsterAttribute } = useTableCompositeNavigation();\n const tableState = useTableFeatures({\n items,\n columns,\n getRowId\n }, [\n useTableSort({\n defaultSortState,\n sortState,\n onSortChange\n }),\n useTableSelection({\n defaultSelectedItems,\n selectedItems,\n onSelectionChange,\n selectionMode: selectionMode !== null && selectionMode !== void 0 ? selectionMode : 'multiselect'\n }),\n useTableColumnSizing_unstable({\n onColumnResize,\n columnSizingOptions,\n // The selection cell is not part of the columns, therefore its width needs to be subtracted\n // from the container to make sure the columns don't overflow the table.\n containerWidthOffset: widthOffset\n })\n ]);\n const innerRef = React.useRef(null);\n const { findFirstFocusable, findLastFocusable } = useFocusFinders();\n const onKeyDown = useEventCallback((e)=>{\n var _props_onKeyDown;\n (_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, e);\n focusMode === 'composite' && onCompositeKeyDown(e);\n // handle ctrl+home and ctrl+end\n if (!innerRef.current || !e.ctrlKey || e.defaultPrevented) {\n return;\n }\n if (e.key === Home) {\n const firstRow = innerRef.current.querySelector('[role=\"row\"]');\n if (firstRow) {\n var _findFirstFocusable;\n (_findFirstFocusable = findFirstFocusable(firstRow)) === null || _findFirstFocusable === void 0 ? void 0 : _findFirstFocusable.focus();\n }\n }\n if (e.key === End) {\n const rows = innerRef.current.querySelectorAll('[role=\"row\"]');\n if (rows.length) {\n var _findLastFocusable;\n const lastRow = rows.item(rows.length - 1);\n (_findLastFocusable = findLastFocusable(lastRow)) === null || _findLastFocusable === void 0 ? void 0 : _findLastFocusable.focus();\n }\n }\n });\n const baseTableState = useTable_unstable({\n role: 'grid',\n as: 'div',\n noNativeElements: true,\n ...focusMode === 'cell' && gridTabsterAttribute,\n ...focusMode === 'composite' && compositeTabsterAttribute,\n ...props,\n onKeyDown,\n ...resizableColumns ? tableState.columnSizing_unstable.getTableProps(props) : {}\n }, useMergedRefs(ref, tableState.tableRef, innerRef));\n return {\n ...baseTableState,\n focusMode,\n tableState,\n selectableRows: !!selectionMode,\n subtleSelection,\n selectionAppearance,\n resizableColumns,\n compositeRowTabsterAttribute\n };\n};\n"],"names":["useDataGrid_unstable","props","ref","items","columns","focusMode","selectionMode","onSortChange","onSelectionChange","defaultSortState","sortState","selectedItems","defaultSelectedItems","subtleSelection","selectionAppearance","getRowId","resizableColumns","columnSizingOptions","onColumnResize","containerWidthOffset","widthOffset","CELL_WIDTH","gridTabsterAttribute","useArrowNavigationGroup","axis","onTableKeyDown","onCompositeKeyDown","tableTabsterAttribute","compositeTabsterAttribute","tableRowTabsterAttribute","compositeRowTabsterAttribute","useTableCompositeNavigation","tableState","useTableFeatures","useTableSort","useTableSelection","useTableColumnSizing_unstable","innerRef","React","useRef","findFirstFocusable","findLastFocusable","useFocusFinders","onKeyDown","useEventCallback","e","_props_onKeyDown","call","current","ctrlKey","defaultPrevented","key","Home","firstRow","querySelector","_findFirstFocusable","focus","End","rows","querySelectorAll","length","_findLastFocusable","lastRow","item","baseTableState","useTable_unstable","role","as","noNativeElements","columnSizing_unstable","getTableProps","useMergedRefs","tableRef","selectableRows"],"mappings":";;;;+BAeiBA;;;eAAAA;;;;iEAfM;8BACkC;0BACvB;gCACc;8BACtB;uBACoG;oCACnG;AAShB,MAAMA,uBAAuB,CAACC,OAAOC;IAC5C,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,YAAY,MAAM,EAAEC,aAAa,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,SAAS,EAAEC,aAAa,EAAEC,oBAAoB,EAAEC,kBAAkB,KAAK,EAAEC,sBAAsB,OAAO,EAAEC,QAAQ,EAAEC,gBAAgB,EAAEC,mBAAmB,EAAEC,cAAc,EAAEC,oBAAoB,EAAE,GAAGlB;IAChT,MAAMmB,cAAcD,yBAAyB,QAAQA,yBAAyB,KAAK,IAAIA,uBAAuBb,gBAAgB,CAACe,8BAAU,GAAG;IAC5I,MAAMC,uBAAuBC,IAAAA,qCAAuB,EAAC;QACjDC,MAAM;IACV;IACA,MAAM,EAAEC,gBAAgBC,kBAAkB,EAAEC,uBAAuBC,yBAAyB,EAAEC,0BAA0BC,4BAA4B,EAAE,GAAGC,IAAAA,kCAA2B;IACpL,MAAMC,aAAaC,IAAAA,uBAAgB,EAAC;QAChC9B;QACAC;QACAW;IACJ,GAAG;QACCmB,IAAAA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AAIA,mBAAmBL,KAAK;YACnI;QACJ;IACJ;IACA,MAAMQ,iBAAiBC,IAAAA,2BAAiB,EAAC;QACrCC,MAAM;QACNC,IAAI;QACJC,kBAAkB;QAClB,GAAG/D,cAAc,UAAUiB,oBAAoB;QAC/C,GAAGjB,cAAc,eAAeuB,yBAAyB;QACzD,GAAG3B,KAAK;QACR0C;QACA,GAAG3B,mBAAmBgB,WAAWqC,qBAAqB,CAACC,aAAa,CAACrE,SAAS,CAAC,CAAC;IACpF,GAAGsE,IAAAA,6BAAa,EAACrE,KAAK8B,WAAWwC,QAAQ,EAAEnC;IAC3C,OAAO;QACH,GAAG2B,cAAc;QACjB3D;QACA2B;QACAyC,gBAAgB,CAAC,CAACnE;QAClBO;QACAC;QACAE;QACAc;IACJ;AACJ"}
|
|
@@ -15,22 +15,32 @@ const _useTableHeaderCell = require("../TableHeaderCell/useTableHeaderCell");
|
|
|
15
15
|
const _dataGridContext = require("../../contexts/dataGridContext");
|
|
16
16
|
const _columnIdContext = require("../../contexts/columnIdContext");
|
|
17
17
|
const _tableContext = require("../../contexts/tableContext");
|
|
18
|
+
const _isColumnSortable = require("../../utils/isColumnSortable");
|
|
18
19
|
const useDataGridHeaderCell_unstable = (props, ref)=>{
|
|
19
20
|
const columnId = (0, _columnIdContext.useColumnIdContext)();
|
|
20
|
-
const { sortable } = (0, _tableContext.useTableContext)();
|
|
21
|
+
const { sortable: gridSortable } = (0, _tableContext.useTableContext)();
|
|
21
22
|
const toggleColumnSort = (0, _dataGridContext.useDataGridContext_unstable)((ctx)=>ctx.sort.toggleColumnSort);
|
|
23
|
+
const sortable = (0, _dataGridContext.useDataGridContext_unstable)((ctx)=>{
|
|
24
|
+
const columnSortable = !!ctx.columns.find((c)=>c.columnId === columnId && (0, _isColumnSortable.isColumnSortable)(c));
|
|
25
|
+
if (!gridSortable) {
|
|
26
|
+
// if the grid is not sortable - disable sorting on all columns
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return columnSortable;
|
|
30
|
+
});
|
|
22
31
|
const sortDirection = (0, _dataGridContext.useDataGridContext_unstable)((ctx)=>sortable ? ctx.sort.getSortDirection(columnId) : undefined);
|
|
23
32
|
const resizableColumns = (0, _dataGridContext.useDataGridContext_unstable)((ctx)=>ctx.resizableColumns);
|
|
24
33
|
const columnSizing = (0, _dataGridContext.useDataGridContext_unstable)((ctx)=>ctx.columnSizing_unstable);
|
|
25
34
|
// eslint-disable-next-line deprecation/deprecation -- prefer HTMLTableCellElement
|
|
26
35
|
const onClick = (0, _reactutilities.useEventCallback)((e)=>{
|
|
27
|
-
var _props_onClick
|
|
36
|
+
var _props_onClick;
|
|
28
37
|
if (sortable) {
|
|
29
38
|
toggleColumnSort(e, columnId);
|
|
30
39
|
}
|
|
31
|
-
(_props_onClick =
|
|
40
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);
|
|
32
41
|
});
|
|
33
42
|
return (0, _useTableHeaderCell.useTableHeaderCell_unstable)({
|
|
43
|
+
sortable,
|
|
34
44
|
sortDirection,
|
|
35
45
|
as: 'div',
|
|
36
46
|
tabIndex: sortable ? undefined : 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useDataGridHeaderCell.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { useTableHeaderCell_unstable } from '../TableHeaderCell/useTableHeaderCell';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\nimport { useColumnIdContext } from '../../contexts/columnIdContext';\nimport { useTableContext } from '../../contexts/tableContext';\n/**\n * Create the state required to render DataGridHeaderCell.\n *\n * The returned state can be modified with hooks such as useDataGridHeaderCellStyles_unstable,\n * before being passed to renderDataGridHeaderCell_unstable.\n *\n * @param props - props from this instance of DataGridHeaderCell\n * @param ref - reference to root HTMLElement of DataGridHeaderCell\n */ export const useDataGridHeaderCell_unstable = (props, ref)=>{\n const columnId = useColumnIdContext();\n const { sortable } = useTableContext();\n const toggleColumnSort = useDataGridContext_unstable((ctx)=>ctx.sort.toggleColumnSort);\n const sortDirection = useDataGridContext_unstable((ctx)=>sortable ? ctx.sort.getSortDirection(columnId) : undefined);\n const resizableColumns = useDataGridContext_unstable((ctx)=>ctx.resizableColumns);\n const columnSizing = useDataGridContext_unstable((ctx)=>ctx.columnSizing_unstable);\n // eslint-disable-next-line deprecation/deprecation -- prefer HTMLTableCellElement\n const onClick = useEventCallback((e)=>{\n var _props_onClick
|
|
1
|
+
{"version":3,"sources":["useDataGridHeaderCell.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { useTableHeaderCell_unstable } from '../TableHeaderCell/useTableHeaderCell';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\nimport { useColumnIdContext } from '../../contexts/columnIdContext';\nimport { useTableContext } from '../../contexts/tableContext';\nimport { isColumnSortable } from '../../utils/isColumnSortable';\n/**\n * Create the state required to render DataGridHeaderCell.\n *\n * The returned state can be modified with hooks such as useDataGridHeaderCellStyles_unstable,\n * before being passed to renderDataGridHeaderCell_unstable.\n *\n * @param props - props from this instance of DataGridHeaderCell\n * @param ref - reference to root HTMLElement of DataGridHeaderCell\n */ export const useDataGridHeaderCell_unstable = (props, ref)=>{\n const columnId = useColumnIdContext();\n const { sortable: gridSortable } = useTableContext();\n const toggleColumnSort = useDataGridContext_unstable((ctx)=>ctx.sort.toggleColumnSort);\n const sortable = useDataGridContext_unstable((ctx)=>{\n const columnSortable = !!ctx.columns.find((c)=>c.columnId === columnId && isColumnSortable(c));\n if (!gridSortable) {\n // if the grid is not sortable - disable sorting on all columns\n return false;\n }\n return columnSortable;\n });\n const sortDirection = useDataGridContext_unstable((ctx)=>sortable ? ctx.sort.getSortDirection(columnId) : undefined);\n const resizableColumns = useDataGridContext_unstable((ctx)=>ctx.resizableColumns);\n const columnSizing = useDataGridContext_unstable((ctx)=>ctx.columnSizing_unstable);\n // eslint-disable-next-line deprecation/deprecation -- prefer HTMLTableCellElement\n const onClick = useEventCallback((e)=>{\n var _props_onClick;\n if (sortable) {\n toggleColumnSort(e, columnId);\n }\n (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);\n });\n return useTableHeaderCell_unstable({\n sortable,\n sortDirection,\n as: 'div',\n tabIndex: sortable ? undefined : 0,\n ...resizableColumns ? columnSizing.getTableHeaderCellProps(columnId) : {},\n ...props,\n onClick\n }, ref);\n};\n"],"names":["useDataGridHeaderCell_unstable","props","ref","columnId","useColumnIdContext","sortable","gridSortable","useTableContext","toggleColumnSort","useDataGridContext_unstable","ctx","sort","columnSortable","columns","find","c","isColumnSortable","sortDirection","getSortDirection","undefined","resizableColumns","columnSizing","columnSizing_unstable","onClick","useEventCallback","e","_props_onClick","call","useTableHeaderCell_unstable","as","tabIndex","getTableHeaderCellProps"],"mappings":";;;;+BAeiBA;;;eAAAA;;;;iEAfM;gCACU;oCACW;iCACA;iCACT;8BACH;kCACC;AAStB,MAAMA,iCAAiC,CAACC,OAAOC;IACtD,MAAMC,WAAWC,IAAAA,mCAAkB;IACnC,MAAM,EAAEC,UAAUC,YAAY,EAAE,GAAGC,IAAAA,6BAAe;IAClD,MAAMC,mBAAmBC,IAAAA,4CAA2B,EAAC,CAACC,MAAMA,IAAIC,IAAI,CAACH,gBAAgB;IACrF,MAAMH,WAAWI,IAAAA,4CAA2B,EAAC,CAACC;QAC1C,MAAME,iBAAiB,CAAC,CAACF,IAAIG,OAAO,CAACC,IAAI,CAAC,CAACC,IAAIA,EAAEZ,QAAQ,KAAKA,YAAYa,IAAAA,kCAAgB,EAACD;QAC3F,IAAI,CAACT,cAAc;YACf,+DAA+D;YAC/D,OAAO;QACX;QACA,OAAOM;IACX;IACA,MAAMK,gBAAgBR,IAAAA,4CAA2B,EAAC,CAACC,MAAML,WAAWK,IAAIC,IAAI,CAACO,gBAAgB,CAACf,YAAYgB;IAC1G,MAAMC,mBAAmBX,IAAAA,4CAA2B,EAAC,CAACC,MAAMA,IAAIU,gBAAgB;IAChF,MAAMC,eAAeZ,IAAAA,4CAA2B,EAAC,CAACC,MAAMA,IAAIY,qBAAqB;IACjF,kFAAkF;IAClF,MAAMC,UAAUC,IAAAA,gCAAgB,EAAC,CAACC;QAC9B,IAAIC;QACJ,IAAIrB,UAAU;YACVG,iBAAiBiB,GAAGtB;QACxB;QACCuB,CAAAA,iBAAiBzB,MAAMsB,OAAO,AAAD,MAAO,QAAQG,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeC,IAAI,CAAC1B,OAAOwB;IACjH;IACA,OAAOG,IAAAA,+CAA2B,EAAC;QAC/BvB;QACAY;QACAY,IAAI;QACJC,UAAUzB,WAAWc,YAAY;QACjC,GAAGC,mBAAmBC,aAAaU,uBAAuB,CAAC5B,YAAY,CAAC,CAAC;QACzE,GAAGF,KAAK;QACRsB;IACJ,GAAGrB;AACP"}
|
|
@@ -35,20 +35,20 @@ const useDataGridRow_unstable = (props, ref)=>{
|
|
|
35
35
|
const toggleRow = (0, _dataGridContext.useDataGridContext_unstable)((ctx)=>ctx.selection.toggleRow);
|
|
36
36
|
const dataGridContextValue = (0, _dataGridContext.useDataGridContext_unstable)((ctx)=>ctx);
|
|
37
37
|
const onClick = (0, _reactutilities.useEventCallback)((e)=>{
|
|
38
|
-
var _props_onClick
|
|
38
|
+
var _props_onClick;
|
|
39
39
|
if (selectable && !isHeader) {
|
|
40
40
|
toggleRow(e, rowId);
|
|
41
41
|
}
|
|
42
|
-
(_props_onClick =
|
|
42
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);
|
|
43
43
|
});
|
|
44
44
|
const onKeyDown = (0, _reactutilities.useEventCallback)((e)=>{
|
|
45
|
-
var _props_onKeyDown
|
|
45
|
+
var _props_onKeyDown;
|
|
46
46
|
if (selectable && !isHeader && e.key === _keyboardkeys.Space && !(0, _reactutilities.isInteractiveHTMLElement)(e.target)) {
|
|
47
47
|
// stop scrolling
|
|
48
48
|
e.preventDefault();
|
|
49
49
|
toggleRow(e, rowId);
|
|
50
50
|
}
|
|
51
|
-
(_props_onKeyDown =
|
|
51
|
+
(_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, e);
|
|
52
52
|
});
|
|
53
53
|
const baseState = (0, _useTableRow.useTableRow_unstable)({
|
|
54
54
|
appearance,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useDataGridRow.js"],"sourcesContent":["import * as React from 'react';\nimport { isInteractiveHTMLElement, useEventCallback, slot } from '@fluentui/react-utilities';\nimport { Space } from '@fluentui/keyboard-keys';\nimport { useTableRow_unstable } from '../TableRow/useTableRow';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\nimport { DataGridSelectionCell } from '../DataGridSelectionCell/DataGridSelectionCell';\nimport { useTableRowIdContext } from '../../contexts/rowIdContext';\nimport { useIsInTableHeader } from '../../contexts/tableHeaderContext';\n/**\n * Create the state required to render DataGridRow.\n *\n * The returned state can be modified with hooks such as useDataGridRowStyles_unstable,\n * before being passed to renderDataGridRow_unstable.\n *\n * @param props - props from this instance of DataGridRow\n * @param ref - reference to root HTMLElement of DataGridRow\n */ export const useDataGridRow_unstable = (props, ref)=>{\n const rowId = useTableRowIdContext();\n const isHeader = useIsInTableHeader();\n const columnDefs = useDataGridContext_unstable((ctx)=>ctx.columns);\n const selectable = useDataGridContext_unstable((ctx)=>ctx.selectableRows);\n const selected = useDataGridContext_unstable((ctx)=>ctx.selection.isRowSelected(rowId));\n const focusMode = useDataGridContext_unstable((ctx)=>ctx.focusMode);\n const compositeRowTabsterAttribute = useDataGridContext_unstable((ctx)=>ctx.compositeRowTabsterAttribute);\n const tabbable = focusMode === 'row_unstable' || focusMode === 'composite';\n const appearance = useDataGridContext_unstable((ctx)=>{\n if (!isHeader && selectable && ctx.selection.isRowSelected(rowId)) {\n return ctx.selectionAppearance;\n }\n return 'none';\n });\n const toggleRow = useDataGridContext_unstable((ctx)=>ctx.selection.toggleRow);\n const dataGridContextValue = useDataGridContext_unstable((ctx)=>ctx);\n const onClick = useEventCallback((e)=>{\n var _props_onClick
|
|
1
|
+
{"version":3,"sources":["useDataGridRow.js"],"sourcesContent":["import * as React from 'react';\nimport { isInteractiveHTMLElement, useEventCallback, slot } from '@fluentui/react-utilities';\nimport { Space } from '@fluentui/keyboard-keys';\nimport { useTableRow_unstable } from '../TableRow/useTableRow';\nimport { useDataGridContext_unstable } from '../../contexts/dataGridContext';\nimport { DataGridSelectionCell } from '../DataGridSelectionCell/DataGridSelectionCell';\nimport { useTableRowIdContext } from '../../contexts/rowIdContext';\nimport { useIsInTableHeader } from '../../contexts/tableHeaderContext';\n/**\n * Create the state required to render DataGridRow.\n *\n * The returned state can be modified with hooks such as useDataGridRowStyles_unstable,\n * before being passed to renderDataGridRow_unstable.\n *\n * @param props - props from this instance of DataGridRow\n * @param ref - reference to root HTMLElement of DataGridRow\n */ export const useDataGridRow_unstable = (props, ref)=>{\n const rowId = useTableRowIdContext();\n const isHeader = useIsInTableHeader();\n const columnDefs = useDataGridContext_unstable((ctx)=>ctx.columns);\n const selectable = useDataGridContext_unstable((ctx)=>ctx.selectableRows);\n const selected = useDataGridContext_unstable((ctx)=>ctx.selection.isRowSelected(rowId));\n const focusMode = useDataGridContext_unstable((ctx)=>ctx.focusMode);\n const compositeRowTabsterAttribute = useDataGridContext_unstable((ctx)=>ctx.compositeRowTabsterAttribute);\n const tabbable = focusMode === 'row_unstable' || focusMode === 'composite';\n const appearance = useDataGridContext_unstable((ctx)=>{\n if (!isHeader && selectable && ctx.selection.isRowSelected(rowId)) {\n return ctx.selectionAppearance;\n }\n return 'none';\n });\n const toggleRow = useDataGridContext_unstable((ctx)=>ctx.selection.toggleRow);\n const dataGridContextValue = useDataGridContext_unstable((ctx)=>ctx);\n const onClick = useEventCallback((e)=>{\n var _props_onClick;\n if (selectable && !isHeader) {\n toggleRow(e, rowId);\n }\n (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);\n });\n const onKeyDown = useEventCallback((e)=>{\n var _props_onKeyDown;\n if (selectable && !isHeader && e.key === Space && !isInteractiveHTMLElement(e.target)) {\n // stop scrolling\n e.preventDefault();\n toggleRow(e, rowId);\n }\n (_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, e);\n });\n const baseState = useTableRow_unstable({\n appearance,\n 'aria-selected': selectable ? selected : undefined,\n tabIndex: tabbable && !isHeader ? 0 : undefined,\n ...focusMode === 'composite' && !isHeader && compositeRowTabsterAttribute,\n ...props,\n onClick,\n onKeyDown,\n children: null,\n as: 'div'\n }, ref);\n return {\n ...baseState,\n components: {\n ...baseState.components,\n selectionCell: DataGridSelectionCell\n },\n selectionCell: slot.optional(props.selectionCell, {\n renderByDefault: selectable,\n elementType: DataGridSelectionCell\n }),\n renderCell: props.children,\n columnDefs,\n dataGridContextValue\n };\n};\n"],"names":["useDataGridRow_unstable","props","ref","rowId","useTableRowIdContext","isHeader","useIsInTableHeader","columnDefs","useDataGridContext_unstable","ctx","columns","selectable","selectableRows","selected","selection","isRowSelected","focusMode","compositeRowTabsterAttribute","tabbable","appearance","selectionAppearance","toggleRow","dataGridContextValue","onClick","useEventCallback","e","_props_onClick","call","onKeyDown","_props_onKeyDown","key","Space","isInteractiveHTMLElement","target","preventDefault","baseState","useTableRow_unstable","undefined","tabIndex","children","as","components","selectionCell","DataGridSelectionCell","slot","optional","renderByDefault","elementType","renderCell"],"mappings":";;;;+BAgBiBA;;;eAAAA;;;;iEAhBM;gCAC0C;8BAC3C;6BACe;iCACO;uCACN;8BACD;oCACF;AASxB,MAAMA,0BAA0B,CAACC,OAAOC;IAC/C,MAAMC,QAAQC,IAAAA,kCAAoB;IAClC,MAAMC,WAAWC,IAAAA,sCAAkB;IACnC,MAAMC,aAAaC,IAAAA,4CAA2B,EAAC,CAACC,MAAMA,IAAIC,OAAO;IACj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AIA,iBAAiBF,IAAI,CAAC1B,OAAOwB;IACzH;IACA,MAAMU,YAAYC,IAAAA,iCAAoB,EAAC;QACnCjB;QACA,iBAAiBR,aAAaE,WAAWwB;QACzCC,UAAUpB,YAAY,CAACb,WAAW,IAAIgC;QACtC,GAAGrB,cAAc,eAAe,CAACX,YAAYY,4BAA4B;QACzE,GAAGhB,KAAK;QACRsB;QACAK;QACAW,UAAU;QACVC,IAAI;IACR,GAAGtC;IACH,OAAO;QACH,GAAGiC,SAAS;QACZM,YAAY;YACR,GAAGN,UAAUM,UAAU;YACvBC,eAAeC,4CAAqB;QACxC;QACAD,eAAeE,oBAAI,CAACC,QAAQ,CAAC5C,MAAMyC,aAAa,EAAE;YAC9CI,iBAAiBnC;YACjBoC,aAAaJ,4CAAqB;QACtC;QACAK,YAAY/C,MAAMsC,QAAQ;QAC1BhC;QACAe;IACJ;AACJ"}
|
|
@@ -28,11 +28,11 @@ const useDataGridSelectionCell_unstable = (props, ref)=>{
|
|
|
28
28
|
const toggleAllRows = (0, _dataGridContext.useDataGridContext_unstable)((ctx)=>ctx.selection.toggleAllRows);
|
|
29
29
|
const type = (0, _dataGridContext.useDataGridContext_unstable)((ctx)=>ctx.selection.selectionMode === 'multiselect' ? 'checkbox' : 'radio');
|
|
30
30
|
const onClick = (0, _reactutilities.useEventCallback)((e)=>{
|
|
31
|
-
var _props_onClick
|
|
31
|
+
var _props_onClick;
|
|
32
32
|
if (isHeader) {
|
|
33
33
|
toggleAllRows(e);
|
|
34
34
|
}
|
|
35
|
-
(_props_onClick =
|
|
35
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);
|
|
36
36
|
});
|
|
37
37
|
return (0, _useTableSelectionCell.useTableSelectionCell_unstable)({
|
|
38
38
|
as: 'div',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useDataGridSelectionCell.js"],"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';\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 */ export const useDataGridSelectionCell_unstable = (props, ref)=>{\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 return ctx.selection.isRowSelected(rowId);\n });\n const toggleAllRows = useDataGridContext_unstable((ctx)=>ctx.selection.toggleAllRows);\n const type = useDataGridContext_unstable((ctx)=>ctx.selection.selectionMode === 'multiselect' ? 'checkbox' : 'radio');\n const onClick = useEventCallback((e)=>{\n var _props_onClick
|
|
1
|
+
{"version":3,"sources":["useDataGridSelectionCell.js"],"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';\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 */ export const useDataGridSelectionCell_unstable = (props, ref)=>{\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 return ctx.selection.isRowSelected(rowId);\n });\n const toggleAllRows = useDataGridContext_unstable((ctx)=>ctx.selection.toggleAllRows);\n const type = useDataGridContext_unstable((ctx)=>ctx.selection.selectionMode === 'multiselect' ? 'checkbox' : 'radio');\n const onClick = useEventCallback((e)=>{\n var _props_onClick;\n if (isHeader) {\n toggleAllRows(e);\n }\n (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);\n });\n return useTableSelectionCell_unstable({\n as: 'div',\n role: 'gridcell',\n checked,\n type,\n hidden: isHeader && type === 'radio',\n 'aria-checked': isHeader ? checked : undefined,\n 'aria-selected': isHeader || checked === 'mixed' ? undefined : checked,\n subtle,\n ...props,\n onClick\n }, ref);\n};\n"],"names":["useDataGridSelectionCell_unstable","props","ref","isHeader","useIsInTableHeader","rowId","useTableRowIdContext","subtle","useDataGridContext_unstable","ctx","subtleSelection","checked","selection","selectionMode","allRowsSelected","someRowsSelected","isRowSelected","toggleAllRows","type","onClick","useEventCallback","e","_props_onClick","call","useTableSelectionCell_unstable","as","role","hidden","undefined"],"mappings":";;;;+BAciBA;;;eAAAA;;;;iEAdM;gCACU;iCACW;8BACP;oCACF;uCACY;AASpC,MAAMA,oCAAoC,CAACC,OAAOC;IACzD,MAAMC,WAAWC,IAAAA,sCAAkB;IACnC,MAAMC,QAAQC,IAAAA,kCAAoB;IAClC,MAAMC,SAASC,IAAAA,4CAA2B,EAAC,CAACC,MAAMA,IAAIC,eAAe;IACrE,MAAMC,UAAUH,IAAAA,4CAA2B,EAAC,CAACC;QACzC,IAAIN,YAAYM,IAAIG,SAAS,CAACC,aAAa,KAAK,eAAe;YAC3D,OAAOJ,IAAIG,SAAS,CAACE,eAAe,GAAG,OAAOL,IAAIG,SAAS,CAACG,gBAAgB,GAAG,UAAU;QAC7F;QACA,OAAON,IAAIG,SAAS,CAACI,aAAa,CAACX;IACvC;IACA,MAAMY,gBAAgBT,IAAAA,4CAA2B,EAAC,CAACC,MAAMA,IAAIG,SAAS,CAACK,aAAa;IACpF,MAAMC,OAAOV,IAAAA,4CAA2B,EAAC,CAACC,MAAMA,IAAIG,SAAS,CAACC,aAAa,KAAK,gBAAgB,aAAa;IAC7G,MAAMM,UAAUC,IAAAA,gCAAgB,EAAC,CAACC;QAC9B,IAAIC;QACJ,IAAInB,UAAU;YACVc,cAAcI;QAClB;QACCC,CAAAA,iBAAiBrB,MAAMkB,OAAO,AAAD,MAAO,QAAQG,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeC,IAAI,CAACtB,OAAOoB;IACjH;IACA,OAAOG,IAAAA,qDAA8B,EAAC;QAClCC,IAAI;QACJC,MAAM;QACNf;QACAO;QACAS,QAAQxB,YAAYe,SAAS;QAC7B,gBAAgBf,WAAWQ,UAAUiB;QACrC,iBAAiBzB,YAAYQ,YAAY,UAAUiB,YAAYjB;QAC/DJ;QACA,GAAGN,KAAK;QACRkB;IACJ,GAAGjB;AACP"}
|
|
@@ -24,7 +24,8 @@ const sortIcons = {
|
|
|
24
24
|
})
|
|
25
25
|
};
|
|
26
26
|
const useTableHeaderCell_unstable = (props, ref)=>{
|
|
27
|
-
const { noNativeElements, sortable } = (0, _tableContext.useTableContext)();
|
|
27
|
+
const { noNativeElements, sortable: contextSortable } = (0, _tableContext.useTableContext)();
|
|
28
|
+
const { sortable = contextSortable } = props;
|
|
28
29
|
var _props_as;
|
|
29
30
|
const rootComponent = ((_props_as = props.as) !== null && _props_as !== void 0 ? _props_as : noNativeElements) ? 'div' : 'th';
|
|
30
31
|
var _props_sortDirection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTableHeaderCell.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { ArrowUpRegular, ArrowDownRegular } from '@fluentui/react-icons';\nimport { useARIAButtonShorthand } from '@fluentui/react-aria';\nimport { useTableContext } from '../../contexts/tableContext';\nconst sortIcons = {\n ascending: /*#__PURE__*/ React.createElement(ArrowUpRegular, {\n fontSize: 12\n }),\n descending: /*#__PURE__*/ React.createElement(ArrowDownRegular, {\n fontSize: 12\n })\n};\n/**\n * Create the state required to render TableHeaderCell.\n *\n * The returned state can be modified with hooks such as useTableHeaderCellStyles_unstable,\n * before being passed to renderTableHeaderCell_unstable.\n *\n * @param props - props from this instance of TableHeaderCell\n * @param ref - reference to root HTMLElement of TableHeaderCell\n */ export const useTableHeaderCell_unstable = (props, ref)=>{\n const { noNativeElements, sortable } = useTableContext();\n var _props_as;\n const rootComponent = ((_props_as = props.as) !== null && _props_as !== void 0 ? _props_as : noNativeElements) ? 'div' : 'th';\n var _props_sortDirection;\n return {\n components: {\n root: rootComponent,\n button: 'div',\n sortIcon: 'span',\n aside: 'span'\n },\n root: slot.always(getNativeElementProps(rootComponent, {\n ref: useMergedRefs(ref, useFocusWithin()),\n role: rootComponent === 'div' ? 'columnheader' : undefined,\n 'aria-sort': sortable ? (_props_sortDirection = props.sortDirection) !== null && _props_sortDirection !== void 0 ? _props_sortDirection : 'none' : undefined,\n ...props\n }), {\n elementType: rootComponent\n }),\n aside: slot.optional(props.aside, {\n elementType: 'span'\n }),\n sortIcon: slot.optional(props.sortIcon, {\n renderByDefault: !!props.sortDirection,\n defaultProps: {\n children: props.sortDirection ? sortIcons[props.sortDirection] : undefined\n },\n elementType: 'span'\n }),\n button: slot.always(useARIAButtonShorthand(props.button, {\n required: true,\n defaultProps: {\n as: 'div',\n ...!sortable && {\n role: 'presentation',\n tabIndex: undefined\n }\n }\n }), {\n elementType: 'div'\n }),\n sortable,\n noNativeElements\n };\n};\n"],"names":["useTableHeaderCell_unstable","sortIcons","ascending","React","createElement","ArrowUpRegular","fontSize","descending","ArrowDownRegular","props","ref","noNativeElements","sortable","useTableContext","_props_as","rootComponent","as","_props_sortDirection","components","root","button","sortIcon","aside","slot","always","getNativeElementProps","useMergedRefs","useFocusWithin","role","undefined","sortDirection","elementType","optional","renderByDefault","defaultProps","children","useARIAButtonShorthand","required","tabIndex"],"mappings":";;;;+BAsBiBA;;;eAAAA;;;;iEAtBM;gCACoC;8BAC5B;4BACkB;2BACV;8BACP;AAChC,MAAMC,YAAY;IACdC,WAAW,WAAW,GAAGC,OAAMC,aAAa,CAACC,0BAAc,EAAE;QACzDC,UAAU;IACd;IACAC,YAAY,WAAW,GAAGJ,OAAMC,aAAa,CAACI,4BAAgB,EAAE;QAC5DF,UAAU;IACd;AACJ;AASW,MAAMN,8BAA8B,CAACS,OAAOC;IACnD,MAAM,EAAEC,gBAAgB,EAAEC,
|
|
1
|
+
{"version":3,"sources":["useTableHeaderCell.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { ArrowUpRegular, ArrowDownRegular } from '@fluentui/react-icons';\nimport { useARIAButtonShorthand } from '@fluentui/react-aria';\nimport { useTableContext } from '../../contexts/tableContext';\nconst sortIcons = {\n ascending: /*#__PURE__*/ React.createElement(ArrowUpRegular, {\n fontSize: 12\n }),\n descending: /*#__PURE__*/ React.createElement(ArrowDownRegular, {\n fontSize: 12\n })\n};\n/**\n * Create the state required to render TableHeaderCell.\n *\n * The returned state can be modified with hooks such as useTableHeaderCellStyles_unstable,\n * before being passed to renderTableHeaderCell_unstable.\n *\n * @param props - props from this instance of TableHeaderCell\n * @param ref - reference to root HTMLElement of TableHeaderCell\n */ export const useTableHeaderCell_unstable = (props, ref)=>{\n const { noNativeElements, sortable: contextSortable } = useTableContext();\n const { sortable = contextSortable } = props;\n var _props_as;\n const rootComponent = ((_props_as = props.as) !== null && _props_as !== void 0 ? _props_as : noNativeElements) ? 'div' : 'th';\n var _props_sortDirection;\n return {\n components: {\n root: rootComponent,\n button: 'div',\n sortIcon: 'span',\n aside: 'span'\n },\n root: slot.always(getNativeElementProps(rootComponent, {\n ref: useMergedRefs(ref, useFocusWithin()),\n role: rootComponent === 'div' ? 'columnheader' : undefined,\n 'aria-sort': sortable ? (_props_sortDirection = props.sortDirection) !== null && _props_sortDirection !== void 0 ? _props_sortDirection : 'none' : undefined,\n ...props\n }), {\n elementType: rootComponent\n }),\n aside: slot.optional(props.aside, {\n elementType: 'span'\n }),\n sortIcon: slot.optional(props.sortIcon, {\n renderByDefault: !!props.sortDirection,\n defaultProps: {\n children: props.sortDirection ? sortIcons[props.sortDirection] : undefined\n },\n elementType: 'span'\n }),\n button: slot.always(useARIAButtonShorthand(props.button, {\n required: true,\n defaultProps: {\n as: 'div',\n ...!sortable && {\n role: 'presentation',\n tabIndex: undefined\n }\n }\n }), {\n elementType: 'div'\n }),\n sortable,\n noNativeElements\n };\n};\n"],"names":["useTableHeaderCell_unstable","sortIcons","ascending","React","createElement","ArrowUpRegular","fontSize","descending","ArrowDownRegular","props","ref","noNativeElements","sortable","contextSortable","useTableContext","_props_as","rootComponent","as","_props_sortDirection","components","root","button","sortIcon","aside","slot","always","getNativeElementProps","useMergedRefs","useFocusWithin","role","undefined","sortDirection","elementType","optional","renderByDefault","defaultProps","children","useARIAButtonShorthand","required","tabIndex"],"mappings":";;;;+BAsBiBA;;;eAAAA;;;;iEAtBM;gCACoC;8BAC5B;4BACkB;2BACV;8BACP;AAChC,MAAMC,YAAY;IACdC,WAAW,WAAW,GAAGC,OAAMC,aAAa,CAACC,0BAAc,EAAE;QACzDC,UAAU;IACd;IACAC,YAAY,WAAW,GAAGJ,OAAMC,aAAa,CAACI,4BAAgB,EAAE;QAC5DF,UAAU;IACd;AACJ;AASW,MAAMN,8BAA8B,CAACS,OAAOC;IACnD,MAAM,E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"}
|
|
@@ -13,8 +13,8 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
|
13
13
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
14
14
|
const useTableResizeHandle_unstable = (props, ref)=>{
|
|
15
15
|
const onClick = (0, _reactutilities.useEventCallback)((event)=>{
|
|
16
|
-
var _props_onClick
|
|
17
|
-
(_props_onClick =
|
|
16
|
+
var _props_onClick;
|
|
17
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, event);
|
|
18
18
|
event.stopPropagation();
|
|
19
19
|
});
|
|
20
20
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTableResizeHandle.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useEventCallback, slot } from '@fluentui/react-utilities';\n/**\n * Create the state required to render TableResizeHandle.\n *\n * The returned state can be modified with hooks such as useTableResizeHandleStyles_unstable,\n * before being passed to renderTableResizeHandle_unstable.\n *\n * @param props - props from this instance of TableResizeHandle\n * @param ref - reference to root HTMLElement of TableResizeHandle\n */ export const useTableResizeHandle_unstable = (props, ref)=>{\n const onClick = useEventCallback((event)=>{\n var _props_onClick
|
|
1
|
+
{"version":3,"sources":["useTableResizeHandle.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useEventCallback, slot } from '@fluentui/react-utilities';\n/**\n * Create the state required to render TableResizeHandle.\n *\n * The returned state can be modified with hooks such as useTableResizeHandleStyles_unstable,\n * before being passed to renderTableResizeHandle_unstable.\n *\n * @param props - props from this instance of TableResizeHandle\n * @param ref - reference to root HTMLElement of TableResizeHandle\n */ export const useTableResizeHandle_unstable = (props, ref)=>{\n const onClick = useEventCallback((event)=>{\n var _props_onClick;\n (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, event);\n event.stopPropagation();\n });\n return {\n components: {\n root: 'div'\n },\n root: slot.always(getNativeElementProps('div', {\n ref,\n ...props,\n onClick\n }), {\n elementType: 'div'\n })\n };\n};\n"],"names":["useTableResizeHandle_unstable","props","ref","onClick","useEventCallback","event","_props_onClick","call","stopPropagation","components","root","slot","always","getNativeElementProps","elementType"],"mappings":";;;;+BAUiBA;;;eAAAA;;;;iEAVM;gCACuC;AASnD,MAAMA,gCAAgC,CAACC,OAAOC;IACrD,MAAMC,UAAUC,IAAAA,gCAAgB,EAAC,CAACC;QAC9B,IAAIC;QACHA,CAAAA,iBAAiBL,MAAME,OAAO,AAAD,MAAO,QAAQG,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeC,IAAI,CAACN,OAAOI;QAC7GA,MAAMG,eAAe;IACzB;IACA,OAAO;QACHC,YAAY;YACRC,MAAM;QACV;QACAA,MAAMC,oBAAI,CAACC,MAAM,CAACC,IAAAA,qCAAqB,EAAC,OAAO;YAC3CX;YACA,GAAGD,KAAK;YACRE;QACJ,IAAI;YACAW,aAAa;QACjB;IACJ;AACJ"}
|
|
@@ -23,6 +23,8 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
|
|
|
23
23
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
24
24
|
const columnIdContext = /*#__PURE__*/ _react.createContext(undefined);
|
|
25
25
|
const columnIdContextDefaultValue = '';
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const useColumnIdContext = ()=>{
|
|
27
|
+
var _React_useContext;
|
|
28
|
+
return (_React_useContext = _react.useContext(columnIdContext)) !== null && _React_useContext !== void 0 ? _React_useContext : columnIdContextDefaultValue;
|
|
29
|
+
};
|
|
28
30
|
const ColumnIdContextProvider = columnIdContext.Provider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["columnIdContext.js"],"sourcesContent":["import * as React from 'react';\nconst columnIdContext = React.createContext(undefined);\nexport const columnIdContextDefaultValue = '';\
|
|
1
|
+
{"version":3,"sources":["columnIdContext.js"],"sourcesContent":["import * as React from 'react';\nconst columnIdContext = React.createContext(undefined);\nexport const columnIdContextDefaultValue = '';\nexport const useColumnIdContext = ()=>{\n var _React_useContext;\n return (_React_useContext = React.useContext(columnIdContext)) !== null && _React_useContext !== void 0 ? _React_useContext : columnIdContextDefaultValue;\n};\nexport const ColumnIdContextProvider = columnIdContext.Provider;\n"],"names":["columnIdContextDefaultValue","useColumnIdContext","ColumnIdContextProvider","columnIdContext","React","createContext","undefined","_React_useContext","useContext","Provider"],"mappings":";;;;;;;;;;;IAEaA,2BAA2B;eAA3BA;;IACAC,kBAAkB;eAAlBA;;IAIAC,uBAAuB;eAAvBA;;;;iEAPU;AACvB,MAAMC,gCAAkBC,OAAMC,aAAa,CAACC;AACrC,MAAMN,8BAA8B;AACpC,MAAMC,qBAAqB;IAC9B,IAAIM;IACJ,OAAO,AAACA,CAAAA,oBAAoBH,OAAMI,UAAU,CAACL,gBAAe,MAAO,QAAQI,sBAAsB,KAAK,IAAIA,oBAAoBP;AAClI;AACO,MAAME,0BAA0BC,gBAAgBM,QAAQ"}
|
|
@@ -23,6 +23,8 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
|
|
|
23
23
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
24
24
|
const rowIdContext = /*#__PURE__*/ _react.createContext(undefined);
|
|
25
25
|
const tableRowIdContextDefaultValue = '';
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const useTableRowIdContext = ()=>{
|
|
27
|
+
var _React_useContext;
|
|
28
|
+
return (_React_useContext = _react.useContext(rowIdContext)) !== null && _React_useContext !== void 0 ? _React_useContext : tableRowIdContextDefaultValue;
|
|
29
|
+
};
|
|
28
30
|
const TableRowIdContextProvider = rowIdContext.Provider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["rowIdContext.js"],"sourcesContent":["import * as React from 'react';\nconst rowIdContext = React.createContext(undefined);\nexport const tableRowIdContextDefaultValue = '';\
|
|
1
|
+
{"version":3,"sources":["rowIdContext.js"],"sourcesContent":["import * as React from 'react';\nconst rowIdContext = React.createContext(undefined);\nexport const tableRowIdContextDefaultValue = '';\nexport const useTableRowIdContext = ()=>{\n var _React_useContext;\n return (_React_useContext = React.useContext(rowIdContext)) !== null && _React_useContext !== void 0 ? _React_useContext : tableRowIdContextDefaultValue;\n};\nexport const TableRowIdContextProvider = rowIdContext.Provider;\n"],"names":["tableRowIdContextDefaultValue","useTableRowIdContext","TableRowIdContextProvider","rowIdContext","React","createContext","undefined","_React_useContext","useContext","Provider"],"mappings":";;;;;;;;;;;IAEaA,6BAA6B;eAA7BA;;IACAC,oBAAoB;eAApBA;;IAIAC,yBAAyB;eAAzBA;;;;iEAPU;AACvB,MAAMC,6BAAeC,OAAMC,aAAa,CAACC;AAClC,MAAMN,gCAAgC;AACtC,MAAMC,uBAAuB;IAChC,IAAIM;IACJ,OAAO,AAACA,CAAAA,oBAAoBH,OAAMI,UAAU,CAACL,aAAY,MAAO,QAAQI,sBAAsB,KAAK,IAAIA,oBAAoBP;AAC/H;AACO,MAAME,4BAA4BC,aAAaM,QAAQ"}
|
|
@@ -28,5 +28,7 @@ const tableContextDefaultValue = {
|
|
|
28
28
|
sortable: false
|
|
29
29
|
};
|
|
30
30
|
const TableContextProvider = tableContext.Provider;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const useTableContext = ()=>{
|
|
32
|
+
var _React_useContext;
|
|
33
|
+
return (_React_useContext = _react.useContext(tableContext)) !== null && _React_useContext !== void 0 ? _React_useContext : tableContextDefaultValue;
|
|
34
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["tableContext.js"],"sourcesContent":["import * as React from 'react';\nconst tableContext = React.createContext(undefined);\nexport const tableContextDefaultValue = {\n size: 'medium',\n noNativeElements: false,\n sortable: false\n};\nexport const TableContextProvider = tableContext.Provider;\
|
|
1
|
+
{"version":3,"sources":["tableContext.js"],"sourcesContent":["import * as React from 'react';\nconst tableContext = React.createContext(undefined);\nexport const tableContextDefaultValue = {\n size: 'medium',\n noNativeElements: false,\n sortable: false\n};\nexport const TableContextProvider = tableContext.Provider;\nexport const useTableContext = ()=>{\n var _React_useContext;\n return (_React_useContext = React.useContext(tableContext)) !== null && _React_useContext !== void 0 ? _React_useContext : tableContextDefaultValue;\n};\n"],"names":["tableContextDefaultValue","TableContextProvider","useTableContext","tableContext","React","createContext","undefined","size","noNativeElements","sortable","Provider","_React_useContext","useContext"],"mappings":";;;;;;;;;;;IAEaA,wBAAwB;eAAxBA;;IAKAC,oBAAoB;eAApBA;;IACAC,eAAe;eAAfA;;;;iEARU;AACvB,MAAMC,6BAAeC,OAAMC,aAAa,CAACC;AAClC,MAAMN,2BAA2B;IACpCO,MAAM;IACNC,kBAAkB;IAClBC,UAAU;AACd;AACO,MAAMR,uBAAuBE,aAAaO,QAAQ;AAClD,MAAMR,kBAAkB;IAC3B,IAAIS;IACJ,OAAO,AAACA,CAAAA,oBAAoBP,OAAMQ,UAAU,CAACT,aAAY,MAAO,QAAQQ,sBAAsB,KAAK,IAAIA,oBAAoBX;AAC/H"}
|
|
@@ -62,9 +62,9 @@ function useKeyboardResizing(columnResizeState) {
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
const enableInteractiveMode = _react.useCallback((colId)=>{
|
|
65
|
-
var _onChangeRef_current,
|
|
65
|
+
var _onChangeRef_current, _resizeHandleRefs_get;
|
|
66
66
|
setColumnId(colId);
|
|
67
|
-
(_onChangeRef_current =
|
|
67
|
+
(_onChangeRef_current = onChangeRef.current) === null || _onChangeRef_current === void 0 ? void 0 : _onChangeRef_current.call(onChangeRef, colId, true);
|
|
68
68
|
const handle = (_resizeHandleRefs_get = resizeHandleRefs.get(colId)) === null || _resizeHandleRefs_get === void 0 ? void 0 : _resizeHandleRefs_get.current;
|
|
69
69
|
if (handle) {
|
|
70
70
|
handle.setAttribute('tabindex', '-1');
|
|
@@ -75,11 +75,11 @@ function useKeyboardResizing(columnResizeState) {
|
|
|
75
75
|
resizeHandleRefs
|
|
76
76
|
]);
|
|
77
77
|
const disableInteractiveMode = _react.useCallback(()=>{
|
|
78
|
-
var _onChangeRef_current,
|
|
78
|
+
var _onChangeRef_current, _resizeHandleRefs_get;
|
|
79
79
|
if (!columnId) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
(_onChangeRef_current =
|
|
82
|
+
(_onChangeRef_current = onChangeRef.current) === null || _onChangeRef_current === void 0 ? void 0 : _onChangeRef_current.call(onChangeRef, columnId, false);
|
|
83
83
|
// Find the previous focusable element (table header button) and focus it.
|
|
84
84
|
const el = (_resizeHandleRefs_get = resizeHandleRefs.get(columnId)) === null || _resizeHandleRefs_get === void 0 ? void 0 : _resizeHandleRefs_get.current;
|
|
85
85
|
if (el) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useKeyboardResizing.js"],"sourcesContent":["import * as React from 'react';\nimport { ArrowLeft, ArrowRight, Enter, Escape, Shift, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { useFocusFinders, useTabsterAttributes } from '@fluentui/react-tabster';\nconst STEP = 20;\nconst PRECISION_MODIFIER = Shift;\nconst PRECISION_FACTOR = 1 / 4;\nexport function useKeyboardResizing(columnResizeState) {\n const [columnId, setColumnId] = React.useState();\n const onChangeRef = React.useRef();\n const { findPrevFocusable } = useFocusFinders();\n const columnResizeStateRef = React.useRef(columnResizeState);\n React.useEffect(()=>{\n columnResizeStateRef.current = columnResizeState;\n }, [\n columnResizeState\n ]);\n const [resizeHandleRefs] = React.useState(()=>new Map());\n const keyboardHandler = useEventCallback((event)=>{\n if (!columnId) {\n return;\n }\n const width = columnResizeStateRef.current.getColumnWidth(columnId);\n const precisionModifier = event.getModifierState(PRECISION_MODIFIER);\n const stopEvent = ()=>{\n event.preventDefault();\n event.stopPropagation();\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 case ArrowRight:\n stopEvent();\n columnResizeStateRef.current.setColumnWidth(event.nativeEvent, {\n columnId,\n width: width + (precisionModifier ? STEP * PRECISION_FACTOR : STEP)\n });\n return;\n case Space:\n case Enter:\n case Escape:\n var // Just blur here, the onBlur handler will take care of the rest (disableInteractiveMode).\n _resizeHandleRefs_get_current, _resizeHandleRefs_get;\n stopEvent();\n (_resizeHandleRefs_get = resizeHandleRefs.get(columnId)) === null || _resizeHandleRefs_get === void 0 ? void 0 : (_resizeHandleRefs_get_current = _resizeHandleRefs_get.current) === null || _resizeHandleRefs_get_current === void 0 ? void 0 : _resizeHandleRefs_get_current.blur();\n break;\n }\n });\n const enableInteractiveMode = React.useCallback((colId)=>{\n var _onChangeRef_current, _onChangeRef, _resizeHandleRefs_get;\n setColumnId(colId);\n (_onChangeRef_current = (_onChangeRef = onChangeRef).current) === null || _onChangeRef_current === void 0 ? void 0 : _onChangeRef_current.call(_onChangeRef, colId, true);\n const handle = (_resizeHandleRefs_get = resizeHandleRefs.get(colId)) === null || _resizeHandleRefs_get === void 0 ? void 0 : _resizeHandleRefs_get.current;\n if (handle) {\n handle.setAttribute('tabindex', '-1');\n handle.tabIndex = -1;\n handle.focus();\n }\n }, [\n resizeHandleRefs\n ]);\n const disableInteractiveMode = React.useCallback(()=>{\n var // Notify the onChange listener that we are disabling interactive mode.\n _onChangeRef_current, _onChangeRef, _resizeHandleRefs_get;\n if (!columnId) {\n return;\n }\n (_onChangeRef_current = (_onChangeRef = onChangeRef).current) === null || _onChangeRef_current === void 0 ? void 0 : _onChangeRef_current.call(_onChangeRef, columnId, false);\n // Find the previous focusable element (table header button) and focus it.\n const el = (_resizeHandleRefs_get = resizeHandleRefs.get(columnId)) === null || _resizeHandleRefs_get === void 0 ? void 0 : _resizeHandleRefs_get.current;\n if (el) {\n var _findPrevFocusable;\n (_findPrevFocusable = findPrevFocusable(el)) === null || _findPrevFocusable === void 0 ? void 0 : _findPrevFocusable.focus(); // Focus the previous focusable element (header button).\n el.removeAttribute('tabindex');\n }\n setColumnId(undefined);\n }, [\n columnId,\n findPrevFocusable,\n resizeHandleRefs\n ]);\n const toggleInteractiveMode = (colId, onChange)=>{\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 const getKeyboardResizingRef = React.useCallback((colId)=>{\n const ref = resizeHandleRefs.get(colId) || React.createRef();\n resizeHandleRefs.set(colId, ref);\n return ref;\n }, [\n resizeHandleRefs\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 return {\n toggleInteractiveMode,\n columnId,\n getKeyboardResizingProps: (colId, currentWidth)=>({\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 };\n}\n"],"names":["useKeyboardResizing","STEP","PRECISION_MODIFIER","Shift","PRECISION_FACTOR","columnResizeState","columnId","setColumnId","React","useState","onChangeRef","useRef","findPrevFocusable","useFocusFinders","columnResizeStateRef","useEffect","current","resizeHandleRefs","Map","keyboardHandler","useEventCallback","event","width","getColumnWidth","precisionModifier","getModifierState","stopEvent","preventDefault","stopPropagation","key","ArrowLeft","setColumnWidth","nativeEvent","ArrowRight","Space","Enter","Escape","_resizeHandleRefs_get_current","_resizeHandleRefs_get","get","blur","enableInteractiveMode","useCallback","colId","_onChangeRef_current","_onChangeRef","call","handle","setAttribute","tabIndex","focus","disableInteractiveMode","el","_findPrevFocusable","removeAttribute","undefined","toggleInteractiveMode","onChange","getKeyboardResizingRef","ref","createRef","set","tabsterAttrs","useTabsterAttributes","focusable","ignoreKeydown","getKeyboardResizingProps","currentWidth","onKeyDown","onBlur","role"],"mappings":";;;;+BAOgBA;;;eAAAA;;;;iEAPO;8BAC4C;gCAClC;8BACqB;AACtD,MAAMC,OAAO;AACb,MAAMC,qBAAqBC,mBAAK;AAChC,MAAMC,mBAAmB,IAAI;AACtB,SAASJ,oBAAoBK,iBAAiB;IACjD,MAAM,CAACC,UAAUC,YAAY,GAAGC,OAAMC,QAAQ;IAC9C,MAAMC,cAAcF,OAAMG,MAAM;IAChC,MAAM,EAAEC,iBAAiB,EAAE,GAAGC,IAAAA,6BAAe;IAC7C,MAAMC,uBAAuBN,OAAMG,MAAM,CAACN;IAC1CG,OAAMO,SAAS,CAAC;QACZD,qBAAqBE,OAAO,GAAGX;IACnC,GAAG;QACCA;KACH;IACD,MAAM,CAACY,iBAAiB,GAAGT,OAAMC,QAAQ,CAAC,IAAI,IAAIS;IAClD,MAAMC,kBAAkBC,IAAAA,gCAAgB,EAAC,CAACC;QACtC,IAAI,CAACf,UAAU;YACX;QACJ;QACA,MAAMgB,QAAQR,qBAAqBE,OAAO,CAACO,cAAc,CAACjB;QAC1D,MAAMkB,oBAAoBH,MAAMI,gBAAgB,CAACvB;QACjD,MAAMwB,YAAY;YACdL,MAAMM,cAAc;YACpBN,MAAMO,eAAe;QACzB;QACA,OAAOP,MAAMQ,GAAG;YACZ,KAAKC,uBAAS;gBACVJ;gBACAZ,qBAAqBE,OAAO,CAACe,cAAc,CAACV,MAAMW,WAAW,EAAE;oBAC3D1B;oBACAgB,OAAOA,QAASE,CAAAA,oBAAoBvB,OAAOG,mBAAmBH,IAAG;gBACrE;gBACA;YACJ,KAAKgC,wBAAU;gBACXP;gBACAZ,qBAAqBE,OAAO,CAACe,cAAc,CAACV,MAAMW,WAAW,EAAE;oBAC3D1B;oBACAgB,OAAOA,QAASE,CAAAA,oBAAoBvB,OAAOG,mBAAmBH,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React from 'react';\nimport { ArrowLeft, ArrowRight, Enter, Escape, Shift, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { useFocusFinders, useTabsterAttributes } from '@fluentui/react-tabster';\nconst STEP = 20;\nconst PRECISION_MODIFIER = Shift;\nconst PRECISION_FACTOR = 1 / 4;\nexport function useKeyboardResizing(columnResizeState) {\n const [columnId, setColumnId] = React.useState();\n const onChangeRef = React.useRef();\n const { findPrevFocusable } = useFocusFinders();\n const columnResizeStateRef = React.useRef(columnResizeState);\n React.useEffect(()=>{\n columnResizeStateRef.current = columnResizeState;\n }, [\n columnResizeState\n ]);\n const [resizeHandleRefs] = React.useState(()=>new Map());\n const keyboardHandler = useEventCallback((event)=>{\n if (!columnId) {\n return;\n }\n const width = columnResizeStateRef.current.getColumnWidth(columnId);\n const precisionModifier = event.getModifierState(PRECISION_MODIFIER);\n const stopEvent = ()=>{\n event.preventDefault();\n event.stopPropagation();\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 case ArrowRight:\n stopEvent();\n columnResizeStateRef.current.setColumnWidth(event.nativeEvent, {\n columnId,\n width: width + (precisionModifier ? STEP * PRECISION_FACTOR : STEP)\n });\n return;\n case Space:\n case Enter:\n case Escape:\n var // Just blur here, the onBlur handler will take care of the rest (disableInteractiveMode).\n _resizeHandleRefs_get_current, _resizeHandleRefs_get;\n stopEvent();\n (_resizeHandleRefs_get = resizeHandleRefs.get(columnId)) === null || _resizeHandleRefs_get === void 0 ? void 0 : (_resizeHandleRefs_get_current = _resizeHandleRefs_get.current) === null || _resizeHandleRefs_get_current === void 0 ? void 0 : _resizeHandleRefs_get_current.blur();\n break;\n }\n });\n const enableInteractiveMode = React.useCallback((colId)=>{\n var _onChangeRef_current, _resizeHandleRefs_get;\n setColumnId(colId);\n (_onChangeRef_current = onChangeRef.current) === null || _onChangeRef_current === void 0 ? void 0 : _onChangeRef_current.call(onChangeRef, colId, true);\n const handle = (_resizeHandleRefs_get = resizeHandleRefs.get(colId)) === null || _resizeHandleRefs_get === void 0 ? void 0 : _resizeHandleRefs_get.current;\n if (handle) {\n handle.setAttribute('tabindex', '-1');\n handle.tabIndex = -1;\n handle.focus();\n }\n }, [\n resizeHandleRefs\n ]);\n const disableInteractiveMode = React.useCallback(()=>{\n var // Notify the onChange listener that we are disabling interactive mode.\n _onChangeRef_current, _resizeHandleRefs_get;\n if (!columnId) {\n return;\n }\n (_onChangeRef_current = onChangeRef.current) === null || _onChangeRef_current === void 0 ? void 0 : _onChangeRef_current.call(onChangeRef, columnId, false);\n // Find the previous focusable element (table header button) and focus it.\n const el = (_resizeHandleRefs_get = resizeHandleRefs.get(columnId)) === null || _resizeHandleRefs_get === void 0 ? void 0 : _resizeHandleRefs_get.current;\n if (el) {\n var _findPrevFocusable;\n (_findPrevFocusable = findPrevFocusable(el)) === null || _findPrevFocusable === void 0 ? void 0 : _findPrevFocusable.focus(); // Focus the previous focusable element (header button).\n el.removeAttribute('tabindex');\n }\n setColumnId(undefined);\n }, [\n columnId,\n findPrevFocusable,\n resizeHandleRefs\n ]);\n const toggleInteractiveMode = (colId, onChange)=>{\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 const getKeyboardResizingRef = React.useCallback((colId)=>{\n const ref = resizeHandleRefs.get(colId) || React.createRef();\n resizeHandleRefs.set(colId, ref);\n return ref;\n }, [\n resizeHandleRefs\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 return {\n toggleInteractiveMode,\n columnId,\n getKeyboardResizingProps: (colId, currentWidth)=>({\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 };\n}\n"],"names":["useKeyboardResizing","STEP","PRECISION_MODIFIER","Shift","PRECISION_FACTOR","columnResizeState","columnId","setColumnId","React","useState","onChangeRef","useRef","findPrevFocusable","useFocusFinders","columnResizeStateRef","useEffect","current","resizeHandleRefs","Map","keyboardHandler","useEventCallback","event","width","getColumnWidth","precisionModifier","getModifierState","stopEvent","preventDefault","stopPropagation","key","ArrowLeft","setColumnWidth","nativeEvent","ArrowRight","Space","Enter","Escape","_resizeHandleRefs_get_current","_resizeHandleRefs_get","get","blur","enableInteractiveMode","useCallback","colId","_onChangeRef_current","call","handle","setAttribute","tabIndex","focus","disableInteractiveMode","el","_findPrevFocusable","removeAttribute","undefined","toggleInteractiveMode","onChange","getKeyboardResizingRef","ref","createRef","set","tabsterAttrs","useTabsterAttributes","focusable","ignoreKeydown","getKeyboardResizingProps","currentWidth","onKeyDown","onBlur","role"],"mappings":";;;;+BAOgBA;;;eAAAA;;;;iEAPO;8BAC4C;gCAClC;8BACqB;AACtD,MAAMC,OAAO;AACb,MAAMC,qBAAqBC,mBAAK;AAChC,MAAMC,mBAAmB,IAAI;AACtB,SAASJ,oBAAoBK,iBAAiB;IACjD,MAAM,CAACC,UAAUC,YAAY,GAAGC,OAAMC,QAAQ;IAC9C,MAAMC,cAAcF,OAAMG,MAAM;IAChC,MAAM,EAAEC,iBAAiB,EAAE,GAAGC,IAAAA,6BAAe;IAC7C,MAAMC,uBAAuBN,OAAMG,MAAM,CAACN;IAC1CG,OAAMO,SAAS,CAAC;QACZD,qBAAqBE,OAAO,GAAGX;IACnC,GAAG;QACCA;KACH;IACD,MAAM,CAACY,iBAAiB,GAAGT,OAAMC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AAG,CAACjB,OAAOe;QAC5B,OAAOA;IACX,GAAG;QACCzC;KACH;IACD,wEAAwE;IACxE,yCAAyC;IACzC,MAAM4C,eAAeC,IAAAA,kCAAoB,EAAC;QACtCC,WAAW;YACPC,eAAe;gBACXlC,WAAW;gBACXG,YAAY;YAChB;QACJ;IACJ;IACA,OAAO;QACHsB;QACAjD;QACA2D,0BAA0B,CAACtB,OAAOuB,eAAgB,CAAA;gBAC1CC,WAAWhD;gBACXiD,QAAQlB;gBACRQ,KAAKD,uBAAuBd;gBAC5B0B,MAAM;gBACN,cAAc;gBACd,kBAAkB,CAAC,EAAEH,aAAa,OAAO,CAAC;gBAC1C,eAAevB,UAAUrC,WAAW,QAAQ;gBAC5C0C,UAAUL,UAAUrC,WAAW,IAAIgD;gBACnC,GAAGO,YAAY;YACnB,CAAA;IACR;AACJ"}
|
|
@@ -45,10 +45,7 @@ function useMeasureElement() {
|
|
|
45
45
|
handleResize
|
|
46
46
|
]);
|
|
47
47
|
_react.useEffect(()=>{
|
|
48
|
-
return ()=>
|
|
49
|
-
var _resizeObserver;
|
|
50
|
-
return (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.disconnect();
|
|
51
|
-
};
|
|
48
|
+
return ()=>resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
52
49
|
}, [
|
|
53
50
|
resizeObserver
|
|
54
51
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useMeasureElement.js"],"sourcesContent":["import { canUseDOM } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\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 */ export function useMeasureElement() {\n const [width, setWidth] = React.useState(0);\n const container = React.useRef(undefined);\n const { targetDocument } = useFluent();\n // the handler for resize observer\n const handleResize = React.useCallback(()=>{\n var _container_current;\n const containerWidth = (_container_current = container.current) === null || _container_current === void 0 ? void 0 : _container_current.getBoundingClientRect().width;\n setWidth(containerWidth || 0);\n }, []);\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver] = React.useState(canUseDOM() ? new ResizeObserver(handleResize) : undefined);\n const measureElementRef = React.useCallback((el)=>{\n if (!targetDocument || !resizeObserver) {\n return;\n }\n // cleanup previous container\n if (container.current) {\n resizeObserver.unobserve(container.current);\n container.current.remove();\n }\n if (el) {\n container.current = targetDocument.createElement('div');\n el.insertAdjacentElement('beforebegin', container.current);\n resizeObserver.observe(container.current);\n handleResize();\n }\n }, [\n targetDocument,\n resizeObserver,\n handleResize\n ]);\n React.useEffect(()=>{\n return ()=>
|
|
1
|
+
{"version":3,"sources":["useMeasureElement.js"],"sourcesContent":["import { canUseDOM } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\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 */ export function useMeasureElement() {\n const [width, setWidth] = React.useState(0);\n const container = React.useRef(undefined);\n const { targetDocument } = useFluent();\n // the handler for resize observer\n const handleResize = React.useCallback(()=>{\n var _container_current;\n const containerWidth = (_container_current = container.current) === null || _container_current === void 0 ? void 0 : _container_current.getBoundingClientRect().width;\n setWidth(containerWidth || 0);\n }, []);\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver] = React.useState(canUseDOM() ? new ResizeObserver(handleResize) : undefined);\n const measureElementRef = React.useCallback((el)=>{\n if (!targetDocument || !resizeObserver) {\n return;\n }\n // cleanup previous container\n if (container.current) {\n resizeObserver.unobserve(container.current);\n container.current.remove();\n }\n if (el) {\n container.current = targetDocument.createElement('div');\n el.insertAdjacentElement('beforebegin', container.current);\n resizeObserver.observe(container.current);\n handleResize();\n }\n }, [\n targetDocument,\n resizeObserver,\n handleResize\n ]);\n React.useEffect(()=>{\n return ()=>resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();\n }, [\n resizeObserver\n ]);\n return {\n width,\n measureElementRef\n };\n}\n"],"names":["useMeasureElement","width","setWidth","React","useState","container","useRef","undefined","targetDocument","useFluent","handleResize","useCallback","_container_current","containerWidth","current","getBoundingClientRect","resizeObserver","canUseDOM","ResizeObserver","measureElementRef","el","unobserve","remove","createElement","insertAdjacentElement","observe","useEffect","disconnect"],"mappings":";;;;+BAQoBA;;;eAAAA;;;;gCARM;iEACH;qCACyB;AAMrC,SAASA;IAChB,MAAM,CAACC,OAAOC,SAAS,GAAGC,OAAMC,QAAQ,CAAC;IACzC,MAAMC,YAAYF,OAAMG,MAAM,CAACC;IAC/B,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,kCAAkC;IAClC,MAAMC,eAAeP,OAAMQ,WAAW,CAAC;QACnC,IAAIC;QACJ,MAAMC,iBAAiB,AAACD,CAAAA,qBAAqBP,UAAUS,OAAO,AAAD,MAAO,QAAQF,uBAAuB,KAAK,IAAI,KAAK,IAAIA,mBAAmBG,qBAAqB,GAAGd,KAAK;QACrKC,SAASW,kBAAkB;IAC/B,GAAG,EAAE;IACL,uFAAuF;IACvF,MAAM,CAACG,eAAe,GAAGb,OAAMC,QAAQ,CAACa,IAAAA,yBAAS,MAAK,IAAIC,eAAeR,gBAAgBH;IACzF,MAAMY,oBAAoBhB,OAAMQ,WAAW,CAAC,CAACS;QACzC,IAAI,CAACZ,kBAAkB,CAACQ,gBAAgB;YACpC;QACJ;QACA,6BAA6B;QAC7B,IAAIX,UAAUS,OAAO,EAAE;YACnBE,eAAeK,SAAS,CAAChB,UAAUS,OAAO;YAC1CT,UAAUS,OAAO,CAACQ,MAAM;QAC5B;QACA,IAAIF,IAAI;YACJf,UAAUS,OAAO,GAAGN,eAAee,aAAa,CAAC;YACjDH,GAAGI,qBAAqB,CAAC,eAAenB,UAAUS,OAAO;YACzDE,eAAeS,OAAO,CAACpB,UAAUS,OAAO;YACxCJ;QACJ;IACJ,GAAG;QACCF;QACAQ;QACAN;KACH;IACDP,OAAMuB,SAAS,CAAC;QACZ,OAAO,IAAIV,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeW,UAAU;IACxG,GAAG;QACCX;KACH;IACD,OAAO;QACHf;QACAkB;IACJ;AACJ"}
|
|
@@ -13,12 +13,11 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
|
13
13
|
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
14
14
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
15
15
|
function useTableColumnResizeMouseHandler(columnResizeState) {
|
|
16
|
-
var _targetDocument, _globalWin;
|
|
17
16
|
const mouseX = _react.useRef(0);
|
|
18
17
|
const currentWidth = _react.useRef(0);
|
|
19
18
|
const colId = _react.useRef(undefined);
|
|
20
19
|
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
21
|
-
const globalWin =
|
|
20
|
+
const globalWin = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
22
21
|
const recalculatePosition = _react.useCallback((e)=>{
|
|
23
22
|
const { clientX } = (0, _reactutilities.getEventClientCoords)(e);
|
|
24
23
|
const dx = clientX - mouseX.current;
|
|
@@ -33,27 +32,24 @@ function useTableColumnResizeMouseHandler(columnResizeState) {
|
|
|
33
32
|
columnResizeState
|
|
34
33
|
]);
|
|
35
34
|
const onDrag = _react.useCallback((e)=>{
|
|
36
|
-
var _globalWin;
|
|
37
35
|
// Using requestAnimationFrame here drastically improves resizing experience on slower CPUs
|
|
38
|
-
if (typeof (
|
|
36
|
+
if (typeof (globalWin === null || globalWin === void 0 ? void 0 : globalWin.requestAnimationFrame) === 'function') {
|
|
39
37
|
requestAnimationFrame(()=>recalculatePosition(e));
|
|
40
38
|
} else {
|
|
41
39
|
recalculatePosition(e);
|
|
42
40
|
}
|
|
43
41
|
}, [
|
|
44
|
-
|
|
42
|
+
globalWin === null || globalWin === void 0 ? void 0 : globalWin.requestAnimationFrame,
|
|
45
43
|
recalculatePosition
|
|
46
44
|
]);
|
|
47
45
|
const onDragEnd = _react.useCallback((event)=>{
|
|
48
46
|
if ((0, _reactutilities.isMouseEvent)(event)) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
(_targetDocument1 = targetDocument) === null || _targetDocument1 === void 0 ? void 0 : _targetDocument1.removeEventListener('mousemove', onDrag);
|
|
47
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('mouseup', onDragEnd);
|
|
48
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('mousemove', onDrag);
|
|
52
49
|
}
|
|
53
50
|
if ((0, _reactutilities.isTouchEvent)(event)) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
(_targetDocument3 = targetDocument) === null || _targetDocument3 === void 0 ? void 0 : _targetDocument3.removeEventListener('touchmove', onDrag);
|
|
51
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('touchend', onDragEnd);
|
|
52
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('touchmove', onDrag);
|
|
57
53
|
}
|
|
58
54
|
}, [
|
|
59
55
|
onDrag,
|
|
@@ -66,18 +62,16 @@ function useTableColumnResizeMouseHandler(columnResizeState) {
|
|
|
66
62
|
mouseX.current = (0, _reactutilities.getEventClientCoords)(event).clientX;
|
|
67
63
|
colId.current = columnId;
|
|
68
64
|
if ((0, _reactutilities.isMouseEvent)(event)) {
|
|
69
|
-
var _targetDocument, _targetDocument1;
|
|
70
65
|
// ignore other buttons than primary mouse button
|
|
71
66
|
if (event.target !== event.currentTarget || event.button !== 0) {
|
|
72
67
|
return;
|
|
73
68
|
}
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mouseup', onDragEnd);
|
|
70
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mousemove', onDrag);
|
|
76
71
|
}
|
|
77
72
|
if ((0, _reactutilities.isTouchEvent)(event)) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
(_targetDocument3 = targetDocument) === null || _targetDocument3 === void 0 ? void 0 : _targetDocument3.addEventListener('touchmove', onDrag);
|
|
73
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('touchend', onDragEnd);
|
|
74
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('touchmove', onDrag);
|
|
81
75
|
}
|
|
82
76
|
};
|
|
83
77
|
return {
|