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