@griddo/ax 1.63.5 → 1.64.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.
- package/config/griddo-config/cx-polyfills/builder.ssr.js +6 -0
- package/config/griddo-config/cx-polyfills/componentsBundle.js +4 -0
- package/config/{griddo-config.js → griddo-config/index.js} +36 -15
- package/config/griddo-config/ssrHelpers.js +47 -0
- package/config/jest/componentsMock.js +29 -0
- package/config/jest/fileMock.js +1 -0
- package/config/jest/setup.js +5 -0
- package/config/jest/styleMock.js +1 -0
- package/config/jest/test-utils.js +17 -0
- package/config/paths.js +36 -5
- package/config/webpack.config.js +1 -1
- package/config/webpackDevServer.config.js +4 -1
- package/config/webpackSchemas.config.js +4 -1
- package/package.json +33 -59
- package/scripts/build.js +9 -2
- package/src/__mocks__/reducers/analyticsState.tsx +14 -0
- package/src/__mocks__/reducers/pageEditor.tsx +30 -0
- package/src/api/sites.tsx +28 -6
- package/src/api/structuredData.tsx +1 -1
- package/src/api/users.tsx +5 -4
- package/src/components/ActionMenu/style.tsx +2 -0
- package/src/components/Browser/index.tsx +9 -5
- package/src/{modules/Content/PageItem/atoms.tsx → components/CategoryCell/index.tsx} +4 -6
- package/src/components/CategoryCell/style.tsx +11 -0
- package/src/components/Fields/AnalyticsField/PageAnalytics/index.tsx +19 -19
- package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/atoms.tsx +26 -16
- package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/index.tsx +8 -13
- package/src/components/Fields/AnalyticsField/index.test.tsx +100 -0
- package/src/components/Fields/AnalyticsField/index.tsx +9 -2
- package/src/components/Fields/AnalyticsField/utils.tsx +2 -2
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/style.tsx +2 -1
- package/src/components/Fields/CheckField/index.test.tsx +95 -0
- package/src/components/Fields/CheckField/index.tsx +9 -3
- package/src/components/Fields/CheckField/style.tsx +32 -24
- package/src/components/Fields/CheckGroup/index.test.tsx +274 -0
- package/src/components/Fields/CheckGroup/index.tsx +2 -1
- package/src/components/Fields/FileField/FileDragAndDrop/style.tsx +3 -2
- package/src/components/Fields/FileField/style.tsx +2 -1
- package/src/components/Fields/MultiCheckSelect/style.tsx +18 -18
- package/src/components/Fields/NoteField/style.tsx +9 -9
- package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +1 -1
- package/src/components/Fields/Select/style.tsx +41 -37
- package/src/components/Fields/TagField/index.test.tsx +136 -0
- package/src/components/Fields/TagField/index.tsx +8 -12
- package/src/components/Fields/TextArea/index.test.tsx +69 -0
- package/src/components/Fields/TextArea/index.tsx +4 -13
- package/src/components/Fields/TextArea/style.tsx +2 -2
- package/src/components/Fields/TextField/index.test.tsx +144 -0
- package/src/components/Fields/TextField/index.tsx +23 -19
- package/src/components/Fields/TextField/style.tsx +16 -7
- package/src/components/Fields/UniqueCheck/index.test.tsx +43 -0
- package/src/components/Fields/UrlField/utils.tsx +8 -6
- package/src/components/FieldsBehavior/index.tsx +0 -2
- package/src/components/FieldsBehavior/style.tsx +21 -21
- package/src/components/Gallery/GalleryFilters/Orientation/style.tsx +2 -1
- package/src/components/Gallery/GalleryFilters/SortBy/style.tsx +2 -1
- package/src/components/Icon/index.tsx +12 -10
- package/src/components/IconAction/index.tsx +7 -1
- package/src/components/IconAction/style.tsx +10 -10
- package/src/components/SearchField/index.tsx +11 -8
- package/src/components/SearchField/style.tsx +21 -12
- package/src/components/TableFilters/CategoryFilter/index.tsx +1 -1
- package/src/components/TableFilters/CategoryFilter/style.tsx +2 -1
- package/src/components/TableFilters/DateFilter/style.tsx +2 -1
- package/src/components/TableFilters/LiveFilter/index.tsx +2 -2
- package/src/components/TableFilters/LiveFilter/style.tsx +2 -1
- package/src/components/TableFilters/NameFilter/style.tsx +2 -1
- package/src/components/TableFilters/SiteFilter/index.tsx +38 -24
- package/src/components/TableFilters/SiteFilter/style.tsx +2 -1
- package/src/components/TableFilters/StatusFilter/style.tsx +2 -1
- package/src/components/TableFilters/TranslationsFilter/style.tsx +2 -1
- package/src/components/TableFilters/TypeFilter/style.tsx +2 -1
- package/src/components/Tag/index.tsx +9 -7
- package/src/components/Tag/style.tsx +20 -8
- package/src/components/index.tsx +4 -2
- package/src/containers/App/reducer.tsx +0 -2
- package/src/containers/PageEditor/actions.tsx +2 -2
- package/src/containers/Sites/actions.tsx +30 -19
- package/src/containers/Users/actions.tsx +10 -2
- package/src/containers/Users/reducer.tsx +3 -1
- package/src/helpers/fields.tsx +2 -4
- package/src/helpers/index.tsx +3 -0
- package/src/helpers/themes.tsx +9 -0
- package/src/modules/Analytics/GroupPanel/utils.tsx +3 -3
- package/src/modules/App/Routing/NavMenu/index.tsx +13 -12
- package/src/modules/Content/PageItem/index.tsx +31 -9
- package/src/modules/Content/PageItem/style.tsx +0 -7
- package/src/modules/Content/atoms.tsx +78 -0
- package/src/modules/Content/index.tsx +104 -33
- package/src/modules/Content/style.tsx +10 -7
- package/src/modules/GlobalEditor/PageBrowser/index.tsx +0 -4
- package/src/modules/GlobalEditor/index.tsx +3 -3
- package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/DefaultsBrowser/index.tsx +0 -4
- package/src/modules/PageEditor/PageBrowser/index.tsx +0 -4
- package/src/modules/PageEditor/atoms.tsx +74 -0
- package/src/modules/PageEditor/index.tsx +30 -9
- package/src/modules/PageEditor/style.tsx +4 -0
- package/src/modules/PublicPreview/index.tsx +3 -5
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/TemplateBrowser/index.tsx +0 -4
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +2 -3
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +1 -1
- package/src/modules/Settings/Globals/index.tsx +3 -3
- package/src/modules/StructuredData/Form/index.tsx +2 -4
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +22 -18
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +3 -24
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +2 -2
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/style.tsx +0 -7
- package/src/modules/StructuredData/StructuredDataList/OptionTable/index.tsx +2 -4
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +46 -14
- package/src/modules/StructuredData/StructuredDataList/hooks.tsx +21 -9
- package/src/modules/StructuredData/StructuredDataList/index.tsx +48 -20
- package/src/modules/Users/Profile/index.tsx +12 -7
- package/src/modules/Users/UserCreate/SiteItem/index.tsx +44 -0
- package/src/modules/Users/UserCreate/SiteItem/style.tsx +30 -0
- package/src/modules/Users/UserCreate/index.tsx +120 -10
- package/src/modules/Users/UserCreate/style.tsx +54 -1
- package/src/modules/Users/UserEdit/index.tsx +53 -15
- package/src/modules/Users/UserForm/index.tsx +152 -5
- package/src/modules/Users/UserForm/style.tsx +40 -2
- package/src/modules/Users/UserList/BulkHeader/TableHeader/index.tsx +40 -2
- package/src/modules/Users/UserList/BulkHeader/TableHeader/style.tsx +0 -1
- package/src/modules/Users/UserList/BulkHeader/index.tsx +10 -1
- package/src/modules/Users/UserList/UserItem/index.tsx +70 -15
- package/src/modules/Users/UserList/hooks.tsx +58 -1
- package/src/modules/Users/UserList/index.tsx +80 -34
- package/src/modules/Users/index.tsx +18 -11
- package/src/routes/site.tsx +8 -0
- package/src/types/index.tsx +7 -0
- package/tsconfig.json +2 -0
- package/scripts/test.js +0 -45
|
@@ -2,38 +2,53 @@ import styled from "styled-components";
|
|
|
2
2
|
|
|
3
3
|
const Wrapper = styled.div``;
|
|
4
4
|
|
|
5
|
-
const Label = styled.label<{ disabled: boolean | undefined}>`
|
|
6
|
-
${p => p.theme.textStyle.fieldContent};
|
|
5
|
+
const Label = styled.label<{ disabled: boolean | undefined }>`
|
|
6
|
+
${(p) => p.theme.textStyle.fieldContent};
|
|
7
7
|
display: block;
|
|
8
8
|
position: relative;
|
|
9
|
-
padding-left: calc(${p => p.theme.spacing.s} + ${p => p.theme.spacing.xs});
|
|
10
|
-
margin-bottom: ${p => p.theme.spacing.xs};
|
|
9
|
+
padding-left: calc(${(p) => p.theme.spacing.s} + ${(p) => p.theme.spacing.xs});
|
|
10
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
11
11
|
cursor: pointer;
|
|
12
12
|
user-select: none;
|
|
13
|
-
color: ${p => p.disabled && p.theme.color.interactiveDisabled};
|
|
13
|
+
color: ${(p) => p.disabled && p.theme.color.interactiveDisabled};
|
|
14
14
|
`;
|
|
15
15
|
|
|
16
|
-
const CheckMark = styled.span<{
|
|
16
|
+
const CheckMark = styled.span<{
|
|
17
|
+
checked: boolean | undefined;
|
|
18
|
+
error: boolean | undefined;
|
|
19
|
+
indeterminate: boolean | undefined;
|
|
20
|
+
}>`
|
|
17
21
|
position: absolute;
|
|
18
22
|
top: 2px;
|
|
19
23
|
left: 0;
|
|
20
|
-
height: ${p => p.theme.spacing.s};
|
|
21
|
-
width: ${p => p.theme.spacing.s};
|
|
22
|
-
background-color: ${
|
|
23
|
-
|
|
24
|
+
height: ${(p) => p.theme.spacing.s};
|
|
25
|
+
width: ${(p) => p.theme.spacing.s};
|
|
26
|
+
background-color: ${(p) =>
|
|
27
|
+
p.checked || p.indeterminate
|
|
28
|
+
? p.error
|
|
29
|
+
? p.theme.color.error
|
|
30
|
+
: p.theme.color.interactive01
|
|
31
|
+
: p.theme.color.interactiveBackground};
|
|
32
|
+
border: 2px solid
|
|
33
|
+
${(p) =>
|
|
34
|
+
p.error
|
|
35
|
+
? p.theme.color.error
|
|
36
|
+
: p.checked || p.indeterminate
|
|
37
|
+
? p.theme.color.interactive01
|
|
38
|
+
: p.theme.color.interactiveInactive};
|
|
24
39
|
border-radius: 1.5px;
|
|
25
40
|
:after {
|
|
26
41
|
content: "";
|
|
27
42
|
position: absolute;
|
|
28
|
-
display: ${p => (p.checked || p.indeterminate ? `blocked` : `none`)};
|
|
43
|
+
display: ${(p) => (p.checked || p.indeterminate ? `blocked` : `none`)};
|
|
29
44
|
left: 3px;
|
|
30
45
|
top: -1px;
|
|
31
46
|
width: 4px;
|
|
32
47
|
height: 10px;
|
|
33
48
|
border: solid #ffffff;
|
|
34
49
|
color: white;
|
|
35
|
-
border-width: ${p => p.indeterminate ? "0 2px 0 0" : "0 2px 2px 0"};
|
|
36
|
-
transform: ${p => p.indeterminate ? "rotate(90deg)" : "rotate(45deg)"};
|
|
50
|
+
border-width: ${(p) => (p.indeterminate ? "0 2px 0 0" : "0 2px 2px 0")};
|
|
51
|
+
transform: ${(p) => (p.indeterminate ? "rotate(90deg)" : "rotate(45deg)")};
|
|
37
52
|
}
|
|
38
53
|
`;
|
|
39
54
|
|
|
@@ -44,8 +59,8 @@ const Input = styled.input`
|
|
|
44
59
|
height: 0;
|
|
45
60
|
width: 0;
|
|
46
61
|
:disabled ~ ${CheckMark} {
|
|
47
|
-
background-color: ${p => (p.checked ? p.theme.color.interactiveDisabled : p.theme.color.interactiveBackground)};
|
|
48
|
-
border: 2px solid ${p => p.theme.color.interactiveDisabled};
|
|
62
|
+
background-color: ${(p) => (p.checked ? p.theme.color.interactiveDisabled : p.theme.color.interactiveBackground)};
|
|
63
|
+
border: 2px solid ${(p) => p.theme.color.interactiveDisabled};
|
|
49
64
|
}
|
|
50
65
|
`;
|
|
51
66
|
|
|
@@ -54,14 +69,7 @@ const IconLabelWrapper = styled.div`
|
|
|
54
69
|
`;
|
|
55
70
|
|
|
56
71
|
const IconWrapper = styled.div`
|
|
57
|
-
padding-right: ${p => p.theme.spacing.xs};
|
|
72
|
+
padding-right: ${(p) => p.theme.spacing.xs};
|
|
58
73
|
`;
|
|
59
74
|
|
|
60
|
-
export {
|
|
61
|
-
Wrapper,
|
|
62
|
-
Label,
|
|
63
|
-
CheckMark,
|
|
64
|
-
Input,
|
|
65
|
-
IconLabelWrapper,
|
|
66
|
-
IconWrapper
|
|
67
|
-
};
|
|
75
|
+
export { Wrapper, Label, CheckMark, Input, IconLabelWrapper, IconWrapper };
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import CheckGroup 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 { Simulate } from "react-dom/test-utils";
|
|
8
|
+
import { render, cleanup, fireEvent, screen } from "@testing-library/react";
|
|
9
|
+
|
|
10
|
+
afterEach(cleanup);
|
|
11
|
+
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
value: "",
|
|
14
|
+
options: [],
|
|
15
|
+
onChange: jest.fn(),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe("CheckField component rendering", () => {
|
|
19
|
+
it("should render the component with no CheckField", () => {
|
|
20
|
+
render(
|
|
21
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
22
|
+
<CheckGroup {...defaultProps} />
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
expect(screen.findByTestId("CheckGroupFieldgroup")).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should render the component with CheckField", async () => {
|
|
30
|
+
const checkFieldOptions = [
|
|
31
|
+
{
|
|
32
|
+
name: "name 1",
|
|
33
|
+
value: 1,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "name 2",
|
|
37
|
+
value: 2,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
const props = {
|
|
41
|
+
value: "",
|
|
42
|
+
options: checkFieldOptions,
|
|
43
|
+
onChange: jest.fn(),
|
|
44
|
+
};
|
|
45
|
+
render(
|
|
46
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
47
|
+
<CheckGroup {...props} />
|
|
48
|
+
</ThemeProvider>
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
expect(screen.findByTestId("CheckGroupFieldgroup")).toBeTruthy();
|
|
52
|
+
expect(await screen.findAllByTestId("checkFieldLabel")).toHaveLength(2);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe("CheckField events", () => {
|
|
57
|
+
it("should call the onchange", async () => {
|
|
58
|
+
const checkFieldOptions = [
|
|
59
|
+
{
|
|
60
|
+
name: "name 1",
|
|
61
|
+
value: 1,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "name 2",
|
|
65
|
+
value: 2,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
const onChangeMock = jest.fn();
|
|
69
|
+
|
|
70
|
+
const props = {
|
|
71
|
+
value: "",
|
|
72
|
+
options: checkFieldOptions,
|
|
73
|
+
onChange: onChangeMock,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
render(
|
|
77
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
78
|
+
<CheckGroup {...props} />
|
|
79
|
+
</ThemeProvider>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
expect(screen.findByTestId("CheckGroupFieldgroup")).toBeTruthy();
|
|
83
|
+
expect(await screen.findAllByTestId("checkFieldLabel")).toHaveLength(2);
|
|
84
|
+
const checkFieldInput = await screen.queryAllByTestId<HTMLInputElement>("checkFieldInput");
|
|
85
|
+
fireEvent.change(checkFieldInput[0], {
|
|
86
|
+
target: { value: "name", checked: true },
|
|
87
|
+
});
|
|
88
|
+
expect(checkFieldInput[0].value).toBe("name");
|
|
89
|
+
expect(checkFieldInput[0].checked).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("should pass 'all' in the onchange call", async () => {
|
|
93
|
+
const checkFieldOptions = [
|
|
94
|
+
{
|
|
95
|
+
name: "all",
|
|
96
|
+
value: 1,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "surname",
|
|
100
|
+
value: 2,
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
const onChangeMock = jest.fn();
|
|
104
|
+
|
|
105
|
+
const props = {
|
|
106
|
+
value: "",
|
|
107
|
+
options: checkFieldOptions,
|
|
108
|
+
onChange: onChangeMock,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
render(
|
|
112
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
113
|
+
<CheckGroup {...props} />
|
|
114
|
+
</ThemeProvider>
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect(await screen.findAllByTestId("checkFieldLabel")).toHaveLength(2);
|
|
118
|
+
const checkFieldInput = await screen.queryAllByTestId<HTMLInputElement>("checkFieldInput");
|
|
119
|
+
fireEvent.change(checkFieldInput[0], {
|
|
120
|
+
target: { value: "all", checked: true },
|
|
121
|
+
});
|
|
122
|
+
expect(checkFieldInput[0].value).toBe("all");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("should pass 'all' selected in the onchange call when all options selected", async () => {
|
|
126
|
+
const checkFieldOptions = [
|
|
127
|
+
{
|
|
128
|
+
name: "all",
|
|
129
|
+
value: 1,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "name",
|
|
133
|
+
value: 2,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "surname",
|
|
137
|
+
value: 3,
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
const onChangeMock = jest.fn();
|
|
141
|
+
|
|
142
|
+
const props = {
|
|
143
|
+
value: [],
|
|
144
|
+
options: checkFieldOptions,
|
|
145
|
+
selectAllOption: "all",
|
|
146
|
+
onChange: onChangeMock,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
render(
|
|
150
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
151
|
+
<CheckGroup {...props} />
|
|
152
|
+
</ThemeProvider>
|
|
153
|
+
);
|
|
154
|
+
expect(await screen.findAllByTestId("checkFieldLabel")).toHaveLength(3);
|
|
155
|
+
const checkFieldInputs = await screen.queryAllByTestId("checkFieldInput");
|
|
156
|
+
fireEvent.change(checkFieldInputs[1], {
|
|
157
|
+
target: { value: "name", checked: true },
|
|
158
|
+
});
|
|
159
|
+
Simulate.change(checkFieldInputs[1]);
|
|
160
|
+
|
|
161
|
+
fireEvent.change(checkFieldInputs[2], {
|
|
162
|
+
target: { value: "surname", checked: true },
|
|
163
|
+
});
|
|
164
|
+
Simulate.change(checkFieldInputs[2]);
|
|
165
|
+
|
|
166
|
+
expect(onChangeMock).toHaveBeenCalledTimes(2);
|
|
167
|
+
expect(onChangeMock).toBeCalledWith(["all"]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("should pass two selected values in the onchange call", async () => {
|
|
171
|
+
const checkFieldOptions = [
|
|
172
|
+
{
|
|
173
|
+
name: "all",
|
|
174
|
+
value: 1,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "name",
|
|
178
|
+
value: 2,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "surname",
|
|
182
|
+
value: 3,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "surname 2",
|
|
186
|
+
value: 4,
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
const onChangeMock = jest.fn();
|
|
190
|
+
|
|
191
|
+
const props = {
|
|
192
|
+
value: [],
|
|
193
|
+
options: checkFieldOptions,
|
|
194
|
+
selectAllOption: "all",
|
|
195
|
+
onChange: onChangeMock,
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
render(
|
|
199
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
200
|
+
<CheckGroup {...props} />
|
|
201
|
+
</ThemeProvider>
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
expect(await screen.findAllByTestId("checkFieldLabel")).toHaveLength(4);
|
|
205
|
+
|
|
206
|
+
const checkFieldInputs = await screen.queryAllByTestId("checkFieldInput");
|
|
207
|
+
fireEvent.change(checkFieldInputs[1], {
|
|
208
|
+
target: { value: "name", checked: true },
|
|
209
|
+
});
|
|
210
|
+
Simulate.change(checkFieldInputs[1]);
|
|
211
|
+
expect(onChangeMock).toHaveBeenCalledTimes(1);
|
|
212
|
+
expect(onChangeMock).toBeCalledWith(["name"]);
|
|
213
|
+
|
|
214
|
+
fireEvent.change(checkFieldInputs[2], {
|
|
215
|
+
target: { value: "surname", checked: true },
|
|
216
|
+
});
|
|
217
|
+
Simulate.change(checkFieldInputs[2]);
|
|
218
|
+
expect(onChangeMock).toHaveBeenCalledTimes(2);
|
|
219
|
+
expect(onChangeMock).toBeCalledWith(["name", "surname"]);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("should return only one value in the onchange call", async () => {
|
|
223
|
+
const checkFieldOptions = [
|
|
224
|
+
{
|
|
225
|
+
name: "all",
|
|
226
|
+
value: 1,
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "name",
|
|
230
|
+
value: 2,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: "surname",
|
|
234
|
+
value: 3,
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "surname 2",
|
|
238
|
+
value: 4,
|
|
239
|
+
},
|
|
240
|
+
];
|
|
241
|
+
const onChangeMock = jest.fn();
|
|
242
|
+
|
|
243
|
+
const props = {
|
|
244
|
+
value: [],
|
|
245
|
+
options: checkFieldOptions,
|
|
246
|
+
multipleSelection: false,
|
|
247
|
+
onChange: onChangeMock,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
render(
|
|
251
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
252
|
+
<CheckGroup {...props} />
|
|
253
|
+
</ThemeProvider>
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
expect(await screen.findAllByTestId("checkFieldLabel")).toHaveLength(4);
|
|
257
|
+
|
|
258
|
+
const checkFieldInputs = await screen.queryAllByTestId("checkFieldInput");
|
|
259
|
+
fireEvent.change(checkFieldInputs[1], {
|
|
260
|
+
target: { value: "name", checked: true },
|
|
261
|
+
});
|
|
262
|
+
Simulate.change(checkFieldInputs[1]);
|
|
263
|
+
|
|
264
|
+
expect(onChangeMock).toHaveBeenCalledTimes(1);
|
|
265
|
+
expect(onChangeMock).toBeCalledWith(["name"]);
|
|
266
|
+
|
|
267
|
+
fireEvent.change(checkFieldInputs[2], {
|
|
268
|
+
target: { value: "surname", checked: true },
|
|
269
|
+
});
|
|
270
|
+
Simulate.change(checkFieldInputs[2]);
|
|
271
|
+
expect(onChangeMock).toHaveBeenCalledTimes(2);
|
|
272
|
+
expect(onChangeMock).toBeCalledWith(["surname"]);
|
|
273
|
+
});
|
|
274
|
+
});
|
|
@@ -38,6 +38,7 @@ const CheckGroup = (props: ICheckGroupProps): JSX.Element => {
|
|
|
38
38
|
const checks = options
|
|
39
39
|
? options.map((item: ICheckFieldProps) => (
|
|
40
40
|
<CheckField
|
|
41
|
+
data-testid="CheckGroupCheckfield"
|
|
41
42
|
key={item.name}
|
|
42
43
|
onChange={handleChange}
|
|
43
44
|
checked={valueArray.includes(item.name)}
|
|
@@ -51,7 +52,7 @@ const CheckGroup = (props: ICheckGroupProps): JSX.Element => {
|
|
|
51
52
|
))
|
|
52
53
|
: "";
|
|
53
54
|
|
|
54
|
-
return <S.FieldGroup>{checks}</S.FieldGroup>;
|
|
55
|
+
return <S.FieldGroup data-testid="CheckGroupFieldgroup">{checks}</S.FieldGroup>;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
interface ICheckGroupProps {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import styled from "styled-components";
|
|
2
3
|
import Button from "@ax/components/Button";
|
|
3
4
|
|
|
@@ -154,7 +155,7 @@ export const ErrorMsg = styled.div`
|
|
|
154
155
|
margin-top: ${(p) => p.theme.spacing.xxs};
|
|
155
156
|
`;
|
|
156
157
|
|
|
157
|
-
export const StyledButton = styled(Button)`
|
|
158
|
+
export const StyledButton = styled((props) => <Button {...props} />)`
|
|
158
159
|
margin-top: ${(p) => p.theme.spacing.s};
|
|
159
160
|
`;
|
|
160
161
|
|
|
@@ -162,7 +163,7 @@ export const FilesInput = styled.input<{ ref: any }>`
|
|
|
162
163
|
display: none;
|
|
163
164
|
`;
|
|
164
165
|
|
|
165
|
-
export const FilesButton = styled(Button).attrs((props: any) => ({
|
|
166
|
+
export const FilesButton = styled((props) => <Button {...props} />).attrs((props: any) => ({
|
|
166
167
|
ref: props.ref,
|
|
167
168
|
}))<{ ref: any }>`
|
|
168
169
|
margin-top: ${(p) => p.theme.spacing.xs};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import styled from "styled-components";
|
|
2
3
|
import ActionMenu from "@ax/components/ActionMenu";
|
|
3
4
|
|
|
@@ -54,7 +55,7 @@ const ComponentIconWrapper = styled.div`
|
|
|
54
55
|
margin-right: ${(p) => p.theme.spacing.xs};
|
|
55
56
|
`;
|
|
56
57
|
|
|
57
|
-
const StyledActionMenu = styled(ActionMenu)`
|
|
58
|
+
const StyledActionMenu = styled((props) => <ActionMenu {...props} />)`
|
|
58
59
|
opacity: 0;
|
|
59
60
|
width: 32px;
|
|
60
61
|
display: flex;
|
|
@@ -2,28 +2,28 @@ import styled from "styled-components";
|
|
|
2
2
|
|
|
3
3
|
const Wrapper = styled.div`
|
|
4
4
|
position: relative;
|
|
5
|
-
min-width: calc(${(p) => p.theme.spacing
|
|
6
|
-
max-width: calc(${(p) => p.theme.spacing
|
|
5
|
+
min-width: calc(${(p) => p.theme.spacing?.xl} * 2);
|
|
6
|
+
max-width: calc(${(p) => p.theme.spacing?.xl} * 6);
|
|
7
7
|
z-index: 2;
|
|
8
8
|
`;
|
|
9
9
|
|
|
10
|
-
const Field = styled.div<{isOpen: boolean}>`
|
|
10
|
+
const Field = styled.div<{ isOpen: boolean }>`
|
|
11
11
|
position: relative;
|
|
12
|
-
${(p) => p.theme.textStyle
|
|
13
|
-
color: ${(p) => p.theme.color
|
|
12
|
+
${(p) => p.theme.textStyle?.fieldContent};
|
|
13
|
+
color: ${(p) => p.theme.color?.textHighEmphasis};
|
|
14
14
|
display: flex;
|
|
15
15
|
width: 100%;
|
|
16
|
-
height: ${(p) => p.theme.spacing
|
|
17
|
-
background-color: ${p => p.theme.color
|
|
18
|
-
border: 1px solid ${p => p.isOpen ? p.theme.color
|
|
19
|
-
border-radius: ${p => p.theme.radii
|
|
16
|
+
height: ${(p) => p.theme.spacing?.l};
|
|
17
|
+
background-color: ${(p) => p.theme.color?.interactiveBackground};
|
|
18
|
+
border: 1px solid ${(p) => (p.isOpen ? p.theme.color?.interactive01 : p.theme.color?.uiLine)};
|
|
19
|
+
border-radius: ${(p) => p.theme.radii?.s};
|
|
20
20
|
align-items: center;
|
|
21
21
|
cursor: pointer;
|
|
22
|
-
padding: 0 ${p => p.theme.spacing
|
|
22
|
+
padding: 0 ${(p) => p.theme.spacing?.s};
|
|
23
23
|
|
|
24
24
|
:focus,
|
|
25
25
|
:active {
|
|
26
|
-
border: 1px solid ${p => p.theme.color
|
|
26
|
+
border: 1px solid ${(p) => p.theme.color?.interactive01};
|
|
27
27
|
outline: none;
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -32,7 +32,7 @@ const Field = styled.div<{isOpen: boolean}>`
|
|
|
32
32
|
right: 16px;
|
|
33
33
|
top: ${(p) => (p.isOpen ? `22px` : `18px`)};
|
|
34
34
|
content: "";
|
|
35
|
-
border: solid ${(p) => p.theme.color
|
|
35
|
+
border: solid ${(p) => p.theme.color?.interactive01};
|
|
36
36
|
border-width: 0 2px 2px 0;
|
|
37
37
|
display: inline-block;
|
|
38
38
|
padding: 3px;
|
|
@@ -41,19 +41,19 @@ const Field = styled.div<{isOpen: boolean}>`
|
|
|
41
41
|
`;
|
|
42
42
|
|
|
43
43
|
const DropDown = styled.div<{ floating?: boolean }>`
|
|
44
|
-
background-color: ${p => p.theme.color
|
|
45
|
-
border: 1px solid ${p => p.theme.color
|
|
46
|
-
border-radius: ${p => p.theme.radii
|
|
47
|
-
padding: ${p => `${p.theme.spacing
|
|
44
|
+
background-color: ${(p) => p.theme.color?.uiBarBackground};
|
|
45
|
+
border: 1px solid ${(p) => p.theme.color?.uiLine};
|
|
46
|
+
border-radius: ${(p) => p.theme.radii?.s};
|
|
47
|
+
padding: ${(p) => `${p.theme.spacing?.s} ${p.theme.spacing?.xs} ${p.theme.spacing?.xs} ${p.theme.spacing?.s}`};
|
|
48
48
|
width: 100%;
|
|
49
49
|
z-index: 2;
|
|
50
50
|
max-height: 130px;
|
|
51
51
|
overflow: auto;
|
|
52
|
-
position: ${(p) => p.floating ? "absolute" : "block"};
|
|
52
|
+
position: ${(p) => (p.floating ? "absolute" : "block")};
|
|
53
53
|
`;
|
|
54
54
|
|
|
55
55
|
const Asterisk = styled.span`
|
|
56
|
-
color: ${(p) => p.theme.color
|
|
56
|
+
color: ${(p) => p.theme.color?.error};
|
|
57
57
|
`;
|
|
58
58
|
|
|
59
59
|
export { Wrapper, Field, DropDown, Asterisk };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
|
|
3
3
|
const Wrapper = styled.div`
|
|
4
|
-
background-color: ${(p) => p.theme.color
|
|
5
|
-
padding: ${(p) => p.theme.spacing
|
|
6
|
-
border-radius: ${(p) => p.theme.radii
|
|
4
|
+
background-color: ${(p) => p.theme.color?.uiBackground03};
|
|
5
|
+
padding: ${(p) => p.theme.spacing?.s};
|
|
6
|
+
border-radius: ${(p) => p.theme.radii?.s};
|
|
7
7
|
`;
|
|
8
8
|
|
|
9
9
|
const Title = styled.div`
|
|
10
|
-
${(p) => p.theme.textStyle
|
|
11
|
-
color: ${(p) =>p.theme.color
|
|
12
|
-
margin-bottom: ${(p) => p.theme.spacing
|
|
10
|
+
${(p) => p.theme.textStyle?.headingXS};
|
|
11
|
+
color: ${(p) => p.theme.color?.textMediumEmphasis};
|
|
12
|
+
margin-bottom: ${(p) => p.theme.spacing?.xs};
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
15
|
const Text = styled.div`
|
|
16
|
-
${(p) => p.theme.textStyle
|
|
17
|
-
color: ${(p) =>p.theme.color
|
|
16
|
+
${(p) => p.theme.textStyle?.uiXS};
|
|
17
|
+
color: ${(p) => p.theme.color?.textMediumEmphasis};
|
|
18
18
|
`;
|
|
19
19
|
|
|
20
|
-
export { Wrapper, Title, Text }
|
|
20
|
+
export { Wrapper, Title, Text };
|
|
@@ -139,7 +139,7 @@ const AutoItem = (props: IProps) => {
|
|
|
139
139
|
const handleClick = () => {
|
|
140
140
|
handleDeleteTag(e.id);
|
|
141
141
|
};
|
|
142
|
-
return <Tag key={e.label} text={e.label}
|
|
142
|
+
return <Tag key={e.label} text={e.label} onDeleteAction={handleClick} />;
|
|
143
143
|
})}
|
|
144
144
|
</S.FiltersWrapper>
|
|
145
145
|
<S.ActionsFilterWrapper isOpen={state.isOpen}>
|