@griddo/ax 1.75.86 → 1.75.90

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "1.75.86",
4
+ "version": "1.75.90",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -230,5 +230,5 @@
230
230
  "publishConfig": {
231
231
  "access": "public"
232
232
  },
233
- "gitHead": "bc95f57f09c830d9b284742fe75c6b77c2b8e344"
233
+ "gitHead": "8889a43af32258e1c6ef30472639275e19bc9769"
234
234
  }
@@ -2,11 +2,11 @@
2
2
 
3
3
  exports[`Avatar component rendering should render the component only with name 1`] = `
4
4
  <div
5
- className="sc-gSAPjG jRkXjC"
5
+ className="sc-gScZFl gCBoym"
6
6
  data-testid="avatar-wrapper"
7
7
  >
8
8
  <div
9
- className="sc-lbxAil fkodDH"
9
+ className="sc-lbVpMG hOAqbs"
10
10
  data-testid="avatar"
11
11
  />
12
12
  </div>
@@ -14,11 +14,11 @@ exports[`Avatar component rendering should render the component only with name 1
14
14
 
15
15
  exports[`Avatar component rendering should render the component with a wrong image url 1`] = `
16
16
  <div
17
- className="sc-gSAPjG jRkXjC"
17
+ className="sc-gScZFl gCBoym"
18
18
  data-testid="avatar-wrapper"
19
19
  >
20
20
  <div
21
- className="sc-lbxAil ejhcAS"
21
+ className="sc-lbVpMG kLnTvZ"
22
22
  data-testid="avatar"
23
23
  />
24
24
  </div>
@@ -26,11 +26,11 @@ exports[`Avatar component rendering should render the component with a wrong ima
26
26
 
27
27
  exports[`Avatar component rendering should render the component with an empty string as name 1`] = `
28
28
  <div
29
- className="sc-gSAPjG jRkXjC"
29
+ className="sc-gScZFl gCBoym"
30
30
  data-testid="avatar-wrapper"
31
31
  >
32
32
  <div
33
- className="sc-lbxAil hilXDA"
33
+ className="sc-lbVpMG dbQJiT"
34
34
  data-testid="avatar"
35
35
  />
36
36
  </div>
@@ -38,11 +38,11 @@ exports[`Avatar component rendering should render the component with an empty st
38
38
 
39
39
  exports[`Avatar component rendering should render the component with image null 1`] = `
40
40
  <div
41
- className="sc-gSAPjG jRkXjC"
41
+ className="sc-gScZFl gCBoym"
42
42
  data-testid="avatar-wrapper"
43
43
  >
44
44
  <div
45
- className="sc-lbxAil jDWEnq"
45
+ className="sc-lbVpMG jpmXvZ"
46
46
  data-testid="avatar"
47
47
  />
48
48
  </div>
@@ -50,11 +50,11 @@ exports[`Avatar component rendering should render the component with image null
50
50
 
