@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.
Files changed (83) hide show
  1. package/dist/elements/ArrayAction/index.d.ts +2 -0
  2. package/dist/elements/ArrayAction/index.d.ts.map +1 -1
  3. package/dist/elements/ArrayAction/index.js +37 -13
  4. package/dist/elements/ArrayAction/index.js.map +1 -1
  5. package/dist/elements/ClipboardAction/ClipboardActionLabel.d.ts +5 -0
  6. package/dist/elements/ClipboardAction/ClipboardActionLabel.d.ts.map +1 -0
  7. package/dist/elements/ClipboardAction/ClipboardActionLabel.js +44 -0
  8. package/dist/elements/ClipboardAction/ClipboardActionLabel.js.map +1 -0
  9. package/dist/elements/ClipboardAction/clipboardUtilities.d.ts +10 -0
  10. package/dist/elements/ClipboardAction/clipboardUtilities.d.ts.map +1 -0
  11. package/dist/elements/ClipboardAction/clipboardUtilities.js +53 -0
  12. package/dist/elements/ClipboardAction/clipboardUtilities.js.map +1 -0
  13. package/dist/elements/ClipboardAction/index.d.ts +21 -0
  14. package/dist/elements/ClipboardAction/index.d.ts.map +1 -0
  15. package/dist/elements/ClipboardAction/index.js +197 -0
  16. package/dist/elements/ClipboardAction/index.js.map +1 -0
  17. package/dist/elements/ClipboardAction/isClipboardDataValid.d.ts +10 -0
  18. package/dist/elements/ClipboardAction/isClipboardDataValid.d.ts.map +1 -0
  19. package/dist/elements/ClipboardAction/isClipboardDataValid.js +86 -0
  20. package/dist/elements/ClipboardAction/isClipboardDataValid.js.map +1 -0
  21. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts +14 -0
  22. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts.map +1 -0
  23. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js +100 -0
  24. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js.map +1 -0
  25. package/dist/elements/ClipboardAction/types.d.ts +45 -0
  26. package/dist/elements/ClipboardAction/types.d.ts.map +1 -0
  27. package/dist/elements/ClipboardAction/types.js +2 -0
  28. package/dist/elements/ClipboardAction/types.js.map +1 -0
  29. package/dist/elements/DatePicker/index.scss +18 -0
  30. package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts.map +1 -1
  31. package/dist/elements/PublishButton/ScheduleDrawer/index.js +10 -1
  32. package/dist/elements/PublishButton/ScheduleDrawer/index.js.map +1 -1
  33. package/dist/elements/ReactSelect/ClearIndicator/index.scss +1 -0
  34. package/dist/elements/ReactSelect/DropdownIndicator/index.scss +1 -0
  35. package/dist/exports/client/index.js +22 -22
  36. package/dist/exports/client/index.js.map +4 -4
  37. package/dist/exports/shared/index.js +2 -2
  38. package/dist/exports/shared/index.js.map +4 -4
  39. package/dist/fields/Array/ArrayRow.d.ts +2 -0
  40. package/dist/fields/Array/ArrayRow.d.ts.map +1 -1
  41. package/dist/fields/Array/ArrayRow.js +49 -43
  42. package/dist/fields/Array/ArrayRow.js.map +1 -1
  43. package/dist/fields/Array/index.d.ts.map +1 -1
  44. package/dist/fields/Array/index.js +176 -43
  45. package/dist/fields/Array/index.js.map +1 -1
  46. package/dist/fields/Array/index.scss +17 -3
  47. package/dist/fields/Blocks/BlockRow.d.ts +2 -0
  48. package/dist/fields/Blocks/BlockRow.d.ts.map +1 -1
  49. package/dist/fields/Blocks/BlockRow.js +41 -35
  50. package/dist/fields/Blocks/BlockRow.js.map +1 -1
  51. package/dist/fields/Blocks/RowActions.d.ts +2 -0
  52. package/dist/fields/Blocks/RowActions.d.ts.map +1 -1
  53. package/dist/fields/Blocks/RowActions.js +32 -26
  54. package/dist/fields/Blocks/RowActions.js.map +1 -1
  55. package/dist/fields/Blocks/index.d.ts.map +1 -1
  56. package/dist/fields/Blocks/index.js +295 -348
  57. package/dist/fields/Blocks/index.js.map +1 -1
  58. package/dist/fields/Hidden/index.js +19 -17
  59. package/dist/fields/Hidden/index.js.map +1 -1
  60. package/dist/forms/useField/index.d.ts.map +1 -1
  61. package/dist/forms/useField/index.js +1 -2
  62. package/dist/forms/useField/index.js.map +1 -1
  63. package/dist/providers/LivePreview/index.d.ts +1 -1
  64. package/dist/providers/LivePreview/index.d.ts.map +1 -1
  65. package/dist/providers/LivePreview/index.js +1 -2
  66. package/dist/providers/LivePreview/index.js.map +1 -1
  67. package/dist/styles.css +1 -1
  68. package/dist/utilities/buildFormState.js +1 -1
  69. package/dist/utilities/buildFormState.js.map +1 -1
  70. package/dist/utilities/buildTableState.js +1 -0
  71. package/dist/utilities/buildTableState.js.map +1 -1
  72. package/dist/utilities/formatDocTitle/formatRelationshipTitle.d.ts +2 -0
  73. package/dist/utilities/formatDocTitle/formatRelationshipTitle.d.ts.map +1 -0
  74. package/dist/utilities/formatDocTitle/formatRelationshipTitle.js +15 -0
  75. package/dist/utilities/formatDocTitle/formatRelationshipTitle.js.map +1 -0
  76. package/dist/utilities/formatDocTitle/index.d.ts.map +1 -1
  77. package/dist/utilities/formatDocTitle/index.js +6 -0
  78. package/dist/utilities/formatDocTitle/index.js.map +1 -1
  79. package/dist/views/Edit/Auth/APIKey.d.ts.map +1 -1
  80. package/dist/views/Edit/Auth/APIKey.js +27 -10
  81. package/dist/views/Edit/Auth/APIKey.js.map +1 -1
  82. package/dist/views/Edit/Auth/index.scss +31 -5
  83. 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: t0,
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: t4,
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("fields:blocks"),
99
- singular: t("fields:block"),
91
+ plural: t('fields:blocks'),
92
+ singular: t('fields:block'),
100
93
  ...labelsFromProps
