@griddo/ax 1.63.5 → 1.64.2

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 (130) hide show
  1. package/config/griddo-config/cx-polyfills/builder.ssr.js +6 -0
  2. package/config/griddo-config/cx-polyfills/componentsBundle.js +4 -0
  3. package/config/{griddo-config.js → griddo-config/index.js} +36 -15
  4. package/config/griddo-config/ssrHelpers.js +47 -0
  5. package/config/jest/componentsMock.js +29 -0
  6. package/config/jest/fileMock.js +1 -0
  7. package/config/jest/setup.js +5 -0
  8. package/config/jest/styleMock.js +1 -0
  9. package/config/jest/test-utils.js +17 -0
  10. package/config/paths.js +36 -5
  11. package/config/webpack.config.js +1 -1
  12. package/config/webpackDevServer.config.js +4 -1
  13. package/config/webpackSchemas.config.js +4 -1
  14. package/package.json +33 -59
  15. package/scripts/build.js +9 -2
  16. package/src/__mocks__/reducers/analyticsState.tsx +14 -0
  17. package/src/__mocks__/reducers/pageEditor.tsx +30 -0
  18. package/src/api/sites.tsx +28 -6
  19. package/src/api/structuredData.tsx +1 -1
  20. package/src/api/users.tsx +5 -4
  21. package/src/components/ActionMenu/style.tsx +2 -0
  22. package/src/components/Browser/index.tsx +9 -5
  23. package/src/{modules/Content/PageItem/atoms.tsx → components/CategoryCell/index.tsx} +4 -6
  24. package/src/components/CategoryCell/style.tsx +11 -0
  25. package/src/components/Fields/AnalyticsField/PageAnalytics/index.tsx +19 -19
  26. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/atoms.tsx +26 -16
  27. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/index.tsx +8 -13
  28. package/src/components/Fields/AnalyticsField/index.test.tsx +100 -0
  29. package/src/components/Fields/AnalyticsField/index.tsx +9 -2
  30. package/src/components/Fields/AnalyticsField/utils.tsx +2 -2
  31. package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/style.tsx +2 -1
  32. package/src/components/Fields/CheckField/index.test.tsx +95 -0
  33. package/src/components/Fields/CheckField/index.tsx +9 -3
  34. package/src/components/Fields/CheckField/style.tsx +32 -24
  35. package/src/components/Fields/CheckGroup/index.test.tsx +274 -0
  36. package/src/components/Fields/CheckGroup/index.tsx +2 -1
  37. package/src/components/Fields/FileField/FileDragAndDrop/style.tsx +3 -2
  38. package/src/components/Fields/FileField/style.tsx +2 -1
  39. package/src/components/Fields/MultiCheckSelect/style.tsx +18 -18
  40. package/src/components/Fields/NoteField/style.tsx +9 -9
  41. package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +1 -1
  42. package/src/components/Fields/Select/style.tsx +41 -37
  43. package/src/components/Fields/TagField/index.test.tsx +136 -0
  44. package/src/components/Fields/TagField/index.tsx +8 -12
  45. package/src/components/Fields/TextArea/index.test.tsx +69 -0
  46. package/src/components/Fields/TextArea/index.tsx +4 -13
  47. package/src/components/Fields/TextArea/style.tsx +2 -2
  48. package/src/components/Fields/TextField/index.test.tsx +144 -0
  49. package/src/components/Fields/TextField/index.tsx +23 -19
  50. package/src/components/Fields/TextField/style.tsx +16 -7
  51. package/src/components/Fields/UniqueCheck/index.test.tsx +43 -0
  52. package/src/components/Fields/UrlField/utils.tsx +8 -6
  53. package/src/components/FieldsBehavior/index.tsx +0 -2
  54. package/src/components/FieldsBehavior/style.tsx +21 -21
  55. package/src/components/Gallery/GalleryFilters/Orientation/style.tsx +2 -1
  56. package/src/components/Gallery/GalleryFilters/SortBy/style.tsx +2 -1
  57. package/src/components/Icon/index.tsx +12 -10
  58. package/src/components/IconAction/index.tsx +7 -1
  59. package/src/components/IconAction/style.tsx +10 -10
  60. package/src/components/SearchField/index.tsx +11 -8
  61. package/src/components/SearchField/style.tsx +21 -12
  62. package/src/components/TableFilters/CategoryFilter/index.tsx +1 -1
  63. package/src/components/TableFilters/CategoryFilter/style.tsx +2 -1
  64. package/src/components/TableFilters/DateFilter/style.tsx +2 -1
  65. package/src/components/TableFilters/LiveFilter/index.tsx +2 -2
  66. package/src/components/TableFilters/LiveFilter/style.tsx +2 -1
  67. package/src/components/TableFilters/NameFilter/style.tsx +2 -1
  68. package/src/components/TableFilters/SiteFilter/index.tsx +38 -24
  69. package/src/components/TableFilters/SiteFilter/style.tsx +2 -1
  70. package/src/components/TableFilters/StatusFilter/style.tsx +2 -1
  71. package/src/components/TableFilters/TranslationsFilter/style.tsx +2 -1
  72. package/src/components/TableFilters/TypeFilter/style.tsx +2 -1
  73. package/src/components/Tag/index.tsx +9 -7
  74. package/src/components/Tag/style.tsx +20 -8
  75. package/src/components/index.tsx +4 -2
  76. package/src/containers/App/reducer.tsx +0 -2
  77. package/src/containers/PageEditor/actions.tsx +2 -2
  78. package/src/containers/Sites/actions.tsx +30 -19
  79. package/src/containers/Users/actions.tsx +10 -2
  80. package/src/containers/Users/reducer.tsx +3 -1
  81. package/src/helpers/fields.tsx +2 -4
  82. package/src/helpers/index.tsx +3 -0
  83. package/src/helpers/themes.tsx +9 -0
  84. package/src/modules/Analytics/GroupPanel/utils.tsx +3 -3
  85. package/src/modules/App/Routing/NavMenu/index.tsx +13 -12
  86. package/src/modules/Content/PageItem/index.tsx +31 -9
  87. package/src/modules/Content/PageItem/style.tsx +0 -7
  88. package/src/modules/Content/atoms.tsx +78 -0
  89. package/src/modules/Content/index.tsx +104 -33
  90. package/src/modules/Content/style.tsx +10 -7
  91. package/src/modules/GlobalEditor/PageBrowser/index.tsx +0 -4
  92. package/src/modules/GlobalEditor/index.tsx +3 -3
  93. package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/DefaultsBrowser/index.tsx +0 -4
  94. package/src/modules/PageEditor/PageBrowser/index.tsx +0 -4
  95. package/src/modules/PageEditor/atoms.tsx +74 -0
  96. package/src/modules/PageEditor/index.tsx +30 -9
  97. package/src/modules/PageEditor/style.tsx +4 -0
  98. package/src/modules/PublicPreview/index.tsx +3 -5
  99. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/TemplateBrowser/index.tsx +0 -4
  100. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +2 -3
  101. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +1 -1
  102. package/src/modules/Settings/Globals/index.tsx +3 -3
  103. package/src/modules/StructuredData/Form/index.tsx +2 -4
  104. package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +22 -18
  105. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +3 -24
  106. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +2 -2
  107. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/style.tsx +0 -7
  108. package/src/modules/StructuredData/StructuredDataList/OptionTable/index.tsx +2 -4
  109. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +46 -14
  110. package/src/modules/StructuredData/StructuredDataList/hooks.tsx +21 -9
  111. package/src/modules/StructuredData/StructuredDataList/index.tsx +48 -20
  112. package/src/modules/Users/Profile/index.tsx +12 -7
  113. package/src/modules/Users/UserCreate/SiteItem/index.tsx +44 -0
  114. package/src/modules/Users/UserCreate/SiteItem/style.tsx +30 -0
  115. package/src/modules/Users/UserCreate/index.tsx +120 -10
  116. package/src/modules/Users/UserCreate/style.tsx +54 -1
  117. package/src/modules/Users/UserEdit/index.tsx +53 -15
  118. package/src/modules/Users/UserForm/index.tsx +152 -5
  119. package/src/modules/Users/UserForm/style.tsx +40 -2
  120. package/src/modules/Users/UserList/BulkHeader/TableHeader/index.tsx +40 -2
  121. package/src/modules/Users/UserList/BulkHeader/TableHeader/style.tsx +0 -1
  122. package/src/modules/Users/UserList/BulkHeader/index.tsx +10 -1
  123. package/src/modules/Users/UserList/UserItem/index.tsx +70 -15
  124. package/src/modules/Users/UserList/hooks.tsx +58 -1
  125. package/src/modules/Users/UserList/index.tsx +80 -34
  126. package/src/modules/Users/index.tsx +18 -11
  127. package/src/routes/site.tsx +8 -0
  128. package/src/types/index.tsx +7 -0
  129. package/tsconfig.json +2 -0
  130. package/scripts/test.js +0 -45
