@linzjs/step-ag-grid 1.5.4 → 2.0.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/README.md +117 -2
- package/{src/components → dist}/GridTheme.scss +37 -23
- package/dist/index.css +351 -0
- package/dist/index.js +625 -332
- package/dist/index.js.map +1 -1
- package/dist/src/components/ComponentLoadingWrapper.d.ts +1 -0
- package/dist/src/components/Grid.d.ts +0 -2
- package/dist/src/components/GridCell.d.ts +21 -27
- package/dist/src/components/GridPopoverHook.d.ts +5 -2
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +10 -4
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +5 -5
- package/dist/src/components/gridForm/GridFormMessage.d.ts +4 -5
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +5 -4
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -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 +3 -4
- 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 +4 -5
- package/dist/src/contexts/GridContext.d.ts +1 -1
- 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/index.d.ts +31 -0
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -21
- package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +7 -0
- package/dist/src/react-menu3/contexts/HoverItemContext.d.ts +2 -0
- package/dist/src/react-menu3/contexts/ItemSettingsContext.d.ts +5 -0
- package/dist/src/react-menu3/contexts/MenuListContext.d.ts +9 -0
- package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +11 -0
- package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +7 -0
- package/dist/src/react-menu3/contexts/SettingsContext.d.ts +20 -0
- package/dist/src/react-menu3/index.d.ts +0 -1
- package/dist/src/react-menu3/utils/constants.d.ts +1 -50
- package/dist/step-ag-grid.esm.js +622 -312
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +39 -26
- package/src/components/ComponentLoadingWrapper.tsx +2 -1
- package/src/components/Grid.tsx +3 -8
- package/src/components/GridCell.tsx +62 -79
- package/src/components/GridLoadableCell.tsx +0 -1
- package/src/components/GridPopoverHook.tsx +18 -16
- package/src/components/gridForm/GridFormDropDown.tsx +47 -32
- package/src/components/gridForm/GridFormEditBearing.tsx +14 -14
- package/src/components/gridForm/GridFormMessage.tsx +11 -17
- package/src/components/gridForm/GridFormMultiSelect.tsx +89 -79
- package/src/components/gridForm/GridFormPopoutMenu.tsx +10 -11
- package/src/components/gridForm/GridFormTextArea.tsx +16 -17
- package/src/components/gridForm/GridFormTextInput.tsx +17 -17
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +20 -15
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +53 -45
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +21 -15
- package/src/components/gridPopoverEdit/GridPopoverMenu.scss +4 -4
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +21 -23
- 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 +5 -6
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +2 -2
- package/src/contexts/GridContext.tsx +1 -1
- package/src/contexts/GridContextProvider.tsx +3 -5
- package/src/contexts/GridPopoverContext.tsx +26 -0
- package/src/contexts/GridPopoverContextProvider.tsx +54 -0
- package/src/contexts/{UpdatingContext.tsx → GridUpdatingContext.tsx} +2 -2
- package/src/contexts/{UpdatingContextProvider.tsx → GridUpdatingContextProvider.tsx} +8 -6
- package/src/index.ts +38 -0
- package/src/lui/TextInputFormatted.scss +1 -1
- package/src/react-menu3/README.md +66 -0
- package/src/react-menu3/components/ControlledMenu.tsx +9 -17
- package/src/react-menu3/components/FocusableItem.tsx +2 -9
- package/src/react-menu3/components/MenuGroup.tsx +2 -1
- package/src/react-menu3/components/MenuItem.tsx +3 -12
- package/src/react-menu3/components/MenuList.tsx +4 -4
- package/src/react-menu3/components/MenuRadioGroup.tsx +3 -22
- package/src/react-menu3/components/SubMenu.tsx +4 -4
- package/src/react-menu3/contexts/EventHandlersContext.ts +11 -0
- package/src/react-menu3/contexts/HoverItemContext.ts +3 -0
- package/src/react-menu3/contexts/ItemSettingsContext.ts +6 -0
- package/src/react-menu3/contexts/MenuListContext.ts +10 -0
- package/src/react-menu3/contexts/MenuListItemContext.ts +16 -0
- package/src/react-menu3/contexts/RadioGroupContext.ts +8 -0
- package/src/react-menu3/contexts/SettingsContext.ts +20 -0
- package/src/react-menu3/hooks/useItemState.ts +3 -1
- package/src/react-menu3/index.ts +0 -1
- package/src/react-menu3/styles/_var.scss +4 -4
- package/src/react-menu3/styles/core.scss +6 -6
- package/src/react-menu3/styles/index.scss +10 -7
- package/src/react-menu3/styles/theme-dark.scss +4 -2
- package/src/react-menu3/styles/transitions/slide.scss +8 -8
- package/src/react-menu3/utils/constants.ts +1 -74
- package/src/react-menu3/utils/withHovering.tsx +1 -1
- package/src/stories/components/FormTest.scss +1 -2
- package/src/stories/components/FormTest.tsx +4 -3
- package/src/stories/components/GridPopoutBearing.stories.tsx +30 -26
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +94 -51
- package/src/stories/components/GridPopoutEditGeneric.stories.tsx +18 -14
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +78 -62
- package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +60 -52
- package/src/stories/components/GridReadOnly.stories.tsx +77 -64
- package/src/stories/components/ReactMenu.stories.tsx +0 -4
- package/src/{components → styles}/Grid.scss +9 -6
- package/src/styles/GridFormDropDown.scss +18 -0
- package/src/{components/gridForm → styles}/GridFormEditBearing.scss +0 -0
- package/src/styles/GridFormMultiSelect.scss +18 -0
- package/src/styles/GridRenderGenericCell.scss +15 -0
- package/src/styles/GridTheme.scss +108 -0
- package/src/styles/index.scss +2 -0
- package/src/styles/lui-overrides.scss +49 -0
- package/src/styles/react-menu-customisations.scss +135 -0
- package/dist/index.d.ts +0 -38
- package/dist/src/contexts/UpdatingContextProvider.d.ts +0 -7
- package/dist/src/stories/components/FormTest.d.ts +0 -13
- package/dist/src/stories/components/GridPopoutBearing.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditDropDown.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditGeneric.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditGenericTextArea.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditMultiSelect.stories.d.ts +0 -9
- package/dist/src/stories/components/GridReadOnly.stories.d.ts +0 -9
- package/dist/src/stories/components/ReactMenu.stories.d.ts +0 -8
- package/src/components/gridRender/GridRenderGenericCell.scss +0 -15
- package/src/lui-overrides.scss +0 -163
- package/src/react-menu3/style-utils.d.ts +0 -110
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../../styles/GridFormEditBearing.scss";
|
|
2
2
|
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import { GridBaseRow } from "../Grid";
|
|
5
5
|
import { TextInputFormatted } from "../../lui/TextInputFormatted";
|
|
6
6
|
import { bearingNumberParser, bearingStringValidator, convertDDToDMS } from "@utils/bearing";
|
|
7
|
-
import { GenericCellEditorParams, GridFormProps } from "../GridCell";
|
|
8
7
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
8
|
+
import { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
9
9
|
|
|
10
|
-
export interface GridFormEditBearingProps<RowType extends GridBaseRow> extends
|
|
11
|
-
placeHolder
|
|
10
|
+
export interface GridFormEditBearingProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
11
|
+
placeHolder?: string;
|
|
12
12
|
range?: (value: number | null) => string | null;
|
|
13
13
|
onSave?: (selectedRows: RowType[], value: number | null) => Promise<boolean>;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const GridFormEditBearing = <RowType extends GridBaseRow>(
|
|
17
|
-
const
|
|
16
|
+
export const GridFormEditBearing = <RowType extends GridBaseRow>(_props: GridFormEditBearingProps<RowType>) => {
|
|
17
|
+
const props = _props as GridFormEditBearingProps<RowType> & CellParams<RowType>;
|
|
18
18
|
const [value, setValue] = useState<string>(`${props.value ?? ""}`);
|
|
19
|
-
|
|
20
19
|
const save = useCallback(
|
|
21
20
|
async (selectedRows: RowType[]): Promise<boolean> => {
|
|
22
21
|
if (bearingStringValidator(value)) return false;
|
|
@@ -25,8 +24,9 @@ export const GridFormEditBearing = <RowType extends GridBaseRow>(props: GridForm
|
|
|
25
24
|
if (parsedValue === props.value) {
|
|
26
25
|
return true;
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
|
|
28
|
+
if (props.onSave) {
|
|
29
|
+
return await props.onSave(selectedRows, parsedValue);
|
|
30
30
|
} else {
|
|
31
31
|
const field = props.field;
|
|
32
32
|
if (field == null) {
|
|
@@ -37,9 +37,9 @@ export const GridFormEditBearing = <RowType extends GridBaseRow>(props: GridForm
|
|
|
37
37
|
}
|
|
38
38
|
return true;
|
|
39
39
|
},
|
|
40
|
-
[
|
|
40
|
+
[props, value],
|
|
41
41
|
);
|
|
42
|
-
const {
|
|
42
|
+
const { triggerSave, popoverWrapper } = useGridPopoverHook({ className: props.className, save });
|
|
43
43
|
|
|
44
44
|
return popoverWrapper(
|
|
45
45
|
<div className={"GridFormEditBearing-input Grid-popoverContainer"}>
|
|
@@ -50,13 +50,13 @@ export const GridFormEditBearing = <RowType extends GridBaseRow>(props: GridForm
|
|
|
50
50
|
}}
|
|
51
51
|
inputProps={{
|
|
52
52
|
autoFocus: true,
|
|
53
|
-
placeholder:
|
|
53
|
+
placeholder: props.placeHolder,
|
|
54
54
|
disabled: false,
|
|
55
55
|
maxLength: 16,
|
|
56
56
|
onKeyDown: async (e) => e.key === "Enter" && triggerSave().then(),
|
|
57
57
|
}}
|
|
58
|
-
formatted={bearingStringValidator(value,
|
|
59
|
-
error={bearingStringValidator(value,
|
|
58
|
+
formatted={bearingStringValidator(value, props.range) ? "?" : convertDDToDMS(bearingNumberParser(value))}
|
|
59
|
+
error={bearingStringValidator(value, props.range)}
|
|
60
60
|
/>
|
|
61
61
|
</div>,
|
|
62
62
|
);
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
1
2
|
import { useEffect, useState } from "react";
|
|
2
|
-
import { GenericCellEditorParams, GridFormProps } from "../GridCell";
|
|
3
|
-
import { ICellEditorParams } from "ag-grid-community";
|
|
4
3
|
import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
|
|
5
4
|
import { GridBaseRow } from "../Grid";
|
|
6
5
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
6
|
+
import { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
7
7
|
|
|
8
|
-
export interface GridFormMessageProps<RowType extends GridBaseRow> extends
|
|
9
|
-
message: (
|
|
10
|
-
selectedRows: RowType[],
|
|
11
|
-
cellEditorParams: ICellEditorParams,
|
|
12
|
-
) => Promise<string | JSX.Element> | string | JSX.Element;
|
|
8
|
+
export interface GridFormMessageProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
9
|
+
message: (cellParams: CellParams<RowType>) => Promise<string | JSX.Element> | string | JSX.Element;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
export const GridFormMessage = <RowType extends GridBaseRow>(
|
|
16
|
-
const
|
|
17
|
-
|
|
12
|
+
export const GridFormMessage = <RowType extends GridBaseRow>(_props: GridFormMessageProps<RowType>) => {
|
|
13
|
+
const props = _props as GridFormMessageProps<RowType> & CellParams<RowType>;
|
|
18
14
|
const [message, setMessage] = useState<string | JSX.Element | null>(null);
|
|
19
|
-
const { popoverWrapper } = useGridPopoverHook(props);
|
|
15
|
+
const { popoverWrapper } = useGridPopoverHook({ className: props.className });
|
|
20
16
|
|
|
21
17
|
useEffect(() => {
|
|
22
18
|
(async () => {
|
|
23
|
-
setMessage(await
|
|
19
|
+
setMessage(await props.message(props));
|
|
24
20
|
})().then();
|
|
25
|
-
}, [
|
|
21
|
+
}, [props]);
|
|
26
22
|
|
|
27
23
|
return popoverWrapper(
|
|
28
|
-
<ComponentLoadingWrapper loading={message === null}>
|
|
29
|
-
|
|
30
|
-
{message}
|
|
31
|
-
</div>
|
|
24
|
+
<ComponentLoadingWrapper loading={message === null} className={clsx("GridFormMessage-container", props.className)}>
|
|
25
|
+
<>{message}</>
|
|
32
26
|
</ComponentLoadingWrapper>,
|
|
33
27
|
);
|
|
34
28
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import "../../
|
|
1
|
+
import "../../styles/GridFormMultiSelect.scss";
|
|
2
2
|
|
|
3
|
-
import { MenuItem, MenuDivider, FocusableItem
|
|
4
|
-
import {
|
|
3
|
+
import { MenuItem, MenuDivider, FocusableItem } from "@react-menu3";
|
|
4
|
+
import { useCallback, useEffect, useRef, useState, KeyboardEvent } from "react";
|
|
5
5
|
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 { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
12
|
+
import { ClickEvent } from "../../react-menu3/types";
|
|
12
13
|
|
|
13
14
|
interface MultiFinalSelectOption<ValueType> {
|
|
14
15
|
value: ValueType;
|
|
@@ -23,8 +24,14 @@ export interface MultiSelectResult<RowType> {
|
|
|
23
24
|
values: Record<string, any>;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType>
|
|
27
|
-
|
|
27
|
+
export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType> extends CellEditorCommon {
|
|
28
|
+
// This overrides CellEditorCommon to provide some common class options
|
|
29
|
+
className?:
|
|
30
|
+
| "GridMultiSelect-containerSmall"
|
|
31
|
+
| "GridMultiSelect-containerMedium"
|
|
32
|
+
| "GridMultiSelect-containerLarge"
|
|
33
|
+
| string
|
|
34
|
+
| undefined;
|
|
28
35
|
filtered?: boolean;
|
|
29
36
|
filterPlaceholder?: string;
|
|
30
37
|
onSave?: (props: MultiSelectResult<RowType>) => Promise<boolean>;
|
|
@@ -34,16 +41,17 @@ export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType
|
|
|
34
41
|
initialSelectedValues?: (selectedRows: RowType[]) => any[];
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(
|
|
45
|
+
props: GridFormMultiSelectProps<RowType, ValueType>,
|
|
46
|
+
) => {
|
|
47
|
+
const { selectedRows } = props as unknown as CellParams<RowType>;
|
|
40
48
|
const [filter, setFilter] = useState("");
|
|
41
49
|
const [filteredValues, setFilteredValues] = useState<any[]>([]);
|
|
42
50
|
const optionsInitialising = useRef(false);
|
|
43
51
|
const [options, setOptions] = useState<MultiFinalSelectOption<ValueType>[]>();
|
|
44
52
|
const subSelectedValues = useRef<Record<string, any>>({});
|
|
45
53
|
const [selectedValues, setSelectedValues] = useState<any[]>(() =>
|
|
46
|
-
|
|
54
|
+
props.initialSelectedValues ? props.initialSelectedValues(selectedRows) : [],
|
|
47
55
|
);
|
|
48
56
|
|
|
49
57
|
const save = useCallback(
|
|
@@ -51,24 +59,23 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
51
59
|
const values: Record<string, any> = fromPairs(
|
|
52
60
|
selectedValues.map((value) => [value, subSelectedValues.current[value] ?? true]),
|
|
53
61
|
);
|
|
54
|
-
if (
|
|
55
|
-
return await
|
|
62
|
+
if (props.onSave) {
|
|
63
|
+
return await props.onSave({ selectedRows, values });
|
|
56
64
|
}
|
|
57
65
|
return true;
|
|
58
66
|
},
|
|
59
|
-
[
|
|
67
|
+
[props, selectedValues],
|
|
60
68
|
);
|
|
61
|
-
const { popoverWrapper, triggerSave } = useGridPopoverHook(props, save);
|
|
62
69
|
|
|
63
70
|
// Load up options list if it's async function
|
|
64
71
|
useEffect(() => {
|
|
65
72
|
if (options || optionsInitialising.current) return;
|
|
66
73
|
optionsInitialising.current = true;
|
|
67
|
-
let optionsConf =
|
|
74
|
+
let optionsConf = props.options ?? [];
|
|
68
75
|
|
|
69
76
|
(async () => {
|
|
70
77
|
if (typeof optionsConf == "function") {
|
|
71
|
-
optionsConf = await optionsConf(
|
|
78
|
+
optionsConf = await optionsConf(selectedRows);
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
const optionsList = optionsConf?.map((item) => {
|
|
@@ -78,7 +85,7 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
78
85
|
return item;
|
|
79
86
|
}) as any as MultiFinalSelectOption<ValueType>[];
|
|
80
87
|
|
|
81
|
-
if (
|
|
88
|
+
if (props.filtered) {
|
|
82
89
|
// This is needed otherwise when filter input is rendered and sets autofocus
|
|
83
90
|
// the mouse up of the double click edit triggers the cell to cancel editing
|
|
84
91
|
delay(() => setOptions(optionsList), 100);
|
|
@@ -87,10 +94,10 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
87
94
|
}
|
|
88
95
|
optionsInitialising.current = false;
|
|
89
96
|
})();
|
|
90
|
-
}, [
|
|
97
|
+
}, [props.filtered, props.options, options, selectedRows]);
|
|
91
98
|
|
|
92
99
|
useEffect(() => {
|
|
93
|
-
if (!
|
|
100
|
+
if (!props.filtered || options == null) return;
|
|
94
101
|
setFilteredValues(
|
|
95
102
|
options
|
|
96
103
|
.map((option) => {
|
|
@@ -103,23 +110,24 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
103
110
|
})
|
|
104
111
|
.filter((r) => r !== undefined),
|
|
105
112
|
);
|
|
106
|
-
}, [
|
|
113
|
+
}, [props.filtered, filter, options]);
|
|
107
114
|
|
|
115
|
+
const { popoverWrapper, triggerSave } = useGridPopoverHook({ className: props.className, save });
|
|
108
116
|
return popoverWrapper(
|
|
109
|
-
<ComponentLoadingWrapper loading={!options}>
|
|
110
|
-
|
|
111
|
-
{options &&
|
|
117
|
+
<ComponentLoadingWrapper loading={!options} className={"GridFormMultiSelect-container"}>
|
|
118
|
+
<>
|
|
119
|
+
{options && props.filtered && (
|
|
112
120
|
<>
|
|
113
121
|
<FocusableItem className={"filter-item"} key={"filter"}>
|
|
114
122
|
{({ ref }: any) => (
|
|
115
|
-
<div style={{ display: "flex", width: "100%" }}>
|
|
123
|
+
<div style={{ display: "flex", width: "100%" }} className={"GridFormMultiSelect-filter"}>
|
|
116
124
|
<input
|
|
117
125
|
autoFocus
|
|
118
126
|
className={"free-text-input"}
|
|
119
127
|
style={{ border: "0px" }}
|
|
120
128
|
ref={ref}
|
|
121
129
|
type="text"
|
|
122
|
-
placeholder={
|
|
130
|
+
placeholder={props.filterPlaceholder ?? "Placeholder"}
|
|
123
131
|
data-testid={"filteredMenu-free-text-input"}
|
|
124
132
|
defaultValue={""}
|
|
125
133
|
onChange={(e) => setFilter(e.target.value.toLowerCase())}
|
|
@@ -130,70 +138,72 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
|
|
|
130
138
|
<MenuDivider key={`$$divider_filter`} />
|
|
131
139
|
</>
|
|
132
140
|
)}
|
|
133
|
-
{options
|
|
134
|
-
item
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
e
|
|
142
|
-
|
|
143
|
-
setSelectedValues(selectedValues.filter((value) => value != item.value));
|
|
144
|
-
} else {
|
|
145
|
-
setSelectedValues([...selectedValues, item.value]);
|
|
146
|
-
}
|
|
147
|
-
}}
|
|
148
|
-
onKeyDown={async (e: KeyboardEvent) => {
|
|
149
|
-
if (e.key === "Enter") triggerSave().then();
|
|
150
|
-
else if (e.key === " ") {
|
|
141
|
+
<div className={"GridFormMultiSelect-options"}>
|
|
142
|
+
{options?.map((item, index) =>
|
|
143
|
+
item.value === MenuSeparatorString ? (
|
|
144
|
+
<MenuDivider key={`$$divider_${index}`} />
|
|
145
|
+
) : filteredValues.includes(item.value) ? null : (
|
|
146
|
+
<div key={`${index}`}>
|
|
147
|
+
<MenuItem
|
|
148
|
+
key={`${index}`}
|
|
149
|
+
onClick={(e: ClickEvent) => {
|
|
150
|
+
e.keepOpen = true;
|
|
151
151
|
if (selectedValues.includes(item.value)) {
|
|
152
152
|
setSelectedValues(selectedValues.filter((value) => value != item.value));
|
|
153
153
|
} else {
|
|
154
154
|
setSelectedValues([...selectedValues, item.value]);
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
inputProps={{
|
|
166
|
-
onClick: (e) => {
|
|
156
|
+
}}
|
|
157
|
+
onKeyDown={async (e: KeyboardEvent) => {
|
|
158
|
+
if (e.key === "Enter") triggerSave().then();
|
|
159
|
+
else if (e.key === " ") {
|
|
160
|
+
if (selectedValues.includes(item.value)) {
|
|
161
|
+
setSelectedValues(selectedValues.filter((value) => value != item.value));
|
|
162
|
+
} else {
|
|
163
|
+
setSelectedValues([...selectedValues, item.value]);
|
|
164
|
+
}
|
|
167
165
|
e.preventDefault();
|
|
168
166
|
e.stopPropagation();
|
|
169
|
-
|
|
170
|
-
},
|
|
171
|
-
}}
|
|
172
|
-
onChange={() => {
|
|
173
|
-
/*Do nothing, change handled by menuItem*/
|
|
167
|
+
}
|
|
174
168
|
}}
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
>
|
|
170
|
+
<LuiCheckboxInput
|
|
171
|
+
isChecked={selectedValues.includes(item.value)}
|
|
172
|
+
value={`${item.value}`}
|
|
173
|
+
label={item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)}
|
|
174
|
+
inputProps={{
|
|
175
|
+
onClick: (e) => {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
e.stopPropagation();
|
|
178
|
+
return false;
|
|
179
|
+
},
|
|
180
|
+
}}
|
|
181
|
+
onChange={() => {
|
|
182
|
+
/*Do nothing, change handled by menuItem*/
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
</MenuItem>
|
|
177
186
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
{selectedValues.includes(item.value) && item.subComponent && (
|
|
188
|
+
<FocusableItem className={"LuiDeprecatedForms"} key={`${item.value}_subcomponent`}>
|
|
189
|
+
{(ref: any) =>
|
|
190
|
+
item.subComponent &&
|
|
191
|
+
item.subComponent(
|
|
192
|
+
{
|
|
193
|
+
setValue: (value: any) => {
|
|
194
|
+
subSelectedValues.current[item.value as string] = value;
|
|
195
|
+
},
|
|
186
196
|
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
ref,
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
</FocusableItem>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
),
|
|
204
|
+
)}
|
|
205
|
+
</div>
|
|
206
|
+
</>
|
|
197
207
|
</ComponentLoadingWrapper>,
|
|
198
208
|
);
|
|
199
209
|
};
|
|
@@ -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 { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
8
8
|
|
|
9
|
-
export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> extends
|
|
9
|
+
export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
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,10 +68,10 @@ 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(props);
|
|
71
|
+
const { popoverWrapper } = useGridPopoverHook({ className: props.className });
|
|
73
72
|
return popoverWrapper(
|
|
74
|
-
<ComponentLoadingWrapper loading={!filteredOptions}>
|
|
75
|
-
|
|
73
|
+
<ComponentLoadingWrapper loading={!filteredOptions} className={"GridFormPopupMenu"}>
|
|
74
|
+
<>
|
|
76
75
|
{options?.map((item, index) =>
|
|
77
76
|
item.label === PopoutMenuSeparator ? (
|
|
78
77
|
<MenuDivider key={`$$divider_${index}`} />
|
|
@@ -89,7 +88,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
|
|
|
89
88
|
)
|
|
90
89
|
),
|
|
91
90
|
)}
|
|
92
|
-
|
|
91
|
+
</>
|
|
93
92
|
</ComponentLoadingWrapper>,
|
|
94
93
|
);
|
|
95
94
|
};
|
|
@@ -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 { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
6
6
|
|
|
7
|
-
export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends
|
|
7
|
+
export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
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(props, save);
|
|
54
|
-
|
|
53
|
+
const { popoverWrapper } = useGridPopoverHook({ className: props.className, save });
|
|
55
54
|
return popoverWrapper(
|
|
56
|
-
<div style={{ display: "flex", flexDirection: "row", width:
|
|
55
|
+
<div style={{ display: "flex", flexDirection: "row", width: props.width ?? 240 }}>
|
|
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 { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
6
6
|
|
|
7
|
-
export interface GridFormTextInputProps<RowType extends GridBaseRow> extends
|
|
7
|
+
export interface GridFormTextInputProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
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(props, save);
|
|
57
|
+
const { popoverWrapper, triggerSave } = useGridPopoverHook({ className: props.className, 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,26 @@
|
|
|
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
|
-
|
|
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
|
+
editorParams: {
|
|
22
|
+
className: "GridMultiSelect-containerMedium",
|
|
23
|
+
...(props.editorParams as GridFormMultiSelectProps<RowType, ValueType>),
|
|
19
24
|
},
|
|
20
|
-
}
|
|
21
|
-
|
|
25
|
+
},
|
|
26
|
+
);
|