@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
|
@@ -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(
|
|
@@ -3,14 +3,14 @@ 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 { wait } from "@utils/util";
|
|
11
11
|
import { GridPopoverMenu } from "@components/gridPopoverEdit/GridPopoverMenu";
|
|
12
|
+
import { CellParams, ColDefT, GridCell } from "@components/GridCell";
|
|
12
13
|
import { GridPopoverMessage } from "@components/gridPopoverEdit/GridPopoverMessage";
|
|
13
|
-
import { GridCell } from "@components/GridCell";
|
|
14
14
|
|
|
15
15
|
export default {
|
|
16
16
|
title: "Components / Grids",
|
|
@@ -22,11 +22,11 @@ export default {
|
|
|
22
22
|
decorators: [
|
|
23
23
|
(Story) => (
|
|
24
24
|
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
25
|
-
<
|
|
25
|
+
<GridUpdatingContextProvider>
|
|
26
26
|
<GridContextProvider>
|
|
27
27
|
<Story />
|
|
28
28
|
</GridContextProvider>
|
|
29
|
-
</
|
|
29
|
+
</GridUpdatingContextProvider>
|
|
30
30
|
</div>
|
|
31
31
|
),
|
|
32
32
|
],
|
|
@@ -42,7 +42,7 @@ interface ITestRow {
|
|
|
42
42
|
|
|
43
43
|
const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
44
44
|
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
45
|
-
const columnDefs = useMemo(
|
|
45
|
+
const columnDefs: ColDefT<ITestRow>[] = useMemo(
|
|
46
46
|
() => [
|
|
47
47
|
GridCell({
|
|
48
48
|
field: "id",
|
|
@@ -50,7 +50,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
50
50
|
initialWidth: 65,
|
|
51
51
|
maxWidth: 85,
|
|
52
52
|
}),
|
|
53
|
-
GridCell
|
|
53
|
+
GridCell({
|
|
54
54
|
field: "position",
|
|
55
55
|
headerName: "Position",
|
|
56
56
|
initialWidth: 65,
|
|
@@ -72,65 +72,81 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
72
72
|
initialWidth: 150,
|
|
73
73
|
maxWidth: 200,
|
|
74
74
|
}),
|
|
75
|
-
GridPopoverMessage
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return `There are ${selectedRows.length} row(s) selected`;
|
|
75
|
+
GridPopoverMessage(
|
|
76
|
+
{
|
|
77
|
+
headerName: "Popout message",
|
|
78
|
+
cellRenderer: () => <>Click me!</>,
|
|
79
|
+
cellRendererParams: {
|
|
80
|
+
warning: () => "x",
|
|
82
81
|
},
|
|
83
|
-
multiEdit: true,
|
|
84
82
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
{
|
|
84
|
+
editorParams: {
|
|
85
|
+
message: async (formParams: CellParams<ITestRow>): Promise<string> => {
|
|
86
|
+
await wait(1000);
|
|
87
|
+
return `There are ${formParams.selectedRows.length} row(s) selected`;
|
|
88
|
+
},
|
|
89
|
+
multiEdit: true,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
),
|
|
93
|
+
GridPopoverMenu(
|
|
94
|
+
{
|
|
95
|
+
headerName: "Menu",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
multiEdit: true,
|
|
99
|
+
editorParams: {
|
|
100
|
+
options: async (selectedItems) => {
|
|
101
|
+
// Just doing a timeout here to demonstrate deferred loading
|
|
102
|
+
await wait(500);
|
|
103
|
+
return [
|
|
104
|
+
{
|
|
105
|
+
label: "Single edit only",
|
|
106
|
+
action: async (selectedRows) => {
|
|
107
|
+
alert(`Single-edit: ${selectedRows.length} rows`);
|
|
108
|
+
await wait(1500);
|
|
109
|
+
return true;
|
|
110
|
+
},
|
|
111
|
+
supportsMultiEdit: false,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: "Multi-edit",
|
|
115
|
+
action: async (selectedRows) => {
|
|
116
|
+
alert(`Multi-edit: ${selectedRows.length} rows`);
|
|
117
|
+
await wait(1500);
|
|
118
|
+
return true;
|
|
119
|
+
},
|
|
120
|
+
supportsMultiEdit: true,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: "Disabled item",
|
|
124
|
+
disabled: "Disabled for test",
|
|
125
|
+
supportsMultiEdit: true,
|
|
99
126
|
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
action: async (selectedRows) => {
|
|
105
|
-
alert(`Multi-edit: ${selectedRows.length} rows`);
|
|
106
|
-
await wait(1500);
|
|
107
|
-
return true;
|
|
127
|
+
{
|
|
128
|
+
label: "Developer Only",
|
|
129
|
+
hidden: selectedItems.some((x) => x.position != "Developer"),
|
|
130
|
+
supportsMultiEdit: true,
|
|
108
131
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
{
|
|
112
|
-
label: "Disabled item",
|
|
113
|
-
disabled: "Disabled for test",
|
|
114
|
-
supportsMultiEdit: true,
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
label: "Developer Only",
|
|
118
|
-
hidden: selectedItems.some((x) => x.position != "Developer"),
|
|
119
|
-
supportsMultiEdit: true,
|
|
120
|
-
},
|
|
121
|
-
];
|
|
132
|
+
];
|
|
133
|
+
},
|
|
122
134
|
},
|
|
123
135
|
},
|
|
124
|
-
|
|
125
|
-
GridPopoverMenu
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
),
|
|
137
|
+
GridPopoverMenu(
|
|
138
|
+
{
|
|
139
|
+
headerName: "Menu disabled",
|
|
140
|
+
editable: false,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
editorParams: {
|
|
144
|
+
options: async () => {
|
|
145
|
+
return [];
|
|
146
|
+
},
|
|
131
147
|
},
|
|
132
148
|
},
|
|
133
|
-
|
|
149
|
+
),
|
|
134
150
|
],
|
|
135
151
|
[],
|
|
136
152
|
);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
interface UpdatingContextProviderProps {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
}
|
|
5
|
-
export declare type UpdatingContextStatus = Record<string, (number | string)[] | undefined>;
|
|
6
|
-
export declare const UpdatingContextProvider: (props: UpdatingContextProviderProps) => JSX.Element;
|
|
7
|
-
export {};
|