51
51
  exports[`Avatar component rendering should render the component without name or image 1`] = `
52
52
  <div
53
- className="sc-gSAPjG jRkXjC"
53
+ className="sc-gScZFl gCBoym"
54
54
  data-testid="avatar-wrapper"
55
55
  >
56
56
  <div
57
- className="sc-lbxAil hilXDA"
57
+ className="sc-lbVpMG dbQJiT"
58
58
  data-testid="avatar"
59
59
  />
60
60
  </div>
@@ -1,11 +1,13 @@
1
1
  import * as React from "react";
2
2
  import ToggleField, { IToggleFieldProps } from "@ax/components/Fields/ToggleField";
3
3
  import { ThemeProvider } from "styled-components";
4
- import { parseTheme } from "@ax/helpers";
5
- import globalTheme from "@ax/themes/theme.json";
6
4
  import { render, screen, cleanup, fireEvent } from "@testing-library/react";
5
+ import "@testing-library/jest-dom";
7
6
  import { mock } from "jest-mock-extended";
8
7
 
8
+ import { parseTheme } from "@ax/helpers";
9
+ import globalTheme from "@ax/themes/theme.json";
10
+
9
11
  afterEach(cleanup);
10
12
 
11
13
  const defaultProps = mock<IToggleFieldProps>();
@@ -20,6 +22,10 @@ describe("ToggleField component rendering", () => {
20
22
 
21
23
  const toggleFieldWrapper = screen.getByTestId("toggle-field-wrapper");
22
24
  expect(toggleFieldWrapper).toBeTruthy();
25
+ const theme = parseTheme(globalTheme);
26
+ expect(toggleFieldWrapper).not.toHaveStyle(`background: ${theme.colors.uiBackground03}`);
27
+ const toggleAuxtext = screen.queryByTestId("toggle-auxtext");
28
+ expect(toggleAuxtext).not.toBeTruthy();
23
29
  });
24
30
 
25
31
  it("should render input as checked", () => {
@@ -60,6 +66,34 @@ describe("ToggleField component rendering", () => {
60
66
  const toggleFieldInput = screen.getByTestId<HTMLInputElement>("toggle-field-input");
61
67
  expect(toggleFieldInput.name).toEqual("This is the name");
62
68
  });
69
+
70
+ it("should render the auxText", () => {
71
+ defaultProps.auxText = "This is the new text";
72
+
73
+ render(
74
+ <ThemeProvider theme={parseTheme(globalTheme)}>
75
+ <ToggleField {...defaultProps} />
76
+ </ThemeProvider>
77
+ );
78
+
79
+ const auxText = screen.getByText("This is the new text");
80
+ expect(auxText).toBeInTheDocument();
81
+ });
82
+
83
+ it("should render with the background", () => {
84
+ defaultProps.background = true;
85
+
86
+ render(
87
+ <ThemeProvider theme={parseTheme(globalTheme)}>
88
+ <ToggleField {...defaultProps} />
89
+ </ThemeProvider>
90
+ );
91
+
92
+ const toggleFieldWrapper = screen.getByTestId<HTMLInputElement>("toggle-field-wrapper");
93
+ expect(toggleFieldWrapper).toBeTruthy();
94
+ const theme = parseTheme(globalTheme);
95
+ expect(toggleFieldWrapper).toHaveStyle(`background: ${theme.colors.uiBackground03}`);
96
+ });
63
97
  });
64
98
 
65
99
  describe("onClick events", () => {
@@ -105,7 +105,7 @@ const AutoItem = (props: IProps) => {
105
105
  };
106
106
 
107
107
  const handleButtonClick = () => {
108
- addFilter(state.filter);
108
+ addFilter(state.filter, source.id);
109
109
  setState({ ...state, isOpen: false });
110
110
  };
111
111
 
@@ -121,7 +121,7 @@ const AutoItem = (props: IProps) => {
121
121
  const handleDeleteTag = (id: number) => {
122
122
  const newFilters = state.filter.filter((e) => e.id !== id);
123
123
  setState({ ...state, filter: newFilters });
124
- addFilter(newFilters);
124
+ addFilter(newFilters, source.id);
125
125
  };
126
126
 
127
127
  return (
@@ -193,7 +193,7 @@ interface IProps {
193
193
  site: ISite;
194
194
  structuredDataSite: IStructuredData[];
195
195
  handleDelete: (value: string) => void;
196
- addFilter: (value: any[]) => void;
196
+ addFilter: (value: any[], source: string) => void;
197
197
  }
198
198
 
199
199
  export default AutoItem;
@@ -145,8 +145,9 @@ const AutoPanel = (props: IProps): JSX.Element => {
145
145
  }
146
146
  };
147
147
 
148
- const handleAddFilter = (newFilters: any[]) => {
149
- setState((state: IReferenceState) => ({ ...state, filter: newFilters }));
148
+ const handleAddFilter = (newFilters: any[], source: string) => {
149
+ const oldFilters = state.filter.filter((f: any) => f.source !== source);
150
+ setState((state: IReferenceState) => ({ ...state, filter: [...oldFilters, ...newFilters] }));
150
151
  };
151
152
 
152
153
  const quantityOptions = [
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import * as S from "./style";
4
4
 
5
5
  const ToggleField = (props: IToggleFieldProps): JSX.Element => {
6
- const { name, value, disabled, onChange } = props;
6
+ const { name, value, disabled, onChange, size = "m", background = false, auxText } = props;
7
7
 
8
8
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
9
9
  const isChecked = e.target.checked;
@@ -13,7 +13,7 @@ const ToggleField = (props: IToggleFieldProps): JSX.Element => {
13
13
  };
14
14
 
15
15
  return (
16
- <S.Wrapper data-testid="toggle-field-wrapper">
16
+ <S.Wrapper background={background} data-testid="toggle-field-wrapper">
17
17
  <S.Input
18
18
  id={`toggle-${name}`}
19
19
  type="checkbox"
@@ -24,7 +24,8 @@ const ToggleField = (props: IToggleFieldProps): JSX.Element => {
24
24
  onChange={handleChange}
25
25
  data-testid="toggle-field-input"
26
26
  />
27
- <S.Label htmlFor={`toggle-${name}`} />
27
+ <S.Label htmlFor={`toggle-${name}`} size={background ? "s" : size} />
28
+ {auxText && <S.AuxText data-testid="toggle-auxtext">{auxText}</S.AuxText>}
28
29
  </S.Wrapper>
29
30
  );
30
31
  };
@@ -34,6 +35,9 @@ export interface IToggleFieldProps {
34
35
  value: any;
35
36
  disabled?: boolean;
36
37
  onChange?: (value: boolean) => void;
38
+ size?: "s" | "m";
39
+ background?: boolean;
40
+ auxText?: string;
37
41
  }
38
42
 
39
43
  export default ToggleField;
@@ -1,6 +1,11 @@
1
1
  import styled from "styled-components";
2
2
 
3
- const Wrapper = styled.div``;
3
+ const Wrapper = styled.div<{ background: boolean | undefined }>`
4
+ background: ${(p) => (p.background ? p.theme.colors.uiBackground03 : "none")};
5
+ border-radius: ${(p) => (p.background ? p.theme.spacing.xxs : 0)};
6
+ padding: ${(p) => (p.background ? p.theme.spacing.s : 0)};
7
+ display: ${(p) => (p.background ? "flex" : "block")};
8
+ `;
4
9
 
5
10
  const Input = styled.input`