@@ -8,7 +8,10 @@ const IconWrapper = styled.div<{ error: boolean | undefined; readonly: boolean |
8
8
  border-bottom: ${(p) => (p.readonly === true ? `none` : `1px solid`)};
9
9
  border-color: ${(p) => (p.error === true ? p.theme.color.error : p.theme.color.uiLine)};
10
10
  border-radius: ${(p) => `0 ${p.theme.radii.s} ${p.theme.radii.s} 0`};
11
- width: ${(p) => (p.readonly === true ? `calc(${p.theme.spacing.xs} * 2 + ${p.theme.spacing.s})` : `calc(${p.theme.spacing.xs} * 2 + ${p.theme.spacing.m})`)};
11
+ width: ${(p) =>
12
+ p.readonly === true
13
+ ? `calc(${p.theme.spacing.xs} * 2 + ${p.theme.spacing.s})`
14
+ : `calc(${p.theme.spacing.xs} * 2 + ${p.theme.spacing.m})`};
12
15
  button {
13
16
  position: absolute;
14
17
  top: 50%;
@@ -21,7 +24,13 @@ const IconWrapper = styled.div<{ error: boolean | undefined; readonly: boolean |
21
24
  }
22
25
  `;
23
26
 
24
- const Input = styled.input<{ error?: boolean; button?: boolean; icon?: boolean; hasPrefix: boolean; prefixWidth: number }>`
27
+ const Input = styled.input<{
28
+ error?: boolean;
29
+ button?: boolean;
30
+ icon?: boolean;
31
+ hasPrefix: boolean;
32
+ prefixWidth: number;
33
+ }>`
25
34
  flex: 1;
26
35
  border-top: 1px solid;
27
36
  border-right: ${(p) => (p.button ? `none` : `1px solid`)};
@@ -31,9 +40,9 @@ const Input = styled.input<{ error?: boolean; button?: boolean; icon?: boolean;
31
40
  border-radius: ${(p) => (p.button ? `${p.theme.radii.s} 0 0 ${p.theme.radii.s}` : p.theme.radii.s)};
32
41
  background: ${(p) => p.theme.color.uiBackground02};
33
42
  padding-top: 0;
34
- padding-right: ${(p) => p.icon ? `40px` : p.theme.spacing.s};
43
+ padding-right: ${(p) => (p.icon ? `40px` : p.theme.spacing.s)};
35
44
  padding-bottom: 0;
36
- padding-left: ${(p) => p.hasPrefix ? `calc(${p.prefixWidth}px + 15px)` : p.theme.spacing.s};
45
+ padding-left: ${(p) => (p.hasPrefix ? `calc(${p.prefixWidth}px + 15px)` : p.theme.spacing.s)};
37
46
  height: ${(p) => p.theme.spacing.l};
38
47
  width: 100%;
39
48
  ${(p) => p.theme.textStyle.fieldContent};
@@ -57,8 +66,8 @@ const Input = styled.input<{ error?: boolean; button?: boolean; icon?: boolean;
57
66
  }
58
67
 
59
68
  &:disabled {
60
- color: ${p => p.theme.color.interactiveDisabled};
61
- border-color: ${p => p.theme.color.interactiveDisabled};
69
+ color: ${(p) => p.theme.color.interactiveDisabled};
70
+ border-color: ${(p) => p.theme.color.interactiveDisabled};
62
71
  }
63
72
  `;
64
73
 
@@ -73,7 +82,7 @@ const FieldWrapper = styled.div<{ error: boolean | undefined }>`
73
82
  }
74
83
  `;
75
84
 
76
- const BackgroundIcon = styled.div<{ onClick?: any }>`
85
+ const BackgroundIcon = styled.div<{ onClick?: any }>`
77
86
  position: absolute;
78
87
  right: ${(p) => p.theme.spacing.xs};
79
88
  top: 50%;
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ import UniqueCheck from "./index";
3
+ import { ThemeProvider } from "styled-components";
4
+ import { parseTheme } from "@griddo/core";
5
+ import globalTheme from "../../../themes/theme.json";
6
+ import "@testing-library/jest-dom";
7
+ import { render, screen, cleanup } from "@testing-library/react";
8
+
9
+ afterEach(cleanup);
10
+
11
+ const optionsArray = [
12
+ {
13
+ name: "option_1",
14
+ value: null,
15
+ title: "Option 1",
16
+ },
17
+ {
18
+ name: "option_2",
19
+ value: null,
20
+ title: "Option 2",
21
+ },
22
+ ];
23
+ const initialValues = {
24
+ name: "",
25
+ value: null,
26
+ options: optionsArray,
27
+ onChange: jest.fn(),
28
+ };
29
+
30
+ describe("CheckField component rendering", () => {
31
+ it("should render the component CheckField", () => {
32
+ render(
33
+ <ThemeProvider theme={parseTheme(globalTheme)}>
34
+ <UniqueCheck {...initialValues} />
35
+ </ThemeProvider>
36
+ );
37
+
38
+ const checkFieldLabel = screen.getByTestId("checkFieldLabel");
39
+
40
+ expect(screen.getAllByTestId("checkFieldLabel")).toHaveLength(1);
41
+ expect(checkFieldLabel).toHaveTextContent("Option 1");
42
+ });
43
+ });
@@ -15,12 +15,14 @@ const findAnchorsFromPage = (page: IPage): ISelectOption[] => {
15
15
  }
16
16
  if (module.elements) {
17
17
  module.elements.forEach((element: any) => {
18
- element.componentModules && element.componentModules.forEach((component: any) => {
19
- if (component.anchorID && component.anchorID.trim() !== "") {
20
- const option = { value: component.anchorID, label: component.anchorID };
21
- options.push(option);
22
- }
23
- });
18
+ element.componentModules &&
19
+ Array.isArray(element.componentModules) &&
20
+ element.componentModules.forEach((component: any) => {
21
+ if (component.anchorID && component.anchorID.trim() !== "") {
22
+ const option = { value: component.anchorID, label: component.anchorID };
23
+ options.push(option);
24
+ }
25
+ });
24
26
  });
25
27
  }
26
28
  });
