@linzjs/step-ag-grid 1.5.4 → 2.0.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 +2 -2
- package/dist/index.js +241 -200
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridCell.d.ts +18 -27
- package/dist/src/components/GridPopoverHook.d.ts +4 -2
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +8 -3
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +3 -4
- package/dist/src/components/gridForm/GridFormMessage.d.ts +4 -5
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +2 -3
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +2 -3
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -3
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +2 -3
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +5 -270
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +3 -2
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -3
- package/dist/src/contexts/GridPopoverContext.d.ts +17 -0
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +6 -0
- package/dist/src/contexts/{UpdatingContext.d.ts → GridUpdatingContext.d.ts} +2 -2
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +7 -0
- package/dist/src/stories/components/FormTest.d.ts +1 -2
- package/dist/step-ag-grid.esm.js +238 -198
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +2 -2
- package/src/components/GridCell.tsx +57 -79
- package/src/components/GridLoadableCell.tsx +4 -1
- package/src/components/GridPopoverHook.tsx +10 -14
- package/src/components/gridForm/GridFormDropDown.tsx +41 -30
- package/src/components/gridForm/GridFormEditBearing.tsx +13 -13
- package/src/components/gridForm/GridFormMessage.tsx +8 -13
- package/src/components/gridForm/GridFormMultiSelect.tsx +19 -19
- package/src/components/gridForm/GridFormPopoutMenu.tsx +7 -8
- package/src/components/gridForm/GridFormTextArea.tsx +16 -17
- package/src/components/gridForm/GridFormTextInput.tsx +17 -17
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +17 -16
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +53 -45
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +17 -16
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +20 -21
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +18 -16
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +12 -16
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +15 -15
- package/src/components/gridRender/GridRenderGenericCell.tsx +3 -5
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +2 -2
- package/src/contexts/GridContextProvider.tsx +3 -5
- package/src/contexts/GridPopoverContext.tsx +32 -0
- package/src/contexts/GridPopoverContextProvider.tsx +53 -0
- package/src/contexts/{UpdatingContext.tsx → GridUpdatingContext.tsx} +2 -2
- package/src/contexts/{UpdatingContextProvider.tsx → GridUpdatingContextProvider.tsx} +8 -6
- package/src/stories/components/FormTest.tsx +4 -3
- package/src/stories/components/GridPopoutBearing.stories.tsx +28 -25
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +91 -50
- package/src/stories/components/GridPopoutEditGeneric.stories.tsx +18 -13
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +76 -61
- package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +58 -51
- package/src/stories/components/GridReadOnly.stories.tsx +73 -57
- package/dist/src/contexts/UpdatingContextProvider.d.ts +0 -7
|
@@ -6,9 +6,9 @@ import { GridBaseRow } from "../Grid";
|
|
|
6
6
|
import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
|
|
7
7
|
import { delay, fromPairs } from "lodash-es";
|
|
8
8
|
import { LuiCheckboxInput } from "@linzjs/lui";
|
|
9
|
-
import { GenericCellEditorParams, GridFormProps } from "../GridCell";
|
|
10
9
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
11
10
|
import { MenuSeparatorString } from "@components/gridForm/GridFormDropDown";
|
|
11
|
+
import { CellParams } from "@components/GridCell";
|
|
12
12
|
|
|
13
13
|
interface MultiFinalSelectOption<ValueType> {
|
|
14
14
|
value: ValueType;
|
|
@@ -23,8 +23,7 @@ export interface MultiSelectResult<RowType> {
|
|
|
23
23
|
values: Record<string, any>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType>
|
|
27
|
-
extends GenericCellEditorParams<RowType> {
|
|
26
|
+
export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType> {
|
|
28
27
|
filtered?: boolean;
|
|
29
28
|
filterPlaceholder?: string;
|
|
30
29
|
onSave?: (props: MultiSelectResult<RowType>) => Promise<boolean>;
|
|
@@ -34,16 +33,17 @@ export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType
|
|
|
34
33
|
initialSelectedValues?: (selectedRows: RowType[]) => any[];
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(
|
|
37
|
+
props: GridFormMultiSelectProps<RowType, ValueType>,
|
|
38
|
+
) => {
|
|
39
|
+
const { selectedRows } = props as unknown as CellParams<RowType>;
|
|
40
40
|
const [filter, setFilter] = useState("");
|
|
41
41
|
const [filteredValues, setFilteredValues] = useState<any[]>([]);
|
|
42
42
|
const optionsInitialising = useRef(false);
|
|
43
43
|
const [options, setOptions] = useState<MultiFinalSelectOption<ValueType>[]>();
|
|
44
44
|
const subSelectedValues = useRef<Record<string, any>>({});
|
|
45
45
|
const [selectedValues, setSelectedValues] = useState<any[]>(() =>
|
|
46
|
-
|
|
46
|
+
props.initialSelectedValues ? props.initialSelectedValues(selectedRows) : [],
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
const save = useCallback(
|
|
@@ -51,24 +51,24 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
51
51
|
const values: Record<string, any> = fromPairs(
|
|
52
52
|
selectedValues.map((value) => [value, subSelectedValues.current[value] ?? true]),
|
|
53
53
|
);
|
|
54
|
-
if (
|
|
55
|
-
return await
|
|
54
|
+
if (props.onSave) {
|
|
55
|
+
return await props.onSave({ selectedRows, values });
|
|
56
56
|
}
|
|
57
57
|
return true;
|
|
58
58
|
},
|
|
59
|
-
[
|
|
59
|
+
[props, selectedValues],
|
|
60
60
|
);
|
|
61
|
-
const { popoverWrapper, triggerSave } = useGridPopoverHook(
|
|
61
|
+
const { popoverWrapper, triggerSave } = useGridPopoverHook({ save });
|
|
62
62
|
|
|
63
63
|
// Load up options list if it's async function
|
|
64
64
|
useEffect(() => {
|
|
65
65
|
if (options || optionsInitialising.current) return;
|
|
66
66
|
optionsInitialising.current = true;
|
|
67
|
-
let optionsConf =
|
|
67
|
+
let optionsConf = props.options ?? [];
|
|
68
68
|
|
|
69
69
|
(async () => {
|
|
70
70
|
if (typeof optionsConf == "function") {
|
|
71
|
-
optionsConf = await optionsConf(
|
|
71
|
+
optionsConf = await optionsConf(selectedRows);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const optionsList = optionsConf?.map((item) => {
|
|
@@ -78,7 +78,7 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
78
78
|
return item;
|
|
79
79
|
}) as any as MultiFinalSelectOption<ValueType>[];
|
|
80
80
|
|
|
81
|
-
if (
|
|
81
|
+
if (props.filtered) {
|
|
82
82
|
// This is needed otherwise when filter input is rendered and sets autofocus
|
|
83
83
|
// the mouse up of the double click edit triggers the cell to cancel editing
|
|
84
84
|
delay(() => setOptions(optionsList), 100);
|
|
@@ -87,10 +87,10 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
87
87
|
}
|
|
88
88
|
optionsInitialising.current = false;
|
|
89
89
|
})();
|
|
90
|
-
}, [
|
|
90
|
+
}, [props.filtered, props.options, options, selectedRows]);
|
|
91
91
|
|
|
92
92
|
useEffect(() => {
|
|
93
|
-
if (!
|
|
93
|
+
if (!props.filtered || options == null) return;
|
|
94
94
|
setFilteredValues(
|
|
95
95
|
options
|
|
96
96
|
.map((option) => {
|
|
@@ -103,12 +103,12 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
103
103
|
})
|
|
104
104
|
.filter((r) => r !== undefined),
|
|
105
105
|
);
|
|
106
|
-
}, [
|
|
106
|
+
}, [props.filtered, filter, options]);
|
|
107
107
|
|
|
108
108
|
return popoverWrapper(
|
|
109
109
|
<ComponentLoadingWrapper loading={!options}>
|
|
110
110
|
<div className={"Grid-popoverContainerList"}>
|
|
111
|
-
{options &&
|
|
111
|
+
{options && props.filtered && (
|
|
112
112
|
<>
|
|
113
113
|
<FocusableItem className={"filter-item"} key={"filter"}>
|
|
114
114
|
{({ ref }: any) => (
|
|
@@ -119,7 +119,7 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
119
119
|
style={{ border: "0px" }}
|
|
120
120
|
ref={ref}
|
|
121
121
|
type="text"
|
|
122
|
-
placeholder={
|
|
122
|
+
placeholder={props.filterPlaceholder ?? "Placeholder"}
|
|
123
123
|
data-testid={"filteredMenu-free-text-input"}
|
|
124
124
|
defaultValue={""}
|
|
125
125
|
onChange={(e) => setFilter(e.target.value.toLowerCase())}
|
|
@@ -3,10 +3,10 @@ import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { GridContext } from "@contexts/GridContext";
|
|
4
4
|
import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
|
|
5
5
|
import { MenuDivider, MenuItem } from "@react-menu3";
|
|
6
|
-
import { GenericCellEditorParams, GridFormProps } from "../GridCell";
|
|
7
6
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
7
|
+
import { CellParams } from "@components/GridCell";
|
|
8
8
|
|
|
9
|
-
export interface GridFormPopoutMenuProps<RowType extends GridBaseRow>
|
|
9
|
+
export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> {
|
|
10
10
|
options: (selectedRows: RowType[]) => Promise<MenuOption<RowType>[]>;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -29,9 +29,8 @@ export interface MenuOption<RowType> {
|
|
|
29
29
|
* NOTE: If the popout menu doesn't appear on single click when also selecting row it's because
|
|
30
30
|
* you need a useMemo around your columnDefs
|
|
31
31
|
*/
|
|
32
|
-
export const GridFormPopoutMenu = <RowType extends GridBaseRow>(
|
|
33
|
-
const
|
|
34
|
-
|
|
32
|
+
export const GridFormPopoutMenu = <RowType extends GridBaseRow>(_props: GridFormPopoutMenuProps<RowType>) => {
|
|
33
|
+
const props = _props as GridFormPopoutMenuProps<RowType> & CellParams<RowType>;
|
|
35
34
|
const { updatingCells } = useContext(GridContext);
|
|
36
35
|
const optionsInitialising = useRef(false);
|
|
37
36
|
const [options, setOptions] = useState<MenuOption<RowType>[]>();
|
|
@@ -40,7 +39,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
|
|
|
40
39
|
useEffect(() => {
|
|
41
40
|
if (options || optionsInitialising.current) return;
|
|
42
41
|
optionsInitialising.current = true;
|
|
43
|
-
const optionsConf =
|
|
42
|
+
const optionsConf = props.options ?? [];
|
|
44
43
|
|
|
45
44
|
(async () => {
|
|
46
45
|
if (typeof optionsConf == "function") {
|
|
@@ -51,7 +50,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
|
|
|
51
50
|
|
|
52
51
|
optionsInitialising.current = false;
|
|
53
52
|
})();
|
|
54
|
-
}, [options,
|
|
53
|
+
}, [options, props.options, props.selectedRows]);
|
|
55
54
|
|
|
56
55
|
const actionClick = useCallback(
|
|
57
56
|
async (menuOption: MenuOption<any>) => {
|
|
@@ -69,7 +68,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
|
|
|
69
68
|
return menuOption.label === PopoutMenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
|
|
70
69
|
});
|
|
71
70
|
|
|
72
|
-
const { popoverWrapper } = useGridPopoverHook(
|
|
71
|
+
const { popoverWrapper } = useGridPopoverHook();
|
|
73
72
|
return popoverWrapper(
|
|
74
73
|
<ComponentLoadingWrapper loading={!filteredOptions}>
|
|
75
74
|
<div className={"Grid-popoverContainerList"}>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useCallback, useState } from "react";
|
|
2
|
-
import { GenericCellEditorParams, GridFormProps } from "../GridCell";
|
|
3
2
|
import { TextAreaInput } from "../../lui/TextAreaInput";
|
|
4
3
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
5
4
|
import { GridBaseRow } from "../Grid";
|
|
5
|
+
import { CellParams } from "@components/GridCell";
|
|
6
6
|
|
|
7
|
-
export interface GridFormTextAreaProps<RowType extends GridBaseRow>
|
|
7
|
+
export interface GridFormTextAreaProps<RowType extends GridBaseRow> {
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
maxlength?: number;
|
|
@@ -13,22 +13,22 @@ export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends Gene
|
|
|
13
13
|
onSave?: (selectedRows: RowType[], value: string) => Promise<boolean>;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const GridFormTextArea = <RowType extends GridBaseRow>(
|
|
17
|
-
const
|
|
16
|
+
export const GridFormTextArea = <RowType extends GridBaseRow>(_props: GridFormTextAreaProps<RowType>) => {
|
|
17
|
+
const props = _props as GridFormTextAreaProps<RowType> & CellParams<RowType>;
|
|
18
18
|
const [value, setValue] = useState(props.value ?? "");
|
|
19
19
|
|
|
20
20
|
const invalid = useCallback(() => {
|
|
21
|
-
if (
|
|
21
|
+
if (props.required && value.length == 0) {
|
|
22
22
|
return `Some text is required`;
|
|
23
23
|
}
|
|
24
|
-
if (
|
|
25
|
-
return `Text must be no longer than ${
|
|
24
|
+
if (props.maxlength && value.length > props.maxlength) {
|
|
25
|
+
return `Text must be no longer than ${props.maxlength} characters`;
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
27
|
+
if (props.validate) {
|
|
28
|
+
return props.validate(value);
|
|
29
29
|
}
|
|
30
30
|
return null;
|
|
31
|
-
}, [
|
|
31
|
+
}, [props, value]);
|
|
32
32
|
|
|
33
33
|
const save = useCallback(
|
|
34
34
|
async (selectedRows: any[]): Promise<boolean> => {
|
|
@@ -36,8 +36,8 @@ export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormPro
|
|
|
36
36
|
|
|
37
37
|
if (props.value === (value ?? "")) return true;
|
|
38
38
|
|
|
39
|
-
if (
|
|
40
|
-
return await
|
|
39
|
+
if (props.onSave) {
|
|
40
|
+
return await props.onSave(selectedRows, value);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const field = props.field;
|
|
@@ -48,17 +48,16 @@ export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormPro
|
|
|
48
48
|
selectedRows.forEach((row) => (row[field] = value));
|
|
49
49
|
return true;
|
|
50
50
|
},
|
|
51
|
-
[
|
|
51
|
+
[props, invalid, value],
|
|
52
52
|
);
|
|
53
|
-
const { popoverWrapper } = useGridPopoverHook(
|
|
54
|
-
|
|
53
|
+
const { popoverWrapper } = useGridPopoverHook({ save });
|
|
55
54
|
return popoverWrapper(
|
|
56
|
-
<div style={{ display: "flex", flexDirection: "row", width:
|
|
55
|
+
<div style={{ display: "flex", flexDirection: "row", width: props.width ?? 240 }} className={"FormTest"}>
|
|
57
56
|
<TextAreaInput
|
|
58
57
|
value={value}
|
|
59
58
|
onChange={(e) => setValue(e.target.value)}
|
|
60
59
|
error={invalid()}
|
|
61
|
-
inputProps={{ placeholder:
|
|
60
|
+
inputProps={{ placeholder: props.placeholder }}
|
|
62
61
|
/>
|
|
63
62
|
</div>,
|
|
64
63
|
);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useCallback, useState } from "react";
|
|
2
|
-
import { GenericCellEditorParams, GridFormProps } from "../GridCell";
|
|
3
2
|
import { TextInputFormatted } from "../../lui/TextInputFormatted";
|
|
4
3
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
5
4
|
import { GridBaseRow } from "../Grid";
|
|
5
|
+
import { CellParams } from "@components/GridCell";
|
|
6
6
|
|
|
7
|
-
export interface GridFormTextInputProps<RowType extends GridBaseRow>
|
|
7
|
+
export interface GridFormTextInputProps<RowType extends GridBaseRow> {
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
units?: string;
|
|
10
10
|
required?: boolean;
|
|
@@ -15,24 +15,24 @@ export interface GridFormTextInputProps<RowType extends GridBaseRow> extends Gen
|
|
|
15
15
|
onSave?: (selectedRows: RowType[], value: string) => Promise<boolean>;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const GridFormTextInput = <RowType extends GridBaseRow>(
|
|
19
|
-
const
|
|
18
|
+
export const GridFormTextInput = <RowType extends GridBaseRow>(_props: GridFormTextInputProps<RowType>) => {
|
|
19
|
+
const props = _props as GridFormTextInputProps<RowType> & CellParams<RowType>;
|
|
20
20
|
const initValue = props.value == null ? "" : `${props.value}`;
|
|
21
21
|
const [value, setValue] = useState(initValue);
|
|
22
22
|
|
|
23
23
|
const invalid = useCallback(() => {
|
|
24
24
|
const trimmedValue = value.trim();
|
|
25
|
-
if (
|
|
25
|
+
if (props.required && trimmedValue.length == 0) {
|
|
26
26
|
return `Some text is required`;
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
29
|
-
return `Text must be no longer than ${
|
|
28
|
+
if (props.maxlength && trimmedValue.length > props.maxlength) {
|
|
29
|
+
return `Text must be no longer than ${props.maxlength} characters`;
|
|
30
30
|
}
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
31
|
+
if (props.validate) {
|
|
32
|
+
return props.validate(trimmedValue, props.data);
|
|
33
33
|
}
|
|
34
34
|
return null;
|
|
35
|
-
}, [
|
|
35
|
+
}, [props, value]);
|
|
36
36
|
|
|
37
37
|
const save = useCallback(
|
|
38
38
|
async (selectedRows: any[]): Promise<boolean> => {
|
|
@@ -40,8 +40,8 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormPr
|
|
|
40
40
|
const trimmedValue = value.trim();
|
|
41
41
|
if (initValue === trimmedValue) return true;
|
|
42
42
|
|
|
43
|
-
if (
|
|
44
|
-
return await
|
|
43
|
+
if (props.onSave) {
|
|
44
|
+
return await props.onSave(selectedRows, trimmedValue);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const field = props.field;
|
|
@@ -52,20 +52,20 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormPr
|
|
|
52
52
|
selectedRows.forEach((row) => (row[field] = trimmedValue));
|
|
53
53
|
return true;
|
|
54
54
|
},
|
|
55
|
-
[invalid, value, initValue,
|
|
55
|
+
[invalid, value, initValue, props],
|
|
56
56
|
);
|
|
57
|
-
const { popoverWrapper, triggerSave } = useGridPopoverHook(
|
|
57
|
+
const { popoverWrapper, triggerSave } = useGridPopoverHook({ save });
|
|
58
58
|
|
|
59
59
|
return popoverWrapper(
|
|
60
|
-
<div style={{ display: "flex", flexDirection: "row", width:
|
|
60
|
+
<div style={{ display: "flex", flexDirection: "row", width: props.width ?? 240 }} className={"FormTest"}>
|
|
61
61
|
<TextInputFormatted
|
|
62
62
|
value={value}
|
|
63
63
|
onChange={(e) => setValue(e.target.value)}
|
|
64
64
|
error={invalid()}
|
|
65
|
-
formatted={
|
|
65
|
+
formatted={props.units}
|
|
66
66
|
inputProps={{
|
|
67
67
|
style: { width: "100%" },
|
|
68
|
-
placeholder:
|
|
68
|
+
placeholder: props.placeholder,
|
|
69
69
|
onKeyDown: async (e) => e.key === "Enter" && triggerSave().then(),
|
|
70
70
|
}}
|
|
71
71
|
/>
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { GenericMultiEditCellClass } from "../GenericCellClass";
|
|
2
|
-
import {
|
|
3
|
-
import { GridCell } from "../GridCell";
|
|
2
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
4
3
|
import { GridBaseRow } from "../Grid";
|
|
5
4
|
import { GridFormMultiSelect, GridFormMultiSelectProps } from "../gridForm/GridFormMultiSelect";
|
|
5
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
6
6
|
|
|
7
7
|
export const GridPopoutEditMultiSelect = <RowType extends GridBaseRow, ValueType>(
|
|
8
|
-
colDef: GenericCellColDef<RowType
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
colDef: GenericCellColDef<RowType>,
|
|
9
|
+
props: GenericCellEditorProps<GridFormMultiSelectProps<RowType, ValueType>>,
|
|
10
|
+
): ColDefT<RowType> =>
|
|
11
|
+
GridCell(
|
|
12
|
+
{
|
|
13
|
+
initialWidth: 65,
|
|
14
|
+
maxWidth: 150,
|
|
15
|
+
cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined,
|
|
16
|
+
...colDef,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
editor: GridFormMultiSelect,
|
|
20
|
+
...props,
|
|
21
|
+
},
|
|
22
|
+
);
|
|
@@ -1,61 +1,69 @@
|
|
|
1
1
|
import { GenericMultiEditCellClass } from "../GenericCellClass";
|
|
2
|
-
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
3
2
|
import { bearingCorrectionValueFormatter, bearingValueFormatter } from "@utils/bearing";
|
|
4
|
-
import { GridCell } from "../GridCell";
|
|
3
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
5
4
|
import { GridFormEditBearing, GridFormEditBearingProps } from "../gridForm/GridFormEditBearing";
|
|
6
5
|
import { GridBaseRow } from "../Grid";
|
|
6
|
+
import { ColDef } from "ag-grid-community";
|
|
7
7
|
|
|
8
8
|
export const GridPopoverEditBearingLike = <RowType extends GridBaseRow>(
|
|
9
|
-
colDef:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
colDef: ColDef,
|
|
10
|
+
props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
|
|
11
|
+
): ColDefT<RowType> => {
|
|
12
|
+
return GridCell(
|
|
13
|
+
{
|
|
14
|
+
initialWidth: 65,
|
|
15
|
+
maxWidth: 150,
|
|
16
|
+
valueFormatter: bearingValueFormatter,
|
|
17
|
+
cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined,
|
|
18
|
+
...colDef,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
editor: GridFormEditBearing,
|
|
22
|
+
...props,
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
};
|
|
24
26
|
|
|
25
27
|
export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
|
|
26
|
-
colDef:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
30
|
-
...
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
colDef: ColDef,
|
|
29
|
+
props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
|
|
30
|
+
): ColDefT<RowType> => {
|
|
31
|
+
return GridPopoverEditBearingLike(
|
|
32
|
+
{ valueFormatter: bearingValueFormatter, ...colDef },
|
|
33
|
+
{
|
|
34
|
+
multiEdit: !!props.multiEdit,
|
|
35
|
+
editorParams: {
|
|
36
|
+
placeHolder: "Enter bearing correction",
|
|
37
|
+
range: (value: number | null) => {
|
|
38
|
+
if (value === null) return "Bearing correction is required";
|
|
39
|
+
if (value >= 360) return "Bearing correction must be less than 360 degrees";
|
|
40
|
+
if (value < 0) return "Bearing correction must not be negative";
|
|
41
|
+
return null;
|
|
42
|
+
},
|
|
43
|
+
...props.editorParams,
|
|
38
44
|
},
|
|
39
|
-
...init.cellEditorParams,
|
|
40
45
|
},
|
|
41
|
-
|
|
46
|
+
);
|
|
42
47
|
};
|
|
43
48
|
|
|
44
49
|
export const GridPopoverEditBearingCorrection = <RowType extends GridBaseRow>(
|
|
45
|
-
colDef:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
-
...
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
colDef: ColDef,
|
|
51
|
+
props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
|
|
52
|
+
): ColDefT<RowType> => {
|
|
53
|
+
return GridPopoverEditBearingLike(
|
|
54
|
+
{ valueFormatter: bearingCorrectionValueFormatter, ...colDef },
|
|
55
|
+
{
|
|
56
|
+
multiEdit: !!props.multiEdit,
|
|
57
|
+
editorParams: {
|
|
58
|
+
placeHolder: "Enter bearing correction",
|
|
59
|
+
range: (value: number | null) => {
|
|
60
|
+
if (value === null) return "Bearing is required";
|
|
61
|
+
if (value >= 360) return "Bearing must be less than 360 degrees";
|
|
62
|
+
if (value <= -180) return "Bearing must be greater then -180 degrees";
|
|
63
|
+
return null;
|
|
64
|
+
},
|
|
65
|
+
...props.editorParams,
|
|
57
66
|
},
|
|
58
|
-
...init.cellEditorParams,
|
|
59
67
|
},
|
|
60
|
-
|
|
68
|
+
);
|
|
61
69
|
};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { GenericMultiEditCellClass } from "../GenericCellClass";
|
|
2
|
-
import {
|
|
3
|
-
import { GridCell } from "../GridCell";
|
|
2
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
4
3
|
import { GridBaseRow } from "../Grid";
|
|
5
4
|
import { GridFormDropDown, GridFormPopoutDropDownProps } from "../gridForm/GridFormDropDown";
|
|
5
|
+
import { ColDef } from "ag-grid-community";
|
|
6
6
|
|
|
7
7
|
export const GridPopoverEditDropDown = <RowType extends GridBaseRow, ValueType>(
|
|
8
|
-
colDef:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
colDef: ColDef,
|
|
9
|
+
props: GenericCellEditorProps<GridFormPopoutDropDownProps<RowType, ValueType>>,
|
|
10
|
+
): ColDefT<RowType> =>
|
|
11
|
+
GridCell(
|
|
12
|
+
{
|
|
13
|
+
initialWidth: 65,
|
|
14
|
+
maxWidth: 150,
|
|
15
|
+
cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined,
|
|
16
|
+
...colDef,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
editor: GridFormDropDown,
|
|
20
|
+
...props,
|
|
21
|
+
},
|
|
22
|
+
);
|
|
@@ -4,32 +4,31 @@ import "../../react-menu3/styles/index.scss";
|
|
|
4
4
|
import { ColDef } from "ag-grid-community";
|
|
5
5
|
import { GenericMultiEditCellClass } from "../GenericCellClass";
|
|
6
6
|
import { GridBaseRow } from "../Grid";
|
|
7
|
-
import { GridCell } from "../GridCell";
|
|
7
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
8
8
|
import { GridFormPopoutMenu, GridFormPopoutMenuProps } from "../gridForm/GridFormPopoutMenu";
|
|
9
9
|
import { GridRenderPopoutMenuCell } from "../gridRender/GridRenderPopoutMenuCell";
|
|
10
|
-
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Popout burger menu
|
|
14
13
|
*/
|
|
15
14
|
export const GridPopoverMenu = <RowType extends GridBaseRow>(
|
|
16
|
-
colDef:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
cellEditorParams: {
|
|
30
|
-
multiEdit: true,
|
|
31
|
-
...colDef.cellEditorParams,
|
|
32
|
-
form: GridFormPopoutMenu,
|
|
15
|
+
colDef: ColDef,
|
|
16
|
+
props: GenericCellEditorProps<GridFormPopoutMenuProps<RowType>>,
|
|
17
|
+
): ColDefT<RowType> =>
|
|
18
|
+
GridCell<RowType, GridFormPopoutMenuProps<RowType>>(
|
|
19
|
+
{
|
|
20
|
+
maxWidth: 64,
|
|
21
|
+
editable: colDef.editable != null ? colDef.editable : true,
|
|
22
|
+
cellRenderer: GridRenderPopoutMenuCell,
|
|
23
|
+
cellClass: colDef?.cellEditorParams?.multiEdit !== false ? GenericMultiEditCellClass : undefined,
|
|
24
|
+
...colDef,
|
|
25
|
+
cellRendererParams: {
|
|
26
|
+
// Menus open on single click, this parameter is picked up in Grid.tsx
|
|
27
|
+
singleClickEdit: true,
|
|
33
28
|
},
|
|
34
|
-
}
|
|
35
|
-
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
editor: GridFormPopoutMenu,
|
|
32
|
+
...props,
|
|
33
|
+
},
|
|
34
|
+
);
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { GridCell } from "../GridCell";
|
|
1
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
2
2
|
import { GridFormMessage, GridFormMessageProps } from "../gridForm/GridFormMessage";
|
|
3
3
|
import { GridBaseRow } from "../Grid";
|
|
4
|
-
import {
|
|
4
|
+
import { ColDef } from "ag-grid-community";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverMessage = <RowType extends GridBaseRow>(
|
|
7
|
-
colDef:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
...colDef.cellEditorParams,
|
|
18
|
-
form: GridFormMessage,
|
|
7
|
+
colDef: ColDef,
|
|
8
|
+
props: GenericCellEditorProps<GridFormMessageProps<RowType>>,
|
|
9
|
+
): ColDefT<RowType> => {
|
|
10
|
+
return GridCell(
|
|
11
|
+
{
|
|
12
|
+
maxWidth: 140,
|
|
13
|
+
...colDef,
|
|
14
|
+
cellRendererParams: {
|
|
15
|
+
singleClickEdit: true,
|
|
16
|
+
...colDef.cellRendererParams,
|
|
19
17
|
},
|
|
20
|
-
}
|
|
21
|
-
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
editor: GridFormMessage,
|
|
21
|
+
...props,
|
|
22
|
+
},
|
|
23
|
+
);
|
|
22
24
|
};
|