@payloadcms/next 3.20.0-canary.0e01b65 → 3.20.0-canary.296a49c

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 (110) hide show
  1. package/dist/prod/styles.css +1 -1
  2. package/dist/views/Account/index.d.ts.map +1 -1
  3. package/dist/views/Account/index.js +1 -2
  4. package/dist/views/Account/index.js.map +1 -1
  5. package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
  6. package/dist/views/CreateFirstUser/index.client.js +2 -4
  7. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  8. package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
  9. package/dist/views/CreateFirstUser/index.js +1 -2
  10. package/dist/views/CreateFirstUser/index.js.map +1 -1
  11. package/dist/views/Document/getDocumentPermissions.js +2 -2
  12. package/dist/views/Document/getDocumentPermissions.js.map +1 -1
  13. package/dist/views/Document/index.d.ts.map +1 -1
  14. package/dist/views/Document/index.js +1 -2
  15. package/dist/views/Document/index.js.map +1 -1
  16. package/dist/views/LivePreview/index.client.d.ts.map +1 -1
  17. package/dist/views/LivePreview/index.client.js +2 -5
  18. package/dist/views/LivePreview/index.client.js.map +1 -1
  19. package/dist/views/Version/Default/index.d.ts.map +1 -1
  20. package/dist/views/Version/Default/index.js +159 -89
  21. package/dist/views/Version/Default/index.js.map +1 -1
  22. package/dist/views/Version/Default/types.d.ts +4 -4
  23. package/dist/views/Version/Default/types.d.ts.map +1 -1
  24. package/dist/views/Version/Default/types.js.map +1 -1
  25. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.d.ts +2 -2
  26. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.d.ts.map +1 -1
  27. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js +31 -54
  28. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js.map +1 -1
  29. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.d.ts +3 -3
  30. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.d.ts.map +1 -1
  31. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js +35 -59
  32. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js.map +1 -1
  33. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts +2 -2
  34. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts.map +1 -1
  35. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +65 -97
  36. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
  37. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts +2 -1
  38. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts.map +1 -1
  39. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +15 -17
  40. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
  41. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.d.ts +2 -2
  42. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.d.ts.map +1 -1
  43. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js +24 -7
  44. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js.map +1 -1
  45. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts +2 -1
  46. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts.map +1 -1
  47. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +27 -56
  48. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
  49. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts +2 -1
  50. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts.map +1 -1
  51. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +80 -137
  52. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
  53. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts +2 -1
  54. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts.map +1 -1
  55. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +36 -71
  56. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
  57. package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts +22 -2
  58. package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts.map +1 -1
  59. package/dist/views/Version/RenderFieldsToDiff/fields/index.js +0 -2
  60. package/dist/views/Version/RenderFieldsToDiff/fields/index.js.map +1 -1
  61. package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts +21 -0
  62. package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts.map +1 -0
  63. package/dist/views/Version/RenderFieldsToDiff/fields/types.js +2 -0
  64. package/dist/views/Version/RenderFieldsToDiff/fields/types.js.map +1 -0
  65. package/dist/views/Version/RenderFieldsToDiff/index.d.ts +4 -2
  66. package/dist/views/Version/RenderFieldsToDiff/index.d.ts.map +1 -1
  67. package/dist/views/Version/RenderFieldsToDiff/index.js +111 -8
  68. package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
  69. package/dist/views/Version/RenderFieldsToDiff/types.d.ts +20 -2
  70. package/dist/views/Version/RenderFieldsToDiff/types.d.ts.map +1 -1
  71. package/dist/views/Version/RenderFieldsToDiff/types.js.map +1 -1
  72. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.d.ts.map +1 -1
  73. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js +1 -7
  74. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js.map +1 -1
  75. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.d.ts +3 -8
  76. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.d.ts.map +1 -1
  77. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js +3 -12
  78. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js.map +1 -1
  79. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js +9 -27
  80. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js.map +1 -1
  81. package/dist/views/Version/Restore/index.d.ts.map +1 -1
  82. package/dist/views/Version/Restore/index.js +2 -2
  83. package/dist/views/Version/Restore/index.js.map +1 -1
  84. package/dist/views/Version/SelectComparison/index.d.ts.map +1 -1
  85. package/dist/views/Version/SelectComparison/index.js +3 -7
  86. package/dist/views/Version/SelectComparison/index.js.map +1 -1
  87. package/dist/views/Version/index.d.ts.map +1 -1
  88. package/dist/views/Version/index.js +15 -117
  89. package/dist/views/Version/index.js.map +1 -1
  90. package/dist/views/Versions/getLatestVersion.d.ts +1 -4
  91. package/dist/views/Versions/getLatestVersion.d.ts.map +1 -1
  92. package/dist/views/Versions/getLatestVersion.js +0 -6
  93. package/dist/views/Versions/getLatestVersion.js.map +1 -1
  94. package/package.json +7 -7
  95. package/dist/views/Version/Default/SelectedLocalesContext.d.ts +0 -8
  96. package/dist/views/Version/Default/SelectedLocalesContext.d.ts.map +0 -1
  97. package/dist/views/Version/Default/SelectedLocalesContext.js +0 -10
  98. package/dist/views/Version/Default/SelectedLocalesContext.js.map +0 -1
  99. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.d.ts +0 -6
  100. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.d.ts.map +0 -1
  101. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js +0 -36
  102. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js.map +0 -1
  103. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts +0 -30
  104. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts.map +0 -1
  105. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +0 -300
  106. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +0 -1
  107. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.d.ts +0 -27
  108. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.d.ts.map +0 -1
  109. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.js +0 -30
  110. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.js.map +0 -1