@@ -27,7 +27,6 @@ const FieldsBehavior = (props: any): JSX.Element => {
27
27
  editorID,
28
28
  objKey,
29
29
  } = props;
30
-
31
30
  const [showAdvanced, setShowAdvanced] = useState(false);
32
31
  const [errorField, setErrorField] = useState(false);
33
32
  const [message, setMessage] = useState(helptext);
@@ -72,7 +71,6 @@ const FieldsBehavior = (props: any): JSX.Element => {
72
71
  }
73
72
  setErrorField(!isValid);
74
73
  };
75
-
76
74
  return (
77
75
  <S.Wrapper error={errorField} className={wrapperClass} showTitle={showTitle} id={objKey}>
78
76
  <S.Content error={errorField}>
@@ -1,19 +1,19 @@
1
1
  import styled from "styled-components";
2
2
 
3
3
  export const Label = styled.label`
4
- ${(p) => p.theme.textStyle.fieldLabel};
5
- color: ${(p) => p.theme.color.textMediumEmphasis};
4
+ ${(p) => p.theme.textStyle?.fieldLabel};
5
+ color: ${(p) => p.theme.color?.textMediumEmphasis};
6
6
  display: block;
7
- margin-bottom: ${(p) => p.theme.spacing.xs};
7
+ margin-bottom: ${(p) => p.theme.spacing?.xs};
8
8
  `;
9
9
 
10
10
  export const Asterisk = styled.span`
11
- color: ${(p) => p.theme.color.error};
11
+ color: ${(p) => p.theme.color?.error};
12
12
  `;
13
13
 
14
14
  export const HelpText = styled.div`
15
15
  ${(p) => p.theme.textStyle.uiXS};
16
- color: ${(p) => p.theme.color.textMediumEmphasis};
16
+ color: ${(p) => p.theme.color?.textMediumEmphasis};
17
17
  `;
18
18
 
19
19
  export const Header = styled.div`
@@ -32,15 +32,15 @@ export const Icons = styled.div`
32
32
 
33
33
  export const Wrapper = styled.div<{ error: boolean | undefined; showTitle: boolean | undefined }>`
34
34
  position: relative;
35
- margin-bottom: ${(p) => p.theme.spacing.m};
36
- padding-top: ${(p) => p.showTitle ? p.theme.spacing.m : 0};
35
+ margin-bottom: ${(p) => p.theme.spacing?.m};
36
+ padding-top: ${(p) => (p.showTitle ? p.theme.spacing?.m : 0)};
37
37
  width: 100%;
38
38
 
39
39
  ${HelpText} {
40
- color: ${(p) => (p.error === true ? p.theme.color.error : p.theme.color.textMediumEmphasis)};
40
+ color: ${(p) => (p.error === true ? p.theme.color?.error : p.theme.color?.textMediumEmphasis)};
41
41
  }
42
42
  ${Label} {
43
- color: ${(p) => (p.error === true ? p.theme.color.error : p.theme.color.textMediumEmphasis)};
43
+ color: ${(p) => (p.error === true ? p.theme.color?.error : p.theme.color?.textMediumEmphasis)};
44
44
  }
45
45
 
46
46
  &:hover > .fieldHeader ${Icons} {
@@ -48,25 +48,25 @@ export const Wrapper = styled.div<{ error: boolean | undefined; showTitle: boole
48
48
  }
49
49
 
50
50
  &.filled {
51
- padding-top: ${(p) => p.showTitle ? `calc(${p.theme.spacing.m} + ${p.theme.spacing.s})` : p.theme.spacing.s};
52
- padding-left: ${(p) => p.theme.spacing.s};
53
- padding-right: ${(p) => p.theme.spacing.s};
54
- padding-bottom: ${(p) => p.theme.spacing.xs};
55
- background-color: ${(p) => p.theme.color.uiBarBackground};
56
- border-radius: ${(p) => p.theme.radii.s};
57
- box-shadow: ${(p) => p.theme.shadow.shadowS};
51
+ padding-top: ${(p) => (p.showTitle ? `calc(${p.theme.spacing?.m} + ${p.theme.spacing?.s})` : p.theme.spacing?.s)};
52
+ padding-left: ${(p) => p.theme.spacing?.s};
53
+ padding-right: ${(p) => p.theme.spacing?.s};
54
+ padding-bottom: ${(p) => p.theme.spacing?.xs};
55
+ background-color: ${(p) => p.theme.color?.uiBarBackground};
56
+ border-radius: ${(p) => p.theme.radii?.s};
57
+ box-shadow: ${(p) => p.theme.shadow?.shadowS};
58
58
 
59
59
  ${Header} {
60
- top: ${(p) => p.theme.spacing.s};
61
- left: ${(p) => p.theme.spacing.s};
60
+ top: ${(p) => p.theme.spacing?.s};
61
+ left: ${(p) => p.theme.spacing?.s};
62
62
  }
63
63
  }
64
64
  `;
65
65
 
66
66
  export const Content = styled.div<{ error: boolean | undefined }>`
67
67
  &:focus-within {
68
- & + div label {
69
- color: ${(p) => (p.error === true ? p.theme.color.error : p.theme.color.interactive01)};
70
- }
68
+ & + div label {
69
+ color: ${(p) => (p.error === true ? p.theme.color?.error : p.theme.color?.interactive01)};
71
70
  }
71
+ }
72
72
  `;
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const Orientation = styled(Header) <{ isActive: boolean }>`
5
+ const Orientation = styled((props) => <Header {...props} />)<{ isActive: boolean }>`
5
6
  width: 90px;
6
7
  justify-content: center;
7
8
  flex-wrap: nowrap;
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const SortBy = styled(Header) <{ isActive: boolean }>`
5
+ const SortBy = styled((props) => <Header {...props} />)<{ isActive: boolean }>`
5
6
  width: 100%;
6
7
  cursor: pointer;
7
8
  &:hover {
@@ -8,23 +8,25 @@ const getImage = (name: string) => {
8
8
  }
9
9
  };
10
10
  const Icon = (props: IProps) => {
11
- const name = props.name && props.name
11
+ const name =
12
+ props.name &&
13
+ props.name
12
14
  .replace(".svg", "")
13
15
  .split("-")
14
16
  .map((type: any) => type.charAt(0).toUpperCase() + type.slice(1))
15
17
  .join("");
16
18
 
17
- const size = props.size ? props.size : "22";
18
- const fill = props.fill ? props.fill : "black";
19
+ const size = props.size ? props.size : "22";
20
+ const fill = props.fill ? props.fill : "black";
19
21
 
20
- const Svg = getImage(name);
22
+ const Svg = getImage(name);
21
23
 
22
- if (Svg) {
23
- return <Svg height={size} width={size} viewBox="0 0 24 24" fill={fill} />;
24
- }
24
+ if (Svg) {
25
+ return <Svg data-testid="iconComponent" height={size} width={size} viewBox="0 0 24 24" fill={fill} />;
26
+ }
25
27
 
26
- return null;
27
- }
28
+ return null;
29
+ };
28
30
 
