@payloadcms/ui 3.47.0-canary.2 → 3.47.0-internal.b17506e
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/elements/ArrayAction/index.d.ts +0 -2
- package/dist/elements/ArrayAction/index.d.ts.map +1 -1
- package/dist/elements/ArrayAction/index.js +13 -37
- package/dist/elements/ArrayAction/index.js.map +1 -1
- package/dist/elements/DatePicker/index.scss +0 -1
- package/dist/elements/ReactSelect/ClearIndicator/index.scss +0 -1
- package/dist/elements/ReactSelect/DropdownIndicator/index.scss +0 -1
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +4 -4
- package/dist/fields/Array/ArrayRow.d.ts +0 -2
- package/dist/fields/Array/ArrayRow.d.ts.map +1 -1
- package/dist/fields/Array/ArrayRow.js +43 -49
- package/dist/fields/Array/ArrayRow.js.map +1 -1
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +44 -175
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/BlockRow.d.ts +0 -2
- package/dist/fields/Blocks/BlockRow.d.ts.map +1 -1
- package/dist/fields/Blocks/BlockRow.js +35 -41
- package/dist/fields/Blocks/BlockRow.js.map +1 -1
- package/dist/fields/Blocks/RowActions.d.ts +0 -2
- package/dist/fields/Blocks/RowActions.d.ts.map +1 -1
- package/dist/fields/Blocks/RowActions.js +26 -32
- package/dist/fields/Blocks/RowActions.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +348 -294
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/providers/LivePreview/index.d.ts +1 -1
- package/dist/providers/LivePreview/index.d.ts.map +1 -1
- package/dist/providers/LivePreview/index.js +2 -1
- package/dist/providers/LivePreview/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/formatDocTitle/index.d.ts.map +1 -1
- package/dist/utilities/formatDocTitle/index.js +0 -6
- package/dist/utilities/formatDocTitle/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/elements/ClipboardAction/ClipboardActionLabel.d.ts +0 -5
- package/dist/elements/ClipboardAction/ClipboardActionLabel.d.ts.map +0 -1
- package/dist/elements/ClipboardAction/ClipboardActionLabel.js +0 -44
- package/dist/elements/ClipboardAction/ClipboardActionLabel.js.map +0 -1
- package/dist/elements/ClipboardAction/clipboardUtilities.d.ts +0 -10
- package/dist/elements/ClipboardAction/clipboardUtilities.d.ts.map +0 -1
- package/dist/elements/ClipboardAction/clipboardUtilities.js +0 -53
- package/dist/elements/ClipboardAction/clipboardUtilities.js.map +0 -1
- package/dist/elements/ClipboardAction/index.d.ts +0 -20
- package/dist/elements/ClipboardAction/index.d.ts.map +0 -1
- package/dist/elements/ClipboardAction/index.js +0 -188
- package/dist/elements/ClipboardAction/index.js.map +0 -1
- package/dist/elements/ClipboardAction/isClipboardDataValid.d.ts +0 -10
- package/dist/elements/ClipboardAction/isClipboardDataValid.d.ts.map +0 -1
- package/dist/elements/ClipboardAction/isClipboardDataValid.js +0 -86
- package/dist/elements/ClipboardAction/isClipboardDataValid.js.map +0 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts +0 -14
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts.map +0 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js +0 -100
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js.map +0 -1
- package/dist/elements/ClipboardAction/types.d.ts +0 -45
- package/dist/elements/ClipboardAction/types.d.ts.map +0 -1
- package/dist/elements/ClipboardAction/types.js +0 -2
- package/dist/elements/ClipboardAction/types.js.map +0 -1
- package/dist/utilities/formatDocTitle/formatRelationshipTitle.d.ts +0 -2
- package/dist/utilities/formatDocTitle/formatRelationshipTitle.d.ts.map +0 -1
- package/dist/utilities/formatDocTitle/formatRelationshipTitle.js +0 -15
- package/dist/utilities/formatDocTitle/formatRelationshipTitle.js.map +0 -1
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
5
|
import { getTranslation } from '@payloadcms/translations';
|
|
5
|
-
import React, { Fragment, useCallback
|
|
6
|
-
import { toast } from 'sonner';
|
|
6
|
+
import React, { Fragment, useCallback } from 'react';
|
|
7
7
|
import { Banner } from '../../elements/Banner/index.js';
|
|
8
8
|
import { Button } from '../../elements/Button/index.js';
|
|
9
|
-
import { clipboardCopy, clipboardPaste } from '../../elements/ClipboardAction/clipboardUtilities.js';
|
|
10
|
-
import { ClipboardAction } from '../../elements/ClipboardAction/index.js';
|
|
11
|
-
import { mergeFormStateFromClipboard, reduceFormStateByPath } from '../../elements/ClipboardAction/mergeFormStateFromClipboard.js';
|
|
12
9
|
import { DraggableSortableItem } from '../../elements/DraggableSortable/DraggableSortableItem/index.js';
|
|
13
10
|
import { DraggableSortable } from '../../elements/DraggableSortable/index.js';
|
|
14
11
|
import { DrawerToggler } from '../../elements/Drawer/index.js';
|
|
@@ -25,43 +22,54 @@ import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
|
|
|
25
22
|
import { useLocale } from '../../providers/Locale/index.js';
|
|
26
23
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
27
24
|
import { scrollToID } from '../../utilities/scrollToID.js';
|
|
28
|
-
import './index.scss';
|
|
29
25
|
import { FieldDescription } from '../FieldDescription/index.js';
|
|
30
26
|
import { FieldError } from '../FieldError/index.js';
|
|
31
27
|
import { FieldLabel } from '../FieldLabel/index.js';
|
|
32
28
|
import { fieldBaseClass } from '../shared/index.js';
|
|
33
29
|
import { BlockRow } from './BlockRow.js';
|
|
34
30
|
import { BlocksDrawer } from './BlocksDrawer/index.js';
|
|
31
|
+
import './index.scss';
|
|
35
32
|
const baseClass = 'blocks-field';
|
|
36
33
|
const BlocksFieldComponent = props => {
|
|
34
|
+
const $ = _c(50);
|
|
37
35
|
const {
|
|
38
36
|
i18n,
|
|
39
37
|
t
|
|
40
38
|
} = useTranslation();
|
|
41
39
|
const {
|
|
42
|
-
field:
|
|
43
|
-
name,
|
|
44
|
-
type,
|
|
45
|
-
admin: {
|
|
46
|
-
className,
|
|
47
|
-
description,
|
|
48
|
-
isSortable = true
|
|
49
|
-
} = {},
|
|
50
|
-
blockReferences,
|
|
51
|
-
blocks,
|
|
52
|
-
label,
|
|
53
|
-
labels: labelsFromProps,
|
|
54
|
-
localized,
|
|
55
|
-
maxRows,
|
|
56
|
-
minRows: minRowsProp,
|
|
57
|
-
required
|
|
58
|
-
},
|
|
40
|
+
field: t0,
|
|
59
41
|
path: pathFromProps,
|
|
60
42
|
permissions,
|
|
61
43
|
readOnly,
|
|
62
44
|
schemaPath: schemaPathFromProps,
|
|
63
45
|
validate
|
|
64
46
|
} = props;
|
|
47
|
+
const {
|
|
48
|
+
name,
|
|
49
|
+
admin: t1,
|
|
50
|
+
blockReferences,
|
|
51
|
+
blocks,
|
|
52
|
+
label,
|
|
53
|
+
labels: labelsFromProps,
|
|
54
|
+
localized,
|
|
55
|
+
maxRows,
|
|
56
|
+
minRows: minRowsProp,
|
|
57
|
+
required
|
|
58
|
+
} = t0;
|
|
59
|
+
let t2;
|
|
60
|
+
if ($[0] !== t1) {
|
|
61
|
+
t2 = t1 === undefined ? {} : t1;
|
|
62
|
+
$[0] = t1;
|
|
63
|
+
$[1] = t2;
|
|
64
|
+
} else {
|
|
65
|
+
t2 = $[1];
|
|
66
|
+
}
|
|
67
|
+
const {
|
|
68
|
+
className,
|
|
69
|
+
description,
|
|
70
|
+
isSortable: t3
|
|
71
|
+
} = t2;
|
|
72
|
+
const isSortable = t3 === undefined ? true : t3;
|
|
65
73
|
const schemaPath = schemaPathFromProps ?? name;
|
|
66
74
|
const minRows = minRowsProp ?? required ? 1 : 0;
|
|
67
75
|
const {
|
|
@@ -70,378 +78,424 @@ const BlocksFieldComponent = props => {
|
|
|
70
78
|
const {
|
|
71
79
|
addFieldRow,
|
|
72
80
|
dispatchFields,
|
|
73
|
-
getFields,
|
|
74
81
|
moveFieldRow,
|
|
75
82
|
removeFieldRow,
|
|
76
|
-
replaceState,
|
|
77
83
|
setModified
|
|
78
84
|
} = useForm();
|
|
79
85
|
const {
|
|
80
86
|
code: locale
|
|
81
87
|
} = useLocale();
|
|
82
88
|
const {
|
|
83
|
-
config:
|
|
84
|
-
localization
|
|
85
|
-
},
|
|
89
|
+
config: t4,
|
|
86
90
|
config
|
|
87
91
|
} = useConfig();
|
|
88
|
-
const
|
|
92
|
+
const {
|
|
93
|
+
localization
|
|
94
|
+
} = t4;
|
|
95
|
+
const drawerSlug = useDrawerSlug("blocks-drawer");
|
|
89
96
|
const submitted = useFormSubmitted();
|
|
90
97
|
const labels = {
|
|
91
|
-
plural: t(
|
|
92
|
-
singular: t(
|
|
98
|
+
plural: t("fields:blocks"),
|
|
99
|
+
singular: t("fields:block"),
|
|
93
100
|
...labelsFromProps
|
|
94
101
|
};
|
|
95
|
-
|
|
102
|
+
let t5;
|
|
103
|
+
bb0: {
|
|
96
104
|
if (localization && localization.fallback) {
|
|
97
105
|
const defaultLocale = localization.defaultLocale;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return true;
|
|
101
|
-
})();
|
|
102
|
-
const clientBlocks = useMemo(() => {
|
|
103
|
-
if (!blockReferences) {
|
|
104
|
-
return blocks;
|
|
106
|
+
t5 = locale === defaultLocale;
|
|
107
|
+
break bb0;
|
|
105
108
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
t5 = true;
|
|
110
|
+
}
|
|
111
|
+
const editingDefaultLocale = t5;
|
|
112
|
+
let t6;
|
|
113
|
+
if ($[2] !== editingDefaultLocale || $[3] !== maxRows || $[4] !== minRows || $[5] !== required || $[6] !== validate) {
|
|
114
|
+
t6 = (value, options) => {
|
|
115
|
+
if (!editingDefaultLocale && value === null) {
|
|
116
|
+
return true;
|
|
111
117
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
if (typeof validate === "function") {
|
|
119
|
+
return validate(value, {
|
|
120
|
+
...options,
|
|
121
|
+
maxRows,
|
|
122
|
+
minRows,
|
|
123
|
+
required
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
$[2] = editingDefaultLocale;
|
|
128
|
+
$[3] = maxRows;
|
|
129
|
+
$[4] = minRows;
|
|
130
|
+
$[5] = required;
|
|
131
|
+
$[6] = validate;
|
|
132
|
+
$[7] = t6;
|
|
133
|
+
} else {
|
|
134
|
+
t6 = $[7];
|
|
135
|
+
}
|
|
136
|
+
const memoizedValidate = t6;
|
|
137
|
+
let t7;
|
|
138
|
+
if ($[8] !== memoizedValidate || $[9] !== pathFromProps) {
|
|
139
|
+
t7 = {
|
|
140
|
+
hasRows: true,
|
|
141
|
+
potentiallyStalePath: pathFromProps,
|
|
142
|
+
validate: memoizedValidate
|
|
143
|
+
};
|
|
144
|
+
$[8] = memoizedValidate;
|
|
145
|
+
$[9] = pathFromProps;
|
|
146
|
+
$[10] = t7;
|
|
147
|
+
} else {
|
|
148
|
+
t7 = $[10];
|
|
149
|
+
}
|
|
129
150
|
const {
|
|
130
|
-
customComponents:
|
|
131
|
-
AfterInput,
|
|
132
|
-
BeforeInput,
|
|
133
|
-
Description,
|
|
134
|
-
Error,
|
|
135
|
-
Label
|
|
136
|
-
} = {},
|
|
151
|
+
customComponents: t8,
|
|
137
152
|
disabled,
|
|
138
153
|
errorPaths,
|
|
139
154
|
path,
|
|
140
|
-
rows
|
|
155
|
+
rows: t9,
|
|
141
156
|
showError,
|
|
142
157
|
valid,
|
|
143
158
|
value: value_0
|
|
144
|
-
} = useField(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
rowIndex: rowIndex_1
|
|
175
|
-
});
|
|
176
|
-
}, [path, removeFieldRow]);
|
|
177
|
-
const moveRow = useCallback((moveFromIndex, moveToIndex) => {
|
|
178
|
-
moveFieldRow({
|
|
179
|
-
moveFromIndex,
|
|
180
|
-
moveToIndex,
|
|
181
|
-
path
|
|
182
|
-
});
|
|
183
|
-
}, [moveFieldRow, path]);
|
|
184
|
-
const toggleCollapseAll = useCallback(collapsed => {
|
|
185
|
-
const {
|
|
186
|
-
collapsedIDs,
|
|
187
|
-
updatedRows
|
|
188
|
-
} = toggleAllRows({
|
|
189
|
-
collapsed,
|
|
190
|
-
rows
|
|
191
|
-
});
|
|
192
|
-
dispatchFields({
|
|
193
|
-
type: 'SET_ALL_ROWS_COLLAPSED',
|
|
194
|
-
path,
|
|
195
|
-
updatedRows
|
|
196
|
-
});
|
|
197
|
-
setDocFieldPreferences(path, {
|
|
198
|
-
collapsed: collapsedIDs
|
|
199
|
-
});
|
|
200
|
-
}, [dispatchFields, path, rows, setDocFieldPreferences]);
|
|
201
|
-
const setCollapse = useCallback((rowID, collapsed_0) => {
|
|
202
|
-
const {
|
|
203
|
-
collapsedIDs: collapsedIDs_0,
|
|
204
|
-
updatedRows: updatedRows_0
|
|
205
|
-
} = extractRowsAndCollapsedIDs({
|
|
206
|
-
collapsed: collapsed_0,
|
|
207
|
-
rowID,
|
|
208
|
-
rows
|
|
209
|
-
});
|
|
210
|
-
dispatchFields({
|
|
211
|
-
type: 'SET_ROW_COLLAPSED',
|
|
212
|
-
path,
|
|
213
|
-
updatedRows: updatedRows_0
|
|
214
|
-
});
|
|
215
|
-
setDocFieldPreferences(path, {
|
|
216
|
-
collapsed: collapsedIDs_0
|
|
217
|
-
});
|
|
218
|
-
}, [dispatchFields, path, rows, setDocFieldPreferences]);
|
|
219
|
-
const copyRow = useCallback(rowIndex_2 => {
|
|
220
|
-
const clipboardResult = clipboardCopy({
|
|
221
|
-
type,
|
|
222
|
-
blocks: clientBlocks,
|
|
223
|
-
getDataToCopy: () => reduceFormStateByPath({
|
|
224
|
-
formState: {
|
|
225
|
-
...getFields()
|
|
226
|
-
},
|
|
159
|
+
} = useField(t7);
|
|
160
|
+
let t10;
|
|
161
|
+
if ($[11] !== t8) {
|
|
162
|
+
t10 = t8 === undefined ? {} : t8;
|
|
163
|
+
$[11] = t8;
|
|
164
|
+
$[12] = t10;
|
|
165
|
+
} else {
|
|
166
|
+
t10 = $[12];
|
|
167
|
+
}
|
|
168
|
+
const {
|
|
169
|
+
AfterInput,
|
|
170
|
+
BeforeInput,
|
|
171
|
+
Description,
|
|
172
|
+
Error,
|
|
173
|
+
Label
|
|
174
|
+
} = t10;
|
|
175
|
+
let t11;
|
|
176
|
+
if ($[13] !== t9) {
|
|
177
|
+
t11 = t9 === undefined ? [] : t9;
|
|
178
|
+
$[13] = t9;
|
|
179
|
+
$[14] = t11;
|
|
180
|
+
} else {
|
|
181
|
+
t11 = $[14];
|
|
182
|
+
}
|
|
183
|
+
const rows = t11;
|
|
184
|
+
let t12;
|
|
185
|
+
if ($[15] !== addFieldRow || $[16] !== path || $[17] !== schemaPath) {
|
|
186
|
+
t12 = (rowIndex, blockType) => {
|
|
187
|
+
addFieldRow({
|
|
188
|
+
blockType,
|
|
227
189
|
path,
|
|
228
|
-
rowIndex
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (typeof clipboardResult === 'string') {
|
|
235
|
-
toast.error(clipboardResult);
|
|
236
|
-
} else {
|
|
237
|
-
toast.success(t('general:copied'));
|
|
238
|
-
}
|
|
239
|
-
}, [clientBlocks, path, t, type, getFields]);
|
|
240
|
-
const pasteRow = useCallback(rowIndex_3 => {
|
|
241
|
-
const pasteArgs = {
|
|
242
|
-
onPaste: dataFromClipboard => {
|
|
243
|
-
const formState = {
|
|
244
|
-
...getFields()
|
|
245
|
-
};
|
|
246
|
-
const newState = mergeFormStateFromClipboard({
|
|
247
|
-
dataFromClipboard,
|
|
248
|
-
formState,
|
|
249
|
-
path,
|
|
250
|
-
rowIndex: rowIndex_3
|
|
251
|
-
});
|
|
252
|
-
replaceState(newState);
|
|
253
|
-
setModified(true);
|
|
254
|
-
},
|
|
255
|
-
path,
|
|
256
|
-
schemaBlocks: clientBlocks,
|
|
257
|
-
t
|
|
190
|
+
rowIndex,
|
|
191
|
+
schemaPath
|
|
192
|
+
});
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
scrollToID(`${path}-row-${rowIndex + 1}`);
|
|
195
|
+
}, 0);
|
|
258
196
|
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
197
|
+
$[15] = addFieldRow;
|
|
198
|
+
$[16] = path;
|
|
199
|
+
$[17] = schemaPath;
|
|
200
|
+
$[18] = t12;
|
|
201
|
+
} else {
|
|
202
|
+
t12 = $[18];
|
|
203
|
+
}
|
|
204
|
+
const addRow = t12;
|
|
205
|
+
let t13;
|
|
206
|
+
if ($[19] !== dispatchFields || $[20] !== path || $[21] !== setModified) {
|
|
207
|
+
t13 = rowIndex_0 => {
|
|
208
|
+
dispatchFields({
|
|
209
|
+
type: "DUPLICATE_ROW",
|
|
210
|
+
path,
|
|
211
|
+
rowIndex: rowIndex_0
|
|
212
|
+
});
|
|
213
|
+
setModified(true);
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
scrollToID(`${path}-row-${rowIndex_0 + 1}`);
|
|
216
|
+
}, 0);
|
|
267
217
|
};
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
218
|
+
$[19] = dispatchFields;
|
|
219
|
+
$[20] = path;
|
|
220
|
+
$[21] = setModified;
|
|
221
|
+
$[22] = t13;
|
|
222
|
+
} else {
|
|
223
|
+
t13 = $[22];
|
|
224
|
+
}
|
|
225
|
+
const duplicateRow = t13;
|
|
226
|
+
let t14;
|
|
227
|
+
if ($[23] !== path || $[24] !== removeFieldRow) {
|
|
228
|
+
t14 = rowIndex_1 => {
|
|
229
|
+
removeFieldRow({
|
|
230
|
+
path,
|
|
231
|
+
rowIndex: rowIndex_1
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
$[23] = path;
|
|
235
|
+
$[24] = removeFieldRow;
|
|
236
|
+
$[25] = t14;
|
|
237
|
+
} else {
|
|
238
|
+
t14 = $[25];
|
|
239
|
+
}
|
|
240
|
+
const removeRow = t14;
|
|
241
|
+
let t15;
|
|
242
|
+
if ($[26] !== moveFieldRow || $[27] !== path) {
|
|
243
|
+
t15 = (moveFromIndex, moveToIndex) => {
|
|
244
|
+
moveFieldRow({
|
|
245
|
+
moveFromIndex,
|
|
246
|
+
moveToIndex,
|
|
247
|
+
path
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
$[26] = moveFieldRow;
|
|
251
|
+
$[27] = path;
|
|
252
|
+
$[28] = t15;
|
|
253
|
+
} else {
|
|
254
|
+
t15 = $[28];
|
|
255
|
+
}
|
|
256
|
+
const moveRow = t15;
|
|
257
|
+
let t16;
|
|
258
|
+
if ($[29] !== dispatchFields || $[30] !== path || $[31] !== rows || $[32] !== setDocFieldPreferences) {
|
|
259
|
+
t16 = collapsed => {
|
|
260
|
+
const {
|
|
261
|
+
collapsedIDs,
|
|
262
|
+
updatedRows
|
|
263
|
+
} = toggleAllRows({
|
|
264
|
+
collapsed,
|
|
265
|
+
rows
|
|
266
|
+
});
|
|
267
|
+
dispatchFields({
|
|
268
|
+
type: "SET_ALL_ROWS_COLLAPSED",
|
|
269
|
+
path,
|
|
270
|
+
updatedRows
|
|
271
|
+
});
|
|
272
|
+
setDocFieldPreferences(path, {
|
|
273
|
+
collapsed: collapsedIDs
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
$[29] = dispatchFields;
|
|
277
|
+
$[30] = path;
|
|
278
|
+
$[31] = rows;
|
|
279
|
+
$[32] = setDocFieldPreferences;
|
|
280
|
+
$[33] = t16;
|
|
281
|
+
} else {
|
|
282
|
+
t16 = $[33];
|
|
283
|
+
}
|
|
284
|
+
const toggleCollapseAll = t16;
|
|
285
|
+
let t17;
|
|
286
|
+
if ($[34] !== dispatchFields || $[35] !== path || $[36] !== rows || $[37] !== setDocFieldPreferences) {
|
|
287
|
+
t17 = (rowID, collapsed_0) => {
|
|
288
|
+
const {
|
|
289
|
+
collapsedIDs: collapsedIDs_0,
|
|
290
|
+
updatedRows: updatedRows_0
|
|
291
|
+
} = extractRowsAndCollapsedIDs({
|
|
292
|
+
collapsed: collapsed_0,
|
|
293
|
+
rowID,
|
|
294
|
+
rows
|
|
295
|
+
});
|
|
296
|
+
dispatchFields({
|
|
297
|
+
type: "SET_ROW_COLLAPSED",
|
|
298
|
+
path,
|
|
299
|
+
updatedRows: updatedRows_0
|
|
300
|
+
});
|
|
301
|
+
setDocFieldPreferences(path, {
|
|
302
|
+
collapsed: collapsedIDs_0
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
$[34] = dispatchFields;
|
|
306
|
+
$[35] = path;
|
|
307
|
+
$[36] = rows;
|
|
308
|
+
$[37] = setDocFieldPreferences;
|
|
309
|
+
$[38] = t17;
|
|
310
|
+
} else {
|
|
311
|
+
t17 = $[38];
|
|
312
|
+
}
|
|
313
|
+
const setCollapse = t17;
|
|
276
314
|
const hasMaxRows = maxRows && rows.length >= maxRows;
|
|
277
315
|
const fieldErrorCount = errorPaths.length;
|
|
278
316
|
const fieldHasErrors = submitted && fieldErrorCount + (valid ? 0 : 1) > 0;
|
|
279
317
|
const showMinRows = rows.length < minRows || required && rows.length === 0;
|
|
280
318
|
const showRequired = readOnly && rows.length === 0;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
319
|
+
const t18 = fieldHasErrors ? `${baseClass}--has-error` : `${baseClass}--has-no-error`;
|
|
320
|
+
let t19;
|
|
321
|
+
if ($[39] !== className || $[40] !== t18) {
|
|
322
|
+
t19 = [fieldBaseClass, baseClass, className, t18].filter(Boolean);
|
|
323
|
+
$[39] = className;
|
|
324
|
+
$[40] = t18;
|
|
325
|
+
$[41] = t19;
|
|
326
|
+
} else {
|
|
327
|
+
t19 = $[41];
|
|
328
|
+
}
|
|
329
|
+
let t20;
|
|
330
|
+
if ($[42] !== Error || $[43] !== path || $[44] !== showError) {
|
|
331
|
+
t20 = showError && _jsx(RenderCustomComponent, {
|
|
285
332
|
CustomComponent: Error,
|
|
286
|
-
Fallback:
|
|
287
|
-
path
|
|
288
|
-
showError
|
|
333
|
+
Fallback: _jsx(FieldError, {
|
|
334
|
+
path,
|
|
335
|
+
showError
|
|
289
336
|
})
|
|
290
|
-
})
|
|
337
|
+
});
|
|
338
|
+
$[42] = Error;
|
|
339
|
+
$[43] = path;
|
|
340
|
+
$[44] = showError;
|
|
341
|
+
$[45] = t20;
|
|
342
|
+
} else {
|
|
343
|
+
t20 = $[45];
|
|
344
|
+
}
|
|
345
|
+
let t21;
|
|
346
|
+
if ($[46] !== fieldErrorCount || $[47] !== fieldHasErrors || $[48] !== i18n) {
|
|
347
|
+
t21 = fieldHasErrors && fieldErrorCount > 0 && _jsx(ErrorPill, {
|
|
348
|
+
count: fieldErrorCount,
|
|
349
|
+
i18n,
|
|
350
|
+
withMessage: true
|
|
351
|
+
});
|
|
352
|
+
$[46] = fieldErrorCount;
|
|
353
|
+
$[47] = fieldHasErrors;
|
|
354
|
+
$[48] = i18n;
|
|
355
|
+
$[49] = t21;
|
|
356
|
+
} else {
|
|
357
|
+
t21 = $[49];
|
|
358
|
+
}
|
|
359
|
+
return _jsxs("div", {
|
|
360
|
+
className: t19.join(" "),
|
|
361
|
+
id: `field-${path?.replace(/\./g, "__")}`,
|
|
362
|
+
children: [t20, _jsxs("header", {
|
|
291
363
|
className: `${baseClass}__header`,
|
|
292
|
-
children: [
|
|
364
|
+
children: [_jsxs("div", {
|
|
293
365
|
className: `${baseClass}__header-wrap`,
|
|
294
|
-
children: [
|
|
366
|
+
children: [_jsxs("div", {
|
|
295
367
|
className: `${baseClass}__heading-with-error`,
|
|
296
|
-
children: [
|
|
297
|
-
children:
|
|
368
|
+
children: [_jsx("h3", {
|
|
369
|
+
children: _jsx(RenderCustomComponent, {
|
|
298
370
|
CustomComponent: Label,
|
|
299
|
-
Fallback:
|
|
300
|
-
label
|
|
301
|
-
localized
|
|
302
|
-
path
|
|
303
|
-
required
|
|
371
|
+
Fallback: _jsx(FieldLabel, {
|
|
372
|
+
label,
|
|
373
|
+
localized,
|
|
374
|
+
path,
|
|
375
|
+
required
|
|
304
376
|
})
|
|
305
377
|
})
|
|
306
|
-
}),
|
|
307
|
-
|
|
308
|
-
i18n: i18n,
|
|
309
|
-
withMessage: true
|
|
310
|
-
})]
|
|
311
|
-
}), /*#__PURE__*/_jsxs("ul", {
|
|
378
|
+
}), t21]
|
|
379
|
+
}), rows.length > 0 && _jsxs("ul", {
|
|
312
380
|
className: `${baseClass}__header-actions`,
|
|
313
|
-
children: [
|
|
314
|
-
children:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
children: /*#__PURE__*/_jsx("button", {
|
|
323
|
-
className: `${baseClass}__header-action`,
|
|
324
|
-
onClick: () => toggleCollapseAll(false),
|
|
325
|
-
type: "button",
|
|
326
|
-
children: t('fields:showAll')
|
|
327
|
-
})
|
|
328
|
-
})]
|
|
329
|
-
}), /*#__PURE__*/_jsx("li", {
|
|
330
|
-
children: /*#__PURE__*/_jsx(ClipboardAction, {
|
|
331
|
-
blocks: clientBlocks,
|
|
381
|
+
children: [_jsx("li", {
|
|
382
|
+
children: _jsx("button", {
|
|
383
|
+
className: `${baseClass}__header-action`,
|
|
384
|
+
onClick: () => toggleCollapseAll(true),
|
|
385
|
+
type: "button",
|
|
386
|
+
children: t("fields:collapseAll")
|
|
387
|
+
})
|
|
388
|
+
}), _jsx("li", {
|
|
389
|
+
children: _jsx("button", {
|
|
332
390
|
className: `${baseClass}__header-action`,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
formState: {
|
|
337
|
-
...getFields()
|
|
338
|
-
},
|
|
339
|
-
path
|
|
340
|
-
}),
|
|
341
|
-
onPaste: pasteBlocks,
|
|
342
|
-
path: path,
|
|
343
|
-
type: type
|
|
391
|
+
onClick: () => toggleCollapseAll(false),
|
|
392
|
+
type: "button",
|
|
393
|
+
children: t("fields:showAll")
|
|
344
394
|
})
|
|
345
395
|
})]
|
|
346
396
|
})]
|
|
347
|
-
}),
|
|
397
|
+
}), _jsx(RenderCustomComponent, {
|
|
348
398
|
CustomComponent: Description,
|
|
349
|
-
Fallback:
|
|
350
|
-
description
|
|
351
|
-
path
|
|
399
|
+
Fallback: _jsx(FieldDescription, {
|
|
400
|
+
description,
|
|
401
|
+
path
|
|
352
402
|
})
|
|
353
403
|
})]
|
|
354
|
-
}), BeforeInput,
|
|
404
|
+
}), BeforeInput, _jsx(NullifyLocaleField, {
|
|
355
405
|
fieldValue: value_0,
|
|
356
|
-
localized
|
|
357
|
-
path
|
|
358
|
-
}), (rows.length > 0 || !valid && (showRequired || showMinRows)) &&
|
|
406
|
+
localized,
|
|
407
|
+
path
|
|
408
|
+
}), (rows.length > 0 || !valid && (showRequired || showMinRows)) && _jsxs(DraggableSortable, {
|
|
359
409
|
className: `${baseClass}__rows`,
|
|
360
|
-
ids: rows.map(
|
|
361
|
-
onDragEnd:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
410
|
+
ids: rows.map(_temp),
|
|
411
|
+
onDragEnd: t22 => {
|
|
412
|
+
const {
|
|
413
|
+
moveFromIndex: moveFromIndex_0,
|
|
414
|
+
moveToIndex: moveToIndex_0
|
|
415
|
+
} = t22;
|
|
416
|
+
return moveRow(moveFromIndex_0, moveToIndex_0);
|
|
417
|
+
},
|
|
365
418
|
children: [rows.map((row_0, i) => {
|
|
366
419
|
const {
|
|
367
420
|
blockType: blockType_0,
|
|
368
421
|
isLoading
|
|
369
422
|
} = row_0;
|
|
370
|
-
const blockConfig = config.blocksMap[blockType_0] ?? (blockReferences ?? blocks).find(
|
|
423
|
+
const blockConfig = config.blocksMap[blockType_0] ?? (blockReferences ?? blocks).find(block => typeof block !== "string" && block.slug === blockType_0);
|
|
371
424
|
if (blockConfig) {
|
|
372
425
|
const rowPath = `${path}.${i}`;
|
|
373
|
-
const rowErrorCount = errorPaths.filter(errorPath => errorPath.startsWith(rowPath +
|
|
374
|
-
return
|
|
426
|
+
const rowErrorCount = errorPaths.filter(errorPath => errorPath.startsWith(rowPath + ".")).length;
|
|
427
|
+
return _jsx(DraggableSortableItem, {
|
|
375
428
|
disabled: readOnly || disabled || !isSortable,
|
|
376
429
|
id: row_0.id,
|
|
377
|
-
children: draggableSortableItemProps =>
|
|
430
|
+
children: draggableSortableItemProps => _jsx(BlockRow, {
|
|
378
431
|
...draggableSortableItemProps,
|
|
379
|
-
addRow
|
|
432
|
+
addRow,
|
|
380
433
|
block: blockConfig,
|
|
381
434
|
blocks: blockReferences ?? blocks,
|
|
382
|
-
|
|
383
|
-
duplicateRow: duplicateRow,
|
|
435
|
+
duplicateRow,
|
|
384
436
|
errorCount: rowErrorCount,
|
|
385
437
|
fields: blockConfig.fields,
|
|
386
|
-
hasMaxRows
|
|
387
|
-
isLoading
|
|
388
|
-
isSortable
|
|
438
|
+
hasMaxRows,
|
|
439
|
+
isLoading,
|
|
440
|
+
isSortable,
|
|
389
441
|
Label: rows?.[i]?.customComponents?.RowLabel,
|
|
390
|
-
labels
|
|
391
|
-
moveRow
|
|
442
|
+
labels,
|
|
443
|
+
moveRow,
|
|
392
444
|
parentPath: path,
|
|
393
|
-
pasteRow: pasteRow,
|
|
394
445
|
path: rowPath,
|
|
395
|
-
permissions
|
|
446
|
+
permissions,
|
|
396
447
|
readOnly: readOnly || disabled,
|
|
397
|
-
removeRow
|
|
448
|
+
removeRow,
|
|
398
449
|
row: row_0,
|
|
399
450
|
rowCount: rows.length,
|
|
400
451
|
rowIndex: i,
|
|
401
452
|
schemaPath: schemaPath + blockConfig.slug,
|
|
402
|
-
setCollapse
|
|
453
|
+
setCollapse
|
|
403
454
|
})
|
|
404
455
|
}, row_0.id);
|
|
405
456
|
}
|
|
406
457
|
return null;
|
|
407
|
-
}), !editingDefaultLocale &&
|
|
408
|
-
children: [showMinRows &&
|
|
458
|
+
}), !editingDefaultLocale && _jsxs(React.Fragment, {
|
|
459
|
+
children: [showMinRows && _jsx(Banner, {
|
|
409
460
|
type: "error",
|
|
410
|
-
children: t(
|
|
461
|
+
children: t("validation:requiresAtLeast", {
|
|
411
462
|
count: minRows,
|
|
412
|
-
label: getTranslation(minRows > 1 ? labels.plural : labels.singular, i18n) || t(minRows > 1 ?
|
|
463
|
+
label: getTranslation(minRows > 1 ? labels.plural : labels.singular, i18n) || t(minRows > 1 ? "general:row" : "general:rows")
|
|
413
464
|
})
|
|
414
|
-
}), showRequired &&
|
|
415
|
-
children: t(
|
|
465
|
+
}), showRequired && _jsx(Banner, {
|
|
466
|
+
children: t("validation:fieldHasNo", {
|
|
416
467
|
label: getTranslation(labels.plural, i18n)
|
|
417
468
|
})
|
|
418
469
|
})]
|
|
419
470
|
})]
|
|
420
|
-
}), !hasMaxRows &&
|
|
421
|
-
children: [
|
|
471
|
+
}), !hasMaxRows && _jsxs(Fragment, {
|
|
472
|
+
children: [_jsx(DrawerToggler, {
|
|
422
473
|
className: `${baseClass}__drawer-toggler`,
|
|
423
474
|
disabled: readOnly || disabled,
|
|
424
475
|
slug: drawerSlug,
|
|
425
|
-
children:
|
|
476
|
+
children: _jsx(Button, {
|
|
426
477
|
buttonStyle: "icon-label",
|
|
427
478
|
disabled: readOnly || disabled,
|
|
428
479
|
el: "span",
|
|
429
480
|
icon: "plus",
|
|
430
481
|
iconPosition: "left",
|
|
431
482
|
iconStyle: "with-border",
|
|
432
|
-
children: t(
|
|
483
|
+
children: t("fields:addLabel", {
|
|
433
484
|
label: getTranslation(labels.singular, i18n)
|
|
434
485
|
})
|
|
435
486
|
})
|
|
436
|
-
}),
|
|
437
|
-
addRow
|
|
487
|
+
}), _jsx(BlocksDrawer, {
|
|
488
|
+
addRow,
|
|
438
489
|
addRowIndex: rows?.length || 0,
|
|
439
490
|
blocks: blockReferences ?? blocks,
|
|
440
|
-
drawerSlug
|
|
441
|
-
labels
|
|
491
|
+
drawerSlug,
|
|
492
|
+
labels
|
|
442
493
|
})]
|
|
443
494
|
}), AfterInput]
|
|
444
495
|
});
|
|
445
496
|
};
|
|
446
497
|
export const BlocksField = withCondition(BlocksFieldComponent);
|
|
498
|
+
function _temp(row) {
|
|
499
|
+
return row.id;
|
|
500
|
+
}
|
|
447
501
|
//# sourceMappingURL=index.js.map
|