@linzjs/step-ag-grid 7.19.6 → 8.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 (39) hide show
  1. package/dist/index.css +4 -0
  2. package/dist/src/components/Grid.d.ts +2 -1
  3. package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -0
  4. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +5 -1
  5. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +8 -2
  6. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +11 -6
  7. package/dist/src/components/gridForm/GridFormTextArea.d.ts +4 -1
  8. package/dist/src/components/gridForm/GridFormTextInput.d.ts +4 -1
  9. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +10 -1
  10. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
  11. package/dist/src/lui/ActionButton.d.ts +2 -1
  12. package/dist/src/utils/bearing.d.ts +2 -3
  13. package/dist/step-ag-grid.esm.js +135 -98
  14. package/dist/step-ag-grid.esm.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/components/Grid.tsx +3 -3
  17. package/src/components/gridForm/GridFormDropDown.tsx +86 -71
  18. package/src/components/gridForm/GridFormEditBearing.tsx +9 -4
  19. package/src/components/gridForm/GridFormMultiSelect.tsx +7 -7
  20. package/src/components/gridForm/GridFormPopoverMenu.tsx +62 -53
  21. package/src/components/gridForm/GridFormTextArea.tsx +2 -2
  22. package/src/components/gridForm/GridFormTextInput.tsx +2 -2
  23. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +40 -32
  24. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +3 -3
  25. package/src/lui/ActionButton.tsx +3 -1
  26. package/src/react-menu3/components/ControlledMenu.tsx +5 -1
  27. package/src/react-menu3/styles/index.scss +4 -0
  28. package/src/stories/components/ActionButton.stories.tsx +11 -0
  29. package/src/stories/grid/GridNonEditableRow.stories.tsx +6 -6
  30. package/src/stories/grid/GridPopoutBearing.stories.tsx +1 -1
  31. package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +5 -5
  32. package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +3 -3
  33. package/src/stories/grid/GridReadOnly.stories.tsx +6 -6
  34. package/src/stories/grid/gridForm/GridFormDropDown.stories.tsx +109 -0
  35. package/src/stories/grid/gridForm/GridFormEditBearing.stories.tsx +54 -0
  36. package/src/stories/grid/gridForm/GridFormEditBearingCorrection.stories.tsx +54 -0
  37. package/src/stories/grid/gridForm/GridFormMessage.stories.tsx +32 -0
  38. package/src/stories/grid/gridForm/GridFormPopoverMenu.stories.tsx +55 -0
  39. package/src/utils/bearing.ts +10 -12
@@ -21,6 +21,7 @@ export interface ActionButtonProps {
21
21
  onClick: () => Promise<void> | void;
22
22
  level?: LuiButtonProps["level"];
23
23
  style?: CSSProperties;
24
+ disabled?: boolean;
24
25
  }
25
26
 
26
27
  // Kept this less than one second, so I don't have issues with waitFor as it defaults to 1s
