@linzjs/step-ag-grid 5.0.1 → 6.0.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/index.js +100 -84
- package/dist/index.js.map +1 -1
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +11 -11
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +1 -1
- package/dist/src/contexts/GridContext.d.ts +1 -2
- package/dist/src/utils/bearing.d.ts +1 -1
- package/dist/src/utils/textValidator.d.ts +2 -1
- package/dist/step-ag-grid.esm.js +100 -84
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridPopoverHook.tsx +2 -2
- package/src/components/gridForm/GridFormDropDown.tsx +49 -46
- package/src/components/gridForm/GridFormPopoverMenu.tsx +10 -24
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +3 -3
- package/src/contexts/GridContext.tsx +1 -4
- package/src/contexts/GridContextProvider.tsx +16 -2
- package/src/contexts/GridPopoverContextProvider.tsx +8 -12
- package/src/react-menu3/components/ControlledMenu.tsx +6 -4
- package/src/stories/grid/GridPopoutEditDropDown.stories.tsx +4 -39
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +3 -4
- package/src/stories/grid/GridReadOnly.stories.tsx +0 -1
- package/src/utils/bearing.ts +2 -2
- package/src/utils/textValidator.ts +7 -3
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import "../../styles/GridFormDropDown.scss";
|
|
3
3
|
import { GridBaseRow } from "../Grid";
|
|
4
4
|
import { CellEditorCommon } from "../GridCell";
|
|
5
|
-
export interface GridPopoutEditDropDownSelectedItem<RowType
|
|
5
|
+
export interface GridPopoutEditDropDownSelectedItem<RowType> {
|
|
6
6
|
selectedRows: RowType[];
|
|
7
|
-
value:
|
|
8
|
-
subComponentValue?:
|
|
7
|
+
value: any;
|
|
8
|
+
subComponentValue?: any;
|
|
9
9
|
}
|
|
10
|
-
interface FinalSelectOption
|
|
11
|
-
value:
|
|
10
|
+
interface FinalSelectOption {
|
|
11
|
+
value: any;
|
|
12
12
|
label?: JSX.Element | string;
|
|
13
13
|
disabled?: boolean | string;
|
|
14
14
|
subComponent?: (props: any, ref: any) => any;
|
|
@@ -22,15 +22,15 @@ export declare const MenuHeaderItem: (title: string) => {
|
|
|
22
22
|
label: string;
|
|
23
23
|
value: string;
|
|
24
24
|
};
|
|
25
|
-
export type SelectOption
|
|
26
|
-
export interface GridFormPopoutDropDownProps<RowType extends GridBaseRow
|
|
25
|
+
export type SelectOption = null | string | FinalSelectOption;
|
|
26
|
+
export interface GridFormPopoutDropDownProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
27
27
|
className?: "GridPopoverEditDropDown-containerSmall" | "GridPopoverEditDropDown-containerMedium" | "GridPopoverEditDropDown-containerLarge" | "GridPopoverEditDropDown-containerUnlimited" | string | undefined;
|
|
28
28
|
filtered?: "local" | "reload";
|
|
29
29
|
filterPlaceholder?: string;
|
|
30
|
-
onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<RowType
|
|
31
|
-
onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<RowType
|
|
32
|
-
options: SelectOption
|
|
30
|
+
onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<RowType>) => Promise<void>;
|
|
31
|
+
onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<RowType>) => Promise<void>;
|
|
32
|
+
options: SelectOption[] | ((selectedRows: RowType[], filter?: string) => Promise<SelectOption[]> | SelectOption[]);
|
|
33
33
|
optionsRequestCancel?: () => void;
|
|
34
34
|
}
|
|
35
|
-
export declare const GridFormDropDown: <RowType extends GridBaseRow
|
|
35
|
+
export declare const GridFormDropDown: <RowType extends GridBaseRow>(props: GridFormPopoutDropDownProps<RowType>) => JSX.Element;
|
|
36
36
|
export {};
|
|
@@ -2,4 +2,4 @@ import { ColDefT, GenericCellEditorProps } from "../GridCell";
|
|
|
2
2
|
import { GridBaseRow } from "../Grid";
|
|
3
3
|
import { GridFormPopoutDropDownProps } from "../gridForm/GridFormDropDown";
|
|
4
4
|
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
5
|
-
export declare const GridPopoverEditDropDown: <RowType extends GridBaseRow
|
|
5
|
+
export declare const GridPopoverEditDropDown: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, props: GenericCellEditorProps<GridFormPopoutDropDownProps<RowType>>) => ColDefT<RowType>;
|
|
@@ -21,8 +21,7 @@ export interface GridContextType {
|
|
|
21
21
|
updatingCells: (props: {
|
|
22
22
|
selectedRows: GridBaseRow[];
|
|
23
23
|
field?: string;
|
|
24
|
-
}, fnUpdate: (selectedRows: any[]) => Promise<boolean>, setSaving?: (saving: boolean) => void) => Promise<boolean>;
|
|
24
|
+
}, fnUpdate: (selectedRows: any[]) => Promise<boolean>, setSaving?: (saving: boolean) => void, tabDirection?: 1 | 0 | -1) => Promise<boolean>;
|
|
25
25
|
redrawRows: (rowNodes?: RowNode[]) => void;
|
|
26
|
-
selectNextCell: (tabDirection: -1 | 0 | 1) => void;
|
|
27
26
|
}
|
|
28
27
|
export declare const GridContext: import("react").Context<GridContextType>;
|
|
@@ -2,5 +2,5 @@ import { ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef
|
|
|
2
2
|
export declare const bearingValueFormatter: (params: ValueFormatterParams) => string;
|
|
3
3
|
export declare const bearingCorrectionValueFormatter: (params: ValueFormatterParams) => string;
|
|
4
4
|
export declare const bearingNumberParser: (value: string) => number | null;
|
|
5
|
-
export declare const bearingStringValidator: (value: string,
|
|
5
|
+
export declare const bearingStringValidator: (value: string, customInvalid?: ((value: number | null) => string | null) | undefined) => string | null;
|
|
6
6
|
export declare const convertDDToDMS: (dd: number | null, showPositiveSymbol?: boolean, addTrailingZeros?: boolean) => string;
|
|
@@ -2,6 +2,7 @@ import { GridBaseRow } from "../components/Grid";
|
|
|
2
2
|
export interface TextInputValidatorProps<RowType extends GridBaseRow> {
|
|
3
3
|
required?: boolean;
|
|
4
4
|
maxLength?: number;
|
|
5
|
-
|
|
5
|
+
maxBytes?: number;
|
|
6
|
+
invalid?: (value: string, data: RowType) => string | null;
|
|
6
7
|
}
|
|
7
8
|
export declare const TextInputValidator: <RowType extends GridBaseRow>(props: TextInputValidatorProps<RowType>, value: string | null, data: RowType) => string | null;
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -1345,8 +1345,10 @@ var ControlledMenuFr = function (_a, externalRef) {
|
|
|
1345
1345
|
// the cell doesn't refresh during update if save is invoked from a native event
|
|
1346
1346
|
// This doesn't happen in React18
|
|
1347
1347
|
// To work around it, I invoke the save by clicking on a passed in invisible button ref
|
|
1348
|
-
if (saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current)
|
|
1348
|
+
if (saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current) {
|
|
1349
|
+
saveButtonRef.current.setAttribute("data-reason", CloseReason.BLUR);
|
|
1349
1350
|
saveButtonRef.current.click();
|
|
1351
|
+
}
|
|
1350
1352
|
else
|
|
1351
1353
|
safeCall(onClose, { reason: CloseReason.BLUR });
|
|
1352
1354
|
// If a user clicks on the menu button when a menu is open, we need to close the menu.
|
|
@@ -1479,8 +1481,8 @@ var ControlledMenuFr = function (_a, externalRef) {
|
|
|
1479
1481
|
thisDocument_1.addEventListener("click", handleScreenEventForCancel, true);
|
|
1480
1482
|
thisDocument_1.addEventListener("dblclick", handleScreenEventForCancel, true);
|
|
1481
1483
|
return function () {
|
|
1482
|
-
thisDocument_1.
|
|
1483
|
-
thisDocument_1.
|
|
1484
|
+
thisDocument_1.removeEventListener("keydown", handleKeydownTabAndEnter, true);
|
|
1485
|
+
thisDocument_1.removeEventListener("keyup", handleKeyupTabAndEnter, true);
|
|
1484
1486
|
thisDocument_1.removeEventListener("mousedown", handleScreenEventForSave, true);
|
|
1485
1487
|
thisDocument_1.removeEventListener("mouseup", handleScreenEventForCancel, true);
|
|
1486
1488
|
thisDocument_1.removeEventListener("click", handleScreenEventForCancel, true);
|
|
@@ -1989,9 +1991,6 @@ var GridContext = createContext({
|
|
|
1989
1991
|
}); },
|
|
1990
1992
|
redrawRows: function () {
|
|
1991
1993
|
console.error("no context provider for redrawRows");
|
|
1992
|
-
},
|
|
1993
|
-
selectNextCell: function () {
|
|
1994
|
-
console.error("no context provider for selectNextCell");
|
|
1995
1994
|
}
|
|
1996
1995
|
});
|
|
1997
1996
|
|
|
@@ -2211,17 +2210,18 @@ var GridContextProvider = function (props) {
|
|
|
2211
2210
|
});
|
|
2212
2211
|
};
|
|
2213
2212
|
var stopEditing = function () { return gridApiOp(function (gridApi) { return gridApi.stopEditing(); }); };
|
|
2214
|
-
var updatingCells = function (props, fnUpdate, setSaving) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2213
|
+
var updatingCells = function (props, fnUpdate, setSaving, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2215
2214
|
return __generator(this, function (_a) {
|
|
2216
2215
|
switch (_a.label) {
|
|
2217
2216
|
case 0:
|
|
2218
2217
|
setSaving && setSaving(true);
|
|
2219
2218
|
return [4 /*yield*/, gridApiOp(function (gridApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2220
|
-
var selectedRows, ok, cell;
|
|
2219
|
+
var preOpCell, selectedRows, ok, cell, postOpCell;
|
|
2221
2220
|
var _a;
|
|
2222
2221
|
return __generator(this, function (_b) {
|
|
2223
2222
|
switch (_b.label) {
|
|
2224
2223
|
case 0:
|
|
2224
|
+
preOpCell = gridApi.getFocusedCell();
|
|
2225
2225
|
selectedRows = props.selectedRows;
|
|
2226
2226
|
ok = false;
|
|
2227
2227
|
return [4 /*yield*/, modifyUpdating((_a = props.field) !== null && _a !== void 0 ? _a : "", selectedRows.map(function (data) { return data.id; }), function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -2253,6 +2253,14 @@ var GridContextProvider = function (props) {
|
|
|
2253
2253
|
// Don't set saving if ok as the form has already closed
|
|
2254
2254
|
setSaving && setSaving(false);
|
|
2255
2255
|
}
|
|
2256
|
+
postOpCell = gridApi.getFocusedCell();
|
|
2257
|
+
if (tabDirection &&
|
|
2258
|
+
preOpCell &&
|
|
2259
|
+
postOpCell &&
|
|
2260
|
+
preOpCell.rowIndex == postOpCell.rowIndex &&
|
|
2261
|
+
preOpCell.column.getColId() == postOpCell.column.getColId()) {
|
|
2262
|
+
selectNextCell(tabDirection);
|
|
2263
|
+
}
|
|
2256
2264
|
return [2 /*return*/, ok];
|
|
2257
2265
|
}
|
|
2258
2266
|
});
|
|
@@ -2293,8 +2301,7 @@ var GridContextProvider = function (props) {
|
|
|
2293
2301
|
sizeColumnsToFit: sizeColumnsToFit,
|
|
2294
2302
|
stopEditing: stopEditing,
|
|
2295
2303
|
updatingCells: updatingCells,
|
|
2296
|
-
redrawRows: redrawRows
|
|
2297
|
-
selectNextCell: selectNextCell
|
|
2304
|
+
redrawRows: redrawRows
|
|
2298
2305
|
} }, { children: props.children })));
|
|
2299
2306
|
};
|
|
2300
2307
|
|
|
@@ -2359,8 +2366,9 @@ var useGridPopoverContext = function () {
|
|
|
2359
2366
|
var GridPopoverContextProvider = function (_a) {
|
|
2360
2367
|
var _b, _c, _d;
|
|
2361
2368
|
var props = _a.props, children = _a.children;
|
|
2362
|
-
var _e = useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells
|
|
2369
|
+
var _e = useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells;
|
|
2363
2370
|
var anchorRef = useRef(props.eGridCell);
|
|
2371
|
+
var hasSaved = useRef(false);
|
|
2364
2372
|
var _f = useState(false), saving = _f[0], setSaving = _f[1];
|
|
2365
2373
|
var colDef = props.colDef;
|
|
2366
2374
|
var cellEditorParams = colDef.cellEditorParams;
|
|
@@ -2369,24 +2377,27 @@ var GridPopoverContextProvider = function (_a) {
|
|
|
2369
2377
|
var selectedRows = useMemo(function () { return (multiEdit ? sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
|
|
2370
2378
|
var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
|
|
2371
2379
|
var updateValue = useCallback(function (saveFn, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2372
|
-
var
|
|
2373
|
-
return __generator(this, function (
|
|
2374
|
-
switch (
|
|
2380
|
+
var r, _a;
|
|
2381
|
+
return __generator(this, function (_b) {
|
|
2382
|
+
switch (_b.label) {
|
|
2375
2383
|
case 0:
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
case
|
|
2384
|
+
if (hasSaved.current)
|
|
2385
|
+
return [2 /*return*/, true];
|
|
2386
|
+
hasSaved.current = true;
|
|
2387
|
+
if (!saving) return [3 /*break*/, 1];
|
|
2388
|
+
_a = false;
|
|
2389
|
+
return [3 /*break*/, 3];
|
|
2390
|
+
case 1: return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving, tabDirection)];
|
|
2391
|
+
case 2:
|
|
2392
|
+
_a = _b.sent();
|
|
2393
|
+
_b.label = 3;
|
|
2394
|
+
case 3:
|
|
2395
|
+
r = _a;
|
|
2396
|
+
//if (r) stopEditing();
|
|
2397
|
+
return [2 /*return*/, r];
|
|
2387
2398
|
}
|
|
2388
2399
|
});
|
|
2389
|
-
}); }, [field, saving,
|
|
2400
|
+
}); }, [field, saving, selectedRows, updatingCells]);
|
|
2390
2401
|
return (jsx(GridPopoverContext.Provider, __assign({ value: {
|
|
2391
2402
|
anchorRef: anchorRef,
|
|
2392
2403
|
saving: saving,
|
|
@@ -2918,7 +2929,7 @@ var useGridPopoverHook = function (props) {
|
|
|
2918
2929
|
return __generator(this, function (_a) {
|
|
2919
2930
|
switch (_a.label) {
|
|
2920
2931
|
case 0:
|
|
2921
|
-
if (reason ==
|
|
2932
|
+
if (reason == CloseReason.CANCEL) {
|
|
2922
2933
|
stopEditing();
|
|
2923
2934
|
return [2 /*return*/];
|
|
2924
2935
|
}
|
|
@@ -2947,7 +2958,7 @@ var useGridPopoverHook = function (props) {
|
|
|
2947
2958
|
var popoverWrapper = useCallback(function (children) {
|
|
2948
2959
|
return (jsx(Fragment$1, { children: anchorRef.current && (jsxs(ControlledMenu, __assign({ state: isOpen ? "open" : "closed", portal: true, unmountOnClose: true, anchorRef: anchorRef, saveButtonRef: saveButtonRef, menuClassName: "step-ag-grid-react-menu", onClose: function (event) {
|
|
2949
2960
|
// Prevent menu from closing when modals are invoked
|
|
2950
|
-
if (event.reason ===
|
|
2961
|
+
if (event.reason === CloseReason.BLUR)
|
|
2951
2962
|
return;
|
|
2952
2963
|
triggerSave(event.reason).then();
|
|
2953
2964
|
}, viewScroll: "auto", dontShrinkIfDirectionIsTop: true, className: props.className, closeMenuExclusionClassName: "ReactModal__Content" }, { children: [saving && ( // This is the overlay that prevents editing when the editor is saving
|
|
@@ -3078,7 +3089,6 @@ var fieldToString = function (field) {
|
|
|
3078
3089
|
var GridFormDropDown = function (props) {
|
|
3079
3090
|
var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue, data = _a.data;
|
|
3080
3091
|
// Save triggers during async action processing which triggers another selectItem(), this ref blocks that
|
|
3081
|
-
var hasSubmitted = useRef(false);
|
|
3082
3092
|
var _b = useState(""), filter = _b[0], setFilter = _b[1];
|
|
3083
3093
|
var _c = useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
|
|
3084
3094
|
var optionsInitialising = useRef(false);
|
|
@@ -3086,32 +3096,39 @@ var GridFormDropDown = function (props) {
|
|
|
3086
3096
|
var subComponentIsValid = useRef(false);
|
|
3087
3097
|
var _e = useState(), subSelectedValue = _e[0], setSubSelectedValue = _e[1];
|
|
3088
3098
|
var _f = useState(null), selectedSubComponent = _f[0], setSelectedSubComponent = _f[1];
|
|
3089
|
-
var selectItemHandler = useCallback(function (value, subComponentValue
|
|
3099
|
+
var selectItemHandler = useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3100
|
+
var hasChanged;
|
|
3090
3101
|
return __generator(this, function (_a) {
|
|
3091
|
-
|
|
3102
|
+
switch (_a.label) {
|
|
3103
|
+
case 0:
|
|
3104
|
+
hasChanged = selectedRows.some(function (row) { return row[field] !== value; });
|
|
3105
|
+
if (!hasChanged) return [3 /*break*/, 3];
|
|
3106
|
+
if (!props.onSelectedItem) return [3 /*break*/, 2];
|
|
3107
|
+
return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value, subComponentValue: subComponentValue })];
|
|
3108
|
+
case 1:
|
|
3109
|
+
_a.sent();
|
|
3110
|
+
return [3 /*break*/, 3];
|
|
3111
|
+
case 2:
|
|
3112
|
+
selectedRows.forEach(function (row) { return (row[field] = value); });
|
|
3113
|
+
_a.label = 3;
|
|
3114
|
+
case 3: return [2 /*return*/, true];
|
|
3115
|
+
}
|
|
3116
|
+
});
|
|
3117
|
+
}); }, [field, props, selectedRows]);
|
|
3118
|
+
var clickItemHandler = useCallback(function (value, subComponentValue, reason) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3119
|
+
return __generator(this, function (_a) {
|
|
3120
|
+
if (subComponentValue !== undefined && !subComponentIsValid.current)
|
|
3092
3121
|
return [2 /*return*/, false];
|
|
3093
|
-
|
|
3094
|
-
return [2 /*return*/, updateValue(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3095
|
-
var hasChanged;
|
|
3122
|
+
return [2 /*return*/, updateValue(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3096
3123
|
return __generator(this, function (_a) {
|
|
3097
3124
|
switch (_a.label) {
|
|
3098
|
-
case 0:
|
|
3099
|
-
|
|
3100
|
-
if (!hasChanged) return [3 /*break*/, 3];
|
|
3101
|
-
if (!props.onSelectedItem) return [3 /*break*/, 2];
|
|
3102
|
-
return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value, subComponentValue: subComponentValue })];
|
|
3103
|
-
case 1:
|
|
3104
|
-
_a.sent();
|
|
3105
|
-
return [3 /*break*/, 3];
|
|
3106
|
-
case 2:
|
|
3107
|
-
selectedRows.forEach(function (row) { return (row[field] = value); });
|
|
3108
|
-
_a.label = 3;
|
|
3109
|
-
case 3: return [2 /*return*/, true];
|
|
3125
|
+
case 0: return [4 /*yield*/, selectItemHandler(value, subComponentValue)];
|
|
3126
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3110
3127
|
}
|
|
3111
3128
|
});
|
|
3112
3129
|
}); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
|
|
3113
3130
|
});
|
|
3114
|
-
}); }, [
|
|
3131
|
+
}); }, [selectItemHandler, updateValue]);
|
|
3115
3132
|
var selectFilterHandler = useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3116
3133
|
return __generator(this, function (_a) {
|
|
3117
3134
|
return [2 /*return*/, updateValue(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3151,14 +3168,13 @@ var GridFormDropDown = function (props) {
|
|
|
3151
3168
|
_a.label = 2;
|
|
3152
3169
|
case 2:
|
|
3153
3170
|
optionsList = optionsConf === null || optionsConf === void 0 ? void 0 : optionsConf.map(function (item) {
|
|
3154
|
-
|
|
3155
|
-
|
|
3171
|
+
return item == null || typeof item == "string"
|
|
3172
|
+
? {
|
|
3156
3173
|
value: item,
|
|
3157
3174
|
label: item,
|
|
3158
3175
|
disabled: false
|
|
3159
|
-
}
|
|
3160
|
-
|
|
3161
|
-
return item;
|
|
3176
|
+
}
|
|
3177
|
+
: item;
|
|
3162
3178
|
});
|
|
3163
3179
|
if (props.filtered) {
|
|
3164
3180
|
// This is needed otherwise when filter input is rendered and sets autofocus
|
|
@@ -3203,6 +3219,9 @@ var GridFormDropDown = function (props) {
|
|
|
3203
3219
|
researchOnFilterChange().then();
|
|
3204
3220
|
}
|
|
3205
3221
|
}, [filter, props, researchOnFilterChange]);
|
|
3222
|
+
/**
|
|
3223
|
+
* Saves are wrapped in updateValue and triggered by blur events
|
|
3224
|
+
*/
|
|
3206
3225
|
var save = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3207
3226
|
var activeOptions;
|
|
3208
3227
|
return __generator(this, function (_a) {
|
|
@@ -3270,7 +3289,7 @@ var GridFormDropDown = function (props) {
|
|
|
3270
3289
|
e.keepOpen = true;
|
|
3271
3290
|
}
|
|
3272
3291
|
else {
|
|
3273
|
-
|
|
3292
|
+
clickItemHandler(item.value, undefined, e.key === "Tab"
|
|
3274
3293
|
? e.shiftKey
|
|
3275
3294
|
? CloseReason.TAB_BACKWARD
|
|
3276
3295
|
: CloseReason.TAB_FORWARD
|
|
@@ -3462,8 +3481,6 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3462
3481
|
var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, updateValue = _a.updateValue, data = _a.data;
|
|
3463
3482
|
var optionsInitialising = useRef(false);
|
|
3464
3483
|
var _b = useState(), options = _b[0], setOptions = _b[1];
|
|
3465
|
-
// Save triggers during async action processing which triggers another action(), this ref blocks that
|
|
3466
|
-
var actionProcessing = useRef(false);
|
|
3467
3484
|
var _c = useState(null), subComponentSelected = _c[0], setSubComponentSelected = _c[1];
|
|
3468
3485
|
var subComponentIsValid = useRef(false);
|
|
3469
3486
|
var _d = useState(), subSelectedValue = _d[0], setSubSelectedValue = _d[1];
|
|
@@ -3520,26 +3537,20 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3520
3537
|
});
|
|
3521
3538
|
}); })();
|
|
3522
3539
|
}, [options, props.defaultAction, props.options, selectedRows]);
|
|
3523
|
-
var actionClick = useCallback(function (menuOption
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
_b.sent();
|
|
3536
|
-
actionProcessing.current = false;
|
|
3537
|
-
return [2 /*return*/, true];
|
|
3538
|
-
}
|
|
3539
|
-
});
|
|
3540
|
-
}); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
|
|
3540
|
+
var actionClick = useCallback(function (menuOption) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3541
|
+
var result;
|
|
3542
|
+
var _a;
|
|
3543
|
+
return __generator(this, function (_b) {
|
|
3544
|
+
switch (_b.label) {
|
|
3545
|
+
case 0:
|
|
3546
|
+
result = __assign(__assign({}, menuOption), { subValue: subSelectedValue });
|
|
3547
|
+
return [4 /*yield*/, ((_a = menuOption.action) !== null && _a !== void 0 ? _a : defaultAction)(selectedRows, result)];
|
|
3548
|
+
case 1:
|
|
3549
|
+
_b.sent();
|
|
3550
|
+
return [2 /*return*/, true];
|
|
3551
|
+
}
|
|
3541
3552
|
});
|
|
3542
|
-
}); }, [defaultAction, selectedRows, subSelectedValue
|
|
3553
|
+
}); }, [defaultAction, selectedRows, subSelectedValue]);
|
|
3543
3554
|
var onMenuItemClick = useCallback(function (e, item) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3544
3555
|
return __generator(this, function (_a) {
|
|
3545
3556
|
switch (_a.label) {
|
|
@@ -3550,27 +3561,29 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3550
3561
|
setSubComponentSelected(subComponentSelected === item ? null : item);
|
|
3551
3562
|
e.keepOpen = true;
|
|
3552
3563
|
return [3 /*break*/, 3];
|
|
3553
|
-
case 1: return [4 /*yield*/,
|
|
3564
|
+
case 1: return [4 /*yield*/, updateValue(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
3565
|
+
return [2 /*return*/, actionClick(item)];
|
|
3566
|
+
}); }); }, e.key === "Tab" ? (e.shiftKey ? -1 : 1) : 0)];
|
|
3554
3567
|
case 2:
|
|
3555
3568
|
_a.sent();
|
|
3556
3569
|
_a.label = 3;
|
|
3557
3570
|
case 3: return [2 /*return*/];
|
|
3558
3571
|
}
|
|
3559
3572
|
});
|
|
3560
|
-
}); }, [actionClick, subComponentSelected]);
|
|
3573
|
+
}); }, [actionClick, subComponentSelected, updateValue]);
|
|
3561
3574
|
var save = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3562
3575
|
return __generator(this, function (_a) {
|
|
3563
3576
|
switch (_a.label) {
|
|
3564
3577
|
case 0:
|
|
3565
|
-
if (!
|
|
3578
|
+
if (!subComponentSelected) return [3 /*break*/, 2];
|
|
3566
3579
|
if (!subComponentIsValid.current)
|
|
3567
3580
|
return [2 /*return*/, false];
|
|
3568
|
-
return [4 /*yield*/, actionClick(subComponentSelected
|
|
3581
|
+
return [4 /*yield*/, actionClick(subComponentSelected)];
|
|
3569
3582
|
case 1:
|
|
3570
3583
|
_a.sent();
|
|
3571
|
-
|
|
3584
|
+
_a.label = 2;
|
|
3572
3585
|
case 2:
|
|
3573
|
-
//
|
|
3586
|
+
// Close the menu
|
|
3574
3587
|
return [2 /*return*/, true];
|
|
3575
3588
|
}
|
|
3576
3589
|
});
|
|
@@ -3630,7 +3643,7 @@ var bearingNumberParser = function (value) {
|
|
|
3630
3643
|
return parseFloat(value);
|
|
3631
3644
|
};
|
|
3632
3645
|
var validMaskForDmsBearing = /^((-)?\d+)?(\.([0-5](\d([0-5](\d(\d+)?)?)?)?)?)?$/;
|
|
3633
|
-
var bearingStringValidator = function (value,
|
|
3646
|
+
var bearingStringValidator = function (value, customInvalid) {
|
|
3634
3647
|
value = value.trim();
|
|
3635
3648
|
if (value === "")
|
|
3636
3649
|
return null;
|
|
@@ -3642,7 +3655,7 @@ var bearingStringValidator = function (value, customValidate) {
|
|
|
3642
3655
|
return "Bearing has a maximum of 5 decimal places";
|
|
3643
3656
|
}
|
|
3644
3657
|
var bearing = parseFloat(value);
|
|
3645
|
-
return
|
|
3658
|
+
return customInvalid ? customInvalid(bearing) : null;
|
|
3646
3659
|
};
|
|
3647
3660
|
// Decimal-ish degrees to Degrees Minutes Seconds converter
|
|
3648
3661
|
var convertDDToDMS = function (dd, showPositiveSymbol, addTrailingZeros) {
|
|
@@ -3905,8 +3918,11 @@ var TextInputValidator = function (props, value, data) {
|
|
|
3905
3918
|
if (props.maxLength && value.length > props.maxLength) {
|
|
3906
3919
|
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3907
3920
|
}
|
|
3908
|
-
if (props.
|
|
3909
|
-
return props.
|
|
3921
|
+
if (props.maxBytes && new TextEncoder().encode(value).length > props.maxBytes) {
|
|
3922
|
+
return "Text must be no longer than ".concat(props.maxLength, " bytes");
|
|
3923
|
+
}
|
|
3924
|
+
if (props.invalid) {
|
|
3925
|
+
return props.invalid(value, data);
|
|
3910
3926
|
}
|
|
3911
3927
|
return null;
|
|
3912
3928
|
};
|