@griddo/ax 1.75.255 → 1.75.256
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 +2 -2
- package/src/__tests__/components/Fields/TagField/TagField.test.tsx +34 -34
- package/src/__tests__/components/Gallery/GalleryPanel/DetailPanel/DetailPanel.test.tsx +4 -4
- package/src/components/Fields/{TagField → TagsField}/index.tsx +2 -2
- package/src/components/Fields/index.tsx +2 -2
- package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +1 -1
- package/src/schemas/pages/GlobalPage.tsx +1 -1
- package/src/schemas/pages/Page.tsx +1 -1
- /package/src/components/Fields/{TagField → TagsField}/style.tsx +0 -0
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.
|
|
4
|
+
"version": "1.75.256",
|
|
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": "
|
|
233
|
+
"gitHead": "5a8f1a970ca0b3eab2407b462004a3476c9f8abb"
|
|
234
234
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import TagsField from "@ax/components/Fields/TagsField";
|
|
3
3
|
import { ThemeProvider } from "styled-components";
|
|
4
4
|
import { parseTheme } from "@ax/helpers";
|
|
5
5
|
import globalTheme from "@ax/themes/theme.json";
|
|
@@ -12,21 +12,21 @@ const props = {
|
|
|
12
12
|
onChange: jest.fn(),
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
describe("
|
|
15
|
+
describe("TagsField component", () => {
|
|
16
16
|
test("should render the component", () => {
|
|
17
17
|
render(
|
|
18
18
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
19
|
-
<
|
|
19
|
+
<TagsField {...props} />
|
|
20
20
|
</ThemeProvider>
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
expect(
|
|
25
|
-
expect(
|
|
23
|
+
const tagsFieldWrapper = screen.getAllByTestId("tag-field-wrapper");
|
|
24
|
+
expect(tagsFieldWrapper).toBeTruthy();
|
|
25
|
+
expect(tagsFieldWrapper).toHaveLength(1);
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
expect(
|
|
29
|
-
expect(
|
|
27
|
+
const tagsFieldInput = screen.getAllByTestId("tag-field-input");
|
|
28
|
+
expect(tagsFieldInput).toBeTruthy();
|
|
29
|
+
expect(tagsFieldInput).toHaveLength(1);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test("should render the tags if have values", () => {
|
|
@@ -37,17 +37,17 @@ describe("TagField component", () => {
|
|
|
37
37
|
|
|
38
38
|
render(
|
|
39
39
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
40
|
-
<
|
|
40
|
+
<TagsField {...defaultProps} />
|
|
41
41
|
</ThemeProvider>
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
const
|
|
45
|
-
expect(
|
|
44
|
+
const tagsFieldWrapper = screen.getByTestId("tag-field-wrapper");
|
|
45
|
+
expect(tagsFieldWrapper).toBeTruthy();
|
|
46
46
|
|
|
47
|
-
const
|
|
48
|
-
expect(
|
|
47
|
+
const tagsFieldInput = screen.getByTestId("tag-field-input");
|
|
48
|
+
expect(tagsFieldInput).toBeTruthy();
|
|
49
49
|
|
|
50
|
-
const tagRendered = within(
|
|
50
|
+
const tagRendered = within(tagsFieldWrapper).getAllByTestId("delete-icon-wrapper");
|
|
51
51
|
expect(tagRendered).toHaveLength(2);
|
|
52
52
|
|
|
53
53
|
const tagComponent = screen.getByTestId("tag-field-wrapper");
|
|
@@ -55,17 +55,17 @@ describe("TagField component", () => {
|
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
describe("
|
|
58
|
+
describe("TagsField events", () => {
|
|
59
59
|
test("should call the value when call onchange", () => {
|
|
60
60
|
render(
|
|
61
61
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
62
|
-
<
|
|
62
|
+
<TagsField {...props} />
|
|
63
63
|
</ThemeProvider>
|
|
64
64
|
);
|
|
65
|
-
const
|
|
65
|
+
const TagsFieldInput = screen.getByTestId<HTMLInputElement>("tag-field-input");
|
|
66
66
|
|
|
67
|
-
fireEvent.change(
|
|
68
|
-
expect(
|
|
67
|
+
fireEvent.change(TagsFieldInput, { target: { value: "test" } });
|
|
68
|
+
expect(TagsFieldInput.value).toBe("test");
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
test("should add new value on keyDown if it's not in array", () => {
|
|
@@ -76,13 +76,13 @@ describe("TagField events", () => {
|
|
|
76
76
|
};
|
|
77
77
|
render(
|
|
78
78
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
79
|
-
<
|
|
79
|
+
<TagsField {...defaultProps} />
|
|
80
80
|
</ThemeProvider>
|
|
81
81
|
);
|
|
82
82
|
|
|
83
|
-
const
|
|
84
|
-
fireEvent.input(
|
|
85
|
-
fireEvent.keyDown(
|
|
83
|
+
const tagsFieldInput = screen.getByTestId<HTMLInputElement>("tag-field-input");
|
|
84
|
+
fireEvent.input(tagsFieldInput, { target: { value: "test" } });
|
|
85
|
+
fireEvent.keyDown(tagsFieldInput, { key: "Enter", code: "Enter", charCode: 13 });
|
|
86
86
|
expect(onChange).toHaveBeenCalledWith(["test"]);
|
|
87
87
|
});
|
|
88
88
|
test("shouldn't add new value on keyDown if it's in array", () => {
|
|
@@ -93,13 +93,13 @@ describe("TagField events", () => {
|
|
|
93
93
|
};
|
|
94
94
|
render(
|
|
95
95
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
96
|
-
<
|
|
96
|
+
<TagsField {...defaultProps} />
|
|
97
97
|
</ThemeProvider>
|
|
98
98
|
);
|
|
99
99
|
|
|
100
|
-
const
|
|
101
|
-
fireEvent.input(
|
|
102
|
-
fireEvent.keyDown(
|
|
100
|
+
const tagsFieldInput = screen.getByTestId<HTMLInputElement>("tag-field-input");
|
|
101
|
+
fireEvent.input(tagsFieldInput, { target: { value: "test" } });
|
|
102
|
+
fireEvent.keyDown(tagsFieldInput, { key: "Enter", code: "Enter", charCode: 13 });
|
|
103
103
|
expect(onChange).toBeCalledTimes(0);
|
|
104
104
|
});
|
|
105
105
|
test("should delete value from array", () => {
|
|
@@ -111,12 +111,12 @@ describe("TagField events", () => {
|
|
|
111
111
|
|
|
112
112
|
render(
|
|
113
113
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
114
|
-
<
|
|
114
|
+
<TagsField {...defaultProps} />
|
|
115
115
|
</ThemeProvider>
|
|
116
116
|
);
|
|
117
117
|
|
|
118
|
-
const
|
|
119
|
-
const tagRendered = within(
|
|
118
|
+
const tagsFieldWrapper = screen.getByTestId("tag-field-wrapper");
|
|
119
|
+
const tagRendered = within(tagsFieldWrapper).getAllByTestId("delete-icon-wrapper");
|
|
120
120
|
expect(tagRendered).toHaveLength(2);
|
|
121
121
|
fireEvent.click(tagRendered[0], 0);
|
|
122
122
|
expect(onChange).toBeCalledTimes(1);
|
|
@@ -126,11 +126,11 @@ describe("TagField events", () => {
|
|
|
126
126
|
const useRefSpy = jest.spyOn(React, "useRef").mockReturnValueOnce({ current: { focus: jest.fn() } });
|
|
127
127
|
render(
|
|
128
128
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
129
|
-
<
|
|
129
|
+
<TagsField {...props} />
|
|
130
130
|
</ThemeProvider>
|
|
131
131
|
);
|
|
132
|
-
const
|
|
133
|
-
fireEvent.click(
|
|
132
|
+
const tagsFieldWrapper = screen.getByTestId("tag-field-wrapper");
|
|
133
|
+
fireEvent.click(tagsFieldWrapper);
|
|
134
134
|
expect(useRefSpy).toBeCalledTimes(1);
|
|
135
135
|
});
|
|
136
136
|
});
|
|
@@ -843,11 +843,11 @@ describe("Gallery component rendering", () => {
|
|
|
843
843
|
|
|
844
844
|
expect(screen.getByDisplayValue("a description")).toBeInTheDocument();
|
|
845
845
|
|
|
846
|
-
const
|
|
847
|
-
expect(
|
|
848
|
-
fireEvent.change(
|
|
846
|
+
const tagsFieldInput = screen.getByTestId("tag-field-input");
|
|
847
|
+
expect(tagsFieldInput).toBeTruthy();
|
|
848
|
+
fireEvent.change(tagsFieldInput, { target: { value: "a tag" } });
|
|
849
849
|
expect(screen.getByDisplayValue("a tag")).toBeInTheDocument();
|
|
850
|
-
fireEvent.keyDown(
|
|
850
|
+
fireEvent.keyDown(tagsFieldInput, { key: "Enter" });
|
|
851
851
|
expect(screen.queryByDisplayValue("a tag")).not.toBeInTheDocument();
|
|
852
852
|
});
|
|
853
853
|
});
|
|
@@ -3,7 +3,7 @@ import { Tag } from "@ax/components";
|
|
|
3
3
|
|
|
4
4
|
import * as S from "./style";
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const TagsField = (props: IProps): JSX.Element => {
|
|
7
7
|
const { value, onChange } = props;
|
|
8
8
|
const valueArray = value && Array.isArray(value) ? value : [];
|
|
9
9
|
const [inputValue, setInputValue] = useState("");
|
|
@@ -61,4 +61,4 @@ interface IProps {
|
|
|
61
61
|
onChange: (value: string[]) => void;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export default
|
|
64
|
+
export default TagsField;
|
|
@@ -27,7 +27,7 @@ import RichText from "./RichText";
|
|
|
27
27
|
import Select from "./Select";
|
|
28
28
|
import SliderField from "./SliderField";
|
|
29
29
|
import SummaryButton from "./SummaryButton";
|
|
30
|
-
import
|
|
30
|
+
import TagsField from "./TagsField";
|
|
31
31
|
import TextArea from "./TextArea";
|
|
32
32
|
import TextField from "./TextField";
|
|
33
33
|
import TimeField from "./TimeField";
|
|
@@ -69,7 +69,7 @@ export {
|
|
|
69
69
|
Select,
|
|
70
70
|
SliderField,
|
|
71
71
|
SummaryButton,
|
|
72
|
-
|
|
72
|
+
TagsField,
|
|
73
73
|
TextArea,
|
|
74
74
|
TextField,
|
|
75
75
|
TimeField,
|
|
@@ -181,7 +181,7 @@ const GalleryDetailPanel = (props: IProps) => {
|
|
|
181
181
|
fieldType="TextArea"
|
|
182
182
|
onChange={handleDescription}
|
|
183
183
|
/>
|
|
184
|
-
<FieldsBehavior title="Tags" value={imageForm.tags} fieldType="
|
|
184
|
+
<FieldsBehavior title="Tags" value={imageForm.tags} fieldType="TagsField" onChange={handleTags} />
|
|
185
185
|
</S.FormWrapper>
|
|
186
186
|
</S.PanelForm>
|
|
187
187
|
);
|
|
File without changes
|