6
11
  display: none;
@@ -10,25 +15,26 @@ const Input = styled.input`
10
15
  }
11
16
 
12
17
  &:checked + Label {
13
- background: ${p => p.theme.color.interactive01};
18
+ background: ${(p) => p.theme.color.interactive01};
14
19
  }
15
20
 
16
21
  &:disabled + Label {
17
22
  pointer-events: none;
23
+ opacity: 40%;
18
24
  }
19
- `
25
+ `;
20
26
 
21
- const Label = styled.label`
27
+ const Label = styled.label<{ size?: string }>`
22
28
  box-sizing: border-box;
23
29
  outline: 0;
24
30
  display: block;
25
- width: 4em;
26
- height: 2em;
31
+ width: ${(p) => (p.size === "m" ? "4em" : "40px")};
32
+ height: ${(p) => (p.size === "m" ? "2em" : "18px")};
27
33
  position: relative;
28
34
  cursor: pointer;
29
- background: ${p => p.theme.color.interactiveDisabled};
30
- border-radius: 2em;
31
- padding: 4px;
35
+ background: ${(p) => p.theme.color.interactiveDisabled};
36
+ border-radius: ${(p) => (p.size === "m" ? "2em" : " 2em")};
37
+ padding: ${(p) => (p.size === "m" ? "4px" : " 2px")};
32
38
  transition: all 0.4s ease;
33
39
 
34
40
  &::selection {
@@ -37,17 +43,17 @@ const Label = styled.label`
37
43
 
38
44
  &:after {
39
45
  border-radius: 50%;
40
- background: ${p => p.theme.color.interactiveBackground};
46
+ background: ${(p) => p.theme.color.interactiveBackground};
41
47
  transition: all 0.2s ease;
42
48
  }
43
-
49
+
44
50
  &:after,
45
51
  &:before {
46
52
  position: relative;
47
53
  display: block;
48
54
  content: "";
49
- width: 42%;
50
- height: 100%;
55
+ width: ${(p) => (p.size === "m" ? "42%" : "14px")};
56
+ height: ${(p) => (p.size === "m" ? "100%" : "14px")};
51
57
  }
52
58
 
53
59
  &:after {
@@ -57,10 +63,12 @@ const Label = styled.label`
57
63
  &:before {
58
64
  display: none;
59
65
  }
60
- `
66
+ `;
67
+
68
+ const AuxText = styled.span`
69
+ ${(p) => p.theme.textStyle?.uiXS};
70
+ color: ${(p) => p.theme.colors.textMediumEmphasis};
71
+ padding-left: ${(p) => p.theme.spacing.xs};
72
+ `;
61
73
 
62
- export {
63
- Wrapper,
64
- Input,
65
- Label,
66
- };
74
+ export { Wrapper, Input, Label, AuxText };
@@ -1,6 +1,8 @@
1
1
  import styled from "styled-components";
2
2
 
3
- export const Label = styled.label<{ error: boolean | undefined }>`
3
+ export const Label = styled.label<{
4
+ error: boolean | undefined;
5
+ }>`
4
6
  ${(p) => p.theme.textStyle?.fieldLabel};
5
7
  color: ${(p) => (p.error === true ? p.theme.color?.error : p.theme.color?.textMediumEmphasis)};
6
8
  display: block;
@@ -19,8 +21,8 @@ export const HelpText = styled.div<{ error: boolean | undefined }>`
19
21
  export const Header = styled.div`
20
22
  position: absolute;
21
23
  left: 0;
22
- right: 0;
23
24
  top: 0;
25
+ right: 0;
24
26
  display: flex;
25
27
  justify-content: space-between;
26
28
  `;
@@ -40,6 +40,7 @@ const initialState = {
40
40
  type: "link",
41
41
  headerStyle: "",
42
42
  footerStyle: "",
43
+ itemSpecial: false,
43
44
  },
44
45
  totalItems: 0,
45
46
  };
@@ -60,4 +61,4 @@ function reducer(state = initialState, action: MenuActionsCreators): IMenuState
60
61
  }
