@linzjs/step-ag-grid 8.0.0 → 8.2.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 +23 -5
  2. package/dist/src/components/gridForm/GridFormDropDown.d.ts +3 -2
  3. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -0
  4. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +3 -4
  5. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +2 -2
  6. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
  7. package/dist/src/lui/ActionButton.d.ts +2 -1
  8. package/dist/src/utils/bearing.d.ts +2 -0
  9. package/dist/step-ag-grid.esm.js +107 -87
  10. package/dist/step-ag-grid.esm.js.map +1 -1
  11. package/package.json +1 -1
  12. package/src/components/GridCell.tsx +2 -2
  13. package/src/components/gridForm/GridFormDropDown.tsx +94 -75
  14. package/src/components/gridForm/GridFormEditBearing.tsx +1 -1
  15. package/src/components/gridForm/GridFormMultiSelect.tsx +10 -8
  16. package/src/components/gridForm/GridFormPopoverMenu.tsx +53 -46
  17. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +8 -13
  18. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +3 -3
  19. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +3 -3
  20. package/src/lui/ActionButton.tsx +3 -1
  21. package/src/react-menu3/styles/_var.scss +1 -1
  22. package/src/react-menu3/styles/index.scss +4 -0
  23. package/src/stories/components/ActionButton.stories.tsx +11 -0
  24. package/src/stories/grid/gridForm/GridFormDropDown.stories.tsx +81 -36
  25. package/src/stories/grid/gridForm/GridFormEditBearing.stories.tsx +9 -15
  26. package/src/stories/grid/gridForm/GridFormEditBearingCorrection.stories.tsx +9 -15
  27. package/src/stories/grid/gridForm/GridFormMessage.stories.tsx +31 -0
  28. package/src/stories/grid/gridForm/GridFormMultiSelect.stories.tsx +70 -0
  29. package/src/stories/grid/gridForm/GridFormPopoverMenu.stories.tsx +55 -0
  30. package/src/stories/grid/gridForm/GridFormTextArea.stories.tsx +44 -0
  31. package/src/stories/grid/gridForm/GridFormTextInput.stories.tsx +44 -0
  32. package/src/styles/Grid.scss +1 -1
  33. package/src/styles/GridFormMultiSelect.scss +4 -0
  34. package/src/styles/GridIcon.scss +10 -0
  35. package/src/styles/lui-overrides.scss +1 -1
  36. package/src/styles/react-menu-customisations.scss +2 -2
  37. package/src/utils/bearing.test.ts +46 -3
  38. package/src/utils/bearing.ts +14 -0
  39. package/src/stories/grid/gridForm/reactMenuTest.scss +0 -3
@@ -1,60 +1,105 @@
1
1
  import "@linzjs/lui/dist/scss/base.scss";
2
2
  import "@linzjs/lui/dist/fonts";
3
- // Force react-menu not to render static inline not absolute
4
- import "./reactMenuTest.scss";
5
3
 
6
4
  import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
7
- import { GridFormDropDown, MenuHeaderItem } from "../../../components/gridForm/GridFormDropDown";
5
+ import { GridFormDropDown, GridFormDropDownProps, MenuHeaderItem } from "../../../components/gridForm/GridFormDropDown";
8
6
  import { GridContextProvider } from "../../../contexts/GridContextProvider";
9
7
  import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
10
8
  import { useRef } from "react";
9
+ import { GridBaseRow } from "../../../components/Grid";
11
10
 
12
11
  export default {
13
- title: "GridForm / Samples",
12
+ title: "GridForm / Testing",
14
13
  component: GridFormDropDown,
15
14
  args: {},
16
15
  } as ComponentMeta<typeof GridFormDropDown>;
17
16
 
