@linzjs/step-ag-grid 29.15.0 → 29.16.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 +2 -1
- package/dist/step-ag-grid.cjs +21 -6
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +21 -6
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/gridFilter/GridFilterColumnsMultiSelect.tsx +23 -4
- package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +9 -5
|
@@ -3,6 +3,7 @@ import type { IDoesFilterPassParams, IFilterComp, IFilterParams } from 'ag-grid-
|
|
|
3
3
|
export interface CheckboxMultiFilterParams extends IFilterParams {
|
|
4
4
|
labels?: Record<string, string>;
|
|
5
5
|
labelFormatter?: (value: string) => string;
|
|
6
|
+
customOrder?: string[];
|
|
6
7
|
}
|
|
7
8
|
export interface CheckboxMultiFilterModel {
|
|
8
9
|
values: string[];
|
|
@@ -28,4 +29,4 @@ export declare class GridFilterColumnsMultiSelect implements IFilterComp {
|
|
|
28
29
|
setModel(model: CheckboxMultiFilterModel | null): void;
|
|
29
30
|
destroy(): void;
|
|
30
31
|
}
|
|
31
|
-
export declare const createCheckboxMultiFilterParams: (labels?: Record<string, string>, labelFormatter?: (value: string) => string) => Partial<CheckboxMultiFilterParams>;
|
|
32
|
+
export declare const createCheckboxMultiFilterParams: (labels?: Record<string, string>, labelFormatter?: (value: string) => string, customOrder?: string[]) => Partial<CheckboxMultiFilterParams>;
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -4249,10 +4249,18 @@ class GridFilterColumnsMultiSelect {
|
|
|
4249
4249
|
const norm = this.normalizeCellValue(raw);
|
|
4250
4250
|
values.add(norm);
|
|
4251
4251
|
});
|
|
4252
|
+
const { customOrder } = this.params;
|
|
4253
|
+
const orderMap = customOrder?.length ? new Map(customOrder.map((val, idx) => [val, idx])) : null;
|
|
4252
4254
|
return Array.from(values).sort((a, b) => {
|
|
4253
|
-
if (
|
|
4254
|
-
|
|
4255
|
-
|
|
4255
|
+
if (orderMap) {
|
|
4256
|
+
const aIdx = orderMap.get(a) ?? Infinity;
|
|
4257
|
+
const bIdx = orderMap.get(b) ?? Infinity;
|
|
4258
|
+
if (aIdx !== bIdx)
|
|
4259
|
+
return aIdx - bIdx;
|
|
4260
|
+
}
|
|
4261
|
+
if (a === EMPTY_KEY)
|
|
4262
|
+
return b === EMPTY_KEY ? 0 : -1;
|
|
4263
|
+
if (b === EMPTY_KEY)
|
|
4256
4264
|
return 1;
|
|
4257
4265
|
return a.localeCompare(b);
|
|
4258
4266
|
});
|
|
@@ -4299,9 +4307,12 @@ class GridFilterColumnsMultiSelect {
|
|
|
4299
4307
|
return this.gui;
|
|
4300
4308
|
}
|
|
4301
4309
|
isFilterActive() {
|
|
4302
|
-
return this.selectedValues.size
|
|
4310
|
+
return this.selectedValues.size !== this.allValues.length;
|
|
4303
4311
|
}
|
|
4304
4312
|
doesFilterPass(p) {
|
|
4313
|
+
if (this.selectedValues.size === 0) {
|
|
4314
|
+
return false;
|
|
4315
|
+
}
|
|
4305
4316
|
const field = this.params.colDef.field;
|
|
4306
4317
|
if (!p.data || typeof p.data !== 'object') {
|
|
4307
4318
|
return this.selectedValues.has(EMPTY_KEY);
|
|
@@ -4311,7 +4322,10 @@ class GridFilterColumnsMultiSelect {
|
|
|
4311
4322
|
return this.selectedValues.has(norm);
|
|
4312
4323
|
}
|
|
4313
4324
|
getModel() {
|
|
4314
|
-
|
|
4325
|
+
if (this.selectedValues.size !== this.allValues.length) {
|
|
4326
|
+
return { values: Array.from(this.selectedValues) };
|
|
4327
|
+
}
|
|
4328
|
+
return null;
|
|
4315
4329
|
}
|
|
4316
4330
|
setModel(model) {
|
|
4317
4331
|
this.selectedValues = new Set(model?.values || []);
|
|
@@ -4324,9 +4338,10 @@ class GridFilterColumnsMultiSelect {
|
|
|
4324
4338
|
}
|
|
4325
4339
|
}
|
|
4326
4340
|
}
|
|
4327
|
-
const createCheckboxMultiFilterParams = (labels = {}, labelFormatter) => ({
|
|
4341
|
+
const createCheckboxMultiFilterParams = (labels = {}, labelFormatter, customOrder) => ({
|
|
4328
4342
|
labels: { [EMPTY_KEY]: DEFAULT_EMPTY_LABEL, ...labels },
|
|
4329
4343
|
labelFormatter,
|
|
4344
|
+
customOrder,
|
|
4330
4345
|
});
|
|
4331
4346
|
|
|
4332
4347
|
const GridFilterHeaderIconButton = React.forwardRef(function columnsButton({ icon, title, onClick, buttonProps, disabled = false, size = 'md' }, ref) {
|