29
31
  interface IStateProps {
30
32
  name: string;
@@ -34,4 +36,4 @@ interface IStateProps {
34
36
 
35
37
  type IProps = IStateProps;
36
38
 
37
- export default Icon;
39
+ export default Icon;
@@ -13,7 +13,13 @@ const IconAction = (props: IIconActionProps): JSX.Element => {
13
13
  };
14
14
 
15
15
  return (
16
- <S.Button disabled={disabled} onClick={handleOnClick} size={size} inversed={inversed}>
16
+ <S.Button
17
+ data-testid="iconActionComponent"
18
+ disabled={disabled}
19
+ onClick={handleOnClick}
20
+ size={size}
21
+ inversed={inversed}
22
+ >
17
23
  <S.Icon>
18
24
  <Icon name={icon} />
19
25
  </S.Icon>
@@ -1,6 +1,6 @@
1
1
  import styled from "styled-components";
2
2
 
3
- export const Button = styled.button<{ size: string | undefined; inversed?: boolean; disabled?:boolean }>`
3
+ export const Button = styled.button<{ size: string | undefined; inversed?: boolean; disabled?: boolean }>`
4
4
  background: transparent;
5
5
  border: none;
6
6
  border-radius: 50%;
@@ -8,9 +8,9 @@ export const Button = styled.button<{ size: string | undefined; inversed?: boole
8
8
  cursor: pointer;
9
9
  font-size: 0;
10
10
  outline: transparent;
11
- padding: ${(p) => p.theme.spacing.xxs};
11
+ padding: ${(p) => p.theme.spacing?.xxs};
12
12
  position: relative;
13
- pointer-events: ${(p) => p.disabled ? "none" : "auto"};
13
+ pointer-events: ${(p) => (p.disabled ? "none" : "auto")};
14
14
  :before {
15
15
  content: "";
16
16
  border-radius: 50%;
@@ -23,15 +23,15 @@ export const Button = styled.button<{ size: string | undefined; inversed?: boole
23
23
  transition: opacity 0.1s;
24
24
  }
25
25
  :hover:before {
26
- background-color: ${(p) => p.theme.color.overlayHoverPrimary};
26
+ background-color: ${(p) => p.theme.color?.overlayHoverPrimary};
27
27
  opacity: 1;
28
28
  }
29
29
  :focus:before {
30
- background-color: ${(p) => p.theme.color.overlayFocusPrimary};
30
+ background-color: ${(p) => p.theme.color?.overlayFocusPrimary};
31
31
  opacity: 1;
32
32
  }
33
33
  :active:before {
34
- background-color: ${(p) => p.theme.color.overlayPressedPrimary};
34
+ background-color: ${(p) => p.theme.color?.overlayPressedPrimary};
35
35
  opacity: 1;
36
36
  }
37
37
  :disabled {
@@ -43,15 +43,15 @@ export const Button = styled.button<{ size: string | undefined; inversed?: boole
43
43
  }
44
44
  svg {
45
45
  path {
46
- fill: ${(p) => p.theme.color.interactiveDisabled};
46
+ fill: ${(p) => p.theme.color?.interactiveDisabled};
47
47
  }
48
48
  }
49
49
  }
50
50
  svg {
51
- width: ${(p) => (p.size === "s" ? p.theme.spacing.s : p.theme.spacing.m)};
52
- height: ${(p) => (p.size === "s" ? p.theme.spacing.s : p.theme.spacing.m)};
51
+ width: ${(p) => (p.size === "s" ? p.theme.spacing?.s : p.theme.spacing?.m)};
52
+ height: ${(p) => (p.size === "s" ? p.theme.spacing?.s : p.theme.spacing?.m)};
53
53
  path {
54
- fill: ${(p) => (p.inversed ? p.theme.color.textHighEmphasisInverse : p.theme.color.interactive01)};
54
+ fill: ${(p) => (p.inversed ? p.theme.color?.textHighEmphasisInverse : p.theme.color?.interactive01)};
55
55
  }
56
56
  }
57
57
  `;
@@ -4,7 +4,7 @@ import React, { useState } from "react";
4
4
  import * as S from "./style";
5
5
 
6
6
  const SearchField = (props: IProps): JSX.Element => {
7
- const { onChange, placeholder, closeOnInactive = false } = props;
7
+ const { onChange, placeholder, closeOnInactive = false, searchOnEnter = true, disabled = false } = props;
8
8
 
9
9
  const [isOpen, setIsOpen] = useState(false);
10
10
  const [inputValue, setInputValue] = useState("");
@@ -28,10 +28,10 @@ const SearchField = (props: IProps): JSX.Element => {
28
28
 
29
29
  const handleClick = () => {
30
30
  closeOnInactive ? handleClose() : handleClear();
31
- }
31
+ };
32
32
 
33
33
  const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
34
- if (e.key === "Enter") {
34
+ if (!searchOnEnter || e.key === "Enter") {
35
35
  onChange(inputValue);
36
36
  }
37
37
  };
@@ -49,21 +49,22 @@ const SearchField = (props: IProps): JSX.Element => {
49
49
  onKeyDown={handleKeyDown}
50
50
  placeholder={placeholder}
51
51
  closeOnInactive={closeOnInactive}
52
+ disabled={disabled}
52
53
  autoFocus
53
54
  />
54
- {inputValue.trim() !== "" && <S.HelpText>Press ENTER</S.HelpText>}
55
+ {inputValue.trim() !== "" && searchOnEnter && <S.HelpText>Press ENTER</S.HelpText>}
55
56
  {closeOnInactive || inputValue.length > 0 ? (
56
57
  <S.IconCloseWrapper onClick={handleClick}>
57
58
  <Icon name="close" size="24" />
58
59
  </S.IconCloseWrapper>
59
60
  ) : (
60
- <S.IconSearchWrapper>
61
- <Icon name="search" size="24" />
61
+ <S.IconSearchWrapper disabled={disabled}>
62
+ <Icon name="search" size="24" />
62
63
  </S.IconSearchWrapper>
63
64
  )}
64
65
  </S.FieldWrapper>
65
66
  ) : (
66
- <S.IconSearchWrapper onClick={toggleField}>
67
+ <S.IconSearchWrapper disabled={disabled} onClick={toggleField}>
67
68
  <Icon name="search" size="24" />
68
69
  </S.IconSearchWrapper>
69
70
  )}
@@ -75,6 +76,8 @@ interface IProps {
75
76
  onChange(query: string): void;
76
77
  placeholder?: string;
77
78
  closeOnInactive?: boolean;
79
+ searchOnEnter?: boolean;
80
+ disabled?: boolean;
78
81
  }
79
82
 
80
- export default SearchField;
83
+ export default SearchField;
@@ -5,29 +5,33 @@ const Wrapper = styled.div`
5
5
  width: 100%;
6
6
  `;
7
7
 
8
- const FieldWrapper = styled.div`
9
- `;
8
+ const FieldWrapper = styled.div``;
10
9
 
11
- const Input = styled.input<{ closeOnInactive: boolean }>`
10
+ const Input = styled.input<{ closeOnInactive: boolean; disabled: boolean }>`
12
11
  ${(p) => p.theme.textStyle.fieldContent};
13
12
  color: ${(p) => p.theme.color.textHighEmphasis};
14
13
  background-color: ${(p) => p.theme.color.interactiveBackground};
15
14
  width: 100%;
16
15
  height: ${(p) => p.theme.spacing.l};
17
16
  padding-left: ${(p) => p.theme.spacing.xs};
18
- border-color: ${(p) => p.closeOnInactive ? p.theme.color.interactive01 : p.theme.color.uiLine};
19
- border-width: ${(p) => p.closeOnInactive ? "0 0 1px" : "1px"};
17
+ border-color: ${(p) =>
18
+ p.disabled
19
+ ? p.theme.color.interactiveDisabled
20
+ : p.closeOnInactive
21
+ ? p.theme.color.interactive01
22
+ : p.theme.color.uiLine};
23
+ border-width: ${(p) => (p.closeOnInactive ? "0 0 1px" : "1px")};
20
24
  border-style: solid;
21
- border-radius: ${(p) => p.closeOnInactive ? 0 : p.theme.radii.s};
25
+ border-radius: ${(p) => (p.closeOnInactive ? 0 : p.theme.radii.s)};
22
26
 
23
27
  &:active,
24
28
  &:focus {
25
29
  outline: none;
26
- border-color: ${(p) => p.theme.color.interactive01};
30
+ border-color: ${(p) => (p.disabled ? p.theme.color.interactiveDisabled : p.theme.color.interactive01)};
27
31
  }
28
32
  `;
29
33
 
30
- const IconSearchWrapper = styled.div<{ onClick?: () => void }>`
34
+ const IconSearchWrapper = styled.div<{ onClick?: () => void; disabled: boolean }>`
31
35
  position: absolute;
32
36
  right: ${(p) => p.theme.spacing.xxs};
33
37
  top: 50%;
@@ -35,6 +39,11 @@ const IconSearchWrapper = styled.div<{ onClick?: () => void }>`
35
39
  height: ${(p) => p.theme.spacing.m};
36
40
  cursor: ${(p) => (p.onClick ? "pointer" : "default")};
37
41
  transform: translateY(-50%);
42
+ svg {
43
+ path {
44
+ fill: ${(p) => (p.disabled ? p.theme.color.interactiveDisabled : p.theme.color.interactive01)};
45
+ }
46
+ }
38
47
  `;
39
48
 
40
49
  const HelpText = styled.div`
@@ -49,12 +58,12 @@ const HelpText = styled.div`
49
58
 
50
59
  const IconCloseWrapper = styled.div`
51
60
  position: absolute;
52
- right: ${p => p.theme.spacing.xxs};
61
+ right: ${(p) => p.theme.spacing.xxs};
53
62
  top: 50%;
54
- width: ${p => p.theme.spacing.m};
55
- height: ${p => p.theme.spacing.m};
63
+ width: ${(p) => p.theme.spacing.m};
64
+ height: ${(p) => p.theme.spacing.m};
56
65
  cursor: pointer;
57
66
  transform: translateY(-50%);
58
67
  `;
59
68
 
60
- export { Wrapper, IconSearchWrapper, FieldWrapper, Input, HelpText, IconCloseWrapper };
69
+ export { Wrapper, IconSearchWrapper, FieldWrapper, Input, HelpText, IconCloseWrapper };
@@ -62,7 +62,7 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
62
62
  filterItems("categories", queryFilters);
63
63
  };
64
64
 
65
- const isActive = !areEquals(selectedValue, initialState);
65
+ const isActive = !areEquals(selectedValue, [selectAllOption]);
66
66
 
67
67
  const Header = () => (
68
68
  <S.HeaderWrapper isActive={isActive}>
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const HeaderWrapper = styled(Header)<{ isActive: boolean }>`
5
+ const HeaderWrapper = styled((props) => <Header {...props} />)<{ isActive: boolean }>`
5
6
  width: 150px;
6
7
  justify-content: center;
7
8
  &:hover {
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const Date = styled(Header) <{ isActive: boolean }>`
5
+ const Date = styled((props) => <Header {...props} />)<{ isActive: boolean }>`
5
6
  width: 100px;
6
7
  &:hover {
7
8
  color: ${(p) => p.theme.color.interactive01};
@@ -9,7 +9,6 @@ import * as S from "./style";
9
9
 
10
10
  const LiveFilter = (props: ILiveFilterProps): JSX.Element => {
11
11
  const { filterItems, value, isStructuredData } = props;
12
-
13
12
  const filters: IFilterValue[] = [
14
13
  {
15
14
  name: "all",
@@ -27,7 +26,8 @@ const LiveFilter = (props: ILiveFilterProps): JSX.Element => {
27
26
  const structuredDataStatus = ["offline", "active"];
28
27
 
29
28
  useEffect(() => {
30
- setSelectedValue([value]);
29
+ setSelectedValue([...storedValue]);
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
31
  }, [value]);
32
32
 
33
33
  const getLiveStatusValues = async () => {
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const LiveOptions = styled(Header)<{ isActive: boolean }>`
5
+ const LiveOptions = styled((props) => <Header {...props} />)<{ isActive: boolean }>`
5
6
  width: 80px;
6
7
  justify-content: center;
7
8
  &:hover {
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const NameHeader = styled(Header)<{ isActive: boolean }>`
5
+ const NameHeader = styled((props) => <Header {...props} />)<{ isActive: boolean }>`
5
6
  width: 100%;
6
7
  min-width: 88px;
7
8
  &:hover {
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from "react";
1
+ import React, { useEffect, useLayoutEffect, useState } from "react";
2
2
 
3
3
  import { CheckGroup, FloatingMenu, Icon, ListTitle } from "@ax/components";
4
4
  import { areEquals, isNumber, isReqOk } from "@ax/helpers";
@@ -8,23 +8,33 @@ import { IFilterValue } from "@ax/types";
8
8
  import * as S from "./style";
9
9
 
10
10
  const SiteFilter = (props: ISiteFilterProps): JSX.Element => {
11
- const { filterItems, value, pointer, center = true } = props;
11
+ const {
12
+ filterItems,
13
+ value,
14
+ pointer,
15
+ center = true,
16
+ label = "Site",
17
+ selectAllOption = "all",
18
+ filters = [
19
+ {
20
+ name: "all",
21
+ value: "all",
22
+ title: "All",
23
+ },
24
+ ],
25
+ } = props;
12
26
 
13
- const filters: IFilterValue[] = [
14
- {
15
- name: "all",
16
- value: "all",
17
- title: "All",
18
- },
19
- ];
20
-
21
- const storedValue = value && value[pointer] ? value[pointer].split(",") : [];
22
- const parsedValue = storedValue.map((value: any) => (isNumber(value) ? parseInt(value) : value));
23
- const [initialState] = useState(parsedValue);
24
- const selectAllOption = "all";
25
- const [selectedValue, setSelectedValue] = useState([...initialState]);
27
+ const initialState = [selectAllOption];
28
+ const [selectedValue, setSelectedValue] = useState([selectAllOption]);
26
29
  const [options, setOptions] = useState(filters);
27
30
 
31
+ useLayoutEffect(() => {
32
+ const storedValue = value && value[pointer] ? value[pointer].split(",") : [];
33
+ const parsedValue = storedValue.map((value: any) => (isNumber(value) ? parseInt(value) : value));
34
+ setSelectedValue(parsedValue);
35
+ // eslint-disable-next-line react-hooks/exhaustive-deps
36
+ }, [value]);
37
+
28
38
  const getSelectSites = async () => {
29
39
  try {
30
40
  const items = await selects.getSelectSites();
@@ -39,14 +49,15 @@ const SiteFilter = (props: ISiteFilterProps): JSX.Element => {
39
49
 
40
50
  useEffect(() => {
41
51
  getSelectSites().then((items) => {
42
- items.forEach((item: { value: string; label: string }) => {
43
- const newFilter = {
44
- name: item.value,
45
- value: item.value,
46
- title: item.label,
47
- };
48
- filters.push(newFilter);
49
- });
52
+ items &&
53
+ items.forEach((item: { value: string; label: string }) => {
54
+ const newFilter = {
55
+ name: item.value,
56
+ value: item.value,
57
+ title: item.label,
58
+ };
59
+ filters.push(newFilter);
60
+ });
50
61
  setOptions(filters);
51
62
  });
52
63
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -65,7 +76,7 @@ const SiteFilter = (props: ISiteFilterProps): JSX.Element => {
65
76
 
66
77
  const Header = () => (
67
78
  <S.Site isActive={isActive} center={center}>
68
- Site
79
+ {label}
69
80
  <S.IconsWrapper>
70
81
  <Icon name="Filter" size="16" />
71
82
  </S.IconsWrapper>
@@ -87,6 +98,9 @@ interface ISiteFilterProps {
87
98
  value: any;
88
99
  pointer: string;
89
100
  center?: boolean;
101
+ label?: string;
102
+ selectAllOption?: string;
103
+ filters?: IFilterValue[];
90
104
  }
91
105
 
92
106
  export default SiteFilter;