18
17
  const Template: ComponentStory<typeof GridFormDropDown> = (props) => {
19
- const anchorRef1 = useRef<HTMLHeadingElement>(null);
20
- const anchorRef2 = useRef<HTMLHeadingElement>(null);
21
- const anchorRef3 = useRef<HTMLHeadingElement>(null);
18
+ const configs: [string, GridFormDropDownProps<GridBaseRow>, string?][] = [
19
+ ["No options", { options: [] }],
20
+ ["Custom no options", { options: [], noOptionsMessage: "Custom no options" }],
21
+ [
22
+ "Enabled and disabled",
23
+ {
24
+ options: [
25
+ { label: "Enabled", value: 1 },
26
+ { label: "Disabled", value: 0, disabled: true },
27
+ ],
28
+ },
29
+ ],
30
+ [
31
+ "Headers",
32
+ {
33
+ options: [
34
+ MenuHeaderItem("Header 1"),
35
+ { label: "Option 1", value: 1 },
36
+ MenuHeaderItem("Header 2"),
37
+ { label: "Option 2", value: 2 },
38
+ ],
39
+ },
40
+ ],
41
+ [
42
+ "Filter",
43
+ {
44
+ filtered: "local",
45
+ options: [
46
+ MenuHeaderItem("Header 1"),
47
+ { label: "Option 1", value: 1 },
48
+ MenuHeaderItem("Header 2"),
49
+ { label: "Option 2", value: 2 },
50
+ ],
51
+ },
52
+ ],
53
+ [
54
+ "Filter custom placeholder",
55
+ {
56
+ filtered: "local",
57
+ filterPlaceholder: "Custom placeholder",
58
+ filterHelpText: "Filter help text",
59
+ options: [MenuHeaderItem("Header 1"), { label: "Option 1", value: 1 }],
60
+ },
61
+ ],
62
+ [
63
+ "Filter help text and default filter text",
64
+ {
65
+ filtered: "local",
66
+ filterHelpText: "Filter help text",
67
+ filterDefaultValue: "filter",
68
+ options: [
69
+ MenuHeaderItem("Header 1"),
70
+ { label: "Filter match", value: 1 },
71
+ MenuHeaderItem("ERROR! this header should not be visible"),
72
+ { label: "ERROR! this option should not be visible", value: 2 },
73
+ ],
74
+ },
75
+ ],
76
+ ];
77
+ // eslint-disable-next-line react-hooks/rules-of-hooks
78
+ const anchorRefs = configs.map(() => useRef<HTMLHeadingElement>(null));
22
79
 
23
80
  return (
24
81
  <div className={"react-menu-inline-test"}>
25
82
  <GridContextProvider>
26
- <h6 ref={anchorRef1}>No options</h6>
27
- <GridPopoverContext.Provider value={{ anchorRef: anchorRef1 } as any as GridPopoverContextType<any>}>
28
- <GridFormDropDown {...props} options={[]} />
29
- </GridPopoverContext.Provider>
30
-
31
- <h6 ref={anchorRef2}>Enabled and disabled</h6>
32
- <GridPopoverContext.Provider value={{ anchorRef: anchorRef2 } as any as GridPopoverContextType<any>}>
33
- <GridFormDropDown
34
- {...props}
35
- options={[
36
- { label: "Enabled", value: 1 },
37
- { label: "Disabled", value: 0, disabled: true },
38
- ]}
39
- />
40
- </GridPopoverContext.Provider>
41
-
42
- <h6 ref={anchorRef3}>Headers</h6>
43
- <GridPopoverContext.Provider value={{ anchorRef: anchorRef3 } as any as GridPopoverContextType<any>}>
44
- <GridFormDropDown
45
- {...props}
46
- options={[
47
- MenuHeaderItem("Header 1"),
48
- { label: "Option 1", value: 1 },
49
- MenuHeaderItem("Header 2"),
50
- { label: "Option 2", value: 2 },
51
- ]}
52
- />
53
- </GridPopoverContext.Provider>
83
+ {configs.map((config, index) => (
84
+ <div key={`${index}`}>
85
+ <h6 ref={anchorRefs[index]}>{config[0]}</h6>
86
+ <GridPopoverContext.Provider
87
+ value={
88
+ {
89
+ anchorRef: anchorRefs[index],
90
+ data: { value: config[2] },
91
+ value: config[2],
92
+ field: "value",
93
+ } as any as GridPopoverContextType<any>
94
+ }
95
+ >
96
+ <GridFormDropDown {...props} {...config[1]} />
97
+ </GridPopoverContext.Provider>
98
+ </div>
99
+ ))}
54
100
  </GridContextProvider>
55
101
  </div>
56
102
  );
57
103
  };
58
104
 
59
105
  export const GridFormDropDown_ = Template.bind({});
60
- GridFormDropDown_.args = { options: [] };
@@ -1,30 +1,25 @@
1
1
  import "@linzjs/lui/dist/scss/base.scss";
2
2
  import "@linzjs/lui/dist/fonts";
3
- // Force react-menu not to render static inline not absolute
4
- import "./reactMenuTest.scss";
5
3
 
6
4
  import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
