@linzjs/step-ag-grid 8.1.0 → 8.2.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/index.css +19 -5
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -0
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +2 -2
- package/dist/src/utils/bearing.d.ts +2 -0
- package/dist/step-ag-grid.esm.js +46 -46
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +0 -11
- package/src/components/GridCell.tsx +2 -2
- package/src/components/gridForm/GridFormDropDown.tsx +8 -4
- package/src/components/gridForm/GridFormEditBearing.tsx +1 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +10 -8
- package/src/components/gridForm/GridFormPopoverMenu.tsx +2 -0
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +8 -13
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +3 -3
- package/src/react-menu3/styles/_var.scss +1 -1
- package/src/stories/grid/GridReadOnly.stories.tsx +4 -0
- package/src/stories/grid/gridForm/GridFormDropDown.stories.tsx +2 -6
- package/src/stories/grid/gridForm/GridFormEditBearing.stories.tsx +8 -12
- package/src/stories/grid/gridForm/GridFormEditBearingCorrection.stories.tsx +8 -12
- package/src/stories/grid/gridForm/GridFormMessage.stories.tsx +0 -1
- package/src/stories/grid/gridForm/GridFormMultiSelect.stories.tsx +70 -0
- package/src/stories/grid/gridForm/GridFormTextArea.stories.tsx +44 -0
- package/src/stories/grid/gridForm/GridFormTextInput.stories.tsx +44 -0
- package/src/styles/Grid.scss +1 -1
- package/src/styles/GridFormMultiSelect.scss +4 -0
- package/src/styles/GridIcon.scss +10 -0
- package/src/styles/lui-overrides.scss +1 -1
- package/src/styles/react-menu-customisations.scss +2 -2
- package/src/utils/bearing.test.ts +46 -3
- package/src/utils/bearing.ts +14 -0
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
bearingCorrectionRangeValidator,
|
|
3
|
+
bearingRangeValidator,
|
|
4
|
+
bearingStringValidator,
|
|
5
|
+
convertDDToDMS,
|
|
6
|
+
} from "./bearing";
|
|
2
7
|
|
|
3
|
-
describe("
|
|
4
|
-
test("converts decimal-ish degrees to DMS", () => {
|
|
8
|
+
describe("bearing", () => {
|
|
9
|
+
test("convertDDToDMS converts decimal-ish degrees to DMS", () => {
|
|
5
10
|
expect(convertDDToDMS(-0.001, false, false)).toBe("-0° 00' 10\"");
|
|
6
11
|
expect(convertDDToDMS(-10.001, false, false)).toBe("-10° 00' 10\"");
|
|
7
12
|
expect(convertDDToDMS(-370.001, false, false)).toBe("-10° 00' 10\"");
|
|
@@ -27,4 +32,42 @@ describe("convertDDToDMS", () => {
|
|
|
27
32
|
expect(convertDDToDMS(300.1, false, false)).toBe("300° 10'");
|
|
28
33
|
expect(convertDDToDMS(0, false)).toBe("0° 00'");
|
|
29
34
|
});
|
|
35
|
+
|
|
36
|
+
test("bearingStringValidator", () => {
|
|
37
|
+
const tests: [string, string | null][] = [
|
|
38
|
+
["", null],
|
|
39
|
+
["1", null],
|
|
40
|
+
["1.2345", null],
|
|
41
|
+
["-1.2345", null],
|
|
42
|
+
["360.2345", null],
|
|
43
|
+
["-360.2345", null],
|
|
44
|
+
["1.2e6", "Bearing must be a number in D.MMSSS format"],
|
|
45
|
+
["0.60000", "Bearing must be a number in D.MMSSS format"],
|
|
46
|
+
["0.00600", "Bearing must be a number in D.MMSSS format"],
|
|
47
|
+
["0.123456", "Bearing has a maximum of 5 decimal places"],
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
tests.forEach((test, i) => {
|
|
51
|
+
expect(bearingStringValidator(test[0]), `Test ${i}: "${test[0]}" should return "${test[1]}"`).toBe(test[1]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// calls custom invalid
|
|
55
|
+
const fn = jest.fn();
|
|
56
|
+
bearingStringValidator("1.2", fn);
|
|
57
|
+
expect(fn).toHaveBeenCalledWith(1.2);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("bearingRangeValidator", () => {
|
|
61
|
+
expect(bearingRangeValidator(0)).toBeNull();
|
|
62
|
+
expect(bearingRangeValidator(359.595999)).toBeNull();
|
|
63
|
+
expect(bearingRangeValidator(-0.00001)).toBe("Bearing must not be negative");
|
|
64
|
+
expect(bearingRangeValidator(360)).toBe("Bearing must be less than 360 degrees");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("bearingCorrectionRangeValidator", () => {
|
|
68
|
+
expect(bearingCorrectionRangeValidator(-179.59999)).toBeNull();
|
|
69
|
+
expect(bearingCorrectionRangeValidator(359.59999)).toBeNull();
|
|
70
|
+
expect(bearingCorrectionRangeValidator(-180)).toBe("Bearing correction must be greater then -180 degrees");
|
|
71
|
+
expect(bearingCorrectionRangeValidator(360)).toBe("Bearing correction must be less than 360 degrees");
|
|
72
|
+
});
|
|
30
73
|
});
|
package/src/utils/bearing.ts
CHANGED
|
@@ -81,3 +81,17 @@ export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, add
|
|
|
81
81
|
|
|
82
82
|
return dmsString;
|
|
83
83
|
};
|
|
84
|
+
|
|
85
|
+
export const bearingRangeValidator = (value: number | null) => {
|
|
86
|
+
if (value === null) return "Bearing is required";
|
|
87
|
+
if (value >= 360) return "Bearing must be less than 360 degrees";
|
|
88
|
+
if (value < 0) return "Bearing must not be negative";
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const bearingCorrectionRangeValidator = (value: number | null) => {
|
|
93
|
+
if (value === null) return "Bearing correction is required";
|
|
94
|
+
if (value >= 360) return "Bearing correction must be less than 360 degrees";
|
|
95
|
+
if (value <= -180) return "Bearing correction must be greater then -180 degrees";
|
|
96
|
+
return null;
|
|
97
|
+
};
|