61
62
  }
62
63
 
63
- export { initialState as menuInitialState, reducer as menuReducer };
64
+ export { initialState as menuInitialState, reducer as menuReducer };
@@ -55,6 +55,7 @@ const Item = (props: IItemProps): JSX.Element => {
55
55
  updateFormValue({ type });
56
56
  updateFormValue({ headerStyle });
57
57
  updateFormValue({ footerStyle });
58
+ updateFormValue({ itemSpecial: item.special || false });
58
59
  };
59
60
 
60
61
  const openModal = () => {
@@ -10,13 +10,14 @@ import { IRootState, IMenuForm, IImage } from "@ax/types";
10
10
  const Form = (props: IProps): JSX.Element => {
11
11
  const { form, updateForm, toggleSecondaryPanel, setIsGalleryOpened } = props;
12
12
 
13
- const { itemLink, itemLabel, itemAuxText, type, itemImage } = form;
13
+ const { itemLink, itemLabel, itemAuxText, type, itemImage, itemSpecial } = form;
14
14
 
15
15
  const setLinkValue = (value: any) => updateForm({ itemLink: value });
16
16
  const setLabelValue = (value: string) => updateForm({ itemLabel: value });
17
17
  const setAuxTextValue = (value: string) => updateForm({ itemAuxText: value });
18
18
  const setTypeValue = (value: string) => updateForm({ type: value });
19
19
  const setImageValue = (value: IImage) => updateForm({ itemImage: value });
20
+ const setSpecial = (value: boolean) => updateForm({ itemSpecial: value });
20
21
 
21
22
  const typeLinkOptions = [
22
23
  {
@@ -63,13 +64,6 @@ const Form = (props: IProps): JSX.Element => {
63
64
  />
64
65
  ) : (
65
66
  <>
66
- <FieldsBehavior
67
- title="Auxiliar Text"
68
- name="auxText"
69
- fieldType="TextArea"
70
- value={itemAuxText || ""}
71
- onChange={setAuxTextValue}
72
- />
73
67
  <FieldsBehavior
74
68
  title="Link"
75
69
  name="link"
@@ -80,6 +74,13 @@ const Form = (props: IProps): JSX.Element => {
80
74
  handlePanel={toggleSecondaryPanel}
81
75
  inFloatingPanel={true}
82
76
  />
77
+ <FieldsBehavior
78
+ title="Auxiliar Text"
79
+ name="auxText"
80
+ fieldType="TextArea"
81
+ value={itemAuxText || ""}
82
+ onChange={setAuxTextValue}
83
+ />
83
84
  <FieldsBehavior
84
85
  title="Image"
85
86
  name="image"
@@ -89,6 +90,14 @@ const Form = (props: IProps): JSX.Element => {
89
90
  onChange={setImageValue}
90
91
  setIsGalleryOpened={setIsGalleryOpened}
91
92
  />
93
+ <FieldsBehavior
94
+ name="special"
95
+ fieldType="ToggleField"
96
+ value={itemSpecial}
97
+ onChange={setSpecial}
98
+ background
99
+ auxText="Check it if the link has a special behavior."
100
+ />
92
101
  </>
93
102
  )}
94
103
  </>
@@ -14,7 +14,7 @@ const SidePanel = (props: IProps): JSX.Element => {
14
14
  const { isOpen, isOpenedSecond, toggleModal, toggleSecondaryPanel, addMenuItem, updateMenuItem, item, edit, form } =
15
15
  props;
16
16
 
17
- const { itemLabel, itemLink, itemImage, itemAuxText, type, headerStyle, footerStyle } = form;
17
+ const { itemLabel, itemLink, itemImage, itemAuxText, type, headerStyle, footerStyle, itemSpecial } = form;
18
18
 
19
19
  const [isGalleryOpened, setIsGalleryOpened] = useState(false);
20
20
 
@@ -29,6 +29,7 @@ const SidePanel = (props: IProps): JSX.Element => {
29
29
  auxText: itemAuxText,
30
30
  component: "Menu",
31
31
  config: { type, headerStyle, footerStyle },
32
+ special: itemSpecial,
32
33
  };
33
34
 
34
35
  menuItem.children = edit && item ? item.children : [];
@@ -341,6 +341,7 @@ export interface IMenuItem {
341
341
  isExpanded?: boolean;
342
342
  config: IMenuItemConfig | null;
343
343
  parentEditorID?: number;
344
+ special: boolean;
344
345
  }
345
346
 
346
347
  export interface IMenuItemConfig {
@@ -357,6 +358,7 @@ export interface IMenuForm {
357
358
  type: string;
358
359
  headerStyle: string;
359
360
  footerStyle: string;
361
+ itemSpecial: boolean;
360
362
  }
361
363
 
362
364
  export interface IHeader {