@linzjs/step-ag-grid 7.5.2 → 7.6.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.
Files changed (38) hide show
  1. package/dist/GridTheme.scss +11 -9
  2. package/dist/index.css +233 -135
  3. package/dist/index.js +97 -94
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/components/Grid.d.ts +1 -0
  6. package/dist/src/components/GridIcon.d.ts +4 -1
  7. package/dist/src/components/GridLoadableCell.d.ts +0 -2
  8. package/dist/src/components/gridForm/GridFormDropDown.d.ts +0 -1
  9. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +0 -1
  10. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +0 -1
  11. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +0 -1
  12. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +2 -2
  13. package/dist/src/index.d.ts +1 -0
  14. package/dist/src/utils/deferredPromise.d.ts +5 -0
  15. package/dist/src/utils/util.d.ts +1 -0
  16. package/dist/step-ag-grid.esm.js +96 -94
  17. package/dist/step-ag-grid.esm.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/components/Grid.tsx +40 -22
  20. package/src/components/GridCell.tsx +23 -10
  21. package/src/components/GridIcon.tsx +15 -4
  22. package/src/components/GridLoadableCell.tsx +10 -23
  23. package/src/components/gridForm/GridFormDropDown.tsx +0 -2
  24. package/src/components/gridForm/GridFormEditBearing.tsx +0 -2
  25. package/src/components/gridForm/GridFormMultiSelect.tsx +0 -2
  26. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +0 -2
  27. package/src/components/gridRender/GridRenderGenericCell.tsx +3 -32
  28. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +8 -24
  29. package/src/index.ts +1 -0
  30. package/src/stories/grid/GridReadOnly.stories.tsx +16 -3
  31. package/src/styles/Grid.scss +16 -4
  32. package/src/styles/{GridRenderGenericCell.scss → GridIcon.scss} +19 -15
  33. package/src/{components → styles}/GridLoadableCell.scss +5 -4
  34. package/src/{components/gridPopoverEdit → styles}/GridPopoverMenu.scss +1 -1
  35. package/src/styles/GridTheme.scss +11 -9
  36. package/src/styles/index.scss +8 -0
  37. package/src/utils/deferredPromise.ts +34 -0
  38. package/src/utils/util.ts +2 -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": "7.5.2",
5
+ "version": "7.6.1",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -7,15 +7,17 @@ import { GridOptions } from "ag-grid-community/dist/lib/entities/gridOptions";
7
7
  import { difference, last, xorBy } from "lodash-es";
8
8
  import { GridContext } from "../contexts/GridContext";
9
9
  import { usePostSortRowsHook } from "./PostSortRowsHook";
10
- import { isNotEmpty } from "../utils/util";
10
+ import { fnOrVar, isNotEmpty } from "../utils/util";
11
11
  import { GridHeaderSelect } from "./gridHeader/GridHeaderSelect";
12
12
  import { GridUpdatingContext } from "../contexts/GridUpdatingContext";
13
+ import { CellClassParams } from "ag-grid-community/dist/lib/entities/colDef";
13
14
 
14
15
  export interface GridBaseRow {
15
16
  id: string | number;
16
17
  }
17
18
 
18
19
  export interface GridProps {
20
+ readOnly?: boolean; // set all editables to false when read only, make all styles black, otherwise style is gray for not editable
19
21
  selectable?: boolean;
20
22
  ["data-testid"]?: string;
21
23
  quickFilter?: boolean;
@@ -124,26 +126,35 @@ export const Grid = (params: GridProps): JSX.Element => {
124
126
  synchroniseExternallySelectedItemsToGrid();
125
127
  }, [synchroniseExternallySelectedItemsToGrid]);
126
128
 