7
- import { GridFormEditBearing } from "../../../components/gridForm/GridFormEditBearing";
5
+ import { GridFormEditBearing, GridFormEditBearingProps } from "../../../components/gridForm/GridFormEditBearing";
8
6
  import { GridContextProvider } from "../../../contexts/GridContextProvider";
9
7
  import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
10
8
  import { useRef } from "react";
11
9
  import { GridPopoverEditBearingEditorParams } from "../../../components/gridPopoverEdit/GridPopoverEditBearing";
12
10
 
13
11
  export default {
14
- title: "GridForm / Samples",
12
+ title: "GridForm / Testing",
15
13
  component: GridFormEditBearing,
16
14
  args: {},
17
15
  } as ComponentMeta<typeof GridFormEditBearing>;
18
16
 
19
17
  const Template: ComponentStory<typeof GridFormEditBearing> = (props) => {
20
- const values = [
21
- ["Null value", null],
22
- ["Minimum value", 0],
23
- ["Maximum value", 359.59599],
24
- ["5dp value", 1.23456],
25
- ["Invalid 6dp value", 1.234567],
26
- ["Invalid exceeds max value", 360],
27
- ["Invalid exceeds min value", -0.00001],
18
+ const values: [string, GridFormEditBearingProps<any>, number | null][] = [
19
+ ["Null value", {}, null],
20
+ ["Custom placeholder", { placeHolder: "Custom placeholder" }, null],
21
+ ["Valid value", {}, 90],
22
+ ["With error", {}, 1.234567],
28
23
  ];
29
24
  // eslint-disable-next-line react-hooks/rules-of-hooks
30
25
  const anchorRefs = values.map(() => useRef<HTMLHeadingElement>(null));
@@ -39,11 +34,11 @@ const Template: ComponentStory<typeof GridFormEditBearing> = (props) => {
39
34
  value={
40
35
  {
41
36
  anchorRef: anchorRefs[index],
42
- value: value[1],
37
+ value: value[2],
43
38
  } as any as GridPopoverContextType<any>
44
39
  }
45
40
  >
46
- <GridFormEditBearing {...props} {...GridPopoverEditBearingEditorParams} />
41
+ <GridFormEditBearing {...props} {...GridPopoverEditBearingEditorParams} {...value[1]} />
47
42
  </GridPopoverContext.Provider>
48
43
  </>
49
44
  ))}
@@ -53,4 +48,3 @@ const Template: ComponentStory<typeof GridFormEditBearing> = (props) => {
53
48
  };
54
49
 
55
50
  export const GridFormEditBearing_ = Template.bind({});
56
- GridFormEditBearing_.args = {};
@@ -1,30 +1,25 @@
1
1
  import "@linzjs/lui/dist/scss/base.scss";
2
2
  import "@linzjs/lui/dist/fonts";
3
- // Force react-menu not to render static inline not absolute
4
- import "./reactMenuTest.scss";
5
3
 
6
4
  import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
7
- import { GridFormEditBearing } from "../../../components/gridForm/GridFormEditBearing";
5
+ import { GridFormEditBearing, GridFormEditBearingProps } from "../../../components/gridForm/GridFormEditBearing";
8
6
  import { GridContextProvider } from "../../../contexts/GridContextProvider";
9
7
  import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
10
8
  import { useRef } from "react";
11
9
  import { GridPopoverEditBearingCorrectionEditorParams } from "../../../components/gridPopoverEdit/GridPopoverEditBearing";
12
10
 
13
11
  export default {
14
- title: "GridForm / Samples",
12
+ title: "GridForm / Testing",
15
13
  component: GridFormEditBearing,
16
14
  args: {},
17
15
  } as ComponentMeta<typeof GridFormEditBearing>;
18
16
 
19
17
  const Template: ComponentStory<typeof GridFormEditBearing> = (props) => {
20
- const values = [
21
- ["Null value", null],
22
- ["Minimum value", -179.59599],
23
- ["Maximum value", 359.59599],
24
- ["5dp value", 1.23456],
25
- ["Invalid 6dp value", 1.234567],
26
- ["Invalid exceeds max value", 360],
27
- ["Invalid exceeds min value", -180],
18
+ const values: [string, GridFormEditBearingProps<any>, number | null][] = [
19
+ ["Null value", {}, null],
20
+ ["Custom placeholder", { placeHolder: "Custom placeholder" }, null],
21
+ ["Valid value", {}, -10],
22
+ ["With error", {}, 360],
28
23
  ];
29
24
  // eslint-disable-next-line react-hooks/rules-of-hooks
30
25
  const anchorRefs = values.map(() => useRef<HTMLHeadingElement>(null));
@@ -39,11 +34,11 @@ const Template: ComponentStory<typeof GridFormEditBearing> = (props) => {
39
34
  value={
40
35
  {
41
36
  anchorRef: anchorRefs[index],
42
- value: value[1],
37
+ value: value[2],
43
38
  } as any as GridPopoverContextType<any>
44
39
  }
45
40
  >
46
- <GridFormEditBearing {...props} {...GridPopoverEditBearingCorrectionEditorParams} />
41
+ <GridFormEditBearing {...props} {...GridPopoverEditBearingCorrectionEditorParams} {...value[1]} />
47
42
  </GridPopoverContext.Provider>
48
43
  </>
49
44
  ))}
