@linzjs/step-ag-grid 18.0.0 → 19.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.css +8 -0
- package/dist/src/components/Grid.d.ts +2 -0
- package/dist/step-ag-grid.cjs.js +7 -5
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +7 -5
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +4 -0
- package/src/react-menu3/components/ControlledMenu.tsx +6 -4
- package/src/stories/grid/GridPinnedRow.stories.tsx +105 -0
- package/src/stories/grid/GridReadOnly.stories.tsx +0 -19
- package/src/styles/Grid.scss +9 -0
package/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -105,6 +105,8 @@ export interface GridProps {
|
|
|
105
105
|
|
|
106
106
|
loading?: boolean;
|
|
107
107
|
suppressCellFocus?: boolean;
|
|
108
|
+
pinnedTopRowData?: GridOptions["pinnedTopRowData"];
|
|
109
|
+
pinnedBottomRowData?: GridOptions["pinnedBottomRowData"];
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
/**
|
|
@@ -738,6 +740,8 @@ export const Grid = ({
|
|
|
738
740
|
onRowDragEnd={onRowDragEnd}
|
|
739
741
|
onRowDragLeave={onRowDragLeave}
|
|
740
742
|
suppressCellFocus={params.suppressCellFocus}
|
|
743
|
+
pinnedTopRowData={params.pinnedTopRowData}
|
|
744
|
+
pinnedBottomRowData={params.pinnedBottomRowData}
|
|
741
745
|
/>
|
|
742
746
|
</div>
|
|
743
747
|
</div>
|
|
@@ -264,10 +264,12 @@ export const ControlledMenuFr = (
|
|
|
264
264
|
[onItemClick, onClose],
|
|
265
265
|
);
|
|
266
266
|
|
|
267
|
-
const
|
|
268
|
-
switch (key) {
|
|
267
|
+
const onKeyUp = (e: KeyboardEvent) => {
|
|
268
|
+
switch (e.key) {
|
|
269
269
|
case Keys.ESC:
|
|
270
|
-
|
|
270
|
+
e.preventDefault();
|
|
271
|
+
e.stopPropagation();
|
|
272
|
+
safeCall(onClose, { key: e.key, reason: CloseReason.CANCEL });
|
|
271
273
|
break;
|
|
272
274
|
}
|
|
273
275
|
};
|
|
@@ -298,7 +300,7 @@ export const ControlledMenuFr = (
|
|
|
298
300
|
|
|
299
301
|
const menuList = (
|
|
300
302
|
<div
|
|
301
|
-
{...mergeProps({
|
|
303
|
+
{...mergeProps({ onKeyUp, onBlur }, containerProps)}
|
|
302
304
|
className={useBEM({
|
|
303
305
|
block: menuContainerClass,
|
|
304
306
|
modifiers,
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import "../../styles/GridTheme.scss";
|
|
2
|
+
import "../../styles/index.scss";
|
|
3
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
4
|
+
|
|
5
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
6
|
+
import { useMemo, useState } from "react";
|
|
7
|
+
|
|
8
|
+
import "@linzjs/lui/dist/fonts";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ColDefT,
|
|
12
|
+
Grid,
|
|
13
|
+
GridCell,
|
|
14
|
+
GridContextProvider,
|
|
15
|
+
GridProps,
|
|
16
|
+
GridUpdatingContextProvider,
|
|
17
|
+
GridWrapper,
|
|
18
|
+
} from "../..";
|
|
19
|
+
import { waitForGridReady } from "../../utils/storybookTestUtil";
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
title: "Components / Grids",
|
|
23
|
+
component: Grid,
|
|
24
|
+
args: {
|
|
25
|
+
selectable: false,
|
|
26
|
+
},
|
|
27
|
+
// Storybook hangs otherwise
|
|
28
|
+
parameters: {
|
|
29
|
+
docs: {
|
|
30
|
+
source: {
|
|
31
|
+
type: "code",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
decorators: [
|
|
36
|
+
(Story) => (
|
|
37
|
+
<div style={{ maxWidth: 1024, height: 260, display: "flex", flexDirection: "column" }}>
|
|
38
|
+
<GridUpdatingContextProvider>
|
|
39
|
+
<GridContextProvider>
|
|
40
|
+
<Story />
|
|
41
|
+
</GridContextProvider>
|
|
42
|
+
</GridUpdatingContextProvider>
|
|
43
|
+
</div>
|
|
44
|
+
),
|
|
45
|
+
],
|
|
46
|
+
} as Meta<typeof Grid>;
|
|
47
|
+
|
|
48
|
+
interface ITestRow {
|
|
49
|
+
id: number;
|
|
50
|
+
name: string;
|
|
51
|
+
position: string;
|
|
52
|
+
age: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface ITestPinnedRow {
|
|
56
|
+
name: string;
|
|
57
|
+
position: string;
|
|
58
|
+
age: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const PinnedRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
62
|
+
const columnDefs: ColDefT<ITestRow>[] = useMemo(
|
|
63
|
+
() => [
|
|
64
|
+
GridCell({
|
|
65
|
+
field: "name",
|
|
66
|
+
headerName: "Name",
|
|
67
|
+
}),
|
|
68
|
+
GridCell({
|
|
69
|
+
field: "position",
|
|
70
|
+
headerName: "Position",
|
|
71
|
+
}),
|
|
72
|
+
GridCell({
|
|
73
|
+
field: "age",
|
|
74
|
+
headerName: "Age",
|
|
75
|
+
}),
|
|
76
|
+
],
|
|
77
|
+
[],
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const [rowData] = useState<ITestRow[]>([
|
|
81
|
+
{ id: 1, name: "Opeyemi", position: "Tester", age: 30 },
|
|
82
|
+
{ id: 2, name: "Johnie", position: "Developer", age: 21 },
|
|
83
|
+
{ id: 3, name: "Laxmi", position: "Manager", age: 65 },
|
|
84
|
+
{ id: 4, name: "Salama", position: "Developer", age: 22 },
|
|
85
|
+
{ id: 5, name: "Husni", position: "Developer", age: 24 },
|
|
86
|
+
]);
|
|
87
|
+
const [pinnedBottomRowData] = useState<ITestPinnedRow[]>([{ name: "Total Age", position: "", age: 170 }]);
|
|
88
|
+
const [pinnedTopRowData] = useState<ITestPinnedRow[]>([{ name: "Min Age", position: "", age: 21 }]);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<GridWrapper maxHeight={400}>
|
|
92
|
+
<Grid
|
|
93
|
+
data-testid={"readonly"}
|
|
94
|
+
{...props}
|
|
95
|
+
selectable={false}
|
|
96
|
+
columnDefs={columnDefs}
|
|
97
|
+
rowData={rowData}
|
|
98
|
+
pinnedTopRowData={pinnedTopRowData}
|
|
99
|
+
pinnedBottomRowData={pinnedBottomRowData}
|
|
100
|
+
/>
|
|
101
|
+
</GridWrapper>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
export const PinnedRow = PinnedRowTemplate.bind({});
|
|
105
|
+
PinnedRow.play = waitForGridReady;
|
|
@@ -220,25 +220,6 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
220
220
|
{ id: 1001, position: "Developer", age: 12, height: `5'3"`, desc: "Develops application", dd: "2" },
|
|
221
221
|
{ id: 1002, position: "Manager", age: 65, height: `5'9"`, desc: "Manages", dd: "3" },
|
|
222
222
|
]);
|
|
223
|
-
/*
|
|
224
|
-
Testing
|
|
225
|
-
const [loading, setLoading] = useState(false);
|
|
226
|
-
|
|
227
|
-
useTimeout(() => {
|
|
228
|
-
setRowData([
|
|
229
|
-
{ id: 1000, position: "Tester", age: 30, height: `6'4"`, desc: "Tests application", dd: "1" },
|
|
230
|
-
{ id: 1001, position: "Developer", age: 12, height: `5'3"`, desc: "Develops application", dd: "2" },
|
|
231
|
-
{ id: 1002, position: "Manager", age: 65, height: `5'9"`, desc: "Manages", dd: "3" },
|
|
232
|
-
]);
|
|
233
|
-
}, 5000);
|
|
234
|
-
|
|
235
|
-
useTimeout(() => {
|
|
236
|
-
setLoading(true);
|
|
237
|
-
}, 7000);
|
|
238
|
-
|
|
239
|
-
useTimeout(() => {
|
|
240
|
-
setLoading(false);
|
|
241
|
-
}, 9000);*/
|
|
242
223
|
|
|
243
224
|
return (
|
|
244
225
|
<GridWrapper maxHeight={400}>
|