@linzjs/step-ag-grid 22.0.0 → 22.1.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.
Files changed (37) hide show
  1. package/dist/index.css +38 -0
  2. package/dist/src/components/Grid.d.ts +1 -2
  3. package/dist/src/components/GridCell.d.ts +1 -1
  4. package/dist/src/components/clickInputWhenContainingCellClicked.d.ts +6 -0
  5. package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
  6. package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +11 -0
  7. package/dist/src/components/gridPopoverEdit/index.d.ts +1 -0
  8. package/dist/src/components/index.d.ts +1 -0
  9. package/dist/src/lui/TextAreaInput.d.ts +0 -1
  10. package/dist/step-ag-grid.cjs.js +101 -76
  11. package/dist/step-ag-grid.cjs.js.map +1 -1
  12. package/dist/step-ag-grid.esm.js +101 -77
  13. package/dist/step-ag-grid.esm.js.map +1 -1
  14. package/package.json +32 -33
  15. package/src/components/Grid.tsx +18 -23
  16. package/src/components/GridCell.tsx +4 -2
  17. package/src/components/clickInputWhenContainingCellClicked.tsx +40 -0
  18. package/src/components/gridForm/GridFormDropDown.tsx +1 -0
  19. package/src/components/gridForm/GridFormMultiSelectGrid.tsx +1 -1
  20. package/src/components/gridPopoverEdit/GridEditBoolean.tsx +79 -0
  21. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +8 -1
  22. package/src/components/gridPopoverEdit/index.ts +1 -0
  23. package/src/components/index.ts +1 -0
  24. package/src/contexts/GridContextProvider.tsx +1 -0
  25. package/src/lui/TextAreaInput.tsx +3 -8
  26. package/src/stories/grid/FormTest.tsx +1 -0
  27. package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +74 -0
  28. package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +1 -0
  29. package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +1 -0
  30. package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +1 -0
  31. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +1 -0
  32. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +1 -0
  33. package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +1 -0
  34. package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +1 -0
  35. package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +1 -0
  36. package/src/styles/Grid.scss +33 -0
  37. package/src/styles/GridFormDropDown.scss +5 -0
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "22.0.0",
5
+ "version": "22.1.0",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@linzjs/lui": ">=21",
31
- "ag-grid-community": "^32.1.0",
32
- "ag-grid-react": "^32.1.0",
31
+ "ag-grid-community": "^32.2.0",
32
+ "ag-grid-react": "^32.2.0",
33
33
  "lodash-es": ">=4",
34
34
  "react": ">=18",
35
35
  "react-dom": ">=18"
@@ -40,8 +40,7 @@
40
40
  "lodash-es": ">=4",
41
41
  "matcher": "^5.0.0",
42
42
  "react-transition-state": "^2.1.2",
43
- "usehooks-ts": "^3.1.0",
44
- "uuid": "^10.0.0"
43
+ "usehooks-ts": "^3.1.0"
45
44
  },
46
45
  "scripts": {
47
46
  "build": "run-s clean stylelint lint css bundle",
@@ -78,51 +77,51 @@
78
77
  },
