@byline/admin 3.16.0 → 3.16.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/dist/fields/array/array-field.d.ts +8 -1
- package/dist/fields/array/array-field.js +3 -1
- package/dist/fields/field-renderer.js +2 -0
- package/dist/fields/group/group-field.d.ts +7 -1
- package/dist/fields/group/group-field.js +2 -1
- package/package.json +5 -5
- package/src/fields/array/array-field.tsx +10 -0
- package/src/fields/field-renderer.tsx +2 -0
- package/src/fields/group/group-field.tsx +14 -1
|
@@ -6,11 +6,18 @@
|
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
8
|
import type { ArrayField as ArrayFieldType } from '@byline/core';
|
|
9
|
-
export declare const ArrayField: ({ field, defaultValue, path, disableSorting, contentLocale, }: {
|
|
9
|
+
export declare const ArrayField: ({ field, defaultValue, path, disableSorting, collectionPath, contentLocale, }: {
|
|
10
10
|
field: ArrayFieldType;
|
|
11
11
|
defaultValue: any;
|
|
12
12
|
path: string;
|
|
13
13
|
disableSorting?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Collection path forwarded to upload-capable fields (`file` / `image`)
|
|
16
|
+
* nested inside an array item, which need it to reach the `/upload`
|
|
17
|
+
* endpoint. Without it those fields fall back to their empty placeholder
|
|
18
|
+
* and never render an upload widget.
|
|
19
|
+
*/
|
|
20
|
+
collectionPath?: string;
|
|
14
21
|
/**
|
|
15
22
|
* Active content locale, forwarded to each array item's fields so
|
|
16
23
|
* localized widgets nested inside an array (e.g. a `localized` richText)
|
|
@@ -8,7 +8,7 @@ import { FieldRenderer } from "../field-renderer.js";
|
|
|
8
8
|
import { SortableItem } from "../sortable-item.js";
|
|
9
9
|
import { useFormContext } from "../../forms/form-context.js";
|
|
10
10
|
import array_field_module from "./array-field.module.js";
|
|
11
|
-
const ArrayField = ({ field, defaultValue, path, disableSorting = false, contentLocale })=>{
|
|
11
|
+
const ArrayField = ({ field, defaultValue, path, disableSorting = false, collectionPath, contentLocale })=>{
|
|
12
12
|
const { appendPatch, getFieldValue, getFieldValues, setFieldStore } = useFormContext();
|
|
13
13
|
const { t } = useTranslation('byline-admin');
|
|
14
14
|
const [items, setItems] = useState([]);
|
|
@@ -118,6 +118,7 @@ const ArrayField = ({ field, defaultValue, path, disableSorting = false, content
|
|
|
118
118
|
defaultValue: groupData[innerField.name],
|
|
119
119
|
basePath: `${arrayElementPath}.${childField.name}`,
|
|
120
120
|
disableSorting: true,
|
|
121
|
+
collectionPath: collectionPath,
|
|
121
122
|
contentLocale: contentLocale
|
|
122
123
|
}, innerField.name))
|
|
123
124
|
]
|
|
@@ -128,6 +129,7 @@ const ArrayField = ({ field, defaultValue, path, disableSorting = false, content
|
|
|
128
129
|
defaultValue: initial,
|
|
129
130
|
basePath: arrayElementPath,
|
|
130
131
|
disableSorting: true,
|
|
132
|
+
collectionPath: collectionPath,
|
|
131
133
|
contentLocale: contentLocale
|
|
132
134
|
}, childField.name);
|
|
133
135
|
});
|
|
@@ -180,6 +180,7 @@ const FieldRenderer = ({ field, defaultValue, basePath, disableSorting, hideLabe
|
|
|
180
180
|
} : field,
|
|
181
181
|
defaultValue: defaultValue,
|
|
182
182
|
path: path,
|
|
183
|
+
collectionPath: collectionPath,
|
|
183
184
|
contentLocale: contentLocale
|
|
184
185
|
});
|
|
185
186
|
case 'blocks':
|
|
@@ -197,6 +198,7 @@ const FieldRenderer = ({ field, defaultValue, basePath, disableSorting, hideLabe
|
|
|
197
198
|
defaultValue: defaultValue,
|
|
198
199
|
path: path,
|
|
199
200
|
disableSorting: disableSorting,
|
|
201
|
+
collectionPath: collectionPath,
|
|
200
202
|
contentLocale: contentLocale
|
|
201
203
|
});
|
|
202
204
|
default:
|
|
@@ -10,6 +10,12 @@ interface GroupFieldProps {
|
|
|
10
10
|
field: GroupFieldType;
|
|
11
11
|
defaultValue: any;
|
|
12
12
|
path: string;
|
|
13
|
+
/**
|
|
14
|
+
* Collection path forwarded to upload-capable child fields (`file` / `image`),
|
|
15
|
+
* which need it to reach the `/upload` endpoint. Without it those fields fall
|
|
16
|
+
* back to their empty placeholder and never render an upload widget.
|
|
17
|
+
*/
|
|
18
|
+
collectionPath?: string;
|
|
13
19
|
/**
|
|
14
20
|
* Active content locale, forwarded to child fields so localized widgets
|
|
15
21
|
* nested inside the group (e.g. a `localized` richText) can render their
|
|
@@ -17,5 +23,5 @@ interface GroupFieldProps {
|
|
|
17
23
|
*/
|
|
18
24
|
contentLocale?: string;
|
|
19
25
|
}
|
|
20
|
-
export declare const GroupField: ({ field, defaultValue, path, contentLocale }: GroupFieldProps) => import("react").JSX.Element;
|
|
26
|
+
export declare const GroupField: ({ field, defaultValue, path, collectionPath, contentLocale, }: GroupFieldProps) => import("react").JSX.Element;
|
|
21
27
|
export {};
|
|
@@ -6,7 +6,7 @@ import { placeholderForField } from "../field-helpers.js";
|
|
|
6
6
|
import { FieldRenderer } from "../field-renderer.js";
|
|
7
7
|
import { useFieldError } from "../../forms/form-context.js";
|
|
8
8
|
import group_field_module from "./group-field.module.js";
|
|
9
|
-
const GroupField = ({ field, defaultValue, path, contentLocale })=>{
|
|
9
|
+
const GroupField = ({ field, defaultValue, path, collectionPath, contentLocale })=>{
|
|
10
10
|
const fieldError = useFieldError(field.name);
|
|
11
11
|
const groupData = useMemo(()=>{
|
|
12
12
|
if (defaultValue && 'object' == typeof defaultValue && !Array.isArray(defaultValue)) return defaultValue;
|
|
@@ -47,6 +47,7 @@ const GroupField = ({ field, defaultValue, path, contentLocale })=>{
|
|
|
47
47
|
defaultValue: groupData[innerField.name],
|
|
48
48
|
basePath: path,
|
|
49
49
|
disableSorting: true,
|
|
50
|
+
collectionPath: collectionPath,
|
|
50
51
|
contentLocale: contentLocale
|
|
51
52
|
}, innerField.name))
|
|
52
53
|
}),
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@byline/admin",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"version": "3.16.
|
|
5
|
+
"version": "3.16.1",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0"
|
|
8
8
|
},
|
|
@@ -155,10 +155,10 @@
|
|
|
155
155
|
"react-diff-viewer-continued": "^4.2.2",
|
|
156
156
|
"uuid": "^14.0.0",
|
|
157
157
|
"zod": "^4.4.3",
|
|
158
|
-
"@byline/
|
|
159
|
-
"@byline/
|
|
160
|
-
"@byline/
|
|
161
|
-
"@byline/
|
|
158
|
+
"@byline/i18n": "3.16.1",
|
|
159
|
+
"@byline/core": "3.16.1",
|
|
160
|
+
"@byline/ui": "3.16.1",
|
|
161
|
+
"@byline/auth": "3.16.1"
|
|
162
162
|
},
|
|
163
163
|
"peerDependencies": {
|
|
164
164
|
"react": "^19.0.0",
|
|
@@ -29,12 +29,20 @@ export const ArrayField = ({
|
|
|
29
29
|
defaultValue,
|
|
30
30
|
path,
|
|
31
31
|
disableSorting = false,
|
|
32
|
+
collectionPath,
|
|
32
33
|
contentLocale,
|
|
33
34
|
}: {
|
|
34
35
|
field: ArrayFieldType
|
|
35
36
|
defaultValue: any
|
|
36
37
|
path: string
|
|
37
38
|
disableSorting?: boolean
|
|
39
|
+
/**
|
|
40
|
+
* Collection path forwarded to upload-capable fields (`file` / `image`)
|
|
41
|
+
* nested inside an array item, which need it to reach the `/upload`
|
|
42
|
+
* endpoint. Without it those fields fall back to their empty placeholder
|
|
43
|
+
* and never render an upload widget.
|
|
44
|
+
*/
|
|
45
|
+
collectionPath?: string
|
|
38
46
|
/**
|
|
39
47
|
* Active content locale, forwarded to each array item's fields so
|
|
40
48
|
* localized widgets nested inside an array (e.g. a `localized` richText)
|
|
@@ -205,6 +213,7 @@ export const ArrayField = ({
|
|
|
205
213
|
defaultValue={groupData[innerField.name]}
|
|
206
214
|
basePath={`${arrayElementPath}.${childField.name}`}
|
|
207
215
|
disableSorting={true}
|
|
216
|
+
collectionPath={collectionPath}
|
|
208
217
|
contentLocale={contentLocale}
|
|
209
218
|
/>
|
|
210
219
|
))}
|
|
@@ -219,6 +228,7 @@ export const ArrayField = ({
|
|
|
219
228
|
defaultValue={initial}
|
|
220
229
|
basePath={arrayElementPath}
|
|
221
230
|
disableSorting={true}
|
|
231
|
+
collectionPath={collectionPath}
|
|
222
232
|
contentLocale={contentLocale}
|
|
223
233
|
/>
|
|
224
234
|
)
|
|
@@ -254,6 +254,7 @@ export const FieldRenderer = ({
|
|
|
254
254
|
}
|
|
255
255
|
defaultValue={defaultValue}
|
|
256
256
|
path={path}
|
|
257
|
+
collectionPath={collectionPath}
|
|
257
258
|
contentLocale={contentLocale}
|
|
258
259
|
/>
|
|
259
260
|
)
|
|
@@ -275,6 +276,7 @@ export const FieldRenderer = ({
|
|
|
275
276
|
defaultValue={defaultValue}
|
|
276
277
|
path={path}
|
|
277
278
|
disableSorting={disableSorting}
|
|
279
|
+
collectionPath={collectionPath}
|
|
278
280
|
contentLocale={contentLocale}
|
|
279
281
|
/>
|
|
280
282
|
)
|
|
@@ -32,6 +32,12 @@ interface GroupFieldProps {
|
|
|
32
32
|
field: GroupFieldType
|
|
33
33
|
defaultValue: any
|
|
34
34
|
path: string
|
|
35
|
+
/**
|
|
36
|
+
* Collection path forwarded to upload-capable child fields (`file` / `image`),
|
|
37
|
+
* which need it to reach the `/upload` endpoint. Without it those fields fall
|
|
38
|
+
* back to their empty placeholder and never render an upload widget.
|
|
39
|
+
*/
|
|
40
|
+
collectionPath?: string
|
|
35
41
|
/**
|
|
36
42
|
* Active content locale, forwarded to child fields so localized widgets
|
|
37
43
|
* nested inside the group (e.g. a `localized` richText) can render their
|
|
@@ -40,7 +46,13 @@ interface GroupFieldProps {
|
|
|
40
46
|
contentLocale?: string
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
export const GroupField = ({
|
|
49
|
+
export const GroupField = ({
|
|
50
|
+
field,
|
|
51
|
+
defaultValue,
|
|
52
|
+
path,
|
|
53
|
+
collectionPath,
|
|
54
|
+
contentLocale,
|
|
55
|
+
}: GroupFieldProps) => {
|
|
44
56
|
const fieldError = useFieldError(field.name)
|
|
45
57
|
// Default value for a group field is a plain object: { rating: 5, comment: '...' }
|
|
46
58
|
// Normalize to a plain object if not already one.
|
|
@@ -80,6 +92,7 @@ export const GroupField = ({ field, defaultValue, path, contentLocale }: GroupFi
|
|
|
80
92
|
defaultValue={groupData[innerField.name]}
|
|
81
93
|
basePath={path}
|
|
82
94
|
disableSorting={true}
|
|
95
|
+
collectionPath={collectionPath}
|
|
83
96
|
contentLocale={contentLocale}
|
|
84
97
|
/>
|
|
85
98
|
)
|