@elliemae/ds-data-table 3.51.0-rc.17 → 3.51.0-rc.18
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 +13 -10
- package/dist/cjs/addons/Columns/ColumnSelectMultiple/ColumnSelectMultiple.js.map +2 -2
- package/dist/cjs/exported-related/RowRenderer/useRowRendererHandlers.js +12 -8
- package/dist/cjs/exported-related/RowRenderer/useRowRendererHandlers.js.map +2 -2
- package/dist/cjs/helpers/multipleSelectRow.js +50 -0
- package/dist/cjs/helpers/multipleSelectRow.js.map +7 -0
- package/dist/esm/addons/Columns/ColumnSelectMultiple/ColumnSelectMultiple.js +13 -10
- package/dist/esm/addons/Columns/ColumnSelectMultiple/ColumnSelectMultiple.js.map +2 -2
- package/dist/esm/exported-related/RowRenderer/useRowRendererHandlers.js +12 -8
- package/dist/esm/exported-related/RowRenderer/useRowRendererHandlers.js.map +2 -2
- package/dist/esm/helpers/multipleSelectRow.js +20 -0
- package/dist/esm/helpers/multipleSelectRow.js.map +7 -0
- package/dist/types/helpers/multipleSelectRow.d.ts +2 -0
- package/package.json +28 -28
|
@@ -38,6 +38,7 @@ var import_ds_form_checkbox = require("@elliemae/ds-form-checkbox");
|
|
|
38
38
|
var import_uid = require("uid");
|
|
39
39
|
var import_constants = require("../../../configs/constants.js");
|
|
40
40
|
var import_createInternalAndPropsContext = require("../../../configs/useStore/createInternalAndPropsContext.js");
|
|
41
|
+
var import_multipleSelectRow = require("../../../helpers/multipleSelectRow.js");
|
|
41
42
|
const multiSelectColumn = {
|
|
42
43
|
// Build our multiSelecter column
|
|
43
44
|
id: "multiSelecter",
|
|
@@ -106,26 +107,28 @@ const multiSelectColumn = {
|
|
|
106
107
|
const checkboxSelectAllProps = (0, import_createInternalAndPropsContext.usePropsStore)((state) => state.checkboxSelectAllProps);
|
|
107
108
|
const isShiftPressed = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.isShiftPressed);
|
|
108
109
|
const setIsShiftPressed = (0, import_createInternalAndPropsContext.useInternalStore)((state) => state.setIsShiftPressed);
|
|
109
|
-
const { uid } = row;
|
|
110
|
+
const { uid, realIndex } = row;
|
|
110
111
|
const selectedState = selection?.[uid] ?? false;
|
|
111
112
|
const isShiftPressedKeyRef = (0, import_react.useRef)(false);
|
|
112
113
|
const onChangeHandler = (0, import_react.useCallback)(
|
|
113
114
|
(newState, e) => {
|
|
114
|
-
|
|
115
|
+
let newSelection = { ...selection, [uid]: newState };
|
|
115
116
|
if (!newState) delete newSelection[uid];
|
|
116
|
-
const now =
|
|
117
|
+
const now = realIndex;
|
|
117
118
|
if ((isShiftPressed || isShiftPressedKeyRef.current) && lastSelected.current > -1) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
newSelection = (0, import_multipleSelectRow.updateRangeSelection)(
|
|
120
|
+
newSelection,
|
|
121
|
+
lastSelected.current,
|
|
122
|
+
now,
|
|
123
|
+
flattenedData,
|
|
124
|
+
disabledRows,
|
|
125
|
+
newState
|
|
126
|
+
);
|
|
124
127
|
}
|
|
125
128
|
lastSelected.current = now;
|
|
126
129
|
onSelectionChange(newSelection, uid, e);
|
|
127
130
|
},
|
|
128
|
-
[
|
|
131
|
+
[selection, uid, realIndex, isShiftPressed, lastSelected, onSelectionChange, flattenedData, disabledRows]
|
|
129
132
|
);
|
|
130
133
|
const onKeyDownHandler = (0, import_react.useCallback)(
|
|
131
134
|
(e) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/addons/Columns/ColumnSelectMultiple/ColumnSelectMultiple.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-statements */\nimport React, { useMemo, useRef, useCallback, createRef } from 'react';\nimport { DSControlledCheckbox } from '@elliemae/ds-form-checkbox';\nimport { uid as genUid } from 'uid';\nimport type { DSDataTableT } from '../../../react-desc-prop-types.js';\nimport { DATA_TESTID } from '../../../configs/constants.js';\nimport { useInternalStore, usePropsStore } from '../../../configs/useStore/createInternalAndPropsContext.js';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADyEjB;AAxEN,mBAA+D;AAC/D,8BAAqC;AACrC,iBAA8B;AAE9B,uBAA4B;AAC5B,2CAAgD;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-statements */\nimport React, { useMemo, useRef, useCallback, createRef } from 'react';\nimport { DSControlledCheckbox } from '@elliemae/ds-form-checkbox';\nimport { uid as genUid } from 'uid';\nimport type { DSDataTableT } from '../../../react-desc-prop-types.js';\nimport { DATA_TESTID } from '../../../configs/constants.js';\nimport { useInternalStore, usePropsStore } from '../../../configs/useStore/createInternalAndPropsContext.js';\nimport { updateRangeSelection } from '../../../helpers/multipleSelectRow.js';\nexport const multiSelectColumn: DSDataTableT.InternalColumn = {\n // Build our multiSelecter column\n id: 'multiSelecter', // Make sure it has an ID\n Header: () => {\n const onSelectionChange = usePropsStore((state) => state.onSelectionChange);\n const selection = usePropsStore((state) => state.selection);\n const disabledRows = usePropsStore((state) => state.disabledRows);\n const noResultsMessage = usePropsStore((state) => state.noResultsMessage);\n const noResultsSecondaryMessage = usePropsStore((state) => state.noResultsSecondaryMessage);\n const allDataFlattened = usePropsStore((state) => state.allDataFlattened);\n const flattenedData = usePropsStore((state) => state.flattenedData);\n const isEmptyContent = usePropsStore((state) => state.isEmptyContent);\n const firstFocuseableColumnHeaderId = usePropsStore((state) => state.firstFocuseableColumnHeaderId);\n const domIdAffix = usePropsStore((state) => state.domIdAffix);\n const visibleRangeRef = usePropsStore((state) => state.visibleRangeRef);\n\n // We for sure have selection, so we just typecast it for TS reasons\n const dtSelection = selection ?? {};\n const selectionKeyCount = flattenedData.reduce(\n (acc, cur) => (dtSelection[cur.uid] && !disabledRows[cur.uid] ? 1 : 0) + acc,\n 0,\n );\n\n const currentGlobalState = useMemo(\n () =>\n selectionKeyCount > 0 && selectionKeyCount < flattenedData.filter((datum) => !disabledRows[datum.uid]).length\n ? 'mixed'\n : selectionKeyCount > 0,\n [selectionKeyCount, flattenedData, disabledRows],\n );\n\n // global state toggling: false to true, mixed to true, true to false\n const newGlobalStateAfterToggle = useMemo(() => currentGlobalState !== true, [currentGlobalState]);\n\n const newSelection: DSDataTableT.Selection = useMemo(() => {\n if (!newGlobalStateAfterToggle) return {};\n\n return allDataFlattened.reduce<DSDataTableT.Selection>((newSelectionObject, datum) => {\n newSelectionObject[datum.uid] = !disabledRows[datum.uid];\n return newSelectionObject;\n }, {});\n }, [newGlobalStateAfterToggle, allDataFlattened, disabledRows]);\n\n const onChangeHandler = useCallback(\n (newState: boolean, e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent) => {\n onSelectionChange(newSelection, 'All', e);\n },\n [newSelection, onSelectionChange],\n );\n\n const ariaControls = useMemo(\n () =>\n allDataFlattened\n .map((datum) => `data-table-checkbox-${datum.uid}${domIdAffix ? `-${domIdAffix}` : ''}`)\n .join(' '),\n [allDataFlattened, domIdAffix],\n );\n\n const startCandidate = visibleRangeRef.current.start - visibleRangeRef.current.overscan;\n const start = startCandidate > 0 ? startCandidate : 0;\n const endCandidate = visibleRangeRef.current.end + visibleRangeRef.current.overscan + 1;\n const end = endCandidate > visibleRangeRef.current.size ? visibleRangeRef.current.size : endCandidate;\n const visibleAriaControls = ariaControls.split(' ').slice(start, end).join(' ');\n\n return (\n <DSControlledCheckbox\n aria-controls={visibleAriaControls}\n data-testid={DATA_TESTID.DATA_TABLE_GLOBAL_CHECKBOX}\n aria-label={\n isEmptyContent && firstFocuseableColumnHeaderId === 'multiSelecter'\n ? `${noResultsMessage}. ${\n noResultsSecondaryMessage ? `${noResultsSecondaryMessage}.` : ''\n } Toggle all rows selected`\n : 'Toggle all rows selected'\n }\n checked={currentGlobalState}\n onChange={onChangeHandler}\n />\n );\n },\n Cell: ({ cell, row, isRowSelected, domIdAffix = genUid(4) }) => {\n const onSelectionChange = usePropsStore((state) => state.onSelectionChange);\n const selection = usePropsStore((state) => state.selection);\n const disabledRows = usePropsStore((state) => state.disabledRows);\n const lastSelected = usePropsStore((state) => state.lastSelected);\n const flattenedData = usePropsStore((state) => state.flattenedData);\n const checkboxSelectAllProps = usePropsStore((state) => state.checkboxSelectAllProps);\n\n const isShiftPressed = useInternalStore((state) => state.isShiftPressed);\n const setIsShiftPressed = useInternalStore((state) => state.setIsShiftPressed);\n\n const { uid, realIndex } = row;\n const selectedState = selection?.[uid] ?? false;\n const isShiftPressedKeyRef = useRef(false);\n const onChangeHandler = useCallback(\n (newState: boolean, e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent) => {\n let newSelection = { ...selection, [uid]: newState }; // we only want true and mixed values\n if (!newState) delete newSelection[uid]; // if newState is false, remove from the new selection\n const now = realIndex;\n if ((isShiftPressed || isShiftPressedKeyRef.current) && lastSelected.current > -1) {\n newSelection = updateRangeSelection(\n newSelection,\n lastSelected.current,\n now,\n flattenedData,\n disabledRows,\n newState,\n );\n }\n lastSelected.current = now;\n onSelectionChange(newSelection, uid, e);\n },\n [selection, uid, realIndex, isShiftPressed, lastSelected, onSelectionChange, flattenedData, disabledRows],\n );\n\n const onKeyDownHandler: React.KeyboardEventHandler = useCallback(\n (e) => {\n setIsShiftPressed(e.code === 'Shift' || e.shiftKey);\n e.stopPropagation();\n },\n [setIsShiftPressed],\n );\n\n const onKeyUpHandler: React.KeyboardEventHandler = useCallback(\n (e) => {\n setIsShiftPressed(false);\n isShiftPressedKeyRef.current = false;\n e.stopPropagation();\n },\n [setIsShiftPressed],\n );\n\n const stopThePropagation = useCallback((e: React.MouseEvent | React.KeyboardEvent) => {\n if (e.shiftKey) {\n isShiftPressedKeyRef.current = true;\n }\n e.stopPropagation();\n }, []);\n\n return (\n <div role=\"presentation\" onClick={stopThePropagation} onKeyDown={onKeyDownHandler} onKeyUp={onKeyUpHandler}>\n <DSControlledCheckbox\n id={`data-table-checkbox-${uid}-${domIdAffix}`}\n data-testid={DATA_TESTID.DATA_TABLE_CHECKBOX}\n aria-label=\"Toggle row selected\"\n checked={selectedState}\n onChange={onChangeHandler}\n disabled={disabledRows[row.uid]}\n innerRef={cell.ref}\n tabIndex={isRowSelected ? 0 : -1}\n {...checkboxSelectAllProps}\n />\n </div>\n );\n },\n textWrap: 'wrap',\n width: 32,\n padding: 7,\n canResize: false,\n isFocuseable: false,\n disableDnD: true,\n parentId: null,\n depth: 0,\n ref: createRef(),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADyEjB;AAxEN,mBAA+D;AAC/D,8BAAqC;AACrC,iBAA8B;AAE9B,uBAA4B;AAC5B,2CAAgD;AAChD,+BAAqC;AAC9B,MAAM,oBAAiD;AAAA;AAAA,EAE5D,IAAI;AAAA;AAAA,EACJ,QAAQ,MAAM;AACZ,UAAM,wBAAoB,oDAAc,CAAC,UAAU,MAAM,iBAAiB;AAC1E,UAAM,gBAAY,oDAAc,CAAC,UAAU,MAAM,SAAS;AAC1D,UAAM,mBAAe,oDAAc,CAAC,UAAU,MAAM,YAAY;AAChE,UAAM,uBAAmB,oDAAc,CAAC,UAAU,MAAM,gBAAgB;AACxE,UAAM,gCAA4B,oDAAc,CAAC,UAAU,MAAM,yBAAyB;AAC1F,UAAM,uBAAmB,oDAAc,CAAC,UAAU,MAAM,gBAAgB;AACxE,UAAM,oBAAgB,oDAAc,CAAC,UAAU,MAAM,aAAa;AAClE,UAAM,qBAAiB,oDAAc,CAAC,UAAU,MAAM,cAAc;AACpE,UAAM,oCAAgC,oDAAc,CAAC,UAAU,MAAM,6BAA6B;AAClG,UAAM,iBAAa,oDAAc,C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A,EACZ,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAK,wBAAU;AACjB;",
|
|
6
6
|
"names": ["genUid"]
|
|
7
7
|
}
|
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(useRowRendererHandlers_exports);
|
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_react = require("react");
|
|
36
36
|
var import_createInternalAndPropsContext = require("../../configs/useStore/createInternalAndPropsContext.js");
|
|
37
|
+
var import_multipleSelectRow = require("../../helpers/multipleSelectRow.js");
|
|
37
38
|
const useRowRendererHandlers = ({
|
|
38
39
|
row,
|
|
39
40
|
itemIndex,
|
|
@@ -67,16 +68,19 @@ const useRowRendererHandlers = ({
|
|
|
67
68
|
if (selectSingle) {
|
|
68
69
|
onSelectionChange({ [uid]: true }, uid, e);
|
|
69
70
|
} else {
|
|
70
|
-
const
|
|
71
|
+
const newState = !selection[uid];
|
|
72
|
+
let newSelection = { ...selection, [uid]: newState };
|
|
71
73
|
if (!newSelection[uid]) delete newSelection[uid];
|
|
72
|
-
const now =
|
|
74
|
+
const now = row.realIndex;
|
|
73
75
|
if (e.shiftKey && lastSelected.current > -1) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
newSelection = (0, import_multipleSelectRow.updateRangeSelection)(
|
|
77
|
+
newSelection,
|
|
78
|
+
lastSelected.current,
|
|
79
|
+
now,
|
|
80
|
+
flattenedData,
|
|
81
|
+
disabledRows,
|
|
82
|
+
newState
|
|
83
|
+
);
|
|
80
84
|
}
|
|
81
85
|
lastSelected.current = now;
|
|
82
86
|
onSelectionChange(newSelection, uid, e);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/exported-related/RowRenderer/useRowRendererHandlers.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback } from 'react';\nimport { useInternalStore, usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\nimport type { SortableItemContextType } from '../../parts/HoC/SortableItemContext.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAA4B;AAC5B,2CAAgD;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback } from 'react';\nimport { useInternalStore, usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\nimport type { SortableItemContextType } from '../../parts/HoC/SortableItemContext.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\nimport { updateRangeSelection } from '../../helpers/multipleSelectRow.js';\nexport const useRowRendererHandlers = ({\n row,\n itemIndex,\n items,\n draggableProps,\n isDragOverlay,\n drilldownRowId,\n}: {\n row: DSDataTableT.InternalRow;\n itemIndex: number;\n items: DSDataTableT.InternalRow[];\n draggableProps: SortableItemContextType['draggableProps'];\n isDragOverlay: boolean;\n drilldownRowId: string | null;\n}): {\n handleItemClick: React.MouseEventHandler;\n handleKeyDown: React.KeyboardEventHandler;\n handleOnBlur: React.FocusEventHandler;\n handleOnFocus: React.FocusEventHandler;\n} => {\n const onRowClick = usePropsStore((state) => state.onRowClick);\n const onSelectionChange = usePropsStore((state) => state.onSelectionChange);\n const selectSingle = usePropsStore((state) => state.selectSingle);\n const selection = usePropsStore((state) => state.selection);\n const onRowFocus = usePropsStore((state) => state.onRowFocus);\n const disabledRows = usePropsStore((state) => state.disabledRows);\n const lastSelected = usePropsStore((state) => state.lastSelected);\n const flattenedData = usePropsStore((state) => state.flattenedData);\n const { scrollToIndex } = usePropsStore((state) => state.virtualListHelpers);\n const setDrilldownRowId = useInternalStore((state) => state.setDrilldownRowId);\n const setFocusedRowId = useInternalStore((state) => state.setFocusedRowId);\n\n const findInCircularList = (\n list: DSDataTableT.InternalRow[],\n from: number,\n step = 1,\n // eslint-disable-next-line max-params\n ): number => {\n // the following loop is dark magic, requires a PHD in math to understand what's going on, but it works so...\n // eslint-disable-next-line no-unreachable-loop\n for (\n let i = (from + step + list.length) % list.length;\n i !== from && from > -1;\n i = (i + step + list.length) % list.length\n ) {\n return i;\n }\n return from; // return same item\n };\n\n const handleItemClick = useCallback(\n (e: React.MouseEvent | React.KeyboardEvent, { original, uid } = row) => {\n if (disabledRows[uid]) return;\n onRowClick(original, e, uid);\n if (selection && onSelectionChange) {\n if (selectSingle) {\n onSelectionChange({ [uid]: true }, uid, e);\n } else {\n const newState = !selection[uid];\n let newSelection = { ...selection, [uid]: newState }; // we only want true and mixed values\n if (!newSelection[uid]) delete newSelection[uid]; // if newState is false, remove from the new selection\n const now = row.realIndex;\n if (e.shiftKey && lastSelected.current > -1) {\n newSelection = updateRangeSelection(\n newSelection,\n lastSelected.current,\n now,\n flattenedData,\n disabledRows,\n newState,\n );\n }\n lastSelected.current = now;\n\n onSelectionChange(newSelection, uid, e);\n }\n }\n onRowFocus(\n {\n itemIndex,\n scrollToItem: (\n opts: { align: 'auto' | 'start' | 'center' | 'end' } = {\n align: 'start',\n },\n ) => scrollToIndex(itemIndex, opts),\n original,\n },\n e,\n );\n },\n [\n row,\n disabledRows,\n onRowClick,\n selection,\n onSelectionChange,\n onRowFocus,\n itemIndex,\n selectSingle,\n lastSelected,\n flattenedData,\n scrollToIndex,\n ],\n );\n\n const isActive = draggableProps && draggableProps.active;\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (isDragOverlay || isActive) {\n e.preventDefault();\n return;\n }\n const { target } = e;\n const isChildEvent = (target as HTMLElement).getAttribute('role') !== 'row'; // if the event comes from a row\n\n if (e.code === 'Enter') {\n if (!isChildEvent) {\n e.preventDefault();\n if (drilldownRowId !== row.uid) {\n setDrilldownRowId(row.uid);\n setTimeout(() => {\n const focuseableCell = row.cells.find((cell) => cell.ref.current !== null);\n if (focuseableCell) focuseableCell.ref.current?.focus?.();\n });\n }\n }\n }\n if (e.code === 'Space') {\n if (!isChildEvent) {\n e.preventDefault();\n }\n handleItemClick(e, row);\n }\n if (e.code === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n const next = findInCircularList(items, itemIndex);\n setFocusedRowId(items[next].uid);\n }\n if (e.code === 'ArrowUp') {\n e.preventDefault();\n const prev = findInCircularList(items, itemIndex, -1);\n setFocusedRowId(items[prev].uid);\n }\n },\n [\n isDragOverlay,\n isActive,\n drilldownRowId,\n row,\n setDrilldownRowId,\n handleItemClick,\n items,\n itemIndex,\n setFocusedRowId,\n ],\n );\n\n const handleOnBlur: React.FocusEventHandler = useCallback(\n (e) => {\n if (e.relatedTarget?.getAttribute('role') === 'row') {\n setDrilldownRowId(null);\n }\n },\n [setDrilldownRowId],\n );\n\n const handleOnFocus: React.FocusEventHandler = useCallback(\n (e) => {\n if (e.target && e.target.getAttribute('role') === 'row') {\n setFocusedRowId(row.uid);\n }\n },\n [row.uid, setFocusedRowId],\n );\n\n return { handleItemClick, handleKeyDown, handleOnBlur, handleOnFocus };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAA4B;AAC5B,2CAAgD;AAGhD,+BAAqC;AAC9B,MAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAYK;AACH,QAAM,iBAAa,oDAAc,CAAC,UAAU,MAAM,UAAU;AAC5D,QAAM,wBAAoB,oDAAc,CAAC,UAAU,MAAM,iBAAiB;AAC1E,QAAM,mBAAe,oDAAc,CAAC,UAAU,MAAM,YAAY;AAChE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,WAAW;AACxB,UAAE,eAAe;AACjB,cAAM,OAAO,mBAAmB,OAAO,WAAW,EAAE;AACpD,wBAAgB,MAAM,IAAI,EAAE,GAAG;AAAA,MACjC;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,mBAAwC;AAAA,IAC5C,CAAC,MAAM;AACL,UAAI,EAAE,eAAe,aAAa,MAAM,MAAM,OAAO;AACnD,0BAAkB,IAAI;AAAA,MACxB;AAAA,IACF;AAAA,IACA,CAAC,iBAAiB;AAAA,EACpB;AAEA,QAAM,oBAAyC;AAAA,IAC7C,CAAC,MAAM;AACL,UAAI,EAAE,UAAU,EAAE,OAAO,aAAa,MAAM,MAAM,OAAO;AACvD,wBAAgB,IAAI,GAAG;AAAA,MACzB;AAAA,IACF;AAAA,IACA,CAAC,IAAI,KAAK,eAAe;AAAA,EAC3B;AAEA,SAAO,EAAE,iBAAiB,eAAe,cAAc,cAAc;AACvE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var multipleSelectRow_exports = {};
|
|
30
|
+
__export(multipleSelectRow_exports, {
|
|
31
|
+
updateRangeSelection: () => updateRangeSelection
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(multipleSelectRow_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
function updateRangeSelection(currentSelection, lastSelectedIndex, currentRowIndex, flattenedData, disabledRows, newState) {
|
|
36
|
+
const updatedSelection = { ...currentSelection };
|
|
37
|
+
const start = Math.min(lastSelectedIndex, currentRowIndex);
|
|
38
|
+
const end = Math.max(lastSelectedIndex, currentRowIndex);
|
|
39
|
+
for (let i = start; i <= end; i += 1) {
|
|
40
|
+
const uid = flattenedData[i]?.uid;
|
|
41
|
+
if (uid && !disabledRows[uid]) {
|
|
42
|
+
updatedSelection[uid] = newState;
|
|
43
|
+
}
|
|
44
|
+
if (!updatedSelection[uid]) {
|
|
45
|
+
delete updatedSelection[uid];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return updatedSelection;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=multipleSelectRow.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/multipleSelectRow.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-params */\nimport type { DSDataTableT } from '../react-desc-prop-types.js';\n\nexport function updateRangeSelection(\n currentSelection: DSDataTableT.Selection,\n lastSelectedIndex: number,\n currentRowIndex: number,\n flattenedData: DSDataTableT.InternalRow[],\n disabledRows: Record<string, boolean>,\n newState: boolean,\n): DSDataTableT.Selection {\n const updatedSelection = { ...currentSelection };\n const start = Math.min(lastSelectedIndex, currentRowIndex);\n const end = Math.max(lastSelectedIndex, currentRowIndex);\n for (let i = start; i <= end; i += 1) {\n const uid = flattenedData[i]?.uid;\n if (uid && !disabledRows[uid]) {\n updatedSelection[uid] = newState;\n }\n if (!updatedSelection[uid]) {\n delete updatedSelection[uid];\n }\n }\n return updatedSelection;\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGhB,SAAS,qBACd,kBACA,mBACA,iBACA,eACA,cACA,UACwB;AACxB,QAAM,mBAAmB,EAAE,GAAG,iBAAiB;AAC/C,QAAM,QAAQ,KAAK,IAAI,mBAAmB,eAAe;AACzD,QAAM,MAAM,KAAK,IAAI,mBAAmB,eAAe;AACvD,WAAS,IAAI,OAAO,KAAK,KAAK,KAAK,GAAG;AACpC,UAAM,MAAM,cAAc,CAAC,GAAG;AAC9B,QAAI,OAAO,CAAC,aAAa,GAAG,GAAG;AAC7B,uBAAiB,GAAG,IAAI;AAAA,IAC1B;AACA,QAAI,CAAC,iBAAiB,GAAG,GAAG;AAC1B,aAAO,iBAAiB,GAAG;AAAA,IAC7B;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -5,6 +5,7 @@ import { DSControlledCheckbox } from "@elliemae/ds-form-checkbox";
|
|
|
5
5
|
import { uid as genUid } from "uid";
|
|
6
6
|
import { DATA_TESTID } from "../../../configs/constants.js";
|
|
7
7
|
import { useInternalStore, usePropsStore } from "../../../configs/useStore/createInternalAndPropsContext.js";
|
|
8
|
+
import { updateRangeSelection } from "../../../helpers/multipleSelectRow.js";
|
|
8
9
|
const multiSelectColumn = {
|
|
9
10
|
// Build our multiSelecter column
|
|
10
11
|
id: "multiSelecter",
|
|
@@ -73,26 +74,28 @@ const multiSelectColumn = {
|
|
|
73
74
|
const checkboxSelectAllProps = usePropsStore((state) => state.checkboxSelectAllProps);
|
|
74
75
|
const isShiftPressed = useInternalStore((state) => state.isShiftPressed);
|
|
75
76
|
const setIsShiftPressed = useInternalStore((state) => state.setIsShiftPressed);
|
|
76
|
-
const { uid } = row;
|
|
77
|
+
const { uid, realIndex } = row;
|
|
77
78
|
const selectedState = selection?.[uid] ?? false;
|
|
78
79
|
const isShiftPressedKeyRef = useRef(false);
|
|
79
80
|
const onChangeHandler = useCallback(
|
|
80
81
|
(newState, e) => {
|
|
81
|
-
|
|
82
|
+
let newSelection = { ...selection, [uid]: newState };
|
|
82
83
|
if (!newState) delete newSelection[uid];
|
|
83
|
-
const now =
|
|
84
|
+
const now = realIndex;
|
|
84
85
|
if ((isShiftPressed || isShiftPressedKeyRef.current) && lastSelected.current > -1) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
newSelection = updateRangeSelection(
|
|
87
|
+
newSelection,
|
|
88
|
+
lastSelected.current,
|
|
89
|
+
now,
|
|
90
|
+
flattenedData,
|
|
91
|
+
disabledRows,
|
|
92
|
+
newState
|
|
93
|
+
);
|
|
91
94
|
}
|
|
92
95
|
lastSelected.current = now;
|
|
93
96
|
onSelectionChange(newSelection, uid, e);
|
|
94
97
|
},
|
|
95
|
-
[
|
|
98
|
+
[selection, uid, realIndex, isShiftPressed, lastSelected, onSelectionChange, flattenedData, disabledRows]
|
|
96
99
|
);
|
|
97
100
|
const onKeyDownHandler = useCallback(
|
|
98
101
|
(e) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/addons/Columns/ColumnSelectMultiple/ColumnSelectMultiple.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\nimport React, { useMemo, useRef, useCallback, createRef } from 'react';\nimport { DSControlledCheckbox } from '@elliemae/ds-form-checkbox';\nimport { uid as genUid } from 'uid';\nimport type { DSDataTableT } from '../../../react-desc-prop-types.js';\nimport { DATA_TESTID } from '../../../configs/constants.js';\nimport { useInternalStore, usePropsStore } from '../../../configs/useStore/createInternalAndPropsContext.js';\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACyEjB;AAxEN,SAAgB,SAAS,QAAQ,aAAa,iBAAiB;AAC/D,SAAS,4BAA4B;AACrC,SAAS,OAAO,cAAc;AAE9B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\nimport React, { useMemo, useRef, useCallback, createRef } from 'react';\nimport { DSControlledCheckbox } from '@elliemae/ds-form-checkbox';\nimport { uid as genUid } from 'uid';\nimport type { DSDataTableT } from '../../../react-desc-prop-types.js';\nimport { DATA_TESTID } from '../../../configs/constants.js';\nimport { useInternalStore, usePropsStore } from '../../../configs/useStore/createInternalAndPropsContext.js';\nimport { updateRangeSelection } from '../../../helpers/multipleSelectRow.js';\nexport const multiSelectColumn: DSDataTableT.InternalColumn = {\n // Build our multiSelecter column\n id: 'multiSelecter', // Make sure it has an ID\n Header: () => {\n const onSelectionChange = usePropsStore((state) => state.onSelectionChange);\n const selection = usePropsStore((state) => state.selection);\n const disabledRows = usePropsStore((state) => state.disabledRows);\n const noResultsMessage = usePropsStore((state) => state.noResultsMessage);\n const noResultsSecondaryMessage = usePropsStore((state) => state.noResultsSecondaryMessage);\n const allDataFlattened = usePropsStore((state) => state.allDataFlattened);\n const flattenedData = usePropsStore((state) => state.flattenedData);\n const isEmptyContent = usePropsStore((state) => state.isEmptyContent);\n const firstFocuseableColumnHeaderId = usePropsStore((state) => state.firstFocuseableColumnHeaderId);\n const domIdAffix = usePropsStore((state) => state.domIdAffix);\n const visibleRangeRef = usePropsStore((state) => state.visibleRangeRef);\n\n // We for sure have selection, so we just typecast it for TS reasons\n const dtSelection = selection ?? {};\n const selectionKeyCount = flattenedData.reduce(\n (acc, cur) => (dtSelection[cur.uid] && !disabledRows[cur.uid] ? 1 : 0) + acc,\n 0,\n );\n\n const currentGlobalState = useMemo(\n () =>\n selectionKeyCount > 0 && selectionKeyCount < flattenedData.filter((datum) => !disabledRows[datum.uid]).length\n ? 'mixed'\n : selectionKeyCount > 0,\n [selectionKeyCount, flattenedData, disabledRows],\n );\n\n // global state toggling: false to true, mixed to true, true to false\n const newGlobalStateAfterToggle = useMemo(() => currentGlobalState !== true, [currentGlobalState]);\n\n const newSelection: DSDataTableT.Selection = useMemo(() => {\n if (!newGlobalStateAfterToggle) return {};\n\n return allDataFlattened.reduce<DSDataTableT.Selection>((newSelectionObject, datum) => {\n newSelectionObject[datum.uid] = !disabledRows[datum.uid];\n return newSelectionObject;\n }, {});\n }, [newGlobalStateAfterToggle, allDataFlattened, disabledRows]);\n\n const onChangeHandler = useCallback(\n (newState: boolean, e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent) => {\n onSelectionChange(newSelection, 'All', e);\n },\n [newSelection, onSelectionChange],\n );\n\n const ariaControls = useMemo(\n () =>\n allDataFlattened\n .map((datum) => `data-table-checkbox-${datum.uid}${domIdAffix ? `-${domIdAffix}` : ''}`)\n .join(' '),\n [allDataFlattened, domIdAffix],\n );\n\n const startCandidate = visibleRangeRef.current.start - visibleRangeRef.current.overscan;\n const start = startCandidate > 0 ? startCandidate : 0;\n const endCandidate = visibleRangeRef.current.end + visibleRangeRef.current.overscan + 1;\n const end = endCandidate > visibleRangeRef.current.size ? visibleRangeRef.current.size : endCandidate;\n const visibleAriaControls = ariaControls.split(' ').slice(start, end).join(' ');\n\n return (\n <DSControlledCheckbox\n aria-controls={visibleAriaControls}\n data-testid={DATA_TESTID.DATA_TABLE_GLOBAL_CHECKBOX}\n aria-label={\n isEmptyContent && firstFocuseableColumnHeaderId === 'multiSelecter'\n ? `${noResultsMessage}. ${\n noResultsSecondaryMessage ? `${noResultsSecondaryMessage}.` : ''\n } Toggle all rows selected`\n : 'Toggle all rows selected'\n }\n checked={currentGlobalState}\n onChange={onChangeHandler}\n />\n );\n },\n Cell: ({ cell, row, isRowSelected, domIdAffix = genUid(4) }) => {\n const onSelectionChange = usePropsStore((state) => state.onSelectionChange);\n const selection = usePropsStore((state) => state.selection);\n const disabledRows = usePropsStore((state) => state.disabledRows);\n const lastSelected = usePropsStore((state) => state.lastSelected);\n const flattenedData = usePropsStore((state) => state.flattenedData);\n const checkboxSelectAllProps = usePropsStore((state) => state.checkboxSelectAllProps);\n\n const isShiftPressed = useInternalStore((state) => state.isShiftPressed);\n const setIsShiftPressed = useInternalStore((state) => state.setIsShiftPressed);\n\n const { uid, realIndex } = row;\n const selectedState = selection?.[uid] ?? false;\n const isShiftPressedKeyRef = useRef(false);\n const onChangeHandler = useCallback(\n (newState: boolean, e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent) => {\n let newSelection = { ...selection, [uid]: newState }; // we only want true and mixed values\n if (!newState) delete newSelection[uid]; // if newState is false, remove from the new selection\n const now = realIndex;\n if ((isShiftPressed || isShiftPressedKeyRef.current) && lastSelected.current > -1) {\n newSelection = updateRangeSelection(\n newSelection,\n lastSelected.current,\n now,\n flattenedData,\n disabledRows,\n newState,\n );\n }\n lastSelected.current = now;\n onSelectionChange(newSelection, uid, e);\n },\n [selection, uid, realIndex, isShiftPressed, lastSelected, onSelectionChange, flattenedData, disabledRows],\n );\n\n const onKeyDownHandler: React.KeyboardEventHandler = useCallback(\n (e) => {\n setIsShiftPressed(e.code === 'Shift' || e.shiftKey);\n e.stopPropagation();\n },\n [setIsShiftPressed],\n );\n\n const onKeyUpHandler: React.KeyboardEventHandler = useCallback(\n (e) => {\n setIsShiftPressed(false);\n isShiftPressedKeyRef.current = false;\n e.stopPropagation();\n },\n [setIsShiftPressed],\n );\n\n const stopThePropagation = useCallback((e: React.MouseEvent | React.KeyboardEvent) => {\n if (e.shiftKey) {\n isShiftPressedKeyRef.current = true;\n }\n e.stopPropagation();\n }, []);\n\n return (\n <div role=\"presentation\" onClick={stopThePropagation} onKeyDown={onKeyDownHandler} onKeyUp={onKeyUpHandler}>\n <DSControlledCheckbox\n id={`data-table-checkbox-${uid}-${domIdAffix}`}\n data-testid={DATA_TESTID.DATA_TABLE_CHECKBOX}\n aria-label=\"Toggle row selected\"\n checked={selectedState}\n onChange={onChangeHandler}\n disabled={disabledRows[row.uid]}\n innerRef={cell.ref}\n tabIndex={isRowSelected ? 0 : -1}\n {...checkboxSelectAllProps}\n />\n </div>\n );\n },\n textWrap: 'wrap',\n width: 32,\n padding: 7,\n canResize: false,\n isFocuseable: false,\n disableDnD: true,\n parentId: null,\n depth: 0,\n ref: createRef(),\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACyEjB;AAxEN,SAAgB,SAAS,QAAQ,aAAa,iBAAiB;AAC/D,SAAS,4BAA4B;AACrC,SAAS,OAAO,cAAc;AAE9B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,qBAAqB;AAChD,SAAS,4BAA4B;AAC9B,MAAM,oBAAiD;AAAA;AAAA,EAE5D,IAAI;AAAA;AAAA,EACJ,QAAQ,MAAM;AACZ,UAAM,oBAAoB,cAAc,CAAC,UAAU,MAAM,iBAAiB;AAC1E,UAAM,YAAY,cAAc,CAAC,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AAAA;AAAA,QACC,IAAI,uBAAuB,GAAG,IAAI,UAAU;AAAA,QAC5C,eAAa,YAAY;AAAA,QACzB,cAAW;AAAA,QACX,SAAS;AAAA,QACT,UAAU;AAAA,QACV,UAAU,aAAa,IAAI,GAAG;AAAA,QAC9B,UAAU,KAAK;AAAA,QACf,UAAU,gBAAgB,IAAI;AAAA,QAC7B,GAAG;AAAA;AAAA,IACN,GACF;AAAA,EAEJ;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK,UAAU;AACjB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { useInternalStore, usePropsStore } from "../../configs/useStore/createInternalAndPropsContext.js";
|
|
4
|
+
import { updateRangeSelection } from "../../helpers/multipleSelectRow.js";
|
|
4
5
|
const useRowRendererHandlers = ({
|
|
5
6
|
row,
|
|
6
7
|
itemIndex,
|
|
@@ -34,16 +35,19 @@ const useRowRendererHandlers = ({
|
|
|
34
35
|
if (selectSingle) {
|
|
35
36
|
onSelectionChange({ [uid]: true }, uid, e);
|
|
36
37
|
} else {
|
|
37
|
-
const
|
|
38
|
+
const newState = !selection[uid];
|
|
39
|
+
let newSelection = { ...selection, [uid]: newState };
|
|
38
40
|
if (!newSelection[uid]) delete newSelection[uid];
|
|
39
|
-
const now =
|
|
41
|
+
const now = row.realIndex;
|
|
40
42
|
if (e.shiftKey && lastSelected.current > -1) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
newSelection = updateRangeSelection(
|
|
44
|
+
newSelection,
|
|
45
|
+
lastSelected.current,
|
|
46
|
+
now,
|
|
47
|
+
flattenedData,
|
|
48
|
+
disabledRows,
|
|
49
|
+
newState
|
|
50
|
+
);
|
|
47
51
|
}
|
|
48
52
|
lastSelected.current = now;
|
|
49
53
|
onSelectionChange(newSelection, uid, e);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/exported-related/RowRenderer/useRowRendererHandlers.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback } from 'react';\nimport { useInternalStore, usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\nimport type { SortableItemContextType } from '../../parts/HoC/SortableItemContext.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback } from 'react';\nimport { useInternalStore, usePropsStore } from '../../configs/useStore/createInternalAndPropsContext.js';\nimport type { SortableItemContextType } from '../../parts/HoC/SortableItemContext.js';\nimport type { DSDataTableT } from '../../react-desc-prop-types.js';\nimport { updateRangeSelection } from '../../helpers/multipleSelectRow.js';\nexport const useRowRendererHandlers = ({\n row,\n itemIndex,\n items,\n draggableProps,\n isDragOverlay,\n drilldownRowId,\n}: {\n row: DSDataTableT.InternalRow;\n itemIndex: number;\n items: DSDataTableT.InternalRow[];\n draggableProps: SortableItemContextType['draggableProps'];\n isDragOverlay: boolean;\n drilldownRowId: string | null;\n}): {\n handleItemClick: React.MouseEventHandler;\n handleKeyDown: React.KeyboardEventHandler;\n handleOnBlur: React.FocusEventHandler;\n handleOnFocus: React.FocusEventHandler;\n} => {\n const onRowClick = usePropsStore((state) => state.onRowClick);\n const onSelectionChange = usePropsStore((state) => state.onSelectionChange);\n const selectSingle = usePropsStore((state) => state.selectSingle);\n const selection = usePropsStore((state) => state.selection);\n const onRowFocus = usePropsStore((state) => state.onRowFocus);\n const disabledRows = usePropsStore((state) => state.disabledRows);\n const lastSelected = usePropsStore((state) => state.lastSelected);\n const flattenedData = usePropsStore((state) => state.flattenedData);\n const { scrollToIndex } = usePropsStore((state) => state.virtualListHelpers);\n const setDrilldownRowId = useInternalStore((state) => state.setDrilldownRowId);\n const setFocusedRowId = useInternalStore((state) => state.setFocusedRowId);\n\n const findInCircularList = (\n list: DSDataTableT.InternalRow[],\n from: number,\n step = 1,\n // eslint-disable-next-line max-params\n ): number => {\n // the following loop is dark magic, requires a PHD in math to understand what's going on, but it works so...\n // eslint-disable-next-line no-unreachable-loop\n for (\n let i = (from + step + list.length) % list.length;\n i !== from && from > -1;\n i = (i + step + list.length) % list.length\n ) {\n return i;\n }\n return from; // return same item\n };\n\n const handleItemClick = useCallback(\n (e: React.MouseEvent | React.KeyboardEvent, { original, uid } = row) => {\n if (disabledRows[uid]) return;\n onRowClick(original, e, uid);\n if (selection && onSelectionChange) {\n if (selectSingle) {\n onSelectionChange({ [uid]: true }, uid, e);\n } else {\n const newState = !selection[uid];\n let newSelection = { ...selection, [uid]: newState }; // we only want true and mixed values\n if (!newSelection[uid]) delete newSelection[uid]; // if newState is false, remove from the new selection\n const now = row.realIndex;\n if (e.shiftKey && lastSelected.current > -1) {\n newSelection = updateRangeSelection(\n newSelection,\n lastSelected.current,\n now,\n flattenedData,\n disabledRows,\n newState,\n );\n }\n lastSelected.current = now;\n\n onSelectionChange(newSelection, uid, e);\n }\n }\n onRowFocus(\n {\n itemIndex,\n scrollToItem: (\n opts: { align: 'auto' | 'start' | 'center' | 'end' } = {\n align: 'start',\n },\n ) => scrollToIndex(itemIndex, opts),\n original,\n },\n e,\n );\n },\n [\n row,\n disabledRows,\n onRowClick,\n selection,\n onSelectionChange,\n onRowFocus,\n itemIndex,\n selectSingle,\n lastSelected,\n flattenedData,\n scrollToIndex,\n ],\n );\n\n const isActive = draggableProps && draggableProps.active;\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (isDragOverlay || isActive) {\n e.preventDefault();\n return;\n }\n const { target } = e;\n const isChildEvent = (target as HTMLElement).getAttribute('role') !== 'row'; // if the event comes from a row\n\n if (e.code === 'Enter') {\n if (!isChildEvent) {\n e.preventDefault();\n if (drilldownRowId !== row.uid) {\n setDrilldownRowId(row.uid);\n setTimeout(() => {\n const focuseableCell = row.cells.find((cell) => cell.ref.current !== null);\n if (focuseableCell) focuseableCell.ref.current?.focus?.();\n });\n }\n }\n }\n if (e.code === 'Space') {\n if (!isChildEvent) {\n e.preventDefault();\n }\n handleItemClick(e, row);\n }\n if (e.code === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n const next = findInCircularList(items, itemIndex);\n setFocusedRowId(items[next].uid);\n }\n if (e.code === 'ArrowUp') {\n e.preventDefault();\n const prev = findInCircularList(items, itemIndex, -1);\n setFocusedRowId(items[prev].uid);\n }\n },\n [\n isDragOverlay,\n isActive,\n drilldownRowId,\n row,\n setDrilldownRowId,\n handleItemClick,\n items,\n itemIndex,\n setFocusedRowId,\n ],\n );\n\n const handleOnBlur: React.FocusEventHandler = useCallback(\n (e) => {\n if (e.relatedTarget?.getAttribute('role') === 'row') {\n setDrilldownRowId(null);\n }\n },\n [setDrilldownRowId],\n );\n\n const handleOnFocus: React.FocusEventHandler = useCallback(\n (e) => {\n if (e.target && e.target.getAttribute('role') === 'row') {\n setFocusedRowId(row.uid);\n }\n },\n [row.uid, setFocusedRowId],\n );\n\n return { handleItemClick, handleKeyDown, handleOnBlur, handleOnFocus };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,qBAAqB;AAGhD,SAAS,4BAA4B;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;AACjB,YAAE,eAAe;AAAA,QACnB;AACA,wBAAgB,GAAG,GAAG;AAAA,MACxB;AACA,UAAI,EAAE,SAAS,aAAa;AAC1B,UAAE,eAAe;AACjB,UAAE,gBAAgB;AAClB,cAAM,OAAO,mBAAmB,OAAO,SAAS;AAChD,wBAAgB,MAAM,IAAI,EAAE,GAAG;AAAA,MACjC;AACA,UAAI,EAAE,SAAS,WAAW;AACxB,UAAE,eAAe;AACjB,cAAM,OAAO,mBAAmB,OAAO,WAAW,EAAE;AACpD,wBAAgB,MAAM,IAAI,EAAE,GAAG;AAAA,MACjC;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAwC;AAAA,IAC5C,CAAC,MAAM;AACL,UAAI,EAAE,eAAe,aAAa,MAAM,MAAM,OAAO;AACnD,0BAAkB,IAAI;AAAA,MACxB;AAAA,IACF;AAAA,IACA,CAAC,iBAAiB;AAAA,EACpB;AAEA,QAAM,gBAAyC;AAAA,IAC7C,CAAC,MAAM;AACL,UAAI,EAAE,UAAU,EAAE,OAAO,aAAa,MAAM,MAAM,OAAO;AACvD,wBAAgB,IAAI,GAAG;AAAA,MACzB;AAAA,IACF;AAAA,IACA,CAAC,IAAI,KAAK,eAAe;AAAA,EAC3B;AAEA,SAAO,EAAE,iBAAiB,eAAe,cAAc,cAAc;AACvE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function updateRangeSelection(currentSelection, lastSelectedIndex, currentRowIndex, flattenedData, disabledRows, newState) {
|
|
3
|
+
const updatedSelection = { ...currentSelection };
|
|
4
|
+
const start = Math.min(lastSelectedIndex, currentRowIndex);
|
|
5
|
+
const end = Math.max(lastSelectedIndex, currentRowIndex);
|
|
6
|
+
for (let i = start; i <= end; i += 1) {
|
|
7
|
+
const uid = flattenedData[i]?.uid;
|
|
8
|
+
if (uid && !disabledRows[uid]) {
|
|
9
|
+
updatedSelection[uid] = newState;
|
|
10
|
+
}
|
|
11
|
+
if (!updatedSelection[uid]) {
|
|
12
|
+
delete updatedSelection[uid];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return updatedSelection;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
updateRangeSelection
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=multipleSelectRow.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/helpers/multipleSelectRow.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport type { DSDataTableT } from '../react-desc-prop-types.js';\n\nexport function updateRangeSelection(\n currentSelection: DSDataTableT.Selection,\n lastSelectedIndex: number,\n currentRowIndex: number,\n flattenedData: DSDataTableT.InternalRow[],\n disabledRows: Record<string, boolean>,\n newState: boolean,\n): DSDataTableT.Selection {\n const updatedSelection = { ...currentSelection };\n const start = Math.min(lastSelectedIndex, currentRowIndex);\n const end = Math.max(lastSelectedIndex, currentRowIndex);\n for (let i = start; i <= end; i += 1) {\n const uid = flattenedData[i]?.uid;\n if (uid && !disabledRows[uid]) {\n updatedSelection[uid] = newState;\n }\n if (!updatedSelection[uid]) {\n delete updatedSelection[uid];\n }\n }\n return updatedSelection;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGhB,SAAS,qBACd,kBACA,mBACA,iBACA,eACA,cACA,UACwB;AACxB,QAAM,mBAAmB,EAAE,GAAG,iBAAiB;AAC/C,QAAM,QAAQ,KAAK,IAAI,mBAAmB,eAAe;AACzD,QAAM,MAAM,KAAK,IAAI,mBAAmB,eAAe;AACvD,WAAS,IAAI,OAAO,KAAK,KAAK,KAAK,GAAG;AACpC,UAAM,MAAM,cAAc,CAAC,GAAG;AAC9B,QAAI,OAAO,CAAC,aAAa,GAAG,GAAG;AAC7B,uBAAiB,GAAG,IAAI;AAAA,IAC1B;AACA,QAAI,CAAC,iBAAiB,GAAG,GAAG;AAC1B,aAAO,iBAAiB,GAAG;AAAA,IAC7B;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { DSDataTableT } from '../react-desc-prop-types.js';
|
|
2
|
+
export declare function updateRangeSelection(currentSelection: DSDataTableT.Selection, lastSelectedIndex: number, currentRowIndex: number, flattenedData: DSDataTableT.InternalRow[], disabledRows: Record<string, boolean>, newState: boolean): DSDataTableT.Selection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-data-table",
|
|
3
|
-
"version": "3.51.0-rc.
|
|
3
|
+
"version": "3.51.0-rc.18",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Data Table",
|
|
6
6
|
"files": [
|
|
@@ -39,39 +39,39 @@
|
|
|
39
39
|
"react-virtual": "~2.10.4",
|
|
40
40
|
"uid": "~2.0.1",
|
|
41
41
|
"use-onclickoutside": "0.4.1",
|
|
42
|
-
"@elliemae/ds-button": "3.51.0-rc.
|
|
43
|
-
"@elliemae/ds-
|
|
44
|
-
"@elliemae/ds-
|
|
45
|
-
"@elliemae/ds-
|
|
46
|
-
"@elliemae/ds-dropdownmenu": "3.51.0-rc.
|
|
47
|
-
"@elliemae/ds-form-
|
|
48
|
-
"@elliemae/ds-
|
|
49
|
-
"@elliemae/ds-
|
|
50
|
-
"@elliemae/ds-form-date-time-picker": "3.51.0-rc.
|
|
51
|
-
"@elliemae/ds-form-
|
|
52
|
-
"@elliemae/ds-
|
|
53
|
-
"@elliemae/ds-form-input-text": "3.51.0-rc.
|
|
54
|
-
"@elliemae/ds-form-
|
|
55
|
-
"@elliemae/ds-grid": "3.51.0-rc.
|
|
56
|
-
"@elliemae/ds-pagination": "3.51.0-rc.
|
|
57
|
-
"@elliemae/ds-
|
|
58
|
-
"@elliemae/ds-pills-v2": "3.51.0-rc.
|
|
59
|
-
"@elliemae/ds-
|
|
60
|
-
"@elliemae/ds-
|
|
61
|
-
"@elliemae/ds-
|
|
62
|
-
"@elliemae/ds-
|
|
63
|
-
"@elliemae/ds-
|
|
64
|
-
"@elliemae/ds-
|
|
65
|
-
"@elliemae/ds-zustand-helpers": "3.51.0-rc.
|
|
66
|
-
"@elliemae/ds-
|
|
42
|
+
"@elliemae/ds-button-v2": "3.51.0-rc.18",
|
|
43
|
+
"@elliemae/ds-drag-and-drop": "3.51.0-rc.18",
|
|
44
|
+
"@elliemae/ds-button": "3.51.0-rc.18",
|
|
45
|
+
"@elliemae/ds-form-checkbox": "3.51.0-rc.18",
|
|
46
|
+
"@elliemae/ds-dropdownmenu": "3.51.0-rc.18",
|
|
47
|
+
"@elliemae/ds-form-combobox": "3.51.0-rc.18",
|
|
48
|
+
"@elliemae/ds-form-date-range-picker": "3.51.0-rc.18",
|
|
49
|
+
"@elliemae/ds-dropdownmenu-v2": "3.51.0-rc.18",
|
|
50
|
+
"@elliemae/ds-form-date-time-picker": "3.51.0-rc.18",
|
|
51
|
+
"@elliemae/ds-form-helpers-mask-hooks": "3.51.0-rc.18",
|
|
52
|
+
"@elliemae/ds-circular-progress-indicator": "3.51.0-rc.18",
|
|
53
|
+
"@elliemae/ds-form-input-text": "3.51.0-rc.18",
|
|
54
|
+
"@elliemae/ds-form-layout-blocks": "3.51.0-rc.18",
|
|
55
|
+
"@elliemae/ds-grid": "3.51.0-rc.18",
|
|
56
|
+
"@elliemae/ds-pagination": "3.51.0-rc.18",
|
|
57
|
+
"@elliemae/ds-form-radio": "3.51.0-rc.18",
|
|
58
|
+
"@elliemae/ds-pills-v2": "3.51.0-rc.18",
|
|
59
|
+
"@elliemae/ds-icons": "3.51.0-rc.18",
|
|
60
|
+
"@elliemae/ds-popperjs": "3.51.0-rc.18",
|
|
61
|
+
"@elliemae/ds-props-helpers": "3.51.0-rc.18",
|
|
62
|
+
"@elliemae/ds-system": "3.51.0-rc.18",
|
|
63
|
+
"@elliemae/ds-truncated-tooltip-text": "3.51.0-rc.18",
|
|
64
|
+
"@elliemae/ds-typescript-helpers": "3.51.0-rc.18",
|
|
65
|
+
"@elliemae/ds-zustand-helpers": "3.51.0-rc.18",
|
|
66
|
+
"@elliemae/ds-skeleton": "3.51.0-rc.18"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@elliemae/pui-cli": "9.0.0-next.55",
|
|
70
70
|
"jest": "~29.7.0",
|
|
71
71
|
"styled-components": "~5.3.9",
|
|
72
72
|
"styled-system": "^5.1.5",
|
|
73
|
-
"@elliemae/ds-monorepo-devops": "3.51.0-rc.
|
|
74
|
-
"@elliemae/ds-toolbar-v2": "3.51.0-rc.
|
|
73
|
+
"@elliemae/ds-monorepo-devops": "3.51.0-rc.18",
|
|
74
|
+
"@elliemae/ds-toolbar-v2": "3.51.0-rc.18"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"lodash": "^4.17.21",
|