@elliemae/ds-data-table 3.70.0-next.6 → 3.70.0-next.60
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/dist/cjs/addons/Columns/ColumnSelectMultiple/ColumnSelectMultiple.js +15 -3
- package/dist/cjs/addons/Columns/ColumnSelectMultiple/ColumnSelectMultiple.js.map +3 -3
- package/dist/cjs/addons/Editables/index.js.map +1 -1
- package/dist/cjs/addons/Filters/Components/SelectFilter/BaseSelectFilter.js.map +2 -2
- package/dist/cjs/addons/Filters/Components/SelectFilter/BaseSelectFilterV2.js.map +2 -2
- package/dist/cjs/configs/constants.js +4 -0
- package/dist/cjs/configs/constants.js.map +2 -2
- package/dist/cjs/configs/useAutocalculated/index.js +15 -1
- package/dist/cjs/configs/useAutocalculated/index.js.map +2 -2
- package/dist/cjs/configs/useStore/useStore.js +46 -0
- package/dist/cjs/configs/useStore/useStore.js.map +2 -2
- package/dist/cjs/constants/index.js +1 -0
- package/dist/cjs/constants/index.js.map +2 -2
- package/dist/cjs/exported-related/FilterBar/PillsFromDataTableFilters.js +2 -1
- package/dist/cjs/exported-related/FilterBar/PillsFromDataTableFilters.js.map +2 -2
- package/dist/cjs/exported-related/FilterPopover/FilterPopoverV2.js +14 -8
- package/dist/cjs/exported-related/FilterPopover/FilterPopoverV2.js.map +2 -2
- package/dist/cjs/exported-related/FilterPopover/index.js +31 -7
- package/dist/cjs/exported-related/FilterPopover/index.js.map +2 -2
- package/dist/cjs/package.json +1 -4
- package/dist/cjs/parts/Cells/Cell.js +1 -1
- package/dist/cjs/parts/Cells/Cell.js.map +2 -2
- package/dist/cjs/parts/Cells/CellFactory.js +1 -1
- package/dist/cjs/parts/Cells/CellFactory.js.map +2 -2
- package/dist/cjs/parts/FilterBar/FiltersBar.js +2 -1
- package/dist/cjs/parts/FilterBar/FiltersBar.js.map +2 -2
- package/dist/cjs/parts/Headers/HeaderCell.js +13 -24
- package/dist/cjs/parts/Headers/HeaderCell.js.map +2 -2
- package/dist/cjs/parts/Headers/HeaderCellTitle.js +24 -4
- package/dist/cjs/parts/Headers/HeaderCellTitle.js.map +2 -2
- package/dist/cjs/parts/Headers/HeaderResizer.js +40 -18
- package/dist/cjs/parts/Headers/HeaderResizer.js.map +2 -2
- package/dist/cjs/{exported-related/FilterPopover/useOnClickOutside.js → parts/Headers/buildScreenReaderInstructions.js} +33 -30
- package/dist/cjs/parts/Headers/buildScreenReaderInstructions.js.map +7 -0
- package/dist/cjs/parts/Headers/index.js +15 -7
- package/dist/cjs/parts/Headers/index.js.map +2 -2
- package/dist/cjs/parts/Headers/useHeaderCellHandlers.js +44 -8
- package/dist/cjs/parts/Headers/useHeaderCellHandlers.js.map +2 -2
- package/dist/cjs/parts/Headers/useHeaderResizer.js +13 -3
- package/dist/cjs/parts/Headers/useHeaderResizer.js.map +2 -2
- package/dist/cjs/parts/HoC/withDnDSortableColumnContext.js +3 -1
- package/dist/cjs/parts/HoC/withDnDSortableColumnContext.js.map +2 -2
- package/dist/cjs/parts/VirtualRowsList.js +2 -0
- package/dist/cjs/parts/VirtualRowsList.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +10 -3
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/styled.js +55 -52
- package/dist/cjs/styled.js.map +2 -2
- package/dist/esm/addons/Columns/ColumnSelectMultiple/ColumnSelectMultiple.js +15 -3
- package/dist/esm/addons/Columns/ColumnSelectMultiple/ColumnSelectMultiple.js.map +2 -2
- package/dist/esm/addons/Editables/index.js.map +1 -1
- package/dist/esm/addons/Filters/Components/SelectFilter/BaseSelectFilter.js.map +2 -2
- package/dist/esm/addons/Filters/Components/SelectFilter/BaseSelectFilterV2.js.map +2 -2
- package/dist/esm/configs/constants.js +4 -0
- package/dist/esm/configs/constants.js.map +2 -2
- package/dist/esm/configs/useAutocalculated/index.js +15 -1
- package/dist/esm/configs/useAutocalculated/index.js.map +2 -2
- package/dist/esm/configs/useStore/useStore.js +46 -0
- package/dist/esm/configs/useStore/useStore.js.map +2 -2
- package/dist/esm/constants/index.js +1 -0
- package/dist/esm/constants/index.js.map +2 -2
- package/dist/esm/exported-related/FilterBar/PillsFromDataTableFilters.js +2 -1
- package/dist/esm/exported-related/FilterBar/PillsFromDataTableFilters.js.map +2 -2
- package/dist/esm/exported-related/FilterPopover/FilterPopoverV2.js +15 -9
- package/dist/esm/exported-related/FilterPopover/FilterPopoverV2.js.map +2 -2
- package/dist/esm/exported-related/FilterPopover/index.js +31 -7
- package/dist/esm/exported-related/FilterPopover/index.js.map +2 -2
- package/dist/esm/package.json +1 -4
- package/dist/esm/parts/Cells/Cell.js +1 -1
- package/dist/esm/parts/Cells/Cell.js.map +2 -2
- package/dist/esm/parts/Cells/CellFactory.js +1 -1
- package/dist/esm/parts/Cells/CellFactory.js.map +2 -2
- package/dist/esm/parts/FilterBar/FiltersBar.js +2 -1
- package/dist/esm/parts/FilterBar/FiltersBar.js.map +2 -2
- package/dist/esm/parts/Headers/HeaderCell.js +13 -24
- package/dist/esm/parts/Headers/HeaderCell.js.map +2 -2
- package/dist/esm/parts/Headers/HeaderCellTitle.js +24 -4
- package/dist/esm/parts/Headers/HeaderCellTitle.js.map +2 -2
- package/dist/esm/parts/Headers/HeaderResizer.js +41 -19
- package/dist/esm/parts/Headers/HeaderResizer.js.map +2 -2
- package/dist/esm/parts/Headers/buildScreenReaderInstructions.js +33 -0
- package/dist/esm/parts/Headers/buildScreenReaderInstructions.js.map +7 -0
- package/dist/esm/parts/Headers/index.js +15 -7
- package/dist/esm/parts/Headers/index.js.map +2 -2
- package/dist/esm/parts/Headers/useHeaderCellHandlers.js +44 -8
- package/dist/esm/parts/Headers/useHeaderCellHandlers.js.map +2 -2
- package/dist/esm/parts/Headers/useHeaderResizer.js +14 -4
- package/dist/esm/parts/Headers/useHeaderResizer.js.map +2 -2
- package/dist/esm/parts/HoC/withDnDSortableColumnContext.js +3 -1
- package/dist/esm/parts/HoC/withDnDSortableColumnContext.js.map +2 -2
- package/dist/esm/parts/VirtualRowsList.js +2 -0
- package/dist/esm/parts/VirtualRowsList.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +10 -3
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/styled.js +13 -10
- package/dist/esm/styled.js.map +2 -2
- package/dist/types/TruncatedTooltipText.d.ts +1 -1
- package/dist/types/addons/Editables/index.d.ts +1 -1
- package/dist/types/configs/constants.d.ts +2 -0
- package/dist/types/constants/index.d.ts +4 -0
- package/dist/types/exported-related/Skeleton/SkeletonCell.d.ts +2 -1
- package/dist/types/exported-related/Skeleton/SkeletonHeaderCell.d.ts +2 -1
- package/dist/types/parts/Headers/HeaderCellGroup.d.ts +1 -1
- package/dist/types/parts/Headers/buildScreenReaderInstructions.d.ts +19 -0
- package/dist/types/parts/Headers/useHeaderResizer.d.ts +1 -0
- package/dist/types/parts/HoC/withConditionalDnDSortableContext.d.ts +1 -1
- package/dist/types/parts/HoC/withDnDSortableColumnContext.d.ts +1 -1
- package/dist/types/parts/HoC/withDnDSortableRowContext.d.ts +1 -1
- package/dist/types/parts/Loader.d.ts +1 -1
- package/dist/types/parts/Row.d.ts +1 -1
- package/dist/types/parts/SkeletonTable.d.ts +1 -1
- package/dist/types/parts/TableContent.d.ts +2 -1
- package/dist/types/parts/VirtualRowsList.d.ts +2 -1
- package/dist/types/react-desc-prop-types.d.ts +11 -0
- package/dist/types/styled.d.ts +2 -1
- package/package.json +34 -34
- package/skills/ds-data-table-slots/SKILL.md +11 -3
- package/dist/cjs/exported-related/FilterPopover/useOnClickOutside.js.map +0 -7
- package/dist/esm/exported-related/FilterPopover/useOnClickOutside.js +0 -30
- package/dist/esm/exported-related/FilterPopover/useOnClickOutside.js.map +0 -7
- package/dist/types/exported-related/FilterPopover/useOnClickOutside.d.ts +0 -1
- package/dist/types/tests/DSDataTable.exports.test.d.ts +0 -1
- package/dist/types/tests/DSDataTable.get-owner-props-arguments-slots.test.d.ts +0 -1
- package/dist/types/tests/a11y/aria-label-customization.test.d.ts +0 -1
- package/dist/types/tests/a11y/aria-level.test.d.ts +0 -1
- package/dist/types/tests/a11y/internally-printed-ids.A11y.test.d.ts +0 -1
- package/dist/types/tests/a11y/number-of-cells-and-columnheader.test.d.ts +0 -1
- package/dist/types/tests/a11y/out-of-the-box-filters.A11y.test.d.ts +0 -1
- package/dist/types/tests/callbacks/editableCell.events.test.d.ts +0 -1
- package/dist/types/tests/callbacks/header.events.test.d.ts +0 -1
- package/dist/types/tests/callbacks/pagination.events.test.d.ts +0 -1
- package/dist/types/tests/callbacks/row.events.test.d.ts +0 -1
- package/dist/types/tests/data-testid/DSDataTable.data-testid.test.d.ts +0 -1
- package/dist/types/tests/data-testid/Renderers.d.ts +0 -36
- package/dist/types/tests/filters/DSDatatable.PUI-17318.test.d.ts +0 -1
- package/dist/types/tests/filters/combobox-filter.test.d.ts +0 -1
- package/dist/types/tests/filters/currency-range-filter-PUI-12735.test.d.ts +0 -1
- package/dist/types/tests/filters/free-text-search-filter.test.d.ts +0 -1
- package/dist/types/tests/keyboard/dragAndDropColumns.test.d.ts +0 -1
- package/dist/types/tests/keyboard/dragAndDropRows.test.d.ts +0 -1
- package/dist/types/tests/keyboard/expandable.test.d.ts +0 -1
- package/dist/types/tests/keyboard/grouped.test.d.ts +0 -1
- package/dist/types/tests/keyboard/masterDetails.test.d.ts +0 -1
- package/dist/types/tests/keyboard/navigation.test.d.ts +0 -1
- package/dist/types/tests/keyboard/selectMultiple.test.d.ts +0 -1
- package/dist/types/tests/keyboard/selectSingle.test.d.ts +0 -1
- package/dist/types/tests/keyboard/sort.test.d.ts +0 -1
- package/dist/types/tests/playwright/DSDataTable.ControlledFilterTestRenderer.d.ts +0 -2
- package/dist/types/tests/playwright/DSDataTable.ControlledHiddenPanelTestRenderer.d.ts +0 -1
- package/dist/types/tests/playwright/DSDataTable.ControlledSortTestRenderer.d.ts +0 -2
- package/dist/types/tests/playwright/DSDataTable.slot-contracts-dynamic.test.playwright.d.ts +0 -1
- package/dist/types/tests/playwright/DSDataTable.test.playwright.d.ts +0 -1
- package/dist/types/tests/playwright/DSDataTableDropIndicatorTestRenderer.d.ts +0 -1
- package/dist/types/tests/playwright/GenericExampleTable.d.ts +0 -1
- package/dist/types/tests/render/cellStyle.test.d.ts +0 -1
- package/dist/types/tests/render/empty-state.test.d.ts +0 -1
- package/dist/types/tests/render/selectMultiple.test.d.ts +0 -1
- package/dist/types/tests/render/toolbar.test.d.ts +0 -1
- package/dist/types/tests/utils/index.d.ts +0 -65
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/Headers/HeaderCellTitle.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { TruncatedTooltipText } from '../../TruncatedTooltipText.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\nimport type { SortableItemContextType } from '../HoC/SortableItemContext.js';\nimport { RequiredDot } from './RequiredDot.js';\nimport { DATA_TESTID } from '../../configs/constants.js';\n\ninterface HeaderCellTitleProps {\n column: DSDataTableT.InternalColumn;\n draggableProps: SortableItemContextType['draggableProps'];\n textWrap: 'wrap' | 'wrap-all' | 'truncate';\n}\n\nconst StringTitle = ({ text, textWrap }: { textWrap: HeaderCellTitleProps['textWrap']; text: string }) =>\n textWrap === 'truncate' ? <TruncatedTooltipText value={text} /> : text;\n\nexport const HeaderCellTitle: React.ComponentType<HeaderCellTitleProps> = ({ column, draggableProps, textWrap }) => (\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { TruncatedTooltipText } from '../../TruncatedTooltipText.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\nimport type { SortableItemContextType } from '../HoC/SortableItemContext.js';\nimport { RequiredDot } from './RequiredDot.js';\nimport { DATA_TESTID } from '../../configs/constants.js';\n\ninterface HeaderCellTitleProps {\n column: DSDataTableT.InternalColumn;\n draggableProps: SortableItemContextType['draggableProps'];\n textWrap: 'wrap' | 'wrap-all' | 'truncate';\n}\n\nconst resolveWrapStyle = (textWrap: HeaderCellTitleProps['textWrap']): React.CSSProperties => {\n if (textWrap === 'wrap-all') return { whiteSpace: 'pre-wrap', wordBreak: 'break-all' };\n if (textWrap === 'wrap') return { whiteSpace: 'pre-wrap', overflowWrap: 'break-word' };\n return {};\n};\n\nconst StringTitle = ({ text, textWrap }: { textWrap: HeaderCellTitleProps['textWrap']; text: string }) =>\n textWrap === 'truncate' ? <TruncatedTooltipText value={text} /> : text;\n\nexport const HeaderCellTitle: React.ComponentType<HeaderCellTitleProps> = ({ column, draggableProps, textWrap }) => {\n const effectiveTextWrap = column.textWrap || textWrap;\n return (\n <div\n style={{\n display: 'flex',\n alignItems: 'flex-start',\n paddingTop: typeof column.Header === 'string' ? '5px' : undefined,\n ...resolveWrapStyle(effectiveTextWrap),\n }}\n data-testid={DATA_TESTID.DATA_TABLE_HEADER_CELL_TITLE}\n >\n {typeof column.Header === 'string' ? (\n <StringTitle text={column.Header} textWrap={effectiveTextWrap} />\n ) : (\n <column.Header column={column} draggableProps={draggableProps} />\n )}\n {column.required && <RequiredDot />}\n </div>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADoBK;AAnB5B,kCAAqC;AAGrC,yBAA4B;AAC5B,uBAA4B;AAQ5B,MAAM,mBAAmB,CAAC,aAAoE;AAC5F,MAAI,aAAa,WAAY,QAAO,EAAE,YAAY,YAAY,WAAW,YAAY;AACrF,MAAI,aAAa,OAAQ,QAAO,EAAE,YAAY,YAAY,cAAc,aAAa;AACrF,SAAO,CAAC;AACV;AAEA,MAAM,cAAc,CAAC,EAAE,MAAM,SAAS,MACpC,aAAa,aAAa,4CAAC,oDAAqB,OAAO,MAAM,IAAK;AAE7D,MAAM,kBAA6D,CAAC,EAAE,QAAQ,gBAAgB,SAAS,MAAM;AAClH,QAAM,oBAAoB,OAAO,YAAY;AAC7C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,YAAY,OAAO,OAAO,WAAW,WAAW,QAAQ;AAAA,QACxD,GAAG,iBAAiB,iBAAiB;AAAA,MACvC;AAAA,MACA,eAAa,6BAAY;AAAA,MAExB;AAAA,eAAO,OAAO,WAAW,WACxB,4CAAC,eAAY,MAAM,OAAO,QAAQ,UAAU,mBAAmB,IAE/D,4CAAC,OAAO,QAAP,EAAc,QAAgB,gBAAgC;AAAA,QAEhE,OAAO,YAAY,4CAAC,kCAAY;AAAA;AAAA;AAAA,EACnC;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -37,13 +37,23 @@ var import_react = require("react");
|
|
|
37
37
|
var import_styled = require("../../styled.js");
|
|
38
38
|
var import_useHeaderResizer = require("./useHeaderResizer.js");
|
|
39
39
|
var import_createInternalAndPropsContext = require("../../configs/useStore/createInternalAndPropsContext.js");
|
|
40
|
+
var import_constants = require("../../configs/constants.js");
|
|
40
41
|
const stopPropagation = (e) => e.stopPropagation();
|
|
42
|
+
const HIDDEN_STYLE = { display: "none" };
|
|
43
|
+
const RESIZE_INSTRUCTION = "Use the left and right arrow keys to increase or decrease the column width.";
|
|
44
|
+
const bracketBound = (configuredBound, columnWidth, pickWider) => pickWider(configuredBound, columnWidth ?? configuredBound);
|
|
41
45
|
const HeaderResizer = ({ column, innerRef, isReachable }) => {
|
|
42
|
-
const { isResizing, onResizeStart, onResizeEnd, onResizeHandler, handleKeyboardResize } = (0, import_useHeaderResizer.useHeaderResizer)({
|
|
46
|
+
const { isResizing, columnWidth, onResizeStart, onResizeEnd, onResizeHandler, handleKeyboardResize } = (0, import_useHeaderResizer.useHeaderResizer)({
|
|
43
47
|
columnId: column.id,
|
|
44
48
|
innerRef
|
|
45
49
|
});
|
|
46
50
|
const getOwnerProps = (0, import_createInternalAndPropsContext.usePropsStore)((store) => store.get);
|
|
51
|
+
const resizeLabel = typeof column.Header === "string" ? `Resize ${column.Header} column` : "Resize column";
|
|
52
|
+
const instructionId = `resize-instr-${column.id}`.replace(/ /g, "");
|
|
53
|
+
const valueMin = bracketBound(column.minWidth ?? import_constants.DEFAULT_MIN_COLUMN_WIDTH, columnWidth, Math.min);
|
|
54
|
+
const valueMax = bracketBound(column.maxWidth ?? import_constants.DEFAULT_MAX_COLUMN_WIDTH, columnWidth, Math.max);
|
|
55
|
+
const sliderValue = columnWidth ?? valueMin;
|
|
56
|
+
const valueText = columnWidth === void 0 ? void 0 : `${columnWidth} pixels`;
|
|
47
57
|
(0, import_react.useEffect)(() => {
|
|
48
58
|
const addEvents = () => {
|
|
49
59
|
document.addEventListener("mousemove", onResizeHandler);
|
|
@@ -61,22 +71,34 @@ const HeaderResizer = ({ column, innerRef, isReachable }) => {
|
|
|
61
71
|
else removeEvents();
|
|
62
72
|
return removeEvents;
|
|
63
73
|
}, [isResizing, onResizeHandler, onResizeEnd]);
|
|
64
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
76
|
+
import_styled.StyledResizer,
|
|
77
|
+
{
|
|
78
|
+
type: "range",
|
|
79
|
+
min: valueMin,
|
|
80
|
+
max: valueMax,
|
|
81
|
+
value: sliderValue,
|
|
82
|
+
"aria-valuenow": columnWidth,
|
|
83
|
+
"aria-valuemin": valueMin,
|
|
84
|
+
"aria-valuemax": valueMax,
|
|
85
|
+
"aria-valuetext": valueText,
|
|
86
|
+
"aria-label": resizeLabel,
|
|
87
|
+
"aria-describedby": instructionId,
|
|
88
|
+
"aria-hidden": isReachable ? void 0 : true,
|
|
89
|
+
tabIndex: isReachable ? 0 : -1,
|
|
90
|
+
innerRef,
|
|
91
|
+
draggable: false,
|
|
92
|
+
onMouseDown: onResizeStart,
|
|
93
|
+
onTouchStart: onResizeStart,
|
|
94
|
+
onMouseUp: onResizeEnd,
|
|
95
|
+
onTouchEnd: onResizeEnd,
|
|
96
|
+
onClick: stopPropagation,
|
|
97
|
+
onKeyDown: handleKeyboardResize,
|
|
98
|
+
getOwnerProps
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { id: instructionId, style: HIDDEN_STYLE, children: RESIZE_INSTRUCTION })
|
|
102
|
+
] });
|
|
81
103
|
};
|
|
82
104
|
//# sourceMappingURL=HeaderResizer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/Headers/HeaderResizer.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect } from 'react';\nimport { StyledResizer } from '../../styled.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\nimport { useHeaderResizer } from './useHeaderResizer.js';\nimport { usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\n\nconst stopPropagation = (e: React.MouseEvent) => e.stopPropagation();\n\nexport const HeaderResizer: React.ComponentType<{\n column: DSDataTableT.InternalColumn;\n innerRef: React.MutableRefObject<HTMLInputElement | null>;\n isReachable: boolean;\n}> = ({ column, innerRef, isReachable }) => {\n const { isResizing, onResizeStart, onResizeEnd, onResizeHandler, handleKeyboardResize }
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { useEffect } from 'react';\nimport { StyledResizer } from '../../styled.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\nimport { useHeaderResizer } from './useHeaderResizer.js';\nimport { usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\nimport { DEFAULT_MAX_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH } from '../../configs/constants.js';\n\nconst stopPropagation = (e: React.MouseEvent | React.KeyboardEvent) => e.stopPropagation();\n\n/** Instruction node \u2014 referenced via aria-describedby, never rendered visually. */\nconst HIDDEN_STYLE: React.CSSProperties = { display: 'none' };\nconst RESIZE_INSTRUCTION = 'Use the left and right arrow keys to increase or decrease the column width.';\n\n/**\n * PUI-17784: brackets the announced bounds around the actual current width, not just the configured\n * ones. The resize clamp (narrow() in useHeaderResizer.ts) only bounds INTERACTIVE resizing \u2014 an\n * explicit column.width set outside [minWidth, maxWidth] renders as-is on first paint (pre-existing,\n * unrelated to this ticket), so columnWidth can start below configuredMin or above configuredMax.\n * Reporting aria-valuenow outside [aria-valuemin, aria-valuemax] is an internally-inconsistent ARIA\n * value \u2014 exactly the class of meaningless-value problem this ticket exists to fix, just in a\n * narrower corner. Widening the bound to include the real value (rather than clamping the value to a\n * bound the column isn't actually honoring) keeps the announcement accurate; it self-corrects to the\n * configured bound on the first interactive resize, since narrow() clamps from then on.\n */\nconst bracketBound = (configuredBound: number, columnWidth: number | undefined, pickWider: typeof Math.min) =>\n pickWider(configuredBound, columnWidth ?? configuredBound);\n\nexport const HeaderResizer: React.ComponentType<{\n column: DSDataTableT.InternalColumn;\n innerRef: React.MutableRefObject<HTMLInputElement | null>;\n isReachable: boolean;\n}> = ({ column, innerRef, isReachable }) => {\n const { isResizing, columnWidth, onResizeStart, onResizeEnd, onResizeHandler, handleKeyboardResize } =\n useHeaderResizer({\n columnId: column.id,\n innerRef,\n });\n const getOwnerProps = usePropsStore((store) => store.get);\n\n const resizeLabel = typeof column.Header === 'string' ? `Resize ${column.Header} column` : 'Resize column';\n const instructionId = `resize-instr-${column.id}`.replace(/ /g, '');\n\n const valueMin = bracketBound(column.minWidth ?? DEFAULT_MIN_COLUMN_WIDTH, columnWidth, Math.min);\n const valueMax = bracketBound(column.maxWidth ?? DEFAULT_MAX_COLUMN_WIDTH, columnWidth, Math.max);\n const sliderValue = columnWidth ?? valueMin;\n const valueText = columnWidth === undefined ? undefined : `${columnWidth} pixels`;\n\n // This setups the event listeners for the resize (only for mouse)\n // It reacts to the isResizing state change\n useEffect(() => {\n const addEvents = () => {\n document.addEventListener('mousemove', onResizeHandler);\n document.addEventListener('touchmove', onResizeHandler);\n document.addEventListener('mouseup', onResizeEnd);\n document.addEventListener('touchend', onResizeEnd);\n };\n const removeEvents = () => {\n document.removeEventListener('mousemove', onResizeHandler);\n document.removeEventListener('touchmove', onResizeHandler);\n document.removeEventListener('mouseup', onResizeEnd);\n document.removeEventListener('touchend', onResizeEnd);\n };\n\n if (isResizing) addEvents();\n else removeEvents();\n\n // just in case the component is unmounted\n return removeEvents;\n }, [isResizing, onResizeHandler, onResizeEnd]);\n\n return (\n <>\n <StyledResizer\n type=\"range\"\n min={valueMin}\n max={valueMax}\n value={sliderValue}\n aria-valuenow={columnWidth}\n aria-valuemin={valueMin}\n aria-valuemax={valueMax}\n aria-valuetext={valueText}\n aria-label={resizeLabel}\n aria-describedby={instructionId}\n aria-hidden={isReachable ? undefined : true}\n tabIndex={isReachable ? 0 : -1}\n innerRef={innerRef}\n draggable={false}\n onMouseDown={onResizeStart}\n onTouchStart={onResizeStart}\n onMouseUp={onResizeEnd}\n onTouchEnd={onResizeEnd}\n onClick={stopPropagation}\n onKeyDown={handleKeyboardResize}\n getOwnerProps={getOwnerProps}\n />\n <span id={instructionId} style={HIDDEN_STYLE}>\n {R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,eAAe;AACzD,eAAS,oBAAoB,aAAa,eAAe;AACzD,eAAS,oBAAoB,WAAW,WAAW;AACnD,eAAS,oBAAoB,YAAY,WAAW;AAAA,IACtD;AAEA,QAAI,WAAY,WAAU;AAAA,QACrB,cAAa;AAGlB,WAAO;AAAA,EACT,GAAG,CAAC,YAAY,iBAAiB,WAAW,CAAC;AAE7C,SACE,4EACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,QACL,OAAO;AAAA,QACP,iBAAe;AAAA,QACf,iBAAe;AAAA,QACf,iBAAe;AAAA,QACf,kBAAgB;AAAA,QAChB,cAAY;AAAA,QACZ,oBAAkB;AAAA,QAClB,eAAa,cAAc,SAAY;AAAA,QACvC,UAAU,cAAc,IAAI;AAAA,QAC5B;AAAA,QACA,WAAW;AAAA,QACX,aAAa;AAAA,QACb,cAAc;AAAA,QACd,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,WAAW;AAAA,QACX;AAAA;AAAA,IACF;AAAA,IACA,4CAAC,UAAK,IAAI,eAAe,OAAO,cAC7B,8BACH;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -26,35 +26,38 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
29
|
+
var buildScreenReaderInstructions_exports = {};
|
|
30
|
+
__export(buildScreenReaderInstructions_exports, {
|
|
31
|
+
buildScreenReaderInstructions: () => buildScreenReaderInstructions
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(buildScreenReaderInstructions_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
(0,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
35
|
+
const joinAffordances = (items) => {
|
|
36
|
+
if (items.length <= 1) return items[0] ?? "";
|
|
37
|
+
if (items.length === 2) return `${items[0]} and ${items[1]}`;
|
|
38
|
+
return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
39
|
+
};
|
|
40
|
+
const SORT_INSTRUCTION = "You can sort the data ascendingly or descendingly by this column. Use the up / down arrow keys to do so.";
|
|
41
|
+
const buildScreenReaderInstructions = ({
|
|
42
|
+
colSpan,
|
|
43
|
+
draggable,
|
|
44
|
+
filterable,
|
|
45
|
+
sortable,
|
|
46
|
+
resizable
|
|
47
|
+
}) => {
|
|
48
|
+
const prefix = colSpan === 1 ? "" : "Column Group. ";
|
|
49
|
+
const sentences = [];
|
|
50
|
+
const enterAffordances = [];
|
|
51
|
+
if (draggable) enterAffordances.push("draggable");
|
|
52
|
+
if (filterable) enterAffordances.push("filterable");
|
|
53
|
+
if (resizable) enterAffordances.push("resizable");
|
|
54
|
+
if (enterAffordances.length > 0) {
|
|
55
|
+
const interaction = enterAffordances.length > 1 ? "these interactions" : "this interaction";
|
|
56
|
+
sentences.push(
|
|
57
|
+
`This column is ${joinAffordances(enterAffordances)}. To enable ${interaction} press the enter key.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (sortable) sentences.push(SORT_INSTRUCTION);
|
|
61
|
+
return `${prefix}${sentences.join(" ")}`;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=buildScreenReaderInstructions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/Headers/buildScreenReaderInstructions.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Joins affordance words into a natural-language list:\n * ['a'] -> 'a'\n * ['a', 'b'] -> 'a and b'\n * ['a', 'b', 'c'] -> 'a, b and c'\n */\nconst joinAffordances = (items: string[]): string => {\n if (items.length <= 1) return items[0] ?? '';\n if (items.length === 2) return `${items[0]} and ${items[1]}`;\n return `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`;\n};\n\nconst SORT_INSTRUCTION =\n 'You can sort the data ascendingly or descendingly by this column. Use the up / down arrow keys to do so.';\n\n/**\n * Builds the screen-reader instructions announced for a column header (via the header's\n * aria-describedby).\n *\n * Draggable, filterable and resizable share the SAME activation \u2014 pressing Enter on the focused\n * header reveals and focuses those controls (see useHeaderCellHandlers onKeyDown) \u2014 so they are\n * announced together as a single grammatical list with ONE \"press the enter key\" instruction, for\n * any combination/permutation, instead of repeating the instruction per affordance.\n *\n * Sorting is a distinct interaction (Up / Down arrow keys directly on the header, no Enter), so it\n * gets its own sentence. Wording pending a11y SME review.\n */\nexport const buildScreenReaderInstructions = ({\n colSpan,\n draggable,\n filterable,\n sortable,\n resizable,\n}: {\n colSpan: number;\n draggable: boolean;\n filterable: boolean;\n sortable: boolean;\n resizable: boolean;\n}): string => {\n const prefix = colSpan === 1 ? '' : 'Column Group. ';\n const sentences: string[] = [];\n\n // Enter-activated affordances \u2014 combined into one sentence regardless of which are present.\n const enterAffordances: string[] = [];\n if (draggable) enterAffordances.push('draggable');\n if (filterable) enterAffordances.push('filterable');\n if (resizable) enterAffordances.push('resizable');\n if (enterAffordances.length > 0) {\n const interaction = enterAffordances.length > 1 ? 'these interactions' : 'this interaction';\n sentences.push(\n `This column is ${joinAffordances(enterAffordances)}. To enable ${interaction} press the enter key.`,\n );\n }\n\n // Sorting uses the up / down arrow keys directly on the focused header.\n if (sortable) sentences.push(SORT_INSTRUCTION);\n\n return `${prefix}${sentences.join(' ')}`;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADMvB,MAAM,kBAAkB,CAAC,UAA4B;AACnD,MAAI,MAAM,UAAU,EAAG,QAAO,MAAM,CAAC,KAAK;AAC1C,MAAI,MAAM,WAAW,EAAG,QAAO,GAAG,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,CAAC;AAC1D,SAAO,GAAG,MAAM,MAAM,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,QAAQ,MAAM,MAAM,SAAS,CAAC,CAAC;AACxE;AAEA,MAAM,mBACJ;AAcK,MAAM,gCAAgC,CAAC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAMc;AACZ,QAAM,SAAS,YAAY,IAAI,KAAK;AACpC,QAAM,YAAsB,CAAC;AAG7B,QAAM,mBAA6B,CAAC;AACpC,MAAI,UAAW,kBAAiB,KAAK,WAAW;AAChD,MAAI,WAAY,kBAAiB,KAAK,YAAY;AAClD,MAAI,UAAW,kBAAiB,KAAK,WAAW;AAChD,MAAI,iBAAiB,SAAS,GAAG;AAC/B,UAAM,cAAc,iBAAiB,SAAS,IAAI,uBAAuB;AACzE,cAAU;AAAA,MACR,kBAAkB,gBAAgB,gBAAgB,CAAC,eAAe,WAAW;AAAA,IAC/E;AAAA,EACF;AAGA,MAAI,SAAU,WAAU,KAAK,gBAAgB;AAE7C,SAAO,GAAG,MAAM,GAAG,UAAU,KAAK,GAAG,CAAC;AACxC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -45,7 +45,7 @@ const HeadersComp = () => {
|
|
|
45
45
|
const isSkeleton = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.isSkeleton);
|
|
46
46
|
const colsLayoutStyle = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.colsLayoutStyle);
|
|
47
47
|
const visibleColumns = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.visibleColumns);
|
|
48
|
-
const
|
|
48
|
+
const columnHeaderCallbackRef = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.columnHeaderCallbackRef);
|
|
49
49
|
const virtualListRef = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.virtualListRef);
|
|
50
50
|
const getOwnerProps = (0, import_createInternalAndPropsContext.usePropsStore)((store) => store.get);
|
|
51
51
|
(0, import_react.useEffect)(() => {
|
|
@@ -54,16 +54,24 @@ const HeadersComp = () => {
|
|
|
54
54
|
if (visibleColumns.length === 0 && isSkeleton) {
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
|
-
import_styled.
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
|
+
import_styled.StyledHeadWrapper,
|
|
59
59
|
{
|
|
60
|
-
role: "row",
|
|
61
60
|
colsLayoutStyle,
|
|
62
|
-
|
|
61
|
+
innerRef: columnHeaderCallbackRef,
|
|
63
62
|
getOwnerProps,
|
|
64
|
-
children:
|
|
63
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SortableHeaderCell.SortableHeaderCell, { items: visibleColumns, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
import_styled.StyledHeadTr,
|
|
65
|
+
{
|
|
66
|
+
role: "row",
|
|
67
|
+
colsLayoutStyle,
|
|
68
|
+
isExpandable,
|
|
69
|
+
getOwnerProps,
|
|
70
|
+
children: visibleColumns.map((h, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_HeaderCellGroup.HeaderCellGroupSortable, { header: h, isLast: index === visibleColumns.length - 1 }, h.id))
|
|
71
|
+
}
|
|
72
|
+
) })
|
|
65
73
|
}
|
|
66
|
-
)
|
|
74
|
+
);
|
|
67
75
|
};
|
|
68
76
|
const Headers = (0, import_withConditionalDnDColumnContext.withConditionalDnDColumnContext)(HeadersComp);
|
|
69
77
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/Headers/index.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect } from 'react';\nimport { StyledHeadWrapper, StyledHeadTr } from '../../styled.js';\nimport { withConditionalDnDColumnContext } from '../HoC/withConditionalDnDColumnContext.js';\nimport { HeaderCellGroupSortable } from './HeaderCellGroup.js';\nimport { SortableHeaderCell } from '../SortableHeaderCell.js';\nimport { setSubColumnsGridLayout } from '../../helpers/gridLayoutHelpers.js';\nimport { usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\n\nconst HeadersComp = () => {\n const isExpandable = usePropsStore((state) => state.isExpandable);\n const isSkeleton = usePropsStore((state) => state.isSkeleton);\n const colsLayoutStyle = usePropsStore((state) => state.colsLayoutStyle);\n const visibleColumns = usePropsStore((state) => state.visibleColumns);\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { useEffect } from 'react';\nimport { StyledHeadWrapper, StyledHeadTr } from '../../styled.js';\nimport { withConditionalDnDColumnContext } from '../HoC/withConditionalDnDColumnContext.js';\nimport { HeaderCellGroupSortable } from './HeaderCellGroup.js';\nimport { SortableHeaderCell } from '../SortableHeaderCell.js';\nimport { setSubColumnsGridLayout } from '../../helpers/gridLayoutHelpers.js';\nimport { usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\n\nconst HeadersComp = () => {\n const isExpandable = usePropsStore((state) => state.isExpandable);\n const isSkeleton = usePropsStore((state) => state.isSkeleton);\n const colsLayoutStyle = usePropsStore((state) => state.colsLayoutStyle);\n const visibleColumns = usePropsStore((state) => state.visibleColumns);\n const columnHeaderCallbackRef = usePropsStore((state) => state.columnHeaderCallbackRef);\n const virtualListRef = usePropsStore((state) => state.virtualListRef);\n const getOwnerProps = usePropsStore((store) => store.get);\n\n useEffect(() => {\n // TODO: remove this, for further info see the comment on setSubColumnsGridLayout\n setSubColumnsGridLayout(virtualListRef.current, visibleColumns, true);\n }, [virtualListRef, visibleColumns]);\n\n if (visibleColumns.length === 0 && isSkeleton) {\n return null;\n }\n return (\n <StyledHeadWrapper\n colsLayoutStyle={colsLayoutStyle}\n innerRef={columnHeaderCallbackRef}\n getOwnerProps={getOwnerProps}\n >\n <SortableHeaderCell items={visibleColumns}>\n <StyledHeadTr\n role=\"row\"\n colsLayoutStyle={colsLayoutStyle}\n isExpandable={isExpandable}\n getOwnerProps={getOwnerProps}\n >\n {visibleColumns.map((h, index) => (\n <HeaderCellGroupSortable header={h} key={h.id} isLast={index === visibleColumns.length - 1} />\n ))}\n </StyledHeadTr>\n </SortableHeaderCell>\n </StyledHeadWrapper>\n );\n};\n\nexport const Headers = withConditionalDnDColumnContext(HeadersComp);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADuCX;AAvCZ,mBAAiC;AACjC,oBAAgD;AAChD,6CAAgD;AAChD,6BAAwC;AACxC,gCAAmC;AACnC,+BAAwC;AACxC,2CAA8B;AAE9B,MAAM,cAAc,MAAM;AACxB,QAAM,mBAAe,oDAAc,CAAC,UAAU,MAAM,YAAY;AAChE,QAAM,iBAAa,oDAAc,CAAC,UAAU,MAAM,UAAU;AAC5D,QAAM,sBAAkB,oDAAc,CAAC,UAAU,MAAM,eAAe;AACtE,QAAM,qBAAiB,oDAAc,CAAC,UAAU,MAAM,cAAc;AACpE,QAAM,8BAA0B,oDAAc,CAAC,UAAU,MAAM,uBAAuB;AACtF,QAAM,qBAAiB,oDAAc,CAAC,UAAU,MAAM,cAAc;AACpE,QAAM,oBAAgB,oDAAc,CAAC,UAAU,MAAM,GAAG;AAExD,8BAAU,MAAM;AAEd,0DAAwB,eAAe,SAAS,gBAAgB,IAAI;AAAA,EACtE,GAAG,CAAC,gBAAgB,cAAc,CAAC;AAEnC,MAAI,eAAe,WAAW,KAAK,YAAY;AAC7C,WAAO;AAAA,EACT;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MAEA,sDAAC,gDAAmB,OAAO,gBACzB;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UAEC,yBAAe,IAAI,CAAC,GAAG,UACtB,4CAAC,kDAAwB,QAAQ,GAAc,QAAQ,UAAU,eAAe,SAAS,KAAhD,EAAE,EAAiD,CAC7F;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;AAEO,MAAM,cAAU,wEAAgC,WAAW;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -75,18 +75,27 @@ const useHeaderCellHandlers = ({
|
|
|
75
75
|
const visibleColumns = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.visibleColumns);
|
|
76
76
|
const setFocusedRowId = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.setFocusedRowId);
|
|
77
77
|
const patchHeader = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.patchHeader);
|
|
78
|
+
const closeFilterMenuIfOpen = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.closeFilterMenuIfOpen);
|
|
79
|
+
const resetAllHeadersExcept = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.resetAllHeadersExcept);
|
|
80
|
+
const hoveredColumnId = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.hoveredColumnId);
|
|
81
|
+
const setHoveredColumnId = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.setHoveredColumnId);
|
|
78
82
|
const reduxHeaders = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.reduxHeaders);
|
|
79
83
|
const reduxHeader = (0, import_react.useMemo)(() => reduxHeaders[column.id], [reduxHeaders, column]);
|
|
80
84
|
const headerRef = referenceColumn.current;
|
|
81
85
|
const onMouseEnter = (0, import_react.useCallback)(() => {
|
|
86
|
+
setHoveredColumnId(column.id);
|
|
82
87
|
patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD, hasSortingCaret));
|
|
83
|
-
}, [column.id, hasDnD, hasFilter, patchHeader, reduxHeader, hasSortingCaret]);
|
|
88
|
+
}, [column.id, hasDnD, hasFilter, patchHeader, reduxHeader, hasSortingCaret, setHoveredColumnId]);
|
|
84
89
|
const onMouseLeave = (0, import_react.useCallback)(() => {
|
|
90
|
+
setHoveredColumnId(
|
|
91
|
+
(currentHoveredColumnId) => currentHoveredColumnId === column.id ? null : currentHoveredColumnId
|
|
92
|
+
);
|
|
85
93
|
if (!headerRef?.contains(document.activeElement)) {
|
|
86
94
|
patchHeader(column.id, buildNextHeader(reduxHeader, false, hasFilter, hasDnD, false));
|
|
87
95
|
}
|
|
88
|
-
}, [column.id, hasDnD, hasFilter, headerRef, patchHeader, reduxHeader]);
|
|
96
|
+
}, [column.id, hasDnD, hasFilter, headerRef, patchHeader, reduxHeader, setHoveredColumnId]);
|
|
89
97
|
const handleSort = (0, import_react.useCallback)(() => {
|
|
98
|
+
closeFilterMenuIfOpen(column.id);
|
|
90
99
|
if (column.canSort) {
|
|
91
100
|
onColumnSortChange?.({
|
|
92
101
|
column: column.id,
|
|
@@ -98,7 +107,15 @@ const useHeaderCellHandlers = ({
|
|
|
98
107
|
column.isSortedDesc ? "ASC" : "DESC"
|
|
99
108
|
);
|
|
100
109
|
}
|
|
101
|
-
}, [
|
|
110
|
+
}, [
|
|
111
|
+
column.canSort,
|
|
112
|
+
column.id,
|
|
113
|
+
column.isSortedDesc,
|
|
114
|
+
onColumnSort,
|
|
115
|
+
onColumnSortChange,
|
|
116
|
+
visibleColumns,
|
|
117
|
+
closeFilterMenuIfOpen
|
|
118
|
+
]);
|
|
102
119
|
const isActive = draggableProps && draggableProps.active;
|
|
103
120
|
const onKeyDown = (0, import_react.useCallback)(
|
|
104
121
|
(e) => {
|
|
@@ -157,10 +174,12 @@ const useHeaderCellHandlers = ({
|
|
|
157
174
|
resizeHandlerRef.current
|
|
158
175
|
];
|
|
159
176
|
if (e.target === headerRef) {
|
|
177
|
+
resetAllHeadersExcept(column.id);
|
|
160
178
|
patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD, hasSortingCaret));
|
|
161
179
|
setFocusedRowId(null);
|
|
162
180
|
}
|
|
163
181
|
if (possibleTargets.includes(e.target)) {
|
|
182
|
+
resetAllHeadersExcept(column.id);
|
|
164
183
|
patchHeader(column.id, {
|
|
165
184
|
hideFilterButton: !hasFilter,
|
|
166
185
|
showDnDHandle: hasDnD,
|
|
@@ -177,6 +196,7 @@ const useHeaderCellHandlers = ({
|
|
|
177
196
|
hasFilter,
|
|
178
197
|
headerRef,
|
|
179
198
|
patchHeader,
|
|
199
|
+
resetAllHeadersExcept,
|
|
180
200
|
reduxHeader,
|
|
181
201
|
resizeHandlerRef,
|
|
182
202
|
setFocusedRowId,
|
|
@@ -185,13 +205,29 @@ const useHeaderCellHandlers = ({
|
|
|
185
205
|
);
|
|
186
206
|
const onBlur = (0, import_react.useCallback)(
|
|
187
207
|
(e) => {
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
if (
|
|
208
|
+
const { relatedTarget } = e;
|
|
209
|
+
if (relatedTarget && relatedTarget === dragHandleRef.current) return;
|
|
210
|
+
if (relatedTarget && relatedTarget === filterIconRef.current) return;
|
|
211
|
+
if (relatedTarget && relatedTarget === resizeHandlerRef.current) return;
|
|
212
|
+
if (relatedTarget && relatedTarget === sortRef?.current) return;
|
|
213
|
+
if (hoveredColumnId === column.id) {
|
|
214
|
+
patchHeader(column.id, { withTabStops: false });
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
192
217
|
patchHeader(column.id, buildNextHeader(reduxHeader, false, hasFilter, hasDnD, false));
|
|
193
218
|
},
|
|
194
|
-
[
|
|
219
|
+
[
|
|
220
|
+
dragHandleRef,
|
|
221
|
+
filterIconRef,
|
|
222
|
+
resizeHandlerRef,
|
|
223
|
+
sortRef,
|
|
224
|
+
patchHeader,
|
|
225
|
+
column.id,
|
|
226
|
+
reduxHeader,
|
|
227
|
+
hasFilter,
|
|
228
|
+
hasDnD,
|
|
229
|
+
hoveredColumnId
|
|
230
|
+
]
|
|
195
231
|
);
|
|
196
232
|
return { onMouseEnter, onMouseLeave, handleSort, onKeyDown, onBlur, onFocus };
|
|
197
233
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/Headers/useHeaderCellHandlers.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport { useCallback, useMemo } from 'react';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\nimport { useInternalStore, usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\ntype UseHeaderCellHandlersType = (args: {\n hasFilter: boolean;\n column: DSDataTableT.InternalColumn;\n hasDnD: boolean;\n dragHandleRef: React.MutableRefObject<HTMLDivElement | null>;\n sortRef: React.MutableRefObject<HTMLButtonElement | null>;\n filterIconRef: React.MutableRefObject<HTMLButtonElement | null>;\n resizeHandlerRef: React.MutableRefObject<HTMLInputElement | null>;\n hasSortingCaret: boolean;\n isDragOverlay?: boolean;\n draggableProps: DSDataTableT.DraggablePropsT;\n referenceColumn: React.MutableRefObject<HTMLDivElement | null>;\n}) => {\n onMouseEnter: React.MouseEventHandler;\n onMouseLeave: React.MouseEventHandler;\n handleSort: React.MouseEventHandler;\n onKeyDown: React.KeyboardEventHandler;\n onFocus: React.FocusEventHandler;\n onBlur: React.FocusEventHandler;\n};\n\n// TODO: reduxHeader was a mistake from the start.\n// Please remove this and make this logic more simple and\n// easy to follow.\nconst buildNextHeader = (\n reduxHeader: DSDataTableT.ReduxHeader,\n value: boolean,\n hasFilter: boolean,\n hasDnD: boolean,\n hasSortingCaret: boolean,\n withTabStops = false,\n) => ({\n hideFilterMenu: true, // Do this to overwrite it if it exists\n ...reduxHeader,\n hideFilterButton: !(hasFilter && value),\n showDnDHandle: hasDnD && value,\n showSortCaret: hasSortingCaret,\n withTabStops,\n});\n\nconst getNextSortedVisibleColumns = (\n visibleColumns: DSDataTableT.InternalColumn[],\n columnId: string,\n isSortedDesc: boolean,\n) => {\n const doit = (columns: DSDataTableT.InternalColumn[]) =>\n columns.map((col) => {\n const newCol = { ...col };\n delete newCol.isSortedDesc;\n if (col.id === columnId) {\n newCol.isSortedDesc = isSortedDesc;\n }\n if (newCol.columns) {\n newCol.columns = doit(newCol.columns);\n }\n return newCol;\n });\n return doit(visibleColumns);\n};\n\nexport const useHeaderCellHandlers: UseHeaderCellHandlersType = ({\n hasFilter,\n column,\n hasDnD,\n dragHandleRef,\n filterIconRef,\n sortRef,\n resizeHandlerRef,\n hasSortingCaret,\n isDragOverlay,\n draggableProps,\n referenceColumn,\n}) => {\n const onColumnSortChange = usePropsStore((state) => state.onColumnSortChange);\n const onColumnSort = usePropsStore((state) => state.onColumnSort);\n const visibleColumns = usePropsStore((state) => state.visibleColumns);\n const setFocusedRowId = useInternalStore((state) => state.setFocusedRowId);\n const patchHeader = useInternalStore((state) => state.patchHeader);\n const reduxHeaders = useInternalStore((state) => state.reduxHeaders);\n\n const reduxHeader = useMemo(() => reduxHeaders[column.id], [reduxHeaders, column]);\n\n const headerRef = referenceColumn.current;\n\n const onMouseEnter: React.MouseEventHandler = useCallback(() => {\n patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD, hasSortingCaret));\n }, [column.id, hasDnD, hasFilter, patchHeader, reduxHeader, hasSortingCaret]);\n\n const onMouseLeave: React.MouseEventHandler = useCallback(() => {\n if (!headerRef?.contains(document.activeElement)) {\n patchHeader(column.id, buildNextHeader(reduxHeader, false, hasFilter, hasDnD, false));\n }\n }, [column.id, hasDnD, hasFilter, headerRef, patchHeader, reduxHeader]);\n\n const handleSort: React.MouseEventHandler = useCallback(() => {\n if (column.canSort) {\n onColumnSortChange?.({\n column: column.id,\n direction: column.isSortedDesc ? 'ASC' : 'DESC',\n });\n onColumnSort(\n getNextSortedVisibleColumns(visibleColumns, column.id, !column.isSortedDesc),\n column.id,\n column.isSortedDesc ? 'ASC' : 'DESC',\n );\n }\n }, [column.canSort, column.id, column.isSortedDesc, onColumnSort, onColumnSortChange, visibleColumns]);\n\n const isActive = draggableProps && draggableProps.active;\n\n const onKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n // we do the same as the draggable rows.\n // we stop the event if the overlay is active\n // main reason is the tab key\n if (isDragOverlay || isActive) {\n e.preventDefault();\n }\n\n if (e.currentTarget !== e.target) return;\n if (e.code === 'ArrowDown' && column.canSort) {\n e.preventDefault();\n onColumnSortChange?.({\n column: column.id,\n direction: 'DESC',\n });\n onColumnSort(getNextSortedVisibleColumns(visibleColumns, column.id, true), column.id, 'DESC');\n } else if (e.code === 'ArrowUp' && column.canSort) {\n e.preventDefault();\n onColumnSortChange?.({\n column: column.id,\n direction: 'ASC',\n });\n onColumnSort(getNextSortedVisibleColumns(visibleColumns, column.id, false), column.id, 'ASC');\n } else if (['Enter', 'Space'].includes(e.code)) {\n patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD, hasSortingCaret, true));\n // Elements don't not yet exist\n setTimeout(() => {\n if (dragHandleRef.current) dragHandleRef.current.focus();\n else if (filterIconRef.current) filterIconRef.current.focus();\n else if (resizeHandlerRef.current) resizeHandlerRef.current.focus();\n else if (sortRef?.current) sortRef.current.focus();\n });\n }\n },\n [\n isDragOverlay,\n isActive,\n column.canSort,\n column.id,\n onColumnSortChange,\n onColumnSort,\n visibleColumns,\n patchHeader,\n reduxHeader,\n hasFilter,\n hasDnD,\n hasSortingCaret,\n dragHandleRef,\n filterIconRef,\n resizeHandlerRef,\n sortRef,\n ],\n );\n\n const onFocus: React.FocusEventHandler = useCallback(\n (e) => {\n // Don't do anything if focus wasn't placed in the element (bubling issues)\n const possibleTargets: (HTMLElement | null)[] = [\n dragHandleRef.current,\n filterIconRef.current,\n resizeHandlerRef.current,\n ];\n if (e.target === headerRef) {\n patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD, hasSortingCaret));\n setFocusedRowId(null);\n }\n\n if (possibleTargets.includes(e.target as HTMLElement | null)) {\n patchHeader(column.id, {\n hideFilterButton: !hasFilter,\n showDnDHandle: hasDnD,\n withTabStops: true,\n });\n setFocusedRowId(null);\n }\n },\n [\n column.id,\n dragHandleRef,\n filterIconRef,\n hasDnD,\n hasFilter,\n headerRef,\n patchHeader,\n reduxHeader,\n resizeHandlerRef,\n setFocusedRowId,\n hasSortingCaret,\n ],\n );\n\n const onBlur: React.FocusEventHandler = useCallback(\n (e) => {\n // Don't do anything if blur was caused by going to a child\n if (e.relatedTarget === dragHandleRef.current) return;\n if (e.relatedTarget === filterIconRef.current) return;\n if (e.relatedTarget === resizeHandlerRef.current) return;\n if (e.relatedTarget === sortRef?.current) return;\n patchHeader(column.id, buildNextHeader(reduxHeader, false, hasFilter, hasDnD, false));\n },\n [dragHandleRef, filterIconRef, resizeHandlerRef, sortRef, patchHeader, column.id, reduxHeader, hasFilter, hasDnD],\n );\n\n return { onMouseEnter, onMouseLeave, handleSort, onKeyDown, onBlur, onFocus };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAqC;AAErC,2C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useMemo } from 'react';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\nimport { useInternalStore, usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\ntype UseHeaderCellHandlersType = (args: {\n hasFilter: boolean;\n column: DSDataTableT.InternalColumn;\n hasDnD: boolean;\n dragHandleRef: React.MutableRefObject<HTMLDivElement | null>;\n sortRef: React.MutableRefObject<HTMLButtonElement | null>;\n filterIconRef: React.MutableRefObject<HTMLButtonElement | null>;\n resizeHandlerRef: React.MutableRefObject<HTMLInputElement | null>;\n hasSortingCaret: boolean;\n isDragOverlay?: boolean;\n draggableProps: DSDataTableT.DraggablePropsT;\n referenceColumn: React.MutableRefObject<HTMLDivElement | null>;\n}) => {\n onMouseEnter: React.MouseEventHandler;\n onMouseLeave: React.MouseEventHandler;\n handleSort: React.MouseEventHandler;\n onKeyDown: React.KeyboardEventHandler;\n onFocus: React.FocusEventHandler;\n onBlur: React.FocusEventHandler;\n};\n\n// TODO: reduxHeader was a mistake from the start.\n// Please remove this and make this logic more simple and\n// easy to follow.\nconst buildNextHeader = (\n reduxHeader: DSDataTableT.ReduxHeader,\n value: boolean,\n hasFilter: boolean,\n hasDnD: boolean,\n hasSortingCaret: boolean,\n withTabStops = false,\n) => ({\n hideFilterMenu: true, // Do this to overwrite it if it exists\n ...reduxHeader,\n hideFilterButton: !(hasFilter && value),\n showDnDHandle: hasDnD && value,\n showSortCaret: hasSortingCaret,\n withTabStops,\n});\n\nconst getNextSortedVisibleColumns = (\n visibleColumns: DSDataTableT.InternalColumn[],\n columnId: string,\n isSortedDesc: boolean,\n) => {\n const doit = (columns: DSDataTableT.InternalColumn[]) =>\n columns.map((col) => {\n const newCol = { ...col };\n delete newCol.isSortedDesc;\n if (col.id === columnId) {\n newCol.isSortedDesc = isSortedDesc;\n }\n if (newCol.columns) {\n newCol.columns = doit(newCol.columns);\n }\n return newCol;\n });\n return doit(visibleColumns);\n};\n\nexport const useHeaderCellHandlers: UseHeaderCellHandlersType = ({\n hasFilter,\n column,\n hasDnD,\n dragHandleRef,\n filterIconRef,\n sortRef,\n resizeHandlerRef,\n hasSortingCaret,\n isDragOverlay,\n draggableProps,\n referenceColumn,\n}) => {\n const onColumnSortChange = usePropsStore((state) => state.onColumnSortChange);\n const onColumnSort = usePropsStore((state) => state.onColumnSort);\n const visibleColumns = usePropsStore((state) => state.visibleColumns);\n const setFocusedRowId = useInternalStore((state) => state.setFocusedRowId);\n const patchHeader = useInternalStore((state) => state.patchHeader);\n const closeFilterMenuIfOpen = useInternalStore((state) => state.closeFilterMenuIfOpen);\n const resetAllHeadersExcept = useInternalStore((state) => state.resetAllHeadersExcept);\n const hoveredColumnId = useInternalStore((state) => state.hoveredColumnId);\n const setHoveredColumnId = useInternalStore((state) => state.setHoveredColumnId);\n const reduxHeaders = useInternalStore((state) => state.reduxHeaders);\n\n const reduxHeader = useMemo(() => reduxHeaders[column.id], [reduxHeaders, column]);\n\n const headerRef = referenceColumn.current;\n\n const onMouseEnter: React.MouseEventHandler = useCallback(() => {\n // PUI-15154: tracked separately from reduxHeader's own fields \u2014 see resetAllHeadersExcept in\n // useStore.tsx for why hover identity can't be folded into the same per-column booleans focus\n // writes to.\n setHoveredColumnId(column.id);\n patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD, hasSortingCaret));\n }, [column.id, hasDnD, hasFilter, patchHeader, reduxHeader, hasSortingCaret, setHoveredColumnId]);\n\n const onMouseLeave: React.MouseEventHandler = useCallback(() => {\n setHoveredColumnId((currentHoveredColumnId) =>\n currentHoveredColumnId === column.id ? null : currentHoveredColumnId,\n );\n if (!headerRef?.contains(document.activeElement)) {\n patchHeader(column.id, buildNextHeader(reduxHeader, false, hasFilter, hasDnD, false));\n }\n }, [column.id, hasDnD, hasFilter, headerRef, patchHeader, reduxHeader, setHoveredColumnId]);\n\n const handleSort: React.MouseEventHandler = useCallback(() => {\n /** PUI-18785: this handler runs for every click on the header (title, sort caret, a drag\n * handle click that doesn't turn into an actual drag) \u2014 see closeFilterMenuIfOpen in\n * useStore.tsx for why it needs to force-close the column's own filter menu here.\n */\n closeFilterMenuIfOpen(column.id);\n if (column.canSort) {\n onColumnSortChange?.({\n column: column.id,\n direction: column.isSortedDesc ? 'ASC' : 'DESC',\n });\n onColumnSort(\n getNextSortedVisibleColumns(visibleColumns, column.id, !column.isSortedDesc),\n column.id,\n column.isSortedDesc ? 'ASC' : 'DESC',\n );\n }\n }, [\n column.canSort,\n column.id,\n column.isSortedDesc,\n onColumnSort,\n onColumnSortChange,\n visibleColumns,\n closeFilterMenuIfOpen,\n ]);\n\n const isActive = draggableProps && draggableProps.active;\n\n const onKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n // we do the same as the draggable rows.\n // we stop the event if the overlay is active\n // main reason is the tab key\n if (isDragOverlay || isActive) {\n e.preventDefault();\n }\n\n if (e.currentTarget !== e.target) return;\n if (e.code === 'ArrowDown' && column.canSort) {\n e.preventDefault();\n onColumnSortChange?.({\n column: column.id,\n direction: 'DESC',\n });\n onColumnSort(getNextSortedVisibleColumns(visibleColumns, column.id, true), column.id, 'DESC');\n } else if (e.code === 'ArrowUp' && column.canSort) {\n e.preventDefault();\n onColumnSortChange?.({\n column: column.id,\n direction: 'ASC',\n });\n onColumnSort(getNextSortedVisibleColumns(visibleColumns, column.id, false), column.id, 'ASC');\n } else if (['Enter', 'Space'].includes(e.code)) {\n patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD, hasSortingCaret, true));\n // Elements don't not yet exist\n setTimeout(() => {\n if (dragHandleRef.current) dragHandleRef.current.focus();\n else if (filterIconRef.current) filterIconRef.current.focus();\n else if (resizeHandlerRef.current) resizeHandlerRef.current.focus();\n else if (sortRef?.current) sortRef.current.focus();\n });\n }\n },\n [\n isDragOverlay,\n isActive,\n column.canSort,\n column.id,\n onColumnSortChange,\n onColumnSort,\n visibleColumns,\n patchHeader,\n reduxHeader,\n hasFilter,\n hasDnD,\n hasSortingCaret,\n dragHandleRef,\n filterIconRef,\n resizeHandlerRef,\n sortRef,\n ],\n );\n\n const onFocus: React.FocusEventHandler = useCallback(\n (e) => {\n // Don't do anything if focus wasn't placed in the element (bubling issues)\n const possibleTargets: (HTMLElement | null)[] = [\n dragHandleRef.current,\n filterIconRef.current,\n resizeHandlerRef.current,\n ];\n if (e.target === headerRef) {\n // PUI-15154: proactively clear every other column's stuck DnD handle/sort caret \u2014 see\n // resetAllHeadersExcept in useStore.tsx for why this can't rely solely on the previous\n // column's own onBlur.\n resetAllHeadersExcept(column.id);\n patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD, hasSortingCaret));\n setFocusedRowId(null);\n }\n\n if (possibleTargets.includes(e.target as HTMLElement | null)) {\n resetAllHeadersExcept(column.id);\n patchHeader(column.id, {\n hideFilterButton: !hasFilter,\n showDnDHandle: hasDnD,\n withTabStops: true,\n });\n setFocusedRowId(null);\n }\n },\n [\n column.id,\n dragHandleRef,\n filterIconRef,\n hasDnD,\n hasFilter,\n headerRef,\n patchHeader,\n resetAllHeadersExcept,\n reduxHeader,\n resizeHandlerRef,\n setFocusedRowId,\n hasSortingCaret,\n ],\n );\n\n const onBlur: React.FocusEventHandler = useCallback(\n (e) => {\n // PUI-15154: don't do anything if blur was caused by going to a child \u2014 but only when\n // relatedTarget is a real element. When focus leaves with nowhere specific to land (a click\n // on a non-focusable area, or Tab past the last focusable element), relatedTarget is null.\n // Any of these refs is null too whenever that control isn't rendered for this column (e.g.\n // filterIconRef when the column has no filter \u2014 FilterMapItem renders null). Comparing with\n // plain === then false-matches null against null and skips the reset, leaving the DnD handle\n // and sort caret visibly stuck even though focus genuinely left the header.\n const { relatedTarget } = e;\n if (relatedTarget && relatedTarget === dragHandleRef.current) return;\n if (relatedTarget && relatedTarget === filterIconRef.current) return;\n if (relatedTarget && relatedTarget === resizeHandlerRef.current) return;\n if (relatedTarget && relatedTarget === sortRef?.current) return;\n // PUI-15154: if the mouse is still hovering this same column, don't hide its hover-driven\n // visibility just because focus left it \u2014 only the focus-derived tab-stop state resets.\n // showDnDHandle/showSortCaret stay as hover set them.\n if (hoveredColumnId === column.id) {\n patchHeader(column.id, { withTabStops: false });\n return;\n }\n patchHeader(column.id, buildNextHeader(reduxHeader, false, hasFilter, hasDnD, false));\n },\n [\n dragHandleRef,\n filterIconRef,\n resizeHandlerRef,\n sortRef,\n patchHeader,\n column.id,\n reduxHeader,\n hasFilter,\n hasDnD,\n hoveredColumnId,\n ],\n );\n\n return { onMouseEnter, onMouseLeave, handleSort, onKeyDown, onBlur, onFocus };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAqC;AAErC,2CAAgD;AAyBhD,MAAM,kBAAkB,CACtB,aACA,OACA,WACA,QACA,iBACA,eAAe,WACX;AAAA,EACJ,gBAAgB;AAAA;AAAA,EAChB,GAAG;AAAA,EACH,kBAAkB,EAAE,aAAa;AAAA,EACjC,eAAe,UAAU;AAAA,EACzB,eAAe;AAAA,EACf;AACF;AAEA,MAAM,8BAA8B,CAClC,gBACA,UACA,iBACG;AACH,QAAM,OAAO,CAAC,YACZ,QAAQ,IAAI,CAAC,QAAQ;AACnB,UAAM,SAAS,EAAE,GAAG,IAAI;AACxB,WAAO,OAAO;AACd,QAAI,IAAI,OAAO,UAAU;AACvB,aAAO,eAAe;AAAA,IACxB;AACA,QAAI,OAAO,SAAS;AAClB,aAAO,UAAU,KAAK,OAAO,OAAO;AAAA,IACtC;AACA,WAAO;AAAA,EACT,CAAC;AACH,SAAO,KAAK,cAAc;AAC5B;AAEO,MAAM,wBAAmD,CAAC;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,yBAAqB,oDAAc,CAAC,UAAU,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AAkB,SAAS,QAAS;AAIzD,UAAI,oBAAoB,OAAO,IAAI;AACjC,oBAAY,OAAO,IAAI,EAAE,cAAc,MAAM,CAAC;AAC9C;AAAA,MACF;AACA,kBAAY,OAAO,IAAI,gBAAgB,aAAa,OAAO,WAAW,QAAQ,KAAK,CAAC;AAAA,IACtF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,cAAc,cAAc,YAAY,WAAW,QAAQ,QAAQ;AAC9E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -35,8 +35,9 @@ var React = __toESM(require("react"));
|
|
|
35
35
|
var import_lodash_es = require("lodash-es");
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
37
37
|
var import_createInternalAndPropsContext = require("../../configs/useStore/createInternalAndPropsContext.js");
|
|
38
|
+
var import_constants = require("../../configs/constants.js");
|
|
38
39
|
var import_gridLayoutHelpers = require("../../helpers/gridLayoutHelpers.js");
|
|
39
|
-
const narrow = (value, min, max) => Math.min(Math.max(value, min ??
|
|
40
|
+
const narrow = (value, min, max) => Math.min(Math.max(value, min ?? import_constants.DEFAULT_MIN_COLUMN_WIDTH), max ?? import_constants.DEFAULT_MAX_COLUMN_WIDTH);
|
|
40
41
|
const getCorrectDelta = (e) => {
|
|
41
42
|
let multiplier = 1;
|
|
42
43
|
if (e.shiftKey) multiplier *= 5;
|
|
@@ -57,6 +58,8 @@ const useHeaderResizer = ({
|
|
|
57
58
|
const onColumnResize = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.onColumnResize);
|
|
58
59
|
const onColumnSizeChange = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.onColumnSizeChange);
|
|
59
60
|
const virtualListRef = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.virtualListRef);
|
|
61
|
+
const colsLayoutStyle = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.colsLayoutStyle);
|
|
62
|
+
const closeFilterMenuIfOpen = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.closeFilterMenuIfOpen);
|
|
60
63
|
const [isResizing, setIsResizing] = (0, import_react.useState)(false);
|
|
61
64
|
const visibleColumnsCopy = (0, import_react.useMemo)(() => (0, import_lodash_es.cloneDeep)(visibleColumns), [visibleColumns]);
|
|
62
65
|
const visibleColumnsOnGridLayout = (0, import_react.useMemo)(
|
|
@@ -74,6 +77,9 @@ const useHeaderResizer = ({
|
|
|
74
77
|
);
|
|
75
78
|
const realColumnIndexRef = import_react.default.useRef(realColumnIndex);
|
|
76
79
|
realColumnIndexRef.current = realColumnIndex;
|
|
80
|
+
const [columnWidth, setColumnWidth] = (0, import_react.useState)(
|
|
81
|
+
visibleColumnsOnGridLayout[realColumnIndex]?.width ?? (colsLayoutStyle === import_constants.ColsLayoutStyle.Auto ? void 0 : 150)
|
|
82
|
+
);
|
|
77
83
|
const pushColumnSizeChange = (0, import_react.useCallback)(
|
|
78
84
|
(nextWidth) => {
|
|
79
85
|
if (nextWidth === visibleColumnsOnGridLayout[realColumnIndexRef.current].width) return;
|
|
@@ -85,7 +91,8 @@ const useHeaderResizer = ({
|
|
|
85
91
|
);
|
|
86
92
|
const onResizeStart = (0, import_react.useCallback)(() => {
|
|
87
93
|
setIsResizing(true);
|
|
88
|
-
|
|
94
|
+
closeFilterMenuIfOpen(columnId);
|
|
95
|
+
}, [closeFilterMenuIfOpen, columnId]);
|
|
89
96
|
const onResizeEnd = (0, import_react.useCallback)(() => {
|
|
90
97
|
setIsResizing(false);
|
|
91
98
|
pushColumnSizeChange((0, import_gridLayoutHelpers.getGridLayout)(virtualListRef.current)[realColumnIndexRef.current]);
|
|
@@ -103,6 +110,7 @@ const useHeaderResizer = ({
|
|
|
103
110
|
);
|
|
104
111
|
(0, import_gridLayoutHelpers.changeGridLayout)(virtualListRef.current, realColumnIndexRef.current, widthWithDelta);
|
|
105
112
|
(0, import_gridLayoutHelpers.setSubColumnsGridLayout)(virtualListRef.current, visibleColumnsCopy);
|
|
113
|
+
setColumnWidth(widthWithDelta);
|
|
106
114
|
e.preventDefault();
|
|
107
115
|
e.stopPropagation();
|
|
108
116
|
},
|
|
@@ -127,13 +135,15 @@ const useHeaderResizer = ({
|
|
|
127
135
|
);
|
|
128
136
|
(0, import_gridLayoutHelpers.changeGridLayout)(virtualListRef.current, realColumnIndexRef.current, widthWithDelta);
|
|
129
137
|
(0, import_gridLayoutHelpers.setSubColumnsGridLayout)(virtualListRef.current, visibleColumnsCopy);
|
|
130
|
-
|
|
138
|
+
setColumnWidth(widthWithDelta);
|
|
139
|
+
pushColumnSizeChange(widthWithDelta);
|
|
131
140
|
(0, import_gridLayoutHelpers.removeGridLayout)(virtualListRef.current);
|
|
132
141
|
},
|
|
133
142
|
[pushColumnSizeChange, virtualListRef, visibleColumnsCopy, visibleColumnsOnGridLayout]
|
|
134
143
|
);
|
|
135
144
|
return {
|
|
136
145
|
isResizing,
|
|
146
|
+
columnWidth,
|
|
137
147
|
onResizeStart,
|
|
138
148
|
onResizeEnd,
|
|
139
149
|
onResizeHandler,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/Headers/useHeaderResizer.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { cloneDeep } from 'lodash-es';\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\nimport {\n changeGridLayout,\n getGridLayout,\n removeGridLayout,\n setSubColumnsGridLayout,\n} from '../../helpers/gridLayoutHelpers.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\n\n// if number > max => max\n// if number < min => min\n// else => number\nconst narrow = (value: number, min: number | undefined, max: number | undefined): number =>\n Math.min(Math.max(value, min ??
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA0B;AAC1B,mBAAsD;AACtD,
|
|
4
|
+
"sourcesContent": ["import { cloneDeep } from 'lodash-es';\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { useInternalStore, usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\nimport { ColsLayoutStyle, DEFAULT_MAX_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH } from '../../configs/constants.js';\nimport {\n changeGridLayout,\n getGridLayout,\n removeGridLayout,\n setSubColumnsGridLayout,\n} from '../../helpers/gridLayoutHelpers.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\n\n// if number > max => max\n// if number < min => min\n// else => number\nconst narrow = (value: number, min: number | undefined, max: number | undefined): number =>\n Math.min(Math.max(value, min ?? DEFAULT_MIN_COLUMN_WIDTH), max ?? DEFAULT_MAX_COLUMN_WIDTH);\n\n// Returns the delta of the keyboard event\nconst getCorrectDelta = (e: React.KeyboardEvent) => {\n let multiplier = 1;\n\n if (e.shiftKey) multiplier *= 5;\n if (e.altKey) multiplier *= 10;\n\n if (e.code === 'ArrowLeft') {\n return -multiplier;\n }\n if (e.code === 'ArrowRight') {\n return multiplier;\n }\n return 0;\n};\n\nexport const useHeaderResizer = ({\n columnId,\n innerRef,\n}: {\n columnId: string;\n innerRef: React.MutableRefObject<HTMLInputElement | null>;\n}) => {\n const visibleColumns = usePropsStore((state) => state.visibleColumns);\n const onColumnResize = usePropsStore((state) => state.onColumnResize);\n const onColumnSizeChange = usePropsStore((state) => state.onColumnSizeChange);\n const virtualListRef = usePropsStore((state) => state.virtualListRef);\n const colsLayoutStyle = usePropsStore((state) => state.colsLayoutStyle);\n const closeFilterMenuIfOpen = useInternalStore((state) => state.closeFilterMenuIfOpen);\n\n const [isResizing, setIsResizing] = useState(false);\n\n const visibleColumnsCopy = useMemo(() => cloneDeep(visibleColumns), [visibleColumns]);\n\n const visibleColumnsOnGridLayout = useMemo(\n () =>\n visibleColumnsCopy.reduce((acc, cur) => {\n if (cur.columns) {\n return acc.concat(cur.columns);\n }\n return acc.concat(cur);\n }, [] as DSDataTableT.InternalColumn[]),\n [visibleColumnsCopy],\n );\n\n const realColumnIndex = useMemo(\n () => visibleColumnsOnGridLayout.findIndex((col) => col.id === columnId),\n [columnId, visibleColumnsOnGridLayout],\n );\n\n const realColumnIndexRef = React.useRef(realColumnIndex);\n realColumnIndexRef.current = realColumnIndex;\n\n // PUI-17784: real width in pixels, fed to aria-valuenow/valuetext. Initialized synchronously from\n // props \u2014 no effect needed. Mirrors columnsToGridImpl's own default (helpers/columnsToGrid.tsx,\n // keep both in sync if that default ever changes): an explicit column.width wins; otherwise Fixed\n // layout resolves to a known 150px; Auto layout with no explicit width has no synchronous numeric\n // value (it's a flexible '1fr' the browser resolves at layout time) \u2014 aria-valuenow is legitimately\n // absent until the user's first resize populates it via the handlers below, which already call\n // setColumnWidth on every mouse/keyboard resize using the real applied width.\n const [columnWidth, setColumnWidth] = useState<number | undefined>(\n visibleColumnsOnGridLayout[realColumnIndex]?.width ?? (colsLayoutStyle === ColsLayoutStyle.Auto ? undefined : 150),\n );\n\n // Notifies the user of the change in the column size\n const pushColumnSizeChange = useCallback(\n (nextWidth: number) => {\n // PUI-12695: Avoid unnecessary calls to onColumnResize\n // Avoid calling onColumnResize if the width of the column has not changed\n // unnecessary calls to onColumnResize can cause performance issues (next resizes were not working)\n if (nextWidth === visibleColumnsOnGridLayout[realColumnIndexRef.current].width) return;\n onColumnResize?.(columnId, nextWidth);\n // this next line is updating also the visibleColumnsCopy via mutable changes\n // the mutable changes here works because what we mutate is a cloneDeep of the columns\n visibleColumnsOnGridLayout[realColumnIndexRef.current].width = nextWidth;\n onColumnSizeChange(visibleColumnsCopy, columnId, nextWidth);\n },\n [columnId, onColumnResize, onColumnSizeChange, realColumnIndexRef, visibleColumnsCopy, visibleColumnsOnGridLayout],\n );\n\n const onResizeStart = useCallback(() => {\n setIsResizing(true);\n /**\n * PUI-18785: the resize handle shares the same containment root cause as the header click and\n * drag handle \u2014 see closeFilterMenuIfOpen in useStore.tsx.\n */\n closeFilterMenuIfOpen(columnId);\n }, [closeFilterMenuIfOpen, columnId]);\n\n const onResizeEnd = useCallback(() => {\n setIsResizing(false);\n pushColumnSizeChange(getGridLayout(virtualListRef.current)[realColumnIndexRef.current]);\n removeGridLayout(virtualListRef.current);\n }, [pushColumnSizeChange, virtualListRef, realColumnIndexRef]);\n\n // Mouse resize\n const onResizeHandler = useCallback(\n (e: MouseEvent | TouchEvent) => {\n if (realColumnIndexRef.current === -1) return;\n\n const delta =\n ('clientX' in e ? e.clientX : e.touches[0].clientX) - (innerRef.current?.getBoundingClientRect().x ?? 0); // delta in pixels\n\n const originalWidth = getGridLayout(virtualListRef.current)[realColumnIndexRef.current];\n\n const widthWithDelta = narrow(\n originalWidth + delta,\n visibleColumnsOnGridLayout[realColumnIndexRef.current].minWidth,\n visibleColumnsOnGridLayout[realColumnIndexRef.current].maxWidth,\n );\n\n changeGridLayout(virtualListRef.current, realColumnIndexRef.current, widthWithDelta);\n setSubColumnsGridLayout(virtualListRef.current, visibleColumnsCopy);\n setColumnWidth(widthWithDelta);\n\n // We will notify the user of the change in the column size only when the user releases the mouse button\n\n // To prevent text selection\n e.preventDefault();\n e.stopPropagation();\n },\n [innerRef, virtualListRef, visibleColumnsCopy, visibleColumnsOnGridLayout],\n );\n\n // Keyboard resize\n const handleKeyboardResize = useCallback(\n (e: React.KeyboardEvent) => {\n if (realColumnIndexRef.current === -1) return;\n\n if (e.key === 'Enter') {\n e.stopPropagation();\n }\n\n if (e.code === 'ArrowLeft' || e.code === 'ArrowRight') {\n e.preventDefault();\n }\n\n const delta = getCorrectDelta(e);\n\n if (delta === 0) return;\n\n const originalWidth = getGridLayout(virtualListRef.current)[realColumnIndexRef.current];\n\n const widthWithDelta = narrow(\n originalWidth + delta,\n visibleColumnsOnGridLayout[realColumnIndexRef.current].minWidth,\n visibleColumnsOnGridLayout[realColumnIndexRef.current].maxWidth,\n );\n\n changeGridLayout(virtualListRef.current, realColumnIndexRef.current, widthWithDelta);\n setSubColumnsGridLayout(virtualListRef.current, visibleColumnsCopy);\n setColumnWidth(widthWithDelta);\n\n /**\n * Commit the already-clamped width. getGridLayout() here would just re-read what\n * changeGridLayout() set above (widthWithDelta) \u2014 adding delta again double-counted it and\n * committed a width past minWidth/maxWidth (PUI-12696).\n */\n pushColumnSizeChange(widthWithDelta);\n removeGridLayout(virtualListRef.current);\n },\n [pushColumnSizeChange, virtualListRef, visibleColumnsCopy, visibleColumnsOnGridLayout],\n );\n\n return {\n isResizing,\n columnWidth,\n onResizeStart,\n onResizeEnd,\n onResizeHandler,\n handleKeyboardResize,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA0B;AAC1B,mBAAsD;AACtD,2CAAgD;AAChD,uBAAoF;AACpF,+BAKO;AAMP,MAAM,SAAS,CAAC,OAAe,KAAyB,QACtD,KAAK,IAAI,KAAK,IAAI,OAAO,OAAO,yCAAwB,GAAG,OAAO,yCAAwB;AAG5F,MAAM,kBAAkB,CAAC,MAA2B;AAClD,MAAI,aAAa;AAEjB,MAAI,EAAE,SAAU,eAAc;AAC9B,MAAI,EAAE,OAAQ,eAAc;AAE5B,MAAI,EAAE,SAAS,aAAa;AAC1B,WAAO,CAAC;AAAA,EACV;AACA,MAAI,EAAE,SAAS,cAAc;AAC3B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,MAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA;AACF,MAGM;AACJ,QAAM,qBAAiB,oDAAc,CAAC,UAAU,MAAM,cAAc;AACpE,QAAM,qBAAiB,oDAAc,CAAC,UAAU,MAAM,cAAc;AACpE,QAAM,yBAAqB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AgB;AAAA,QAChB,2BAA2B,mBAAmB,OAAO,EAAE;AAAA,QACvD,2BAA2B,mBAAmB,OAAO,EAAE;AAAA,MACzD;AAEA,qDAAiB,eAAe,SAAS,mBAAmB,SAAS,cAAc;AACnF,4DAAwB,eAAe,SAAS,kBAAkB;AAClE,qBAAe,cAAc;AAO7B,2BAAqB,cAAc;AACnC,qDAAiB,eAAe,OAAO;AAAA,IACzC;AAAA,IACA,CAAC,sBAAsB,gBAAgB,oBAAoB,0BAA0B;AAAA,EACvF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -42,6 +42,7 @@ var import_DnDGroupContext = require("./DnDGroupContext.js");
|
|
|
42
42
|
const withDnDSortableColumnContext = (Component) => (props) => {
|
|
43
43
|
const dragAndDropColumns = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.dragAndDropColumns);
|
|
44
44
|
const setIsHeaderCellDragging = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.setIsHeaderCellDragging);
|
|
45
|
+
const closeFilterMenuIfOpen = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.closeFilterMenuIfOpen);
|
|
45
46
|
const { activeIndex } = (0, import_react.useContext)(import_DnDGroupContext.DnDGroupContext);
|
|
46
47
|
const draggableOptions = (0, import_react.useMemo)(
|
|
47
48
|
() => ({
|
|
@@ -53,10 +54,11 @@ const withDnDSortableColumnContext = (Component) => (props) => {
|
|
|
53
54
|
(0, import_react.useEffect)(() => {
|
|
54
55
|
if (useSortableHelpers.isDragging) {
|
|
55
56
|
setIsHeaderCellDragging(true);
|
|
57
|
+
closeFilterMenuIfOpen(props.header.id);
|
|
56
58
|
} else {
|
|
57
59
|
setIsHeaderCellDragging(false);
|
|
58
60
|
}
|
|
59
|
-
}, [useSortableHelpers.isDragging, setIsHeaderCellDragging]);
|
|
61
|
+
}, [useSortableHelpers.isDragging, setIsHeaderCellDragging, closeFilterMenuIfOpen, props.header.id]);
|
|
60
62
|
const draggableProps = (0, import_react.useMemo)(() => {
|
|
61
63
|
if (!dragAndDropColumns) return false;
|
|
62
64
|
const { index, overIndex } = useSortableHelpers;
|