@linzjs/step-ag-grid 29.1.4 → 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/src/components/GridPopoverHook.d.ts +0 -1
- package/dist/step-ag-grid.cjs +35 -33
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +36 -34
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridPopoverHook.tsx +0 -1
- package/src/components/gridForm/GridFormDropDown.tsx +44 -35
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +0 -1
|
@@ -10,5 +10,4 @@ export declare const CancelPromise: () => Promise<boolean>;
|
|
|
10
10
|
export declare const useGridPopoverHook: <TData extends GridBaseRow>({ className, save, invalid, dontSaveOnExternalClick, }: GridPopoverHookProps<TData>) => {
|
|
11
11
|
popoverWrapper: (children: ReactElement) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
triggerSave: (reason?: string) => Promise<void>;
|
|
13
|
-
gridPopoverOpen: boolean;
|
|
14
13
|
};
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -4010,7 +4010,6 @@ const useGridPopoverHook = ({ className, save, invalid, dontSaveOnExternalClick,
|
|
|
4010
4010
|
return {
|
|
4011
4011
|
popoverWrapper,
|
|
4012
4012
|
triggerSave,
|
|
4013
|
-
gridPopoverOpen: isOpen,
|
|
4014
4013
|
};
|
|
4015
4014
|
};
|
|
4016
4015
|
|
|
@@ -4035,7 +4034,7 @@ const GridFormDropDown = (props) => {
|
|
|
4035
4034
|
// Save triggers during async action processing which triggers another selectItem(), this ref blocks that
|
|
4036
4035
|
const [filter, setFilter] = React.useState(props.filterDefaultValue ?? '');
|
|
4037
4036
|
const [filteredValues, setFilteredValues] = React.useState();
|
|
4038
|
-
const [options, setOptions] = React.useState(null);
|
|
4037
|
+
const [options, setOptions] = React.useState(!!propOptions && typeof propOptions !== 'function' ? propOptions : null);
|
|
4039
4038
|
const subComponentIsValid = React.useRef(false);
|
|
4040
4039
|
const subComponentInitialValue = React.useRef(null);
|
|
4041
4040
|
const [subSelectedValue, setSubSelectedValue] = React.useState(null);
|
|
@@ -4102,55 +4101,58 @@ const GridFormDropDown = (props) => {
|
|
|
4102
4101
|
selectedRows,
|
|
4103
4102
|
subSelectedValue,
|
|
4104
4103
|
]);
|
|
4105
|
-
const { popoverWrapper
|
|
4104
|
+
const { popoverWrapper } = useGridPopoverHook({
|
|
4106
4105
|
className: props.className,
|
|
4107
4106
|
invalid: () => !options || !!(selectedItem && !subComponentIsValid.current),
|
|
4108
4107
|
save,
|
|
4109
4108
|
dontSaveOnExternalClick: true,
|
|
4110
4109
|
});
|
|
4111
4110
|
// Load up options list if it's async function
|
|
4112
|
-
const prevIsOpen = usePrevious(gridPopoverOpen);
|
|
4113
|
-
const prevFilter = usePrevious(filter);
|
|
4114
4111
|
React.useEffect(() => {
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
optionsConf = await optionsConf(selectedRows, filter);
|
|
4120
|
-
}
|
|
4121
|
-
if (optionsConf !== undefined) {
|
|
4122
|
-
setOptions(optionsConf);
|
|
4123
|
-
}
|
|
4124
|
-
})();
|
|
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;
|
|
4125
4116
|
}
|
|
4126
|
-
|
|
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]);
|
|
4127
4130
|
// Local filtering.
|
|
4128
4131
|
React.useEffect(() => {
|
|
4129
|
-
if (props.filtered
|
|
4130
|
-
|
|
4131
|
-
return;
|
|
4132
|
-
setFilteredValues(options
|
|
4133
|
-
.map((option) => {
|
|
4134
|
-
if (option.label != null && typeof option.label !== 'string') {
|
|
4135
|
-
console.error('Cannot filter non-string labels', option);
|
|
4136
|
-
return undefined;
|
|
4137
|
-
}
|
|
4138
|
-
return textMatch(option.label || '', filter) ? option : undefined;
|
|
4139
|
-
})
|
|
4140
|
-
.filter((r) => r !== undefined));
|
|
4132
|
+
if (props.filtered !== 'local') {
|
|
4133
|
+
return;
|
|
4141
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
|
+
})));
|
|
4142
4146
|
}, [props.filtered, filter, options]);
|
|
4143
4147
|
const reSearchOnFilterChange = React.useMemo(() => debounce(() => {
|
|
4144
4148
|
setOptions(null);
|
|
4145
4149
|
}, 500), []);
|
|
4146
|
-
const previousFilter =
|
|
4147
|
-
// Reload filtering.
|
|
4150
|
+
const previousFilter = usePrevious(filter);
|
|
4148
4151
|
React.useEffect(() => {
|
|
4149
|
-
if (previousFilter
|
|
4150
|
-
previousFilter.current = filter;
|
|
4152
|
+
if (previousFilter != null && previousFilter != filter && props.filtered === 'reload') {
|
|
4151
4153
|
void reSearchOnFilterChange();
|
|
4152
4154
|
}
|
|
4153
|
-
}, [filter, props, reSearchOnFilterChange]);
|
|
4155
|
+
}, [filter, previousFilter, props.filtered, reSearchOnFilterChange]);
|
|
4154
4156
|
let lastHeader = null;
|
|
4155
4157
|
let showHeader = null;
|
|
4156
4158
|
return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.filtered && (jsxRuntime.jsxs("div", { className: 'GridFormDropDown-filter', children: [jsxRuntime.jsx(FocusableItem, { className: 'filter-item', onFocus: () => {
|