@linzjs/step-ag-grid 7.6.1 → 7.7.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,5 +5,12 @@ export interface TextInputValidatorProps<RowType extends GridBaseRow> {
5
5
  maxLength?: number;
6
6
  maxBytes?: number;
7
7
  invalid?: (value: string, data: RowType, context: any) => JSX.Element | string | null;
8
+ numberFormat?: {
9
+ precision?: number;
10
+ gtMin?: number;
11
+ geMin?: number;
12
+ ltMax?: number;
13
+ leMax?: number;
14
+ };
8
15
  }
9
16
  export declare const TextInputValidator: <RowType extends GridBaseRow>(props: TextInputValidatorProps<RowType>, value: string | null, data: RowType, context: any) => string | JSX.Element | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -1306,7 +1306,7 @@ var wait$2 = function (timeoutMs) {
1306
1306
  });
1307
1307
  };
1308
1308
  var isFloat = function (value) {
1309
- var regexp = /^-?\d+(\.\d+)?$/;
1309
+ var regexp = /^-?\d*(\.\d+)?$/;
1310
1310
  return regexp.test(value);
1311
1311
  };
1312
1312
  var findParentWithClass = function (className, child) {
@@ -2266,7 +2266,10 @@ var GridContextProvider = function (props) {
2266
2266
  case 0:
2267
2267
  // Need to refresh to get spinners to work on all rows
2268
2268
  gridApi.refreshCells({ rowNodes: props.selectedRows, force: true });
2269
- return [4 /*yield*/, fnUpdate(selectedRows)];
2269
+ return [4 /*yield*/, fnUpdate(selectedRows)["catch"](function (ex) {
2270
+ console.error("Exception during modifyUpdating", ex);
2271
+ return false;
2272
+ })];
2270
2273
  case 1:
2271
2274
  ok = _a.sent();
2272
2275
  return [2 /*return*/];
@@ -2414,7 +2417,7 @@ var GridPopoverContextProvider = function (_a) {
2414
2417
  var selectedRows = useMemo(function () { return (multiEdit ? sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2415
2418
  var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
2416
2419
  var updateValue = useCallback(function (saveFn, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
2417
- var r, _a;
2420
+ var _a;
2418
2421
  return __generator(this, function (_b) {
2419
2422
  switch (_b.label) {
2420
2423
  case 0:
@@ -2428,10 +2431,7 @@ var GridPopoverContextProvider = function (_a) {
2428
2431
  case 2:
2429
2432
  _a = _b.sent();
2430
2433
  _b.label = 3;
2431
- case 3:
2432
- r = _a;
2433
- //if (r) stopEditing();
2434
- return [2 /*return*/, r];
2434
+ case 3: return [2 /*return*/, _a];
2435
2435
  }
2436
2436
  });
2437
2437
  }); }, [field, saving, selectedRows, updatingCells]);
@@ -2868,7 +2868,7 @@ var GridCellRenderer = function (props) {
2868
2868
  var GridCell = function (props, custom) {
2869
2869
  var _a;
2870
2870
  return __assign(__assign(__assign(__assign(__assign(__assign({ colId: props.field, sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true }, ((custom === null || custom === void 0 ? void 0 : custom.editor) && {
2871
- cellClassRules: GridCellMultiSelectClassRules,
2871
+ cellClassRules: custom.multiEdit ? GridCellMultiSelectClassRules : undefined,
2872
2872
  editable: (_a = props.editable) !== null && _a !== void 0 ? _a : true,
2873
2873
  cellEditor: GenericCellEditorComponentWrapper(custom)
2874
2874
  })), { suppressKeyboardEvent: function (e) {
@@ -4176,17 +4176,40 @@ var TextInputValidator = function (props, value, data, context) {
4176
4176
  return null;
4177
4177
  // This can happen because subcomponent is invoked without type safety
4178
4178
  if (typeof value !== "string") {
4179
- console.error("Value is not a string", value);
4180
- return null;
4179
+ return "Value is not a string";
4181
4180
  }
4182
- if (props.required && value.length === 0) {
4183
- return "Some text is required";
4181
+ if (props.required && value == "") {
4182
+ return "Must not be empty";
4184
4183
  }
4185
4184
  if (props.maxLength && value.length > props.maxLength) {
4186
- return "Text must be no longer than ".concat(props.maxLength, " characters");
4185
+ return "Must be no longer than ".concat(props.maxLength, " characters");
4187
4186
  }
4188
4187
  if (props.maxBytes && stringByteLengthIsInvalid(value, props.maxBytes)) {
4189
- return "Text must be no longer than ".concat(props.maxLength, " bytes");
4188
+ return "Must be no longer than ".concat(props.maxBytes, " bytes");
4189
+ }
4190
+ var nf = props.numberFormat;
4191
+ if (nf) {
4192
+ if (value != "" && !isFloat(value)) {
4193
+ return "Must be a valid number";
4194
+ }
4195
+ var number = parseFloat(value);
4196
+ if (nf.gtMin != null && number <= nf.gtMin) {
4197
+ return "Must be greater than ".concat(nf.gtMin);
4198
+ }
4199
+ if (nf.geMin != null && number < nf.geMin) {
4200
+ return "Must not be less than ".concat(nf.geMin);
4201
+ }
4202
+ if (nf.ltMax != null && number >= nf.ltMax) {
4203
+ return "Must be less than ".concat(nf.ltMax);
4204
+ }
4205
+ if (nf.leMax != null && number > nf.leMax) {
4206
+ return "Must not be greater than ".concat(nf.leMax);
4207
+ }
4208
+ if (nf.precision != null && value != "") {
4209
+ if (parseFloat(number.toPrecision(nf.precision + 1)) != number) {
4210
+ return nf.precision == 0 ? "Must be a whole number" : "Must have no more than ".concat(nf.precision, " decimal places");
4211
+ }
4212
+ }
4190
4213
  }
4191
4214
  if (props.invalid) {
4192
4215
  return props.invalid(value, data, context);
@@ -4422,6 +4445,12 @@ var ActionButton = function (_a) {
4422
4445
  var useDeferredPromise = function () {
4423
4446
  var promiseResolve = useRef();
4424
4447
  var promiseReject = useRef();
4448
+ // End promise on unload
4449
+ useEffect(function () {
4450
+ return function () {
4451
+ promiseReject.current && promiseReject.current();
4452
+ };
4453
+ }, []);
4425
4454
  return {
4426
4455
  invoke: function () {
4427
4456
  return new Promise(function (resolve, reject) {