@linzjs/step-ag-grid 29.5.1 → 29.7.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 +30 -0
- package/dist/src/components/gridFilter/index.d.ts +1 -0
- package/dist/step-ag-grid.cjs +136 -27
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +135 -28
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/gridFilter/GridFilterColumnsMultiSelect.scss +20 -0
- package/src/components/gridFilter/GridFilterColumnsMultiSelect.tsx +189 -0
- package/src/components/gridFilter/index.ts +1 -0
- package/src/stories/grid/GridFilterButtons.stories.tsx +1 -1
- package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +122 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import './GridFilterColumnsMultiSelect.scss';
|
|
2
|
+
import type { IDoesFilterPassParams, IFilterComp, IFilterParams } from 'ag-grid-community';
|
|
3
|
+
export interface CheckboxMultiFilterParams extends IFilterParams {
|
|
4
|
+
labels?: Record<string, string>;
|
|
5
|
+
labelFormatter?: (value: string) => string;
|
|
6
|
+
}
|
|
7
|
+
export interface CheckboxMultiFilterModel {
|
|
8
|
+
values: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare class GridFilterColumnsMultiSelect implements IFilterComp {
|
|
11
|
+
private params;
|
|
12
|
+
private selectedValues;
|
|
13
|
+
private labels;
|
|
14
|
+
private allValues;
|
|
15
|
+
private gui;
|
|
16
|
+
private labelFormatter?;
|
|
17
|
+
private reactRoot;
|
|
18
|
+
private loadFieldValues;
|
|
19
|
+
init(params: CheckboxMultiFilterParams): void;
|
|
20
|
+
private render;
|
|
21
|
+
private handleToggleAll;
|
|
22
|
+
private handleToggleOne;
|
|
23
|
+
getGui(): HTMLElement;
|
|
24
|
+
isFilterActive(): boolean;
|
|
25
|
+
doesFilterPass(params: IDoesFilterPassParams): boolean;
|
|
26
|
+
getModel(): CheckboxMultiFilterModel | null;
|
|
27
|
+
setModel(model: CheckboxMultiFilterModel | null): void;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
30
|
+
export declare const createCheckboxMultiFilterParams: (labels?: Record<string, string>, labelFormatter?: (value: string) => string) => Partial<CheckboxMultiFilterParams>;
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -7,6 +7,7 @@ var agGridReact = require('ag-grid-react');
|
|
|
7
7
|
var lodashEs = require('lodash-es');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var reactDom = require('react-dom');
|
|
10
|
+
var client = require('react-dom/client');
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* If loading is true this returns a loading spinner, otherwise it returns its children.
|
|
@@ -3598,6 +3599,139 @@ const GridFilterButtons = ({ className, luiButtonProps, options, }) => {
|
|
|
3598
3599
|
return (jsxRuntime.jsx("div", { className: clsx(className, 'flex-col-center'), children: jsxRuntime.jsx(lui.LuiButtonGroup, { children: options.map((option, index) => (jsxRuntime.jsx(lui.LuiButton, { ...luiButtonProps, className: clsx(`lui-button lui-button-secondary`, selectedOption?.label === option.label && `lui-button-active`, luiButtonProps?.className), onClick: () => setSelectedOption(option), children: option.label }, `${index}`))) }) }));
|
|
3599
3600
|
};
|
|
3600
3601
|
|
|
3602
|
+
function styleInject(css, ref) {
|
|
3603
|
+
if ( ref === void 0 ) ref = {};
|
|
3604
|
+
var insertAt = ref.insertAt;
|
|
3605
|
+
|
|
3606
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
3607
|
+
|
|
3608
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
3609
|
+
var style = document.createElement('style');
|
|
3610
|
+
style.type = 'text/css';
|
|
3611
|
+
|
|
3612
|
+
if (insertAt === 'top') {
|
|
3613
|
+
if (head.firstChild) {
|
|
3614
|
+
head.insertBefore(style, head.firstChild);
|
|
3615
|
+
} else {
|
|
3616
|
+
head.appendChild(style);
|
|
3617
|
+
}
|
|
3618
|
+
} else {
|
|
3619
|
+
head.appendChild(style);
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
if (style.styleSheet) {
|
|
3623
|
+
style.styleSheet.cssText = css;
|
|
3624
|
+
} else {
|
|
3625
|
+
style.appendChild(document.createTextNode(css));
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
|
|
3629
|
+
var css_248z$3 = ".GridFilterColsMultiSelect{background:#fff;font-family:Open Sans,system-ui,sans-serif;font-style:normal;font-weight:600;padding:8px}.GridFilterColsMultiSelect .LuiCheckboxInput-item,.GridFilterColsMultiSelect .LuiCheckboxInput-selectAll{color:#2a292c;font-size:16px;font-style:SemiBold;font-weight:600;letter-spacing:0;line-height:20px;line-height:24px;margin-bottom:0}";
|
|
3630
|
+
styleInject(css_248z$3);
|
|
3631
|
+
|
|
3632
|
+
const FilterUI = ({ allValues, selected, labels, labelFormatter, onToggleAll, onToggleOne, }) => {
|
|
3633
|
+
const allChecked = allValues.length > 0 && selected.size === allValues.length;
|
|
3634
|
+
const getDisplayLabel = (raw) => {
|
|
3635
|
+
const mapped = labels[raw] ?? raw;
|
|
3636
|
+
return labelFormatter ? labelFormatter(mapped) : mapped;
|
|
3637
|
+
};
|
|
3638
|
+
return (jsxRuntime.jsxs("div", { className: "GridFilterColsMultiSelect", children: [jsxRuntime.jsx("span", { className: "LuiSelect-label-text", children: "Filter column" }), jsxRuntime.jsx(lui.LuiCheckboxInput, { className: "LuiCheckboxInput-selectAll", label: 'Select All', value: "true", isChecked: allChecked, onChange: (e) => onToggleAll(e.target.checked) }), allValues.map((val) => (jsxRuntime.jsx(lui.LuiCheckboxInput, { className: "LuiCheckboxInput-item", label: getDisplayLabel(val), value: val, isChecked: selected.has(val), onChange: (e) => onToggleOne(val, e.target.checked) }, val)))] }));
|
|
3639
|
+
};
|
|
3640
|
+
class GridFilterColumnsMultiSelect {
|
|
3641
|
+
params;
|
|
3642
|
+
selectedValues = new Set();
|
|
3643
|
+
labels = {};
|
|
3644
|
+
allValues = [];
|
|
3645
|
+
gui;
|
|
3646
|
+
labelFormatter;
|
|
3647
|
+
reactRoot = null;
|
|
3648
|
+
loadFieldValues() {
|
|
3649
|
+
const field = this.params.colDef.field;
|
|
3650
|
+
const values = new Set();
|
|
3651
|
+
this.params.api.forEachNode((node) => {
|
|
3652
|
+
const data = node.data;
|
|
3653
|
+
const cellValue = data?.[field];
|
|
3654
|
+
if (data &&
|
|
3655
|
+
typeof data === 'object' &&
|
|
3656
|
+
field in data &&
|
|
3657
|
+
typeof cellValue === 'string' &&
|
|
3658
|
+
cellValue !== undefined &&
|
|
3659
|
+
cellValue !== null) {
|
|
3660
|
+
values.add(cellValue);
|
|
3661
|
+
}
|
|
3662
|
+
});
|
|
3663
|
+
return Array.from(values).sort();
|
|
3664
|
+
}
|
|
3665
|
+
init(params) {
|
|
3666
|
+
this.params = params;
|
|
3667
|
+
this.labels = { ...params.labels };
|
|
3668
|
+
this.labelFormatter = params.labelFormatter;
|
|
3669
|
+
this.allValues = this.loadFieldValues();
|
|
3670
|
+
this.gui = document.createElement('div');
|
|
3671
|
+
this.reactRoot = client.createRoot(this.gui);
|
|
3672
|
+
this.render();
|
|
3673
|
+
}
|
|
3674
|
+
render() {
|
|
3675
|
+
if (!this.reactRoot)
|
|
3676
|
+
return;
|
|
3677
|
+
this.reactRoot.render(jsxRuntime.jsx(FilterUI, { allValues: this.allValues, selected: this.selectedValues, labels: this.labels, labelFormatter: this.labelFormatter, onToggleAll: this.handleToggleAll.bind(this), onToggleOne: this.handleToggleOne.bind(this) }));
|
|
3678
|
+
}
|
|
3679
|
+
handleToggleAll(checked) {
|
|
3680
|
+
if (checked) {
|
|
3681
|
+
this.allValues.forEach((val) => this.selectedValues.add(val));
|
|
3682
|
+
}
|
|
3683
|
+
else {
|
|
3684
|
+
this.selectedValues.clear();
|
|
3685
|
+
}
|
|
3686
|
+
this.render();
|
|
3687
|
+
this.params.filterChangedCallback();
|
|
3688
|
+
}
|
|
3689
|
+
handleToggleOne(value, checked) {
|
|
3690
|
+
if (checked) {
|
|
3691
|
+
this.selectedValues.add(value);
|
|
3692
|
+
}
|
|
3693
|
+
else {
|
|
3694
|
+
this.selectedValues.delete(value);
|
|
3695
|
+
}
|
|
3696
|
+
this.render();
|
|
3697
|
+
this.params.filterChangedCallback();
|
|
3698
|
+
}
|
|
3699
|
+
getGui() {
|
|
3700
|
+
return this.gui;
|
|
3701
|
+
}
|
|
3702
|
+
isFilterActive() {
|
|
3703
|
+
return this.selectedValues.size > 0;
|
|
3704
|
+
}
|
|
3705
|
+
doesFilterPass(params) {
|
|
3706
|
+
const field = this.params.colDef.field;
|
|
3707
|
+
if (!params.data || typeof params.data !== 'object' || !(field in params.data)) {
|
|
3708
|
+
return false;
|
|
3709
|
+
}
|
|
3710
|
+
const cellValue = params.data[field];
|
|
3711
|
+
if (typeof cellValue !== 'string') {
|
|
3712
|
+
return false;
|
|
3713
|
+
}
|
|
3714
|
+
return this.selectedValues.has(cellValue);
|
|
3715
|
+
}
|
|
3716
|
+
getModel() {
|
|
3717
|
+
return this.selectedValues.size > 0 ? { values: Array.from(this.selectedValues) } : null;
|
|
3718
|
+
}
|
|
3719
|
+
setModel(model) {
|
|
3720
|
+
this.selectedValues = new Set(model?.values || []);
|
|
3721
|
+
this.render();
|
|
3722
|
+
}
|
|
3723
|
+
destroy() {
|
|
3724
|
+
if (this.reactRoot) {
|
|
3725
|
+
this.reactRoot.unmount();
|
|
3726
|
+
this.reactRoot = null;
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
const createCheckboxMultiFilterParams = (labels = {}, labelFormatter) => ({
|
|
3731
|
+
labels,
|
|
3732
|
+
labelFormatter,
|
|
3733
|
+
});
|
|
3734
|
+
|
|
3601
3735
|
const GridFilterHeaderIconButton = React.forwardRef(function columnsButton({ icon, title, onClick, buttonProps, disabled = false, size = 'md' }, ref) {
|
|
3602
3736
|
return (jsxRuntime.jsx(lui.LuiButton, { ...buttonProps, type: 'button', level: 'tertiary', className: 'lui-button-icon-only', ref: ref, buttonProps: { 'aria-label': title }, title: title, onClick: onClick, disabled: disabled, children: jsxRuntime.jsx(lui.LuiIcon, { name: icon, alt: 'Menu', size: size }) }));
|
|
3603
3737
|
});
|
|
@@ -3865,33 +3999,6 @@ const GridSubComponentContext = React.createContext({
|
|
|
3865
3999
|
context: null,
|
|
3866
4000
|
});
|
|
3867
4001
|
|
|
3868
|
-
function styleInject(css, ref) {
|
|
3869
|
-
if ( ref === void 0 ) ref = {};
|
|
3870
|
-
var insertAt = ref.insertAt;
|
|
3871
|
-
|
|
3872
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
3873
|
-
|
|
3874
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
3875
|
-
var style = document.createElement('style');
|
|
3876
|
-
style.type = 'text/css';
|
|
3877
|
-
|
|
3878
|
-
if (insertAt === 'top') {
|
|
3879
|
-
if (head.firstChild) {
|
|
3880
|
-
head.insertBefore(style, head.firstChild);
|
|
3881
|
-
} else {
|
|
3882
|
-
head.appendChild(style);
|
|
3883
|
-
}
|
|
3884
|
-
} else {
|
|
3885
|
-
head.appendChild(style);
|
|
3886
|
-
}
|
|
3887
|
-
|
|
3888
|
-
if (style.styleSheet) {
|
|
3889
|
-
style.styleSheet.cssText = css;
|
|
3890
|
-
} else {
|
|
3891
|
-
style.appendChild(document.createTextNode(css));
|
|
3892
|
-
}
|
|
3893
|
-
}
|
|
3894
|
-
|
|
3895
4002
|
var css_248z$2 = ".FormError{display:flex}.FormError-helpText{color:#6b6966;font-size:.75rem;font-weight:400}.FormError-text-icon{margin-right:4px;margin-top:4px}.FormError-error{align-items:center;color:#2a292c;font-size:14px;font-weight:600;padding-left:0}";
|
|
3896
4003
|
styleInject(css_248z$2);
|
|
3897
4004
|
|
|
@@ -6027,6 +6134,7 @@ exports.GridContext = GridContext;
|
|
|
6027
6134
|
exports.GridContextProvider = GridContextProvider;
|
|
6028
6135
|
exports.GridEditBoolean = GridEditBoolean;
|
|
6029
6136
|
exports.GridFilterButtons = GridFilterButtons;
|
|
6137
|
+
exports.GridFilterColumnsMultiSelect = GridFilterColumnsMultiSelect;
|
|
6030
6138
|
exports.GridFilterColumnsToggle = GridFilterColumnsToggle;
|
|
6031
6139
|
exports.GridFilterDownloadCsvButton = GridFilterDownloadCsvButton;
|
|
6032
6140
|
exports.GridFilterHeaderIconButton = GridFilterHeaderIconButton;
|
|
@@ -6087,6 +6195,7 @@ exports.bearingRangeValidator = bearingRangeValidator;
|
|
|
6087
6195
|
exports.bearingStringValidator = bearingStringValidator;
|
|
6088
6196
|
exports.bearingValueFormatter = bearingValueFormatter;
|
|
6089
6197
|
exports.convertDDToDMS = convertDDToDMS;
|
|
6198
|
+
exports.createCheckboxMultiFilterParams = createCheckboxMultiFilterParams;
|
|
6090
6199
|
exports.defaultValueFormatter = defaultValueFormatter;
|
|
6091
6200
|
exports.downloadCsvUseValueFormattersProcessCellCallback = downloadCsvUseValueFormattersProcessCellCallback;
|
|
6092
6201
|
exports.findParentWithClass = findParentWithClass;
|