@griddo/ax 11.4.23 → 11.4.24
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 +4 -4
- package/src/__tests__/components/Fields/ComponentContainer/ComponentContainer.test.tsx +10 -52
- package/src/components/ActionMenu/index.tsx +3 -2
- package/src/components/Fields/CheckField/style.tsx +16 -16
- package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +65 -49
- package/src/components/Fields/ComponentArray/SameComponentArray/index.tsx +89 -69
- package/src/components/Fields/ComponentContainer/index.tsx +11 -11
- package/src/components/Fields/ComponentContainer/style.tsx +12 -4
- package/src/components/Fields/ReferenceField/ItemList/Item/index.tsx +19 -9
- package/src/components/Fields/ReferenceField/ItemList/Item/style.tsx +24 -13
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +59 -41
- package/src/containers/StructuredData/actions.tsx +1 -1
- package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +71 -43
- package/src/modules/Categories/CategoriesList/CategoryItem/style.tsx +9 -1
- package/src/modules/Categories/CategoriesList/CategoryNav/index.tsx +0 -1
- package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +1 -0
- package/src/modules/Categories/CategoriesList/helpers.tsx +135 -94
- package/src/modules/Categories/CategoriesList/index.tsx +153 -157
- package/src/modules/Categories/CategoriesList/style.tsx +0 -3
- package/src/modules/FileDrive/FolderTree/MenuItem/index.tsx +83 -0
- package/src/modules/FileDrive/FolderTree/MenuItem/style.tsx +69 -0
- package/src/modules/FileDrive/FolderTree/MenuList/index.tsx +26 -0
- package/src/modules/FileDrive/FolderTree/index.tsx +12 -58
- package/src/modules/FileDrive/FolderTree/style.tsx +6 -27
- package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +11 -17
- package/src/modules/Forms/FormCategoriesList/CategoryItem/style.tsx +4 -1
- package/src/modules/Forms/FormCategoriesList/index.tsx +68 -53
- package/src/modules/Navigation/Menus/List/Table/Item/index.tsx +45 -16
- package/src/modules/Navigation/Menus/List/Table/Item/style.tsx +8 -3
- package/src/modules/Navigation/Menus/List/Table/helpers.tsx +132 -74
- package/src/modules/Navigation/Menus/List/Table/index.tsx +119 -86
- package/src/modules/Settings/Integrations/IntegrationItem/index.tsx +11 -11
- package/src/modules/Settings/Integrations/IntegrationItem/style.tsx +9 -1
- package/src/modules/Settings/Integrations/index.tsx +59 -56
- package/src/types/index.tsx +4 -5
- package/src/modules/FileDrive/FolderTree/utils.tsx +0 -91
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "11.4.
|
|
4
|
+
"version": "11.4.24",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"start:test": "env-cmd -f env/.env.development node scripts/dev.js"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@
|
|
42
|
+
"@dnd-kit/core": "6.3.1",
|
|
43
|
+
"@dnd-kit/sortable": "10.0.0",
|
|
43
44
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.16",
|
|
44
45
|
"@styled-system/prop-types": "5.1.5",
|
|
45
46
|
"@styled-system/theme-get": "5.1.2",
|
|
@@ -112,7 +113,6 @@
|
|
|
112
113
|
"postcss-safe-parser": "6.0.0",
|
|
113
114
|
"react": "18.2.0",
|
|
114
115
|
"react-app-polyfill": "1.0.6",
|
|
115
|
-
"react-beautiful-dnd": "13.1.1",
|
|
116
116
|
"react-datepicker": "4.25.0",
|
|
117
117
|
"react-dev-utils": "11.0.4",
|
|
118
118
|
"react-dom": "18.2.0",
|
|
@@ -224,5 +224,5 @@
|
|
|
224
224
|
"publishConfig": {
|
|
225
225
|
"access": "public"
|
|
226
226
|
},
|
|
227
|
-
"gitHead": "
|
|
227
|
+
"gitHead": "6ab8d7009d1dceabebdf975dc5bef4e3013d8624"
|
|
228
228
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
import { DraggableProvided, Draggable } from "react-beautiful-dnd";
|
|
4
3
|
import { ThemeProvider } from "styled-components";
|
|
5
4
|
import { mock } from "jest-mock-extended";
|
|
6
5
|
|
|
@@ -13,16 +12,6 @@ import ComponentContainer, { IComponentContainerProps } from "@ax/components/Fie
|
|
|
13
12
|
afterEach(cleanup);
|
|
14
13
|
const defaultProps = mock<IComponentContainerProps>();
|
|
15
14
|
|
|
16
|
-
jest.mock("react-beautiful-dnd", () => ({
|
|
17
|
-
Draggable: ({ children, draggableId, index }: any) =>
|
|
18
|
-
children(
|
|
19
|
-
{
|
|
20
|
-
innerRef: jest.fn(),
|
|
21
|
-
},
|
|
22
|
-
{}
|
|
23
|
-
),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
15
|
describe("ComponentContainer component rendering", () => {
|
|
27
16
|
afterEach(() => {
|
|
28
17
|
jest.resetAllMocks();
|
|
@@ -31,16 +20,13 @@ describe("ComponentContainer component rendering", () => {
|
|
|
31
20
|
defaultProps.text = "texto";
|
|
32
21
|
defaultProps.editorID = 1;
|
|
33
22
|
defaultProps.whiteList = ["BasicContent", "CardCollection"];
|
|
34
|
-
defaultProps.goTo = "/home";
|
|
35
23
|
defaultProps.arrayLength = 10;
|
|
36
24
|
defaultProps.theme = "default";
|
|
37
25
|
defaultProps.isArray = true;
|
|
38
26
|
defaultProps.disabled = false;
|
|
39
27
|
render(
|
|
40
28
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
41
|
-
<
|
|
42
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
43
|
-
</Draggable>
|
|
29
|
+
<ComponentContainer {...defaultProps} />
|
|
44
30
|
</ThemeProvider>
|
|
45
31
|
);
|
|
46
32
|
|
|
@@ -54,7 +40,6 @@ describe("ComponentContainer component rendering", () => {
|
|
|
54
40
|
// @ts-ignore
|
|
55
41
|
defaultProps.editorID = undefined;
|
|
56
42
|
defaultProps.whiteList = ["BasicContent", "CardCollection"];
|
|
57
|
-
defaultProps.goTo = "/home";
|
|
58
43
|
defaultProps.isArray = false;
|
|
59
44
|
defaultProps.arrayLength = 10;
|
|
60
45
|
defaultProps.theme = "default";
|
|
@@ -141,7 +126,6 @@ describe("ComponentContainer component rendering", () => {
|
|
|
141
126
|
test("should render the EmptyContainer with title", () => {
|
|
142
127
|
defaultProps.title = "a title";
|
|
143
128
|
defaultProps.whiteList = ["BasicContent", "CardCollection"];
|
|
144
|
-
defaultProps.goTo = "/home";
|
|
145
129
|
defaultProps.isArray = false;
|
|
146
130
|
defaultProps.arrayLength = 10;
|
|
147
131
|
defaultProps.theme = "default";
|
|
@@ -159,9 +143,7 @@ describe("ComponentContainer component rendering", () => {
|
|
|
159
143
|
defaultProps.objKey = "component";
|
|
160
144
|
render(
|
|
161
145
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
162
|
-
<
|
|
163
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
164
|
-
</Draggable>
|
|
146
|
+
<ComponentContainer {...defaultProps} />
|
|
165
147
|
</ThemeProvider>
|
|
166
148
|
);
|
|
167
149
|
expect(screen.getAllByTestId("field-multiple-options")).toBeTruthy();
|
|
@@ -170,7 +152,6 @@ describe("ComponentContainer component rendering", () => {
|
|
|
170
152
|
defaultProps.text = "texto a mostrar";
|
|
171
153
|
defaultProps.editorID = 1;
|
|
172
154
|
defaultProps.whiteList = ["BasicContent", "CardCollection"];
|
|
173
|
-
defaultProps.goTo = "/home";
|
|
174
155
|
defaultProps.isArray = false;
|
|
175
156
|
defaultProps.disabled = false;
|
|
176
157
|
defaultProps.arrayLength = 10;
|
|
@@ -253,9 +234,7 @@ describe("ComponentContainer component rendering", () => {
|
|
|
253
234
|
};
|
|
254
235
|
render(
|
|
255
236
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
256
|
-
<
|
|
257
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
258
|
-
</Draggable>
|
|
237
|
+
<ComponentContainer {...defaultProps} />
|
|
259
238
|
</ThemeProvider>
|
|
260
239
|
);
|
|
261
240
|
expect(screen.getByTestId("icon-wrapper")).toBeTruthy();
|
|
@@ -267,7 +246,6 @@ describe("ComponentContainer component rendering", () => {
|
|
|
267
246
|
defaultProps.moduleTitle = "module title";
|
|
268
247
|
defaultProps.editorID = 1;
|
|
269
248
|
defaultProps.whiteList = [];
|
|
270
|
-
defaultProps.goTo = "/home";
|
|
271
249
|
defaultProps.isArray = false;
|
|
272
250
|
defaultProps.disabled = false;
|
|
273
251
|
defaultProps.arrayLength = 10;
|
|
@@ -291,9 +269,7 @@ describe("ComponentContainer component rendering", () => {
|
|
|
291
269
|
|
|
292
270
|
render(
|
|
293
271
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
294
|
-
<
|
|
295
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
296
|
-
</Draggable>
|
|
272
|
+
<ComponentContainer {...defaultProps} />
|
|
297
273
|
</ThemeProvider>
|
|
298
274
|
);
|
|
299
275
|
expect(screen.findByText("module title")).toBeTruthy();
|
|
@@ -302,7 +278,6 @@ describe("ComponentContainer component rendering", () => {
|
|
|
302
278
|
test("should render the SideModal when click EmptyContainer", () => {
|
|
303
279
|
defaultProps.title = "a title";
|
|
304
280
|
defaultProps.whiteList = ["LinkImage", "Video"];
|
|
305
|
-
defaultProps.goTo = "/home";
|
|
306
281
|
defaultProps.isArray = false;
|
|
307
282
|
defaultProps.arrayLength = 2;
|
|
308
283
|
defaultProps.theme = "griddo-alt-theme";
|
|
@@ -325,9 +300,7 @@ describe("ComponentContainer component rendering", () => {
|
|
|
325
300
|
|
|
326
301
|
render(
|
|
327
302
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
328
|
-
<
|
|
329
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
330
|
-
</Draggable>
|
|
303
|
+
<ComponentContainer {...defaultProps} />
|
|
331
304
|
</ThemeProvider>
|
|
332
305
|
);
|
|
333
306
|
|
|
@@ -341,7 +314,6 @@ describe("ComponentContainer component rendering", () => {
|
|
|
341
314
|
test("should render component options on SideModal", () => {
|
|
342
315
|
defaultProps.title = "a title";
|
|
343
316
|
defaultProps.whiteList = ["LinkImage", "Video"];
|
|
344
|
-
defaultProps.goTo = "/home";
|
|
345
317
|
defaultProps.isArray = false;
|
|
346
318
|
defaultProps.arrayLength = 2;
|
|
347
319
|
defaultProps.theme = "griddo-alt-theme";
|
|
@@ -364,9 +336,7 @@ describe("ComponentContainer component rendering", () => {
|
|
|
364
336
|
|
|
365
337
|
render(
|
|
366
338
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
367
|
-
<
|
|
368
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
369
|
-
</Draggable>
|
|
339
|
+
<ComponentContainer {...defaultProps} />
|
|
370
340
|
</ThemeProvider>
|
|
371
341
|
);
|
|
372
342
|
|
|
@@ -383,7 +353,6 @@ describe("ComponentContainer component rendering", () => {
|
|
|
383
353
|
test("should render the FloatingMenu with options when click Component Container", async () => {
|
|
384
354
|
defaultProps.title = "a title";
|
|
385
355
|
defaultProps.whiteList = ["LinkImage", "Video"];
|
|
386
|
-
defaultProps.goTo = "/home";
|
|
387
356
|
defaultProps.isArray = false;
|
|
388
357
|
defaultProps.arrayLength = 2;
|
|
389
358
|
defaultProps.theme = "griddo-alt-theme";
|
|
@@ -412,9 +381,7 @@ test("should render the FloatingMenu with options when click Component Container
|
|
|
412
381
|
|
|
413
382
|
render(
|
|
414
383
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
415
|
-
<
|
|
416
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
417
|
-
</Draggable>
|
|
384
|
+
<ComponentContainer {...defaultProps} />
|
|
418
385
|
</ThemeProvider>
|
|
419
386
|
);
|
|
420
387
|
|
|
@@ -432,7 +399,6 @@ test("should render the FloatingMenu with options when click Component Container
|
|
|
432
399
|
test("should render the SideModal with options when click the replace action", async () => {
|
|
433
400
|
defaultProps.title = "a title";
|
|
434
401
|
defaultProps.whiteList = ["LinkImage", "Video"];
|
|
435
|
-
defaultProps.goTo = "/home";
|
|
436
402
|
defaultProps.isArray = false;
|
|
437
403
|
defaultProps.arrayLength = 2;
|
|
438
404
|
defaultProps.theme = "griddo-alt-theme";
|
|
@@ -461,9 +427,7 @@ test("should render the SideModal with options when click the replace action", a
|
|
|
461
427
|
|
|
462
428
|
render(
|
|
463
429
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
464
|
-
<
|
|
465
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
466
|
-
</Draggable>
|
|
430
|
+
<ComponentContainer {...defaultProps} />
|
|
467
431
|
</ThemeProvider>
|
|
468
432
|
);
|
|
469
433
|
|
|
@@ -489,7 +453,6 @@ test("should render the SideModal with options when click the replace action", a
|
|
|
489
453
|
test("should not render the drag handle if arrays length is lower than two", async () => {
|
|
490
454
|
defaultProps.title = "a title";
|
|
491
455
|
defaultProps.whiteList = ["LinkImage", "Video"];
|
|
492
|
-
defaultProps.goTo = "/home";
|
|
493
456
|
defaultProps.isArray = false;
|
|
494
457
|
defaultProps.arrayLength = 1;
|
|
495
458
|
defaultProps.theme = "griddo-alt-theme";
|
|
@@ -518,9 +481,7 @@ test("should not render the drag handle if arrays length is lower than two", asy
|
|
|
518
481
|
|
|
519
482
|
render(
|
|
520
483
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
521
|
-
<
|
|
522
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
523
|
-
</Draggable>
|
|
484
|
+
<ComponentContainer {...defaultProps} />
|
|
524
485
|
</ThemeProvider>
|
|
525
486
|
);
|
|
526
487
|
|
|
@@ -531,7 +492,6 @@ test("should not render the drag handle if arrays length is lower than two", asy
|
|
|
531
492
|
test("should render the drag handle if arrays length is greater than two", async () => {
|
|
532
493
|
defaultProps.title = "a title";
|
|
533
494
|
defaultProps.whiteList = ["LinkImage", "Video"];
|
|
534
|
-
defaultProps.goTo = "/home";
|
|
535
495
|
defaultProps.isArray = true;
|
|
536
496
|
defaultProps.arrayLength = 3;
|
|
537
497
|
defaultProps.theme = "griddo-alt-theme";
|
|
@@ -560,9 +520,7 @@ test("should render the drag handle if arrays length is greater than two", async
|
|
|
560
520
|
|
|
561
521
|
render(
|
|
562
522
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
563
|
-
<
|
|
564
|
-
{(provided: DraggableProvided) => <ComponentContainer {...defaultProps} provided={provided} />}
|
|
565
|
-
</Draggable>
|
|
523
|
+
<ComponentContainer {...defaultProps} />
|
|
566
524
|
</ThemeProvider>
|
|
567
525
|
);
|
|
568
526
|
|
|
@@ -6,13 +6,13 @@ import { IActionMenuOption } from "@ax/types";
|
|
|
6
6
|
import * as S from "./style";
|
|
7
7
|
|
|
8
8
|
const ActionMenu = (props: IActionMenuProps): JSX.Element => {
|
|
9
|
-
const { options, icon, className, tooltip } = props;
|
|
9
|
+
const { options, icon, className, tooltip, size } = props;
|
|
10
10
|
|
|
11
11
|
const filteredOptions = options.filter((option: IActionMenuOption | undefined | null) => !!option);
|
|
12
12
|
|
|
13
13
|
const MoreInfoButton = () => (
|
|
14
14
|
<S.IconActionWrapper data-testid="more-info-button">
|
|
15
|
-
<IconAction icon={icon} />
|
|
15
|
+
<IconAction icon={icon} size={size} />
|
|
16
16
|
</S.IconActionWrapper>
|
|
17
17
|
);
|
|
18
18
|
|
|
@@ -56,6 +56,7 @@ export interface IActionMenuProps {
|
|
|
56
56
|
icon: string;
|
|
57
57
|
className?: string;
|
|
58
58
|
tooltip?: string;
|
|
59
|
+
size?: "s" | "m";
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
export default ActionMenu;
|
|
@@ -13,8 +13,8 @@ const Label = styled.label<{ disabled: boolean | undefined; inversed: boolean; h
|
|
|
13
13
|
p.disabled
|
|
14
14
|
? p.theme.color.interactiveDisabled
|
|
15
15
|
: p.inversed
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
? p.theme.color.textHighEmphasisInverse
|
|
17
|
+
: p.theme.color.textHighEmphasis};
|
|
18
18
|
`;
|
|
19
19
|
|
|
20
20
|
const CheckMark = styled.span<{
|
|
@@ -32,21 +32,21 @@ const CheckMark = styled.span<{
|
|
|
32
32
|
p.error
|
|
33
33
|
? p.theme.color.error
|
|
34
34
|
: p.checked || p.indeterminate
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
? p.theme.color.interactive01
|
|
36
|
+
: p.inversed
|
|
37
|
+
? "transparent"
|
|
38
|
+
: p.theme.color.interactiveBackground};
|
|
39
39
|
border: 2px solid
|
|
40
40
|
${(p) =>
|
|
41
41
|
p.error
|
|
42
42
|
? p.theme.color.error
|
|
43
43
|
: p.checked || p.indeterminate
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
? p.theme.color.interactive01
|
|
45
|
+
: p.inversed
|
|
46
|
+
? p.theme.color.interactiveInverse
|
|
47
|
+
: p.theme.color.interactiveInactive};
|
|
48
48
|
border-radius: 1.5px;
|
|
49
|
-
|
|
49
|
+
&:after {
|
|
50
50
|
content: "";
|
|
51
51
|
position: absolute;
|
|
52
52
|
display: ${(p) => (p.checked || p.indeterminate ? `blocked` : `none`)};
|
|
@@ -66,15 +66,15 @@ const CheckMark = styled.span<{
|
|
|
66
66
|
p.error
|
|
67
67
|
? p.theme.color.error
|
|
68
68
|
: p.checked || p.indeterminate
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
? p.theme.color.interactive01
|
|
70
|
+
: p.theme.color.textLowEmphasis};
|
|
71
71
|
&:hover {
|
|
72
72
|
border-color: ${(p) =>
|
|
73
73
|
p.error
|
|
74
74
|
? p.theme.color.error
|
|
75
75
|
: p.checked || p.indeterminate
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
? p.theme.color.interactive01
|
|
77
|
+
: p.theme.color.interactiveInactive};
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
`;
|
|
@@ -85,7 +85,7 @@ const Input = styled.input`
|
|
|
85
85
|
cursor: pointer;
|
|
86
86
|
height: 0;
|
|
87
87
|
width: 0;
|
|
88
|
-
|
|
88
|
+
&:disabled ~ ${CheckMark} {
|
|
89
89
|
background-color: ${(p) => (p.checked ? p.theme.color.interactiveDisabled : p.theme.color.interactiveBackground)};
|
|
90
90
|
border: 2px solid ${(p) => p.theme.color.interactiveDisabled};
|
|
91
91
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
closestCenter,
|
|
4
|
+
DndContext,
|
|
5
|
+
DragEndEvent,
|
|
6
|
+
DragStartEvent,
|
|
7
|
+
PointerSensor,
|
|
8
|
+
useSensor,
|
|
9
|
+
useSensors,
|
|
10
|
+
} from "@dnd-kit/core";
|
|
11
|
+
import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
3
12
|
|
|
4
13
|
import { IModule, INotification, ISchemaField } from "@ax/types";
|
|
5
14
|
import { ComponentContainer, SideModal, Toast } from "@ax/components";
|
|
@@ -82,6 +91,14 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
|
|
|
82
91
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
92
|
}, [selectedItems.all]);
|
|
84
93
|
|
|
94
|
+
const sensors = useSensors(
|
|
95
|
+
useSensor(PointerSensor, {
|
|
96
|
+
activationConstraint: {
|
|
97
|
+
distance: 5,
|
|
98
|
+
},
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
|
|
85
102
|
const getText = (name: string, index: number) => {
|
|
86
103
|
return fixedValue.length > 1 ? `#${index + 1} ${name}` : name;
|
|
87
104
|
};
|
|
@@ -119,23 +136,23 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
|
|
|
119
136
|
|
|
120
137
|
const Asterisk = () => (mandatory ? <S.Asterisk>*</S.Asterisk> : null);
|
|
121
138
|
|
|
122
|
-
const ComponentList = React.memo(function ComponentList({ components }:
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
const ComponentList = React.memo(function ComponentList({ components }: { components: IModule[] }): JSX.Element {
|
|
140
|
+
return (
|
|
141
|
+
<>
|
|
142
|
+
{components.map((element: IModule, i: number) => {
|
|
143
|
+
const { editorID, fixed } = element;
|
|
144
|
+
const componentProps = getComponentProps(element, activatedModules, isModuleArr);
|
|
145
|
+
const { moduleTitle, isModuleDeactivated, componentTitle, displayName, isModule, isModuleDisabled } =
|
|
146
|
+
componentProps;
|
|
147
|
+
const text = getText(componentTitle || displayName, i);
|
|
148
|
+
const isItemSelected = isSelected(editorID);
|
|
149
|
+
const isDraggingSelected = selectedItems.all.includes(draggingId);
|
|
150
|
+
const isGhosting = isItemSelected && !!draggingId && draggingId !== editorID && isDraggingSelected;
|
|
151
|
+
const isMultiDragging = selectedItems.all.length > 1 && draggingId === editorID;
|
|
152
|
+
const isActive = scrollEditorID === editorID;
|
|
153
|
+
const canDelete = !isFormArr || !fixed;
|
|
154
|
+
|
|
155
|
+
return (
|
|
139
156
|
<ComponentContainer
|
|
140
157
|
actionReplace={toggleModal}
|
|
141
158
|
canReplace={canReplace}
|
|
@@ -155,45 +172,44 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
|
|
|
155
172
|
parentKey={objKey}
|
|
156
173
|
theme={theme}
|
|
157
174
|
arrayLength={components.length}
|
|
158
|
-
innerRef={provided.innerRef}
|
|
159
|
-
provided={provided}
|
|
160
175
|
isModule={isModule}
|
|
161
176
|
isSelected={isItemSelected}
|
|
162
177
|
onChange={addToBulkSelection}
|
|
163
178
|
hasMenu={selectedItems.all.length > 0}
|
|
164
179
|
toggleToast={toggleToast}
|
|
165
|
-
isMultiDragging={
|
|
180
|
+
isMultiDragging={isMultiDragging}
|
|
166
181
|
draggingCount={selectedItems.all.length}
|
|
167
182
|
isActive={selectedID === editorID}
|
|
168
|
-
className={`${isGhosting ? "ghosting" : ""} ${
|
|
169
|
-
isActive ? "active" : ""
|
|
170
|
-
}`}
|
|
183
|
+
className={`${isGhosting ? "ghosting" : ""} ${isMultiDragging ? "dragging" : ""} ${isActive ? "active" : ""}`}
|
|
171
184
|
/>
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
185
|
+
);
|
|
186
|
+
})}
|
|
187
|
+
</>
|
|
188
|
+
);
|
|
176
189
|
});
|
|
177
190
|
|
|
178
|
-
const
|
|
191
|
+
const handleDragStart = (event: DragStartEvent) => {
|
|
192
|
+
const { active } = event;
|
|
193
|
+
setDraggingId(active.id as number);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const handleOnDragEnd = (event: DragEndEvent) => {
|
|
197
|
+
const { active, over } = event;
|
|
179
198
|
const { moveModuleAction } = actions || {};
|
|
180
199
|
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
200
|
+
if (moveModuleAction && over && active.id !== over.id) {
|
|
201
|
+
const newIndex = fixedValue.map((e: IModule) => e.editorID).indexOf(over.id as number);
|
|
185
202
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
203
|
+
if (selectedItems.all.length > 0 && selectedItems.all.includes(active.id)) {
|
|
204
|
+
moveModuleAction(selectedItems.all, selectedContent, newIndex, objKey);
|
|
205
|
+
} else {
|
|
206
|
+
moveModuleAction([active.id as number], selectedContent, newIndex, objKey);
|
|
207
|
+
}
|
|
190
208
|
}
|
|
191
209
|
|
|
192
210
|
setDraggingId(null);
|
|
193
211
|
};
|
|
194
212
|
|
|
195
|
-
const onBeforeCapture = (start: BeforeCapture) => setDraggingId(parseInt(start.draggableId));
|
|
196
|
-
|
|
197
213
|
const handleCopy = () => {
|
|
198
214
|
const modulesCopied = copyModuleAction && copyModuleAction(selectedItems.all);
|
|
199
215
|
modulesCopied &&
|
|
@@ -288,16 +304,16 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
|
|
|
288
304
|
</S.ActionsWrapper>
|
|
289
305
|
</S.ItemRow>
|
|
290
306
|
{fixedValue && (
|
|
291
|
-
<
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
</
|
|
300
|
-
</
|
|
307
|
+
<DndContext
|
|
308
|
+
collisionDetection={closestCenter}
|
|
309
|
+
onDragEnd={handleOnDragEnd}
|
|
310
|
+
onDragStart={handleDragStart}
|
|
311
|
+
sensors={sensors}
|
|
312
|
+
>
|
|
313
|
+
<SortableContext items={componentIDs} strategy={verticalListSortingStrategy}>
|
|
314
|
+
<ComponentList components={fixedValue} />
|
|
315
|
+
</SortableContext>
|
|
316
|
+
</DndContext>
|
|
301
317
|
)}
|
|
302
318
|
{displayReplaceSideModal && isOpen && (
|
|
303
319
|
<SideModal
|