@linzjs/step-ag-grid 1.3.0 → 1.4.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.d.ts +4 -2
- package/dist/index.js +3496 -88220
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridCell.d.ts +2 -1
- package/dist/src/components/GridPopoverHook.d.ts +7 -0
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -0
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -0
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +2 -1
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +271 -1
- package/dist/src/components/gridPopoverEdit/{GridPopoutMenu.d.ts → GridPopoverMenu.d.ts} +2 -2
- package/dist/src/contexts/GridContext.d.ts +1 -1
- package/dist/src/stories/components/FormTest.d.ts +2 -2
- package/dist/src/stories/components/GridPopoutBearing.stories.d.ts +1 -1
- package/dist/src/stories/components/GridPopoutEditDropDown.stories.d.ts +1 -1
- package/dist/src/stories/components/GridPopoutEditGeneric.stories.d.ts +1 -1
- package/dist/src/stories/components/GridPopoutEditGenericTextArea.stories.d.ts +1 -1
- package/dist/src/stories/components/GridPopoutEditMultiSelect.stories.d.ts +1 -1
- package/dist/src/stories/components/GridReadOnly.stories.d.ts +1 -1
- package/dist/src/utils/bearing.d.ts +2 -1
- package/dist/src/utils/bearing.test.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +3490 -88217
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +38 -39
- package/src/components/Grid.tsx +3 -3
- package/src/components/GridCell.tsx +27 -3
- package/src/components/{GridPopoutHook.tsx → GridPopoverHook.tsx} +7 -5
- package/src/components/gridForm/GridFormDropDown.tsx +13 -6
- package/src/components/gridForm/GridFormEditBearing.tsx +6 -5
- package/src/components/gridForm/GridFormMessage.tsx +3 -3
- package/src/components/gridForm/GridFormMultiSelect.tsx +3 -3
- package/src/components/gridForm/GridFormPopoutMenu.tsx +9 -7
- package/src/components/gridForm/GridFormTextArea.tsx +4 -4
- package/src/components/gridForm/GridFormTextInput.tsx +4 -4
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +1 -2
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +29 -4
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +1 -2
- package/src/components/gridPopoverEdit/{GridPopoutMenu.scss → GridPopoverMenu.scss} +0 -0
- package/src/components/gridPopoverEdit/{GridPopoutMenu.tsx → GridPopoverMenu.tsx} +2 -2
- package/src/contexts/GridContext.tsx +1 -1
- package/src/contexts/GridContextProvider.tsx +2 -2
- package/src/lui/TextInputFormatted.scss +1 -1
- package/src/stories/components/FormTest.tsx +6 -6
- package/src/stories/components/GridPopoutBearing.stories.tsx +18 -15
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +11 -10
- package/src/stories/components/GridPopoutEditGeneric.stories.tsx +4 -4
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +7 -9
- package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +9 -9
- package/src/stories/components/GridReadOnly.stories.tsx +15 -10
- package/src/utils/bearing.test.ts +30 -0
- package/src/utils/bearing.ts +19 -8
- package/dist/src/components/GridPopoutHook.d.ts +0 -7
|
@@ -2,10 +2,10 @@ import "./FormTest.scss";
|
|
|
2
2
|
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import { LuiTextInput } from "@linzjs/lui";
|
|
5
|
-
import { wait } from "
|
|
6
|
-
import { GridFormProps } from "
|
|
7
|
-
import {
|
|
8
|
-
import { GridBaseRow } from "
|
|
5
|
+
import { wait } from "@utils/util";
|
|
6
|
+
import { GridFormProps } from "@components/GridCell";
|
|
7
|
+
import { useGridPopoverHook } from "@components/GridPopoverHook";
|
|
8
|
+
import { GridBaseRow } from "@components/Grid";
|
|
9
9
|
|
|
10
10
|
export interface IFormTestRow {
|
|
11
11
|
id: number;
|
|
@@ -33,9 +33,9 @@ export const FormTest = <RowType extends GridBaseRow>(props: GridFormProps<RowTy
|
|
|
33
33
|
// Close form
|
|
34
34
|
return true;
|
|
35
35
|
}, [nameType, numba, plan, props.selectedRows]);
|
|
36
|
-
const {
|
|
36
|
+
const { popoverWrapper } = useGridPopoverHook(props, save);
|
|
37
37
|
|
|
38
|
-
return
|
|
38
|
+
return popoverWrapper(
|
|
39
39
|
<div style={{ display: "flex", flexDirection: "row" }} className={"FormTest Grid-popoverContainer"}>
|
|
40
40
|
<div className={"FormTest-textInput"}>
|
|
41
41
|
<LuiTextInput label={"Name type"} value={nameType} onChange={(e) => setNameType(e.target.value)} />
|
|
@@ -3,13 +3,16 @@ import "@linzjs/lui/dist/fonts";
|
|
|
3
3
|
import "../../lui-overrides.scss";
|
|
4
4
|
|
|
5
5
|
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
-
import { GridContextProvider } from "../../contexts/GridContextProvider";
|
|
7
|
-
import { Grid, GridProps } from "../../components/Grid";
|
|
8
6
|
import { useMemo, useState } from "react";
|
|
9
|
-
import { UpdatingContextProvider } from "
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { GridCell } from "
|
|
7
|
+
import { UpdatingContextProvider } from "@contexts/UpdatingContextProvider";
|
|
8
|
+
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
9
|
+
import { Grid, GridProps } from "@components/Grid";
|
|
10
|
+
import { GridCell } from "@components/GridCell";
|
|
11
|
+
import {
|
|
12
|
+
GridPopoverEditBearing,
|
|
13
|
+
GridPopoverEditBearingCorrection,
|
|
14
|
+
} from "@components/gridPopoverEdit/GridPopoverEditBearing";
|
|
15
|
+
import { wait } from "@utils/util";
|
|
13
16
|
|
|
14
17
|
export default {
|
|
15
18
|
title: "Components / Grids",
|
|
@@ -34,7 +37,7 @@ export default {
|
|
|
34
37
|
interface ITestRow {
|
|
35
38
|
id: number;
|
|
36
39
|
bearing1: number | null;
|
|
37
|
-
|
|
40
|
+
bearingCorrection: number | null;
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
@@ -59,15 +62,15 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
59
62
|
placeHolder: "Enter Bearing",
|
|
60
63
|
},
|
|
61
64
|
}),
|
|
62
|
-
|
|
63
|
-
field: "
|
|
64
|
-
headerName: "Bearing
|
|
65
|
+
GridPopoverEditBearingCorrection<ITestRow>({
|
|
66
|
+
field: "bearingCorrection",
|
|
67
|
+
headerName: "Bearing Correction",
|
|
65
68
|
cellEditorParams: {
|
|
66
69
|
multiEdit: true,
|
|
67
70
|
placeHolder: "Enter Bearing",
|
|
68
|
-
onSave: async (selectedRows: ITestRow[], value: ITestRow["
|
|
71
|
+
onSave: async (selectedRows: ITestRow[], value: ITestRow["bearingCorrection"]) => {
|
|
69
72
|
await wait(1000);
|
|
70
|
-
selectedRows.forEach((row) => (row["
|
|
73
|
+
selectedRows.forEach((row) => (row["bearingCorrection"] = value));
|
|
71
74
|
return true;
|
|
72
75
|
},
|
|
73
76
|
},
|
|
@@ -79,9 +82,9 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
79
82
|
const rowData = useMemo(
|
|
80
83
|
() =>
|
|
81
84
|
[
|
|
82
|
-
{ id: 1000, bearing1: 1.234,
|
|
83
|
-
{ id: 1001, bearing1: 1.565,
|
|
84
|
-
{ id: 1002, bearing1: null,
|
|
85
|
+
{ id: 1000, bearing1: 1.234, bearingCorrection: 90 },
|
|
86
|
+
{ id: 1001, bearing1: 1.565, bearingCorrection: 240 },
|
|
87
|
+
{ id: 1002, bearing1: null, bearingCorrection: 355.1 },
|
|
85
88
|
] as ITestRow[],
|
|
86
89
|
[],
|
|
87
90
|
);
|
|
@@ -3,20 +3,20 @@ import "@linzjs/lui/dist/fonts";
|
|
|
3
3
|
import "../../lui-overrides.scss";
|
|
4
4
|
|
|
5
5
|
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { UpdatingContextProvider } from "@contexts/UpdatingContextProvider";
|
|
7
|
+
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
8
|
+
import { Grid, GridProps } from "@components/Grid";
|
|
8
9
|
import { useCallback, useMemo, useState } from "react";
|
|
9
10
|
import {
|
|
10
11
|
GridFormDropDown,
|
|
11
12
|
GridFormPopoutDropDownProps,
|
|
12
13
|
MenuSeparator,
|
|
13
14
|
MenuSeparatorString,
|
|
14
|
-
} from "
|
|
15
|
-
import { UpdatingContextProvider } from "../../contexts/UpdatingContextProvider";
|
|
15
|
+
} from "@components/gridForm/GridFormDropDown";
|
|
16
16
|
import { ColDef } from "ag-grid-community";
|
|
17
|
-
import { wait } from "
|
|
18
|
-
import { GridCell } from "
|
|
19
|
-
import { GridPopoverEditDropDown } from "
|
|
17
|
+
import { wait } from "@utils/util";
|
|
18
|
+
import { GridCell } from "@components/GridCell";
|
|
19
|
+
import { GridPopoverEditDropDown } from "@components/gridPopoverEdit/GridPopoverEditDropDown";
|
|
20
20
|
|
|
21
21
|
export default {
|
|
22
22
|
title: "Components / Grids",
|
|
@@ -94,11 +94,12 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
94
94
|
options: [
|
|
95
95
|
{
|
|
96
96
|
value: "1",
|
|
97
|
-
label:
|
|
97
|
+
label: "One",
|
|
98
|
+
disabled: "Disabled for test",
|
|
98
99
|
},
|
|
99
|
-
{ value: "2", label:
|
|
100
|
+
{ value: "2", label: "Two" },
|
|
100
101
|
MenuSeparator,
|
|
101
|
-
{ value: "3", label:
|
|
102
|
+
{ value: "3", label: "Three" },
|
|
102
103
|
],
|
|
103
104
|
},
|
|
104
105
|
}),
|
|
@@ -3,11 +3,11 @@ import "@linzjs/lui/dist/fonts";
|
|
|
3
3
|
import "../../lui-overrides.scss";
|
|
4
4
|
|
|
5
5
|
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { UpdatingContextProvider } from "@contexts/UpdatingContextProvider";
|
|
7
|
+
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
8
|
+
import { Grid, GridProps } from "@components/Grid";
|
|
8
9
|
import { useMemo, useState } from "react";
|
|
9
|
-
import {
|
|
10
|
-
import { GridCell } from "../../components/GridCell";
|
|
10
|
+
import { GridCell } from "@components/GridCell";
|
|
11
11
|
import { FormTest, IFormTestRow } from "./FormTest";
|
|
12
12
|
|
|
13
13
|
export default {
|
|
@@ -3,17 +3,15 @@ import "@linzjs/lui/dist/fonts";
|
|
|
3
3
|
import "../../lui-overrides.scss";
|
|
4
4
|
|
|
5
5
|
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { UpdatingContextProvider } from "@contexts/UpdatingContextProvider";
|
|
7
|
+
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
8
|
+
import { Grid, GridProps } from "@components/Grid";
|
|
8
9
|
import { useMemo, useState } from "react";
|
|
9
|
-
import {
|
|
10
|
-
import { GridCell } from "../../components/GridCell";
|
|
10
|
+
import { GridCell } from "@components/GridCell";
|
|
11
11
|
import { IFormTestRow } from "./FormTest";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { GridPopoverTextArea } from "../../components/gridPopoverEdit/GridPopoverTextArea";
|
|
16
|
-
import { GridPopoverTextInput } from "../../components/gridPopoverEdit/GridPopoverTextInput";
|
|
12
|
+
import { wait } from "@utils/util";
|
|
13
|
+
import { GridPopoverTextArea } from "@components/gridPopoverEdit/GridPopoverTextArea";
|
|
14
|
+
import { GridPopoverTextInput } from "@components/gridPopoverEdit/GridPopoverTextInput";
|
|
17
15
|
|
|
18
16
|
export default {
|
|
19
17
|
title: "Components / Grids",
|
|
@@ -3,17 +3,17 @@ import "@linzjs/lui/dist/fonts";
|
|
|
3
3
|
import "../../lui-overrides.scss";
|
|
4
4
|
|
|
5
5
|
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { UpdatingContextProvider } from "@contexts/UpdatingContextProvider";
|
|
7
|
+
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
8
|
+
import { Grid, GridProps } from "@components/Grid";
|
|
8
9
|
import { useMemo, useState } from "react";
|
|
9
|
-
import { MenuSeparator } from "
|
|
10
|
-
import { UpdatingContextProvider } from "../../contexts/UpdatingContextProvider";
|
|
10
|
+
import { MenuSeparator } from "@components/gridForm/GridFormDropDown";
|
|
11
11
|
import { ColDef } from "ag-grid-community";
|
|
12
|
-
import { wait } from "
|
|
13
|
-
import { MultiSelectResult } from "
|
|
14
|
-
import { GridSubComponentTextArea } from "
|
|
15
|
-
import { GridCell } from "
|
|
16
|
-
import { GridPopoutEditMultiSelect } from "
|
|
12
|
+
import { wait } from "@utils/util";
|
|
13
|
+
import { MultiSelectResult } from "@components/gridForm/GridFormMultiSelect";
|
|
14
|
+
import { GridSubComponentTextArea } from "@components/GridSubComponentTextArea";
|
|
15
|
+
import { GridCell } from "@components/GridCell";
|
|
16
|
+
import { GridPopoutEditMultiSelect } from "@components/gridPopoverEdit/GridPopoutEditMultiSelect";
|
|
17
17
|
|
|
18
18
|
export default {
|
|
19
19
|
title: "Components / Grids",
|
|
@@ -3,15 +3,15 @@ import "@linzjs/lui/dist/fonts";
|
|
|
3
3
|
import "../../lui-overrides.scss";
|
|
4
4
|
|
|
5
5
|
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { UpdatingContextProvider } from "@contexts/UpdatingContextProvider";
|
|
7
|
+
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
8
|
+
import { Grid, GridProps } from "@components/Grid";
|
|
8
9
|
import { useMemo, useState } from "react";
|
|
9
|
-
import {
|
|
10
|
-
import { wait } from "../../utils/util";
|
|
10
|
+
import { wait } from "@utils/util";
|
|
11
11
|
import { ICellRendererParams } from "ag-grid-community";
|
|
12
|
-
import {
|
|
13
|
-
import { GridPopoverMessage } from "
|
|
14
|
-
import { GridCell } from "
|
|
12
|
+
import { GridPopoverMenu } from "@components/gridPopoverEdit/GridPopoverMenu";
|
|
13
|
+
import { GridPopoverMessage } from "@components/gridPopoverEdit/GridPopoverMessage";
|
|
14
|
+
import { GridCell } from "@components/GridCell";
|
|
15
15
|
|
|
16
16
|
export default {
|
|
17
17
|
title: "Components / Grids",
|
|
@@ -84,7 +84,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
84
84
|
multiEdit: true,
|
|
85
85
|
},
|
|
86
86
|
}),
|
|
87
|
-
|
|
87
|
+
GridPopoverMenu<ITestRow>({
|
|
88
88
|
headerName: "Menu",
|
|
89
89
|
cellEditorParams: {
|
|
90
90
|
options: async () => {
|
|
@@ -109,11 +109,16 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
109
109
|
},
|
|
110
110
|
multiEdit: true,
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
label: "Disabled item",
|
|
114
|
+
disabled: "Disabled for test",
|
|
115
|
+
multiEdit: true,
|
|
116
|
+
},
|
|
112
117
|
];
|
|
113
118
|
},
|
|
114
119
|
},
|
|
115
120
|
}),
|
|
116
|
-
|
|
121
|
+
GridPopoverMenu<ITestRow>({
|
|
117
122
|
headerName: "Menu disabled",
|
|
118
123
|
editable: false,
|
|
119
124
|
cellEditorParams: {
|
|
@@ -138,7 +143,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
138
143
|
return (
|
|
139
144
|
<Grid
|
|
140
145
|
{...props}
|
|
141
|
-
selectable={
|
|
146
|
+
selectable={true}
|
|
142
147
|
externalSelectedItems={externalSelectedItems}
|
|
143
148
|
setExternalSelectedItems={setExternalSelectedItems}
|
|
144
149
|
columnDefs={columnDefs}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { convertDDToDMS } from "./bearing";
|
|
2
|
+
|
|
3
|
+
describe("convertDDToDMS", () => {
|
|
4
|
+
test("converts decimal-ish degrees to DMS", () => {
|
|
5
|
+
expect(convertDDToDMS(-0.001, false, false)).toBe("-0° 00' 10\"");
|
|
6
|
+
expect(convertDDToDMS(-10.001, false, false)).toBe("-10° 00' 10\"");
|
|
7
|
+
expect(convertDDToDMS(-370.001, false, false)).toBe("-10° 00' 10\"");
|
|
8
|
+
expect(convertDDToDMS(359.595999, false, false)).toBe("0° 00'");
|
|
9
|
+
expect(convertDDToDMS(369.696999, false, false)).toBe("10° 10' 10\"");
|
|
10
|
+
expect(convertDDToDMS(221.555999, false, false)).toBe("221° 56'");
|
|
11
|
+
expect(convertDDToDMS(221.555999, false, true)).toBe("221° 56' 00.0\"");
|
|
12
|
+
expect(convertDDToDMS(5)).toBe("+5° 00' 00.0\"");
|
|
13
|
+
expect(convertDDToDMS(5.0)).toBe("+5° 00' 00.0\"");
|
|
14
|
+
expect(convertDDToDMS(5.00001)).toBe("+5° 00' 00.1\"");
|
|
15
|
+
expect(convertDDToDMS(5.1)).toBe("+5° 10' 00.0\"");
|
|
16
|
+
expect(convertDDToDMS(5.12345)).toBe("+5° 12' 34.5\"");
|
|
17
|
+
expect(convertDDToDMS(5.12345, false)).toBe("5° 12' 34.5\"");
|
|
18
|
+
|
|
19
|
+
expect(convertDDToDMS(300)).toBe("+300° 00' 00.0\"");
|
|
20
|
+
expect(convertDDToDMS(300.0)).toBe("+300° 00' 00.0\"");
|
|
21
|
+
expect(convertDDToDMS(300.00001)).toBe("+300° 00' 00.1\"");
|
|
22
|
+
expect(convertDDToDMS(300.1)).toBe("+300° 10' 00.0\"");
|
|
23
|
+
expect(convertDDToDMS(300.12345)).toBe("+300° 12' 34.5\"");
|
|
24
|
+
expect(convertDDToDMS(300.12345, false)).toBe("300° 12' 34.5\"");
|
|
25
|
+
|
|
26
|
+
expect(convertDDToDMS(300, false, false)).toBe("300° 00'");
|
|
27
|
+
expect(convertDDToDMS(300.1, false, false)).toBe("300° 10'");
|
|
28
|
+
expect(convertDDToDMS(0, false)).toBe("0° 00'");
|
|
29
|
+
});
|
|
30
|
+
});
|
package/src/utils/bearing.ts
CHANGED
|
@@ -5,7 +5,15 @@ export const bearingValueFormatter = (params: ValueFormatterParams): string => {
|
|
|
5
5
|
if (value == null) {
|
|
6
6
|
return "-";
|
|
7
7
|
}
|
|
8
|
-
return convertDDToDMS(value);
|
|
8
|
+
return convertDDToDMS(value, false, false);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const bearingCorrectionValueFormatter = (params: ValueFormatterParams): string => {
|
|
12
|
+
const value = params.value;
|
|
13
|
+
if (value == null) {
|
|
14
|
+
return "-";
|
|
15
|
+
}
|
|
16
|
+
return convertDDToDMS(value, true, true);
|
|
9
17
|
};
|
|
10
18
|
|
|
11
19
|
export const bearingNumberParser = (value: string): number | null => {
|
|
@@ -13,27 +21,30 @@ export const bearingNumberParser = (value: string): number | null => {
|
|
|
13
21
|
return parseFloat(value);
|
|
14
22
|
};
|
|
15
23
|
|
|
16
|
-
const validMaskForDmsBearing = /^(
|
|
17
|
-
export const bearingStringValidator = (
|
|
24
|
+
const validMaskForDmsBearing = /^((-)?\d+)?(\.([0-5](\d([0-5](\d(\d+)?)?)?)?)?)?$/;
|
|
25
|
+
export const bearingStringValidator = (
|
|
26
|
+
value: string,
|
|
27
|
+
customValidate?: (value: number | null) => string | null,
|
|
28
|
+
): string | null => {
|
|
18
29
|
value = value.trim();
|
|
19
30
|
if (value === "") return null;
|
|
20
31
|
const match = value.match(validMaskForDmsBearing);
|
|
21
32
|
if (!match) return "Bearing must be a positive number in D.MMSSS format";
|
|
22
|
-
const decimalPart = match[
|
|
33
|
+
const decimalPart = match[4];
|
|
23
34
|
if (decimalPart != null && decimalPart.length > 5) {
|
|
24
35
|
return "Bearing has a maximum of 5 decimal places";
|
|
25
36
|
}
|
|
26
37
|
|
|
27
38
|
const bearing = parseFloat(value);
|
|
28
|
-
|
|
29
|
-
return null;
|
|
39
|
+
|
|
40
|
+
return customValidate ? customValidate(bearing) : null;
|
|
30
41
|
};
|
|
31
42
|
|
|
32
43
|
// Decimal-ish degrees to Degrees Minutes Seconds converter
|
|
33
44
|
export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, addTrailingZeros = true): string => {
|
|
34
45
|
if (dd == null) return "–";
|
|
35
46
|
|
|
36
|
-
if (dd === 0) addTrailingZeros =
|
|
47
|
+
if (dd === 0) addTrailingZeros = false;
|
|
37
48
|
|
|
38
49
|
// toFixed rounds parts up greater than 60, which has to be corrected below
|
|
39
50
|
const [bearingWholeString, beringDecimalString] = dd.toFixed(5).split(".");
|
|
@@ -64,7 +75,7 @@ export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, add
|
|
|
64
75
|
dmsString += `\xa0${minString}'\xa0${secString}.${deciSecString}"`; // "\xa0" is here for non-breaking space
|
|
65
76
|
} else if (secNumeric != 0) {
|
|
66
77
|
dmsString += `\xa0${minString}'\xa0${secString}"`;
|
|
67
|
-
} else
|
|
78
|
+
} else {
|
|
68
79
|
dmsString += `\xa0${minString}'`;
|
|
69
80
|
}
|
|
70
81
|
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { GridFormProps } from "./GridCell";
|
|
3
|
-
import { GridBaseRow } from "./Grid";
|
|
4
|
-
export declare const useGridPopoutHook: <RowType extends GridBaseRow>(props: GridFormProps<RowType>, save?: ((selectedRows: any[]) => Promise<boolean>) | undefined) => {
|
|
5
|
-
popoutWrapper: (children: JSX.Element) => JSX.Element;
|
|
6
|
-
triggerSave: (reason?: string) => Promise<void>;
|
|
7
|
-
};
|