@@ -1,300 +0,0 @@
1
- import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
2
- import { fieldIsID, getUniqueListBy, tabHasName } from 'payload/shared';
3
- import { diffMethods } from './fields/diffMethods.js';
4
- import { diffComponents } from './fields/index.js';
5
- import { getFieldPathsModified } from './utilities/getFieldPathsModified.js';
6
- /**
7
- * Build up an object that contains rendered diff components for each field.
8
- * This is then sent to the client to be rendered.
9
- *
10
- * Here, the server is responsible for traversing through the document data and building up this
11
- * version state object.
12
- */
13
- export const buildVersionFields = ({
14
- clientSchemaMap,
15
- comparisonSiblingData,
16
- customDiffComponents,
17
- entitySlug,
18
- fieldPermissions,
19
- fields,
20
- i18n,
21
- parentIndexPath,
22
- parentPath,
23
- parentSchemaPath,
24
- req,
25
- selectedLocales,
26
- versionSiblingData
27
- }) => {
28
- const versionFields = [];
29
- let fieldIndex = -1;
30
- for (const field of fields) {
31
- fieldIndex++;
32
- if (fieldIsID(field)) {
33
- continue;
34
- }
35
- const {
36
- indexPath,
37
- path,
38
- schemaPath
39
- } = getFieldPathsModified({
40
- field,
41
- index: fieldIndex,
42
- parentIndexPath: 'name' in field ? '' : parentIndexPath,
43
- parentPath,
44
- parentSchemaPath
45
- });
46
- const clientField = clientSchemaMap.get(entitySlug + '.' + schemaPath);
47
- if (!clientField) {
48
- req.payload.logger.error({
49
- clientFieldKey: entitySlug + '.' + schemaPath,
50
- clientSchemaMapKeys: Array.from(clientSchemaMap.keys()),
51
- msg: 'No client field found for ' + entitySlug + '.' + schemaPath,
52
- parentPath,
53
- parentSchemaPath,
54
- path,
55
- schemaPath
56
- });
57
- throw new Error('No client field found for ' + entitySlug + '.' + schemaPath);
58
- }
59
- const versionField = {
60
- type: field.type
61
- };
62
- const isLocalized = 'localized' in field && field.localized;
63
- const fieldName = 'name' in field ? field.name : null;
64
- const versionValue = fieldName ? versionSiblingData?.[fieldName] : versionSiblingData;
65
- const comparisonValue = fieldName ? comparisonSiblingData?.[fieldName] : comparisonSiblingData;
66
- if (isLocalized) {
67
- versionField.fieldByLocale = {};
68
- for (const locale of selectedLocales) {
69
- versionField.fieldByLocale[locale] = buildVersionField({
70
- clientField: clientField,
71
- clientSchemaMap,
72
- comparisonValue: comparisonValue?.[locale],
73
- customDiffComponents,
74
- entitySlug,
75
- field,
76
- fieldPermissions,
77
- i18n,
78
- indexPath,
79
- locale,
80
- parentPath,
81
- parentSchemaPath,
82
- path,
83
- req,
84
- schemaPath,
85
- selectedLocales,
86
- versionValue: versionValue?.[locale]
87
- });
88
- }
89
- } else {
90
- versionField.field = buildVersionField({
91
- clientField: clientField,
92
- clientSchemaMap,
93
- comparisonValue,
94
- customDiffComponents,
95
- entitySlug,
96
- field,
97
- fieldPermissions,
98
- i18n,
99
- indexPath,
100
- parentPath,
101
- parentSchemaPath,
102
- path,
103
- req,
104
- schemaPath,
105
- selectedLocales,
106
- versionValue
107
- });
108
- }
109
- versionFields.push(versionField);
110
- }
111
- return {
112
- versionFields
113
- };
114
- };
115
- const buildVersionField = ({
116
- clientField,
117
- clientSchemaMap,
118
- comparisonValue,
119
- customDiffComponents,
120
- entitySlug,
121
- field,
122
- fieldPermissions,
123
- i18n,
124
- indexPath,
125
- locale,
126
- parentPath,
127
- parentSchemaPath,
128
- path,
129
- req,
130
- schemaPath,
131
- selectedLocales,
132
- versionValue
133
- }) => {
134
- const fieldName = 'name' in field ? field.name : null;
135
- const diffMethod = diffMethods[field.type] || 'CHARS';
136
- const hasPermission = fieldPermissions === true || !fieldName || fieldPermissions?.[fieldName] === true || fieldPermissions?.[fieldName]?.read;
137
- const subFieldPermissions = fieldPermissions === true || !fieldName || fieldPermissions?.[fieldName] === true || fieldPermissions?.[fieldName]?.fields;
138
- if (!hasPermission) {
139
- return null;
140
- }
141
- const CustomComponent = field?.admin?.components?.Diff ?? customDiffComponents?.[field.type];
142
- const DefaultComponent = diffComponents?.[field.type];
143
- const baseVersionField = {
144
- fields: []
145
- };
146
- if (field.type === 'tabs' && 'tabs' in field) {
147
- baseVersionField.tabs = [];
148
- let tabIndex = -1;
149
- for (const tab of field.tabs) {
150
- tabIndex++;
151
- const isNamedTab = tabHasName(tab);
152
- const {
153
- indexPath: tabIndexPath,
154
- path: tabPath,
155
- schemaPath: tabSchemaPath
156
- } = getFieldPathsModified({
157
- field: {
158
- ...tab,
159
- type: 'tab'
160
- },
161
- index: tabIndex,
162
- parentIndexPath: indexPath,
163
- parentPath,
164
- parentSchemaPath
165
- });
166
- baseVersionField.tabs.push({
167
- name: 'name' in tab ? tab.name : null,
168
- fields: buildVersionFields({
169
- clientSchemaMap,
170
- comparisonSiblingData: 'name' in tab ? comparisonValue?.[tab.name] : comparisonValue,
171
- customDiffComponents,
172
- entitySlug,
173
- fieldPermissions,
174
- fields: tab.fields,
175
- i18n,
176
- parentIndexPath: isNamedTab ? '' : tabIndexPath,
177
- parentPath: tabPath,
178
- parentSchemaPath: tabSchemaPath,
179
- req,
180
- selectedLocales,
181
- versionSiblingData: 'name' in tab ? versionValue?.[tab.name] : versionValue
182
- }).versionFields,
183
- label: tab.label
184
- });
185
- }
186
- } else if ('fields' in field) {
187
- if (field.type === 'array') {
188
- if (!Array.isArray(versionValue)) {
189
- throw new Error('Expected versionValue to be an array');
190
- }
191
- baseVersionField.rows = [];
192
- for (let i = 0; i < versionValue.length; i++) {
193
- const comparisonRow = comparisonValue?.[i] || {};
194
- const versionRow = versionValue?.[i] || {};
195
- baseVersionField.rows[i] = buildVersionFields({
196
- clientSchemaMap,
197
- comparisonSiblingData: comparisonRow,
198
- customDiffComponents,
199
- entitySlug,
200
- fieldPermissions,
201
- fields: field.fields,
202
- i18n,
203
- parentIndexPath: 'name' in field ? '' : indexPath,
204
- parentPath: path + '.' + i,
205
- parentSchemaPath: schemaPath,
206
- req,
207
- selectedLocales,
208
- versionSiblingData: versionRow
209
- }).versionFields;
210
- }
211
- } else {
212
- baseVersionField.fields = buildVersionFields({
213
- clientSchemaMap,
214
- comparisonSiblingData: comparisonValue,
215
- customDiffComponents,
216
- entitySlug,
217
- fieldPermissions,
218
- fields: field.fields,
219
- i18n,
220
- parentIndexPath: 'name' in field ? '' : indexPath,
221
- parentPath: path,
222
- parentSchemaPath: schemaPath,
223
- req,
224
- selectedLocales,
225
- versionSiblingData: versionValue
226
- }).versionFields;
227
- }
228
- } else if (field.type === 'blocks') {
229
- baseVersionField.rows = [];
230
- if (!Array.isArray(versionValue)) {
231
- throw new Error('Expected versionValue to be an array');
232
- }
233
- for (let i = 0; i < versionValue.length; i++) {
234
- const comparisonRow = comparisonValue?.[i] || {};
235
- const versionRow = versionValue[i] || {};
236
- const versionBlock = field.blocks.find(block => block.slug === versionRow.blockType);
237
- let fields = [];
238
- if (versionRow.blockType === comparisonRow.blockType) {
239
- fields = versionBlock.fields;
240
- } else {
241
- const comparisonBlock = field.blocks.find(block => block.slug === comparisonRow.blockType);
242
- if (comparisonBlock) {
243
- fields = getUniqueListBy([...versionBlock.fields, ...comparisonBlock.fields], 'name');
244
- } else {
245
- fields = versionBlock.fields;
246
- }
247
- }
248
- baseVersionField.rows[i] = buildVersionFields({
249
- clientSchemaMap,
250
- comparisonSiblingData: comparisonRow,
251
- customDiffComponents,
252
- entitySlug,
253
- fieldPermissions,
254
- fields,
255
- i18n,
256
- parentIndexPath: 'name' in field ? '' : indexPath,
257
- parentPath: path + '.' + i,
258
- parentSchemaPath: schemaPath + '.' + versionBlock.slug,
259
- req,
260
- selectedLocales,
261
- versionSiblingData: versionRow
262
- }).versionFields;
263
- }
264
- }
265
- const clientCellProps = {
266
- baseVersionField: {
267
- ...baseVersionField,
268
- CustomComponent: undefined
269
- },
270
- comparisonValue,
271
- diffMethod,
272
- field: clientField,
273
- fieldPermissions: subFieldPermissions,
274
- versionValue
275
- };
276
- const serverCellProps = {
277
- ...clientCellProps,
278
- clientField,
279
- field,
280
- i18n,
281
- req,
282
- selectedLocales
283
- };
284
- baseVersionField.CustomComponent = RenderServerComponent({
285
- clientProps: locale ? {
286
- ...clientCellProps,
287
- locale
288
- } : clientCellProps,
289
- Component: CustomComponent,
290
- Fallback: DefaultComponent,
291
- importMap: req.payload.importMap,
292
- key: 'diff component',
293
- serverProps: locale ? {
294
- ...serverCellProps,
295
- locale
296
- } : serverCellProps
297
- });
298
- return baseVersionField;
299
- };
300
- //# sourceMappingURL=buildVersionFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildVersionFields.js","names":["RenderServerComponent","fieldIsID","getUniqueListBy","tabHasName","diffMethods","diffComponents","getFieldPathsModified","buildVersionFields","clientSchemaMap","comparisonSiblingData","customDiffComponents","entitySlug","fieldPermissions","fields","i18n","parentIndexPath","parentPath","parentSchemaPath","req","selectedLocales","versionSiblingData","versionFields","fieldIndex","field","indexPath","path","schemaPath","index","clientField","get","payload","logger","error","clientFieldKey","clientSchemaMapKeys","Array","from","keys","msg","Error","versionField","type","isLocalized","localized","fieldName","name","versionValue","comparisonValue","fieldByLocale","locale","buildVersionField","push","diffMethod","hasPermission","read","subFieldPermissions","CustomComponent","admin","components","Diff","DefaultComponent","baseVersionField","tabs","tabIndex","tab","isNamedTab","tabIndexPath","tabPath","tabSchemaPath","label","isArray","rows","i","length","comparisonRow","versionRow","versionBlock","blocks","find","block","slug","blockType","comparisonBlock","clientCellProps","undefined","serverCellProps","clientProps","Component","Fallback","importMap","key","serverProps"],"sources":["../../../../src/views/Version/RenderFieldsToDiff/buildVersionFields.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n BaseVersionField,\n ClientField,\n ClientFieldSchemaMap,\n DiffComponentProps,\n DiffComponentServerProps,\n Field,\n FieldTypes,\n PayloadComponent,\n PayloadRequest,\n SanitizedFieldPermissions,\n VersionField,\n} from 'payload'\nimport type { DiffMethod } from 'react-diff-viewer-continued'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { fieldIsID, getUniqueListBy, tabHasName } from 'payload/shared'\n\nimport { diffMethods } from './fields/diffMethods.js'\nimport { diffComponents } from './fields/index.js'\nimport { getFieldPathsModified } from './utilities/getFieldPathsModified.js'\n\nexport type BuildVersionFieldsArgs = {\n clientSchemaMap: ClientFieldSchemaMap\n comparisonSiblingData: object\n customDiffComponents: Partial<\n Record<FieldTypes, PayloadComponent<DiffComponentServerProps, DiffComponentProps>>\n >\n entitySlug: string\n fieldPermissions:\n | {\n [key: string]: SanitizedFieldPermissions\n }\n | true\n fields: Field[]\n i18n: I18nClient\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n req: PayloadRequest\n selectedLocales: string[]\n versionSiblingData: object\n}\n\n/**\n * Build up an object that contains rendered diff components for each field.\n * This is then sent to the client to be rendered.\n *\n * Here, the server is responsible for traversing through the document data and building up this\n * version state object.\n */\nexport const buildVersionFields = ({\n clientSchemaMap,\n comparisonSiblingData,\n customDiffComponents,\n entitySlug,\n fieldPermissions,\n fields,\n i18n,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n req,\n selectedLocales,\n versionSiblingData,\n}: BuildVersionFieldsArgs): {\n versionFields: VersionField[]\n} => {\n const versionFields: VersionField[] = []\n let fieldIndex = -1\n for (const field of fields) {\n fieldIndex++\n if (fieldIsID(field)) {\n continue\n }\n\n const { indexPath, path, schemaPath } = getFieldPathsModified({\n field,\n index: fieldIndex,\n parentIndexPath: 'name' in field ? '' : parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const clientField = clientSchemaMap.get(entitySlug + '.' + schemaPath)\n\n if (!clientField) {\n req.payload.logger.error({\n clientFieldKey: entitySlug + '.' + schemaPath,\n clientSchemaMapKeys: Array.from(clientSchemaMap.keys()),\n msg: 'No client field found for ' + entitySlug + '.' + schemaPath,\n parentPath,\n parentSchemaPath,\n path,\n schemaPath,\n })\n throw new Error('No client field found for ' + entitySlug + '.' + schemaPath)\n }\n\n const versionField: VersionField = {\n type: field.type,\n }\n const isLocalized = 'localized' in field && field.localized\n const fieldName: null | string = 'name' in field ? field.name : null\n\n const versionValue = fieldName ? versionSiblingData?.[fieldName] : versionSiblingData\n\n const comparisonValue = fieldName ? comparisonSiblingData?.[fieldName] : comparisonSiblingData\n\n if (isLocalized) {\n versionField.fieldByLocale = {}\n\n for (const locale of selectedLocales) {\n versionField.fieldByLocale[locale] = buildVersionField({\n clientField: clientField as ClientField,\n clientSchemaMap,\n comparisonValue: comparisonValue?.[locale],\n customDiffComponents,\n entitySlug,\n field,\n fieldPermissions,\n i18n,\n indexPath,\n locale,\n parentPath,\n parentSchemaPath,\n path,\n req,\n schemaPath,\n selectedLocales,\n versionValue: versionValue?.[locale],\n })\n }\n } else {\n versionField.field = buildVersionField({\n clientField: clientField as ClientField,\n clientSchemaMap,\n comparisonValue,\n customDiffComponents,\n entitySlug,\n field,\n fieldPermissions,\n i18n,\n indexPath,\n parentPath,\n parentSchemaPath,\n path,\n req,\n schemaPath,\n selectedLocales,\n versionValue,\n })\n }\n\n versionFields.push(versionField)\n }\n\n return {\n versionFields,\n }\n}\n\nconst buildVersionField = ({\n clientField,\n clientSchemaMap,\n comparisonValue,\n customDiffComponents,\n entitySlug,\n field,\n fieldPermissions,\n i18n,\n indexPath,\n locale,\n parentPath,\n parentSchemaPath,\n path,\n req,\n schemaPath,\n selectedLocales,\n versionValue,\n}: {\n clientField: ClientField\n comparisonValue: unknown\n field: Field\n indexPath: string\n locale?: string\n path: string\n schemaPath: string\n versionValue: unknown\n} & Omit<\n BuildVersionFieldsArgs,\n 'comparisonSiblingData' | 'fields' | 'parentIndexPath' | 'versionSiblingData'\n>): BaseVersionField | null => {\n const fieldName: null | string = 'name' in field ? field.name : null\n\n const diffMethod: DiffMethod = diffMethods[field.type] || 'CHARS'\n\n const hasPermission =\n fieldPermissions === true ||\n !fieldName ||\n fieldPermissions?.[fieldName] === true ||\n fieldPermissions?.[fieldName]?.read\n\n const subFieldPermissions =\n fieldPermissions === true ||\n !fieldName ||\n fieldPermissions?.[fieldName] === true ||\n fieldPermissions?.[fieldName]?.fields\n\n if (!hasPermission) {\n return null\n }\n\n const CustomComponent = field?.admin?.components?.Diff ?? customDiffComponents?.[field.type]\n const DefaultComponent = diffComponents?.[field.type]\n\n const baseVersionField: BaseVersionField = {\n fields: [],\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n baseVersionField.tabs = []\n let tabIndex = -1\n for (const tab of field.tabs) {\n tabIndex++\n const isNamedTab = tabHasName(tab)\n\n const {\n indexPath: tabIndexPath,\n path: tabPath,\n schemaPath: tabSchemaPath,\n } = getFieldPathsModified({\n field: {\n ...tab,\n type: 'tab',\n },\n index: tabIndex,\n parentIndexPath: indexPath,\n parentPath,\n parentSchemaPath,\n })\n baseVersionField.tabs.push({\n name: 'name' in tab ? tab.name : null,\n fields: buildVersionFields({\n clientSchemaMap,\n comparisonSiblingData: 'name' in tab ? comparisonValue?.[tab.name] : comparisonValue,\n customDiffComponents,\n entitySlug,\n fieldPermissions,\n fields: tab.fields,\n i18n,\n parentIndexPath: isNamedTab ? '' : tabIndexPath,\n parentPath: tabPath,\n parentSchemaPath: tabSchemaPath,\n req,\n selectedLocales,\n versionSiblingData: 'name' in tab ? versionValue?.[tab.name] : versionValue,\n }).versionFields,\n label: tab.label,\n })\n }\n } // At this point, we are dealing with a `row`, etc\n else if ('fields' in field) {\n if (field.type === 'array') {\n if (!Array.isArray(versionValue)) {\n throw new Error('Expected versionValue to be an array')\n }\n baseVersionField.rows = []\n\n for (let i = 0; i < versionValue.length; i++) {\n const comparisonRow = comparisonValue?.[i] || {}\n const versionRow = versionValue?.[i] || {}\n baseVersionField.rows[i] = buildVersionFields({\n clientSchemaMap,\n comparisonSiblingData: comparisonRow,\n customDiffComponents,\n entitySlug,\n fieldPermissions,\n fields: field.fields,\n i18n,\n parentIndexPath: 'name' in field ? '' : indexPath,\n parentPath: path + '.' + i,\n parentSchemaPath: schemaPath,\n req,\n selectedLocales,\n versionSiblingData: versionRow,\n }).versionFields\n }\n } else {\n baseVersionField.fields = buildVersionFields({\n clientSchemaMap,\n comparisonSiblingData: comparisonValue as object,\n customDiffComponents,\n entitySlug,\n fieldPermissions,\n fields: field.fields,\n i18n,\n parentIndexPath: 'name' in field ? '' : indexPath,\n parentPath: path,\n parentSchemaPath: schemaPath,\n req,\n selectedLocales,\n versionSiblingData: versionValue as object,\n }).versionFields\n }\n } else if (field.type === 'blocks') {\n baseVersionField.rows = []\n\n if (!Array.isArray(versionValue)) {\n throw new Error('Expected versionValue to be an array')\n }\n\n for (let i = 0; i < versionValue.length; i++) {\n const comparisonRow = comparisonValue?.[i] || {}\n const versionRow = versionValue[i] || {}\n const versionBlock = field.blocks.find((block) => block.slug === versionRow.blockType)\n\n let fields = []\n\n if (versionRow.blockType === comparisonRow.blockType) {\n fields = versionBlock.fields\n } else {\n const comparisonBlock = field.blocks.find((block) => block.slug === comparisonRow.blockType)\n if (comparisonBlock) {\n fields = getUniqueListBy<Field>(\n [...versionBlock.fields, ...comparisonBlock.fields],\n 'name',\n )\n } else {\n fields = versionBlock.fields\n }\n }\n\n baseVersionField.rows[i] = buildVersionFields({\n clientSchemaMap,\n comparisonSiblingData: comparisonRow,\n customDiffComponents,\n entitySlug,\n fieldPermissions,\n fields,\n i18n,\n parentIndexPath: 'name' in field ? '' : indexPath,\n parentPath: path + '.' + i,\n parentSchemaPath: schemaPath + '.' + versionBlock.slug,\n req,\n selectedLocales,\n versionSiblingData: versionRow,\n }).versionFields\n }\n }\n\n const clientCellProps: DiffComponentProps = {\n baseVersionField: {\n ...baseVersionField,\n CustomComponent: undefined,\n },\n comparisonValue,\n diffMethod,\n field: clientField,\n fieldPermissions: subFieldPermissions,\n versionValue,\n }\n\n const serverCellProps: DiffComponentServerProps = {\n ...clientCellProps,\n clientField,\n field,\n i18n,\n req,\n selectedLocales,\n }\n\n baseVersionField.CustomComponent = RenderServerComponent({\n clientProps: locale\n ? ({\n ...clientCellProps,\n locale,\n } as DiffComponentProps)\n : clientCellProps,\n Component: CustomComponent,\n Fallback: DefaultComponent,\n importMap: req.payload.importMap,\n key: 'diff component',\n serverProps: locale\n ? ({\n ...serverCellProps,\n locale,\n } as DiffComponentServerProps)\n : serverCellProps,\n })\n\n return baseVersionField\n}\n"],"mappings":"AAgBA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,SAAS,EAAEC,eAAe,EAAEC,UAAU,QAAQ;AAEvD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AAwBtC;;;;;;;AAOA,OAAO,MAAMC,kBAAA,GAAqBA,CAAC;EACjCC,eAAe;EACfC,qBAAqB;EACrBC,oBAAoB;EACpBC,UAAU;EACVC,gBAAgB;EAChBC,MAAM;EACNC,IAAI;EACJC,eAAe;EACfC,UAAU;EACVC,gBAAgB;EAChBC,GAAG;EACHC,eAAe;EACfC;AAAkB,CACK;EAGvB,MAAMC,aAAA,GAAgC,EAAE;EACxC,IAAIC,UAAA,GAAa,CAAC;EAClB,KAAK,MAAMC,KAAA,IAASV,MAAA,EAAQ;IAC1BS,UAAA;IACA,IAAIrB,SAAA,CAAUsB,KAAA,GAAQ;MACpB;IACF;IAEA,MAAM;MAAEC,SAAS;MAAEC,IAAI;MAAEC;IAAU,CAAE,GAAGpB,qBAAA,CAAsB;MAC5DiB,KAAA;MACAI,KAAA,EAAOL,UAAA;MACPP,eAAA,EAAiB,UAAUQ,KAAA,GAAQ,KAAKR,eAAA;MACxCC,UAAA;MACAC;IACF;IAEA,MAAMW,WAAA,GAAcpB,eAAA,CAAgBqB,GAAG,CAAClB,UAAA,GAAa,MAAMe,UAAA;IAE3D,IAAI,CAACE,WAAA,EAAa;MAChBV,GAAA,CAAIY,OAAO,CAACC,MAAM,CAAC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BAAA;QACAC,MAAA;QACAC,IAAA;QACAC,eAAA,EAAiB,UAAUQ,KAAA,GAAQ,KAAKC,SAAA;QACxCR,UAAA,EAAYS,IAAA,GAAO,MAAM+C,CAAA;QACzBvD,gBAAA,EAAkBS,UAAA,GAAa,MAAMkD,YAAA,CAAaI,IAAI;QACtD9D,GAAA;QACAC,eAAA;QACAC,kBAAA,EAAoBuD;MACtB,GAAGtD,aAAa;IAClB;EACF;EAEA,MAAM8D,eAAA,GAAsC;IAC1CtB,gBAAA,EAAkB;MAChB,GAAGA,gBAAgB;MACnBL,eAAA,EAAiB4B;IACnB;IACArC,eAAA;IACAK,UAAA;IACA7B,KAAA,EAAOK,WAAA;IACPhB,gBAAA,EAAkB2C,mBAAA;IAClBT;EACF;EAEA,MAAMuC,eAAA,GAA4C;IAChD,GAAGF,eAAe;IAClBvD,WAAA;IACAL,KAAA;IACAT,IAAA;IACAI,GAAA;IACAC;EACF;EAEA0C,gBAAA,CAAiBL,eAAe,GAAGxD,qBAAA,CAAsB;IACvDsF,WAAA,EAAarC,MAAA,GACR;MACC,GAAGkC,eAAe;MAClBlC;IACF,IACAkC,eAAA;IACJI,SAAA,EAAW/B,eAAA;IACXgC,QAAA,EAAU5B,gBAAA;IACV6B,SAAA,EAAWvE,GAAA,CAAIY,OAAO,CAAC2D,SAAS;IAChCC,GAAA,EAAK;IACLC,WAAA,EAAa1C,MAAA,GACR;MACC,GAAGoC,eAAe;MAClBpC;IACF,IACAoC;EACN;EAEA,OAAOxB,gBAAA;AACT","ignoreList":[]}
@@ -1,27 +0,0 @@
1
- import type { ClientField, Field, Tab, TabAsFieldClient } from 'payload';
2
- type Args = {
3
- field: ClientField | Field | Tab | TabAsFieldClient;
4
- index: number;
5
- parentIndexPath: string;
6
- parentPath: string;
7
- parentSchemaPath: string;
8
- };
9
- type FieldPaths = {
10
- /**
11
- * A string of '-' separated indexes representing where
12
- * to find this field in a given field schema array.
13
- * It will always be complete and accurate.
14
- */
15
- indexPath: string;
16
- /**
17
- * Path for this field relative to its position in the data.
18
- */
19
- path: string;
20
- /**
21
- * Path for this field relative to its position in the schema.
22
- */
23
- schemaPath: string;
24
- };
25
- export declare function getFieldPathsModified({ field, index, parentIndexPath, parentPath, parentSchemaPath, }: Args): FieldPaths;
26
- export {};
27
- //# sourceMappingURL=getFieldPathsModified.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFieldPathsModified.d.ts","sourceRoot":"","sources":["../../../../../src/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAExE,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,WAAW,GAAG,KAAK,GAAG,GAAG,GAAG,gBAAgB,CAAA;IACnD,KAAK,EAAE,MAAM,CAAA;IACb,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,KAAK,UAAU,GAAG;IAChB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,KAAK,EACL,eAAe,EACf,UAAU,EACV,gBAAgB,GACjB,EAAE,IAAI,GAAG,UAAU,CAkCnB"}
@@ -1,30 +0,0 @@
1
- export function getFieldPathsModified({
2
- field,
3
- index,
4
- parentIndexPath,
5
- parentPath,
6
- parentSchemaPath
7
- }) {
8
- const parentPathSegments = parentPath.split('.');
9
- const parentIsUnnamed = parentPathSegments[parentPathSegments.length - 1].startsWith('_index-');
10
- const parentWithoutIndex = parentIsUnnamed ? parentPathSegments.slice(0, -1).join('.') : parentPath;
11
- const parentPathToUse = parentIsUnnamed ? parentWithoutIndex : parentPath;
12
- const parentSchemaPathSegments = parentSchemaPath.split('.');
13
- const parentSchemaIsUnnamed = parentSchemaPathSegments[parentSchemaPathSegments.length - 1].startsWith('_index-');
14
- const parentSchemaWithoutIndex = parentSchemaIsUnnamed ? parentSchemaPathSegments.slice(0, -1).join('.') : parentSchemaPath;
15
- const parentSchemaPathToUse = parentSchemaIsUnnamed ? parentSchemaWithoutIndex : parentSchemaPath;
16
- if ('name' in field) {
17
- return {
18
- indexPath: '',
19
- path: `${parentPathToUse ? parentPathToUse + '.' : ''}${field.name}`,
20
- schemaPath: `${parentSchemaPathToUse ? parentSchemaPathToUse + '.' : ''}${field.name}`
21
- };
22
- }
23
- const indexSuffix = `_index-${`${parentIndexPath ? parentIndexPath + '-' : ''}${index}`}`;
24
- return {
25
- indexPath: `${parentIndexPath ? parentIndexPath + '-' : ''}${index}`,
26
- path: `${parentPathToUse ? parentPathToUse + '.' : ''}${indexSuffix}`,
27
- schemaPath: `${!parentIsUnnamed && parentSchemaPathToUse ? parentSchemaPathToUse + '.' : ''}${indexSuffix}`
28
- };
29
- }
30
- //# sourceMappingURL=getFieldPathsModified.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFieldPathsModified.js","names":["getFieldPathsModified","field","index","parentIndexPath","parentPath","parentSchemaPath","parentPathSegments","split","parentIsUnnamed","length","startsWith","parentWithoutIndex","slice","join","parentPathToUse","parentSchemaPathSegments","parentSchemaIsUnnamed","parentSchemaWithoutIndex","parentSchemaPathToUse","indexPath","path","name","schemaPath","indexSuffix"],"sources":["../../../../../src/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.ts"],"sourcesContent":["import type { ClientField, Field, Tab, TabAsFieldClient } from 'payload'\n\ntype Args = {\n field: ClientField | Field | Tab | TabAsFieldClient\n index: number\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n}\n\ntype FieldPaths = {\n /**\n * A string of '-' separated indexes representing where\n * to find this field in a given field schema array.\n * It will always be complete and accurate.\n */\n indexPath: string\n /**\n * Path for this field relative to its position in the data.\n */\n path: string\n /**\n * Path for this field relative to its position in the schema.\n */\n schemaPath: string\n}\n\nexport function getFieldPathsModified({\n field,\n index,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n}: Args): FieldPaths {\n const parentPathSegments = parentPath.split('.')\n\n const parentIsUnnamed = parentPathSegments[parentPathSegments.length - 1].startsWith('_index-')\n\n const parentWithoutIndex = parentIsUnnamed\n ? parentPathSegments.slice(0, -1).join('.')\n : parentPath\n\n const parentPathToUse = parentIsUnnamed ? parentWithoutIndex : parentPath\n\n const parentSchemaPathSegments = parentSchemaPath.split('.')\n const parentSchemaIsUnnamed =\n parentSchemaPathSegments[parentSchemaPathSegments.length - 1].startsWith('_index-')\n const parentSchemaWithoutIndex = parentSchemaIsUnnamed\n ? parentSchemaPathSegments.slice(0, -1).join('.')\n : parentSchemaPath\n const parentSchemaPathToUse = parentSchemaIsUnnamed ? parentSchemaWithoutIndex : parentSchemaPath\n\n if ('name' in field) {\n return {\n indexPath: '',\n path: `${parentPathToUse ? parentPathToUse + '.' : ''}${field.name}`,\n schemaPath: `${parentSchemaPathToUse ? parentSchemaPathToUse + '.' : ''}${field.name}`,\n }\n }\n\n const indexSuffix = `_index-${`${parentIndexPath ? parentIndexPath + '-' : ''}${index}`}`\n\n return {\n indexPath: `${parentIndexPath ? parentIndexPath + '-' : ''}${index}`,\n path: `${parentPathToUse ? parentPathToUse + '.' : ''}${indexSuffix}`,\n schemaPath: `${!parentIsUnnamed && parentSchemaPathToUse ? parentSchemaPathToUse + '.' : ''}${indexSuffix}`,\n }\n}\n"],"mappings":"AA2BA,OAAO,SAASA,sBAAsB;EACpCC,KAAK;EACLC,KAAK;EACLC,eAAe;EACfC,UAAU;EACVC;AAAgB,CACX;EACL,MAAMC,kBAAA,GAAqBF,UAAA,CAAWG,KAAK,CAAC;EAE5C,MAAMC,eAAA,GAAkBF,kBAAkB,CAACA,kBAAA,CAAmBG,MAAM,GAAG,EAAE,CAACC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