@@ -53,4 +48,3 @@ const Template: ComponentStory<typeof GridFormEditBearing> = (props) => {
53
48
  };
54
49
 
55
50
  export const GridFormEditBearingCorrection_ = Template.bind({});
56
- GridFormEditBearingCorrection_.args = {};
@@ -0,0 +1,31 @@
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({});
@@ -0,0 +1,70 @@
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 { GridFormMultiSelect, GridFormMultiSelectProps } from "../../../components/gridForm/GridFormMultiSelect";
6
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
7
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
8
+ import { useRef } from "react";
9
+ import { GridBaseRow } from "../../../components/Grid";
10
+
11
+ export default {
12
+ title: "GridForm / Testing",
13
+ component: GridFormMultiSelect,
14
+ args: {},
15
+ } as ComponentMeta<typeof GridFormMultiSelect>;
16
+
17
+ const Template: ComponentStory<typeof GridFormMultiSelect> = (props) => {
18
+ const configs: [string, GridFormMultiSelectProps<GridBaseRow>, string?][] = [
19
+ ["No options", { options: [] }],
20
+ ["Custom no options", { options: [], noOptionsMessage: "Custom no options" }],
21
+ [
22
+ "With options",
23
+ {
24
+ options: [
25
+ { label: "One", value: 0 },
26
+ { label: "Two", value: 1 },
27
+ ],
28
+ },
29
+ ],
30
+ [
31
+ "With filter",
32
+ {
33
+ filtered: true,
34
+ options: [
35
+ { label: "One", value: 0 },
36
+ { label: "With warning", value: 1, warning: "Test warning" },
37
+ { label: "Three", value: 2 },
38
+ ],
39
+ },
40
+ ],
41
+ ];
42
+ // eslint-disable-next-line react-hooks/rules-of-hooks
43
+ const anchorRefs = configs.map(() => useRef<HTMLHeadingElement>(null));
44
+
45
+ return (
46
+ <div className={"react-menu-inline-test"}>
47
+ <GridContextProvider>
48
+ {configs.map((config, index) => (
49
+ <div key={`${index}`}>
50
+ <h6 ref={anchorRefs[index]}>{config[0]}</h6>
51
+ <GridPopoverContext.Provider
52
+ value={
53
+ {
54
+ anchorRef: anchorRefs[index],
55
+ data: { value: config[2] },
56
+ value: config[2],
57
+ field: "value",
58
+ } as any as GridPopoverContextType<any>
59
+ }
60
+ >
61
+ <GridFormMultiSelect {...props} {...config[1]} />
62
+ </GridPopoverContext.Provider>
63
+ </div>
64
+ ))}
65
+ </GridContextProvider>
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export const GridFormMultiSelect_ = Template.bind({});
@@ -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({});
@@ -0,0 +1,44 @@
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 { GridFormTextArea, GridFormTextAreaProps } from "../../../components/gridForm/GridFormTextArea";
6
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
7
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
8
+ import { useRef } from "react";
9
+ import { GridBaseRow } from "../../../components/Grid";
10
+
11
+ export default {
12
+ title: "GridForm / Testing",
13
+ component: GridFormTextArea,
14
+ args: {},
15
+ } as ComponentMeta<typeof GridFormTextArea>;
16
+
17
+ const Template: ComponentStory<typeof GridFormTextArea> = (props) => {
18
+ const configs: [string, GridFormTextAreaProps<GridBaseRow>, string?][] = [
19
+ ["Text area", {}],
20
+ ["Text area with text", {}, "Some text"],
21
+ ["Text area with error & placeholder", { required: true, placeholder: "Custom placeholder" }],
22
+ ];
23
+ // eslint-disable-next-line react-hooks/rules-of-hooks
24
+ const anchorRefs = configs.map(() => useRef<HTMLHeadingElement>(null));
25
+
26
+ return (
27
+ <div className={"react-menu-inline-test"}>
28
+ <GridContextProvider>
29
+ {configs.map((config, index) => (
30
+ <>
31
+ <h6 ref={anchorRefs[index]}>{config[0]}</h6>
32
+ <GridPopoverContext.Provider
33
+ value={{ anchorRef: anchorRefs[index], value: config[2] } as any as GridPopoverContextType<any>}
34
+ >
35
+ <GridFormTextArea {...props} {...config[1]} />
36
+ </GridPopoverContext.Provider>
37
+ </>
38
+ ))}
39
+ </GridContextProvider>
40
+ </div>
41
+ );
42
+ };
43
+
44
+ export const GridFormTextArea_ = Template.bind({});
@@ -0,0 +1,44 @@
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 { GridFormTextInput, GridFormTextInputProps } from "../../../components/gridForm/GridFormTextInput";
6
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
7
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
8
+ import { useRef } from "react";
9
+ import { GridBaseRow } from "../../../components/Grid";
10
+
11
+ export default {
12
+ title: "GridForm / Testing",
13
+ component: GridFormTextInput,
14
+ args: {},
15
+ } as ComponentMeta<typeof GridFormTextInput>;
16
+
17
+ const Template: ComponentStory<typeof GridFormTextInput> = (props) => {
18
+ const configs: [string, GridFormTextInputProps<GridBaseRow>, string?][] = [
19
+ ["Text input", {}],
20
+ ["Text input with text", {}, "Some text"],
21
+ ["Text input with error & placeholder", { required: true, placeholder: "Custom placeholder" }],
22
+ ];
23
+ // eslint-disable-next-line react-hooks/rules-of-hooks
24
+ const anchorRefs = configs.map(() => useRef<HTMLHeadingElement>(null));
25
+
26
+ return (
27
+ <div className={"react-menu-inline-test"}>
28
+ <GridContextProvider>
29
+ {configs.map((config, index) => (
30
+ <>
31
+ <h6 ref={anchorRefs[index]}>{config[0]}</h6>
32
+ <GridPopoverContext.Provider
33
+ value={{ anchorRef: anchorRefs[index], value: config[2] } as any as GridPopoverContextType<any>}
34
+ >
35
+ <GridFormTextInput {...props} {...config[1]} />
36
+ </GridPopoverContext.Provider>
37
+ </>
38
+ ))}
39
+ </GridContextProvider>
40
+ </div>
41
+ );
42
+ };
43
+
44
+ export const GridFormTextInput_ = Template.bind({});
@@ -32,7 +32,7 @@
32
32
  }
33
33
 
34
34
  .Grid-popoverContainer {
35
- padding: 4px 8px;
35
+ padding: 0.375rem 0.75rem;
36
36
  }
37
37
 
38
38
  .ag-cell .GridCell-editableIcon {
@@ -16,3 +16,7 @@
16
16
  .GridMultiSelect-containerUnlimited .GridFormMultiSelect-options {
17
17
  overflow-y: auto;
18
18
  }
19
+
20
+ .GridMultiSelect-noOptions {
21
+ justify-content: center;
22
+ }
@@ -9,11 +9,21 @@
9
9
  fill: colors.$info;
10
10
  }
11
11
 
12
+ .AgGridGenericCellRenderer-ic_info_outlineIcon {
13
+ margin-right: 4px;
14
+ fill: colors.$info;
15
+ }
16
+
12
17
  .AgGridGenericCellRenderer-ic_warningIcon {
13
18
  margin-right: 4px;
14
19
  fill: colors.$warning;
15
20
  }
16
21
 
22
+ .AgGridGenericCellRenderer-ic_warning_outlineIcon {
23
+ margin-right: 4px;
24
+ fill: colors.$warning;
25
+ }
26
+
17
27
  .GridIcon-disabled {
18
28
  fill: colors.$silver !important;
19
29
  }
@@ -23,7 +23,7 @@
23
23
 
24
24
  .szh-menu__item,
25
25
  .szh-menu__header {
26
- padding: 0.375rem 1.5rem;
26
+ padding: 0.375rem 0.75rem;
27
27
  }
28
28
 
29
29
  .LuiCheckboxInput {
@@ -9,13 +9,13 @@
9
9
  .step-ag-grid-react-menu.szh-menu {
10
10
  z-index: 900;
11
11
  color: colors.$base-type-color;
12
- @include fonts.font-light();
12
+ @include fonts.font-regular();
13
13
 
14
14
  div,
15
15
  a[role="menuitem"] {
16
16
  text-decoration: none;
17
17
  color: colors.$base-type-color;
18
- @include fonts.font-light();
18
+ @include fonts.font-regular();
19
19
  }
20
20
 
21
21
  li[role="menuitem"]:hover {
@@ -1,7 +1,12 @@
1
- import { convertDDToDMS } from "./bearing";
1
+ import {
2
+ bearingCorrectionRangeValidator,
3
+ bearingRangeValidator,
4
+ bearingStringValidator,
5
+ convertDDToDMS,
6
+ } from "./bearing";
2
7
 
3
- describe("convertDDToDMS", () => {
4
- test("converts decimal-ish degrees to DMS", () => {
8
+ describe("bearing", () => {
9
+ test("convertDDToDMS converts decimal-ish degrees to DMS", () => {
5
10
  expect(convertDDToDMS(-0.001, false, false)).toBe("-0° 00' 10\"");
6
11
  expect(convertDDToDMS(-10.001, false, false)).toBe("-10° 00' 10\"");
7
12
  expect(convertDDToDMS(-370.001, false, false)).toBe("-10° 00' 10\"");
@@ -27,4 +32,42 @@ describe("convertDDToDMS", () => {
27
32
  expect(convertDDToDMS(300.1, false, false)).toBe("300° 10'");
28
33
  expect(convertDDToDMS(0, false)).toBe("0° 00'");
29
34
  });
35
+
36
+ test("bearingStringValidator", () => {
37
+ const tests: [string, string | null][] = [
38
+ ["", null],
39
+ ["1", null],
40
+ ["1.2345", null],
41
+ ["-1.2345", null],
42
+ ["360.2345", null],
43
+ ["-360.2345", null],
44
+ ["1.2e6", "Bearing must be a number in D.MMSSS format"],
45
+ ["0.60000", "Bearing must be a number in D.MMSSS format"],
46
+ ["0.00600", "Bearing must be a number in D.MMSSS format"],
47
+ ["0.123456", "Bearing has a maximum of 5 decimal places"],
48
+ ];
49
+
50
+ tests.forEach((test, i) => {
51
+ expect(bearingStringValidator(test[0]), `Test ${i}: "${test[0]}" should return "${test[1]}"`).toBe(test[1]);
52
+ });
53
+
54
+ // calls custom invalid
55
+ const fn = jest.fn();
56
+ bearingStringValidator("1.2", fn);
57
+ expect(fn).toHaveBeenCalledWith(1.2);
58
+ });
59
+
60
+ test("bearingRangeValidator", () => {
61
+ expect(bearingRangeValidator(0)).toBeNull();
62
+ expect(bearingRangeValidator(359.595999)).toBeNull();
63
+ expect(bearingRangeValidator(-0.00001)).toBe("Bearing must not be negative");
64
+ expect(bearingRangeValidator(360)).toBe("Bearing must be less than 360 degrees");
65
+ });
66
+
67
+ test("bearingCorrectionRangeValidator", () => {
68
+ expect(bearingCorrectionRangeValidator(-179.59999)).toBeNull();
69
+ expect(bearingCorrectionRangeValidator(359.59999)).toBeNull();
70
+ expect(bearingCorrectionRangeValidator(-180)).toBe("Bearing correction must be greater then -180 degrees");
71
+ expect(bearingCorrectionRangeValidator(360)).toBe("Bearing correction must be less than 360 degrees");
72
+ });
30
73
  });
@@ -81,3 +81,17 @@ export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, add
81
81
 
82
82
  return dmsString;
83
83
  };
84
+
85
+ export const bearingRangeValidator = (value: number | null) => {
86
+ if (value === null) return "Bearing is required";
87
+ if (value >= 360) return "Bearing must be less than 360 degrees";
88
+ if (value < 0) return "Bearing must not be negative";
89
+ return null;
90
+ };
91
+
92
+ export const bearingCorrectionRangeValidator = (value: number | null) => {
93
+ if (value === null) return "Bearing correction is required";
94
+ if (value >= 360) return "Bearing correction must be less than 360 degrees";
95
+ if (value <= -180) return "Bearing correction must be greater then -180 degrees";
96
+ return null;
97
+ };
@@ -1,3 +0,0 @@
1
- .react-menu-inline-test .szh-menu-container, .react-menu-inline-test .szh-menu {
2
- position: static !important;
3
- }