@linzjs/step-ag-grid 29.1.3 → 29.1.5
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/step-ag-grid.cjs +79 -63
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +80 -64
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +87 -61
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +0 -1
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -3801,6 +3801,19 @@ const FormError = (props) => {
|
|
|
3801
3801
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.error && (jsxRuntime.jsxs("div", { className: "FormError", children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "error", name: "ic_error", className: "FormError-text-icon", size: "sm", status: "error" }), jsxRuntime.jsx("span", { className: "FormError-error", children: props.error })] })), props.helpText && !props.error && jsxRuntime.jsx("span", { className: 'FormError-helpText', children: props.helpText })] }));
|
|
3802
3802
|
};
|
|
3803
3803
|
|
|
3804
|
+
/**
|
|
3805
|
+
* Track previous values of states.
|
|
3806
|
+
*
|
|
3807
|
+
* @param value Value to track.
|
|
3808
|
+
*/
|
|
3809
|
+
const usePrevious = (value) => {
|
|
3810
|
+
const ref = React.useRef();
|
|
3811
|
+
React.useEffect(() => {
|
|
3812
|
+
ref.current = value;
|
|
3813
|
+
}, [value]);
|
|
3814
|
+
return ref.current;
|
|
3815
|
+
};
|
|
3816
|
+
|
|
3804
3817
|
function escapeStringRegexp(string) {
|
|
3805
3818
|
if (typeof string !== 'string') {
|
|
3806
3819
|
throw new TypeError('Expected a string');
|
|
@@ -4017,10 +4030,11 @@ const fieldToString = (field) => {
|
|
|
4017
4030
|
};
|
|
4018
4031
|
const GridFormDropDown = (props) => {
|
|
4019
4032
|
const { selectedRows, field, data } = useGridPopoverContext();
|
|
4033
|
+
const { onSelectFilter, options: propOptions, onSelectedItem } = props;
|
|
4020
4034
|
// Save triggers during async action processing which triggers another selectItem(), this ref blocks that
|
|
4021
4035
|
const [filter, setFilter] = React.useState(props.filterDefaultValue ?? '');
|
|
4022
4036
|
const [filteredValues, setFilteredValues] = React.useState();
|
|
4023
|
-
const [options, setOptions] = React.useState(null);
|
|
4037
|
+
const [options, setOptions] = React.useState(!!propOptions && typeof propOptions !== 'function' ? propOptions : null);
|
|
4024
4038
|
const subComponentIsValid = React.useRef(false);
|
|
4025
4039
|
const subComponentInitialValue = React.useRef(null);
|
|
4026
4040
|
const [subSelectedValue, setSubSelectedValue] = React.useState(null);
|
|
@@ -4030,8 +4044,8 @@ const GridFormDropDown = (props) => {
|
|
|
4030
4044
|
const hasChanged = selectedRows.some((row) => row[field] !== value) ||
|
|
4031
4045
|
(subComponentValue !== undefined && subComponentInitialValue.current !== JSON.stringify(subComponentValue));
|
|
4032
4046
|
if (hasChanged) {
|
|
4033
|
-
if (
|
|
4034
|
-
await
|
|
4047
|
+
if (onSelectedItem) {
|
|
4048
|
+
await onSelectedItem({
|
|
4035
4049
|
selectedRows,
|
|
4036
4050
|
selectedRowIds: selectedRows.map((row) => row.id),
|
|
4037
4051
|
value,
|
|
@@ -4043,58 +4057,17 @@ const GridFormDropDown = (props) => {
|
|
|
4043
4057
|
}
|
|
4044
4058
|
}
|
|
4045
4059
|
return true;
|
|
4046
|
-
}, [field,
|
|
4047
|
-
// Load up options list if it's async function
|
|
4048
|
-
React.useEffect(() => {
|
|
4049
|
-
if (options)
|
|
4050
|
-
return;
|
|
4051
|
-
let optionsConf = props.options;
|
|
4052
|
-
void (async () => {
|
|
4053
|
-
if (typeof optionsConf === 'function') {
|
|
4054
|
-
optionsConf = await optionsConf(selectedRows, filter);
|
|
4055
|
-
}
|
|
4056
|
-
if (optionsConf !== undefined) {
|
|
4057
|
-
setOptions(optionsConf);
|
|
4058
|
-
}
|
|
4059
|
-
})();
|
|
4060
|
-
}, [filter, options, props, selectedRows]);
|
|
4061
|
-
// Local filtering.
|
|
4062
|
-
React.useEffect(() => {
|
|
4063
|
-
if (props.filtered == 'local') {
|
|
4064
|
-
if (options == null)
|
|
4065
|
-
return;
|
|
4066
|
-
setFilteredValues(options
|
|
4067
|
-
.map((option) => {
|
|
4068
|
-
if (option.label != null && typeof option.label !== 'string') {
|
|
4069
|
-
console.error('Cannot filter non-string labels', option);
|
|
4070
|
-
return undefined;
|
|
4071
|
-
}
|
|
4072
|
-
return textMatch(option.label || '', filter) ? option : undefined;
|
|
4073
|
-
})
|
|
4074
|
-
.filter((r) => r !== undefined));
|
|
4075
|
-
}
|
|
4076
|
-
}, [props.filtered, filter, options]);
|
|
4077
|
-
const reSearchOnFilterChange = React.useMemo(() => debounce(() => {
|
|
4078
|
-
setOptions(null);
|
|
4079
|
-
}, 500), []);
|
|
4080
|
-
const previousFilter = React.useRef(filter);
|
|
4081
|
-
// Reload filtering.
|
|
4082
|
-
React.useEffect(() => {
|
|
4083
|
-
if (previousFilter.current != filter && props.filtered == 'reload') {
|
|
4084
|
-
previousFilter.current = filter;
|
|
4085
|
-
void reSearchOnFilterChange();
|
|
4086
|
-
}
|
|
4087
|
-
}, [filter, props, reSearchOnFilterChange]);
|
|
4060
|
+
}, [field, onSelectedItem, selectedRows]);
|
|
4088
4061
|
/**
|
|
4089
4062
|
* Saves are wrapped in updateValue and triggered by blur events
|
|
4090
4063
|
*/
|
|
4091
4064
|
const save = React.useCallback(async () => {
|
|
4092
|
-
if (!options)
|
|
4065
|
+
if (!options) {
|
|
4093
4066
|
return true;
|
|
4067
|
+
}
|
|
4094
4068
|
// Filter saved
|
|
4095
4069
|
if (selectedItem === null) {
|
|
4096
|
-
if (
|
|
4097
|
-
const { onSelectFilter } = props;
|
|
4070
|
+
if (onSelectFilter) {
|
|
4098
4071
|
if (!lodashEs.isEmpty(filter)) {
|
|
4099
4072
|
await onSelectFilter({
|
|
4100
4073
|
selectedRows,
|
|
@@ -4113,17 +4086,73 @@ const GridFormDropDown = (props) => {
|
|
|
4113
4086
|
}
|
|
4114
4087
|
return false;
|
|
4115
4088
|
}
|
|
4116
|
-
if (selectedItem.subComponent && !subComponentIsValid.current)
|
|
4089
|
+
if (selectedItem.subComponent && !subComponentIsValid.current) {
|
|
4117
4090
|
return false;
|
|
4091
|
+
}
|
|
4118
4092
|
await selectItemHandler(selectedItem.value, subSelectedValue);
|
|
4119
4093
|
return true;
|
|
4120
|
-
}, [
|
|
4094
|
+
}, [
|
|
4095
|
+
filter,
|
|
4096
|
+
filteredValues,
|
|
4097
|
+
onSelectFilter,
|
|
4098
|
+
options,
|
|
4099
|
+
selectItemHandler,
|
|
4100
|
+
selectedItem,
|
|
4101
|
+
selectedRows,
|
|
4102
|
+
subSelectedValue,
|
|
4103
|
+
]);
|
|
4121
4104
|
const { popoverWrapper } = useGridPopoverHook({
|
|
4122
4105
|
className: props.className,
|
|
4123
4106
|
invalid: () => !options || !!(selectedItem && !subComponentIsValid.current),
|
|
4124
4107
|
save,
|
|
4125
4108
|
dontSaveOnExternalClick: true,
|
|
4126
4109
|
});
|
|
4110
|
+
// Load up options list if it's async function
|
|
4111
|
+
React.useEffect(() => {
|
|
4112
|
+
// If options is null then we need to load/reload
|
|
4113
|
+
// Options will be set to null during a reload based filter, or on open popup
|
|
4114
|
+
if (options !== null) {
|
|
4115
|
+
return;
|
|
4116
|
+
}
|
|
4117
|
+
// propOptions is a const list
|
|
4118
|
+
if (typeof propOptions !== 'function') {
|
|
4119
|
+
if (propOptions) {
|
|
4120
|
+
setOptions(propOptions);
|
|
4121
|
+
}
|
|
4122
|
+
return;
|
|
4123
|
+
}
|
|
4124
|
+
// propOptions is function, probably loading from web
|
|
4125
|
+
void (async () => {
|
|
4126
|
+
const r = await propOptions(selectedRows, filter);
|
|
4127
|
+
setOptions(r ?? []);
|
|
4128
|
+
})();
|
|
4129
|
+
}, [filter, options, propOptions, selectedRows]);
|
|
4130
|
+
// Local filtering.
|
|
4131
|
+
React.useEffect(() => {
|
|
4132
|
+
if (props.filtered !== 'local') {
|
|
4133
|
+
return;
|
|
4134
|
+
}
|
|
4135
|
+
if (options == null) {
|
|
4136
|
+
setFilteredValues([]);
|
|
4137
|
+
return;
|
|
4138
|
+
}
|
|
4139
|
+
setFilteredValues(lodashEs.compact(options.map((option) => {
|
|
4140
|
+
if (option.label != null && typeof option.label !== 'string') {
|
|
4141
|
+
console.warn('GridFormDropDown: Cannot filter non-string labels', option);
|
|
4142
|
+
return undefined;
|
|
4143
|
+
}
|
|
4144
|
+
return textMatch(option.label || '', filter) ? option : undefined;
|
|
4145
|
+
})));
|
|
4146
|
+
}, [props.filtered, filter, options]);
|
|
4147
|
+
const reSearchOnFilterChange = React.useMemo(() => debounce(() => {
|
|
4148
|
+
setOptions(null);
|
|
4149
|
+
}, 500), []);
|
|
4150
|
+
const previousFilter = usePrevious(filter);
|
|
4151
|
+
React.useEffect(() => {
|
|
4152
|
+
if (previousFilter != null && previousFilter != filter && props.filtered === 'reload') {
|
|
4153
|
+
void reSearchOnFilterChange();
|
|
4154
|
+
}
|
|
4155
|
+
}, [filter, previousFilter, props.filtered, reSearchOnFilterChange]);
|
|
4127
4156
|
let lastHeader = null;
|
|
4128
4157
|
let showHeader = null;
|
|
4129
4158
|
return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.filtered && (jsxRuntime.jsxs("div", { className: 'GridFormDropDown-filter', children: [jsxRuntime.jsx(FocusableItem, { className: 'filter-item', onFocus: () => {
|
|
@@ -5807,19 +5836,6 @@ const GridUpdatingContextProvider = (props) => {
|
|
|
5807
5836
|
var css_248z = ".ActionButton{align-items:center;display:flex}.ActionButton-inProgress .LuiIcon{visibility:hidden}.ActionButton-minimal.lui-button-lg.lui-button-icon-right{padding-right:38px}.ActionButton.lui-button-lg.lui-button-icon-right:not(.ActionButton-tight) .LuiIcon{margin:0 4px}.ActionButton.ActionButton-tight.lui-button-lg.lui-button-icon-right .LuiIcon{margin:0}.ActionButton-iconOnly.lui-button-lg.lui-button-icon-right:not(.ActionButton-tight){padding:8px 5px}.ActionButton-iconOnly.lui-button-lg.lui-button-icon-right.ActionButton-tight{padding:0}.ActionButton-minimalArea{position:relative}.ActionButton-minimalAreaDisplay{position:absolute}.ActionButton-minimalAreaExpand{visibility:hidden}.ActionButton-inProgress.lui-button-lg.lui-button-icon-right{background-color:#e2f3f7;color:#007198;cursor:progress}.ActionButton-fill{justify-content:center;width:100%}";
|
|
5808
5837
|
styleInject(css_248z);
|
|
5809
5838
|
|
|
5810
|
-
/**
|
|
5811
|
-
* Track previous values of states.
|
|
5812
|
-
*
|
|
5813
|
-
* @param value Value to track.
|
|
5814
|
-
*/
|
|
5815
|
-
const usePrevious = (value) => {
|
|
5816
|
-
const ref = React.useRef();
|
|
5817
|
-
React.useEffect(() => {
|
|
5818
|
-
ref.current = value;
|
|
5819
|
-
}, [value]);
|
|
5820
|
-
return ref.current;
|
|
5821
|
-
};
|
|
5822
|
-
|
|
5823
5839
|
// Kept this less than one second, so I don't have issues with waitFor as it defaults to 1s
|
|
5824
5840
|
const minimumInProgressTimeMs = 950;
|
|
5825
5841
|
const ActionButton = ({ icon, name, inProgressName, disabled, dataTestId, style, className, title, onClick, size = 'sm', iconPosition = 'left', level = 'tertiary', 'aria-label': ariaLabel, }) => {
|