@linzjs/step-ag-grid 1.5.3 → 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 +9 -9
- package/dist/index.js +410 -358
- package/dist/index.js.map +1 -1
- package/dist/src/components/Grid.d.ts +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 +5 -10
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +3 -4
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -3
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -4
- 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/GridContext.d.ts +1 -0
- 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 +404 -356
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +20 -15
- 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 +27 -29
- package/src/components/gridForm/GridFormPopoutMenu.tsx +10 -11
- package/src/components/gridForm/GridFormTextArea.tsx +16 -17
- package/src/components/gridForm/GridFormTextInput.tsx +19 -18
- 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/GridContext.tsx +4 -0
- package/src/contexts/GridContextProvider.tsx +13 -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
|
@@ -3,19 +3,13 @@ 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 {
|
|
6
|
+
import { GridUpdatingContextProvider } from "@contexts/GridUpdatingContextProvider";
|
|
7
7
|
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
8
8
|
import { Grid, GridProps } from "@components/Grid";
|
|
9
9
|
import { useCallback, useMemo, useState } from "react";
|
|
10
|
-
import {
|
|
11
|
-
GridFormDropDown,
|
|
12
|
-
GridFormPopoutDropDownProps,
|
|
13
|
-
MenuSeparator,
|
|
14
|
-
MenuSeparatorString,
|
|
15
|
-
} from "@components/gridForm/GridFormDropDown";
|
|
16
|
-
import { ColDef } from "ag-grid-community";
|
|
10
|
+
import { MenuHeaderItem, MenuSeparator, MenuSeparatorString } from "@components/gridForm/GridFormDropDown";
|
|
17
11
|
import { wait } from "@utils/util";
|
|
18
|
-
import { GridCell } from "@components/GridCell";
|
|
12
|
+
import { ColDefT, GridCell } from "@components/GridCell";
|
|
19
13
|
import { GridPopoverEditDropDown } from "@components/gridPopoverEdit/GridPopoverEditDropDown";
|
|
20
14
|
|
|
21
15
|
export default {
|
|
@@ -28,11 +22,11 @@ export default {
|
|
|
28
22
|
decorators: [
|
|
29
23
|
(Story) => (
|
|
30
24
|
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
31
|
-
<
|
|
25
|
+
<GridUpdatingContextProvider>
|
|
32
26
|
<GridContextProvider>
|
|
33
27
|
<Story />
|
|
34
28
|
</GridContextProvider>
|
|
35
|
-
</
|
|
29
|
+
</GridUpdatingContextProvider>
|
|
36
30
|
</div>
|
|
37
31
|
),
|
|
38
32
|
],
|
|
@@ -80,33 +74,39 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
80
74
|
[],
|
|
81
75
|
);
|
|
82
76
|
|
|
83
|
-
const columnDefs = useMemo(
|
|
84
|
-
() =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
const columnDefs: ColDefT<ITestRow>[] = useMemo(
|
|
78
|
+
() => [
|
|
79
|
+
GridCell({
|
|
80
|
+
field: "id",
|
|
81
|
+
headerName: "Id",
|
|
82
|
+
initialWidth: 65,
|
|
83
|
+
maxWidth: 85,
|
|
84
|
+
}),
|
|
85
|
+
GridPopoverEditDropDown(
|
|
86
|
+
{
|
|
93
87
|
field: "position",
|
|
94
88
|
initialWidth: 65,
|
|
95
89
|
maxWidth: 150,
|
|
96
90
|
headerName: "Position",
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
multiEdit: false,
|
|
94
|
+
editorParams: {
|
|
99
95
|
options: ["Architect", "Developer", "Product Owner", "Scrum Master", "Tester", MenuSeparator, "(other)"],
|
|
100
|
-
multiEdit: false,
|
|
101
96
|
},
|
|
102
|
-
}
|
|
103
|
-
|
|
97
|
+
},
|
|
98
|
+
),
|
|
99
|
+
GridPopoverEditDropDown(
|
|
100
|
+
{
|
|
104
101
|
field: "position2",
|
|
105
102
|
maxWidth: 100,
|
|
106
103
|
headerName: "Multi-edit",
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
multiEdit: true,
|
|
107
|
+
editorParams: {
|
|
109
108
|
options: [
|
|
109
|
+
MenuHeaderItem("Header"),
|
|
110
110
|
{
|
|
111
111
|
value: "1",
|
|
112
112
|
label: "One",
|
|
@@ -117,27 +117,36 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
117
117
|
{ value: "3", label: "Three" },
|
|
118
118
|
],
|
|
119
119
|
},
|
|
120
|
-
}
|
|
121
|
-
|
|
120
|
+
},
|
|
121
|
+
),
|
|
122
|
+
GridPopoverEditDropDown(
|
|
123
|
+
{
|
|
122
124
|
field: "position3",
|
|
123
125
|
initialWidth: 65,
|
|
124
126
|
maxWidth: 150,
|
|
125
127
|
headerName: "Custom callback",
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
multiEdit: true,
|
|
131
|
+
editorParams: {
|
|
128
132
|
options: [null, "Architect", "Developer", "Product Owner", "Scrum Master", "Tester", "(other)"],
|
|
129
133
|
onSelectedItem: async (selected) => {
|
|
130
134
|
await wait(2000);
|
|
131
135
|
selected.selectedRows.forEach((row) => (row.position3 = selected.value));
|
|
132
136
|
},
|
|
133
137
|
},
|
|
134
|
-
}
|
|
135
|
-
|
|
138
|
+
},
|
|
139
|
+
),
|
|
140
|
+
GridPopoverEditDropDown(
|
|
141
|
+
{
|
|
136
142
|
field: "position",
|
|
137
143
|
initialWidth: 65,
|
|
138
144
|
maxWidth: 150,
|
|
139
145
|
headerName: "Options Fn",
|
|
140
|
-
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
multiEdit: false,
|
|
149
|
+
editorParams: {
|
|
141
150
|
filtered: "reload",
|
|
142
151
|
filterPlaceholder: "Search me...",
|
|
143
152
|
options: optionsFn,
|
|
@@ -148,44 +157,75 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
148
157
|
// eslint-disable-next-line no-console
|
|
149
158
|
console.log("optionsRequestCancelled");
|
|
150
159
|
},
|
|
151
|
-
multiEdit: false,
|
|
152
160
|
},
|
|
153
|
-
}
|
|
154
|
-
|
|
161
|
+
},
|
|
162
|
+
),
|
|
163
|
+
GridPopoverEditDropDown(
|
|
164
|
+
{
|
|
155
165
|
field: "position3",
|
|
156
166
|
initialWidth: 65,
|
|
157
167
|
maxWidth: 150,
|
|
158
168
|
headerName: "Filtered",
|
|
159
|
-
|
|
160
|
-
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
multiEdit: true,
|
|
172
|
+
editorParams: {
|
|
161
173
|
filtered: "local",
|
|
162
174
|
filterPlaceholder: "Filter this",
|
|
163
175
|
options: [null, "Architect", "Developer", "Product Owner", "Scrum Master", "Tester", "(other)"],
|
|
164
176
|
},
|
|
165
|
-
}
|
|
166
|
-
|
|
177
|
+
},
|
|
178
|
+
),
|
|
179
|
+
GridPopoverEditDropDown(
|
|
180
|
+
{
|
|
167
181
|
field: "position4",
|
|
168
182
|
initialWidth: 65,
|
|
169
183
|
maxWidth: 150,
|
|
170
184
|
headerName: "Filtered (object)",
|
|
171
185
|
valueGetter: (params) => params.data.position4?.desc,
|
|
172
|
-
|
|
173
|
-
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
multiEdit: true,
|
|
189
|
+
editorParams: {
|
|
174
190
|
filtered: "local",
|
|
175
191
|
filterPlaceholder: "Filter this",
|
|
176
192
|
options: optionsObjects.map((o) => {
|
|
177
193
|
return { value: o, label: o.desc, disabled: false };
|
|
178
194
|
}),
|
|
179
195
|
},
|
|
180
|
-
}
|
|
181
|
-
|
|
196
|
+
},
|
|
197
|
+
),
|
|
198
|
+
GridPopoverEditDropDown(
|
|
199
|
+
{
|
|
200
|
+
field: "code",
|
|
201
|
+
initialWidth: 65,
|
|
202
|
+
maxWidth: 150,
|
|
203
|
+
headerName: "Max height",
|
|
204
|
+
valueGetter: (params) => params.data.code,
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
multiEdit: true,
|
|
208
|
+
editorParams: {
|
|
209
|
+
maxRows: 2,
|
|
210
|
+
filtered: "local",
|
|
211
|
+
filterPlaceholder: "Filter this",
|
|
212
|
+
options: Array.from(Array(30).keys()).map((o) => {
|
|
213
|
+
return { value: o, label: `${o}` };
|
|
214
|
+
}),
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
),
|
|
218
|
+
GridPopoverEditDropDown(
|
|
219
|
+
{
|
|
182
220
|
field: "code",
|
|
183
221
|
initialWidth: 65,
|
|
184
222
|
maxWidth: 150,
|
|
185
223
|
headerName: "Filter Selectable",
|
|
186
224
|
valueGetter: (params) => params.data.code,
|
|
187
|
-
|
|
188
|
-
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
multiEdit: true,
|
|
228
|
+
editorParams: {
|
|
189
229
|
filtered: "local",
|
|
190
230
|
filterPlaceholder: "Filter this",
|
|
191
231
|
options: optionsObjects.map((o) => {
|
|
@@ -198,8 +238,9 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
198
238
|
selected.selectedRows.forEach((row) => (row.code = selected.value));
|
|
199
239
|
},
|
|
200
240
|
},
|
|
201
|
-
}
|
|
202
|
-
|
|
241
|
+
},
|
|
242
|
+
),
|
|
243
|
+
],
|
|
203
244
|
[optionsFn, optionsObjects],
|
|
204
245
|
);
|
|
205
246
|
|
|
@@ -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 {
|
|
6
|
+
import { GridUpdatingContextProvider } from "@contexts/GridUpdatingContextProvider";
|
|
7
7
|
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
8
8
|
import { Grid, GridProps } from "@components/Grid";
|
|
9
9
|
import { useMemo, useState } from "react";
|
|
10
|
-
import { GridCell } from "@components/GridCell";
|
|
10
|
+
import { ColDefT, GridCell } from "@components/GridCell";
|
|
11
11
|
import { FormTest, IFormTestRow } from "./FormTest";
|
|
12
12
|
|
|
13
13
|
export default {
|
|
@@ -20,11 +20,11 @@ export default {
|
|
|
20
20
|
decorators: [
|
|
21
21
|
(Story) => (
|
|
22
22
|
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
23
|
-
<
|
|
23
|
+
<GridUpdatingContextProvider>
|
|
24
24
|
<GridContextProvider>
|
|
25
25
|
<Story />
|
|
26
26
|
</GridContextProvider>
|
|
27
|
-
</
|
|
27
|
+
</GridUpdatingContextProvider>
|
|
28
28
|
</div>
|
|
29
29
|
),
|
|
30
30
|
],
|
|
@@ -32,7 +32,7 @@ export default {
|
|
|
32
32
|
|
|
33
33
|
const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
34
34
|
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
35
|
-
const columnDefs = useMemo(
|
|
35
|
+
const columnDefs: ColDefT<IFormTestRow>[] = useMemo(
|
|
36
36
|
() => [
|
|
37
37
|
GridCell({
|
|
38
38
|
field: "id",
|
|
@@ -40,15 +40,20 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
|
|
|
40
40
|
initialWidth: 65,
|
|
41
41
|
maxWidth: 85,
|
|
42
42
|
}),
|
|
43
|
-
GridCell(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
form: FormTest,
|
|
49
|
-
multiEdit: false,
|
|
43
|
+
GridCell(
|
|
44
|
+
{
|
|
45
|
+
field: "name",
|
|
46
|
+
headerName: "Popout Generic Edit",
|
|
47
|
+
maxWidth: 140,
|
|
50
48
|
},
|
|
51
|
-
|
|
49
|
+
{
|
|
50
|
+
multiEdit: true,
|
|
51
|
+
editor: FormTest,
|
|
52
|
+
editorParams: {
|
|
53
|
+
a: 4,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
),
|
|
52
57
|
],
|
|
53
58
|
[],
|
|
54
59
|
);
|
|
@@ -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 {
|
|
6
|
+
import { GridUpdatingContextProvider } from "@contexts/GridUpdatingContextProvider";
|
|
7
7
|
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
8
8
|
import { Grid, GridProps } from "@components/Grid";
|
|
9
9
|
import { useMemo, useState } from "react";
|
|
10
|
-
import { GridCell } from "@components/GridCell";
|
|
10
|
+
import { ColDefT, GridCell } from "@components/GridCell";
|
|
11
11
|
import { IFormTestRow } from "./FormTest";
|
|
12
12
|
import { isFloat, wait } from "@utils/util";
|
|
13
13
|
import { GridPopoverTextArea } from "@components/gridPopoverEdit/GridPopoverTextArea";
|
|
@@ -23,11 +23,11 @@ export default {
|
|
|
23
23
|
decorators: [
|
|
24
24
|
(Story) => (
|
|
25
25
|
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
26
|
-
<
|
|
26
|
+
<GridUpdatingContextProvider>
|
|
27
27
|
<GridContextProvider>
|
|
28
28
|
<Story />
|
|
29
29
|
</GridContextProvider>
|
|
30
|
-
</
|
|
30
|
+
</GridUpdatingContextProvider>
|
|
31
31
|
</div>
|
|
32
32
|
),
|
|
33
33
|
],
|
|
@@ -35,7 +35,7 @@ export default {
|
|
|
35
35
|
|
|
36
36
|
const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
37
37
|
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
38
|
-
const columnDefs = useMemo(
|
|
38
|
+
const columnDefs: ColDefT<IFormTestRow>[] = useMemo(
|
|
39
39
|
() => [
|
|
40
40
|
GridCell({
|
|
41
41
|
field: "id",
|
|
@@ -43,70 +43,85 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
|
|
|
43
43
|
initialWidth: 65,
|
|
44
44
|
maxWidth: 85,
|
|
45
45
|
}),
|
|
46
|
-
GridPopoverTextInput
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
required: true,
|
|
52
|
-
maxlength: 12,
|
|
53
|
-
placeholder: "Enter some text...",
|
|
54
|
-
validate: (value: string) => {
|
|
55
|
-
if (value === "never") return "The value 'never' is not allowed";
|
|
56
|
-
return null;
|
|
57
|
-
},
|
|
58
|
-
multiEdit: false,
|
|
59
|
-
onSave: async (selectedRows, value) => {
|
|
60
|
-
await wait(1000);
|
|
61
|
-
selectedRows.forEach((selectedRow) => (selectedRow["name"] = value));
|
|
62
|
-
return true;
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
GridPopoverTextInput<IFormTestRow>({
|
|
67
|
-
field: "distance",
|
|
68
|
-
headerName: "Number input",
|
|
69
|
-
maxWidth: 140,
|
|
70
|
-
valueFormatter: (params) => {
|
|
71
|
-
const v = params.data.distance;
|
|
72
|
-
return v != null ? `${v}${params.colDef.cellEditorParams.units}` : v;
|
|
46
|
+
GridPopoverTextInput(
|
|
47
|
+
{
|
|
48
|
+
field: "name",
|
|
49
|
+
headerName: "Text input",
|
|
50
|
+
maxWidth: 140,
|
|
73
51
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
52
|
+
{
|
|
53
|
+
multiEdit: true,
|
|
54
|
+
editorParams: {
|
|
55
|
+
required: true,
|
|
56
|
+
maxlength: 12,
|
|
57
|
+
placeholder: "Enter some text...",
|
|
58
|
+
validate: (value: string) => {
|
|
59
|
+
if (value === "never") return "The value 'never' is not allowed";
|
|
60
|
+
return null;
|
|
61
|
+
},
|
|
62
|
+
onSave: async (selectedRows, value) => {
|
|
63
|
+
await wait(1000);
|
|
64
|
+
selectedRows.forEach((selectedRow) => (selectedRow["name"] = value));
|
|
65
|
+
return true;
|
|
66
|
+
},
|
|
81
67
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
68
|
+
},
|
|
69
|
+
),
|
|
70
|
+
GridPopoverTextInput(
|
|
71
|
+
{
|
|
72
|
+
field: "distance",
|
|
73
|
+
headerName: "Number input",
|
|
74
|
+
maxWidth: 140,
|
|
75
|
+
valueFormatter: (params) => {
|
|
76
|
+
const v = params.data.distance;
|
|
77
|
+
return v != null ? `${v}${params.colDef.cellEditorParams.units}` : v;
|
|
87
78
|
},
|
|
88
79
|
},
|
|
89
|
-
|
|
90
|
-
GridPopoverTextArea<IFormTestRow>({
|
|
91
|
-
field: "plan",
|
|
92
|
-
headerName: "Text area",
|
|
93
|
-
maxWidth: 140,
|
|
94
|
-
cellEditorParams: {
|
|
95
|
-
required: true,
|
|
96
|
-
maxlength: 32,
|
|
97
|
-
placeholder: "Enter some text...",
|
|
80
|
+
{
|
|
98
81
|
multiEdit: true,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
82
|
+
editorParams: {
|
|
83
|
+
maxlength: 12,
|
|
84
|
+
placeholder: "Enter distance...",
|
|
85
|
+
units: "m",
|
|
86
|
+
validate: (value: string) => {
|
|
87
|
+
if (value.length && !isFloat(value)) return "Value must be a number";
|
|
88
|
+
return null;
|
|
89
|
+
},
|
|
90
|
+
onSave: async (selectedRows, value) => {
|
|
91
|
+
await wait(1000);
|
|
92
|
+
selectedRows.forEach(
|
|
93
|
+
(selectedRow) => (selectedRow["distance"] = value.length ? parseFloat(value) : null),
|
|
94
|
+
);
|
|
95
|
+
return true;
|
|
96
|
+
},
|
|
102
97
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
},
|
|
99
|
+
),
|
|
100
|
+
GridPopoverTextArea(
|
|
101
|
+
{
|
|
102
|
+
field: "plan",
|
|
103
|
+
headerName: "Text area",
|
|
104
|
+
maxWidth: 140,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
multiEdit: true,
|
|
108
|
+
editorParams: {
|
|
109
|
+
required: true,
|
|
110
|
+
maxlength: 32,
|
|
111
|
+
placeholder: "Enter some text...",
|
|
112
|
+
|
|
113
|
+
validate: (value: string) => {
|
|
114
|
+
if (value === "never") return "The value 'never' is not allowed";
|
|
115
|
+
return null;
|
|
116
|
+
},
|
|
117
|
+
onSave: async (selectedRows, value) => {
|
|
118
|
+
await wait(1000);
|
|
119
|
+
selectedRows.forEach((selectedRow) => (selectedRow["plan"] = value));
|
|
120
|
+
return true;
|
|
121
|
+
},
|
|
107
122
|
},
|
|
108
123
|
},
|
|
109
|
-
|
|
124
|
+
),
|
|
110
125
|
],
|
|
111
126
|
[],
|
|
112
127
|
);
|
|
@@ -3,16 +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 {
|
|
6
|
+
import { GridUpdatingContextProvider } from "@contexts/GridUpdatingContextProvider";
|
|
7
7
|
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
8
8
|
import { Grid, GridProps } from "@components/Grid";
|
|
9
9
|
import { useMemo, useState } from "react";
|
|
10
10
|
import { MenuSeparator } from "@components/gridForm/GridFormDropDown";
|
|
11
|
-
import { ColDef } from "ag-grid-community";
|
|
12
11
|
import { wait } from "@utils/util";
|
|
13
12
|
import { MultiSelectResult } from "@components/gridForm/GridFormMultiSelect";
|
|
14
13
|
import { GridSubComponentTextArea } from "@components/GridSubComponentTextArea";
|
|
15
|
-
import { GridCell } from "@components/GridCell";
|
|
14
|
+
import { ColDefT, GridCell } from "@components/GridCell";
|
|
16
15
|
import { GridPopoutEditMultiSelect } from "@components/gridPopoverEdit/GridPopoutEditMultiSelect";
|
|
17
16
|
|
|
18
17
|
export default {
|
|
@@ -25,11 +24,11 @@ export default {
|
|
|
25
24
|
decorators: [
|
|
26
25
|
(Story) => (
|
|
27
26
|
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
28
|
-
<
|
|
27
|
+
<GridUpdatingContextProvider>
|
|
29
28
|
<GridContextProvider>
|
|
30
29
|
<Story />
|
|
31
30
|
</GridContextProvider>
|
|
32
|
-
</
|
|
31
|
+
</GridUpdatingContextProvider>
|
|
33
32
|
</div>
|
|
34
33
|
),
|
|
35
34
|
],
|
|
@@ -45,7 +44,7 @@ interface ITestRow {
|
|
|
45
44
|
const GridEditMultiSelectTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
46
45
|
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
47
46
|
|
|
48
|
-
const columnDefs = useMemo(() => {
|
|
47
|
+
const columnDefs: ColDefT<ITestRow>[] = useMemo(() => {
|
|
49
48
|
const positionTwoMap: Record<string, string> = {
|
|
50
49
|
"1": "One",
|
|
51
50
|
"2": "Two",
|
|
@@ -58,57 +57,65 @@ const GridEditMultiSelectTemplate: ComponentStory<typeof Grid> = (props: GridPro
|
|
|
58
57
|
initialWidth: 65,
|
|
59
58
|
maxWidth: 85,
|
|
60
59
|
}),
|
|
61
|
-
GridPopoutEditMultiSelect
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
value: "
|
|
79
|
-
|
|
80
|
-
|
|
60
|
+
GridPopoutEditMultiSelect(
|
|
61
|
+
{
|
|
62
|
+
field: "position",
|
|
63
|
+
initialWidth: 65,
|
|
64
|
+
maxWidth: 150,
|
|
65
|
+
headerName: "Position",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
multiEdit: true,
|
|
69
|
+
editorParams: {
|
|
70
|
+
filtered: true,
|
|
71
|
+
filterPlaceholder: "Filter position",
|
|
72
|
+
options: [
|
|
73
|
+
{ value: "a", label: "Architect" },
|
|
74
|
+
{ value: "b", label: "Developer" },
|
|
75
|
+
{ value: "c", label: "Product Owner" },
|
|
76
|
+
{ value: "d", label: "Scrum Master" },
|
|
77
|
+
{ value: "e", label: "Tester" },
|
|
78
|
+
MenuSeparator,
|
|
79
|
+
{
|
|
80
|
+
value: "f",
|
|
81
|
+
label: "Other",
|
|
82
|
+
subComponent: (props) => <GridSubComponentTextArea {...props} />,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
onSave: async (result: MultiSelectResult<ITestRow>) => {
|
|
86
|
+
// eslint-disable-next-line no-console
|
|
87
|
+
console.log(result);
|
|
88
|
+
await wait(1000);
|
|
89
|
+
return true;
|
|
81
90
|
},
|
|
82
|
-
],
|
|
83
|
-
onSave: async (result: MultiSelectResult<ITestRow>) => {
|
|
84
|
-
// eslint-disable-next-line no-console
|
|
85
|
-
console.log(result);
|
|
86
|
-
await wait(1000);
|
|
87
|
-
return true;
|
|
88
91
|
},
|
|
89
92
|
},
|
|
90
|
-
|
|
91
|
-
GridPopoutEditMultiSelect
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
),
|
|
94
|
+
GridPopoutEditMultiSelect(
|
|
95
|
+
{
|
|
96
|
+
field: "position2",
|
|
97
|
+
initialWidth: 65,
|
|
98
|
+
maxWidth: 150,
|
|
99
|
+
headerName: "Inital editor values ",
|
|
100
|
+
valueGetter: (props) => positionTwoMap[props.data.position2],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
98
103
|
multiEdit: false,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
editorParams: {
|
|
105
|
+
filtered: true,
|
|
106
|
+
filterPlaceholder: "Filter position",
|
|
107
|
+
initialSelectedValues: (selectedRows) => [selectedRows[0].position2],
|
|
108
|
+
options: Object.entries(positionTwoMap).map(([k, v]) => ({ value: k, label: v })),
|
|
109
|
+
onSave: async (result: MultiSelectResult<ITestRow>) => {
|
|
110
|
+
// eslint-disable-next-line no-console
|
|
111
|
+
console.log(result);
|
|
112
|
+
await wait(1000);
|
|
113
|
+
return true;
|
|
114
|
+
},
|
|
108
115
|
},
|
|
109
116
|
},
|
|
110
|
-
|
|
111
|
-
]
|
|
117
|
+
),
|
|
118
|
+
];
|
|
112
119
|
}, []);
|
|
113
120
|
|
|
114
121
|
const rowData = useMemo(
|