@linzjs/step-ag-grid 32.7.1 → 34.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/PostSortRowsHook.test.d.ts +1 -0
- package/dist/src/components/gridFilter/GridFilterColumnsMultiSelect.d.ts +6 -25
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +2 -1
- package/dist/src/utils/__tests__/storybookTestUtil.ts +1 -1
- package/dist/step-ag-grid.cjs +190 -206
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +190 -206
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +17 -17
- package/src/components/Grid.tsx +8 -10
- package/src/components/PostSortRowsHook.test.ts +300 -0
- package/src/components/PostSortRowsHook.ts +127 -24
- package/src/components/gridFilter/GridFilterColumnsMultiSelect.tsx +110 -199
- package/src/components/gridForm/GridFormTextInput.tsx +2 -1
- package/src/components/gridHook/useGridRangeSelection.ts +8 -6
- package/src/contexts/GridContextProvider.tsx +5 -9
- package/src/react-menu3/components/ControlledMenu.tsx +5 -3
- package/src/react-menu3/components/MenuList.tsx +7 -3
- package/src/react-menu3/hooks/useItems.ts +1 -1
- package/src/stories/components/ActionButton.stories.tsx +12 -11
- package/src/stories/decorators/withOpenInPanelDecorator.tsx +35 -0
- package/src/stories/grid/GridCopy.stories.tsx +38 -35
- package/src/stories/grid/GridDragRow.stories.tsx +41 -36
- package/src/stories/grid/GridFilterButtons.stories.tsx +25 -19
- package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +42 -37
- package/src/stories/grid/GridInlineText.stories.tsx +62 -49
- package/src/stories/grid/GridNoRowsOverlay.stories.tsx +28 -23
- package/src/stories/grid/GridNonEditableRow.stories.tsx +30 -24
- package/src/stories/grid/GridPinnedRow.stories.tsx +37 -31
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +29 -24
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +89 -82
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +27 -22
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +29 -24
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +30 -25
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +29 -24
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +29 -24
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +28 -24
- package/src/stories/grid/GridReadOnly.stories.tsx +56 -52
- package/src/stories/grid/GridSorting.stories.tsx +498 -86
- package/src/stories/grid/GridViewList.stories.tsx +31 -26
- package/src/stories/grid/GridViewSelectableList.stories.tsx +31 -26
- package/src/stories/grid/gridAutosize/GridAutoSize.stories.tsx +41 -37
- package/src/stories/grid/gridAutosize/GridFitSize.stories.tsx +40 -36
- package/src/stories/grid/gridAutosize/GridFitSizeFlex.stories.tsx +40 -36
- package/src/stories/grid/gridAutosize/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +14 -6
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +74 -74
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +59 -59
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +58 -58
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +62 -62
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +118 -118
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +107 -105
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +72 -64
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +82 -73
- package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +12 -13
- package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +12 -13
- package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +11 -13
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +110 -107
- package/src/stories/react-menu/ReactMenu.stories.tsx +70 -73
- package/src/styles/GridLoadableCell.scss +1 -1
- package/src/utils/__tests__/storybookTestUtil.ts +1 -1
- package/src/utils/useSharedInterval.ts +3 -3
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -3,7 +3,6 @@ import { LuiMiniSpinner, LuiIcon, useShowLUIMessage, LuiStatusSpinner, LuiButton
|
|
|
3
3
|
import React13, { forwardRef, useContext, useRef, useState, useImperativeHandle, useLayoutEffect, useCallback, useMemo, createContext, memo, useEffect, createElement, Suspense, Component as Component$1, useReducer, cloneElement, Fragment as Fragment$1, useId } from 'react';
|
|
4
4
|
import ReactDOM, { createPortal, unstable_batchedUpdates, flushSync } from 'react-dom';
|
|
5
5
|
import { negate, isEmpty, findIndex, defer, debounce as debounce$1, compact, xorBy, last, difference, omit, delay, sortBy, partition, pick, groupBy, fromPairs, toPairs, isEqual, pull, filter, sumBy, remove, flatten, castArray } from 'lodash-es';
|
|
6
|
-
import { createRoot } from 'react-dom/client';
|
|
7
6
|
|
|
8
7
|
const ComponentLoadingWrapper = (props) => {
|
|
9
8
|
return props.loading ? /* @__PURE__ */ jsx(LuiMiniSpinner, { size: 22, divProps: { role: "status", ["aria-label"]: "Loading", style: { padding: 16 } } }) : /* @__PURE__ */ jsxs("div", { style: { pointerEvents: props.saving ? "none" : "inherit" }, className: props.className, children: [
|
|
@@ -57821,6 +57820,13 @@ var AgGridReact = class extends Component$1 {
|
|
|
57821
57820
|
return /* @__PURE__ */ React13.createElement(AgGridReactUi, { ...this.props, passGridApi: this.setGridApi });
|
|
57822
57821
|
}
|
|
57823
57822
|
};
|
|
57823
|
+
function useGridCustomComponent(methods) {
|
|
57824
|
+
const { setMethods } = useContext(CustomContext);
|
|
57825
|
+
setMethods(methods);
|
|
57826
|
+
}
|
|
57827
|
+
function useGridFilter$1(callbacks) {
|
|
57828
|
+
return useGridCustomComponent(callbacks);
|
|
57829
|
+
}
|
|
57824
57830
|
|
|
57825
57831
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
57826
57832
|
|
|
@@ -58560,7 +58566,7 @@ const useItems = (menuRef, focusRef) => {
|
|
|
58560
58566
|
const index = items.indexOf(item);
|
|
58561
58567
|
if (index > -1) {
|
|
58562
58568
|
items.splice(index, 1);
|
|
58563
|
-
if (item.contains(
|
|
58569
|
+
if (item.contains(item.ownerDocument.activeElement)) {
|
|
58564
58570
|
focusRef?.current?.focus();
|
|
58565
58571
|
setHoverItem(void 0);
|
|
58566
58572
|
}
|
|
@@ -59255,7 +59261,8 @@ const MenuList = ({
|
|
|
59255
59261
|
return;
|
|
59256
59262
|
}
|
|
59257
59263
|
if (!scrollNodes.menu) {
|
|
59258
|
-
|
|
59264
|
+
const thisWindow = containerRef.current.ownerDocument.defaultView ?? window;
|
|
59265
|
+
scrollNodes.menu = (boundingBoxRef ? boundingBoxRef.current : getScrollAncestor(rootMenuRef?.current)) || thisWindow;
|
|
59259
59266
|
}
|
|
59260
59267
|
const positionHelpers = getPositionHelpers(containerRef, menuRef, scrollNodes.menu, boundingBoxPadding);
|
|
59261
59268
|
const { menuRect } = positionHelpers;
|
|
@@ -59347,7 +59354,8 @@ const MenuList = ({
|
|
|
59347
59354
|
useEffect(() => {
|
|
59348
59355
|
let { menu: menuScroll } = scrollNodes;
|
|
59349
59356
|
if (!isOpen || !menuScroll) return;
|
|
59350
|
-
|
|
59357
|
+
const thisWindow = containerRef?.current?.ownerDocument.defaultView ?? window;
|
|
59358
|
+
menuScroll = menuScroll.addEventListener ? menuScroll : thisWindow;
|
|
59351
59359
|
if (!scrollNodes.anchors) {
|
|
59352
59360
|
scrollNodes.anchors = [];
|
|
59353
59361
|
let anchorScroll = getScrollAncestor(rootAnchorRef && rootAnchorRef.current);
|
|
@@ -59453,7 +59461,7 @@ const MenuList = ({
|
|
|
59453
59461
|
} else if (captureFocus) {
|
|
59454
59462
|
const id = setTimeout(
|
|
59455
59463
|
() => {
|
|
59456
|
-
if (menuRef.current && !menuRef.current.contains(
|
|
59464
|
+
if (menuRef.current && !menuRef.current.contains(menuRef.current.ownerDocument.activeElement)) {
|
|
59457
59465
|
const popupElement = focusRef.current?.nextSibling;
|
|
59458
59466
|
if (!focusFirstInput(popupElement)) {
|
|
59459
59467
|
focusRef.current?.focus();
|
|
@@ -59805,7 +59813,7 @@ const ControlledMenuFr = ({
|
|
|
59805
59813
|
}
|
|
59806
59814
|
};
|
|
59807
59815
|
const onBlur = (e) => {
|
|
59808
|
-
if (isMenuOpen(state) && !e.currentTarget.contains(e.relatedTarget ||
|
|
59816
|
+
if (isMenuOpen(state) && !e.currentTarget.contains(e.relatedTarget || e.currentTarget.ownerDocument.activeElement) && !isWithinMenu(e.relatedTarget)) {
|
|
59809
59817
|
safeCall(onClose, { reason: CloseReason.BLUR });
|
|
59810
59818
|
if (skipOpen) {
|
|
59811
59819
|
skipOpen.current = true;
|
|
@@ -59847,8 +59855,9 @@ const ControlledMenuFr = ({
|
|
|
59847
59855
|
}
|
|
59848
59856
|
if (portal) {
|
|
59849
59857
|
if (typeof portal === "boolean") {
|
|
59850
|
-
|
|
59851
|
-
|
|
59858
|
+
const thisDocument = containerRef.current?.ownerDocument ?? (typeof document !== "undefined" ? document : void 0);
|
|
59859
|
+
if (portal && thisDocument) {
|
|
59860
|
+
return createPortal(menuList, thisDocument.body);
|
|
59852
59861
|
}
|
|
59853
59862
|
} else {
|
|
59854
59863
|
return portal.target ? createPortal(menuList, portal.target) : portal.stablePosition ? null : menuList;
|
|
@@ -60863,13 +60872,14 @@ const useGridRangeSelection = ({
|
|
|
60863
60872
|
[rangeEndRef]
|
|
60864
60873
|
);
|
|
60865
60874
|
useEffect(() => {
|
|
60866
|
-
|
|
60867
|
-
|
|
60875
|
+
const doc = gridDivRef.current?.ownerDocument;
|
|
60876
|
+
doc?.addEventListener("mousedown", trackMouseDown, { capture: true });
|
|
60877
|
+
doc?.addEventListener("mouseup", trackMouseUp, { capture: true });
|
|
60868
60878
|
return () => {
|
|
60869
|
-
|
|
60870
|
-
|
|
60879
|
+
doc?.removeEventListener("mousemove", trackMouseDown, { capture: true });
|
|
60880
|
+
doc?.removeEventListener("mouseup", trackMouseUp, { capture: true });
|
|
60871
60881
|
};
|
|
60872
|
-
}, [trackMouseDown, trackMouseUp]);
|
|
60882
|
+
}, [trackMouseDown, trackMouseUp, gridDivRef]);
|
|
60873
60883
|
const onCellMouseOver = useCallback(
|
|
60874
60884
|
(e, mouseDown) => {
|
|
60875
60885
|
if (!enableRangeSelection) {
|
|
@@ -60894,7 +60904,7 @@ const useGridRangeSelection = ({
|
|
|
60894
60904
|
if (rangeStartRef.current && rangeEndRef.current && (rangeStartRef.current.rowId !== rangeEndRef.current.rowId || rangeStartRef.current.colId !== rangeEndRef.current.colId)) {
|
|
60895
60905
|
e.api.stopEditing();
|
|
60896
60906
|
hasSelectedMoreThanOneCellRef.current = true;
|
|
60897
|
-
|
|
60907
|
+
gridDivRef.current?.ownerDocument.defaultView?.getSelection()?.removeAllRanges();
|
|
60898
60908
|
}
|
|
60899
60909
|
updateRangeSelectionCellClasses();
|
|
60900
60910
|
},
|
|
@@ -60904,7 +60914,8 @@ const useGridRangeSelection = ({
|
|
|
60904
60914
|
hasSelectedMoreThanOneCellRef,
|
|
60905
60915
|
rangeEndRef,
|
|
60906
60916
|
rangeSortedNodesRef,
|
|
60907
|
-
rangeStartRef
|
|
60917
|
+
rangeStartRef,
|
|
60918
|
+
gridDivRef
|
|
60908
60919
|
]
|
|
60909
60920
|
);
|
|
60910
60921
|
const onCellMouseDown = useCallback(
|
|
@@ -60966,18 +60977,51 @@ const usePostSortRowsHook = ({ setStaleGrid }) => {
|
|
|
60966
60977
|
const previousQuickFilter = useRef("");
|
|
60967
60978
|
return useCallback(
|
|
60968
60979
|
({ api, nodes }) => {
|
|
60969
|
-
if (!api)
|
|
60980
|
+
if (!api || api.isDestroyed()) {
|
|
60981
|
+
return;
|
|
60982
|
+
}
|
|
60970
60983
|
const previousRowSortIndex = previousRowSortIndexRef.current;
|
|
60971
|
-
const
|
|
60972
|
-
return
|
|
60984
|
+
const copyCurrentSortSettings = () => {
|
|
60985
|
+
return api.getColumnState().map((row) => ({ colId: row.colId, sort: row.sort, sortIndex: row.sortIndex }));
|
|
60973
60986
|
};
|
|
60974
|
-
const
|
|
60987
|
+
const currentSortState = copyCurrentSortSettings();
|
|
60988
|
+
const sortedColIds = currentSortState.filter((col) => col.sort).sort((a, b) => (a.sortIndex ?? 0) - (b.sortIndex ?? 0)).map((col) => col.colId);
|
|
60989
|
+
const sortColumnEquals = {};
|
|
60990
|
+
sortedColIds.forEach((colId) => {
|
|
60991
|
+
const colDef = api.getColumn(colId)?.getColDef();
|
|
60992
|
+
if (colDef?.equals) {
|
|
60993
|
+
const equals = colDef.equals;
|
|
60994
|
+
sortColumnEquals[colId] = (a, b) => equals(a, b);
|
|
60995
|
+
} else if (colDef?.comparator) {
|
|
60996
|
+
const comparator = colDef.comparator;
|
|
60997
|
+
sortColumnEquals[colId] = (a, b, nodeA, nodeB) => comparator(a, b, nodeA, nodeB, false) === 0;
|
|
60998
|
+
} else {
|
|
60999
|
+
sortColumnEquals[colId] = (a, b) => a === b;
|
|
61000
|
+
}
|
|
61001
|
+
});
|
|
61002
|
+
const getSortValues = (node) => node ? sortedColIds.map((colId) => api.getCellValue({ rowNode: node, colKey: colId })) : [];
|
|
61003
|
+
const snapshotNode = (node) => node ? { data: node.data, id: node.id } : void 0;
|
|
61004
|
+
const sortValuesChanged = (previous, node, currentValues) => !previous || sortedColIds.some(
|
|
61005
|
+
(colId, i) => !sortColumnEquals[colId](previous.values[i], currentValues[i], previous.node, node)
|
|
61006
|
+
);
|
|
60975
61007
|
const backupSortOrder = () => {
|
|
60976
|
-
for (const x in previousRowSortIndex)
|
|
60977
|
-
|
|
61008
|
+
for (const x in previousRowSortIndex) {
|
|
61009
|
+
delete previousRowSortIndex[x];
|
|
61010
|
+
}
|
|
61011
|
+
nodes.forEach(
|
|
61012
|
+
(node, index) => previousRowSortIndex[`${node.data.id}`] = {
|
|
61013
|
+
index,
|
|
61014
|
+
values: getSortValues(node),
|
|
61015
|
+
node: snapshotNode(node)
|
|
61016
|
+
}
|
|
61017
|
+
);
|
|
61018
|
+
};
|
|
61019
|
+
const isFirstSortColumn = (row) => {
|
|
61020
|
+
return row.sort && [0, null].includes(row.sortIndex ?? null);
|
|
61021
|
+
};
|
|
61022
|
+
const isSameColumnAndDifferentSort = (col1, col2) => {
|
|
61023
|
+
return col1 && col2 && col1.colId === col2.colId && col1.sort != col2.sort;
|
|
60978
61024
|
};
|
|
60979
|
-
const isFirstSortColumn = (row) => row.sort && [0, null].includes(row.sortIndex ?? null);
|
|
60980
|
-
const isSameColumnAndDifferentSort = (col1, col2) => col1 && col2 && col1.colId === col2.colId && col1.sort != col2.sort;
|
|
60981
61025
|
const restorePreviousSortColumnState = () => api.applyColumnState({ state: previousColSort.current });
|
|
60982
61026
|
const sortNodesByPreviousSort = () => {
|
|
60983
61027
|
nodes.sort(
|
|
@@ -60988,25 +61032,27 @@ const usePostSortRowsHook = ({ setStaleGrid }) => {
|
|
|
60988
61032
|
initialised.current = true;
|
|
60989
61033
|
previousColSort.current = copyCurrentSortSettings();
|
|
60990
61034
|
}
|
|
60991
|
-
const newSortOrder = JSON.stringify(
|
|
61035
|
+
const newSortOrder = JSON.stringify(currentSortState);
|
|
60992
61036
|
let sortOrderChanged = newSortOrder != lastSortOrderHash.current;
|
|
60993
|
-
const quickFilter = api.getQuickFilter();
|
|
61037
|
+
const quickFilter = api.getQuickFilter() ?? "";
|
|
60994
61038
|
if (previousQuickFilter.current != quickFilter) {
|
|
60995
|
-
previousQuickFilter.current = quickFilter
|
|
61039
|
+
previousQuickFilter.current = quickFilter;
|
|
60996
61040
|
sortOrderChanged = true;
|
|
60997
61041
|
}
|
|
60998
61042
|
if (isEmpty(previousRowSortIndex)) {
|
|
60999
61043
|
backupSortOrder();
|
|
61000
61044
|
}
|
|
61001
61045
|
if (sortOrderChanged) {
|
|
61002
|
-
const thisFirstCol =
|
|
61046
|
+
const thisFirstCol = currentSortState.find(isFirstSortColumn);
|
|
61003
61047
|
const previousFirstCol = previousColSort.current.find(isFirstSortColumn);
|
|
61004
61048
|
const wasSortChangedOnSameColumn = previousFirstCol && (!thisFirstCol || isSameColumnAndDifferentSort(previousFirstCol, thisFirstCol));
|
|
61005
61049
|
if (sortWasStale.current && wasSortChangedOnSameColumn) {
|
|
61006
61050
|
sortWasStale.current = false;
|
|
61007
61051
|
setStaleGrid(false);
|
|
61008
61052
|
lastSortOrderHash.current = "";
|
|
61009
|
-
|
|
61053
|
+
defer(() => {
|
|
61054
|
+
restorePreviousSortColumnState();
|
|
61055
|
+
});
|
|
61010
61056
|
} else {
|
|
61011
61057
|
if (sortWasStale.current) {
|
|
61012
61058
|
sortWasStale.current = false;
|
|
@@ -61024,7 +61070,7 @@ const usePostSortRowsHook = ({ setStaleGrid }) => {
|
|
|
61024
61070
|
for (const node of nodes) {
|
|
61025
61071
|
const psr = previousRowSortIndex[`${node.data.id}`];
|
|
61026
61072
|
if (psr) {
|
|
61027
|
-
if (psr
|
|
61073
|
+
if (sortValuesChanged(psr, node, getSortValues(node))) {
|
|
61028
61074
|
if (firstChangedNodeIndex === -1) firstChangedNodeIndex = index;
|
|
61029
61075
|
changedRowCount++;
|
|
61030
61076
|
}
|
|
@@ -61037,7 +61083,11 @@ const usePostSortRowsHook = ({ setStaleGrid }) => {
|
|
|
61037
61083
|
let wasStale = false;
|
|
61038
61084
|
if (changedRowCount === 0 && newRowCount === 1) {
|
|
61039
61085
|
const newIndex = index - 1;
|
|
61040
|
-
previousRowSortIndex[`${lastNewNode?.data.id}`] = {
|
|
61086
|
+
previousRowSortIndex[`${lastNewNode?.data.id}`] = {
|
|
61087
|
+
index: newIndex,
|
|
61088
|
+
values: getSortValues(lastNewNode),
|
|
61089
|
+
node: snapshotNode(lastNewNode)
|
|
61090
|
+
};
|
|
61041
61091
|
wasStale = true;
|
|
61042
61092
|
} else if (changedRowCount === 2 && newRowCount === 0) {
|
|
61043
61093
|
backupSortOrder();
|
|
@@ -61045,15 +61095,27 @@ const usePostSortRowsHook = ({ setStaleGrid }) => {
|
|
|
61045
61095
|
} else if (changedRowCount > 1 && newRowCount === 1) {
|
|
61046
61096
|
previousRowSortIndex[`${lastNewNode?.data.id}`] = {
|
|
61047
61097
|
index: firstChangedNodeIndex + 0.5,
|
|
61048
|
-
|
|
61098
|
+
values: getSortValues(lastNewNode),
|
|
61099
|
+
node: snapshotNode(lastNewNode)
|
|
61049
61100
|
};
|
|
61050
61101
|
wasStale = true;
|
|
61051
61102
|
if (lastNewNode) {
|
|
61052
61103
|
redrawRows();
|
|
61053
61104
|
}
|
|
61054
61105
|
} else if (changedRowCount == 1 && newRowCount === 0) {
|
|
61106
|
+
const changedNode = nodes[firstChangedNodeIndex];
|
|
61107
|
+
const previousEntry = changedNode && previousRowSortIndex[`${changedNode.data.id}`];
|
|
61108
|
+
if (changedNode && previousEntry) {
|
|
61109
|
+
previousRowSortIndex[`${changedNode.data.id}`] = {
|
|
61110
|
+
index: previousEntry.index,
|
|
61111
|
+
values: getSortValues(changedNode),
|
|
61112
|
+
node: snapshotNode(changedNode)
|
|
61113
|
+
};
|
|
61114
|
+
}
|
|
61055
61115
|
wasStale = true;
|
|
61056
|
-
} else if (changedRowCount
|
|
61116
|
+
} else if (changedRowCount === 0 && newRowCount === 0 && nodes.length === Object.keys(previousRowSortIndex).length) {
|
|
61117
|
+
wasStale = true;
|
|
61118
|
+
} else {
|
|
61057
61119
|
backupSortOrder();
|
|
61058
61120
|
}
|
|
61059
61121
|
if (wasStale) {
|
|
@@ -61420,7 +61482,7 @@ const Grid = ({
|
|
|
61420
61482
|
const api = event.api;
|
|
61421
61483
|
if (sizeColumns === "fit") {
|
|
61422
61484
|
delay(() => {
|
|
61423
|
-
if (!anyUpdating() &&
|
|
61485
|
+
if (!anyUpdating() && !gridDivRef.current?.ownerDocument.querySelectorAll(".szh-menu--state-open").length) {
|
|
61424
61486
|
if (!api.isDestroyed()) {
|
|
61425
61487
|
api.redrawRows();
|
|
61426
61488
|
}
|
|
@@ -61628,22 +61690,21 @@ const Grid = ({
|
|
|
61628
61690
|
prevLoading.current = newLoading;
|
|
61629
61691
|
}, [params.loading, rowData, showNoRowsOverlay]);
|
|
61630
61692
|
const startDragYRef = useRef(null);
|
|
61631
|
-
const getGridRoot = useCallback(() => gridDivRef.current ?? document, []);
|
|
61632
61693
|
const clearHighlightRowClasses = useCallback(() => {
|
|
61633
|
-
const gridRoot =
|
|
61634
|
-
gridRoot
|
|
61694
|
+
const gridRoot = gridDivRef.current;
|
|
61695
|
+
gridRoot?.querySelectorAll(`.ag-row-highlight-above`)?.forEach((el) => {
|
|
61635
61696
|
el.classList.remove("ag-row-highlight-above");
|
|
61636
61697
|
});
|
|
61637
|
-
gridRoot
|
|
61698
|
+
gridRoot?.querySelectorAll(`.ag-row-highlight-below`)?.forEach((el) => {
|
|
61638
61699
|
el.classList.remove("ag-row-highlight-below");
|
|
61639
61700
|
});
|
|
61640
|
-
}, [
|
|
61701
|
+
}, []);
|
|
61641
61702
|
const clearDragRowClasses = useCallback(() => {
|
|
61642
|
-
const gridRoot =
|
|
61643
|
-
gridRoot
|
|
61703
|
+
const gridRoot = gridDivRef.current;
|
|
61704
|
+
gridRoot?.querySelectorAll(`.ag-row-dragging`)?.forEach((el) => {
|
|
61644
61705
|
el.classList.remove("ag-row-dragging");
|
|
61645
61706
|
});
|
|
61646
|
-
}, [
|
|
61707
|
+
}, []);
|
|
61647
61708
|
const gridElementRef = useRef(void 0);
|
|
61648
61709
|
const multiDragAppliedRef = useRef(false);
|
|
61649
61710
|
const multiDragCountRef = useRef(0);
|
|
@@ -62218,20 +62279,87 @@ const EMPTY_KEY = "__EMPTY__";
|
|
|
62218
62279
|
const DEFAULT_EMPTY_LABEL = "-";
|
|
62219
62280
|
const filterStateMap = /* @__PURE__ */ new Map();
|
|
62220
62281
|
const filterClickCountMap = /* @__PURE__ */ new Map();
|
|
62221
|
-
const
|
|
62222
|
-
|
|
62223
|
-
|
|
62224
|
-
|
|
62225
|
-
|
|
62226
|
-
|
|
62227
|
-
|
|
62228
|
-
|
|
62282
|
+
const normalizeCellValue = (value) => {
|
|
62283
|
+
if (typeof value === "string") return value.trim() === "" ? EMPTY_KEY : value;
|
|
62284
|
+
return EMPTY_KEY;
|
|
62285
|
+
};
|
|
62286
|
+
const loadFieldValues = (params) => {
|
|
62287
|
+
const field = params.colDef.field;
|
|
62288
|
+
const values = /* @__PURE__ */ new Set();
|
|
62289
|
+
params.api.forEachNode((node) => {
|
|
62290
|
+
const data = node.data ?? {};
|
|
62291
|
+
values.add(normalizeCellValue(data[field]));
|
|
62292
|
+
});
|
|
62293
|
+
const { customOrder } = params;
|
|
62294
|
+
const orderMap = customOrder?.length ? new Map(customOrder.map((val, idx) => [val, idx])) : null;
|
|
62295
|
+
return Array.from(values).sort((a, b) => {
|
|
62296
|
+
if (orderMap) {
|
|
62297
|
+
const aIdx = orderMap.get(a) ?? Infinity;
|
|
62298
|
+
const bIdx = orderMap.get(b) ?? Infinity;
|
|
62299
|
+
if (aIdx !== bIdx) return aIdx - bIdx;
|
|
62300
|
+
}
|
|
62301
|
+
if (a === EMPTY_KEY) return b === EMPTY_KEY ? 0 : -1;
|
|
62302
|
+
if (b === EMPTY_KEY) return 1;
|
|
62303
|
+
return a.localeCompare(b);
|
|
62304
|
+
});
|
|
62305
|
+
};
|
|
62306
|
+
const GridFilterColumnsMultiSelect = (props) => {
|
|
62307
|
+
const { model, onModelChange, colDef, column, labels: labelsParam, labelFormatter } = props;
|
|
62308
|
+
const containerRef = useRef(null);
|
|
62309
|
+
const allValues = useMemo(() => loadFieldValues(props), []);
|
|
62310
|
+
const labels = useMemo(
|
|
62311
|
+
() => ({ [EMPTY_KEY]: DEFAULT_EMPTY_LABEL, ...labelsParam }),
|
|
62312
|
+
[labelsParam]
|
|
62313
|
+
);
|
|
62314
|
+
const selected = useMemo(() => new Set(model?.values ?? allValues), [model, allValues]);
|
|
62315
|
+
useGridFilter$1({
|
|
62316
|
+
doesFilterPass: (p) => {
|
|
62317
|
+
if (selected.size === 0) return false;
|
|
62318
|
+
const field = colDef.field;
|
|
62319
|
+
if (!p.data || typeof p.data !== "object") return selected.has(EMPTY_KEY);
|
|
62320
|
+
const raw = p.data[field];
|
|
62321
|
+
return selected.has(normalizeCellValue(raw));
|
|
62322
|
+
}
|
|
62323
|
+
});
|
|
62324
|
+
useEffect(() => {
|
|
62325
|
+
const ownerDocument = containerRef.current?.ownerDocument;
|
|
62326
|
+
const columnId = column.getColId();
|
|
62327
|
+
const filterButton = ownerDocument?.querySelector(`[col-id="${columnId}"] .ag-header-cell-filter-button`);
|
|
62328
|
+
if (!filterButton) {
|
|
62329
|
+
return;
|
|
62330
|
+
}
|
|
62331
|
+
const listener = (e) => {
|
|
62332
|
+
const clickCount = filterClickCountMap.get(columnId) || 0;
|
|
62333
|
+
filterClickCountMap.set(columnId, clickCount + 1);
|
|
62334
|
+
if (clickCount === 0) {
|
|
62335
|
+
e.stopImmediatePropagation();
|
|
62336
|
+
e.preventDefault();
|
|
62337
|
+
props.api.hidePopupMenu();
|
|
62338
|
+
filterStateMap.set(columnId, false);
|
|
62339
|
+
return;
|
|
62340
|
+
}
|
|
62341
|
+
const isOpen = filterStateMap.get(columnId) || false;
|
|
62342
|
+
if (isOpen) {
|
|
62343
|
+
e.stopImmediatePropagation();
|
|
62344
|
+
e.preventDefault();
|
|
62345
|
+
props.api.hidePopupMenu();
|
|
62346
|
+
filterStateMap.set(columnId, false);
|
|
62347
|
+
} else {
|
|
62348
|
+
filterStateMap.set(columnId, true);
|
|
62349
|
+
}
|
|
62350
|
+
};
|
|
62351
|
+
filterButton.addEventListener("click", listener, true);
|
|
62352
|
+
return () => filterButton.removeEventListener("click", listener, true);
|
|
62353
|
+
}, [column, props.api]);
|
|
62229
62354
|
const allChecked = allValues.length > 0 && selected.size === allValues.length;
|
|
62230
62355
|
const getDisplayLabel = (raw) => {
|
|
62231
62356
|
const base = raw === EMPTY_KEY ? labels[EMPTY_KEY] ?? DEFAULT_EMPTY_LABEL : labels[raw] ?? raw;
|
|
62232
62357
|
return labelFormatter ? labelFormatter(base) : base;
|
|
62233
62358
|
};
|
|
62234
|
-
|
|
62359
|
+
const applySelection = (next) => {
|
|
62360
|
+
onModelChange(next.size === allValues.length ? null : { values: Array.from(next) });
|
|
62361
|
+
};
|
|
62362
|
+
return /* @__PURE__ */ jsxs("div", { className: "GridFilterColsMultiSelect", ref: containerRef, children: [
|
|
62235
62363
|
/* @__PURE__ */ jsx("span", { className: "LuiSelect-label-text", children: "Filter column" }),
|
|
62236
62364
|
/* @__PURE__ */ jsx(
|
|
62237
62365
|
LuiCheckboxInput,
|
|
@@ -62240,7 +62368,7 @@ const FilterUI = ({
|
|
|
62240
62368
|
label: "Select All",
|
|
62241
62369
|
value: "true",
|
|
62242
62370
|
isChecked: allChecked,
|
|
62243
|
-
onChange: (e) =>
|
|
62371
|
+
onChange: (e) => applySelection(e.target.checked ? new Set(allValues) : /* @__PURE__ */ new Set())
|
|
62244
62372
|
}
|
|
62245
62373
|
),
|
|
62246
62374
|
allValues.map((val) => /* @__PURE__ */ jsx(
|
|
@@ -62250,163 +62378,17 @@ const FilterUI = ({
|
|
|
62250
62378
|
label: getDisplayLabel(val),
|
|
62251
62379
|
value: val,
|
|
62252
62380
|
isChecked: selected.has(val),
|
|
62253
|
-
onChange: (e) =>
|
|
62381
|
+
onChange: (e) => {
|
|
62382
|
+
const next = new Set(selected);
|
|
62383
|
+
if (e.target.checked) next.add(val);
|
|
62384
|
+
else next.delete(val);
|
|
62385
|
+
applySelection(next);
|
|
62386
|
+
}
|
|
62254
62387
|
},
|
|
62255
62388
|
val
|
|
62256
62389
|
))
|
|
62257
62390
|
] });
|
|
62258
62391
|
};
|
|
62259
|
-
class GridFilterColumnsMultiSelect {
|
|
62260
|
-
params;
|
|
62261
|
-
selectedValues = /* @__PURE__ */ new Set();
|
|
62262
|
-
labels = {};
|
|
62263
|
-
allValues = [];
|
|
62264
|
-
gui;
|
|
62265
|
-
labelFormatter;
|
|
62266
|
-
reactRoot = null;
|
|
62267
|
-
filterButtonClickListener = null;
|
|
62268
|
-
filterButton = null;
|
|
62269
|
-
normalizeCellValue(value) {
|
|
62270
|
-
if (typeof value === "string") return value.trim() === "" ? EMPTY_KEY : value;
|
|
62271
|
-
return EMPTY_KEY;
|
|
62272
|
-
}
|
|
62273
|
-
loadFieldValues() {
|
|
62274
|
-
const field = this.params.colDef.field;
|
|
62275
|
-
const values = /* @__PURE__ */ new Set();
|
|
62276
|
-
this.params.api.forEachNode((node) => {
|
|
62277
|
-
const data = node.data ?? {};
|
|
62278
|
-
const raw = data[field];
|
|
62279
|
-
const norm = this.normalizeCellValue(raw);
|
|
62280
|
-
values.add(norm);
|
|
62281
|
-
});
|
|
62282
|
-
const { customOrder } = this.params;
|
|
62283
|
-
const orderMap = customOrder?.length ? new Map(customOrder.map((val, idx) => [val, idx])) : null;
|
|
62284
|
-
return Array.from(values).sort((a, b) => {
|
|
62285
|
-
if (orderMap) {
|
|
62286
|
-
const aIdx = orderMap.get(a) ?? Infinity;
|
|
62287
|
-
const bIdx = orderMap.get(b) ?? Infinity;
|
|
62288
|
-
if (aIdx !== bIdx) return aIdx - bIdx;
|
|
62289
|
-
}
|
|
62290
|
-
if (a === EMPTY_KEY) return b === EMPTY_KEY ? 0 : -1;
|
|
62291
|
-
if (b === EMPTY_KEY) return 1;
|
|
62292
|
-
return a.localeCompare(b);
|
|
62293
|
-
});
|
|
62294
|
-
}
|
|
62295
|
-
init(params) {
|
|
62296
|
-
this.params = params;
|
|
62297
|
-
this.labels = { ...params.labels };
|
|
62298
|
-
this.labelFormatter = params.labelFormatter;
|
|
62299
|
-
if (!(EMPTY_KEY in this.labels)) {
|
|
62300
|
-
this.labels[EMPTY_KEY] = DEFAULT_EMPTY_LABEL;
|
|
62301
|
-
}
|
|
62302
|
-
this.allValues = this.loadFieldValues();
|
|
62303
|
-
this.selectedValues = new Set(this.allValues);
|
|
62304
|
-
this.gui = document.createElement("div");
|
|
62305
|
-
this.reactRoot = createRoot(this.gui);
|
|
62306
|
-
this.render();
|
|
62307
|
-
this.setupFilterButtonListener();
|
|
62308
|
-
}
|
|
62309
|
-
setupFilterButtonListener() {
|
|
62310
|
-
const columnId = this.params.column.getColId();
|
|
62311
|
-
this.filterButton = document.querySelector(`[col-id="${columnId}"] .ag-header-cell-filter-button`);
|
|
62312
|
-
if (this.filterButton) {
|
|
62313
|
-
this.filterButtonClickListener = (e) => {
|
|
62314
|
-
const clickCount = filterClickCountMap.get(columnId) || 0;
|
|
62315
|
-
filterClickCountMap.set(columnId, clickCount + 1);
|
|
62316
|
-
if (clickCount === 0) {
|
|
62317
|
-
e.stopImmediatePropagation();
|
|
62318
|
-
e.preventDefault();
|
|
62319
|
-
this.params.api.hidePopupMenu();
|
|
62320
|
-
filterStateMap.set(columnId, false);
|
|
62321
|
-
return;
|
|
62322
|
-
}
|
|
62323
|
-
const isOpen = filterStateMap.get(columnId) || false;
|
|
62324
|
-
if (isOpen) {
|
|
62325
|
-
e.stopImmediatePropagation();
|
|
62326
|
-
e.preventDefault();
|
|
62327
|
-
this.params.api.hidePopupMenu();
|
|
62328
|
-
filterStateMap.set(columnId, false);
|
|
62329
|
-
} else {
|
|
62330
|
-
filterStateMap.set(columnId, true);
|
|
62331
|
-
}
|
|
62332
|
-
};
|
|
62333
|
-
this.filterButton.addEventListener("click", this.filterButtonClickListener, true);
|
|
62334
|
-
}
|
|
62335
|
-
}
|
|
62336
|
-
render() {
|
|
62337
|
-
if (!this.reactRoot) return;
|
|
62338
|
-
this.reactRoot.render(
|
|
62339
|
-
/* @__PURE__ */ jsx(
|
|
62340
|
-
FilterUI,
|
|
62341
|
-
{
|
|
62342
|
-
allValues: this.allValues,
|
|
62343
|
-
selected: this.selectedValues,
|
|
62344
|
-
labels: this.labels,
|
|
62345
|
-
labelFormatter: this.labelFormatter,
|
|
62346
|
-
onToggleAll: this.handleToggleAll.bind(this),
|
|
62347
|
-
onToggleOne: this.handleToggleOne.bind(this)
|
|
62348
|
-
}
|
|
62349
|
-
)
|
|
62350
|
-
);
|
|
62351
|
-
}
|
|
62352
|
-
handleToggleAll(checked) {
|
|
62353
|
-
if (checked) {
|
|
62354
|
-
this.allValues.forEach((val) => this.selectedValues.add(val));
|
|
62355
|
-
} else {
|
|
62356
|
-
this.selectedValues.clear();
|
|
62357
|
-
}
|
|
62358
|
-
this.render();
|
|
62359
|
-
this.params.filterChangedCallback();
|
|
62360
|
-
}
|
|
62361
|
-
handleToggleOne(value, checked) {
|
|
62362
|
-
if (checked) {
|
|
62363
|
-
this.selectedValues.add(value);
|
|
62364
|
-
} else {
|
|
62365
|
-
this.selectedValues.delete(value);
|
|
62366
|
-
}
|
|
62367
|
-
this.render();
|
|
62368
|
-
this.params.filterChangedCallback();
|
|
62369
|
-
}
|
|
62370
|
-
getGui() {
|
|
62371
|
-
return this.gui;
|
|
62372
|
-
}
|
|
62373
|
-
isFilterActive() {
|
|
62374
|
-
return this.selectedValues.size !== this.allValues.length;
|
|
62375
|
-
}
|
|
62376
|
-
doesFilterPass(p) {
|
|
62377
|
-
if (this.selectedValues.size === 0) {
|
|
62378
|
-
return false;
|
|
62379
|
-
}
|
|
62380
|
-
const field = this.params.colDef.field;
|
|
62381
|
-
if (!p.data || typeof p.data !== "object") {
|
|
62382
|
-
return this.selectedValues.has(EMPTY_KEY);
|
|
62383
|
-
}
|
|
62384
|
-
const raw = p.data[field];
|
|
62385
|
-
const norm = this.normalizeCellValue(raw);
|
|
62386
|
-
return this.selectedValues.has(norm);
|
|
62387
|
-
}
|
|
62388
|
-
getModel() {
|
|
62389
|
-
if (this.selectedValues.size !== this.allValues.length) {
|
|
62390
|
-
return { values: Array.from(this.selectedValues) };
|
|
62391
|
-
}
|
|
62392
|
-
return null;
|
|
62393
|
-
}
|
|
62394
|
-
setModel(model) {
|
|
62395
|
-
this.selectedValues = new Set(model?.values || []);
|
|
62396
|
-
this.render();
|
|
62397
|
-
}
|
|
62398
|
-
destroy() {
|
|
62399
|
-
if (this.filterButtonClickListener && this.filterButton) {
|
|
62400
|
-
this.filterButton.removeEventListener("click", this.filterButtonClickListener, true);
|
|
62401
|
-
this.filterButtonClickListener = null;
|
|
62402
|
-
this.filterButton = null;
|
|
62403
|
-
}
|
|
62404
|
-
if (this.reactRoot) {
|
|
62405
|
-
this.reactRoot.unmount();
|
|
62406
|
-
this.reactRoot = null;
|
|
62407
|
-
}
|
|
62408
|
-
}
|
|
62409
|
-
}
|
|
62410
62392
|
const createCheckboxMultiFilterParams = (labels = {}, labelFormatter, customOrder) => ({
|
|
62411
62393
|
labels: { [EMPTY_KEY]: DEFAULT_EMPTY_LABEL, ...labels },
|
|
62412
62394
|
labelFormatter,
|
|
@@ -65186,9 +65168,11 @@ const GridContextProvider = (props) => {
|
|
|
65186
65168
|
return ok;
|
|
65187
65169
|
}
|
|
65188
65170
|
if (ok) {
|
|
65189
|
-
|
|
65190
|
-
gridApi2.
|
|
65191
|
-
|
|
65171
|
+
defer(() => {
|
|
65172
|
+
if (!gridApi2.isDestroyed()) {
|
|
65173
|
+
gridApi2.refreshClientSideRowModel();
|
|
65174
|
+
}
|
|
65175
|
+
});
|
|
65192
65176
|
}
|
|
65193
65177
|
void (async () => {
|
|
65194
65178
|
const postPopupFocusedCell = gridApi2.getFocusedCell();
|