@linzjs/step-ag-grid 32.7.0 → 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 +115 -181
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +115 -181
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +17 -17
- package/src/components/Grid.tsx +6 -4
- 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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import './GridFilterColumnsMultiSelect.scss';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IFilterParams } from 'ag-grid-community';
|
|
3
|
+
import { CustomFilterProps } from 'ag-grid-react';
|
|
4
|
+
import React from 'react';
|
|
3
5
|
export interface CheckboxMultiFilterParams extends IFilterParams {
|
|
4
6
|
labels?: Record<string, string>;
|
|
5
7
|
labelFormatter?: (value: string) => string;
|
|
@@ -8,28 +10,7 @@ export interface CheckboxMultiFilterParams extends IFilterParams {
|
|
|
8
10
|
export interface CheckboxMultiFilterModel {
|
|
9
11
|
values: string[];
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private selectedValues;
|
|
14
|
-
private labels;
|
|
15
|
-
private allValues;
|
|
16
|
-
private gui;
|
|
17
|
-
private labelFormatter?;
|
|
18
|
-
private reactRoot;
|
|
19
|
-
private filterButtonClickListener;
|
|
20
|
-
private filterButton;
|
|
21
|
-
private normalizeCellValue;
|
|
22
|
-
private loadFieldValues;
|
|
23
|
-
init(params: CheckboxMultiFilterParams): void;
|
|
24
|
-
private setupFilterButtonListener;
|
|
25
|
-
private render;
|
|
26
|
-
private handleToggleAll;
|
|
27
|
-
private handleToggleOne;
|
|
28
|
-
getGui(): HTMLElement;
|
|
29
|
-
isFilterActive(): boolean;
|
|
30
|
-
doesFilterPass(p: IDoesFilterPassParams): boolean;
|
|
31
|
-
getModel(): CheckboxMultiFilterModel | null;
|
|
32
|
-
setModel(model: CheckboxMultiFilterModel | null): void;
|
|
33
|
-
destroy(): void;
|
|
34
|
-
}
|
|
13
|
+
type GridFilterColumnsMultiSelectProps = CustomFilterProps<any, any, CheckboxMultiFilterModel> & CheckboxMultiFilterParams;
|
|
14
|
+
export declare const GridFilterColumnsMultiSelect: (props: GridFilterColumnsMultiSelectProps) => React.JSX.Element;
|
|
35
15
|
export declare const createCheckboxMultiFilterParams: (labels?: Record<string, string>, labelFormatter?: (value: string) => string, customOrder?: string[]) => Partial<CheckboxMultiFilterParams>;
|
|
16
|
+
export {};
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -5,7 +5,6 @@ var lui = require('@linzjs/lui');
|
|
|
5
5
|
var React13 = require('react');
|
|
6
6
|
var ReactDOM = require('react-dom');
|
|
7
7
|
var lodashEs = require('lodash-es');
|
|
8
|
-
var client = require('react-dom/client');
|
|
9
8
|
|
|
10
9
|
const ComponentLoadingWrapper = (props) => {
|
|
11
10
|
return props.loading ? /* @__PURE__ */ jsxRuntime.jsx(lui.LuiMiniSpinner, { size: 22, divProps: { role: "status", ["aria-label"]: "Loading", style: { padding: 16 } } }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { pointerEvents: props.saving ? "none" : "inherit" }, className: props.className, children: [
|
|
@@ -57823,6 +57822,13 @@ var AgGridReact = class extends React13.Component {
|
|
|
57823
57822
|
return /* @__PURE__ */ React13.createElement(AgGridReactUi, { ...this.props, passGridApi: this.setGridApi });
|
|
57824
57823
|
}
|
|
57825
57824
|
};
|
|
57825
|
+
function useGridCustomComponent(methods) {
|
|
57826
|
+
const { setMethods } = React13.useContext(CustomContext);
|
|
57827
|
+
setMethods(methods);
|
|
57828
|
+
}
|
|
57829
|
+
function useGridFilter$1(callbacks) {
|
|
57830
|
+
return useGridCustomComponent(callbacks);
|
|
57831
|
+
}
|
|
57826
57832
|
|
|
57827
57833
|
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}
|
|
57828
57834
|
|
|
@@ -58562,7 +58568,7 @@ const useItems = (menuRef, focusRef) => {
|
|
|
58562
58568
|
const index = items.indexOf(item);
|
|
58563
58569
|
if (index > -1) {
|
|
58564
58570
|
items.splice(index, 1);
|
|
58565
|
-
if (item.contains(
|
|
58571
|
+
if (item.contains(item.ownerDocument.activeElement)) {
|
|
58566
58572
|
focusRef?.current?.focus();
|
|
58567
58573
|
setHoverItem(void 0);
|
|
58568
58574
|
}
|
|
@@ -59257,7 +59263,8 @@ const MenuList = ({
|
|
|
59257
59263
|
return;
|
|
59258
59264
|
}
|
|
59259
59265
|
if (!scrollNodes.menu) {
|
|
59260
|
-
|
|
59266
|
+
const thisWindow = containerRef.current.ownerDocument.defaultView ?? window;
|
|
59267
|
+
scrollNodes.menu = (boundingBoxRef ? boundingBoxRef.current : getScrollAncestor(rootMenuRef?.current)) || thisWindow;
|
|
59261
59268
|
}
|
|
59262
59269
|
const positionHelpers = getPositionHelpers(containerRef, menuRef, scrollNodes.menu, boundingBoxPadding);
|
|
59263
59270
|
const { menuRect } = positionHelpers;
|
|
@@ -59349,7 +59356,8 @@ const MenuList = ({
|
|
|
59349
59356
|
React13.useEffect(() => {
|
|
59350
59357
|
let { menu: menuScroll } = scrollNodes;
|
|
59351
59358
|
if (!isOpen || !menuScroll) return;
|
|
59352
|
-
|
|
59359
|
+
const thisWindow = containerRef?.current?.ownerDocument.defaultView ?? window;
|
|
59360
|
+
menuScroll = menuScroll.addEventListener ? menuScroll : thisWindow;
|
|
59353
59361
|
if (!scrollNodes.anchors) {
|
|
59354
59362
|
scrollNodes.anchors = [];
|
|
59355
59363
|
let anchorScroll = getScrollAncestor(rootAnchorRef && rootAnchorRef.current);
|
|
@@ -59455,7 +59463,7 @@ const MenuList = ({
|
|
|
59455
59463
|
} else if (captureFocus) {
|
|
59456
59464
|
const id = setTimeout(
|
|
59457
59465
|
() => {
|
|
59458
|
-
if (menuRef.current && !menuRef.current.contains(
|
|
59466
|
+
if (menuRef.current && !menuRef.current.contains(menuRef.current.ownerDocument.activeElement)) {
|
|
59459
59467
|
const popupElement = focusRef.current?.nextSibling;
|
|
59460
59468
|
if (!focusFirstInput(popupElement)) {
|
|
59461
59469
|
focusRef.current?.focus();
|
|
@@ -59807,7 +59815,7 @@ const ControlledMenuFr = ({
|
|
|
59807
59815
|
}
|
|
59808
59816
|
};
|
|
59809
59817
|
const onBlur = (e) => {
|
|
59810
|
-
if (isMenuOpen(state) && !e.currentTarget.contains(e.relatedTarget ||
|
|
59818
|
+
if (isMenuOpen(state) && !e.currentTarget.contains(e.relatedTarget || e.currentTarget.ownerDocument.activeElement) && !isWithinMenu(e.relatedTarget)) {
|
|
59811
59819
|
safeCall(onClose, { reason: CloseReason.BLUR });
|
|
59812
59820
|
if (skipOpen) {
|
|
59813
59821
|
skipOpen.current = true;
|
|
@@ -59849,8 +59857,9 @@ const ControlledMenuFr = ({
|
|
|
59849
59857
|
}
|
|
59850
59858
|
if (portal) {
|
|
59851
59859
|
if (typeof portal === "boolean") {
|
|
59852
|
-
|
|
59853
|
-
|
|
59860
|
+
const thisDocument = containerRef.current?.ownerDocument ?? (typeof document !== "undefined" ? document : void 0);
|
|
59861
|
+
if (portal && thisDocument) {
|
|
59862
|
+
return ReactDOM.createPortal(menuList, thisDocument.body);
|
|
59854
59863
|
}
|
|
59855
59864
|
} else {
|
|
59856
59865
|
return portal.target ? ReactDOM.createPortal(menuList, portal.target) : portal.stablePosition ? null : menuList;
|
|
@@ -60865,13 +60874,14 @@ const useGridRangeSelection = ({
|
|
|
60865
60874
|
[rangeEndRef]
|
|
60866
60875
|
);
|
|
60867
60876
|
React13.useEffect(() => {
|
|
60868
|
-
|
|
60869
|
-
|
|
60877
|
+
const doc = gridDivRef.current?.ownerDocument;
|
|
60878
|
+
doc?.addEventListener("mousedown", trackMouseDown, { capture: true });
|
|
60879
|
+
doc?.addEventListener("mouseup", trackMouseUp, { capture: true });
|
|
60870
60880
|
return () => {
|
|
60871
|
-
|
|
60872
|
-
|
|
60881
|
+
doc?.removeEventListener("mousemove", trackMouseDown, { capture: true });
|
|
60882
|
+
doc?.removeEventListener("mouseup", trackMouseUp, { capture: true });
|
|
60873
60883
|
};
|
|
60874
|
-
}, [trackMouseDown, trackMouseUp]);
|
|
60884
|
+
}, [trackMouseDown, trackMouseUp, gridDivRef]);
|
|
60875
60885
|
const onCellMouseOver = React13.useCallback(
|
|
60876
60886
|
(e, mouseDown) => {
|
|
60877
60887
|
if (!enableRangeSelection) {
|
|
@@ -60896,7 +60906,7 @@ const useGridRangeSelection = ({
|
|
|
60896
60906
|
if (rangeStartRef.current && rangeEndRef.current && (rangeStartRef.current.rowId !== rangeEndRef.current.rowId || rangeStartRef.current.colId !== rangeEndRef.current.colId)) {
|
|
60897
60907
|
e.api.stopEditing();
|
|
60898
60908
|
hasSelectedMoreThanOneCellRef.current = true;
|
|
60899
|
-
|
|
60909
|
+
gridDivRef.current?.ownerDocument.defaultView?.getSelection()?.removeAllRanges();
|
|
60900
60910
|
}
|
|
60901
60911
|
updateRangeSelectionCellClasses();
|
|
60902
60912
|
},
|
|
@@ -60906,7 +60916,8 @@ const useGridRangeSelection = ({
|
|
|
60906
60916
|
hasSelectedMoreThanOneCellRef,
|
|
60907
60917
|
rangeEndRef,
|
|
60908
60918
|
rangeSortedNodesRef,
|
|
60909
|
-
rangeStartRef
|
|
60919
|
+
rangeStartRef,
|
|
60920
|
+
gridDivRef
|
|
60910
60921
|
]
|
|
60911
60922
|
);
|
|
60912
60923
|
const onCellMouseDown = React13.useCallback(
|
|
@@ -61422,7 +61433,7 @@ const Grid = ({
|
|
|
61422
61433
|
const api = event.api;
|
|
61423
61434
|
if (sizeColumns === "fit") {
|
|
61424
61435
|
lodashEs.delay(() => {
|
|
61425
|
-
if (!anyUpdating() &&
|
|
61436
|
+
if (!anyUpdating() && !gridDivRef.current?.ownerDocument.querySelectorAll(".szh-menu--state-open").length) {
|
|
61426
61437
|
if (!api.isDestroyed()) {
|
|
61427
61438
|
api.redrawRows();
|
|
61428
61439
|
}
|
|
@@ -61631,15 +61642,17 @@ const Grid = ({
|
|
|
61631
61642
|
}, [params.loading, rowData, showNoRowsOverlay]);
|
|
61632
61643
|
const startDragYRef = React13.useRef(null);
|
|
61633
61644
|
const clearHighlightRowClasses = React13.useCallback(() => {
|
|
61634
|
-
|
|
61645
|
+
const gridRoot = gridDivRef.current;
|
|
61646
|
+
gridRoot?.querySelectorAll(`.ag-row-highlight-above`)?.forEach((el) => {
|
|
61635
61647
|
el.classList.remove("ag-row-highlight-above");
|
|
61636
61648
|
});
|
|
61637
|
-
|
|
61649
|
+
gridRoot?.querySelectorAll(`.ag-row-highlight-below`)?.forEach((el) => {
|
|
61638
61650
|
el.classList.remove("ag-row-highlight-below");
|
|
61639
61651
|
});
|
|
61640
61652
|
}, []);
|
|
61641
61653
|
const clearDragRowClasses = React13.useCallback(() => {
|
|
61642
|
-
|
|
61654
|
+
const gridRoot = gridDivRef.current;
|
|
61655
|
+
gridRoot?.querySelectorAll(`.ag-row-dragging`)?.forEach((el) => {
|
|
61643
61656
|
el.classList.remove("ag-row-dragging");
|
|
61644
61657
|
});
|
|
61645
61658
|
}, []);
|
|
@@ -62217,20 +62230,87 @@ const EMPTY_KEY = "__EMPTY__";
|
|
|
62217
62230
|
const DEFAULT_EMPTY_LABEL = "-";
|
|
62218
62231
|
const filterStateMap = /* @__PURE__ */ new Map();
|
|
62219
62232
|
const filterClickCountMap = /* @__PURE__ */ new Map();
|
|
62220
|
-
const
|
|
62221
|
-
|
|
62222
|
-
|
|
62223
|
-
|
|
62224
|
-
|
|
62225
|
-
|
|
62226
|
-
|
|
62227
|
-
|
|
62233
|
+
const normalizeCellValue = (value) => {
|
|
62234
|
+
if (typeof value === "string") return value.trim() === "" ? EMPTY_KEY : value;
|
|
62235
|
+
return EMPTY_KEY;
|
|
62236
|
+
};
|
|
62237
|
+
const loadFieldValues = (params) => {
|
|
62238
|
+
const field = params.colDef.field;
|
|
62239
|
+
const values = /* @__PURE__ */ new Set();
|
|
62240
|
+
params.api.forEachNode((node) => {
|
|
62241
|
+
const data = node.data ?? {};
|
|
62242
|
+
values.add(normalizeCellValue(data[field]));
|
|
62243
|
+
});
|
|
62244
|
+
const { customOrder } = params;
|
|
62245
|
+
const orderMap = customOrder?.length ? new Map(customOrder.map((val, idx) => [val, idx])) : null;
|
|
62246
|
+
return Array.from(values).sort((a, b) => {
|
|
62247
|
+
if (orderMap) {
|
|
62248
|
+
const aIdx = orderMap.get(a) ?? Infinity;
|
|
62249
|
+
const bIdx = orderMap.get(b) ?? Infinity;
|
|
62250
|
+
if (aIdx !== bIdx) return aIdx - bIdx;
|
|
62251
|
+
}
|
|
62252
|
+
if (a === EMPTY_KEY) return b === EMPTY_KEY ? 0 : -1;
|
|
62253
|
+
if (b === EMPTY_KEY) return 1;
|
|
62254
|
+
return a.localeCompare(b);
|
|
62255
|
+
});
|
|
62256
|
+
};
|
|
62257
|
+
const GridFilterColumnsMultiSelect = (props) => {
|
|
62258
|
+
const { model, onModelChange, colDef, column, labels: labelsParam, labelFormatter } = props;
|
|
62259
|
+
const containerRef = React13.useRef(null);
|
|
62260
|
+
const allValues = React13.useMemo(() => loadFieldValues(props), []);
|
|
62261
|
+
const labels = React13.useMemo(
|
|
62262
|
+
() => ({ [EMPTY_KEY]: DEFAULT_EMPTY_LABEL, ...labelsParam }),
|
|
62263
|
+
[labelsParam]
|
|
62264
|
+
);
|
|
62265
|
+
const selected = React13.useMemo(() => new Set(model?.values ?? allValues), [model, allValues]);
|
|
62266
|
+
useGridFilter$1({
|
|
62267
|
+
doesFilterPass: (p) => {
|
|
62268
|
+
if (selected.size === 0) return false;
|
|
62269
|
+
const field = colDef.field;
|
|
62270
|
+
if (!p.data || typeof p.data !== "object") return selected.has(EMPTY_KEY);
|
|
62271
|
+
const raw = p.data[field];
|
|
62272
|
+
return selected.has(normalizeCellValue(raw));
|
|
62273
|
+
}
|
|
62274
|
+
});
|
|
62275
|
+
React13.useEffect(() => {
|
|
62276
|
+
const ownerDocument = containerRef.current?.ownerDocument;
|
|
62277
|
+
const columnId = column.getColId();
|
|
62278
|
+
const filterButton = ownerDocument?.querySelector(`[col-id="${columnId}"] .ag-header-cell-filter-button`);
|
|
62279
|
+
if (!filterButton) {
|
|
62280
|
+
return;
|
|
62281
|
+
}
|
|
62282
|
+
const listener = (e) => {
|
|
62283
|
+
const clickCount = filterClickCountMap.get(columnId) || 0;
|
|
62284
|
+
filterClickCountMap.set(columnId, clickCount + 1);
|
|
62285
|
+
if (clickCount === 0) {
|
|
62286
|
+
e.stopImmediatePropagation();
|
|
62287
|
+
e.preventDefault();
|
|
62288
|
+
props.api.hidePopupMenu();
|
|
62289
|
+
filterStateMap.set(columnId, false);
|
|
62290
|
+
return;
|
|
62291
|
+
}
|
|
62292
|
+
const isOpen = filterStateMap.get(columnId) || false;
|
|
62293
|
+
if (isOpen) {
|
|
62294
|
+
e.stopImmediatePropagation();
|
|
62295
|
+
e.preventDefault();
|
|
62296
|
+
props.api.hidePopupMenu();
|
|
62297
|
+
filterStateMap.set(columnId, false);
|
|
62298
|
+
} else {
|
|
62299
|
+
filterStateMap.set(columnId, true);
|
|
62300
|
+
}
|
|
62301
|
+
};
|
|
62302
|
+
filterButton.addEventListener("click", listener, true);
|
|
62303
|
+
return () => filterButton.removeEventListener("click", listener, true);
|
|
62304
|
+
}, [column, props.api]);
|
|
62228
62305
|
const allChecked = allValues.length > 0 && selected.size === allValues.length;
|
|
62229
62306
|
const getDisplayLabel = (raw) => {
|
|
62230
62307
|
const base = raw === EMPTY_KEY ? labels[EMPTY_KEY] ?? DEFAULT_EMPTY_LABEL : labels[raw] ?? raw;
|
|
62231
62308
|
return labelFormatter ? labelFormatter(base) : base;
|
|
62232
62309
|
};
|
|
62233
|
-
|
|
62310
|
+
const applySelection = (next) => {
|
|
62311
|
+
onModelChange(next.size === allValues.length ? null : { values: Array.from(next) });
|
|
62312
|
+
};
|
|
62313
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "GridFilterColsMultiSelect", ref: containerRef, children: [
|
|
62234
62314
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "LuiSelect-label-text", children: "Filter column" }),
|
|
62235
62315
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
62236
62316
|
lui.LuiCheckboxInput,
|
|
@@ -62239,7 +62319,7 @@ const FilterUI = ({
|
|
|
62239
62319
|
label: "Select All",
|
|
62240
62320
|
value: "true",
|
|
62241
62321
|
isChecked: allChecked,
|
|
62242
|
-
onChange: (e) =>
|
|
62322
|
+
onChange: (e) => applySelection(e.target.checked ? new Set(allValues) : /* @__PURE__ */ new Set())
|
|
62243
62323
|
}
|
|
62244
62324
|
),
|
|
62245
62325
|
allValues.map((val) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -62249,163 +62329,17 @@ const FilterUI = ({
|
|
|
62249
62329
|
label: getDisplayLabel(val),
|
|
62250
62330
|
value: val,
|
|
62251
62331
|
isChecked: selected.has(val),
|
|
62252
|
-
onChange: (e) =>
|
|
62332
|
+
onChange: (e) => {
|
|
62333
|
+
const next = new Set(selected);
|
|
62334
|
+
if (e.target.checked) next.add(val);
|
|
62335
|
+
else next.delete(val);
|
|
62336
|
+
applySelection(next);
|
|
62337
|
+
}
|
|
62253
62338
|
},
|
|
62254
62339
|
val
|
|
62255
62340
|
))
|
|
62256
62341
|
] });
|
|
62257
62342
|
};
|
|
62258
|
-
class GridFilterColumnsMultiSelect {
|
|
62259
|
-
params;
|
|
62260
|
-
selectedValues = /* @__PURE__ */ new Set();
|
|
62261
|
-
labels = {};
|
|
62262
|
-
allValues = [];
|
|
62263
|
-
gui;
|
|
62264
|
-
labelFormatter;
|
|
62265
|
-
reactRoot = null;
|
|
62266
|
-
filterButtonClickListener = null;
|
|
62267
|
-
filterButton = null;
|
|
62268
|
-
normalizeCellValue(value) {
|
|
62269
|
-
if (typeof value === "string") return value.trim() === "" ? EMPTY_KEY : value;
|
|
62270
|
-
return EMPTY_KEY;
|
|
62271
|
-
}
|
|
62272
|
-
loadFieldValues() {
|
|
62273
|
-
const field = this.params.colDef.field;
|
|
62274
|
-
const values = /* @__PURE__ */ new Set();
|
|
62275
|
-
this.params.api.forEachNode((node) => {
|
|
62276
|
-
const data = node.data ?? {};
|
|
62277
|
-
const raw = data[field];
|
|
62278
|
-
const norm = this.normalizeCellValue(raw);
|
|
62279
|
-
values.add(norm);
|
|
62280
|
-
});
|
|
62281
|
-
const { customOrder } = this.params;
|
|
62282
|
-
const orderMap = customOrder?.length ? new Map(customOrder.map((val, idx) => [val, idx])) : null;
|
|
62283
|
-
return Array.from(values).sort((a, b) => {
|
|
62284
|
-
if (orderMap) {
|
|
62285
|
-
const aIdx = orderMap.get(a) ?? Infinity;
|
|
62286
|
-
const bIdx = orderMap.get(b) ?? Infinity;
|
|
62287
|
-
if (aIdx !== bIdx) return aIdx - bIdx;
|
|
62288
|
-
}
|
|
62289
|
-
if (a === EMPTY_KEY) return b === EMPTY_KEY ? 0 : -1;
|
|
62290
|
-
if (b === EMPTY_KEY) return 1;
|
|
62291
|
-
return a.localeCompare(b);
|
|
62292
|
-
});
|
|
62293
|
-
}
|
|
62294
|
-
init(params) {
|
|
62295
|
-
this.params = params;
|
|
62296
|
-
this.labels = { ...params.labels };
|
|
62297
|
-
this.labelFormatter = params.labelFormatter;
|
|
62298
|
-
if (!(EMPTY_KEY in this.labels)) {
|
|
62299
|
-
this.labels[EMPTY_KEY] = DEFAULT_EMPTY_LABEL;
|
|
62300
|
-
}
|
|
62301
|
-
this.allValues = this.loadFieldValues();
|
|
62302
|
-
this.selectedValues = new Set(this.allValues);
|
|
62303
|
-
this.gui = document.createElement("div");
|
|
62304
|
-
this.reactRoot = client.createRoot(this.gui);
|
|
62305
|
-
this.render();
|
|
62306
|
-
this.setupFilterButtonListener();
|
|
62307
|
-
}
|
|
62308
|
-
setupFilterButtonListener() {
|
|
62309
|
-
const columnId = this.params.column.getColId();
|
|
62310
|
-
this.filterButton = document.querySelector(`[col-id="${columnId}"] .ag-header-cell-filter-button`);
|
|
62311
|
-
if (this.filterButton) {
|
|
62312
|
-
this.filterButtonClickListener = (e) => {
|
|
62313
|
-
const clickCount = filterClickCountMap.get(columnId) || 0;
|
|
62314
|
-
filterClickCountMap.set(columnId, clickCount + 1);
|
|
62315
|
-
if (clickCount === 0) {
|
|
62316
|
-
e.stopImmediatePropagation();
|
|
62317
|
-
e.preventDefault();
|
|
62318
|
-
this.params.api.hidePopupMenu();
|
|
62319
|
-
filterStateMap.set(columnId, false);
|
|
62320
|
-
return;
|
|
62321
|
-
}
|
|
62322
|
-
const isOpen = filterStateMap.get(columnId) || false;
|
|
62323
|
-
if (isOpen) {
|
|
62324
|
-
e.stopImmediatePropagation();
|
|
62325
|
-
e.preventDefault();
|
|
62326
|
-
this.params.api.hidePopupMenu();
|
|
62327
|
-
filterStateMap.set(columnId, false);
|
|
62328
|
-
} else {
|
|
62329
|
-
filterStateMap.set(columnId, true);
|
|
62330
|
-
}
|
|
62331
|
-
};
|
|
62332
|
-
this.filterButton.addEventListener("click", this.filterButtonClickListener, true);
|
|
62333
|
-
}
|
|
62334
|
-
}
|
|
62335
|
-
render() {
|
|
62336
|
-
if (!this.reactRoot) return;
|
|
62337
|
-
this.reactRoot.render(
|
|
62338
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
62339
|
-
FilterUI,
|
|
62340
|
-
{
|
|
62341
|
-
allValues: this.allValues,
|
|
62342
|
-
selected: this.selectedValues,
|
|
62343
|
-
labels: this.labels,
|
|
62344
|
-
labelFormatter: this.labelFormatter,
|
|
62345
|
-
onToggleAll: this.handleToggleAll.bind(this),
|
|
62346
|
-
onToggleOne: this.handleToggleOne.bind(this)
|
|
62347
|
-
}
|
|
62348
|
-
)
|
|
62349
|
-
);
|
|
62350
|
-
}
|
|
62351
|
-
handleToggleAll(checked) {
|
|
62352
|
-
if (checked) {
|
|
62353
|
-
this.allValues.forEach((val) => this.selectedValues.add(val));
|
|
62354
|
-
} else {
|
|
62355
|
-
this.selectedValues.clear();
|
|
62356
|
-
}
|
|
62357
|
-
this.render();
|
|
62358
|
-
this.params.filterChangedCallback();
|
|
62359
|
-
}
|
|
62360
|
-
handleToggleOne(value, checked) {
|
|
62361
|
-
if (checked) {
|
|
62362
|
-
this.selectedValues.add(value);
|
|
62363
|
-
} else {
|
|
62364
|
-
this.selectedValues.delete(value);
|
|
62365
|
-
}
|
|
62366
|
-
this.render();
|
|
62367
|
-
this.params.filterChangedCallback();
|
|
62368
|
-
}
|
|
62369
|
-
getGui() {
|
|
62370
|
-
return this.gui;
|
|
62371
|
-
}
|
|
62372
|
-
isFilterActive() {
|
|
62373
|
-
return this.selectedValues.size !== this.allValues.length;
|
|
62374
|
-
}
|
|
62375
|
-
doesFilterPass(p) {
|
|
62376
|
-
if (this.selectedValues.size === 0) {
|
|
62377
|
-
return false;
|
|
62378
|
-
}
|
|
62379
|
-
const field = this.params.colDef.field;
|
|
62380
|
-
if (!p.data || typeof p.data !== "object") {
|
|
62381
|
-
return this.selectedValues.has(EMPTY_KEY);
|
|
62382
|
-
}
|
|
62383
|
-
const raw = p.data[field];
|
|
62384
|
-
const norm = this.normalizeCellValue(raw);
|
|
62385
|
-
return this.selectedValues.has(norm);
|
|
62386
|
-
}
|
|
62387
|
-
getModel() {
|
|
62388
|
-
if (this.selectedValues.size !== this.allValues.length) {
|
|
62389
|
-
return { values: Array.from(this.selectedValues) };
|
|
62390
|
-
}
|
|
62391
|
-
return null;
|
|
62392
|
-
}
|
|
62393
|
-
setModel(model) {
|
|
62394
|
-
this.selectedValues = new Set(model?.values || []);
|
|
62395
|
-
this.render();
|
|
62396
|
-
}
|
|
62397
|
-
destroy() {
|
|
62398
|
-
if (this.filterButtonClickListener && this.filterButton) {
|
|
62399
|
-
this.filterButton.removeEventListener("click", this.filterButtonClickListener, true);
|
|
62400
|
-
this.filterButtonClickListener = null;
|
|
62401
|
-
this.filterButton = null;
|
|
62402
|
-
}
|
|
62403
|
-
if (this.reactRoot) {
|
|
62404
|
-
this.reactRoot.unmount();
|
|
62405
|
-
this.reactRoot = null;
|
|
62406
|
-
}
|
|
62407
|
-
}
|
|
62408
|
-
}
|
|
62409
62343
|
const createCheckboxMultiFilterParams = (labels = {}, labelFormatter, customOrder) => ({
|
|
62410
62344
|
labels: { [EMPTY_KEY]: DEFAULT_EMPTY_LABEL, ...labels },
|
|
62411
62345
|
labelFormatter,
|