@linzjs/step-ag-grid 29.14.1 → 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/Grid.d.ts +2 -1
- package/dist/src/components/gridFilter/GridFilterColumnsMultiSelect.d.ts +2 -1
- package/dist/step-ag-grid.cjs +23 -8
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +23 -8
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +22 -25
- package/src/components/Grid.tsx +3 -0
- package/src/components/gridFilter/GridFilterColumnsMultiSelect.tsx +23 -4
- package/src/stories/grid/GridCopy.stories.tsx +1 -12
- package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +9 -5
|
@@ -32,6 +32,7 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
32
32
|
setExternalSelectedItems?: (items: TData[]) => void;
|
|
33
33
|
onBulkEditingComplete?: () => Promise<void> | void;
|
|
34
34
|
singleClickEdit?: boolean;
|
|
35
|
+
stopEditingWhenCellsLoseFocus?: boolean;
|
|
35
36
|
contextMenu?: GridContextMenuComponent<TData>;
|
|
36
37
|
contextMenuSelectRow?: boolean;
|
|
37
38
|
onCellFocused?: (props: {
|
|
@@ -63,4 +64,4 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
63
64
|
/**
|
|
64
65
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
65
66
|
*/
|
|
66
|
-
export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ theme, "data-testid": dataTestId, suppressReadOnlyStyle, defaultPostSort, rowData, rowHeight, rowSelection, sizeColumns, autoSelectFirstRow, enableRangeSelection, externalSelectedIds, externalSelectedItems, selectColumnPinned, selectable, setExternalSelectedIds, setExternalSelectedItems, singleClickEdit, contextMenuSelectRow, contextMenu, onCellFocused: paramsOnCellFocused, onColumnMoved, suppressColumnVirtualization, maxInitialWidth, ...params }: GridProps<TData>) => ReactElement;
|
|
67
|
+
export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ theme, "data-testid": dataTestId, suppressReadOnlyStyle, defaultPostSort, rowData, rowHeight, rowSelection, sizeColumns, autoSelectFirstRow, enableRangeSelection, externalSelectedIds, externalSelectedItems, selectColumnPinned, selectable, setExternalSelectedIds, setExternalSelectedItems, singleClickEdit, stopEditingWhenCellsLoseFocus, contextMenuSelectRow, contextMenu, onCellFocused: paramsOnCellFocused, onColumnMoved, suppressColumnVirtualization, maxInitialWidth, ...params }: GridProps<TData>) => ReactElement;
|
|
@@ -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
|
@@ -3259,7 +3259,7 @@ defaultPostSort = true, rowData, rowHeight = theme === 'ag-theme-step-default' ?
|
|
|
3259
3259
|
// ─── Selection ────────────────────────────────
|
|
3260
3260
|
autoSelectFirstRow, enableRangeSelection = false, externalSelectedIds, externalSelectedItems, selectColumnPinned = 'left', selectable, setExternalSelectedIds, setExternalSelectedItems,
|
|
3261
3261
|
// ─── Editing ──────────────────────────────────
|
|
3262
|
-
singleClickEdit = false,
|
|
3262
|
+
singleClickEdit = false, stopEditingWhenCellsLoseFocus = false,
|
|
3263
3263
|
// ─── Context Menu ─────────────────────────────
|
|
3264
3264
|
contextMenuSelectRow = false, contextMenu,
|
|
3265
3265
|
// ─── Callbacks / Events ───────────────────────
|
|
@@ -3973,7 +3973,7 @@ maxInitialWidth,
|
|
|
3973
3973
|
headerCheckbox: false,
|
|
3974
3974
|
}),
|
|
3975
3975
|
}
|
|
3976
|
-
: undefined, selectionColumnDef: selectionColumnDef, suppressCellFocus: params.suppressCellFocus, suppressClickEdit: true, suppressColumnVirtualisation: suppressColumnVirtualization, suppressStartEditOnTab: true }) })] }));
|
|
3976
|
+
: undefined, stopEditingWhenCellsLoseFocus: stopEditingWhenCellsLoseFocus, selectionColumnDef: selectionColumnDef, suppressCellFocus: params.suppressCellFocus, suppressClickEdit: true, suppressColumnVirtualisation: suppressColumnVirtualization, suppressStartEditOnTab: true }) })] }));
|
|
3977
3977
|
};
|
|
3978
3978
|
const quickFilterParser = (filterStr) => {
|
|
3979
3979
|
// filter is exact matches exactly groups separated by commas
|
|
@@ -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) {
|