@griddo/ax 11.10.13-rc.0 → 11.10.13-rc.1
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": "11.10.13-rc.
|
|
4
|
+
"version": "11.10.13-rc.1",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -217,5 +217,5 @@
|
|
|
217
217
|
"publishConfig": {
|
|
218
218
|
"access": "public"
|
|
219
219
|
},
|
|
220
|
-
"gitHead": "
|
|
220
|
+
"gitHead": "f5bb7e21bd1d985da6ebb2ddb0b21494861c935f"
|
|
221
221
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
|
3
3
|
|
|
4
4
|
import { Button, FieldsDivider } from "@ax/components";
|
|
5
|
-
import { ISite } from "@ax/types";
|
|
5
|
+
import type { ISite } from "@ax/types";
|
|
6
6
|
import { getDefaultSchema } from "@ax/helpers";
|
|
7
7
|
import ArrayFieldItem from "./ArrayFieldItem";
|
|
8
8
|
import ArrayFieldInline from "./ArrayFieldInline";
|
|
@@ -28,20 +28,24 @@ const ArrayFieldGroup = (props: IProps): JSX.Element => {
|
|
|
28
28
|
const [items, setItems] = useState<any[]>([]);
|
|
29
29
|
const [isOpen, setIsOpen] = useState<number | null>(null);
|
|
30
30
|
|
|
31
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: false positive
|
|
31
32
|
useEffect(() => {
|
|
32
33
|
const initialValue = value ? Object.values(value) : [];
|
|
33
|
-
const initialValueMapped = initialValue.map((val
|
|
34
|
+
const initialValueMapped = initialValue.map((val) => {
|
|
34
35
|
return val.id ? val : { id: uuidv4(), ...val };
|
|
35
36
|
});
|
|
36
37
|
setItems(initialValueMapped);
|
|
37
38
|
}, [editorID]);
|
|
38
39
|
|
|
39
40
|
const handleClick = () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
let newComponent = { id: uuidv4() };
|
|
42
|
+
if(selectedContent){
|
|
43
|
+
const defaultValues = getDefaultSchema(selectedContent.component);
|
|
44
|
+
newComponent =
|
|
45
|
+
!!defaultValues[objKey] && defaultValues[objKey].length
|
|
46
|
+
? { ...defaultValues[objKey][0], id: uuidv4() }
|
|
47
|
+
: newComponent;
|
|
48
|
+
}
|
|
45
49
|
|
|
46
50
|
const newItems = [...items, newComponent];
|
|
47
51
|
setItems(newItems);
|
|
@@ -72,40 +76,39 @@ const ArrayFieldGroup = (props: IProps): JSX.Element => {
|
|
|
72
76
|
<div>
|
|
73
77
|
<DividerComponent />
|
|
74
78
|
<div>
|
|
75
|
-
{items
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})}
|
|
79
|
+
{items?.map((item, index) => {
|
|
80
|
+
const handleFieldChange = (newValue: Record<string, unknown>) => handleChange(newValue, index);
|
|
81
|
+
return arrayType === "inline" ? (
|
|
82
|
+
<ArrayFieldInline
|
|
83
|
+
key={item.id}
|
|
84
|
+
fields={innerFields}
|
|
85
|
+
item={item}
|
|
86
|
+
index={index}
|
|
87
|
+
onChange={handleFieldChange}
|
|
88
|
+
handleDelete={handleDelete}
|
|
89
|
+
site={site}
|
|
90
|
+
disabled={disabled}
|
|
91
|
+
parentKey={objKey}
|
|
92
|
+
actions={actions}
|
|
93
|
+
/>
|
|
94
|
+
) : (
|
|
95
|
+
<ArrayFieldItem
|
|
96
|
+
key={item.id}
|
|
97
|
+
name={name}
|
|
98
|
+
fields={innerFields}
|
|
99
|
+
item={item}
|
|
100
|
+
index={index}
|
|
101
|
+
onChange={handleFieldChange}
|
|
102
|
+
handleDelete={handleDelete}
|
|
103
|
+
isOpen={isOpen}
|
|
104
|
+
setIsOpen={setIsOpen}
|
|
105
|
+
site={site}
|
|
106
|
+
disabled={disabled}
|
|
107
|
+
parentKey={objKey}
|
|
108
|
+
actions={actions}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
})}
|
|
109
112
|
</div>
|
|
110
113
|
<S.ButtonWrapper>
|
|
111
114
|
<Button type="button" onClick={handleClick} buttonStyle="line" disabled={disabled}>
|