79
78
  "devDependencies": {
80
79
  "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
81
- "@chromatic-com/storybook": "^1.8.0",
82
- "@linzjs/lui": "^21.44.4",
80
+ "@chromatic-com/storybook": "^2.0.2",
81
+ "@linzjs/lui": "^21.46.0",
83
82
  "@rollup/plugin-commonjs": "^26.0.1",
84
83
  "@rollup/plugin-json": "^6.1.0",
85
- "@rollup/plugin-node-resolve": "^15.2.3",
84
+ "@rollup/plugin-node-resolve": "^15.2.4",
86
85
  "@semantic-release/changelog": "^6.0.3",
87
86
  "@semantic-release/git": "^10.0.1",
88
- "@storybook/addon-essentials": "^8.2.9",
89
- "@storybook/addon-interactions": "^8.2.9",
90
- "@storybook/addon-links": "^8.2.9",
91
- "@storybook/react": "^8.2.9",
92
- "@storybook/react-vite": "^8.2.9",
93
- "@storybook/test": "^8.2.9",
87
+ "@storybook/addon-essentials": "^8.3.2",
88
+ "@storybook/addon-interactions": "^8.3.2",
89
+ "@storybook/addon-links": "^8.3.2",
90
+ "@storybook/react": "^8.3.2",
91
+ "@storybook/react-vite": "^8.3.2",
92
+ "@storybook/test": "^8.3.2",
94
93
  "@storybook/test-runner": "^0.19.1",
95
94
  "@testing-library/dom": "^10.4.0",
96
95
  "@testing-library/jest-dom": "^6.5.0",
97
- "@testing-library/react": "^15.0.7",
96
+ "@testing-library/react": "^16.0.1",
98
97
  "@testing-library/user-event": "^14.5.2",
99
98
  "@trivago/prettier-plugin-sort-imports": "^4.3.0",
100
99
  "@types/debounce-promise": "^3.1.9",
101
- "@types/jest": "^29.5.12",
100
+ "@types/jest": "^29.5.13",
102
101
  "@types/lodash-es": "^4.17.12",
103
- "@types/node": "^18.19.39",
104
- "@types/react": "^18.3.5",
102
+ "@types/node": "^22.5.5",
103
+ "@types/react": "^18.3.8",
105
104
  "@types/react-dom": "^18.3.0",
106
105
  "@types/uuid": "^10.0.0",
107
106
  "@typescript-eslint/eslint-plugin": "^7.15.0",
108
107
  "@typescript-eslint/parser": "^7.15.0",
109
108
  "@vitejs/plugin-react-swc": "^3.7.0",
110
- "ag-grid-community": "^32.1.0",
111
- "ag-grid-react": "^32.1.0",
109
+ "ag-grid-community": "^32.2.0",
110
+ "ag-grid-react": "^32.2.0",
112
111
  "babel-jest": "^29.7.0",
113
112
  "babel-preset-react-app": "^10.0.1",
114
- "chromatic": "^11.7.1",
113
+ "chromatic": "^11.10.2",
115
114
  "css-loader": "^7.1.2",
116
- "esbuild": "^0.23.1",
115
+ "esbuild": "^0.24.0",
117
116
  "eslint": "^8.57.0",
118
117
  "eslint-config-prettier": "^9.1.0",
119
118
  "eslint-config-react-app": "^7.0.1",
120
119
  "eslint-plugin-deprecation": "^2.0.0",
121
- "eslint-plugin-import": "^2.29.1",
122
- "eslint-plugin-jest": "^28.8.1",
123
- "eslint-plugin-jsx-a11y": "^6.9.0",
120
+ "eslint-plugin-import": "^2.30.0",
121
+ "eslint-plugin-jest": "^28.8.3",
122
+ "eslint-plugin-jsx-a11y": "^6.10.0",
124
123
  "eslint-plugin-prettier": "^5.2.1",
125
- "eslint-plugin-react": "^7.35.0",
124
+ "eslint-plugin-react": "^7.36.1",
126
125
  "eslint-plugin-react-hooks": "^4.6.2",
127
126
  "eslint-plugin-storybook": "^0.8.0",
128
127
  "eslint-plugin-testing-library": "^6.3.0",
@@ -132,22 +131,22 @@
132
131
  "jest-expect-message": "^1.1.3",
133
132
  "mkdirp": "^3.0.1",
134
133
  "npm-run-all": "^4.1.5",
135
- "postcss": "^8.4.43",
134
+ "postcss": "^8.4.47",
136
135
  "postcss-loader": "^7.3.4",
137
136
  "postcss-scss": "^4.0.9",
138
137
  "prettier": "^3.3.3",
139
138
  "react": ">=18",
140
139
  "react-app-polyfill": "^3.0.0",
141
140
  "react-dom": "^18.3.1",
142
- "rollup": "^4.21.2",
141
+ "rollup": "^4.22.4",
143
142
  "rollup-plugin-copy": "^3.5.0",
144
143
  "rollup-plugin-peer-deps-external": "^2.2.4",
145
144
  "rollup-plugin-postcss": "^4.0.2",
146
145
  "rollup-plugin-typescript2": "^0.36.0",
147
- "sass": "^1.77.8",
146
+ "sass": "^1.79.3",
148
147
  "sass-loader": "^14.2.1",
149
148
  "semantic-release": "^22.0.12",
150
- "storybook": "^8.2.9",
149
+ "storybook": "^8.3.2",
151
150
  "storybook-css-modules-preset": "^1.1.1",
152
151
  "style-loader": "^4.0.0",
153
152
  "stylelint": "^15.11.0",
@@ -155,10 +154,10 @@
155
154
  "stylelint-config-standard": "^34.0.0",
156
155
  "stylelint-prettier": "^4.1.0",
157
156
  "stylelint-scss": "^5.3.2",
158
- "typescript": "^5.5.4",
159
- "vite": "^5.4.2",
157
+ "typescript": "^5.6.2",
158
+ "vite": "^5.4.7",
160
159
  "vite-plugin-html": "^3.2.2",
161
- "vite-tsconfig-paths": "^4.3.2"
160
+ "vite-tsconfig-paths": "^5.0.1"
162
161
  },
