@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.
@@ -143,6 +143,18 @@ $grid-base-font-size: calc(#{lui.$base-font-size} - 1px);
143
143
  overflow-x: auto;
144
144
  }
145
145
 
146
+ .ag-icon-filter {
147
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232A292C'%3E%3Cpath d='M6 12.984v-1.969h12v1.969zM3 6h18v2.016H3zm6.984 12v-2.016h4.031V18z'/%3E%3C/svg%3E") !important;
148
+ background-repeat: no-repeat;
149
+ background-position: center;
150
+ background-size: contain;
151
+ background-color: transparent;
152
+
153
+ &::before {
154
+ content: none !important;
155
+ }
156
+ }
157
+
146
158
  .ag-header-group-cell {
147
159
  text-transform: uppercase;
148
160
  font-size: 12px;
@@ -265,4 +277,4 @@ $grid-base-font-size: calc(#{lui.$base-font-size} - 1px);
265
277
  .ag-header-cell {
266
278
  font-size: 14px;
267
279
  }
268
- }
280
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './GridFilterButtons';
2
+ export * from './GridFilterColumnsMultiSelect';
2
3
  export * from './GridFilterColumnsToggle';
3
4
  export * from './GridFilterDownloadCsvButton';
4
5
  export * from './GridFilterHeaderIconButton';
@@ -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,140 @@ 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 .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}";
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.selectedValues = new Set(this.allValues);
3671
+ this.gui = document.createElement('div');
3672
+ this.reactRoot = client.createRoot(this.gui);
3673
+ this.render();
3674
+ }
3675
+ render() {
3676
+ if (!this.reactRoot)
3677
+ return;
3678
+ 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) }));
3679
+ }
3680
+ handleToggleAll(checked) {
3681
+ if (checked) {
3682
+ this.allValues.forEach((val) => this.selectedValues.add(val));
3683
+ }
3684
+ else {
3685
+ this.selectedValues.clear();
3686
+ }
3687
+ this.render();
3688
+ this.params.filterChangedCallback();
3689
+ }
3690
+ handleToggleOne(value, checked) {
3691
+ if (checked) {
3692
+ this.selectedValues.add(value);
3693
+ }
3694
+ else {
3695
+ this.selectedValues.delete(value);
3696
+ }
3697
+ this.render();
3698
+ this.params.filterChangedCallback();
3699
+ }
3700
+ getGui() {
3701
+ return this.gui;
3702
+ }
3703
+ isFilterActive() {
3704
+ return this.selectedValues.size > 0;
3705
+ }
3706
+ doesFilterPass(params) {
3707
+ const field = this.params.colDef.field;
3708
+ if (!params.data || typeof params.data !== 'object' || !(field in params.data)) {
3709
+ return false;
3710
+ }
3711
+ const cellValue = params.data[field];
3712
+ if (typeof cellValue !== 'string') {
3713
+ return false;
3714
+ }
3715
+ return this.selectedValues.has(cellValue);
3716
+ }
3717
+ getModel() {
3718
+ return this.selectedValues.size > 0 ? { values: Array.from(this.selectedValues) } : null;
3719
+ }
3720
+ setModel(model) {
3721
+ this.selectedValues = new Set(model?.values || []);
3722
+ this.render();
3723
+ }
3724
+ destroy() {
3725
+ if (this.reactRoot) {
3726
+ this.reactRoot.unmount();
3727
+ this.reactRoot = null;
3728
+ }
3729
+ }
3730
+ }
3731
+ const createCheckboxMultiFilterParams = (labels = {}, labelFormatter) => ({
3732
+ labels,
3733
+ labelFormatter,
3734
+ });
3735
+
3601
3736
  const GridFilterHeaderIconButton = React.forwardRef(function columnsButton({ icon, title, onClick, buttonProps, disabled = false, size = 'md' }, ref) {
3602
3737
  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
3738
  });
@@ -3865,33 +4000,6 @@ const GridSubComponentContext = React.createContext({
3865
4000
  context: null,
3866
4001
  });
3867
4002
 
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
4003
  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
4004
  styleInject(css_248z$2);
3897
4005
 
@@ -6027,6 +6135,7 @@ exports.GridContext = GridContext;
6027
6135
  exports.GridContextProvider = GridContextProvider;
6028
6136
  exports.GridEditBoolean = GridEditBoolean;
6029
6137
  exports.GridFilterButtons = GridFilterButtons;
6138
+ exports.GridFilterColumnsMultiSelect = GridFilterColumnsMultiSelect;
6030
6139
  exports.GridFilterColumnsToggle = GridFilterColumnsToggle;
6031
6140
  exports.GridFilterDownloadCsvButton = GridFilterDownloadCsvButton;
6032
6141
  exports.GridFilterHeaderIconButton = GridFilterHeaderIconButton;
@@ -6087,6 +6196,7 @@ exports.bearingRangeValidator = bearingRangeValidator;
6087
6196
  exports.bearingStringValidator = bearingStringValidator;
6088
6197
  exports.bearingValueFormatter = bearingValueFormatter;
6089
6198
  exports.convertDDToDMS = convertDDToDMS;
6199
+ exports.createCheckboxMultiFilterParams = createCheckboxMultiFilterParams;
6090
6200
  exports.defaultValueFormatter = defaultValueFormatter;
6091
6201
  exports.downloadCsvUseValueFormattersProcessCellCallback = downloadCsvUseValueFormattersProcessCellCallback;
6092
6202
  exports.findParentWithClass = findParentWithClass;