101
94
  };
102
- let t5;
103
- bb0: {
95
+ const editingDefaultLocale = (() => {
104
96
  if (localization && localization.fallback) {
105
97
  const defaultLocale = localization.defaultLocale;
106
- t5 = locale === defaultLocale;
107
- break bb0;
98
+ return locale === defaultLocale;
108
99
  }
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;
117
- }
118
- if (typeof validate === "function") {
119
- return validate(value, {
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
- $[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
- }
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: t8,
130
+ customComponents: {
131
+ AfterInput,
132
+ BeforeInput,
133
+ Description,
134
+ Error,
135
+ Label
136
+ } = {},
152
137
  disabled,
153
138
  errorPaths,
154
139
  path,
155
- rows: t9,
140
+ rows = [],
156
141
  showError,
157
142
  valid,
158
143
  value: value_0
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,
189
- path,
190
- rowIndex,
191
- schemaPath
192
- });
193
- setTimeout(() => {
194
- scrollToID(`${path}-row-${rowIndex + 1}`);
195
- }, 0);
196
- };
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);
217
- };
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",
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
- updatedRows
271
- });
272
- setDocFieldPreferences(path, {
273
- collapsed: collapsedIDs
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
- $[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
- });
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
- $[34] = dispatchFields;
306
- $[35] = path;
307
- $[36] = rows;
308
- $[37] = setDocFieldPreferences;
309
- $[38] = t17;
310
- } else {
311
- t17 = $[38];
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
- 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, {
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
- }), t21]
379
- }), rows.length > 0 && _jsxs("ul", {
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: [_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", {
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
- onClick: () => toggleCollapseAll(false),
392
- type: "button",
393
- children: t("fields:showAll")
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(_temp),
411
- onDragEnd: t22 => {
412
- const {
413
- moveFromIndex: moveFromIndex_0,
414
- moveToIndex: moveToIndex_0
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(block => typeof block !== "string" && block.slug === blockType_0);
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 + ".")).length;
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
- duplicateRow,
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("validation:requiresAtLeast", {
411
+ children: t('validation:requiresAtLeast', {
462
412
  count: minRows,
463
- label: getTranslation(minRows > 1 ? labels.plural : labels.singular, i18n) || t(minRows > 1 ? "general:row" : "general:rows")
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("validation:fieldHasNo", {
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("fields:addLabel", {
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