@elliemae/ds-data-table 3.51.0-rc.16 → 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.
@@ -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
- const newSelection = { ...selection, [uid]: newState };
115
+ let newSelection = { ...selection, [uid]: newState };
115
116
  if (!newState) delete newSelection[uid];
116
- const now = Number.parseInt(uid, 10);
117
+ const now = realIndex;
117
118
  if ((isShiftPressed || isShiftPressedKeyRef.current) && lastSelected.current > -1) {
118
- for (let i = Math.min(lastSelected.current, now); i <= Math.max(lastSelected.current, now); i += 1) {
119
- const correctDataIndex = flattenedData[i]?.id;
120
- if (!Object.keys(disabledRows).includes(correctDataIndex))
121
- newSelection[correctDataIndex] = newSelection[lastSelected.current];
122
- if (!newSelection[correctDataIndex]) delete newSelection[correctDataIndex];
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
- [disabledRows, flattenedData, isShiftPressed, lastSelected, onSelectionChange, selection, uid]
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';\n\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 } = row;\n const selectedState = selection?.[uid] ?? false;\n\n const isShiftPressedKeyRef = useRef(false);\n const onChangeHandler = useCallback(\n (newState: boolean, e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent) => {\n const 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 = Number.parseInt(uid, 10);\n if ((isShiftPressed || isShiftPressedKeyRef.current) && lastSelected.current > -1) {\n for (let i = Math.min(lastSelected.current, now); i <= Math.max(lastSelected.current, now); i += 1) {\n const correctDataIndex = flattenedData[i]?.id;\n if (!Object.keys(disabledRows).includes(correctDataIndex))\n newSelection[correctDataIndex] = newSelection[lastSelected.current];\n if (!newSelection[correctDataIndex]) delete newSelection[correctDataIndex];\n }\n }\n lastSelected.current = now;\n onSelectionChange(newSelection, uid, e);\n },\n [disabledRows, flattenedData, isShiftPressed, lastSelected, onSelectionChange, selection, uid],\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;AAEzC,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,MA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A,MAAC;AAAA;AAAA,QACC,IAAI,uBAAuB,GAAG,IAAI,UAAU;AAAA,QAC5C,eAAa,6BAAY;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,SAAK,wBAAU;AACjB;",
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,U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AO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AAAA,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 newSelection = { ...selection, [uid]: !selection[uid] };
71
+ const newState = !selection[uid];
72
+ let newSelection = { ...selection, [uid]: newState };
71
73
  if (!newSelection[uid]) delete newSelection[uid];
72
- const now = Number.parseInt(uid, 10);
74
+ const now = row.realIndex;
73
75
  if (e.shiftKey && lastSelected.current > -1) {
74
- for (let i = Math.min(lastSelected.current, now); i <= Math.max(lastSelected.current, now); i += 1) {
75
- const correctDataIndex = flattenedData[i]?.id;
76
- if (!Object.keys(disabledRows).includes(correctDataIndex))
77
- newSelection[correctDataIndex] = newSelection[lastSelected.current];
78
- if (!newSelection[correctDataIndex]) delete newSelection[correctDataIndex];
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';\n\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 newSelection = { ...selection, [uid]: !selection[uid] }; // 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 = Number.parseInt(uid, 10);\n if (e.shiftKey && lastSelected.current > -1) {\n for (let i = Math.min(lastSelected.current, now); i <= Math.max(lastSelected.current, now); i += 1) {\n const correctDataIndex = flattenedData[i]?.id;\n if (!Object.keys(disabledRows).includes(correctDataIndex))\n newSelection[correctDataIndex] = newSelection[lastSelected.current];\n if (!newSelection[correctDataIndex]) delete newSelection[correctDataIndex];\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;AAIzC,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,QAAM,gBAAY,oDAAc,CAAC,UAAU,MAAM,SAAS;AAC1D,QAAM,iBAAa,oDAAc,CAAC,UAAU,MAAM,UAAU;AAC5D,QAAM,mBAAe,oDAAc,CAAC,UAAU,MAAM,YAAY;AAChE,QAAM,mBAAe,oDAAc,CAAC,UAAU,MAAM,YAAY;AAChE,QAAM,oBAAgB,oDAAc,CAAC,UAAU,MAAM,aAAa;AAClE,QAAM,EAAE,cAAc,QAAI,oDAAc,CAAC,UAA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AE;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;",
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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AAS;AACtB,YAAI,CAAC,cAAc;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,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
- const newSelection = { ...selection, [uid]: newState };
82
+ let newSelection = { ...selection, [uid]: newState };
82
83
  if (!newState) delete newSelection[uid];
83
- const now = Number.parseInt(uid, 10);
84
+ const now = realIndex;
84
85
  if ((isShiftPressed || isShiftPressedKeyRef.current) && lastSelected.current > -1) {
85
- for (let i = Math.min(lastSelected.current, now); i <= Math.max(lastSelected.current, now); i += 1) {
86
- const correctDataIndex = flattenedData[i]?.id;
87
- if (!Object.keys(disabledRows).includes(correctDataIndex))
88
- newSelection[correctDataIndex] = newSelection[lastSelected.current];
89
- if (!newSelection[correctDataIndex]) delete newSelection[correctDataIndex];
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
- [disabledRows, flattenedData, isShiftPressed, lastSelected, onSelectionChange, selection, uid]
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';\n\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 } = row;\n const selectedState = selection?.[uid] ?? false;\n\n const isShiftPressedKeyRef = useRef(false);\n const onChangeHandler = useCallback(\n (newState: boolean, e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent) => {\n const 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 = Number.parseInt(uid, 10);\n if ((isShiftPressed || isShiftPressedKeyRef.current) && lastSelected.current > -1) {\n for (let i = Math.min(lastSelected.current, now); i <= Math.max(lastSelected.current, now); i += 1) {\n const correctDataIndex = flattenedData[i]?.id;\n if (!Object.keys(disabledRows).includes(correctDataIndex))\n newSelection[correctDataIndex] = newSelection[lastSelected.current];\n if (!newSelection[correctDataIndex]) delete newSelection[correctDataIndex];\n }\n }\n lastSelected.current = now;\n onSelectionChange(newSelection, uid, e);\n },\n [disabledRows, flattenedData, isShiftPressed, lastSelected, onSelectionChange, selection, uid],\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;AAEzC,MAAM,oBAAiD;AAAA;AAAA,EAE5D,IAAI;AAAA;AAAA,EACJ,QAAQ,MAAM;AACZ,UAAM,oBAAoB,cAAc,CAAC,UAAU,MAAM,iBAAiB;AAC1E,UAAM,YAAY,cAAc,CAAC,UAAU,MAAM,SAAS;AAC1D,UAAM,eAAe,cAAc,CAAC,UAAU,MAAM,YAAY;AAChE,UAAM,mBAAmB,cAAc,CAAC,UAAU,MAAM,gBAAgB;AACxE,UAAM,4BAA4B,cAAc,CAAC,UAAU,MAAM,yBAAyB;AAC1F,UAAM,mBAAmB,cAAc,CAAC,UAAU,MAAM,gBAAgB;AACxE,UAAM,gBAAgB,cAAc,CAAC,UAAU,MAAM,aAAa;AAClE,UAAM,iBAAiB,cAAc,CAAC,UAAU,MAAM,cAAc;AACpE,UAAM,gCAAgC,cAAc,CAAC,UAAU,MAAM,6BAA6B;AAClG,UAAM,aAAa,cAAc,CAAC,UAAU,MAAM,UAAU;AAC5D,UAAM,kBAAkB,cAAc,CAAC,UAAU,MAAM,eAAe;AAGtE,UAAM,cAAc,aAAa,CAAC;AAClC,UAAM,oBAAoB,cAAc;AAAA,MACtC,CAAC,KAAK,SAAS,YAAY,IAAI,GAAG,KAAK,CAAC,aAAa,IAAI,GAAG,IAAI,IAAI,KAAK;AAAA,MACzE;AAAA,IACF;A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P,KAAK,UAAU;AACjB;",
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 text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AQ;AAClD,UAAE,gBAAgB;AAAA,MACpB;AAAA,MACA,CAAC,iBAAiB;AAAA,IACpB;AAEA,UAAM,iBAA6C;AAAA,MACjD,CAAC,MAAM;AACL,0BAAkB,KAAK;AACvB,6BAAqB,UAAU;AAC/B,UAAE,gBAAgB;AAAA,MACpB;AAAA,MACA,CAAC,iBAAiB;AAAA,IACpB;AAEA,UAAM,qBAAqB,YAAY,CAAC,MAA8C;AACpF,UAAI,EAAE,UAAU;AACd,6BAAqB,UAAU;AAAA,MACjC;AACA,QAAE,gBAAgB;AAAA,IACpB,GAAG,CAAC,CAAC;AAEL,WACE,oBAAC,SAAI,MAAK,gBAAe,SAAS,oBAAoB,WAAW,kBAAkB,SAAS,gBAC1F;AAAA,MAAC;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 newSelection = { ...selection, [uid]: !selection[uid] };
38
+ const newState = !selection[uid];
39
+ let newSelection = { ...selection, [uid]: newState };
38
40
  if (!newSelection[uid]) delete newSelection[uid];
39
- const now = Number.parseInt(uid, 10);
41
+ const now = row.realIndex;
40
42
  if (e.shiftKey && lastSelected.current > -1) {
41
- for (let i = Math.min(lastSelected.current, now); i <= Math.max(lastSelected.current, now); i += 1) {
42
- const correctDataIndex = flattenedData[i]?.id;
43
- if (!Object.keys(disabledRows).includes(correctDataIndex))
44
- newSelection[correctDataIndex] = newSelection[lastSelected.current];
45
- if (!newSelection[correctDataIndex]) delete newSelection[correctDataIndex];
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';\n\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 newSelection = { ...selection, [uid]: !selection[uid] }; // 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 = Number.parseInt(uid, 10);\n if (e.shiftKey && lastSelected.current > -1) {\n for (let i = Math.min(lastSelected.current, now); i <= Math.max(lastSelected.current, now); i += 1) {\n const correctDataIndex = flattenedData[i]?.id;\n if (!Object.keys(disabledRows).includes(correctDataIndex))\n newSelection[correctDataIndex] = newSelection[lastSelected.current];\n if (!newSelection[correctDataIndex]) delete newSelection[correctDataIndex];\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, handleOnBl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AE,iBAAiB,eAAe,cAAc,cAAc;AACvE;",
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;AAC9B,MAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAYK;AACH,QAAM,aAAa,cAAc,CAAC,UAAU,MAAM,UAAU;AAC5D,QAAM,oBAAoB,cAAc,CAAC,UAAU,MAAM,iBAAiB;AAC1E,QAAM,eAAe,cAAc,CAAC,UAAU,MAAM,YAAY;AAChE,QAAM,YAAY,cAAc,CAAC,UAAU,MAAM,SAAS;AAC1D,QAAM,aAAa,cAAc,CAAC,UAAU,MAAM,UAAU;AAC5D,QAAM,eAAe,cAAc,CAAC,UAAU,MAAM,YAAY;AAChE,QAAM,eAAe,cAAc,CAAC,UAAU,MAAM,YAAY;AAChE,QAAM,gBAAgB,cAAc,CAAC,UAAU,MAAM,aAAa;AAClE,QAAM,EAAE,cAAc,IAAI,cAAc,CAAC,UAAU,MAAM,kBAAkB;AAC3E,QAAM,oBAAoB,iBAAiB,CAAC,UAAU,MA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BAAkB,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.16",
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.16",
43
- "@elliemae/ds-button-v2": "3.51.0-rc.16",
44
- "@elliemae/ds-circular-progress-indicator": "3.51.0-rc.16",
45
- "@elliemae/ds-drag-and-drop": "3.51.0-rc.16",
46
- "@elliemae/ds-form-checkbox": "3.51.0-rc.16",
47
- "@elliemae/ds-dropdownmenu-v2": "3.51.0-rc.16",
48
- "@elliemae/ds-dropdownmenu": "3.51.0-rc.16",
49
- "@elliemae/ds-form-date-range-picker": "3.51.0-rc.16",
50
- "@elliemae/ds-form-date-time-picker": "3.51.0-rc.16",
51
- "@elliemae/ds-form-combobox": "3.51.0-rc.16",
52
- "@elliemae/ds-form-helpers-mask-hooks": "3.51.0-rc.16",
53
- "@elliemae/ds-form-input-text": "3.51.0-rc.16",
54
- "@elliemae/ds-form-layout-blocks": "3.51.0-rc.16",
55
- "@elliemae/ds-form-radio": "3.51.0-rc.16",
56
- "@elliemae/ds-grid": "3.51.0-rc.16",
57
- "@elliemae/ds-pagination": "3.51.0-rc.16",
58
- "@elliemae/ds-icons": "3.51.0-rc.16",
59
- "@elliemae/ds-pills-v2": "3.51.0-rc.16",
60
- "@elliemae/ds-popperjs": "3.51.0-rc.16",
61
- "@elliemae/ds-skeleton": "3.51.0-rc.16",
62
- "@elliemae/ds-props-helpers": "3.51.0-rc.16",
63
- "@elliemae/ds-system": "3.51.0-rc.16",
64
- "@elliemae/ds-truncated-tooltip-text": "3.51.0-rc.16",
65
- "@elliemae/ds-typescript-helpers": "3.51.0-rc.16",
66
- "@elliemae/ds-zustand-helpers": "3.51.0-rc.16"
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.16",
74
- "@elliemae/ds-toolbar-v2": "3.51.0-rc.16"
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",