@@ -30,6 +31,7 @@ export const ActionButton = ({
30
31
  icon,
31
32
  name,
32
33
  inProgressName,
34
+ disabled,
33
35
  dataTestId,
34
36
  style,
35
37
  className,
@@ -83,7 +85,7 @@ export const ActionButton = ({
83
85
  setInProgress(false);
84
86
  }
85
87
  }}
86
- disabled={localInProgress}
88
+ disabled={localInProgress || disabled}
87
89
  >
88
90
  {iconPosition === "right" && buttonText}
89
91
  {localInProgress ? (
@@ -346,7 +346,11 @@ export const ControlledMenuFr = (
346
346
  );
347
347
 
348
348
  if (portal === true && anchorRef?.current != null) {
349
- portal = { target: anchorRef.current.ownerDocument.body } as PortalFieldType;
349
+ if (hasParentClass("react-menu-inline-test", anchorRef.current)) {
350
+ portal = false;
351
+ } else {
352
+ portal = { target: anchorRef.current.ownerDocument.body } as PortalFieldType;
353
+ }
350
354
  }
351
355
 
352
356
  if (portal) {
@@ -71,3 +71,7 @@
71
71
  text-transform: uppercase;
72
72
  }
73
73
  }
74
+
75
+ .react-menu-inline-test .szh-menu-container, .react-menu-inline-test .szh-menu {
76
+ position: static !important;
77
+ }
@@ -39,6 +39,17 @@ const ActionButtonTemplate: ComponentStory<typeof ActionButton> = () => {
39
39
  className={"ActionButton-fill"}
40
40
  style={{ maxWidth: 160 }}
41
41
  />
42
+ <br />
43
+ <ActionButton
44
+ icon={"ic_arrow_forward_right"}
45
+ name={"Disabled"}
46
+ onClick={performAction}
47
+ iconPosition={"right"}
48
+ level={"secondary"}
49
+ className={"ActionButton-fill"}
50
+ style={{ maxWidth: 160 }}
51
+ disabled={true}
52
+ />
42
53
  </>
43
54
  );
44
55
  };
@@ -100,7 +100,7 @@ const GridNonEditableRowTemplate: ComponentStory<typeof Grid> = (props: GridProp
100
100
  return [
101
101
  {
102
102
  label: "Single edit only",
103
- action: async (selectedRows) => {
103
+ action: async ({ selectedRows }) => {
104
104
  alert(`Single-edit: ${selectedRows.map((r) => r.id)} rowId(s) selected`);
105
105
  await wait(1500);
106
106
  },
@@ -108,7 +108,7 @@ const GridNonEditableRowTemplate: ComponentStory<typeof Grid> = (props: GridProp
108
108
  },
109
109
  {
110
110
  label: "Multi-edit",
111
- action: async (selectedRows) => {
111
+ action: async ({ selectedRows }) => {
112
112
  alert(`Multi-edit: ${selectedRows.map((r) => r.id)} rowId(s) selected`);
113
113
  await wait(1500);
114
114
  },
@@ -123,9 +123,9 @@ const GridNonEditableRowTemplate: ComponentStory<typeof Grid> = (props: GridProp
123
123
  },
124
124
  {
125
125
  label: "Other (TextInput)",
126
- action: async (_, menuOptionResult) => {
126
+ action: async ({ menuOption }) => {
127
127
  // eslint-disable-next-line no-console
128
- console.log(`Sub selected value was ${JSON.stringify(menuOptionResult.subValue)}`);
128
+ console.log(`Sub selected value was ${JSON.stringify(menuOption.subValue)}`);
129
129
  await wait(500);
130
130
  },
131
131
  subComponent: () => (
@@ -134,9 +134,9 @@ const GridNonEditableRowTemplate: ComponentStory<typeof Grid> = (props: GridProp
134
134
  },
135
135
  {
136
136
  label: "Other (TextArea)",
137
- action: async (_, menuOptionResult) => {
137
+ action: async ({ menuOption }) => {
138
138
  // eslint-disable-next-line no-console
139
- console.log(`Sub selected value was ${JSON.stringify(menuOptionResult.subValue)}`);
139
+ console.log(`Sub selected value was ${JSON.stringify(menuOption.subValue)}`);
140
140
  await wait(500);
141
141
  },
142
142
  subComponent: () => (
@@ -72,7 +72,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
72
72
  },
73
73
  {
74
74
  editorParams: {
75
- onSave: async (selectedRows, value: ITestRow["bearing"]) => {
75
+ onSave: async ({ selectedRows, value }) => {
76
76
  await wait(1000);
77
77
  selectedRows.forEach((row) => (row["bearing"] = value));
78
78
  return true;
@@ -72,7 +72,7 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
72
72
  if (value === "never") return "The value 'never' is not allowed";
73
73
  return null;
74
74
  },
75
- onSave: async (selectedRows, value) => {
75
+ onSave: async ({ selectedRows, value }) => {
76
76
  await wait(1000);
77
77
  selectedRows.forEach((selectedRow) => (selectedRow["name"] = value));
78
78
  return true;
@@ -87,7 +87,7 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
87
87
  maxWidth: 140,
88
88
  valueFormatter: (params) => {
89
89
  const v = params.data.distance;
90
- return v != null ? `${v}${params.colDef.cellEditorParams.units}` : v;
90
+ return v != null ? `${v}${params.colDef.cellEditorParams.units}` : "–";
91
91
  },
92
92
  },
93
93
  {
@@ -100,7 +100,7 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
100
100
  if (value.length && !isFloat(value)) return "Value must be a number";
101
101
  return null;
102
102
  },
103
- onSave: async (selectedRows, value) => {
103
+ onSave: async ({ selectedRows, value }) => {
104
104
  await wait(1000);
105
105
  selectedRows.forEach(
106
106
  (selectedRow) => (selectedRow["distance"] = value.length ? parseFloat(value) : null),
@@ -126,7 +126,7 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
126
126
  if (value === "never") return "The value 'never' is not allowed";
127
127
  return null;
128
128
  },
129
- onSave: async (selectedRows, value) => {
129
+ onSave: async ({ selectedRows, value }) => {
130
130
  await wait(1000);
131
131
  selectedRows.forEach((selectedRow) => (selectedRow["plan"] = value));
132
132
  return true;
@@ -170,7 +170,7 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
170
170
  options: async (_) => [
171
171
  {
172
172
  label: "Delete",
173
- action: async (selectedRows) => {
173
+ action: async ({ selectedRows }) => {
174
174
  await wait(1500);
175
175
  setRowData(rowData.filter((data) => !selectedRows.some((row) => row.id == data.id)));
176
176
  },
@@ -96,7 +96,7 @@ const GridEditMultiSelectTemplate: ComponentStory<typeof Grid> = (props: GridPro
96
96
  subComponent: () => <GridFormSubComponentTextArea required={true} maxLength={5} defaultValue={""} />,
97
97
  },
98
98
  ],
99
- onSave: async (selectedRows, selectedOptions) => {
99
+ onSave: async ({ selectedRows, selectedOptions }) => {
100
100
  // eslint-disable-next-line no-console
101
101
  console.log("multiSelect result", { selectedRows, selectedOptions });
102
102
 
@@ -129,7 +129,7 @@ const GridEditMultiSelectTemplate: ComponentStory<typeof Grid> = (props: GridPro
129
129
  isEmpty(filter) || options.find((o) => o.label && o.label.toLowerCase() === filter.toLowerCase())
130
130
  ? undefined
131
131
  : "Press enter to add free text",
132
- onSelectFilter: async (filter, options) => {
132
+ onSelectFilter: async ({ filter, options }) => {
133
133
  if (isEmpty(filter) || options.find((o) => o.label && o.label.toLowerCase() === filter.toLowerCase()))
134
134
  return;
135
135
  options.push({ value: filter, label: filter, filter: "freeText", checked: true });
@@ -159,7 +159,7 @@ const GridEditMultiSelectTemplate: ComponentStory<typeof Grid> = (props: GridPro
159
159
  );
160
160
  return r;
161
161
  },
162
- onSave: async (selectedRows, selectedOptions) => {
162
+ onSave: async ({ selectedRows, selectedOptions }) => {
163
163
  // eslint-disable-next-line no-console
164
164
  console.log("multiSelect result", { selectedRows, selectedOptions });
165
165
 
@@ -126,7 +126,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
126
126
  return [
127
127
  {
128
128
  label: "Single edit only",
129
- action: async (selectedRows) => {
129
+ action: async ({ selectedRows }) => {
130
130
  alert(`Single-edit: ${selectedRows.map((r) => r.id)} rowId(s) selected`);
131
131
  await wait(1500);
132
132
  },
@@ -134,7 +134,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
134
134
  },
135
135
  {
136
136
  label: "Multi-edit",
137
- action: async (selectedRows) => {
137
+ action: async ({ selectedRows }) => {
138
138
  alert(`Multi-edit: ${selectedRows.map((r) => r.id)} rowId(s) selected`);
139
139
  await wait(1500);
140
140
  },
@@ -149,9 +149,9 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
149
149
  },
150
150
  {
151
151
  label: "Other (TextInput)",
152
- action: async (_, menuOptionResult) => {
152
+ action: async ({ menuOption }) => {
153
153
  // eslint-disable-next-line no-console
154
- console.log(`Sub selected value was ${JSON.stringify(menuOptionResult.subValue)}`);
154
+ console.log(`Sub selected value was ${JSON.stringify(menuOption.subValue)}`);
155
155
  await wait(500);
156
156
  },
157
157
  subComponent: () => (
@@ -160,9 +160,9 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
160
160
  },
161
161
  {
162
162
  label: "Other (TextArea)",
163
- action: async (_, menuOptionResult) => {
163
+ action: async ({ menuOption }) => {
164
164
  // eslint-disable-next-line no-console
165
- console.log(`Sub selected value was ${JSON.stringify(menuOptionResult.subValue)}`);
165
+ console.log(`Sub selected value was ${JSON.stringify(menuOption.subValue)}`);
166
166
  await wait(500);
167
167
  },
168
168
  subComponent: () => (
@@ -0,0 +1,109 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+ import "@linzjs/lui/dist/fonts";
3
+
4
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
5
+ import {
6
+ GridFormDropDown,
7
+ GridFormPopoutDropDownProps,
8
+ MenuHeaderItem,
9
+ } from "../../../components/gridForm/GridFormDropDown";
10
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
11
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
12
+ import { useRef } from "react";
13
+ import { GridBaseRow } from "../../../components/Grid";
14
+
15
+ export default {
16
+ title: "GridForm / Testing",
17
+ component: GridFormDropDown,
18
+ args: {},
19
+ } as ComponentMeta<typeof GridFormDropDown>;
20
+
21
+ const Template: ComponentStory<typeof GridFormDropDown> = (props) => {
22
+ const configs: [string, GridFormPopoutDropDownProps<GridBaseRow>, string?][] = [
23
+ ["No options", { options: [] }],
24
+ ["Custom no options", { options: [], noOptionsMessage: "Custom no options" }],
25
+ [
26
+ "Enabled and disabled",
27
+ {
28
+ options: [
29
+ { label: "Enabled", value: 1 },
30
+ { label: "Disabled", value: 0, disabled: true },
31
+ ],
32
+ },
33
+ ],
34
+ [
35
+ "Headers",
36
+ {
37
+ options: [
38
+ MenuHeaderItem("Header 1"),
39
+ { label: "Option 1", value: 1 },
40
+ MenuHeaderItem("Header 2"),
41
+ { label: "Option 2", value: 2 },
42
+ ],
43
+ },
44
+ ],
45
+ [
46
+ "Filter",
47
+ {
48
+ filtered: "local",
49
+ options: [
50
+ MenuHeaderItem("Header 1"),
51
+ { label: "Option 1", value: 1 },
52
+ MenuHeaderItem("Header 2"),
53
+ { label: "Option 2", value: 2 },
54
+ ],
55
+ },
56
+ ],
57
+ [
58
+ "Filter custom placeholder",
59
+ {
60
+ filtered: "local",
61
+ filterPlaceholder: "Custom placeholder",
62
+ filterHelpText: "Filter help text",
63
+ options: [MenuHeaderItem("Header 1"), { label: "Option 1", value: 1 }],
64
+ },
65
+ ],
66
+ [
67
+ "Filter help text and default filter text",
68
+ {
69
+ filtered: "local",
70
+ filterHelpText: "Filter help text",
71
+ filterDefaultValue: "filter",
72
+ options: [
73
+ MenuHeaderItem("Header 1"),
74
+ { label: "Filter match", value: 1 },
75
+ MenuHeaderItem("ERROR! this header should not be visible"),
76
+ { label: "ERROR! this option should not be visible", value: 2 },
77
+ ],
78
+ },
79
+ ],
80
+ ];
81
+ // eslint-disable-next-line react-hooks/rules-of-hooks
82
+ const anchorRefs = configs.map(() => useRef<HTMLHeadingElement>(null));
83
+
84
+ return (
85
+ <div className={"react-menu-inline-test"}>
86
+ <GridContextProvider>
87
+ {configs.map((config, index) => (
88
+ <div key={`${index}`}>
89
+ <h6 ref={anchorRefs[index]}>{config[0]}</h6>
90
+ <GridPopoverContext.Provider
91
+ value={
92
+ {
93
+ anchorRef: anchorRefs[index],
94
+ data: { value: config[2] },
95
+ value: config[2],
96
+ field: "value",
97
+ } as any as GridPopoverContextType<any>
98
+ }
99
+ >
100
+ <GridFormDropDown {...props} {...config[1]} />
101
+ </GridPopoverContext.Provider>
102
+ </div>
103
+ ))}
104
+ </GridContextProvider>
105
+ </div>
106
+ );
107
+ };
108
+
109
+ export const GridFormDropDown_ = Template.bind({});
@@ -0,0 +1,54 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+ import "@linzjs/lui/dist/fonts";
3
+
4
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
5
+ import { GridFormEditBearing } from "../../../components/gridForm/GridFormEditBearing";
6
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
7
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
8
+ import { useRef } from "react";
9
+ import { GridPopoverEditBearingEditorParams } from "../../../components/gridPopoverEdit/GridPopoverEditBearing";
10
+
11
+ export default {
12
+ title: "GridForm / Testing",
13
+ component: GridFormEditBearing,
14
+ args: {},
15
+ } as ComponentMeta<typeof GridFormEditBearing>;
16
+
17
+ const Template: ComponentStory<typeof GridFormEditBearing> = (props) => {
18
+ const values = [
19
+ ["Null value", null],
20
+ ["Minimum value", 0],
21
+ ["Maximum value", 359.59599],
22
+ ["5dp value", 1.23456],
23
+ ["Invalid 6dp value", 1.234567],
24
+ ["Invalid exceeds max value", 360],
25
+ ["Invalid exceeds min value", -0.00001],
26
+ ];
27
+ // eslint-disable-next-line react-hooks/rules-of-hooks
28
+ const anchorRefs = values.map(() => useRef<HTMLHeadingElement>(null));
29
+
30
+ return (
31
+ <div className={"react-menu-inline-test"}>
32
+ <GridContextProvider>
33
+ {values.map((value, index) => (
34
+ <>
35
+ <h6 ref={anchorRefs[index]}>{value[0]}</h6>
36
+ <GridPopoverContext.Provider
37
+ value={
38
+ {
39
+ anchorRef: anchorRefs[index],
40
+ value: value[1],
41
+ } as any as GridPopoverContextType<any>
42
+ }
43
+ >
44
+ <GridFormEditBearing {...props} {...GridPopoverEditBearingEditorParams} />
45
+ </GridPopoverContext.Provider>
46
+ </>
47
+ ))}
48
+ </GridContextProvider>
49
+ </div>
50
+ );
51
+ };
52
+
53
+ export const GridFormEditBearing_ = Template.bind({});
54
+ GridFormEditBearing_.args = {};
@@ -0,0 +1,54 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+ import "@linzjs/lui/dist/fonts";
3
+
4
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
5
+ import { GridFormEditBearing } from "../../../components/gridForm/GridFormEditBearing";
6
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
7
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
8
+ import { useRef } from "react";
9
+ import { GridPopoverEditBearingCorrectionEditorParams } from "../../../components/gridPopoverEdit/GridPopoverEditBearing";
10
+
11
+ export default {
12
+ title: "GridForm / Testing",
13
+ component: GridFormEditBearing,
14
+ args: {},
15
+ } as ComponentMeta<typeof GridFormEditBearing>;
16
+
17
+ const Template: ComponentStory<typeof GridFormEditBearing> = (props) => {
18
+ const values = [
19
+ ["Null value", null],
20
+ ["Minimum value", -179.59599],
21
+ ["Maximum value", 359.59599],
22
+ ["5dp value", 1.23456],
23
+ ["Invalid 6dp value", 1.234567],
24
+ ["Invalid exceeds max value", 360],
25
+ ["Invalid exceeds min value", -180],
26
+ ];
27
+ // eslint-disable-next-line react-hooks/rules-of-hooks
28
+ const anchorRefs = values.map(() => useRef<HTMLHeadingElement>(null));
29
+
30
+ return (
31
+ <div className={"react-menu-inline-test"}>
32
+ <GridContextProvider>
33
+ {values.map((value, index) => (
34
+ <>
35
+ <h6 ref={anchorRefs[index]}>{value[0]}</h6>
36
+ <GridPopoverContext.Provider
37
+ value={
38
+ {
39
+ anchorRef: anchorRefs[index],
40
+ value: value[1],
41
+ } as any as GridPopoverContextType<any>
42
+ }
43
+ >
44
+ <GridFormEditBearing {...props} {...GridPopoverEditBearingCorrectionEditorParams} />
45
+ </GridPopoverContext.Provider>
46
+ </>
47
+ ))}
48
+ </GridContextProvider>
49
+ </div>
50
+ );
51
+ };
52
+
53
+ export const GridFormEditBearingCorrection_ = Template.bind({});
54
+ GridFormEditBearingCorrection_.args = {};
@@ -0,0 +1,32 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+ import "@linzjs/lui/dist/fonts";
3
+
4
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
5
+ import { GridFormMessage } from "../../../components/gridForm/GridFormMessage";
6
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
7
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
8
+ import { useRef } from "react";
9
+
10
+ export default {
11
+ title: "GridForm / Testing",
12
+ component: GridFormMessage,
13
+ args: {},
14
+ } as ComponentMeta<typeof GridFormMessage>;
15
+
16
+ const Template: ComponentStory<typeof GridFormMessage> = (props) => {
17
+ const anchorRef1 = useRef<HTMLHeadingElement>(null);
18
+
19
+ return (
20
+ <div className={"react-menu-inline-test"}>
21
+ <GridContextProvider>
22
+ <h6 ref={anchorRef1}>Standard Message</h6>
23
+ <GridPopoverContext.Provider value={{ anchorRef: anchorRef1 } as any as GridPopoverContextType<any>}>
24
+ <GridFormMessage {...props} message={() => <span>This is a message</span>} />
25
+ </GridPopoverContext.Provider>
26
+ </GridContextProvider>
27
+ </div>
28
+ );
29
+ };
30
+
31
+ export const GridFormMessage_ = Template.bind({});
32
+ GridFormMessage_.args = {};
@@ -0,0 +1,55 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+ import "@linzjs/lui/dist/fonts";
3
+
4
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
5
+ import { useRef } from "react";
6
+ import {
7
+ GridFormPopoverMenu,
8
+ GridFormPopoverMenuProps,
9
+ PopoutMenuSeparator,
10
+ } from "../../../components/gridForm/GridFormPopoverMenu";
11
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
12
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
13
+ import { GridBaseRow } from "../../../components/Grid";
14
+
15
+ export default {
16
+ title: "GridForm / Testing",
17
+ component: GridFormPopoverMenu,
18
+ args: {},
19
+ } as ComponentMeta<typeof GridFormPopoverMenu>;
20
+
21
+ const Template: ComponentStory<typeof GridFormPopoverMenu> = (props) => {
22
+ const configs: [string, GridFormPopoverMenuProps<GridBaseRow>][] = [
23
+ ["No options", { options: async () => [] }],
24
+ [
25
+ "Enabled/disabled/hidden and divider",
26
+ {
27
+ options: async () => [
28
+ { label: "Enabled", value: 1 },
29
+ PopoutMenuSeparator,
30
+ { label: "Disabled", value: 0, disabled: true },
31
+ { label: "ERROR! this should be hidden", value: 3, hidden: true },
32
+ ],
33
+ },
34
+ ],
35
+ ];
36
+ // eslint-disable-next-line react-hooks/rules-of-hooks
37
+ const anchorRefs = configs.map(() => useRef<HTMLHeadingElement>(null));
38
+
39
+ return (
40
+ <div className={"react-menu-inline-test"}>
41
+ <GridContextProvider>
42
+ {configs.map((config, index) => (
43
+ <>
44
+ <h6 ref={anchorRefs[index]}>{config[0]}</h6>
45
+ <GridPopoverContext.Provider value={{ anchorRef: anchorRefs[index] } as any as GridPopoverContextType<any>}>
46
+ <GridFormPopoverMenu {...props} {...config[1]} />
47
+ </GridPopoverContext.Provider>
48
+ </>
49
+ ))}
50
+ </GridContextProvider>
51
+ </div>
52
+ );
53
+ };
54
+
55
+ export const GridFormPopoverMenu_ = Template.bind({});
@@ -1,22 +1,20 @@
1
- import { ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef";
2
-
3
- export const bearingValueFormatter = (params: ValueFormatterParams): string => {
4
- const value = typeof params.value == "string" ? parseFloat(params.value) : params.value;
5
- if (value == null) {
1
+ export const bearingValueFormatter = (value: any): string => {
2
+ const safeValue = typeof value == "string" ? parseFloat(value) : value;
3
+ if (safeValue == null) {
6
4
  return "–";
7
5
  }
8
- return convertDDToDMS(value, false, false);
6
+ return convertDDToDMS(safeValue, false, false);
9
7
  };
10
8
 
11
- export const bearingCorrectionValueFormatter = (params: ValueFormatterParams): string => {
12
- const value = params.value;
13
- if (value == null) {
9
+ export const bearingCorrectionValueFormatter = (value: any): string => {
10
+ const safeValue = value;
11
+ if (safeValue == null) {
14
12
  return "–";
15
13
  }
16
- if (typeof value === "string") {
17
- return convertDDToDMS(bearingNumberParser(value), true, true);
14
+ if (typeof safeValue === "string") {
15
+ return convertDDToDMS(bearingNumberParser(safeValue), true, true);
18
16
  }
19
- return convertDDToDMS(value, true, true);
17
+ return convertDDToDMS(safeValue, true, true);
20
18
  };
21
19
 
22
20
  export const bearingNumberParser = (value: string): number | null => {