@linzjs/step-ag-grid 29.6.0 → 29.8.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.
@@ -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,140 @@ 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 .LuiSelect-label-text{color:#6b6966;display:inline-block}.GridFilterColsMultiSelect .LuiCheckboxInput-item,.GridFilterColsMultiSelect .LuiCheckboxInput-selectAll{color:#2a292c;font-size:16px;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.selectedValues = new Set(this.allValues);
3669
+ this.gui = document.createElement('div');
3670
+ this.reactRoot = createRoot(this.gui);
3671
+ this.render();
3672
+ }
3673
+ render() {
3674
+ if (!this.reactRoot)
3675
+ return;
3676
+ 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) }));
3677
+ }
3678
+ handleToggleAll(checked) {
3679
+ if (checked) {
3680
+ this.allValues.forEach((val) => this.selectedValues.add(val));
3681
+ }
3682
+ else {
3683
+ this.selectedValues.clear();
3684
+ }
3685
+ this.render();
3686
+ this.params.filterChangedCallback();
3687
+ }
3688
+ handleToggleOne(value, checked) {
3689
+ if (checked) {
3690
+ this.selectedValues.add(value);
3691
+ }
3692
+ else {
3693
+ this.selectedValues.delete(value);
3694
+ }
3695
+ this.render();
3696
+ this.params.filterChangedCallback();
3697
+ }
3698
+ getGui() {
3699
+ return this.gui;
3700
+ }
3701
+ isFilterActive() {
3702
+ return this.selectedValues.size > 0;
3703
+ }
3704
+ doesFilterPass(params) {
3705
+ const field = this.params.colDef.field;
3706
+ if (!params.data || typeof params.data !== 'object' || !(field in params.data)) {
3707
+ return false;
3708
+ }
3709
+ const cellValue = params.data[field];
3710
+ if (typeof cellValue !== 'string') {
3711
+ return false;
3712
+ }
3713
+ return this.selectedValues.has(cellValue);
3714
+ }
3715
+ getModel() {
3716
+ return this.selectedValues.size > 0 ? { values: Array.from(this.selectedValues) } : null;
3717
+ }
3718
+ setModel(model) {
3719
+ this.selectedValues = new Set(model?.values || []);
3720
+ this.render();
3721
+ }
3722
+ destroy() {
3723
+ if (this.reactRoot) {
3724
+ this.reactRoot.unmount();
3725
+ this.reactRoot = null;
3726
+ }
3727
+ }
3728
+ }
3729
+ const createCheckboxMultiFilterParams = (labels = {}, labelFormatter) => ({
3730
+ labels,
3731
+ labelFormatter,
3732
+ });
3733
+
3599
3734
  const GridFilterHeaderIconButton = forwardRef(function columnsButton({ icon, title, onClick, buttonProps, disabled = false, size = 'md' }, ref) {
3600
3735
  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
3736
  });
@@ -3863,33 +3998,6 @@ const GridSubComponentContext = createContext({
3863
3998
  context: null,
3864
3999
  });
3865
4000
 
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
4001
  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
4002
  styleInject(css_248z$2);
3895
4003
 
@@ -6005,5 +6113,5 @@ const useDeferredPromise = () => {
6005
6113
  };
6006
6114
  };
6007
6115
 
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 };
6116
+ 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
6117
  //# sourceMappingURL=step-ag-grid.esm.js.map