@linzjs/step-ag-grid 1.1.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 +4 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +89342 -0
- package/dist/index.js.map +1 -0
- package/dist/src/components/ComponentLoadingWrapper.d.ts +9 -0
- package/dist/src/components/GenericCellClass.d.ts +2 -0
- package/dist/src/components/Grid.d.ts +24 -0
- package/dist/src/components/GridCell.d.ts +31 -0
- package/dist/src/components/GridIcon.d.ts +6 -0
- package/dist/src/components/GridLoadableCell.d.ts +6 -0
- package/dist/src/components/GridPopoutHook.d.ts +7 -0
- package/dist/src/components/GridSubComponentTextArea.d.ts +5 -0
- package/dist/src/components/PostSortRowsHook.d.ts +11 -0
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +26 -0
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +9 -0
- package/dist/src/components/gridForm/GridFormMessage.d.ts +8 -0
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +26 -0
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +24 -0
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +11 -0
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +11 -0
- package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +8 -0
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +4 -0
- package/dist/src/components/gridPopoverEdit/GridPopoutMenu.d.ts +10 -0
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +4 -0
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +4 -0
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +4 -0
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +15 -0
- package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +3 -0
- package/dist/src/contexts/GridContext.d.ts +25 -0
- package/dist/src/contexts/GridContextProvider.d.ts +11 -0
- package/dist/src/contexts/UpdatingContext.d.ts +6 -0
- package/dist/src/contexts/UpdatingContextProvider.d.ts +7 -0
- package/dist/src/lui/TextAreaInput.d.ts +11 -0
- package/dist/src/lui/TextInputFormatted.d.ts +14 -0
- package/dist/src/setupTests.d.ts +1 -0
- package/dist/src/stories/components/FormTest.d.ts +12 -0
- package/dist/src/stories/components/GridPopoutBearing.stories.d.ts +9 -0
- package/dist/src/stories/components/GridPopoutEditDropDown.stories.d.ts +9 -0
- package/dist/src/stories/components/GridPopoutEditGeneric.stories.d.ts +9 -0
- package/dist/src/stories/components/GridPopoutEditGenericTextArea.stories.d.ts +9 -0
- package/dist/src/stories/components/GridPopoutEditMultiSelect.stories.d.ts +9 -0
- package/dist/src/stories/components/GridReadOnly.stories.d.ts +9 -0
- package/dist/src/utils/bearing.d.ts +5 -0
- package/dist/src/utils/util.d.ts +4 -0
- package/dist/step-ag-grid.esm.js +89297 -0
- package/dist/step-ag-grid.esm.js.map +1 -0
- package/package.json +126 -0
- package/src/components/ComponentLoadingWrapper.tsx +31 -0
- package/src/components/GenericCellClass.tsx +15 -0
- package/src/components/Grid.scss +38 -0
- package/src/components/Grid.tsx +262 -0
- package/src/components/GridCell.tsx +101 -0
- package/src/components/GridIcon.tsx +12 -0
- package/src/components/GridLoadableCell.tsx +22 -0
- package/src/components/GridPopoutHook.tsx +118 -0
- package/src/components/GridSubComponentTextArea.tsx +26 -0
- package/src/components/GridTheme.scss +94 -0
- package/src/components/PostSortRowsHook.ts +131 -0
- package/src/components/gridForm/GridFormDropDown.tsx +192 -0
- package/src/components/gridForm/GridFormEditBearing.scss +3 -0
- package/src/components/gridForm/GridFormEditBearing.tsx +62 -0
- package/src/components/gridForm/GridFormMessage.tsx +34 -0
- package/src/components/gridForm/GridFormMultiSelect.tsx +180 -0
- package/src/components/gridForm/GridFormPopoutMenu.tsx +90 -0
- package/src/components/gridForm/GridFormTextArea.tsx +61 -0
- package/src/components/gridForm/GridFormTextInput.tsx +66 -0
- package/src/components/gridHeader/GridHeaderSelect.tsx +54 -0
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +22 -0
- package/src/components/gridPopoverEdit/GridPopoutMenu.scss +9 -0
- package/src/components/gridPopoverEdit/GridPopoutMenu.tsx +35 -0
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +24 -0
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +22 -0
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +22 -0
- package/src/components/gridRender/GridRenderGenericCell.scss +15 -0
- package/src/components/gridRender/GridRenderGenericCell.tsx +49 -0
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +22 -0
- package/src/contexts/GridContext.tsx +82 -0
- package/src/contexts/GridContextProvider.tsx +292 -0
- package/src/contexts/UpdatingContext.tsx +16 -0
- package/src/contexts/UpdatingContextProvider.tsx +43 -0
- package/src/lui/TextAreaInput.tsx +50 -0
- package/src/lui/TextInputFormatted.scss +11 -0
- package/src/lui/TextInputFormatted.tsx +60 -0
- package/src/lui-overrides.scss +163 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/setupTests.ts +5 -0
- package/src/stories/components/FormTest.scss +10 -0
- package/src/stories/components/FormTest.tsx +51 -0
- package/src/stories/components/GridPopoutBearing.stories.tsx +100 -0
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +174 -0
- package/src/stories/components/GridPopoutEditGeneric.stories.tsx +76 -0
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +106 -0
- package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +111 -0
- package/src/stories/components/GridReadOnly.stories.tsx +151 -0
- package/src/utils/bearing.ts +72 -0
- package/src/utils/util.ts +26 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lui Table additions, to be brought into Lui
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
.lui-base-table.lui-table-bold-headings th {
|
|
6
|
+
font-weight: 600;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.lui-base-table.lui-table-nowrap-headings th {
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.lui-base-table.lui-compact-table th,
|
|
14
|
+
.lui-base-table.lui-compact-table td {
|
|
15
|
+
padding-top: 7px;
|
|
16
|
+
padding-bottom: 7px;
|
|
17
|
+
font-size: 0.875rem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.lui-base-table.lui-compact-table th.lui-table-heading-dark,
|
|
21
|
+
.lui-base-table.lui-compact-table td.lui-table-heading-dark {
|
|
22
|
+
background-color: #55504b; /* $grey-60 */
|
|
23
|
+
color: white;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.lui-base-table.lui-table-no-top-line thead {
|
|
27
|
+
border-top: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Lui Button additions, to be brought into Lui
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
.lui-button.lui-button-toolbar,
|
|
35
|
+
a.lui-button.lui-button-toolbar {
|
|
36
|
+
border-color: transparent;
|
|
37
|
+
padding: 4px;
|
|
38
|
+
line-height: 12px;
|
|
39
|
+
margin: 2px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.lui-compact-table .lui-bearing-input-wrapper .lui-bearing-display {
|
|
43
|
+
line-height: 25px !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Until LUI fix comes (For different font weights) */
|
|
47
|
+
input,
|
|
48
|
+
select .survey-information {
|
|
49
|
+
font-weight: 400 !important;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.table-select input {
|
|
53
|
+
line-height: 25px !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.lui-standard-form .lui-compact-table .lui-input-error input {
|
|
57
|
+
border-left-width: 28px !important;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.lui-standard-form .lui-compact-table .lui-input-error .lui-form-status-icon {
|
|
61
|
+
font-size: 1rem;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* To be replaced by Darrell's changes */
|
|
65
|
+
.lui-standard-form .temporary-tighter-form-style label {
|
|
66
|
+
margin-top: 20px !important;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Survey map header */
|
|
70
|
+
.lui-header.lui-header-white::after {
|
|
71
|
+
height: 2px;
|
|
72
|
+
background: linear-gradient(270deg, #bbb 1%, #ccc 100%);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Context Menu for the tables */
|
|
76
|
+
.edit-cell {
|
|
77
|
+
width: 100%;
|
|
78
|
+
height: 100%;
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
border: none;
|
|
82
|
+
text-align: left;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Free text input */
|
|
86
|
+
|
|
87
|
+
.lui-menu .free-text-input {
|
|
88
|
+
border: transparent;
|
|
89
|
+
outline: transparent;
|
|
90
|
+
line-height: 33px;
|
|
91
|
+
padding-left: 4px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.lui-menu textarea.free-text-input {
|
|
95
|
+
font-weight: 400;
|
|
96
|
+
line-height: 1.5;
|
|
97
|
+
width: 300px;
|
|
98
|
+
height: 150px;
|
|
99
|
+
resize: none;
|
|
100
|
+
border: 0.06rem solid #beb9b4;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.LuiCheckboxInput:focus {
|
|
104
|
+
border: 1px solid black;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.LuiCheckboxInput-group:focus {
|
|
108
|
+
border: 1px solid black;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Bounding box in a popout - any menus will be placed in the space of this div */
|
|
112
|
+
div.menu-bounding-box {
|
|
113
|
+
position: absolute;
|
|
114
|
+
height: 100%;
|
|
115
|
+
width: 95%;
|
|
116
|
+
z-index: -9999;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.lui-button-icon {
|
|
120
|
+
display: flex;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
align-items: center;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.lui-button.lui-button-lg.lui-button-icon .LuiIcon.LuiIcon--sm {
|
|
126
|
+
margin-bottom: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.lui-button.lui-button-med.lui-button-icon .LuiIcon.LuiIcon--md {
|
|
130
|
+
margin-bottom: -1px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.lui-menu {
|
|
134
|
+
/**
|
|
135
|
+
* Scrollbar (Only Chrome)
|
|
136
|
+
*/
|
|
137
|
+
::-webkit-scrollbar {
|
|
138
|
+
width: 20px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
::-webkit-scrollbar-track {
|
|
142
|
+
background-color: transparent;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
::-webkit-scrollbar-thumb {
|
|
146
|
+
background-color: #d6dee1;
|
|
147
|
+
border-radius: 20px;
|
|
148
|
+
border: 6px solid transparent;
|
|
149
|
+
background-clip: content-box;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
::-webkit-scrollbar-thumb:hover {
|
|
153
|
+
background-color: #a8bbbf;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.szh-menu__item {
|
|
157
|
+
padding: 2px 1rem;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.LuiCheckboxInput {
|
|
161
|
+
margin-bottom: 0;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import "./FormTest.scss";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useState } from "react";
|
|
4
|
+
import { LuiTextInput } from "@linzjs/lui";
|
|
5
|
+
import { wait } from "../../utils/util";
|
|
6
|
+
import { GridFormProps } from "../../components/GridCell";
|
|
7
|
+
import { useGridPopoutHook } from "../../components/GridPopoutHook";
|
|
8
|
+
import { GridBaseRow } from "../../components/Grid";
|
|
9
|
+
|
|
10
|
+
export interface IFormTestRow {
|
|
11
|
+
id: number;
|
|
12
|
+
name: string;
|
|
13
|
+
nameType: string;
|
|
14
|
+
numba: string;
|
|
15
|
+
plan: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const FormTest = <RowType extends GridBaseRow>(props: GridFormProps<RowType>): JSX.Element => {
|
|
19
|
+
const [v1, v2, ...v3] = props.value.split(" ");
|
|
20
|
+
|
|
21
|
+
const [nameType, setNameType] = useState(v1);
|
|
22
|
+
const [numba, setNumba] = useState(v2);
|
|
23
|
+
const [plan, setPlan] = useState(v3.join(" "));
|
|
24
|
+
|
|
25
|
+
const save = useCallback(async (): Promise<boolean> => {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.log("onSave", props.selectedRows, nameType, numba, plan);
|
|
28
|
+
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
props.selectedRows.forEach((row) => (row["name"] = [nameType, numba, plan].join(" ")));
|
|
31
|
+
await wait(1000);
|
|
32
|
+
|
|
33
|
+
// Close form
|
|
34
|
+
return true;
|
|
35
|
+
}, [nameType, numba, plan, props.selectedRows]);
|
|
36
|
+
const { popoutWrapper } = useGridPopoutHook(props, save);
|
|
37
|
+
|
|
38
|
+
return popoutWrapper(
|
|
39
|
+
<div style={{ display: "flex", flexDirection: "row" }} className={"FormTest Grid-popoverContainer"}>
|
|
40
|
+
<div className={"FormTest-textInput"}>
|
|
41
|
+
<LuiTextInput label={"Name type"} value={nameType} onChange={(e) => setNameType(e.target.value)} />
|
|
42
|
+
</div>
|
|
43
|
+
<div className={"FormTest-textInput"}>
|
|
44
|
+
<LuiTextInput label={"Number"} value={numba} onChange={(e) => setNumba(e.target.value)} />
|
|
45
|
+
</div>
|
|
46
|
+
<div className={"FormTest-textInput"}>
|
|
47
|
+
<LuiTextInput label={"Plan"} value={plan} onChange={(e) => setPlan(e.target.value)} />
|
|
48
|
+
</div>
|
|
49
|
+
</div>,
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
2
|
+
import "@linzjs/lui/dist/fonts";
|
|
3
|
+
import "../../lui-overrides.scss";
|
|
4
|
+
|
|
5
|
+
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
+
import { GridContextProvider } from "../../contexts/GridContextProvider";
|
|
7
|
+
import { Grid, GridProps } from "../../components/Grid";
|
|
8
|
+
import { useMemo, useState } from "react";
|
|
9
|
+
import { UpdatingContextProvider } from "../../contexts/UpdatingContextProvider";
|
|
10
|
+
import { GridPopoverEditBearing } from "../../components/gridPopoverEdit/GridPopoverEditBearing";
|
|
11
|
+
import { wait } from "../../utils/util";
|
|
12
|
+
import { GridCell } from "../../components/GridCell";
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: "Components / Grids",
|
|
16
|
+
component: Grid,
|
|
17
|
+
args: {
|
|
18
|
+
externalSelectedItems: [],
|
|
19
|
+
setExternalSelectedItems: () => {},
|
|
20
|
+
},
|
|
21
|
+
decorators: [
|
|
22
|
+
(Story) => (
|
|
23
|
+
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
24
|
+
<UpdatingContextProvider>
|
|
25
|
+
<GridContextProvider>
|
|
26
|
+
<Story />
|
|
27
|
+
</GridContextProvider>
|
|
28
|
+
</UpdatingContextProvider>
|
|
29
|
+
</div>
|
|
30
|
+
),
|
|
31
|
+
],
|
|
32
|
+
} as ComponentMeta<typeof Grid>;
|
|
33
|
+
|
|
34
|
+
interface ITestRow {
|
|
35
|
+
id: number;
|
|
36
|
+
bearing1: number | null;
|
|
37
|
+
bearing2: number | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
41
|
+
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
42
|
+
const columnDefs = useMemo(
|
|
43
|
+
() => [
|
|
44
|
+
GridCell({
|
|
45
|
+
field: "id",
|
|
46
|
+
headerName: "Id",
|
|
47
|
+
initialWidth: 65,
|
|
48
|
+
maxWidth: 85,
|
|
49
|
+
}),
|
|
50
|
+
GridPopoverEditBearing<ITestRow>({
|
|
51
|
+
field: "bearing1",
|
|
52
|
+
headerName: "Bearing GCE",
|
|
53
|
+
cellRendererParams: {
|
|
54
|
+
warning: (props) => props.data.id == 1002 && "Testers are testing",
|
|
55
|
+
info: (props) => props.data.id == 1001 && "Developers are developing",
|
|
56
|
+
},
|
|
57
|
+
cellEditorParams: {
|
|
58
|
+
multiEdit: false,
|
|
59
|
+
placeHolder: "Enter Bearing",
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
GridPopoverEditBearing<ITestRow>({
|
|
63
|
+
field: "bearing2",
|
|
64
|
+
headerName: "Bearing onSave",
|
|
65
|
+
cellEditorParams: {
|
|
66
|
+
multiEdit: true,
|
|
67
|
+
placeHolder: "Enter Bearing",
|
|
68
|
+
onSave: async (selectedRows: ITestRow[], value: ITestRow["bearing2"]) => {
|
|
69
|
+
await wait(1000);
|
|
70
|
+
selectedRows.forEach((row) => (row["bearing2"] = value));
|
|
71
|
+
return true;
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
],
|
|
76
|
+
[],
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const rowData = useMemo(
|
|
80
|
+
() =>
|
|
81
|
+
[
|
|
82
|
+
{ id: 1000, bearing1: 1.234, bearing2: 90 },
|
|
83
|
+
{ id: 1001, bearing1: 1.565, bearing2: 240 },
|
|
84
|
+
{ id: 1002, bearing1: null, bearing2: 355.1 },
|
|
85
|
+
] as ITestRow[],
|
|
86
|
+
[],
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<Grid
|
|
91
|
+
{...props}
|
|
92
|
+
externalSelectedItems={externalSelectedItems}
|
|
93
|
+
setExternalSelectedItems={setExternalSelectedItems}
|
|
94
|
+
columnDefs={columnDefs}
|
|
95
|
+
rowData={rowData}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const Bearings = GridReadOnlyTemplate.bind({});
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
2
|
+
import "@linzjs/lui/dist/fonts";
|
|
3
|
+
import "../../lui-overrides.scss";
|
|
4
|
+
|
|
5
|
+
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
+
import { GridContextProvider } from "../../contexts/GridContextProvider";
|
|
7
|
+
import { Grid, GridProps } from "../../components/Grid";
|
|
8
|
+
import { useCallback, useMemo, useState } from "react";
|
|
9
|
+
import {
|
|
10
|
+
GridFormDropDown,
|
|
11
|
+
GridFormPopoutDropDownProps,
|
|
12
|
+
MenuSeparator,
|
|
13
|
+
MenuSeparatorString,
|
|
14
|
+
} from "../../components/gridForm/GridFormDropDown";
|
|
15
|
+
import { UpdatingContextProvider } from "../../contexts/UpdatingContextProvider";
|
|
16
|
+
import { ColDef } from "ag-grid-community";
|
|
17
|
+
import { wait } from "../../utils/util";
|
|
18
|
+
import { GridCell } from "../../components/GridCell";
|
|
19
|
+
import { GridPopoverEditDropDown } from "../../components/gridPopoverEdit/GridPopoverEditDropDown";
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
title: "Components / Grids",
|
|
23
|
+
component: Grid,
|
|
24
|
+
args: {
|
|
25
|
+
externalSelectedItems: [],
|
|
26
|
+
setExternalSelectedItems: () => {},
|
|
27
|
+
},
|
|
28
|
+
decorators: [
|
|
29
|
+
(Story) => (
|
|
30
|
+
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
31
|
+
<UpdatingContextProvider>
|
|
32
|
+
<GridContextProvider>
|
|
33
|
+
<Story />
|
|
34
|
+
</GridContextProvider>
|
|
35
|
+
</UpdatingContextProvider>
|
|
36
|
+
</div>
|
|
37
|
+
),
|
|
38
|
+
],
|
|
39
|
+
} as ComponentMeta<typeof Grid>;
|
|
40
|
+
|
|
41
|
+
interface ITestRow {
|
|
42
|
+
id: number;
|
|
43
|
+
position: string | null;
|
|
44
|
+
position2: string | null;
|
|
45
|
+
position3: string | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
49
|
+
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
50
|
+
|
|
51
|
+
const optionsFn = useCallback(async (selectedRows: ITestRow[], filter?: string) => {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.log("optionsFn selected rows", selectedRows, filter);
|
|
54
|
+
filter = filter?.toLowerCase();
|
|
55
|
+
await wait(1000);
|
|
56
|
+
return [
|
|
57
|
+
null,
|
|
58
|
+
"Architect",
|
|
59
|
+
"Developer",
|
|
60
|
+
"Product Owner",
|
|
61
|
+
"Scrum Master",
|
|
62
|
+
"Tester",
|
|
63
|
+
MenuSeparatorString,
|
|
64
|
+
"(other)",
|
|
65
|
+
].filter((v) => (filter != null ? v != null && v.toLowerCase().indexOf(filter) === 0 : true));
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
const columnDefs = useMemo(
|
|
69
|
+
() =>
|
|
70
|
+
[
|
|
71
|
+
GridCell({
|
|
72
|
+
field: "id",
|
|
73
|
+
headerName: "Id",
|
|
74
|
+
initialWidth: 65,
|
|
75
|
+
maxWidth: 85,
|
|
76
|
+
}),
|
|
77
|
+
GridCell<ITestRow, GridFormPopoutDropDownProps<ITestRow, ITestRow["position"]>>({
|
|
78
|
+
field: "position",
|
|
79
|
+
initialWidth: 65,
|
|
80
|
+
maxWidth: 150,
|
|
81
|
+
headerName: "Position",
|
|
82
|
+
cellEditorParams: {
|
|
83
|
+
form: GridFormDropDown,
|
|
84
|
+
options: ["Architect", "Developer", "Product Owner", "Scrum Master", "Tester", MenuSeparator, "(other)"],
|
|
85
|
+
multiEdit: false,
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
GridPopoverEditDropDown<ITestRow, ITestRow["position2"]>({
|
|
89
|
+
field: "position2",
|
|
90
|
+
maxWidth: 100,
|
|
91
|
+
headerName: "Multi-edit",
|
|
92
|
+
cellEditorParams: {
|
|
93
|
+
multiEdit: true,
|
|
94
|
+
options: [
|
|
95
|
+
{
|
|
96
|
+
value: "1",
|
|
97
|
+
label: <span style={{ border: "2px dashed blue" }}>One</span>,
|
|
98
|
+
},
|
|
99
|
+
{ value: "2", label: <span style={{ border: "2px dashed red" }}>Two</span> },
|
|
100
|
+
MenuSeparator,
|
|
101
|
+
{ value: "3", label: <span style={{ border: "2px dashed green" }}>Three</span> },
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
GridPopoverEditDropDown<ITestRow, ITestRow["position3"]>({
|
|
106
|
+
field: "position3",
|
|
107
|
+
initialWidth: 65,
|
|
108
|
+
maxWidth: 150,
|
|
109
|
+
headerName: "Custom callback",
|
|
110
|
+
cellEditorParams: {
|
|
111
|
+
multiEdit: true,
|
|
112
|
+
options: [null, "Architect", "Developer", "Product Owner", "Scrum Master", "Tester", "(other)"],
|
|
113
|
+
onSelectedItem: async (selected) => {
|
|
114
|
+
await wait(2000);
|
|
115
|
+
selected.selectedRows.forEach((row) => (row.position3 = selected.value));
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
GridPopoverEditDropDown<ITestRow, ITestRow["position"]>({
|
|
120
|
+
field: "position",
|
|
121
|
+
initialWidth: 65,
|
|
122
|
+
maxWidth: 150,
|
|
123
|
+
headerName: "Options Fn",
|
|
124
|
+
cellEditorParams: {
|
|
125
|
+
filtered: "reload",
|
|
126
|
+
filterPlaceholder: "Search me...",
|
|
127
|
+
options: optionsFn,
|
|
128
|
+
optionsRequestCancel: () => {
|
|
129
|
+
// TODO wrap options in an abortable request
|
|
130
|
+
// When performing rest requests call the abort controller,
|
|
131
|
+
// otherwise you'll get multiple requests coming back in different order
|
|
132
|
+
// eslint-disable-next-line no-console
|
|
133
|
+
console.log("optionsRequestCancelled");
|
|
134
|
+
},
|
|
135
|
+
multiEdit: false,
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
GridPopoverEditDropDown<ITestRow, ITestRow["position3"]>({
|
|
139
|
+
field: "position3",
|
|
140
|
+
initialWidth: 65,
|
|
141
|
+
maxWidth: 150,
|
|
142
|
+
headerName: "Filtered",
|
|
143
|
+
cellEditorParams: {
|
|
144
|
+
multiEdit: true,
|
|
145
|
+
filtered: "local",
|
|
146
|
+
filterPlaceholder: "Filter this",
|
|
147
|
+
options: [null, "Architect", "Developer", "Product Owner", "Scrum Master", "Tester", "(other)"],
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
] as ColDef[],
|
|
151
|
+
[optionsFn],
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const rowData = useMemo(
|
|
155
|
+
() =>
|
|
156
|
+
[
|
|
157
|
+
{ id: 1000, position: "Tester", position2: "1", position3: "Tester" },
|
|
158
|
+
{ id: 1001, position: "Developer", position2: "2", position3: "Developer" },
|
|
159
|
+
] as ITestRow[],
|
|
160
|
+
[],
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<Grid
|
|
165
|
+
{...props}
|
|
166
|
+
externalSelectedItems={externalSelectedItems}
|
|
167
|
+
setExternalSelectedItems={setExternalSelectedItems}
|
|
168
|
+
columnDefs={columnDefs}
|
|
169
|
+
rowData={rowData}
|
|
170
|
+
/>
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const EditDropdown = GridEditDropDownTemplate.bind({});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
2
|
+
import "@linzjs/lui/dist/fonts";
|
|
3
|
+
import "../../lui-overrides.scss";
|
|
4
|
+
|
|
5
|
+
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
+
import { GridContextProvider } from "../../contexts/GridContextProvider";
|
|
7
|
+
import { Grid, GridProps } from "../../components/Grid";
|
|
8
|
+
import { useMemo, useState } from "react";
|
|
9
|
+
import { UpdatingContextProvider } from "../../contexts/UpdatingContextProvider";
|
|
10
|
+
import { GridCell } from "../../components/GridCell";
|
|
11
|
+
import { FormTest, IFormTestRow } from "./FormTest";
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: "Components / Grids",
|
|
15
|
+
component: Grid,
|
|
16
|
+
args: {
|
|
17
|
+
externalSelectedItems: [],
|
|
18
|
+
setExternalSelectedItems: () => {},
|
|
19
|
+
},
|
|
20
|
+
decorators: [
|
|
21
|
+
(Story) => (
|
|
22
|
+
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
23
|
+
<UpdatingContextProvider>
|
|
24
|
+
<GridContextProvider>
|
|
25
|
+
<Story />
|
|
26
|
+
</GridContextProvider>
|
|
27
|
+
</UpdatingContextProvider>
|
|
28
|
+
</div>
|
|
29
|
+
),
|
|
30
|
+
],
|
|
31
|
+
} as ComponentMeta<typeof Grid>;
|
|
32
|
+
|
|
33
|
+
const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
34
|
+
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
35
|
+
const columnDefs = useMemo(
|
|
36
|
+
() => [
|
|
37
|
+
GridCell({
|
|
38
|
+
field: "id",
|
|
39
|
+
headerName: "Id",
|
|
40
|
+
initialWidth: 65,
|
|
41
|
+
maxWidth: 85,
|
|
42
|
+
}),
|
|
43
|
+
GridCell({
|
|
44
|
+
field: "name",
|
|
45
|
+
headerName: "Popout Generic Edit",
|
|
46
|
+
maxWidth: 140,
|
|
47
|
+
cellEditorParams: {
|
|
48
|
+
form: FormTest,
|
|
49
|
+
multiEdit: false,
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
[],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const rowData = useMemo(
|
|
57
|
+
() =>
|
|
58
|
+
[
|
|
59
|
+
{ id: 1000, name: "IS IS DP12345", nameType: "IS", numba: "IX", plan: "DP 12345" },
|
|
60
|
+
{ id: 1001, name: "PEG V SD523", nameType: "PEG", numba: "V", plan: "SD 523" },
|
|
61
|
+
] as IFormTestRow[],
|
|
62
|
+
[],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Grid
|
|
67
|
+
{...props}
|
|
68
|
+
externalSelectedItems={externalSelectedItems}
|
|
69
|
+
setExternalSelectedItems={setExternalSelectedItems}
|
|
70
|
+
columnDefs={columnDefs}
|
|
71
|
+
rowData={rowData}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const EditGeneric = GridPopoutEditGenericTemplate.bind({});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
2
|
+
import "@linzjs/lui/dist/fonts";
|
|
3
|
+
import "../../lui-overrides.scss";
|
|
4
|
+
|
|
5
|
+
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
|
+
import { GridContextProvider } from "../../contexts/GridContextProvider";
|
|
7
|
+
import { Grid, GridProps } from "../../components/Grid";
|
|
8
|
+
import { useMemo, useState } from "react";
|
|
9
|
+
import { UpdatingContextProvider } from "../../contexts/UpdatingContextProvider";
|
|
10
|
+
import { GridCell } from "../../components/GridCell";
|
|
11
|
+
import { IFormTestRow } from "./FormTest";
|
|
12
|
+
import { GridFormTextArea, GridFormTextAreaProps } from "../../components/gridForm/GridFormTextArea";
|
|
13
|
+
import { GridFormTextInput, GridFormTextInputProps } from "../../components/gridForm/GridFormTextInput";
|
|
14
|
+
import { wait } from "../../utils/util";
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
title: "Components / Grids",
|
|
18
|
+
component: Grid,
|
|
19
|
+
args: {
|
|
20
|
+
externalSelectedItems: [],
|
|
21
|
+
setExternalSelectedItems: () => {},
|
|
22
|
+
},
|
|
23
|
+
decorators: [
|
|
24
|
+
(Story) => (
|
|
25
|
+
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
26
|
+
<UpdatingContextProvider>
|
|
27
|
+
<GridContextProvider>
|
|
28
|
+
<Story />
|
|
29
|
+
</GridContextProvider>
|
|
30
|
+
</UpdatingContextProvider>
|
|
31
|
+
</div>
|
|
32
|
+
),
|
|
33
|
+
],
|
|
34
|
+
} as ComponentMeta<typeof Grid>;
|
|
35
|
+
|
|
36
|
+
const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
37
|
+
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
38
|
+
const columnDefs = useMemo(
|
|
39
|
+
() => [
|
|
40
|
+
GridCell({
|
|
41
|
+
field: "id",
|
|
42
|
+
headerName: "Id",
|
|
43
|
+
initialWidth: 65,
|
|
44
|
+
maxWidth: 85,
|
|
45
|
+
}),
|
|
46
|
+
GridCell<IFormTestRow, GridFormTextInputProps<IFormTestRow>>({
|
|
47
|
+
field: "name",
|
|
48
|
+
headerName: "Text input",
|
|
49
|
+
maxWidth: 140,
|
|
50
|
+
cellEditorParams: {
|
|
51
|
+
form: GridFormTextInput,
|
|
52
|
+
required: true,
|
|
53
|
+
maxlength: 12,
|
|
54
|
+
placeholder: "Enter some text...",
|
|
55
|
+
width: 240,
|
|
56
|
+
multiEdit: false,
|
|
57
|
+
onSave: async (selectedRows, value) => {
|
|
58
|
+
await wait(1000);
|
|
59
|
+
selectedRows.forEach((selectedRow) => (selectedRow["name"] = value));
|
|
60
|
+
return true;
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
GridCell<IFormTestRow, GridFormTextAreaProps<IFormTestRow>>({
|
|
65
|
+
field: "plan",
|
|
66
|
+
headerName: "Text area",
|
|
67
|
+
maxWidth: 140,
|
|
68
|
+
cellEditorParams: {
|
|
69
|
+
form: GridFormTextArea,
|
|
70
|
+
required: true,
|
|
71
|
+
maxlength: 32,
|
|
72
|
+
placeholder: "Enter some text...",
|
|
73
|
+
width: 260,
|
|
74
|
+
multiEdit: true,
|
|
75
|
+
onSave: async (selectedRows, value) => {
|
|
76
|
+
await wait(1000);
|
|
77
|
+
selectedRows.forEach((selectedRow) => (selectedRow["plan"] = value));
|
|
78
|
+
return true;
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
],
|
|
83
|
+
[],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const rowData = useMemo(
|
|
87
|
+
() =>
|
|
88
|
+
[
|
|
89
|
+
{ id: 1000, name: "IS IS DP12345", nameType: "IS", numba: "IX", plan: "DP 12345" },
|
|
90
|
+
{ id: 1001, name: "PEG V SD523", nameType: "PEG", numba: "V", plan: "SD 523" },
|
|
91
|
+
] as IFormTestRow[],
|
|
92
|
+
[],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Grid
|
|
97
|
+
{...props}
|
|
98
|
+
externalSelectedItems={externalSelectedItems}
|
|
99
|
+
setExternalSelectedItems={setExternalSelectedItems}
|
|
100
|
+
columnDefs={columnDefs}
|
|
101
|
+
rowData={rowData}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const EditGenericTextArea = GridPopoutEditGenericTemplate.bind({});
|