127
- const columnDefs = useMemo(
128
- (): GridOptions["columnDefs"] =>
129
- params.selectable
130
- ? [
131
- {
132
- colId: "selection",
133
- editable: false,
134
- initialWidth: 35,
135
- minWidth: 35,
136
- maxWidth: 35,
137
- suppressSizeToFit: true,
138
- checkboxSelection: true,
139
- headerComponent: GridHeaderSelect,
140
- onCellClicked: clickSelectorCheckboxWhenContainingCellClicked,
141
- },
142
- ...(params.columnDefs as ColDef[]),
143
- ]
144
- : [...(params.columnDefs as ColDef[])],
145
- [clickSelectorCheckboxWhenContainingCellClicked, params.columnDefs, params.selectable],
146
- );
129
+ const columnDefs = useMemo((): GridOptions["columnDefs"] => {
130
+ const adjustColDefs = (params.columnDefs as ColDef[]).map((colDef) => {
131
+ return {
132
+ ...colDef,
133
+ editable: params.readOnly ? false : colDef.editable,
134
+ cellClassRules: {
135
+ ...colDef.cellClassRules,
136
+ "GridCell-readonly": (ccp: CellClassParams) =>
137
+ params.readOnly != null && !params.readOnly && !fnOrVar(colDef.editable, ccp),
138
+ },
139
+ };
140
+ });
141
+ return params.selectable
142
+ ? [
143
+ {
144
+ colId: "selection",
145
+ editable: false,
146
+ initialWidth: 35,
147
+ minWidth: 35,
148
+ maxWidth: 35,
149
+ suppressSizeToFit: true,
150
+ checkboxSelection: true,
151
+ headerComponent: GridHeaderSelect,
152
+ onCellClicked: clickSelectorCheckboxWhenContainingCellClicked,
153
+ },
154
+ ...adjustColDefs,
155
+ ]
156
+ : adjustColDefs;
157
+ }, [clickSelectorCheckboxWhenContainingCellClicked, params.columnDefs, params.selectable, params.readOnly]);
147
158
 
