@linzjs/step-ag-grid 14.8.0 → 14.9.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/src/components/Grid.d.ts +1 -0
- package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +3 -3
- package/dist/step-ag-grid.esm.js +7 -6
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +2 -0
- package/src/components/gridForm/GridFormMultiSelectGrid.tsx +15 -10
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +1 -1
package/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -37,6 +37,7 @@ export interface GridProps {
|
|
|
37
37
|
noRowsOverlayText?: string;
|
|
38
38
|
postSortRows?: GridOptions["postSortRows"];
|
|
39
39
|
animateRows?: boolean;
|
|
40
|
+
rowHeight?: number;
|
|
40
41
|
rowClassRules?: GridOptions["rowClassRules"];
|
|
41
42
|
rowSelection?: "single" | "multiple";
|
|
42
43
|
autoSelectFirstRow?: boolean;
|
|
@@ -564,6 +565,7 @@ export const Grid = ({
|
|
|
564
565
|
>
|
|
565
566
|
<div style={{ flex: 1 }} ref={gridDivRef}>
|
|
566
567
|
<AgGridReact
|
|
568
|
+
rowHeight={params.rowHeight}
|
|
567
569
|
animateRows={params.animateRows}
|
|
568
570
|
rowClassRules={params.rowClassRules}
|
|
569
571
|
getRowId={(params) => `${params.data.id}`}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isEqual } from "lodash-es";
|
|
2
|
+
import { ReactElement, useCallback, useEffect, useRef, useState } from "react";
|
|
2
3
|
|
|
3
4
|
import { LuiCheckboxInput } from "@linzjs/lui";
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ import { useGridPopoverHook } from "../GridPopoverHook";
|
|
|
12
13
|
|
|
13
14
|
export interface MultiSelectGridOption {
|
|
14
15
|
value: any;
|
|
15
|
-
label?: string;
|
|
16
|
+
label?: string | ReactElement;
|
|
16
17
|
checked?: boolean | "partial";
|
|
17
18
|
canSelectPartial?: boolean;
|
|
18
19
|
warning?: string | undefined;
|
|
@@ -37,7 +38,7 @@ export interface GridFormMultiSelectGridProps<RowType extends GridBaseRow> exten
|
|
|
37
38
|
|
|
38
39
|
export const GridFormMultiSelectGrid = <RowType extends GridBaseRow>(
|
|
39
40
|
props: GridFormMultiSelectGridProps<RowType>,
|
|
40
|
-
):
|
|
41
|
+
): ReactElement => {
|
|
41
42
|
const { selectedRows } = useGridPopoverContext<RowType>();
|
|
42
43
|
const optionsInitialising = useRef(false);
|
|
43
44
|
|
|
@@ -65,7 +66,14 @@ export const GridFormMultiSelectGrid = <RowType extends GridBaseRow>(
|
|
|
65
66
|
async (selectedRows: RowType[]): Promise<boolean> => {
|
|
66
67
|
if (!options || !props.onSave) return true;
|
|
67
68
|
// Any changes to save?
|
|
68
|
-
if (
|
|
69
|
+
if (
|
|
70
|
+
isEqual(
|
|
71
|
+
initialValues?.map((o) => o.checked),
|
|
72
|
+
options.map((o) => o.checked),
|
|
73
|
+
)
|
|
74
|
+
) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
69
77
|
if (!props.onSave) return true;
|
|
70
78
|
return await props.onSave(genSave(selectedRows));
|
|
71
79
|
},
|
|
@@ -90,7 +98,7 @@ export const GridFormMultiSelectGrid = <RowType extends GridBaseRow>(
|
|
|
90
98
|
|
|
91
99
|
(async () => {
|
|
92
100
|
const optionsList = typeof props.options === "function" ? await props.options(selectedRows) : props.options;
|
|
93
|
-
setInitialValues(
|
|
101
|
+
setInitialValues(optionsList.map((o) => ({ ...o, label: "" })));
|
|
94
102
|
setOptions(optionsList);
|
|
95
103
|
optionsInitialising.current = false;
|
|
96
104
|
})();
|
|
@@ -122,7 +130,7 @@ export const GridFormMultiSelectGrid = <RowType extends GridBaseRow>(
|
|
|
122
130
|
options.map((o) => (
|
|
123
131
|
<>
|
|
124
132
|
<MenuItem
|
|
125
|
-
key={o.
|
|
133
|
+
key={JSON.stringify(o.value)}
|
|
126
134
|
onClick={(e: ClickEvent) => {
|
|
127
135
|
// Global react-menu MenuItem handler handles tabs
|
|
128
136
|
if (e.key !== "Tab" && e.key !== "Enter") {
|
|
@@ -138,10 +146,7 @@ export const GridFormMultiSelectGrid = <RowType extends GridBaseRow>(
|
|
|
138
146
|
label={
|
|
139
147
|
<>
|
|
140
148
|
{o.warning && <GridIcon icon={"ic_warning_outline"} title={o.warning} />}
|
|
141
|
-
<span
|
|
142
|
-
className={"GridMultiSelectGrid-Label"}
|
|
143
|
-
style={{ fontWeight: o.label?.endsWith("0") ? "bold" : "regular" }}
|
|
144
|
-
>
|
|
149
|
+
<span className={"GridMultiSelectGrid-Label"}>
|
|
145
150
|
{o.label ?? (o.value == null ? `<${o.value}>` : `${o.value}`)}
|
|
146
151
|
</span>
|
|
147
152
|
</>
|
|
@@ -38,7 +38,7 @@ const Template: ComponentStory<typeof GridFormMultiSelectGrid> = (props) => {
|
|
|
38
38
|
{ label: "Two", value: 2 },
|
|
39
39
|
{ label: "Three", value: 3 },
|
|
40
40
|
{ label: "Four", value: 4 },
|
|
41
|
-
{ label:
|
|
41
|
+
{ label: <div>Five</div>, value: 5 },
|
|
42
42
|
];
|
|
43
43
|
const config: GridFormMultiSelectGridProps<any> = {
|
|
44
44
|
onSave,
|