163
162
  "babel": {
164
163
  "presets": [
@@ -1,24 +1,24 @@
1
1
  import {
2
+ AgGridEvent,
3
+ CellClassParams,
2
4
  CellClickedEvent,
3
5
  CellDoubleClickedEvent,
4
6
  CellEditingStartedEvent,
7
+ CellKeyDownEvent,
5
8
  ColDef,
6
9
  ColGroupDef,
7
10
  ColumnResizedEvent,
11
+ EditableCallback,
12
+ EditableCallbackParams,
13
+ GridOptions,
14
+ GridReadyEvent,
8
15
  IClientSideRowModel,
9
16
  ModelUpdatedEvent,
17
+ RowDragEndEvent,
10
18
  RowDragLeaveEvent,
19
+ RowDragMoveEvent,
11
20
  RowHighlightPosition,
12
21
  RowNode,
13
- } from "ag-grid-community";
14
- import { CellClassParams, EditableCallback, EditableCallbackParams } from "ag-grid-community";
15
- import { GridOptions } from "ag-grid-community";
16
- import {
17
- AgGridEvent,
18
- CellKeyDownEvent,
19
- GridReadyEvent,
20
- RowDragEndEvent,
21
- RowDragMoveEvent,
22
22
  SelectionChangedEvent,
23
23
  } from "ag-grid-community";
24
24
  import { AgGridReact } from "ag-grid-react";
@@ -34,6 +34,7 @@ import { GridNoRowsOverlay } from "./GridNoRowsOverlay";
34
34
  import { usePostSortRowsHook } from "./PostSortRowsHook";
35
35
  import { GridHeaderSelect } from "./gridHeader";
36
36
  import { GridContextMenuComponent, useGridContextMenu } from "./gridHook";
37
+ import { clickInputWhenContainingCellClicked } from "./clickInputWhenContainingCellClicked";
37
38
 
38
39
  export interface GridBaseRow {
39
40
  id: string | number;
@@ -266,16 +267,6 @@ export const Grid = ({
266
267
  getFirstRowId,
267
268
  ]);
268
269
 
269
- /**
270
- * AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
271
- * This passes the event to the checkbox when you click anywhere in the cell.
272
- */
273
- const clickSelectorCheckboxWhenContainingCellClicked = useCallback(({ event }: CellClickedEvent) => {
274
- if (!event) return;
275
- const input = (event.target as Element).querySelector("input");
276
- input?.dispatchEvent(event);
277
- }, []);
278
-
279
270
  /**
280
271
  * Ensure external selected items list is in sync with panel.
281
272
  */
@@ -388,7 +379,7 @@ export const Grid = ({
388
379
  }
389
380
  return false;
390
381
  },
391
- onCellClicked: clickSelectorCheckboxWhenContainingCellClicked,
382
+ onCellClicked: clickInputWhenContainingCellClicked,
392
383
  },
393
384
  ...adjustColDefs,
394
385
  ]
@@ -402,7 +393,6 @@ export const Grid = ({
402
393
  params.defaultColDef?.editable,
403
394
  selectColumnPinned,
404
395
  rowSelection,
405
- clickSelectorCheckboxWhenContainingCellClicked,
406
396
  ]);
407
397
 
408
398
  /**
@@ -528,11 +518,16 @@ export const Grid = ({
528
518
  */
529
519
  const onCellKeyPress = useCallback(
530
520
  (e: CellKeyDownEvent) => {
531
- if ((e.event as KeyboardEvent).key === "Enter") {
521
+ const kbe = e.event as KeyboardEvent;
522
+ if (kbe.key === "Enter") {
532
523
  if (!invokeEditAction(e)) startCellEditing(e);
533
524
  }
525
+ if (kbe.key === "Tab") {
526
+ // eslint-disable-next-line
527
+ prePopupOps();
528
+ }
534
529
  },
535
- [startCellEditing],
530
+ [prePopupOps, startCellEditing],
536
531
  );
537
532
 
538
533
  /**
@@ -98,7 +98,9 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
98
98
  editable?: boolean | SAEditableCallback<TData, ValueType>;
99
99
  valueGetter?: string | SAValueGetterFunc<TData, ValueType>;
100
100
  valueFormatter?: string | SAValueFormatterFunc<TData, ValueType>;
101
- cellRenderer?: (props: SAICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
101
+ cellRenderer?:
102
+ | ((props: SAICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined)
103
+ | string;
102
104
  cellRendererParams?: {
103
105
  singleClickEdit?: boolean;
104
106
  rightHoverElement?: ReactElement;
@@ -200,7 +202,7 @@ export const GridCell = <TData extends GridBaseRow, TValue = any, Props extends
200
202
  else return JSON.stringify(params.value);
201
203
  },
202
204
  ...props,
203
- cellRenderer: GridCellRenderer,
205
+ cellRenderer: typeof props.cellRenderer === "string" ? props.cellRenderer : GridCellRenderer,
204
206
  cellRendererParams: {
205
207
  originalCellRenderer: props.cellRenderer,
206
208
  ...props.cellRendererParams,
@@ -0,0 +1,40 @@
1
+ import { CellClickedEvent } from "ag-grid-community";
2
+
3
+ /**
4
+ * AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
5
+ * This passes the event to the checkbox when you click anywhere in the cell.
6
+ */
7
+ export const clickInputWhenContainingCellClicked = ({ data, event, colDef }: CellClickedEvent) => {
8
+ if (!data || !event) return;
9
+
10
+ const element = event.target as Element;
11
+ // Already handled
12
+ if (["BUTTON", "INPUT"].includes(element?.tagName) && element.closest(".ag-cell-inline-editing")) return;
13
+
14
+ const row = element.closest("[row-id]");
15
+ if (!row) return;
16
+
17
+ const colId = colDef.colId;
18
+ if (!colId) return;
19
+
20
+ const clickInput = (cnt: number) => {
21
+ const cell = row.querySelector(`[col-id='${colId}']`);
22
+ if (!cell) return;
23
+
24
+ const input = cell.querySelector("input, button");
25
+ if (!input) {
26
+ return;
27
+ }
28
+ // When clicking on a cell that is not editing, the cell changes to editing and the input/button ref becomes invalid
29
+ // So wait until the cell is in edit mode before sending the click
30
+ if (!input.ownerDocument.contains(input)) {
31
+ if (cnt !== 0) {
32
+ setTimeout(() => clickInput(cnt - 1));
33
+ }
34
+ return;
35
+ }
36
+ input?.dispatchEvent(event);
37
+ };
38
+
39
+ setTimeout(() => clickInput(20), 10);
40
+ };
@@ -45,6 +45,7 @@ export interface GridFormDropDownProps<TData extends GridBaseRow> extends CellEd
45
45
  | "GridPopoverEditDropDown-containerMedium"
46
46
  | "GridPopoverEditDropDown-containerLarge"
47
47
  | "GridPopoverEditDropDown-containerUnlimited"
48
+ | "GridPopoverEditDropDown-containerAutoWidth"
48
49
  | string
49
50
  | undefined;
50
51
  // local means the use the local filter, otherwise it's expected options will be passed a function that takes a filter
@@ -140,7 +140,7 @@ export const GridFormMultiSelectGrid = <TData extends GridBaseRow>(
140
140
  }}
141
141
  >
142
142
  <LuiCheckboxInput
143
- isChecked={!!o.checked ?? false}
143
+ isChecked={!!o.checked}
144
144
  isIndeterminate={o.checked === "partial"}
145
145
  value={`${o.value}`}
146
146
  label={
@@ -0,0 +1,79 @@
1
+ import { CellFocusedEvent } from "ag-grid-community";
2
+ import { CellEditorCommon, ColDefT, GridCell } from "../GridCell";
3
+ import { useEffect, useRef } from "react";
4
+ import { fnOrVar } from "../../utils/util";
5
+ import clsx from "clsx";
6
+ import { GenericCellColDef } from "../gridRender";
7
+ import { GridBaseRow } from "../Grid";
8
+ import { CustomCellEditorProps } from "ag-grid-react";
9
+ import { clickInputWhenContainingCellClicked } from "../clickInputWhenContainingCellClicked";
10
+
11
+ const BooleanCellRenderer = (props: CustomCellEditorProps) => {
12
+ const { onValueChange, value, api, node, column, colDef, data } = props;
13
+ const inputRef = useRef<HTMLInputElement>(null);
14
+
15
+ useEffect(() => {
16
+ const checkFocus = (event: CellFocusedEvent) => {
17
+ if (event.rowIndex === node.rowIndex && event.column === column) {
18
+ inputRef.current?.focus();
19
+ }
20
+ };
21
+ api.addEventListener("cellFocused", checkFocus);
22
+ return () => {
23
+ api.removeEventListener("cellFocused", checkFocus);
24
+ };
25
+ }, [api, column, node.rowIndex]);
26
+
27
+ return (
28
+ <div className={clsx("ag-wrapper ag-input-wrapper ag-checkbox-input-wrapper", { "ag-checked": props.value })}>
29
+ <input
30
+ type="checkbox"
31
+ className="ag-input-field-input ag-checkbox-input"
32
+ disabled={!fnOrVar(colDef?.editable, props)}
33
+ ref={inputRef}
34
+ checked={value}
35
+ onChange={() => {}}
36
+ onClick={(e) => {
37
+ e.stopPropagation();
38
+ // cell has to be in edit mode
39
+ // if in non-edit mode clickInputWhenContainingCellClicked will click to put it in edit mode
40
+ if (!onValueChange) return;
41
+ const params = props?.colDef?.cellEditorParams as GridEditBooleanEditorProps<any> | undefined;
42
+ if (!params) return;
43
+ const selectedRows = [data];
44
+ const checked = !value;
45
+ onValueChange(checked);
46
+ params.onClick({ selectedRows, selectedRowIds: selectedRows.map((r) => r.id), checked }).then();
47
+ }}
48
+ />
49
+ </div>
50
+ );
51
+ };
52
+
53
+ export interface GridEditBooleanEditorProps<TData> extends CellEditorCommon {
54
+ onClick: (props: {
55
+ selectedRows: TData[];
56
+ selectedRowIds: (string | number)[];
57
+ checked: boolean;
58
+ }) => Promise<boolean>;
59
+ }
60
+
61
+ export const GridEditBoolean = <TData extends GridBaseRow>(
62
+ colDef: GenericCellColDef<TData, boolean>,
63
+ editorProps: GridEditBooleanEditorProps<TData>,
64
+ ): ColDefT<TData> => {
65
+ return GridCell({
66
+ minWidth: 64,
67
+ maxWidth: 64,
68
+ cellRenderer: BooleanCellRenderer as any,
69
+ cellEditor: BooleanCellRenderer,
70
+ cellEditorParams: editorProps,
71
+ onCellClicked: clickInputWhenContainingCellClicked,
72
+ singleClickEdit: true,
73
+ resizable: false,
74
+ editable: true,
75
+ cellClass: "GridCellAlignCenter",
76
+ headerClass: "GridHeaderAlignCenter",
77
+ ...colDef,
78
+ });
79
+ };
@@ -13,6 +13,13 @@ export const GridPopoverEditDropDown = <TData extends GridBaseRow, TValue = any>
13
13
  ...props,
14
14
  editorParams: {
15
15
  ...(props.editorParams as GridFormDropDownProps<TData>),
16
- className: clsx("GridPopoverEditDropDown-containerLarge", props.editorParams?.className),
16
+ className: clsx(
17
+ {
18
+ "GridPopoverEditDropDown-containerLarge": !props.editorParams?.className?.includes(
19
+ "GridPopoverEditDropDown-container",
20
+ ),
21
+ },
22
+ props.editorParams?.className,
23
+ ),
17
24
  },
18
25
  });