148
159
  const onGridReady = useCallback(
149
160
  (event: GridReadyEvent) => {
@@ -176,6 +187,7 @@ export const Grid = (params: GridProps): JSX.Element => {
176
187
  if (checkUpdating([event.colDef.field ?? ""], event.data.id)) {
177
188
  return;
178
189
  }
190
+
179
191
  if (event.rowIndex !== null) {
180
192
  event.api.startEditingCell({
181
193
  rowIndex: event.rowIndex,
@@ -188,7 +200,13 @@ export const Grid = (params: GridProps): JSX.Element => {
188
200
 
189
201
  const onCellDoubleClick = useCallback(
190
202
  (event: CellEvent) => {
191
- if (!event.colDef?.cellRendererParams?.singleClickEdit) {
203
+ const editable = fnOrVar(event.colDef?.editable, event);
204
+ if (!editable) return;
205
+ const editAction = event.colDef?.cellRendererParams?.editAction;
206
+ if (editAction) {
207
+ // Clicked row comes first in selected rows
208
+ editAction([event.data, ...event.api.getSelectedRows().filter((row) => row.id !== event.data.id)]);
209
+ } else if (!event.colDef?.cellRendererParams?.singleClickEdit) {
192
210
  startCellEditing(event);
193
211
  }
194
212
  },
@@ -2,16 +2,13 @@ import { forwardRef, useContext } from "react";
2
2
  import { GridBaseRow } from "./Grid";
3
3
  import { GridUpdatingContext } from "../contexts/GridUpdatingContext";
4
4
  import { GridCellMultiSelectClassRules } from "./GridCellMultiSelectClassRules";
5
- import {
6
- GenericCellColDef,
7
- GenericCellRendererParams,
8
- GridRendererGenericCell,
9
- } from "./gridRender/GridRenderGenericCell";
5
+ import { GenericCellColDef, GenericCellRendererParams } from "./gridRender/GridRenderGenericCell";
10
6
  import { ColDef, ICellEditorParams, ICellRendererParams } from "ag-grid-community";
11
7
  import { GridLoadableCell } from "./GridLoadableCell";
12
8
  import { GridIcon } from "./GridIcon";
13
9
  import { ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef";
14
10
  import { GridPopoverContextProvider } from "../contexts/GridPopoverContextProvider";
11
+ import { fnOrVar } from "../utils/util";
15
12
 
16
13
  export interface GenericCellEditorProps<E> {
17
14
  multiEdit?: boolean;
@@ -29,16 +26,23 @@ export const GridCellRenderer = (props: ICellRendererParams) => {
29
26
  const infoFn = rendererParams?.info;
30
27
  const infoText = infoFn ? infoFn(props) : undefined;
31
28
 
32
- return colDef?.cellRendererParams?.originalCellRenderer ? (
29
+ return (
33
30
  <GridLoadableCell isLoading={checkUpdating(colDef.field ?? colDef.colId ?? "", props.data.id)}>
34
31
  <>
35
32
  {typeof warningText === "string" && <GridIcon icon={"ic_warning"} title={warningText} />}
36
33
  {typeof infoText === "string" && <GridIcon icon={"ic_info"} title={infoText} />}
37
- <colDef.cellRendererParams.originalCellRenderer {...props} />
34
+ <div style={{ display: "flex", flex: 1, overflow: "hidden" }}>
35
+ {colDef?.cellRendererParams?.originalCellRenderer ? (
36
+ <colDef.cellRendererParams.originalCellRenderer {...props} />
37
+ ) : (
38
+ <span title={props.valueFormatted}>{props.valueFormatted}</span>
39
+ )}
40
+ </div>
41
+ {fnOrVar(props.colDef?.editable, props) && rendererParams?.editableIcon && (
42
+ <div style={{ display: "flex", alignItems: "center" }}>{rendererParams?.editableIcon}</div>
43
+ )}
38
44
  </>
39
45
  </GridLoadableCell>
40
- ) : (
41
- <GridRendererGenericCell {...props} />
42
46
  );
43
47
  };
44
48
 
@@ -98,9 +102,18 @@ export interface CellEditorCommon {
98
102
 
99
103
  export const GenericCellEditorComponentWrapper = (custom?: { editor?: (props: any) => JSX.Element }) => {
100
104
  return forwardRef(function GenericCellEditorComponentFr(cellEditorParams: ICellEditorParams, _) {
105
+ const valueFormatted = cellEditorParams.formatValue
106
+ ? cellEditorParams.formatValue(cellEditorParams.value)
107
+ : "Missing formatter";
101
108
  return (
102
109
  <GridPopoverContextProvider props={cellEditorParams}>
103
- {<cellEditorParams.colDef.cellRenderer {...cellEditorParams} {...cellEditorParams.colDef.cellRendererParams} />}
110
+ {
111
+ <cellEditorParams.colDef.cellRenderer
112
+ {...cellEditorParams}
113
+ valueFormatted={valueFormatted}
114
+ {...cellEditorParams.colDef.cellRendererParams}
115
+ />
116
+ }
104
117
  {custom?.editor && <custom.editor {...cellEditorParams} />}
105
118
  </GridPopoverContextProvider>
106
119
  );
@@ -1,12 +1,23 @@
1
- import { IconName } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
1
+ import clsx from "clsx";
2
2
  import { LuiIcon } from "@linzjs/lui";
3
+ import { IconName, IconSize } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
3
4
 
4
- export const GridIcon = (props: { icon: IconName; title: string }): JSX.Element => (
5
+ export const GridIcon = (props: {
6
+ icon: IconName;
7
+ title: string;
8
+ size?: IconSize;
9
+ disabled?: boolean;
10
+ className?: string;
11
+ }): JSX.Element => (
5
12
  <LuiIcon
6
13
  name={props.icon}
7
14
  title={props.title}
8
15
  alt={props.title}
9
- size={"md"}
10
- className={`AgGridGenericCellRenderer-${props.icon}Icon`}
16
+ size={props.size ?? "md"}
17
+ className={clsx(
18
+ `AgGridGenericCellRenderer-${props.icon}Icon`,
19
+ props.className,
20
+ props.disabled && "GridIcon-disabled",
21
+ )}
11
22
  />
12
23
  );
@@ -1,25 +1,12 @@
1
- import "./GridLoadableCell.scss";
2
-
3
- import { LuiMiniSpinner } from "@linzjs/lui";
4
1
  import clsx from "clsx";
2
+ import { LuiMiniSpinner } from "@linzjs/lui";
5
3
 
6
- export const GridLoadableCell = (props: {
7
- isLoading: boolean;
8
- dataTestId?: string;
9
- children: JSX.Element | string;
10
- className?: string;
11
- }): JSX.Element => {
12
- if (props.isLoading) {
13
- return (
14
- <div style={{ display: "flex", alignItems: "center" }}>
15
- <LuiMiniSpinner size={22} divProps={{ role: "status", "aria-label": "Loading", style: { marginBottom: 4 } }} />
16
- </div>
17
- );
18
- }
19
- // only add test id into ONE of the columns in a grid. this way each row will have one unique id :)
20
- return (
21
- <div data-testid={props.dataTestId} className={clsx("GridLoadableCell-container", props.className)}>
22
- {props.children}
23
- </div>
24
- );
25
- };
4
+ export const GridLoadableCell = (props: { isLoading: boolean; children: JSX.Element | string; className?: string }) => (
5
+ <div className={clsx("GridLoadableCell-container", props.className)}>
6
+ {props.isLoading ? (
7
+ <LuiMiniSpinner size={22} divProps={{ role: "status", "aria-label": "Loading", style: { marginBottom: 4 } }} />
8
+ ) : (
9
+ props.children
10
+ )}
11
+ </div>
12
+ );
@@ -1,5 +1,3 @@
1
- import "../../styles/GridFormDropDown.scss";
2
-
3
1
  import { FocusableItem, MenuDivider, MenuHeader, MenuItem } from "../../react-menu3";
4
2
  import { KeyboardEvent, useCallback, useContext, useEffect, useRef, useState } from "react";
5
3
  import { GridBaseRow } from "../Grid";
@@ -1,5 +1,3 @@
1
- import "../../styles/GridFormEditBearing.scss";
2
-
3
1
  import { useCallback, useMemo, useState } from "react";
4
2
  import { GridBaseRow } from "../Grid";
5
3
  import { TextInputFormatted } from "../../lui/TextInputFormatted";
@@ -1,5 +1,3 @@
1
- import "../../styles/GridFormMultiSelect.scss";
2
-
3
1
  import { FocusableItem, MenuDivider, MenuHeader, MenuItem } from "../../react-menu3";
4
2
  import {
5
3
  useCallback,
@@ -1,5 +1,3 @@
1
- import "./GridPopoverMenu.scss";
2
-
3
1
  import { GridBaseRow } from "../Grid";
4
2
  import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
5
3
  import { GridFormPopoverMenu, GridFormPopoutMenuProps } from "../gridForm/GridFormPopoverMenu";
@@ -1,10 +1,4 @@
1
- import "../../styles/GridRenderGenericCell.scss";
2
-
3
- import { useContext } from "react";
4
- import { GridUpdatingContext } from "../../contexts/GridUpdatingContext";
5
- import { GridLoadableCell } from "../GridLoadableCell";
6
- import { GridIcon } from "../GridIcon";
7
- import { ColDef, ICellRendererParams } from "ag-grid-community";
1
+ import { ICellRendererParams } from "ag-grid-community";
8
2
  import { GridBaseRow } from "../Grid";
9
3
  import { ColDefT } from "../GridCell";
10
4
 
@@ -18,31 +12,8 @@ export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<
18
12
 
19
13
  export interface GenericCellRendererParams<RowType extends GridBaseRow> {
20
14
  singleClickEdit?: boolean;
15
+ editableIcon?: JSX.Element | undefined;
16
+ editAction?: (selectedRows: RowType[]) => void;
21
17
  warning?: (props: RowICellRendererParams<RowType>) => string | boolean | null | undefined;
22
18
  info?: (props: RowICellRendererParams<RowType>) => string | boolean | null | undefined;
23
19
  }
24
-
25
- export const GridRendererGenericCell = <RowType extends GridBaseRow>(props: ICellRendererParams): JSX.Element => {
26
- const { checkUpdating } = useContext(GridUpdatingContext);
27
-
28
- const colDef = props.colDef as ColDef;
29
- const cellRendererParams = colDef.cellRendererParams as GenericCellRendererParams<RowType> | undefined;
30
- const warningFn = cellRendererParams?.warning;
31
- const warningText = warningFn ? warningFn(props) : undefined;
32
- const infoFn = cellRendererParams?.info;
33
- const infoText = infoFn ? infoFn(props) : undefined;
34
-
35
- const defaultFormatter = (value: any): string => value;
36
- const formatter = props.formatValue ?? defaultFormatter;
37
- const formatted = formatter(props.value);
38
-
39
- return (
40
- <GridLoadableCell isLoading={checkUpdating(colDef.field ?? colDef.colId ?? "", props.data.id)}>
41
- <>
42
- {typeof warningText === "string" && <GridIcon icon={"ic_warning"} title={warningText} />}
43
- {typeof infoText === "string" && <GridIcon icon={"ic_info"} title={infoText} />}
44
- <span title={formatted}>{formatted}</span>
45
- </>
46
- </GridLoadableCell>
47
- );
48
- };
@@ -1,32 +1,16 @@
1
- import { useContext } from "react";
2
- import { ColDef, ICellRendererParams } from "ag-grid-community";
3
- import { GridUpdatingContext } from "../../contexts/GridUpdatingContext";
4
- import { GridLoadableCell } from "../GridLoadableCell";
1
+ import { ICellRendererParams } from "ag-grid-community";
5
2
  import { LuiIcon } from "@linzjs/lui";
6
- import { Column } from "ag-grid-community/dist/lib/entities/column";
3
+ import { fnOrVar } from "../../utils/util";
7
4
 
8
5
  export const GridRenderPopoutMenuCell = (props: ICellRendererParams) => {
9
- const { checkUpdating } = useContext(GridUpdatingContext);
10
- const isLoading = checkUpdating(props.colDef?.field ?? "", props.data.id);
11
- const editable = props.colDef?.editable;
12
- const disabled = !(typeof editable === "function"
13
- ? editable({
14
- node: props.node,
15
- data: props.data,
16
- column: props.column as Column,
17
- colDef: props.colDef as ColDef,
18
- api: props.api,
19
- columnApi: props.columnApi,
20
- context: props.context,
21
- })
22
- : editable);
6
+ const disabled = !fnOrVar(props.colDef?.editable, props);
23
7
 
24
8
  return (
25
- <GridLoadableCell
26
- isLoading={isLoading}
9
+ <LuiIcon
10
+ name={"ic_more_vert"}
11
+ alt={"More actions"}
12
+ size={"md"}
27
13
  className={disabled ? `GridPopoutMenu-burgerDisabled` : `GridPopoutMenu-burger`}
28
- >
29
- <LuiIcon name={"ic_more_vert"} alt={"More actions"} size={"md"} />
30
- </GridLoadableCell>
14
+ />
31
15
  );
32
16
  };
package/src/index.ts CHANGED
@@ -45,4 +45,5 @@ export * from "./lui/ActionButton";
45
45
 
46
46
  export * from "./utils/bearing";
47
47
  export * from "./utils/util";
48
+ export * from "./utils/deferredPromise";
48
49
  export * from "./utils/testUtil";
@@ -15,6 +15,7 @@ import { GridPopoverMessage } from "../../components/gridPopoverEdit/GridPopover
15
15
  import { MenuOption } from "../../components/gridForm/GridFormPopoverMenu";
16
16
  import { GridFormSubComponentTextInput } from "../../components/gridForm/GridFormSubComponentTextInput";
17
17
  import { GridFormSubComponentTextArea } from "../../components/gridForm/GridFormSubComponentTextArea";
18
+ import { GridIcon } from "../../components/GridIcon";
18
19
 
19
20
  export default {
20
21
  title: "Components / Grids",
@@ -81,8 +82,8 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
81
82
  GridPopoverMessage(
82
83
  {
83
84
  headerName: "Popout message",
84
- maxWidth: 200,
85
- cellRenderer: () => <>Click me!</>,
85
+ maxWidth: 150,
86
+ cellRenderer: () => <>Single Click me!</>,
86
87
  },
87
88
  {
88
89
  multiEdit: true,
@@ -94,6 +95,18 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
94
95
  },
95
96
  },
96
97
  ),
98
+ GridCell({
99
+ headerName: "Custom edit",
100
+ maxWidth: 100,
101
+ editable: true,
102
+ valueFormatter: () => "Double click me!",
103
+ cellRendererParams: {
104
+ editableIcon: <GridIcon icon={"ic_launch_modal"} title={"Title text"} className={"GridCell-editableIcon"} />,
105
+ editAction: (selectedRows) => {
106
+ alert(`Custom edit ${selectedRows.length} row(s) selected`);
107
+ },
108
+ },
109
+ }),
97
110
  GridPopoverMenu(
98
111
  {},
99
112
  {
@@ -155,7 +168,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
155
168
  ),
156
169
  GridPopoverMenu(
157
170
  {
158
- editable: false,
171
+ editable: () => false,
159
172
  },
160
173
  {
161
174
  editorParams: {
@@ -35,19 +35,31 @@
35
35
  padding: 4px 8px;
36
36
  }
37
37
 
38
+ .GridCell-editableIcon {
39
+ fill: colors.$silver;
40
+ }
41
+
38
42
  .GridFormMessage-container {
39
43
  padding: 4px 8px;
40
44
  max-width: 400px;
41
45
  }
42
46
 
43
- .ag-cell:not(.ag-cell-focus) .Grid-displayWhenCellFocused {
47
+ .GridCell-readonly {
48
+ color: colors.$gray;
49
+ }
50
+
51
+ .Grid-container.ag-theme-alpine .ag-cell {
52
+ font-weight: 400;
53
+ }
54
+
55
+ .Grid-container.ag-theme-alpine .ag-cell:not(.ag-cell-focus) .Grid-displayWhenCellFocused {
44
56
  visibility: hidden;
45
57
  }
46
58
 
47
- .ag-cell:hover .Grid-displayWhenCellFocused {
59
+ .Grid-container.ag-theme-alpine .ag-cell:hover .Grid-displayWhenCellFocused {
48
60
  visibility: inherit;
49
61
  }
50
62
 
51
- .ag-cell-wrapper {
63
+ .Grid-container.ag-theme-alpine .ag-cell-wrapper {
52
64
  width: 100%;
53
- }
65
+ }
@@ -1,15 +1,19 @@
1
- @use "../../node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars" as colors;
2
-
3
- .AgGridGenericCellRenderer-icon {
4
- margin-right: 4px;
5
- }
6
-
7
- .AgGridGenericCellRenderer-ic_infoIcon {
8
- margin-right: 4px;
9
- fill: colors.$info;
10
- }
11
-
12
- .AgGridGenericCellRenderer-ic_warningIcon {
13
- margin-right: 4px;
14
- fill: colors.$warning;
15
- }
1
+ @use "../../node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars" as colors;
2
+
3
+ .AgGridGenericCellRenderer-icon {
4
+ margin-right: 4px;
5
+ }
6
+
7
+ .AgGridGenericCellRenderer-ic_infoIcon {
8
+ margin-right: 4px;
9
+ fill: colors.$info;
10
+ }
11
+
12
+ .AgGridGenericCellRenderer-ic_warningIcon {
13
+ margin-right: 4px;
14
+ fill: colors.$warning;
15
+ }
16
+
17
+ .GridIcon-disabled {
18
+ fill: colors.$silver !important;
19
+ }
@@ -1,4 +1,5 @@
1
- .GridLoadableCell-container {
2
- display: flex;
3
- align-items: center;
4
- }
1
+ .GridLoadableCell-container {
2
+ width: 100%;
3
+ display: flex;
4
+ align-items: center;
5
+ }
@@ -1,4 +1,4 @@
1
- @use "../../../node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars" as colors;
1
+ @use "../../node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars" as colors;
2
2
 
3
3
  .GridPopoutMenu-burger {
4
4
  cursor: pointer;
@@ -23,13 +23,15 @@
23
23
  header-background-color: lui.$white,
24
24
  border-color: lui.$lily,
25
25
  secondary-border-color: lui.$lily,
26
+ cell-horizontal-border: solid ag-derived(secondary-border-color),
27
+ cell-horizontal-padding: 12,
26
28
  row-hover-color: lui.$lily,
27
29
  font-family: (
28
30
  "Open Sans",
29
31
  system-ui,
30
32
  sans-serif,
31
33
  ),
32
- font-size: 0.875rem !important,
34
+ font-size: 1rem !important,
33
35
  borders: false,
34
36
  borders-critical: true,
35
37
  borders-secondary: false,
@@ -47,7 +49,7 @@
47
49
  }
48
50
 
49
51
  .ag-row:last-of-type {
50
- border-bottom: none;
52
+ border-bottom: 1px solid lui.$lily;
51
53
  }
52
54
 
53
55
  // ag-grid-community 27.x.x needs this vs 28 using the selected-row-background-color above
@@ -58,7 +60,7 @@
58
60
 
59
61
  .ag-header-cell {
60
62
  font-weight: 600;
61
- padding: 7px 0 7px 8px;
63
+ padding: 7px 11px;
62
64
 
63
65
  .LuiIcon {
64
66
  fill: lui.$surfie;
@@ -66,16 +68,16 @@
66
68
  }
67
69
 
68
70
  .ag-cell {
69
- padding-left: 7px;
70
- padding-right: 4px;
71
+ padding-left: 11px;
72
+ padding-right: 11px;
71
73
  display: flex;
72
74
  align-items: center;
73
75
  }
74
76
 
75
- .ag-cell-more {
76
- padding: 0;
77
- display: flex;
78
- justify-content: center;
77
+ .ag-cell.ag-cell-inline-editing {
78
+ padding-left: 9px;
79
+ padding-right: 9px;
80
+ bottom: 0;
79
81
  }
80
82
 
81
83
  .ag-cell-wrap-text {
@@ -1,2 +1,10 @@
1
1
  @use "./lui-overrides";
2
+ @use "./react-menu-customisations";
2
3
  @use "./Grid";
4
+ @use "./GridFormDropDown";
5
+ @use "./GridFormEditBearing";
6
+ @use "./GridFormMultiSelect";
7
+ @use "./GridFormSubComponentTextInput";
8
+ @use "./GridIcon";
9
+ @use "./GridLoadableCell";
10
+ @use "./GridPopoverMenu";
@@ -0,0 +1,34 @@
1
+ import { useRef } from "react";
2
+
3
+ export const useDeferredPromise = <T>() => {
4
+ const promiseResolve = useRef<((value: T | PromiseLike<T>) => void) | undefined>();
5
+ const promiseReject = useRef<() => void>();
6
+
7
+ return {
8
+ invoke: () =>
9
+ new Promise<T>((resolve, reject) => {
10
+ promiseResolve.current = resolve;
11
+ promiseReject.current = reject;
12
+ }),
13
+ resolve: (value: T) => {
14
+ if (!promiseResolve.current) {
15
+ console.error("Promise not invoked so can't resolve");
16
+ return;
17
+ }
18
+ const temp = promiseResolve.current;
19
+ promiseResolve.current = undefined;
20
+ promiseReject.current = undefined;
21
+ temp(value);
22
+ },
23
+ reject: () => {
24
+ if (!promiseResolve.current) {
25
+ console.error("Promise not invoked so can't reject");
26
+ return;
27
+ }
28
+ const reject = promiseReject.current;
29
+ promiseResolve.current = undefined;
30
+ promiseReject.current = undefined;
31
+ if (reject) reject();
32
+ },
33
+ };
34
+ };
package/src/utils/util.ts CHANGED
@@ -34,3 +34,5 @@ export const hasParentClass = function (className: string, child: Node) {
34
34
 
35
35
  export const stringByteLengthIsInvalid = (str: string, maxBytes: number) =>
36
36
  new TextEncoder().encode(str).length > maxBytes;
37
+
38
+ export const fnOrVar = (fn: any, param: any) => (typeof fn === "function" ? fn(param) : fn);