@linzjs/step-ag-grid 32.7.1 → 33.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/gridFilter/GridFilterColumnsMultiSelect.d.ts +6 -25
- package/dist/step-ag-grid.cjs +117 -186
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +117 -186
- 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/gridFilter/GridFilterColumnsMultiSelect.tsx +110 -199
- package/src/components/gridHook/useGridRangeSelection.ts +8 -6
- package/src/react-menu3/components/ControlledMenu.tsx +5 -3
- package/src/react-menu3/components/MenuList.tsx +6 -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 +42 -35
- 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 +81 -79
- 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/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(
|
|
@@ -61420,7 +61431,7 @@ const Grid = ({
|
|
|
61420
61431
|
const api = event.api;
|
|
61421
61432
|
if (sizeColumns === "fit") {
|
|
61422
61433
|
delay(() => {
|
|
61423
|
-
if (!anyUpdating() &&
|
|
61434
|
+
if (!anyUpdating() && !gridDivRef.current?.ownerDocument.querySelectorAll(".szh-menu--state-open").length) {
|
|
61424
61435
|
if (!api.isDestroyed()) {
|
|
61425
61436
|
api.redrawRows();
|
|
61426
61437
|
}
|
|
@@ -61628,22 +61639,21 @@ const Grid = ({
|
|
|
61628
61639
|
prevLoading.current = newLoading;
|
|
61629
61640
|
}, [params.loading, rowData, showNoRowsOverlay]);
|
|
61630
61641
|
const startDragYRef = useRef(null);
|
|
61631
|
-
const getGridRoot = useCallback(() => gridDivRef.current ?? document, []);
|
|
61632
61642
|
const clearHighlightRowClasses = useCallback(() => {
|
|
61633
|
-
const gridRoot =
|
|
61634
|
-
gridRoot
|
|
61643
|
+
const gridRoot = gridDivRef.current;
|
|
61644
|
+
gridRoot?.querySelectorAll(`.ag-row-highlight-above`)?.forEach((el) => {
|
|
61635
61645
|
el.classList.remove("ag-row-highlight-above");
|
|
61636
61646
|
});
|
|
61637
|
-
gridRoot
|
|
61647
|
+
gridRoot?.querySelectorAll(`.ag-row-highlight-below`)?.forEach((el) => {
|
|
61638
61648
|
el.classList.remove("ag-row-highlight-below");
|
|
61639
61649
|
});
|
|
61640
|
-
}, [
|
|
61650
|
+
}, []);
|
|
61641
61651
|
const clearDragRowClasses = useCallback(() => {
|
|
61642
|
-
const gridRoot =
|
|
61643
|
-
gridRoot
|
|
61652
|
+
const gridRoot = gridDivRef.current;
|
|
61653
|
+
gridRoot?.querySelectorAll(`.ag-row-dragging`)?.forEach((el) => {
|
|
61644
61654
|
el.classList.remove("ag-row-dragging");
|
|
61645
61655
|
});
|
|
61646
|
-
}, [
|
|
61656
|
+
}, []);
|
|
61647
61657
|
const gridElementRef = useRef(void 0);
|
|
61648
61658
|
const multiDragAppliedRef = useRef(false);
|
|
61649
61659
|
const multiDragCountRef = useRef(0);
|
|
@@ -62218,20 +62228,87 @@ const EMPTY_KEY = "__EMPTY__";
|
|
|
62218
62228
|
const DEFAULT_EMPTY_LABEL = "-";
|
|
62219
62229
|
const filterStateMap = /* @__PURE__ */ new Map();
|
|
62220
62230
|
const filterClickCountMap = /* @__PURE__ */ new Map();
|
|
62221
|
-
const
|
|
62222
|
-
|
|
62223
|
-
|
|
62224
|
-
|
|
62225
|
-
|
|
62226
|
-
|
|
62227
|
-
|
|
62228
|
-
|
|
62231
|
+
const normalizeCellValue = (value) => {
|
|
62232
|
+
if (typeof value === "string") return value.trim() === "" ? EMPTY_KEY : value;
|
|
62233
|
+
return EMPTY_KEY;
|
|
62234
|
+
};
|
|
62235
|
+
const loadFieldValues = (params) => {
|
|
62236
|
+
const field = params.colDef.field;
|
|
62237
|
+
const values = /* @__PURE__ */ new Set();
|
|
62238
|
+
params.api.forEachNode((node) => {
|
|
62239
|
+
const data = node.data ?? {};
|
|
62240
|
+
values.add(normalizeCellValue(data[field]));
|
|
62241
|
+
});
|
|
62242
|
+
const { customOrder } = params;
|
|
62243
|
+
const orderMap = customOrder?.length ? new Map(customOrder.map((val, idx) => [val, idx])) : null;
|
|
62244
|
+
return Array.from(values).sort((a, b) => {
|
|
62245
|
+
if (orderMap) {
|
|
62246
|
+
const aIdx = orderMap.get(a) ?? Infinity;
|
|
62247
|
+
const bIdx = orderMap.get(b) ?? Infinity;
|
|
62248
|
+
if (aIdx !== bIdx) return aIdx - bIdx;
|
|
62249
|
+
}
|
|
62250
|
+
if (a === EMPTY_KEY) return b === EMPTY_KEY ? 0 : -1;
|
|
62251
|
+
if (b === EMPTY_KEY) return 1;
|
|
62252
|
+
return a.localeCompare(b);
|
|
62253
|
+
});
|
|
62254
|
+
};
|
|
62255
|
+
const GridFilterColumnsMultiSelect = (props) => {
|
|
62256
|
+
const { model, onModelChange, colDef, column, labels: labelsParam, labelFormatter } = props;
|
|
62257
|
+
const containerRef = useRef(null);
|
|
62258
|
+
const allValues = useMemo(() => loadFieldValues(props), []);
|
|
62259
|
+
const labels = useMemo(
|
|
62260
|
+
() => ({ [EMPTY_KEY]: DEFAULT_EMPTY_LABEL, ...labelsParam }),
|
|
62261
|
+
[labelsParam]
|
|
62262
|
+
);
|
|
62263
|
+
const selected = useMemo(() => new Set(model?.values ?? allValues), [model, allValues]);
|
|
62264
|
+
useGridFilter$1({
|
|
62265
|
+
doesFilterPass: (p) => {
|
|
62266
|
+
if (selected.size === 0) return false;
|
|
62267
|
+
const field = colDef.field;
|
|
62268
|
+
if (!p.data || typeof p.data !== "object") return selected.has(EMPTY_KEY);
|
|
62269
|
+
const raw = p.data[field];
|
|
62270
|
+
return selected.has(normalizeCellValue(raw));
|
|
62271
|
+
}
|
|
62272
|
+
});
|
|
62273
|
+
useEffect(() => {
|
|
62274
|
+
const ownerDocument = containerRef.current?.ownerDocument;
|
|
62275
|
+
const columnId = column.getColId();
|
|
62276
|
+
const filterButton = ownerDocument?.querySelector(`[col-id="${columnId}"] .ag-header-cell-filter-button`);
|
|
62277
|
+
if (!filterButton) {
|
|
62278
|
+
return;
|
|
62279
|
+
}
|
|
62280
|
+
const listener = (e) => {
|
|
62281
|
+
const clickCount = filterClickCountMap.get(columnId) || 0;
|
|
62282
|
+
filterClickCountMap.set(columnId, clickCount + 1);
|
|
62283
|
+
if (clickCount === 0) {
|
|
62284
|
+
e.stopImmediatePropagation();
|
|
62285
|
+
e.preventDefault();
|
|
62286
|
+
props.api.hidePopupMenu();
|
|
62287
|
+
filterStateMap.set(columnId, false);
|
|
62288
|
+
return;
|
|
62289
|
+
}
|
|
62290
|
+
const isOpen = filterStateMap.get(columnId) || false;
|
|
62291
|
+
if (isOpen) {
|
|
62292
|
+
e.stopImmediatePropagation();
|
|
62293
|
+
e.preventDefault();
|
|
62294
|
+
props.api.hidePopupMenu();
|
|
62295
|
+
filterStateMap.set(columnId, false);
|
|
62296
|
+
} else {
|
|
62297
|
+
filterStateMap.set(columnId, true);
|
|
62298
|
+
}
|
|
62299
|
+
};
|
|
62300
|
+
filterButton.addEventListener("click", listener, true);
|
|
62301
|
+
return () => filterButton.removeEventListener("click", listener, true);
|
|
62302
|
+
}, [column, props.api]);
|
|
62229
62303
|
const allChecked = allValues.length > 0 && selected.size === allValues.length;
|
|
62230
62304
|
const getDisplayLabel = (raw) => {
|
|
62231
62305
|
const base = raw === EMPTY_KEY ? labels[EMPTY_KEY] ?? DEFAULT_EMPTY_LABEL : labels[raw] ?? raw;
|
|
62232
62306
|
return labelFormatter ? labelFormatter(base) : base;
|
|
62233
62307
|
};
|
|
62234
|
-
|
|
62308
|
+
const applySelection = (next) => {
|
|
62309
|
+
onModelChange(next.size === allValues.length ? null : { values: Array.from(next) });
|
|
62310
|
+
};
|
|
62311
|
+
return /* @__PURE__ */ jsxs("div", { className: "GridFilterColsMultiSelect", ref: containerRef, children: [
|
|
62235
62312
|
/* @__PURE__ */ jsx("span", { className: "LuiSelect-label-text", children: "Filter column" }),
|
|
62236
62313
|
/* @__PURE__ */ jsx(
|
|
62237
62314
|
LuiCheckboxInput,
|
|
@@ -62240,7 +62317,7 @@ const FilterUI = ({
|
|
|
62240
62317
|
label: "Select All",
|
|
62241
62318
|
value: "true",
|
|
62242
62319
|
isChecked: allChecked,
|
|
62243
|
-
onChange: (e) =>
|
|
62320
|
+
onChange: (e) => applySelection(e.target.checked ? new Set(allValues) : /* @__PURE__ */ new Set())
|
|
62244
62321
|
}
|
|
62245
62322
|
),
|
|
62246
62323
|
allValues.map((val) => /* @__PURE__ */ jsx(
|
|
@@ -62250,163 +62327,17 @@ const FilterUI = ({
|
|
|
62250
62327
|
label: getDisplayLabel(val),
|
|
62251
62328
|
value: val,
|
|
62252
62329
|
isChecked: selected.has(val),
|
|
62253
|
-
onChange: (e) =>
|
|
62330
|
+
onChange: (e) => {
|
|
62331
|
+
const next = new Set(selected);
|
|
62332
|
+
if (e.target.checked) next.add(val);
|
|
62333
|
+
else next.delete(val);
|
|
62334
|
+
applySelection(next);
|
|
62335
|
+
}
|
|
62254
62336
|
},
|
|
62255
62337
|
val
|
|
62256
62338
|
))
|
|
62257
62339
|
] });
|
|
62258
62340
|
};
|
|
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
62341
|
const createCheckboxMultiFilterParams = (labels = {}, labelFormatter, customOrder) => ({
|
|
62411
62342
|
labels: { [EMPTY_KEY]: DEFAULT_EMPTY_LABEL, ...labels },
|
|
62412
62343
|
labelFormatter,
|