@@ -1,3 +1,4 @@
1
+ export * from "./GridEditBoolean";
1
2
  export * from "./GridPopoutEditMultiSelect";
2
3
  export * from "./GridPopoutEditMultiSelectGrid";
3
4
  export * from "./GridPopoverMenu";
@@ -16,3 +16,4 @@ export * from "./GridPopoverHook";
16
16
  export * from "./gridRender";
17
17
  export * from "./GridWrapper";
18
18
  export * from "./PostSortRowsHook";
19
+ export * from "./clickInputWhenContainingCellClicked";
@@ -533,6 +533,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
533
533
  // implying it was start/end of grid
534
534
  break;
535
535
  }
536
+
536
537
  if (focusedCellIsEditable()) {
537
538
  const focusedCell = gridApi?.getFocusedCell();
538
539
  if (focusedCell) {
@@ -1,15 +1,9 @@
1
1
  import clsx from "clsx";
2
2
  import { omit } from "lodash-es";
3
- import { InputHTMLAttributes, ReactElement, useState } from "react";
4
- import { v4 as uuidVersion4 } from "uuid";
3
+ import { InputHTMLAttributes, ReactElement, useId } from "react";
5
4
 
6
5
  import { FormError } from "./FormError";
7
6
 
8
- export const useGenerateOrDefaultId = (idFromProps?: string) => {
9
- const [id] = useState(idFromProps ? idFromProps : uuidVersion4());
10
- return id;
11
- };
12
-
13
7
  export interface LuiTextAreaInputProps extends InputHTMLAttributes<HTMLTextAreaElement> {
14
8
  // overrides value in base class to be string type only
15
9
  value: string;
@@ -23,7 +17,8 @@ export interface LuiTextAreaInputProps extends InputHTMLAttributes<HTMLTextAreaE
23
17
  }
24
18
 
25
19
  export const TextAreaInput = (props: LuiTextAreaInputProps) => {
26
- const id = useGenerateOrDefaultId(props?.id);
20
+ const reactId = useId();
21
+ const id = props?.id ?? reactId;
27
22
 
28
23
  return (
29
24
  <div
@@ -13,6 +13,7 @@ export interface IFormTestRow {
13
13
  numba: string;
14
14
  plan: string;
15
15
  distance: number | null;
16
+ bold: boolean;
16
17
  }
17
18
 
18
19
  export const FormTest = (props: CellEditorCommon): ReactElement => {
@@ -0,0 +1,74 @@
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 { ColDefT, Grid, GridCell, GridContextProvider, GridEditBoolean, GridUpdatingContextProvider } from "../..";
11
+ import { waitForGridReady } from "../../utils/storybookTestUtil";
12
+ import { IFormTestRow } from "./FormTest";
13
+
14
+ export default {
15
+ title: "Components / Grids",
16
+ component: Grid,
17
+ decorators: [
18
+ (Story) => (
19
+ <div style={{ width: 1024, height: 400 }}>
20
+ <GridUpdatingContextProvider>
21
+ <GridContextProvider>
22
+ <Story />
23
+ </GridContextProvider>
24
+ </GridUpdatingContextProvider>
25
+ </div>
26
+ ),
27
+ ],
28
+ } as Meta<typeof Grid>;
29
+
30
+ const GridPopoutEditBooleanTemplate: StoryFn<typeof Grid> = () => {
31
+ const [rowData, setRowData] = useState([
32
+ { id: 1000, name: "IS IS DP12345", nameType: "IS", numba: "IX", plan: "DP 12345", bold: true },
33
+ { id: 1001, name: "PEG V SD523", nameType: "PEG", numba: "V", plan: "SD 523", bold: false },
34
+ ] as IFormTestRow[]);
35
+
36
+ const columnDefs: ColDefT<IFormTestRow>[] = useMemo(
37
+ () => [
38
+ GridCell({
39
+ field: "id",
40
+ headerName: "Id",
41
+ }),
42
+ GridEditBoolean(
43
+ {
44
+ field: "bold",
45
+ },
46
+ {
47
+ onClick: async ({ selectedRowIds, checked }) => {
48
+ setRowData((rowData) => {
49
+ // eslint-disable-next-line no-console
50
+ console.log("onchange", selectedRowIds, checked);
51
+ return rowData.map((row) => (selectedRowIds.includes(row.id) ? { ...row, bold: checked } : row));
52
+ });
53
+ return true;
54
+ },
55
+ },
56
+ ),
57
+ ],
58
+ [],
59
+ );
60
+
61
+ return (
62
+ <Grid
63
+ columnDefs={columnDefs}
64
+ rowData={rowData}
65
+ selectable={false}
66
+ singleClickEdit={true}
67
+ rowSelection="single"
68
+ domLayout={"autoHeight"}
69
+ />
70
+ );
71
+ };
72
+
73
+ export const _EditBoolean = GridPopoutEditBooleanTemplate.bind({});
74
+ _EditBoolean.play = waitForGridReady;
@@ -57,6 +57,7 @@ const Template: StoryFn<typeof GridFormDropDown> = (props: GridFormDropDownProps
57
57
  anchorRef,
58
58
  updateValue,
59
59
  data: { value: "" },
60
+ colId: "",
60
61
  value: "",
61
62
  field: "value",
62
63
  selectedRows: [],
@@ -41,6 +41,7 @@ const Template: StoryFn<typeof GridFormEditBearing> = (props: GridFormEditBearin
41
41
  <GridPopoverContext.Provider
42
42
  value={{
43
43
  anchorRef,
44
+ colId: "",
44
45
  value: null,
45
46
  updateValue,
46
47
  formatValue: (value) => value,
@@ -41,6 +41,7 @@ const Template: StoryFn<typeof GridFormEditBearing> = (props: GridFormEditBearin
41
41
  <GridPopoverContext.Provider
42
42
  value={{
43
43
  anchorRef,
44
+ colId: "",
44
45
  value: null,
45
46
  updateValue,
46
47
  formatValue: (value) => value,
@@ -54,6 +54,7 @@ const Template: StoryFn<typeof GridFormMultiSelectGrid> = (props: GridFormMultiS
54
54
  value={{
55
55
  anchorRef: anchorRef,
56
56
  updateValue,
57
+ colId: "",
57
58
  value: "",
58
59
  selectedRows: [],
59
60
  formatValue: (value) => value,
@@ -68,6 +68,7 @@ const Template: StoryFn<typeof GridFormMultiSelect> = (props: GridFormMultiSelec
68
68
  anchorRef,
69
69
  updateValue,
70
70
  data: { value: "" },
71
+ colId: "",
71
72
  value: "",
72
73
  field: "value",
73
74
  selectedRows: [],
@@ -59,6 +59,7 @@ const Template: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMen
59
59
  value: null,
60
60
  updateValue,
61
61
  data: { value: "" },
62
+ colId: "",
62
63
  field: "value",
63
64
  selectedRows: [],
64
65
  saving: false,
@@ -39,6 +39,7 @@ const Template: StoryFn<typeof GridFormTextArea> = (props: GridFormTextAreaProps
39
39
  value: null,
40
40
  updateValue,
41
41
  data: { value: null },
42
+ colId: "",
42
43
  field: "value",
43
44
  selectedRows: [],
44
45
  saving: false,
@@ -39,6 +39,7 @@ const Template: StoryFn<typeof GridFormTextInput> = (props: GridFormTextInputPro
39
39
  value: null,
40
40
  updateValue,
41
41
  data: { value: null },
42
+ colId: "",
42
43
  field: "value",
43
44
  selectedRows: [],
44
45
  saving: false,
@@ -2,6 +2,18 @@
2
2
  @use "./react-menu-customisations";
3
3
  @use "../../node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars" as colors;
4
4
 
5
+
6
+ .LabelPreferencesPanelGridCellAlignCenter .ag-wrapper {
7
+ margin-left: auto;
8
+ margin-right: auto;
9
+ }
10
+
11
+ .LabelPreferencesPanelGridCellAlignCenter .ag-cell-wrapper, .LabelPreferencesPanelGridCellAlignCenter .GridCell-container {
12
+ display: flex;
13
+ justify-content: center;
14
+ }
15
+
16
+
5
17
  .Grid-container {
6
18
  flex: 1;
7
19
  width: 100%;
@@ -106,4 +118,25 @@
106
118
  background-color: colors.$hint;
107
119
  }
108
120
 
121
+ .GridHeaderAlignCenter .ag-header-cell-text {
122
+ margin-left: auto;
123
+ margin-right: auto;
124
+ }
109
125
 
126
+ .GridCellAlignCenter .GridCell-container {
127
+ display: flex;
128
+ }
129
+
130
+ .GridCellAlignCenter .ag-wrapper {
131
+ margin-left: auto;
132
+ margin-right: auto;
133
+ }
134
+
135
+ .GridCellAlignCenter .ag-cell-wrapper, .LabelPreferencesPanelGridCellAlignCenter .GridCell-container {
136
+ display: flex;
137
+ justify-content: center;
138
+ }
139
+
140
+ div.ag-ltr div.ag-header-cell-resize {
141
+ right: -4px;
142
+ }