@linzjs/step-ag-grid 14.6.0 → 14.7.1
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/utils/textValidator.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +27 -7
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +9 -0
- package/src/utils/textValidator.test.ts +7 -0
- package/src/utils/textValidator.ts +8 -4
- package/src/utils/util.test.ts +12 -1
- package/src/utils/util.ts +11 -2
|
@@ -12,6 +12,7 @@ export interface TextInputValidatorProps<RowType extends GridBaseRow> {
|
|
|
12
12
|
geMin?: number;
|
|
13
13
|
ltMax?: number;
|
|
14
14
|
leMax?: number;
|
|
15
|
+
notZero?: boolean;
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
export declare const TextInputValidator: <RowType extends GridBaseRow>(props: TextInputValidatorProps<RowType>, value: string | null, data: RowType, context: any) => string | JSX.Element | null;
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -475,9 +475,19 @@ var wait$2 = function (timeoutMs) {
|
|
|
475
475
|
setTimeout(resolve, timeoutMs);
|
|
476
476
|
});
|
|
477
477
|
};
|
|
478
|
+
// This regexp only works if you parseFloat first, it won't validate a float on its own
|
|
479
|
+
// It prevents scientific 1e10, or trailing decimal 1.2.3, or trailing garbage 1.2xyz
|
|
480
|
+
var isFloatRegExp = /^-?\d*\.?\d*$/;
|
|
478
481
|
var isFloat = function (value) {
|
|
479
|
-
|
|
480
|
-
|
|
482
|
+
try {
|
|
483
|
+
// Just checking it's not scientific notation or "NaN" here.
|
|
484
|
+
// Also parse float will parse up to the first invalid character,
|
|
485
|
+
// so we need to check there's no remaining invalids e.g. "1.2xyz" would parse as 1.2
|
|
486
|
+
return !Number.isNaN(parseFloat(value)) && isFloatRegExp.test(value);
|
|
487
|
+
}
|
|
488
|
+
catch (_a) {
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
481
491
|
};
|
|
482
492
|
var findParentWithClass = function (className, child) {
|
|
483
493
|
for (var node = child; node; node = node.parentNode) {
|
|
@@ -737,12 +747,19 @@ var Grid = function (_a) {
|
|
|
737
747
|
var hasSetContentSizeEmpty = useRef(false);
|
|
738
748
|
var needsAutoSize = useRef(false);
|
|
739
749
|
var setInitialContentSize = useCallback(function () {
|
|
740
|
-
var _a;
|
|
750
|
+
var _a, _b, _c;
|
|
741
751
|
if (!((_a = gridDivRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth)) {
|
|
742
752
|
// Don't resize grids if they are offscreen as it doesn't work.
|
|
743
753
|
needsAutoSize.current = true;
|
|
744
754
|
return;
|
|
745
755
|
}
|
|
756
|
+
var headerCellCount = (_c = (_b = gridDivRef.current) === null || _b === void 0 ? void 0 : _b.getElementsByClassName("ag-header-cell-label")) === null || _c === void 0 ? void 0 : _c.length;
|
|
757
|
+
if (headerCellCount != params.columnDefs.length) {
|
|
758
|
+
// Don't resize grids until all the columns are visible
|
|
759
|
+
// as `autoSizeColumns` will fail silently in this case
|
|
760
|
+
needsAutoSize.current = true;
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
746
763
|
var skipHeader = sizeColumns === "auto-skip-headers" && !isEmpty(params.rowData);
|
|
747
764
|
if (sizeColumns === "auto" || skipHeader) {
|
|
748
765
|
var result = autoSizeColumns({ skipHeader: skipHeader, userSizedColIds: userSizedColIds.current });
|
|
@@ -4458,17 +4475,20 @@ var TextInputValidator = function (props, value, data, context) {
|
|
|
4458
4475
|
}
|
|
4459
4476
|
if (value != "") {
|
|
4460
4477
|
var number = parseFloat(value);
|
|
4478
|
+
if (nf.notZero && number === 0) {
|
|
4479
|
+
return "Must not be 0";
|
|
4480
|
+
}
|
|
4461
4481
|
if (nf.gtMin != null && number <= nf.gtMin) {
|
|
4462
|
-
return "Must be greater than ".concat(nf.gtMin);
|
|
4482
|
+
return "Must be greater than ".concat(nf.gtMin.toLocaleString());
|
|
4463
4483
|
}
|
|
4464
4484
|
if (nf.geMin != null && number < nf.geMin) {
|
|
4465
|
-
return "Must not be less than ".concat(nf.geMin);
|
|
4485
|
+
return "Must not be less than ".concat(nf.geMin.toLocaleString());
|
|
4466
4486
|
}
|
|
4467
4487
|
if (nf.ltMax != null && number >= nf.ltMax) {
|
|
4468
|
-
return "Must be less than ".concat(nf.ltMax);
|
|
4488
|
+
return "Must be less than ".concat(nf.ltMax.toLocaleString());
|
|
4469
4489
|
}
|
|
4470
4490
|
if (nf.leMax != null && number > nf.leMax) {
|
|
4471
|
-
return "Must not be greater than ".concat(nf.leMax);
|
|
4491
|
+
return "Must not be greater than ".concat(nf.leMax.toLocaleString());
|
|
4472
4492
|
}
|
|
4473
4493
|
if (nf.precision != null && value != "") {
|
|
4474
4494
|
if (parseFloat(number.toPrecision(nf.precision)) != number) {
|