@linzjs/step-ag-grid 1.2.0 → 1.3.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.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +1 -0
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -0
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +4 -0
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +4 -0
- package/dist/step-ag-grid.esm.js +6 -0
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/gridForm/GridFormTextArea.tsx +4 -0
- package/src/components/gridForm/GridFormTextInput.tsx +4 -0
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +20 -0
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +20 -0
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +12 -6
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends Gene
|
|
|
9
9
|
required?: boolean;
|
|
10
10
|
maxlength?: number;
|
|
11
11
|
width?: string | number;
|
|
12
|
+
validate?: (value: string) => string | null;
|
|
12
13
|
onSave?: (selectedRows: RowType[], value: string) => Promise<boolean>;
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -23,6 +24,9 @@ export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormPro
|
|
|
23
24
|
if (formProps.maxlength && value.length > formProps.maxlength) {
|
|
24
25
|
return `Text must be no longer than ${formProps.maxlength} characters`;
|
|
25
26
|
}
|
|
27
|
+
if (formProps.validate) {
|
|
28
|
+
return formProps.validate(value);
|
|
29
|
+
}
|
|
26
30
|
return null;
|
|
27
31
|
}, [formProps.maxlength, formProps.required, value.length]);
|
|
28
32
|
|
|
@@ -9,6 +9,7 @@ export interface GridFormTextInputProps<RowType extends GridBaseRow> extends Gen
|
|
|
9
9
|
required?: boolean;
|
|
10
10
|
maxlength?: number;
|
|
11
11
|
width?: string | number;
|
|
12
|
+
validate?: (value: string) => string | null;
|
|
12
13
|
onSave?: (selectedRows: RowType[], value: string) => Promise<boolean>;
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -23,6 +24,9 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormPr
|
|
|
23
24
|
if (formProps.maxlength && value.length > formProps.maxlength) {
|
|
24
25
|
return `Text must be no longer than ${formProps.maxlength} characters`;
|
|
25
26
|
}
|
|
27
|
+
if (formProps.validate) {
|
|
28
|
+
return formProps.validate(value);
|
|
29
|
+
}
|
|
26
30
|
return null;
|
|
27
31
|
}, [formProps.maxlength, formProps.required, value.length]);
|
|
28
32
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GridCell } from "../GridCell";
|
|
2
|
+
import { GridBaseRow } from "../Grid";
|
|
3
|
+
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
4
|
+
import { GridFormTextArea, GridFormTextAreaProps } from "../gridForm/GridFormTextArea";
|
|
5
|
+
|
|
6
|
+
export const GridPopoverTextArea = <RowType extends GridBaseRow>(
|
|
7
|
+
colDef: GenericCellColDef<RowType, GridFormTextAreaProps<RowType>>,
|
|
8
|
+
) => {
|
|
9
|
+
return GridCell<RowType, GridFormTextAreaProps<RowType>>({
|
|
10
|
+
maxWidth: 260,
|
|
11
|
+
...colDef,
|
|
12
|
+
...(colDef?.cellEditorParams && {
|
|
13
|
+
cellEditorParams: {
|
|
14
|
+
width: 260,
|
|
15
|
+
...colDef.cellEditorParams,
|
|
16
|
+
form: GridFormTextArea,
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GridCell } from "../GridCell";
|
|
2
|
+
import { GridBaseRow } from "../Grid";
|
|
3
|
+
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
4
|
+
import { GridFormTextInput, GridFormTextInputProps } from "../gridForm/GridFormTextInput";
|
|
5
|
+
|
|
6
|
+
export const GridPopoverTextInput = <RowType extends GridBaseRow>(
|
|
7
|
+
colDef: GenericCellColDef<RowType, GridFormTextInputProps<RowType>>,
|
|
8
|
+
) => {
|
|
9
|
+
return GridCell<RowType, GridFormTextInputProps<RowType>>({
|
|
10
|
+
maxWidth: 140,
|
|
11
|
+
...colDef,
|
|
12
|
+
...(colDef?.cellEditorParams && {
|
|
13
|
+
cellEditorParams: {
|
|
14
|
+
width: 240,
|
|
15
|
+
...colDef.cellEditorParams,
|
|
16
|
+
form: GridFormTextInput,
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -12,6 +12,8 @@ import { IFormTestRow } from "./FormTest";
|
|
|
12
12
|
import { GridFormTextArea, GridFormTextAreaProps } from "../../components/gridForm/GridFormTextArea";
|
|
13
13
|
import { GridFormTextInput, GridFormTextInputProps } from "../../components/gridForm/GridFormTextInput";
|
|
14
14
|
import { wait } from "../../utils/util";
|
|
15
|
+
import { GridPopoverTextArea } from "../../components/gridPopoverEdit/GridPopoverTextArea";
|
|
16
|
+
import { GridPopoverTextInput } from "../../components/gridPopoverEdit/GridPopoverTextInput";
|
|
15
17
|
|
|
16
18
|
export default {
|
|
17
19
|
title: "Components / Grids",
|
|
@@ -43,16 +45,18 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
|
|
|
43
45
|
initialWidth: 65,
|
|
44
46
|
maxWidth: 85,
|
|
45
47
|
}),
|
|
46
|
-
|
|
48
|
+
GridPopoverTextInput<IFormTestRow>({
|
|
47
49
|
field: "name",
|
|
48
50
|
headerName: "Text input",
|
|
49
51
|
maxWidth: 140,
|
|
50
52
|
cellEditorParams: {
|
|
51
|
-
form: GridFormTextInput,
|
|
52
53
|
required: true,
|
|
53
54
|
maxlength: 12,
|
|
54
55
|
placeholder: "Enter some text...",
|
|
55
|
-
|
|
56
|
+
validate: (value: string) => {
|
|
57
|
+
if (value === "never") return "The value 'never' is not allowed";
|
|
58
|
+
return null;
|
|
59
|
+
},
|
|
56
60
|
multiEdit: false,
|
|
57
61
|
onSave: async (selectedRows, value) => {
|
|
58
62
|
await wait(1000);
|
|
@@ -61,17 +65,19 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
|
|
|
61
65
|
},
|
|
62
66
|
},
|
|
63
67
|
}),
|
|
64
|
-
|
|
68
|
+
GridPopoverTextArea<IFormTestRow>({
|
|
65
69
|
field: "plan",
|
|
66
70
|
headerName: "Text area",
|
|
67
71
|
maxWidth: 140,
|
|
68
72
|
cellEditorParams: {
|
|
69
|
-
form: GridFormTextArea,
|
|
70
73
|
required: true,
|
|
71
74
|
maxlength: 32,
|
|
72
75
|
placeholder: "Enter some text...",
|
|
73
|
-
width: 260,
|
|
74
76
|
multiEdit: true,
|
|
77
|
+
validate: (value: string) => {
|
|
78
|
+
if (value === "never") return "The value 'never' is not allowed";
|
|
79
|
+
return null;
|
|
80
|
+
},
|
|
75
81
|
onSave: async (selectedRows, value) => {
|
|
76
82
|
await wait(1000);
|
|
77
83
|
selectedRows.forEach((selectedRow) => (selectedRow["plan"] = value));
|