@linzjs/step-ag-grid 14.5.1 → 14.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.
- package/dist/src/utils/bearing.d.ts +13 -1
- package/dist/src/utils/textValidator.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +38 -16
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +1 -1
- package/src/utils/bearing.test.ts +24 -19
- package/src/utils/bearing.ts +18 -10
- 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
|
@@ -2,6 +2,18 @@ export declare const bearingValueFormatter: (value: any) => string;
|
|
|
2
2
|
export declare const bearingCorrectionValueFormatter: (value: any) => string;
|
|
3
3
|
export declare const bearingNumberParser: (value: string) => number | null;
|
|
4
4
|
export declare const bearingStringValidator: (value: string, customInvalid?: ((value: number | null) => string | null) | undefined) => string | null;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
*Decimal-ish degrees to Degrees Minutes Seconds converter
|
|
7
|
+
*
|
|
8
|
+
* @param dd Decimal-ish degrees
|
|
9
|
+
* @param showPositiveSymbol whether the + sign appears before the number
|
|
10
|
+
* @param trailingZeroDp 2 | 4 | 5
|
|
11
|
+
* Example:
|
|
12
|
+
* 2 = 300° 00'
|
|
13
|
+
* 4 = 300° 00' 00"
|
|
14
|
+
* 5 = 300° 00' 00.0"
|
|
15
|
+
* @returns Degrees Minutes Seconds
|
|
16
|
+
*/
|
|
17
|
+
export declare const convertDDToDMS: (dd: number | null, showPositiveSymbol?: boolean, trailingZeroDp?: 2 | 4 | 5) => string;
|
|
6
18
|
export declare const bearingRangeValidator: (value: number | null) => "Bearing is required" | "Bearing must be less than 360 degrees" | "Bearing must not be negative" | null;
|
|
7
19
|
export declare const bearingCorrectionRangeValidator: (value: number | null) => "Bearing correction is required" | "Bearing correction must be less than 360 degrees" | "Bearing correction must be greater then -180 degrees" | null;
|
|
@@ -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) {
|
|
@@ -3822,7 +3832,7 @@ var bearingValueFormatter = function (value) {
|
|
|
3822
3832
|
if (safeValue == null) {
|
|
3823
3833
|
return "–";
|
|
3824
3834
|
}
|
|
3825
|
-
return convertDDToDMS(safeValue, false
|
|
3835
|
+
return convertDDToDMS(safeValue, false);
|
|
3826
3836
|
};
|
|
3827
3837
|
var bearingCorrectionValueFormatter = function (value) {
|
|
3828
3838
|
var safeValue = value;
|
|
@@ -3830,9 +3840,9 @@ var bearingCorrectionValueFormatter = function (value) {
|
|
|
3830
3840
|
return "–";
|
|
3831
3841
|
}
|
|
3832
3842
|
if (typeof safeValue === "string") {
|
|
3833
|
-
return convertDDToDMS(bearingNumberParser(safeValue), true,
|
|
3843
|
+
return convertDDToDMS(bearingNumberParser(safeValue), true, 4);
|
|
3834
3844
|
}
|
|
3835
|
-
return convertDDToDMS(safeValue, true,
|
|
3845
|
+
return convertDDToDMS(safeValue, true, 4);
|
|
3836
3846
|
};
|
|
3837
3847
|
var bearingNumberParser = function (value) {
|
|
3838
3848
|
if (value === "")
|
|
@@ -3854,14 +3864,23 @@ var bearingStringValidator = function (value, customInvalid) {
|
|
|
3854
3864
|
var bearing = parseFloat(value);
|
|
3855
3865
|
return customInvalid ? customInvalid(bearing) : null;
|
|
3856
3866
|
};
|
|
3857
|
-
|
|
3858
|
-
|
|
3867
|
+
/**
|
|
3868
|
+
*Decimal-ish degrees to Degrees Minutes Seconds converter
|
|
3869
|
+
*
|
|
3870
|
+
* @param dd Decimal-ish degrees
|
|
3871
|
+
* @param showPositiveSymbol whether the + sign appears before the number
|
|
3872
|
+
* @param trailingZeroDp 2 | 4 | 5
|
|
3873
|
+
* Example:
|
|
3874
|
+
* 2 = 300° 00'
|
|
3875
|
+
* 4 = 300° 00' 00"
|
|
3876
|
+
* 5 = 300° 00' 00.0"
|
|
3877
|
+
* @returns Degrees Minutes Seconds
|
|
3878
|
+
*/
|
|
3879
|
+
var convertDDToDMS = function (dd, showPositiveSymbol, trailingZeroDp) {
|
|
3859
3880
|
if (showPositiveSymbol === void 0) { showPositiveSymbol = true; }
|
|
3860
|
-
if (
|
|
3881
|
+
if (trailingZeroDp === void 0) { trailingZeroDp = 2; }
|
|
3861
3882
|
if (dd == null)
|
|
3862
3883
|
return "–";
|
|
3863
|
-
if (dd === 0)
|
|
3864
|
-
addTrailingZeros = false;
|
|
3865
3884
|
// toFixed rounds parts up greater than 60, which has to be corrected below
|
|
3866
3885
|
var _a = dd.toFixed(5).split("."), bearingWholeString = _a[0], bearingDecimalString = _a[1];
|
|
3867
3886
|
var bearingWhole = Math.abs(parseInt(bearingWholeString));
|
|
@@ -3883,10 +3902,10 @@ var convertDDToDMS = function (dd, showPositiveSymbol, addTrailingZeros) {
|
|
|
3883
3902
|
var secString = secNumeric.toString().padStart(2, "0");
|
|
3884
3903
|
var deciSecString = bearingDecimalString === null || bearingDecimalString === void 0 ? void 0 : bearingDecimalString.substring(4, 5);
|
|
3885
3904
|
var dmsString = "".concat(showPositiveSymbol && dd > 0 ? "+" : "").concat(dd < 0 ? "-" : "").concat(bearingWhole, "\u00B0");
|
|
3886
|
-
if (
|
|
3905
|
+
if (trailingZeroDp === 5 || deciSecString != "0") {
|
|
3887
3906
|
dmsString += "\u00A0".concat(minString, "'\u00A0").concat(secString, ".").concat(deciSecString, "\""); // "\xa0" is here for non-breaking space
|
|
3888
3907
|
}
|
|
3889
|
-
else if (secNumeric != 0) {
|
|
3908
|
+
else if (trailingZeroDp === 4 || secNumeric != 0) {
|
|
3890
3909
|
dmsString += "\u00A0".concat(minString, "'\u00A0").concat(secString, "\"");
|
|
3891
3910
|
}
|
|
3892
3911
|
else {
|
|
@@ -4449,17 +4468,20 @@ var TextInputValidator = function (props, value, data, context) {
|
|
|
4449
4468
|
}
|
|
4450
4469
|
if (value != "") {
|
|
4451
4470
|
var number = parseFloat(value);
|
|
4471
|
+
if (nf.notZero && number === 0) {
|
|
4472
|
+
return "Must not be 0";
|
|
4473
|
+
}
|
|
4452
4474
|
if (nf.gtMin != null && number <= nf.gtMin) {
|
|
4453
|
-
return "Must be greater than ".concat(nf.gtMin);
|
|
4475
|
+
return "Must be greater than ".concat(nf.gtMin.toLocaleString());
|
|
4454
4476
|
}
|
|
4455
4477
|
if (nf.geMin != null && number < nf.geMin) {
|
|
4456
|
-
return "Must not be less than ".concat(nf.geMin);
|
|
4478
|
+
return "Must not be less than ".concat(nf.geMin.toLocaleString());
|
|
4457
4479
|
}
|
|
4458
4480
|
if (nf.ltMax != null && number >= nf.ltMax) {
|
|
4459
|
-
return "Must be less than ".concat(nf.ltMax);
|
|
4481
|
+
return "Must be less than ".concat(nf.ltMax.toLocaleString());
|
|
4460
4482
|
}
|
|
4461
4483
|
if (nf.leMax != null && number > nf.leMax) {
|
|
4462
|
-
return "Must not be greater than ".concat(nf.leMax);
|
|
4484
|
+
return "Must not be greater than ".concat(nf.leMax.toLocaleString());
|
|
4463
4485
|
}
|
|
4464
4486
|
if (nf.precision != null && value != "") {
|
|
4465
4487
|
if (parseFloat(number.toPrecision(nf.precision)) != number) {
|