@fluentui/react-table 9.11.14 → 9.12.0
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.md +32 -2
- package/lib/components/DataGridCell/DataGridCell.types.js +1 -3
- package/lib/components/DataGridCell/DataGridCell.types.js.map +1 -1
- package/lib/components/DataGridHeader/DataGridHeader.types.js +1 -3
- package/lib/components/DataGridHeader/DataGridHeader.types.js.map +1 -1
- package/lib/components/DataGridHeaderCell/DataGridHeaderCell.types.js +1 -3
- package/lib/components/DataGridHeaderCell/DataGridHeaderCell.types.js.map +1 -1
- package/lib/components/DataGridSelectionCell/DataGridSelectionCell.types.js +1 -3
- package/lib/components/DataGridSelectionCell/DataGridSelectionCell.types.js.map +1 -1
- package/lib/components/Table/Table.types.js +1 -3
- package/lib/components/Table/Table.types.js.map +1 -1
- package/lib/components/TableBody/TableBody.types.js +1 -3
- package/lib/components/TableBody/TableBody.types.js.map +1 -1
- package/lib/components/TableCell/TableCell.types.js +1 -3
- package/lib/components/TableCell/TableCell.types.js.map +1 -1
- package/lib/components/TableCellActions/TableCellActions.types.js +1 -3
- package/lib/components/TableCellActions/TableCellActions.types.js.map +1 -1
- package/lib/components/TableCellLayout/TableCellLayout.types.js +1 -3
- package/lib/components/TableCellLayout/TableCellLayout.types.js.map +1 -1
- package/lib/components/TableHeader/TableHeader.types.js +1 -3
- package/lib/components/TableHeader/TableHeader.types.js.map +1 -1
- package/lib/components/TableHeaderCell/TableHeaderCell.types.js +1 -3
- package/lib/components/TableHeaderCell/TableHeaderCell.types.js.map +1 -1
- package/lib/components/TableResizeHandle/TableResizeHandle.types.js +1 -3
- package/lib/components/TableResizeHandle/TableResizeHandle.types.js.map +1 -1
- package/lib/components/TableRow/TableRow.types.js +1 -3
- package/lib/components/TableRow/TableRow.types.js.map +1 -1
- package/lib/components/TableSelectionCell/TableSelectionCell.types.js +1 -3
- package/lib/components/TableSelectionCell/TableSelectionCell.types.js.map +1 -1
- package/lib/hooks/useMeasureElement.js +18 -10
- package/lib/hooks/useMeasureElement.js.map +1 -1
- package/lib/hooks/useTableColumnResizeMouseHandler.js +6 -1
- package/lib/hooks/useTableColumnResizeMouseHandler.js.map +1 -1
- package/lib/hooks/useTableColumnSizing.js +9 -4
- package/lib/hooks/useTableColumnSizing.js.map +1 -1
- package/lib-commonjs/components/DataGridCell/DataGridCell.types.js +1 -3
- package/lib-commonjs/components/DataGridCell/DataGridCell.types.js.map +1 -1
- package/lib-commonjs/components/DataGridHeader/DataGridHeader.types.js +1 -3
- package/lib-commonjs/components/DataGridHeader/DataGridHeader.types.js.map +1 -1
- package/lib-commonjs/components/DataGridHeaderCell/DataGridHeaderCell.types.js +1 -3
- package/lib-commonjs/components/DataGridHeaderCell/DataGridHeaderCell.types.js.map +1 -1
- package/lib-commonjs/components/DataGridSelectionCell/DataGridSelectionCell.types.js +1 -3
- package/lib-commonjs/components/DataGridSelectionCell/DataGridSelectionCell.types.js.map +1 -1
- package/lib-commonjs/components/Table/Table.types.js +1 -3
- package/lib-commonjs/components/Table/Table.types.js.map +1 -1
- package/lib-commonjs/components/TableBody/TableBody.types.js +1 -3
- package/lib-commonjs/components/TableBody/TableBody.types.js.map +1 -1
- package/lib-commonjs/components/TableCell/TableCell.types.js +1 -3
- package/lib-commonjs/components/TableCell/TableCell.types.js.map +1 -1
- package/lib-commonjs/components/TableCellActions/TableCellActions.types.js +1 -3
- package/lib-commonjs/components/TableCellActions/TableCellActions.types.js.map +1 -1
- package/lib-commonjs/components/TableCellLayout/TableCellLayout.types.js +1 -3
- package/lib-commonjs/components/TableCellLayout/TableCellLayout.types.js.map +1 -1
- package/lib-commonjs/components/TableHeader/TableHeader.types.js +1 -3
- package/lib-commonjs/components/TableHeader/TableHeader.types.js.map +1 -1
- package/lib-commonjs/components/TableHeaderCell/TableHeaderCell.types.js +1 -3
- package/lib-commonjs/components/TableHeaderCell/TableHeaderCell.types.js.map +1 -1
- package/lib-commonjs/components/TableResizeHandle/TableResizeHandle.types.js +1 -3
- package/lib-commonjs/components/TableResizeHandle/TableResizeHandle.types.js.map +1 -1
- package/lib-commonjs/components/TableRow/TableRow.types.js +1 -3
- package/lib-commonjs/components/TableRow/TableRow.types.js.map +1 -1
- package/lib-commonjs/components/TableSelectionCell/TableSelectionCell.types.js +1 -3
- package/lib-commonjs/components/TableSelectionCell/TableSelectionCell.types.js.map +1 -1
- package/lib-commonjs/contexts/columnIdContext.js +3 -3
- package/lib-commonjs/contexts/columnIdContext.js.map +1 -1
- package/lib-commonjs/contexts/dataGridContext.js +3 -3
- package/lib-commonjs/contexts/dataGridContext.js.map +1 -1
- package/lib-commonjs/contexts/rowIdContext.js +3 -3
- package/lib-commonjs/contexts/rowIdContext.js.map +1 -1
- package/lib-commonjs/contexts/tableContext.js +3 -3
- package/lib-commonjs/contexts/tableContext.js.map +1 -1
- package/lib-commonjs/hooks/useMeasureElement.js +21 -13
- package/lib-commonjs/hooks/useMeasureElement.js.map +1 -1
- package/lib-commonjs/hooks/useTableColumnResizeMouseHandler.js +6 -1
- package/lib-commonjs/hooks/useTableColumnResizeMouseHandler.js.map +1 -1
- package/lib-commonjs/hooks/useTableColumnSizing.js +9 -4
- package/lib-commonjs/hooks/useTableColumnSizing.js.map +1 -1
- package/lib-commonjs/index.js +213 -213
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/columnResizeUtils.js +7 -7
- package/lib-commonjs/utils/columnResizeUtils.js.map +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -9,14 +9,14 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
ColumnIdContextProvider: function() {
|
|
13
|
-
return ColumnIdContextProvider;
|
|
14
|
-
},
|
|
15
12
|
columnIdContextDefaultValue: function() {
|
|
16
13
|
return columnIdContextDefaultValue;
|
|
17
14
|
},
|
|
18
15
|
useColumnIdContext: function() {
|
|
19
16
|
return useColumnIdContext;
|
|
17
|
+
},
|
|
18
|
+
ColumnIdContextProvider: function() {
|
|
19
|
+
return ColumnIdContextProvider;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
@@ -1 +1 @@
|
|
|
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":["
|
|
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"}
|
|
@@ -9,12 +9,12 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
DataGridContextProvider: function() {
|
|
13
|
-
return DataGridContextProvider;
|
|
14
|
-
},
|
|
15
12
|
dataGridContextDefaultValue: function() {
|
|
16
13
|
return dataGridContextDefaultValue;
|
|
17
14
|
},
|
|
15
|
+
DataGridContextProvider: function() {
|
|
16
|
+
return DataGridContextProvider;
|
|
17
|
+
},
|
|
18
18
|
useDataGridContext_unstable: function() {
|
|
19
19
|
return useDataGridContext_unstable;
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["dataGridContext.js"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport { defaultTableState } from '../hooks';\nconst dataGridContext = createContext(undefined);\nexport const dataGridContextDefaultValue = {\n ...defaultTableState,\n subtleSelection: false,\n selectableRows: false,\n selectionAppearance: 'brand',\n focusMode: 'none',\n compositeRowTabsterAttribute: {}\n};\nexport const DataGridContextProvider = dataGridContext.Provider;\nexport const useDataGridContext_unstable = (selector)=>useContextSelector(dataGridContext, (ctx = dataGridContextDefaultValue)=>selector(ctx));\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["dataGridContext.js"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport { defaultTableState } from '../hooks';\nconst dataGridContext = createContext(undefined);\nexport const dataGridContextDefaultValue = {\n ...defaultTableState,\n subtleSelection: false,\n selectableRows: false,\n selectionAppearance: 'brand',\n focusMode: 'none',\n compositeRowTabsterAttribute: {}\n};\nexport const DataGridContextProvider = dataGridContext.Provider;\nexport const useDataGridContext_unstable = (selector)=>useContextSelector(dataGridContext, (ctx = dataGridContextDefaultValue)=>selector(ctx));\n"],"names":["dataGridContextDefaultValue","DataGridContextProvider","useDataGridContext_unstable","dataGridContext","createContext","undefined","defaultTableState","subtleSelection","selectableRows","selectionAppearance","focusMode","compositeRowTabsterAttribute","Provider","selector","useContextSelector","ctx"],"mappings":";;;;;;;;;;;IAGaA,2BAA2B;eAA3BA;;IAQAC,uBAAuB;eAAvBA;;IACAC,2BAA2B;eAA3BA;;;sCAZqC;uBAChB;AAClC,MAAMC,kBAAkBC,IAAAA,mCAAa,EAACC;AAC/B,MAAML,8BAA8B;IACvC,GAAGM,wBAAiB;IACpBC,iBAAiB;IACjBC,gBAAgB;IAChBC,qBAAqB;IACrBC,WAAW;IACXC,8BAA8B,CAAC;AACnC;AACO,MAAMV,0BAA0BE,gBAAgBS,QAAQ;AACxD,MAAMV,8BAA8B,CAACW,WAAWC,IAAAA,wCAAkB,EAACX,iBAAiB,CAACY,MAAMf,2BAA2B,GAAGa,SAASE"}
|
|
@@ -9,14 +9,14 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
TableRowIdContextProvider: function() {
|
|
13
|
-
return TableRowIdContextProvider;
|
|
14
|
-
},
|
|
15
12
|
tableRowIdContextDefaultValue: function() {
|
|
16
13
|
return tableRowIdContextDefaultValue;
|
|
17
14
|
},
|
|
18
15
|
useTableRowIdContext: function() {
|
|
19
16
|
return useTableRowIdContext;
|
|
17
|
+
},
|
|
18
|
+
TableRowIdContextProvider: function() {
|
|
19
|
+
return TableRowIdContextProvider;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
@@ -1 +1 @@
|
|
|
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":["
|
|
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"}
|
|
@@ -9,12 +9,12 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
TableContextProvider: function() {
|
|
13
|
-
return TableContextProvider;
|
|
14
|
-
},
|
|
15
12
|
tableContextDefaultValue: function() {
|
|
16
13
|
return tableContextDefaultValue;
|
|
17
14
|
},
|
|
15
|
+
TableContextProvider: function() {
|
|
16
|
+
return TableContextProvider;
|
|
17
|
+
},
|
|
18
18
|
useTableContext: function() {
|
|
19
19
|
return useTableContext;
|
|
20
20
|
}
|
|
@@ -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;\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":["
|
|
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"}
|
|
@@ -9,11 +9,11 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
createResizeObserverFromDocument: function() {
|
|
13
|
-
return createResizeObserverFromDocument;
|
|
14
|
-
},
|
|
15
12
|
useMeasureElement: function() {
|
|
16
13
|
return useMeasureElement;
|
|
14
|
+
},
|
|
15
|
+
createResizeObserverFromDocument: function() {
|
|
16
|
+
return createResizeObserverFromDocument;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
@@ -22,6 +22,7 @@ const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
|
22
22
|
function useMeasureElement() {
|
|
23
23
|
const [width, setWidth] = _react.useState(0);
|
|
24
24
|
const container = _react.useRef(undefined);
|
|
25
|
+
const resizeObserverRef = _react.useRef(null);
|
|
25
26
|
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
26
27
|
// the handler for resize observer
|
|
27
28
|
const handleResize = _react.useCallback(()=>{
|
|
@@ -29,31 +30,38 @@ function useMeasureElement() {
|
|
|
29
30
|
const containerWidth = (_container_current = container.current) === null || _container_current === void 0 ? void 0 : _container_current.getBoundingClientRect().width;
|
|
30
31
|
setWidth(containerWidth || 0);
|
|
31
32
|
}, []);
|
|
32
|
-
// Keep the reference of ResizeObserver in the state, as it should live through renders
|
|
33
|
-
const [resizeObserver] = _react.useState(()=>createResizeObserverFromDocument(targetDocument, handleResize));
|
|
34
33
|
const measureElementRef = _react.useCallback((el)=>{
|
|
35
|
-
if (!targetDocument
|
|
34
|
+
if (!targetDocument) {
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
|
-
//
|
|
39
|
-
if (container.current) {
|
|
40
|
-
|
|
37
|
+
// if the element is removed, stop observing it
|
|
38
|
+
if (!el && resizeObserverRef.current && container.current) {
|
|
39
|
+
resizeObserverRef.current.unobserve(container.current);
|
|
41
40
|
}
|
|
42
41
|
container.current = undefined;
|
|
43
42
|
if (el === null || el === void 0 ? void 0 : el.parentElement) {
|
|
43
|
+
var _resizeObserverRef_current;
|
|
44
44
|
container.current = el.parentElement;
|
|
45
|
-
resizeObserver.observe(container.current);
|
|
46
45
|
handleResize();
|
|
46
|
+
(_resizeObserverRef_current = resizeObserverRef.current) === null || _resizeObserverRef_current === void 0 ? void 0 : _resizeObserverRef_current.observe(container.current);
|
|
47
47
|
}
|
|
48
48
|
}, [
|
|
49
49
|
targetDocument,
|
|
50
|
-
resizeObserver,
|
|
51
50
|
handleResize
|
|
52
51
|
]);
|
|
53
52
|
_react.useEffect(()=>{
|
|
54
|
-
|
|
53
|
+
resizeObserverRef.current = createResizeObserverFromDocument(targetDocument, handleResize);
|
|
54
|
+
if (!container.current || !resizeObserverRef.current) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
resizeObserverRef.current.observe(container.current);
|
|
58
|
+
return ()=>{
|
|
59
|
+
var _resizeObserverRef_current;
|
|
60
|
+
(_resizeObserverRef_current = resizeObserverRef.current) === null || _resizeObserverRef_current === void 0 ? void 0 : _resizeObserverRef_current.disconnect();
|
|
61
|
+
};
|
|
55
62
|
}, [
|
|
56
|
-
|
|
63
|
+
handleResize,
|
|
64
|
+
targetDocument
|
|
57
65
|
]);
|
|
58
66
|
return {
|
|
59
67
|
width,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useMeasureElement.js"],"sourcesContent":["import * 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
|
|
1
|
+
{"version":3,"sources":["useMeasureElement.js"],"sourcesContent":["import * 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 resizeObserverRef = React.useRef(null);\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 const measureElementRef = React.useCallback((el)=>{\n if (!targetDocument) {\n return;\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 container.current = undefined;\n if (el === null || el === void 0 ? void 0 : el.parentElement) {\n var _resizeObserverRef_current;\n container.current = el.parentElement;\n handleResize();\n (_resizeObserverRef_current = resizeObserverRef.current) === null || _resizeObserverRef_current === void 0 ? void 0 : _resizeObserverRef_current.observe(container.current);\n }\n }, [\n targetDocument,\n handleResize\n ]);\n React.useEffect(()=>{\n resizeObserverRef.current = createResizeObserverFromDocument(targetDocument, handleResize);\n if (!container.current || !resizeObserverRef.current) {\n return;\n }\n resizeObserverRef.current.observe(container.current);\n return ()=>{\n var _resizeObserverRef_current;\n (_resizeObserverRef_current = resizeObserverRef.current) === null || _resizeObserverRef_current === void 0 ? void 0 : _resizeObserverRef_current.disconnect();\n };\n }, [\n handleResize,\n targetDocument\n ]);\n return {\n width,\n 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 */ export function createResizeObserverFromDocument(targetDocument, callback) {\n var _targetDocument_defaultView;\n if (!(targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.ResizeObserver)) {\n return null;\n }\n return new targetDocument.defaultView.ResizeObserver(callback);\n}\n"],"names":["useMeasureElement","createResizeObserverFromDocument","width","setWidth","React","useState","container","useRef","undefined","resizeObserverRef","targetDocument","useFluent","handleResize","useCallback","_container_current","containerWidth","current","getBoundingClientRect","measureElementRef","el","unobserve","parentElement","_resizeObserverRef_current","observe","useEffect","disconnect","callback","_targetDocument_defaultView","defaultView","ResizeObserver"],"mappings":";;;;;;;;;;;IAOoBA,iBAAiB;eAAjBA;;IAuDAC,gCAAgC;eAAhCA;;;;iEA9DG;qCACyB;AAMrC,SAASD;IAChB,MAAM,CAACE,OAAOC,SAAS,GAAGC,OAAMC,QAAQ,CAAC;IACzC,MAAMC,YAAYF,OAAMG,MAAM,CAACC;IAC/B,MAAMC,oBAAoBL,OAAMG,MAAM,CAAC;IACvC,MAAM,EAAEG,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,kCAAkC;IAClC,MAAMC,eAAeR,OAAMS,WAAW,CAAC;QACnC,IAAIC;QACJ,MAAMC,iBAAiB,AAACD,CAAAA,qBAAqBR,UAAUU,OAAO,AAAD,MAAO,QAAQF,uBAAuB,KA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AAW,AAAD,MAAO,QAAQD,gCAAgC,KAAK,IAAI,KAAK,IAAIA,4BAA4BE,cAAc,AAAD,GAAI;QACxO,OAAO;IACX;IACA,OAAO,IAAInB,eAAekB,WAAW,CAACC,cAAc,CAACH;AACzD"}
|
|
@@ -16,6 +16,7 @@ function useTableColumnResizeMouseHandler(columnResizeState) {
|
|
|
16
16
|
const mouseX = _react.useRef(0);
|
|
17
17
|
const currentWidth = _react.useRef(0);
|
|
18
18
|
const colId = _react.useRef(undefined);
|
|
19
|
+
const [dragging, setDragging] = _react.useState(false);
|
|
19
20
|
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
20
21
|
const globalWin = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
21
22
|
const { getColumnWidth, setColumnWidth } = columnResizeState;
|
|
@@ -52,6 +53,7 @@ function useTableColumnResizeMouseHandler(columnResizeState) {
|
|
|
52
53
|
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('touchend', onDragEnd);
|
|
53
54
|
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('touchmove', onDrag);
|
|
54
55
|
}
|
|
56
|
+
setDragging(false);
|
|
55
57
|
}, [
|
|
56
58
|
onDrag,
|
|
57
59
|
targetDocument
|
|
@@ -69,10 +71,12 @@ function useTableColumnResizeMouseHandler(columnResizeState) {
|
|
|
69
71
|
}
|
|
70
72
|
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mouseup', onDragEnd);
|
|
71
73
|
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mousemove', onDrag);
|
|
74
|
+
setDragging(true);
|
|
72
75
|
}
|
|
73
76
|
if ((0, _reactutilities.isTouchEvent)(event)) {
|
|
74
77
|
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('touchend', onDragEnd);
|
|
75
78
|
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('touchmove', onDrag);
|
|
79
|
+
setDragging(true);
|
|
76
80
|
}
|
|
77
81
|
}, [
|
|
78
82
|
getColumnWidth,
|
|
@@ -81,6 +85,7 @@ function useTableColumnResizeMouseHandler(columnResizeState) {
|
|
|
81
85
|
targetDocument
|
|
82
86
|
]);
|
|
83
87
|
return {
|
|
84
|
-
getOnMouseDown
|
|
88
|
+
getOnMouseDown,
|
|
89
|
+
dragging
|
|
85
90
|
};
|
|
86
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTableColumnResizeMouseHandler.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { getEventClientCoords, isMouseEvent, isTouchEvent } from '@fluentui/react-utilities';\nexport function useTableColumnResizeMouseHandler(columnResizeState) {\n const mouseX = React.useRef(0);\n const currentWidth = React.useRef(0);\n const colId = React.useRef(undefined);\n const { targetDocument } = useFluent();\n const globalWin = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;\n const { getColumnWidth, setColumnWidth } = columnResizeState;\n const recalculatePosition = React.useCallback((e)=>{\n const { clientX } = getEventClientCoords(e);\n const dx = clientX - mouseX.current;\n // Update the local width for the column and set it\n currentWidth.current += dx;\n colId.current && setColumnWidth(e, {\n columnId: colId.current,\n width: currentWidth.current\n });\n mouseX.current = clientX;\n }, [\n setColumnWidth\n ]);\n const onDrag = React.useCallback((e)=>{\n // Using requestAnimationFrame here drastically improves resizing experience on slower CPUs\n if (typeof (globalWin === null || globalWin === void 0 ? void 0 : globalWin.requestAnimationFrame) === 'function') {\n requestAnimationFrame(()=>recalculatePosition(e));\n } else {\n recalculatePosition(e);\n }\n }, [\n globalWin === null || globalWin === void 0 ? void 0 : globalWin.requestAnimationFrame,\n recalculatePosition\n ]);\n const onDragEnd = React.useCallback((event)=>{\n if (isMouseEvent(event)) {\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('mouseup', onDragEnd);\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('mousemove', onDrag);\n }\n if (isTouchEvent(event)) {\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('touchend', onDragEnd);\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('touchmove', onDrag);\n }\n }, [\n onDrag,\n targetDocument\n ]);\n const getOnMouseDown = React.useCallback((columnId)=>(event)=>{\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 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 === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mouseup', onDragEnd);\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mousemove', onDrag);\n }\n if (isTouchEvent(event)) {\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('touchend', onDragEnd);\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('touchmove', onDrag);\n }\n }, [\n getColumnWidth,\n onDrag,\n onDragEnd,\n targetDocument\n ]);\n return {\n getOnMouseDown\n };\n}\n"],"names":["useTableColumnResizeMouseHandler","columnResizeState","mouseX","React","useRef","currentWidth","colId","undefined","targetDocument","useFluent","globalWin","defaultView","getColumnWidth","setColumnWidth","recalculatePosition","useCallback","e","clientX","getEventClientCoords","dx","current","columnId","width","onDrag","requestAnimationFrame","onDragEnd","event","isMouseEvent","removeEventListener","isTouchEvent","getOnMouseDown","target","currentTarget","button","addEventListener"],"mappings":";;;;+BAGgBA;;;eAAAA;;;;iEAHO;qCACyB;gCACiB;AAC1D,SAASA,iCAAiCC,iBAAiB;IAC9D,MAAMC,SAASC,OAAMC,MAAM,CAAC;IAC5B,MAAMC,eAAeF,OAAMC,MAAM,CAAC;IAClC,MAAME,QAAQH,OAAMC,MAAM,CAACG;IAC3B,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,YAAYF,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeG,WAAW;IAC5G,MAAM,EAAEC,cAAc,EAAEC,cAAc,EAAE,
|
|
1
|
+
{"version":3,"sources":["useTableColumnResizeMouseHandler.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { getEventClientCoords, isMouseEvent, isTouchEvent } from '@fluentui/react-utilities';\nexport function useTableColumnResizeMouseHandler(columnResizeState) {\n const mouseX = React.useRef(0);\n const currentWidth = React.useRef(0);\n const colId = React.useRef(undefined);\n const [dragging, setDragging] = React.useState(false);\n const { targetDocument } = useFluent();\n const globalWin = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;\n const { getColumnWidth, setColumnWidth } = columnResizeState;\n const recalculatePosition = React.useCallback((e)=>{\n const { clientX } = getEventClientCoords(e);\n const dx = clientX - mouseX.current;\n // Update the local width for the column and set it\n currentWidth.current += dx;\n colId.current && setColumnWidth(e, {\n columnId: colId.current,\n width: currentWidth.current\n });\n mouseX.current = clientX;\n }, [\n setColumnWidth\n ]);\n const onDrag = React.useCallback((e)=>{\n // Using requestAnimationFrame here drastically improves resizing experience on slower CPUs\n if (typeof (globalWin === null || globalWin === void 0 ? void 0 : globalWin.requestAnimationFrame) === 'function') {\n requestAnimationFrame(()=>recalculatePosition(e));\n } else {\n recalculatePosition(e);\n }\n }, [\n globalWin === null || globalWin === void 0 ? void 0 : globalWin.requestAnimationFrame,\n recalculatePosition\n ]);\n const onDragEnd = React.useCallback((event)=>{\n if (isMouseEvent(event)) {\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('mouseup', onDragEnd);\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('mousemove', onDrag);\n }\n if (isTouchEvent(event)) {\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('touchend', onDragEnd);\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('touchmove', onDrag);\n }\n setDragging(false);\n }, [\n onDrag,\n targetDocument\n ]);\n const getOnMouseDown = React.useCallback((columnId)=>(event)=>{\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 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 === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mouseup', onDragEnd);\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mousemove', onDrag);\n setDragging(true);\n }\n if (isTouchEvent(event)) {\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('touchend', onDragEnd);\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('touchmove', onDrag);\n setDragging(true);\n }\n }, [\n getColumnWidth,\n onDrag,\n onDragEnd,\n targetDocument\n ]);\n return {\n getOnMouseDown,\n dragging\n };\n}\n"],"names":["useTableColumnResizeMouseHandler","columnResizeState","mouseX","React","useRef","currentWidth","colId","undefined","dragging","setDragging","useState","targetDocument","useFluent","globalWin","defaultView","getColumnWidth","setColumnWidth","recalculatePosition","useCallback","e","clientX","getEventClientCoords","dx","current","columnId","width","onDrag","requestAnimationFrame","onDragEnd","event","isMouseEvent","removeEventListener","isTouchEvent","getOnMouseDown","target","currentTarget","button","addEventListener"],"mappings":";;;;+BAGgBA;;;eAAAA;;;;iEAHO;qCACyB;gCACiB;AAC1D,SAASA,iCAAiCC,iBAAiB;IAC9D,MAAMC,SAASC,OAAMC,MAAM,CAAC;IAC5B,MAAMC,eAAeF,OAAMC,MAAM,CAAC;IAClC,MAAME,QAAQ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-next-line react-hooks/rules-of-hooks
|
|
44
44
|
return (tableState)=>useTableColumnSizingState(tableState, params);
|
|
45
45
|
}
|
|
46
|
-
function getColumnStyles(column) {
|
|
46
|
+
function getColumnStyles(column, dragging) {
|
|
47
47
|
const width = column.width;
|
|
48
48
|
return {
|
|
49
49
|
// native styles
|
|
50
50
|
width,
|
|
51
51
|
// non-native element styles (flex layout)
|
|
52
52
|
minWidth: width,
|
|
53
|
-
maxWidth: width
|
|
53
|
+
maxWidth: width,
|
|
54
|
+
// Fixed the unwanted sort: https://github.com/microsoft/fluentui/issues/27803
|
|
55
|
+
...dragging ? {
|
|
56
|
+
pointerEvents: 'none'
|
|
57
|
+
} : {}
|
|
54
58
|
};
|
|
55
59
|
}
|
|
56
60
|
function useTableColumnSizingState(tableState, params) {
|
|
@@ -71,7 +75,7 @@ function useTableColumnSizingState(tableState, params) {
|
|
|
71
75
|
toggleInteractiveMode
|
|
72
76
|
]);
|
|
73
77
|
const { getColumnById, setColumnWidth, getColumns } = columnResizeState;
|
|
74
|
-
const { getOnMouseDown } = mouseHandler;
|
|
78
|
+
const { getOnMouseDown, dragging } = mouseHandler;
|
|
75
79
|
return {
|
|
76
80
|
...tableState,
|
|
77
81
|
tableRef: measureElementRef,
|
|
@@ -102,12 +106,13 @@ function useTableColumnSizingState(tableState, params) {
|
|
|
102
106
|
...getKeyboardResizingProps(columnId, (col === null || col === void 0 ? void 0 : col.width) || 0)
|
|
103
107
|
});
|
|
104
108
|
return col ? {
|
|
105
|
-
style: getColumnStyles(col),
|
|
109
|
+
style: getColumnStyles(col, dragging),
|
|
106
110
|
aside
|
|
107
111
|
} : {};
|
|
108
112
|
}, [
|
|
109
113
|
getColumnById,
|
|
110
114
|
columns,
|
|
115
|
+
dragging,
|
|
111
116
|
getKeyboardResizingProps,
|
|
112
117
|
getOnMouseDown
|
|
113
118
|
]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTableColumnSizing.js"],"sourcesContent":["import * as React from 'react';\nimport { TableResizeHandle } from '../TableResizeHandle';\nimport { useMeasureElement } from './useMeasureElement';\nimport { useTableColumnResizeMouseHandler } from './useTableColumnResizeMouseHandler';\nimport { useTableColumnResizeState } from './useTableColumnResizeState';\nimport { useKeyboardResizing } from './useKeyboardResizing';\nexport const defaultColumnSizingState = {\n getColumnWidths: ()=>[],\n getOnMouseDown: ()=>()=>null,\n setColumnWidth: ()=>null,\n getTableProps: ()=>({}),\n getTableHeaderCellProps: ()=>({\n style: {},\n columnId: ''\n }),\n getTableCellProps: ()=>({\n style: {},\n columnId: ''\n }),\n enableKeyboardMode: ()=>()=>null\n};\nexport function useTableColumnSizing_unstable(params) {\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)=>useTableColumnSizingState(tableState, params);\n}\nfunction getColumnStyles(column) {\n const width = column.width;\n return {\n // native styles\n width,\n // non-native element styles (flex layout)\n minWidth: width,\n maxWidth: width\n };\n}\nfunction useTableColumnSizingState(tableState, params) {\n const { columns } = tableState;\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 === null || params === void 0 ? void 0 : 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 const enableKeyboardMode = React.useCallback((columnId, onChange)=>(e)=>{\n e.preventDefault();\n e.nativeEvent.stopPropagation();\n toggleInteractiveMode(columnId, onChange);\n }, [\n toggleInteractiveMode\n ]);\n const { getColumnById, setColumnWidth, getColumns } = columnResizeState;\n const { getOnMouseDown } = 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, w)=>setColumnWidth(undefined, {\n columnId,\n width: w\n }),\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((columnId)=>{\n var _columns_;\n const col = getColumnById(columnId);\n const isLastColumn = ((_columns_ = columns[columns.length - 1]) === null || _columns_ === void 0 ? void 0 : _columns_.columnId) === columnId;\n const aside = isLastColumn ? null : /*#__PURE__*/ React.createElement(TableResizeHandle, {\n onMouseDown: getOnMouseDown(columnId),\n onTouchStart: getOnMouseDown(columnId),\n ...getKeyboardResizingProps(columnId, (col === null || col === void 0 ? void 0 : col.width) || 0)\n });\n return col ? {\n style: getColumnStyles(col),\n aside\n } : {};\n }, [\n getColumnById,\n columns,\n getKeyboardResizingProps,\n getOnMouseDown\n ]),\n getTableCellProps: React.useCallback((columnId)=>{\n const col = getColumnById(columnId);\n return col ? {\n style: getColumnStyles(col)\n } : {};\n }, [\n getColumnById\n ]),\n enableKeyboardMode\n }\n };\n}\n"],"names":["defaultColumnSizingState","useTableColumnSizing_unstable","getColumnWidths","getOnMouseDown","setColumnWidth","getTableProps","getTableHeaderCellProps","style","columnId","getTableCellProps","enableKeyboardMode","params","tableState","useTableColumnSizingState","getColumnStyles","column","width","minWidth","maxWidth","columns","measureElementRef","useMeasureElement","columnResizeState","useTableColumnResizeState","containerWidthOffset","mouseHandler","useTableColumnResizeMouseHandler","toggleInteractiveMode","getKeyboardResizingProps","useKeyboardResizing","React","useCallback","onChange","e","preventDefault","nativeEvent","stopPropagation","getColumnById","getColumns","tableRef","columnSizing_unstable","w","undefined","props","_columns_","col","isLastColumn","length","aside","createElement","TableResizeHandle","onMouseDown","onTouchStart"],"mappings":";;;;;;;;;;;IAMaA,wBAAwB;eAAxBA;;IAeGC,6BAA6B;eAA7BA;;;;iEArBO;mCACW;mCACA;kDACe;2CACP;qCACN;AAC7B,MAAMD,2BAA2B;IACpCE,iBAAiB,IAAI,EAAE;IACvBC,gBAAgB,IAAI,IAAI;IACxBC,gBAAgB,IAAI;IACpBC,eAAe,IAAK,CAAA,CAAC,CAAA;IACrBC,yBAAyB,IAAK,CAAA;YACtBC,OAAO,CAAC;YACRC,UAAU;QACd,CAAA;IACJC,mBAAmB,IAAK,CAAA;YAChBF,OAAO,CAAC;YACRC,UAAU;QACd,CAAA;IACJE,oBAAoB,IAAI,IAAI;AAChC;AACO,SAAST,8BAA8BU,MAAM;IAChD,4EAA4E;IAC5E,sDAAsD;IACtD,OAAO,CAACC,aAAaC,0BAA0BD,YAAYD;AAC/D;AACA,SAASG,gBAAgBC,MAAM;
|
|
1
|
+
{"version":3,"sources":["useTableColumnSizing.js"],"sourcesContent":["import * as React from 'react';\nimport { TableResizeHandle } from '../TableResizeHandle';\nimport { useMeasureElement } from './useMeasureElement';\nimport { useTableColumnResizeMouseHandler } from './useTableColumnResizeMouseHandler';\nimport { useTableColumnResizeState } from './useTableColumnResizeState';\nimport { useKeyboardResizing } from './useKeyboardResizing';\nexport const defaultColumnSizingState = {\n getColumnWidths: ()=>[],\n getOnMouseDown: ()=>()=>null,\n setColumnWidth: ()=>null,\n getTableProps: ()=>({}),\n getTableHeaderCellProps: ()=>({\n style: {},\n columnId: ''\n }),\n getTableCellProps: ()=>({\n style: {},\n columnId: ''\n }),\n enableKeyboardMode: ()=>()=>null\n};\nexport function useTableColumnSizing_unstable(params) {\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)=>useTableColumnSizingState(tableState, params);\n}\nfunction getColumnStyles(column, dragging) {\n const width = column.width;\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 ? {\n pointerEvents: 'none'\n } : {}\n };\n}\nfunction useTableColumnSizingState(tableState, params) {\n const { columns } = tableState;\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 === null || params === void 0 ? void 0 : 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 const enableKeyboardMode = React.useCallback((columnId, onChange)=>(e)=>{\n e.preventDefault();\n e.nativeEvent.stopPropagation();\n toggleInteractiveMode(columnId, onChange);\n }, [\n toggleInteractiveMode\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, w)=>setColumnWidth(undefined, {\n columnId,\n width: w\n }),\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((columnId)=>{\n var _columns_;\n const col = getColumnById(columnId);\n const isLastColumn = ((_columns_ = columns[columns.length - 1]) === null || _columns_ === void 0 ? void 0 : _columns_.columnId) === columnId;\n const aside = isLastColumn ? null : /*#__PURE__*/ React.createElement(TableResizeHandle, {\n onMouseDown: getOnMouseDown(columnId),\n onTouchStart: getOnMouseDown(columnId),\n ...getKeyboardResizingProps(columnId, (col === null || col === void 0 ? void 0 : col.width) || 0)\n });\n return col ? {\n style: getColumnStyles(col, dragging),\n aside\n } : {};\n }, [\n getColumnById,\n columns,\n dragging,\n getKeyboardResizingProps,\n getOnMouseDown\n ]),\n getTableCellProps: React.useCallback((columnId)=>{\n const col = getColumnById(columnId);\n return col ? {\n style: getColumnStyles(col)\n } : {};\n }, [\n getColumnById\n ]),\n enableKeyboardMode\n }\n };\n}\n"],"names":["defaultColumnSizingState","useTableColumnSizing_unstable","getColumnWidths","getOnMouseDown","setColumnWidth","getTableProps","getTableHeaderCellProps","style","columnId","getTableCellProps","enableKeyboardMode","params","tableState","useTableColumnSizingState","getColumnStyles","column","dragging","width","minWidth","maxWidth","pointerEvents","columns","measureElementRef","useMeasureElement","columnResizeState","useTableColumnResizeState","containerWidthOffset","mouseHandler","useTableColumnResizeMouseHandler","toggleInteractiveMode","getKeyboardResizingProps","useKeyboardResizing","React","useCallback","onChange","e","preventDefault","nativeEvent","stopPropagation","getColumnById","getColumns","tableRef","columnSizing_unstable","w","undefined","props","_columns_","col","isLastColumn","length","aside","createElement","TableResizeHandle","onMouseDown","onTouchStart"],"mappings":";;;;;;;;;;;IAMaA,wBAAwB;eAAxBA;;IAeGC,6BAA6B;eAA7BA;;;;iEArBO;mCACW;mCACA;kDACe;2CACP;qCACN;AAC7B,MAAMD,2BAA2B;IACpCE,iBAAiB,IAAI,EAAE;IACvBC,gBAAgB,IAAI,IAAI;IACxBC,gBAAgB,IAAI;IACpBC,eAAe,IAAK,CAAA,CAAC,CAAA;IACrBC,yBAAyB,IAAK,CAAA;YACtBC,OAAO,CAAC;YACRC,UAAU;QACd,CAAA;IACJC,mBAAmB,IAAK,CAAA;YAChBF,OAAO,CAAC;YACRC,UAAU;QACd,CAAA;IACJE,oBAAoB,IAAI,IAAI;AAChC;AACO,SAAST,8BAA8BU,MAAM;IAChD,4EAA4E;IAC5E,sDAAsD;IACtD,OAAO,CAACC,aAAaC,0BAA0BD,YAAYD;AAC/D;AACA,SAASG,gBAAgBC,MAAM,EAAEC,QAAQ;IACrC,MAAMC,QAAQF,OAAOE,KAAK;IAC1B,OAAO;QACH,gBAAgB;QAChBA;QACA,0CAA0C;QAC1CC,UAAUD;QACVE,UAAUF;QACV,8EAA8E;QAC9E,GAAGD,WAAW;YACVI,eAAe;QACnB,IAAI,CAAC,CAAC;IACV;AACJ;AACA,SAASP,0BAA0BD,UAAU,EAAED,MAAM;IACjD,MAAM,EAAEU,OAAO,EAA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