@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
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -5,6 +5,7 @@ import { AgGridReact } from 'ag-grid-react';
|
|
|
5
5
|
import { negate, isEmpty, findIndex, defer, debounce as debounce$1, xorBy, last, difference, delay, omit, sortBy, partition, compact, pick, groupBy, fromPairs, toPairs, isEqual, pull, filter, sumBy, remove, flatten, castArray } from 'lodash-es';
|
|
6
6
|
import React, { useRef, useLayoutEffect, useEffect, createContext, useContext, useState, useMemo, memo, forwardRef, useCallback, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1, useId } from 'react';
|
|
7
7
|
import { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
|
|
8
|
+
import { createRoot } from 'react-dom/client';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* If loading is true this returns a loading spinner, otherwise it returns its children.
|
|
@@ -3596,6 +3597,139 @@ const GridFilterButtons = ({ className, luiButtonProps, options, }) => {
|
|
|
3596
3597
|
return (jsx("div", { className: clsx(className, 'flex-col-center'), children: jsx(LuiButtonGroup, { children: options.map((option, index) => (jsx(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}`))) }) }));
|
|
3597
3598
|
};
|
|
3598
3599
|
|
|
3600
|
+
function styleInject(css, ref) {
|
|
3601
|
+
if ( ref === void 0 ) ref = {};
|
|
3602
|
+
var insertAt = ref.insertAt;
|
|
3603
|
+
|
|
3604
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
3605
|
+
|
|
3606
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
3607
|
+
var style = document.createElement('style');
|
|
3608
|
+
style.type = 'text/css';
|
|
3609
|
+
|
|
3610
|
+
if (insertAt === 'top') {
|
|
3611
|
+
if (head.firstChild) {
|
|
3612
|
+
head.insertBefore(style, head.firstChild);
|
|
3613
|
+
} else {
|
|
3614
|
+
head.appendChild(style);
|
|
3615
|
+
}
|
|
3616
|
+
} else {
|
|
3617
|
+
head.appendChild(style);
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3620
|
+
if (style.styleSheet) {
|
|
3621
|
+
style.styleSheet.cssText = css;
|
|
3622
|
+
} else {
|
|
3623
|
+
style.appendChild(document.createTextNode(css));
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3627
|
+
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}";
|
|
3628
|
+
styleInject(css_248z$3);
|
|
3629
|
+
|
|
3630
|
+
const FilterUI = ({ allValues, selected, labels, labelFormatter, onToggleAll, onToggleOne, }) => {
|
|
3631
|
+
const allChecked = allValues.length > 0 && selected.size === allValues.length;
|
|
3632
|
+
const getDisplayLabel = (raw) => {
|
|
3633
|
+
const mapped = labels[raw] ?? raw;
|
|
3634
|
+
return labelFormatter ? labelFormatter(mapped) : mapped;
|
|
3635
|
+
};
|
|
3636
|
+
return (jsxs("div", { className: "GridFilterColsMultiSelect", children: [jsx("span", { className: "LuiSelect-label-text", children: "Filter column" }), jsx(LuiCheckboxInput, { className: "LuiCheckboxInput-selectAll", label: 'Select All', value: "true", isChecked: allChecked, onChange: (e) => onToggleAll(e.target.checked) }), allValues.map((val) => (jsx(LuiCheckboxInput, { className: "LuiCheckboxInput-item", label: getDisplayLabel(val), value: val, isChecked: selected.has(val), onChange: (e) => onToggleOne(val, e.target.checked) }, val)))] }));
|
|
3637
|
+
};
|
|
3638
|
+
class GridFilterColumnsMultiSelect {
|
|
3639
|
+
params;
|
|
3640
|
+
selectedValues = new Set();
|
|
3641
|
+
labels = {};
|
|
3642
|
+
allValues = [];
|
|
3643
|
+
gui;
|
|
3644
|
+
labelFormatter;
|
|
3645
|
+
reactRoot = null;
|
|
3646
|
+
loadFieldValues() {
|
|
3647
|
+
const field = this.params.colDef.field;
|
|
3648
|
+
const values = new Set();
|
|
3649
|
+
this.params.api.forEachNode((node) => {
|
|
3650
|
+
const data = node.data;
|
|
3651
|
+
const cellValue = data?.[field];
|
|
3652
|
+
if (data &&
|
|
3653
|
+
typeof data === 'object' &&
|
|
3654
|
+
field in data &&
|
|
3655
|
+
typeof cellValue === 'string' &&
|
|
3656
|
+
cellValue !== undefined &&
|
|
3657
|
+
cellValue !== null) {
|
|
3658
|
+
values.add(cellValue);
|
|
3659
|
+
}
|
|
3660
|
+
});
|
|
3661
|
+
return Array.from(values).sort();
|
|
3662
|
+
}
|
|
3663
|
+
init(params) {
|
|
3664
|
+
this.params = params;
|
|
3665
|
+
this.labels = { ...params.labels };
|
|
3666
|
+
this.labelFormatter = params.labelFormatter;
|
|
3667
|
+
this.allValues = this.loadFieldValues();
|
|
3668
|
+
this.gui = document.createElement('div');
|
|
3669
|
+
this.reactRoot = createRoot(this.gui);
|
|
3670
|
+
this.render();
|
|
3671
|
+
}
|
|
3672
|
+
render() {
|
|
3673
|
+
if (!this.reactRoot)
|
|
3674
|
+
return;
|
|
3675
|
+
this.reactRoot.render(jsx(FilterUI, { allValues: this.allValues, selected: this.selectedValues, labels: this.labels, labelFormatter: this.labelFormatter, onToggleAll: this.handleToggleAll.bind(this), onToggleOne: this.handleToggleOne.bind(this) }));
|
|
3676
|
+
}
|
|
3677
|
+
handleToggleAll(checked) {
|
|
3678
|
+
if (checked) {
|
|
3679
|
+
this.allValues.forEach((val) => this.selectedValues.add(val));
|
|
3680
|
+
}
|
|
3681
|
+
else {
|
|
3682
|
+
this.selectedValues.clear();
|
|
3683
|
+
}
|
|
3684
|
+
this.render();
|
|
3685
|
+
this.params.filterChangedCallback();
|
|
3686
|
+
}
|
|
3687
|
+
handleToggleOne(value, checked) {
|
|
3688
|
+
if (checked) {
|
|
3689
|
+
this.selectedValues.add(value);
|
|
3690
|
+
}
|
|
3691
|
+
else {
|
|
3692
|
+
this.selectedValues.delete(value);
|
|
3693
|
+
}
|
|
3694
|
+
this.render();
|
|
3695
|
+
this.params.filterChangedCallback();
|
|
3696
|
+
}
|
|
3697
|
+
getGui() {
|
|
3698
|
+
return this.gui;
|
|
3699
|
+
}
|
|
3700
|
+
isFilterActive() {
|
|
3701
|
+
return this.selectedValues.size > 0;
|
|
3702
|
+
}
|
|
3703
|
+
doesFilterPass(params) {
|
|
3704
|
+
const field = this.params.colDef.field;
|
|
3705
|
+
if (!params.data || typeof params.data !== 'object' || !(field in params.data)) {
|
|
3706
|
+
return false;
|
|
3707
|
+
}
|
|
3708
|
+
const cellValue = params.data[field];
|
|
3709
|
+
if (typeof cellValue !== 'string') {
|
|
3710
|
+
return false;
|
|
3711
|
+
}
|
|
3712
|
+
return this.selectedValues.has(cellValue);
|
|
3713
|
+
}
|
|
3714
|
+
getModel() {
|
|
3715
|
+
return this.selectedValues.size > 0 ? { values: Array.from(this.selectedValues) } : null;
|
|
3716
|
+
}
|
|
3717
|
+
setModel(model) {
|
|
3718
|
+
this.selectedValues = new Set(model?.values || []);
|
|
3719
|
+
this.render();
|
|
3720
|
+
}
|
|
3721
|
+
destroy() {
|
|
3722
|
+
if (this.reactRoot) {
|
|
3723
|
+
this.reactRoot.unmount();
|
|
3724
|
+
this.reactRoot = null;
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
const createCheckboxMultiFilterParams = (labels = {}, labelFormatter) => ({
|
|
3729
|
+
labels,
|
|
3730
|
+
labelFormatter,
|
|
3731
|
+
});
|
|
3732
|
+
|
|
3599
3733
|
const GridFilterHeaderIconButton = forwardRef(function columnsButton({ icon, title, onClick, buttonProps, disabled = false, size = 'md' }, ref) {
|
|
3600
3734
|
return (jsx(LuiButton, { ...buttonProps, type: 'button', level: 'tertiary', className: 'lui-button-icon-only', ref: ref, buttonProps: { 'aria-label': title }, title: title, onClick: onClick, disabled: disabled, children: jsx(LuiIcon, { name: icon, alt: 'Menu', size: size }) }));
|
|
3601
3735
|
});
|
|
@@ -3863,33 +3997,6 @@ const GridSubComponentContext = createContext({
|
|
|
3863
3997
|
context: null,
|
|
3864
3998
|
});
|
|
3865
3999
|
|
|
3866
|
-
function styleInject(css, ref) {
|
|
3867
|
-
if ( ref === void 0 ) ref = {};
|
|
3868
|
-
var insertAt = ref.insertAt;
|
|
3869
|
-
|
|
3870
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
3871
|
-
|
|
3872
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
3873
|
-
var style = document.createElement('style');
|
|
3874
|
-
style.type = 'text/css';
|
|
3875
|
-
|
|
3876
|
-
if (insertAt === 'top') {
|
|
3877
|
-
if (head.firstChild) {
|
|
3878
|
-
head.insertBefore(style, head.firstChild);
|
|
3879
|
-
} else {
|
|
3880
|
-
head.appendChild(style);
|
|
3881
|
-
}
|
|
3882
|
-
} else {
|
|
3883
|
-
head.appendChild(style);
|
|
3884
|
-
}
|
|
3885
|
-
|
|
3886
|
-
if (style.styleSheet) {
|
|
3887
|
-
style.styleSheet.cssText = css;
|
|
3888
|
-
} else {
|
|
3889
|
-
style.appendChild(document.createTextNode(css));
|
|
3890
|
-
}
|
|
3891
|
-
}
|
|
3892
|
-
|
|
3893
4000
|
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}";
|
|
3894
4001
|
styleInject(css_248z$2);
|
|
3895
4002
|
|
|
@@ -6005,5 +6112,5 @@ const useDeferredPromise = () => {
|
|
|
6005
6112
|
};
|
|
6006
6113
|
};
|
|
6007
6114
|
|
|
6008
|
-
export { ActionButton, CancelPromise, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridButton, GridCell, GridCellFiller, GridCellFillerColId, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridEditBoolean, GridFilterButtons, GridFilterColumnsToggle, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridIcon, GridLoadableCell, GridNoRowsOverlay, GridNoRowsOverlayFr, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, TextInputValidator, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, convertDDToDMS, defaultValueFormatter, downloadCsvUseValueFormattersProcessCellCallback, findParentWithClass, fnOrVar, generateFilterGetter, hasParentClass, isFloat, isGridCellFiller, isNotEmpty, primitiveToSelectOption, sanitiseFileName, stringByteLengthIsInvalid, suppressCellKeyboardEvents, textMatch, useDeferredPromise, useGridContext, useGridContextMenu, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait, waitForCondition };
|
|
6115
|
+
export { ActionButton, CancelPromise, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridButton, GridCell, GridCellFiller, GridCellFillerColId, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridEditBoolean, GridFilterButtons, GridFilterColumnsMultiSelect, GridFilterColumnsToggle, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridIcon, GridLoadableCell, GridNoRowsOverlay, GridNoRowsOverlayFr, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, TextInputValidator, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, convertDDToDMS, createCheckboxMultiFilterParams, defaultValueFormatter, downloadCsvUseValueFormattersProcessCellCallback, findParentWithClass, fnOrVar, generateFilterGetter, hasParentClass, isFloat, isGridCellFiller, isNotEmpty, primitiveToSelectOption, sanitiseFileName, stringByteLengthIsInvalid, suppressCellKeyboardEvents, textMatch, useDeferredPromise, useGridContext, useGridContextMenu, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait, waitForCondition };
|
|
6009
6116
|
//# sourceMappingURL=step-ag-grid.esm.js.map
|