@payloadcms/next 3.20.0-canary.9f2bca1 → 3.20.0-canary.a40bec2
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/prod/styles.css +1 -1
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +2 -1
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +4 -2
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.js +2 -1
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/Document/getDocumentPermissions.js +2 -2
- package/dist/views/Document/getDocumentPermissions.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +2 -1
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +2 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.d.ts.map +1 -1
- package/dist/views/LivePreview/index.client.js +5 -2
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/Version/Default/SelectedLocalesContext.d.ts +8 -0
- package/dist/views/Version/Default/SelectedLocalesContext.d.ts.map +1 -0
- package/dist/views/Version/Default/SelectedLocalesContext.js +10 -0
- package/dist/views/Version/Default/SelectedLocalesContext.js.map +1 -0
- package/dist/views/Version/Default/index.d.ts.map +1 -1
- package/dist/views/Version/Default/index.js +107 -159
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/Default/index.scss +5 -0
- package/dist/views/Version/Default/types.d.ts +5 -4
- package/dist/views/Version/Default/types.d.ts.map +1 -1
- package/dist/views/Version/Default/types.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.d.ts +27 -0
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js +76 -0
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.scss +46 -0
- package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.d.ts +7 -0
- package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js +74 -0
- package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts +31 -0
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +319 -0
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.d.ts +3 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js +67 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.d.ts +4 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js +69 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.scss +14 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts +3 -4
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +100 -63
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.scss +3 -12
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts +2 -5
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +19 -19
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.d.ts +3 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js +17 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js +1 -2
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts +2 -5
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +56 -28
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts +3 -5
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +151 -41
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.scss +20 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js +1 -2
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts +2 -5
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +71 -37
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts +2 -22
- package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/index.js +13 -9
- package/dist/views/Version/RenderFieldsToDiff/fields/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/styles.d.ts +3 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/styles.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/styles.js +3 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/styles.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/index.d.ts +2 -5
- package/dist/views/Version/RenderFieldsToDiff/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/index.js +8 -113
- package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/index.scss +4 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.d.ts +21 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js +197 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js +860 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.d.ts +2 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.js +4 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js +46 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.d.ts +27 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.js +30 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.d.ts +18 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js +44 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js +122 -0
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js.map +1 -0
- package/dist/views/Version/Restore/index.d.ts.map +1 -1
- package/dist/views/Version/Restore/index.js +2 -2
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/index.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/index.js +7 -3
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/types.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/types.js.map +1 -1
- package/dist/views/Version/index.d.ts.map +1 -1
- package/dist/views/Version/index.js +120 -15
- package/dist/views/Version/index.js.map +1 -1
- package/dist/views/Versions/getLatestVersion.d.ts +4 -1
- package/dist/views/Versions/getLatestVersion.d.ts.map +1 -1
- package/dist/views/Versions/getLatestVersion.js +6 -0
- package/dist/views/Versions/getLatestVersion.js.map +1 -1
- package/package.json +8 -7
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.d.ts +0 -6
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.d.ts.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js +0 -43
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.scss +0 -14
- package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts +0 -22
- package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/types.js +0 -2
- package/dist/views/Version/RenderFieldsToDiff/fields/types.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/types.d.ts +0 -21
- package/dist/views/Version/RenderFieldsToDiff/types.d.ts.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/types.js +0 -2
- package/dist/views/Version/RenderFieldsToDiff/types.js.map +0 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { fieldHasChanges } from './fieldHasChanges.js';
|
|
2
|
+
import { getFieldsForRowComparison } from './getFieldsForRowComparison.js';
|
|
3
|
+
/**
|
|
4
|
+
* Recursively counts the number of changed fields between comparison and
|
|
5
|
+
* version data for a given set of fields.
|
|
6
|
+
*/
|
|
7
|
+
export function countChangedFields({
|
|
8
|
+
comparison,
|
|
9
|
+
fields,
|
|
10
|
+
locales,
|
|
11
|
+
version
|
|
12
|
+
}) {
|
|
13
|
+
let count = 0;
|
|
14
|
+
fields.forEach(field => {
|
|
15
|
+
// Don't count the id field since it is not displayed in the UI
|
|
16
|
+
if ('name' in field && field.name === 'id') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const fieldType = field.type;
|
|
20
|
+
switch (fieldType) {
|
|
21
|
+
// Iterable fields are arrays and blocks fields. We iterate over each row and
|
|
22
|
+
// count the number of changed fields in each.
|
|
23
|
+
case 'array':
|
|
24
|
+
case 'blocks':
|
|
25
|
+
{
|
|
26
|
+
if (locales && field.localized) {
|
|
27
|
+
locales.forEach(locale => {
|
|
28
|
+
const comparisonRows = comparison?.[field.name]?.[locale] ?? [];
|
|
29
|
+
const versionRows = version?.[field.name]?.[locale] ?? [];
|
|
30
|
+
count += countChangedFieldsInRows({
|
|
31
|
+
comparisonRows,
|
|
32
|
+
field,
|
|
33
|
+
locales,
|
|
34
|
+
versionRows
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
const comparisonRows = comparison?.[field.name] ?? [];
|
|
39
|
+
const versionRows = version?.[field.name] ?? [];
|
|
40
|
+
count += countChangedFieldsInRows({
|
|
41
|
+
comparisonRows,
|
|
42
|
+
field,
|
|
43
|
+
locales,
|
|
44
|
+
versionRows
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
// Regular fields without nested fields.
|
|
50
|
+
case 'checkbox':
|
|
51
|
+
case 'code':
|
|
52
|
+
case 'date':
|
|
53
|
+
case 'email':
|
|
54
|
+
case 'join':
|
|
55
|
+
case 'json':
|
|
56
|
+
case 'number':
|
|
57
|
+
case 'point':
|
|
58
|
+
case 'radio':
|
|
59
|
+
case 'relationship':
|
|
60
|
+
case 'richText':
|
|
61
|
+
case 'select':
|
|
62
|
+
case 'text':
|
|
63
|
+
case 'textarea':
|
|
64
|
+
case 'upload':
|
|
65
|
+
{
|
|
66
|
+
// Fields that have a name and contain data. We can just check if the data has changed.
|
|
67
|
+
if (locales && field.localized) {
|
|
68
|
+
locales.forEach(locale => {
|
|
69
|
+
if (fieldHasChanges(version?.[field.name]?.[locale], comparison?.[field.name]?.[locale])) {
|
|
70
|
+
count++;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
} else if (fieldHasChanges(version?.[field.name], comparison?.[field.name])) {
|
|
74
|
+
count++;
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
// Fields that have nested fields, but don't nest their fields' data.
|
|
79
|
+
case 'collapsible':
|
|
80
|
+
case 'row':
|
|
81
|
+
{
|
|
82
|
+
count += countChangedFields({
|
|
83
|
+
comparison,
|
|
84
|
+
fields: field.fields,
|
|
85
|
+
locales,
|
|
86
|
+
version
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
// Fields that have nested fields and nest their fields' data.
|
|
91
|
+
case 'group':
|
|
92
|
+
{
|
|
93
|
+
if (locales && field.localized) {
|
|
94
|
+
locales.forEach(locale => {
|
|
95
|
+
count += countChangedFields({
|
|
96
|
+
comparison: comparison?.[field.name]?.[locale],
|
|
97
|
+
fields: field.fields,
|
|
98
|
+
locales,
|
|
99
|
+
version: version?.[field.name]?.[locale]
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
count += countChangedFields({
|
|
104
|
+
comparison: comparison?.[field.name],
|
|
105
|
+
fields: field.fields,
|
|
106
|
+
locales,
|
|
107
|
+
version: version?.[field.name]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
// Each tab in a tabs field has nested fields. The fields data may be
|
|
113
|
+
// nested or not depending on the existence of a name property.
|
|
114
|
+
case 'tabs':
|
|
115
|
+
{
|
|
116
|
+
field.tabs.forEach(tab => {
|
|
117
|
+
if ('name' in tab && locales && tab.localized) {
|
|
118
|
+
// Named localized tab
|
|
119
|
+
locales.forEach(locale => {
|
|
120
|
+
count += countChangedFields({
|
|
121
|
+
comparison: comparison?.[tab.name]?.[locale],
|
|
122
|
+
fields: tab.fields,
|
|
123
|
+
locales,
|
|
124
|
+
version: version?.[tab.name]?.[locale]
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
} else if ('name' in tab) {
|
|
128
|
+
// Named tab
|
|
129
|
+
count += countChangedFields({
|
|
130
|
+
comparison: comparison?.[tab.name],
|
|
131
|
+
fields: tab.fields,
|
|
132
|
+
locales,
|
|
133
|
+
version: version?.[tab.name]
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
// Unnamed tab
|
|
137
|
+
count += countChangedFields({
|
|
138
|
+
comparison,
|
|
139
|
+
fields: tab.fields,
|
|
140
|
+
locales,
|
|
141
|
+
version
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
// UI fields don't have data and are not displayed in the version view
|
|
148
|
+
// so we can ignore them.
|
|
149
|
+
case 'ui':
|
|
150
|
+
{
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
default:
|
|
154
|
+
{
|
|
155
|
+
const _exhaustiveCheck = fieldType;
|
|
156
|
+
throw new Error(`Unexpected field.type in countChangedFields : ${String(fieldType)}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return count;
|
|
161
|
+
}
|
|
162
|
+
export function countChangedFieldsInRows({
|
|
163
|
+
comparisonRows = [],
|
|
164
|
+
field,
|
|
165
|
+
locales,
|
|
166
|
+
versionRows = []
|
|
167
|
+
}) {
|
|
168
|
+
let count = 0;
|
|
169
|
+
let i = 0;
|
|
170
|
+
while (comparisonRows[i] || versionRows[i]) {
|
|
171
|
+
const comparisonRow = comparisonRows?.[i] || {};
|
|
172
|
+
const versionRow = versionRows?.[i] || {};
|
|
173
|
+
const {
|
|
174
|
+
fields: rowFields
|
|
175
|
+
} = getFieldsForRowComparison({
|
|
176
|
+
baseVersionField: {
|
|
177
|
+
type: 'text',
|
|
178
|
+
fields: [],
|
|
179
|
+
path: '',
|
|
180
|
+
schemaPath: ''
|
|
181
|
+
},
|
|
182
|
+
comparisonRow,
|
|
183
|
+
field,
|
|
184
|
+
row: i,
|
|
185
|
+
versionRow
|
|
186
|
+
});
|
|
187
|
+
count += countChangedFields({
|
|
188
|
+
comparison: comparisonRow,
|
|
189
|
+
fields: rowFields,
|
|
190
|
+
locales,
|
|
191
|
+
version: versionRow
|
|
192
|
+
});
|
|
193
|
+
i++;
|
|
194
|
+
}
|
|
195
|
+
return count;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=countChangedFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countChangedFields.js","names":["fieldHasChanges","getFieldsForRowComparison","countChangedFields","comparison","fields","locales","version","count","forEach","field","name","fieldType","type","localized","locale","comparisonRows","versionRows","countChangedFieldsInRows","tabs","tab","_exhaustiveCheck","Error","String","i","comparisonRow","versionRow","rowFields","baseVersionField","path","schemaPath","row"],"sources":["../../../../../src/views/Version/RenderFieldsToDiff/utilities/countChangedFields.ts"],"sourcesContent":["import type { ArrayFieldClient, BlocksFieldClient, ClientField } from 'payload'\n\nimport { fieldHasChanges } from './fieldHasChanges.js'\nimport { getFieldsForRowComparison } from './getFieldsForRowComparison.js'\n\ntype Args = {\n comparison: unknown\n fields: ClientField[]\n locales: string[] | undefined\n version: unknown\n}\n\n/**\n * Recursively counts the number of changed fields between comparison and\n * version data for a given set of fields.\n */\nexport function countChangedFields({ comparison, fields, locales, version }: Args) {\n let count = 0\n\n fields.forEach((field) => {\n // Don't count the id field since it is not displayed in the UI\n if ('name' in field && field.name === 'id') {\n return\n }\n const fieldType = field.type\n switch (fieldType) {\n // Iterable fields are arrays and blocks fields. We iterate over each row and\n // count the number of changed fields in each.\n case 'array':\n case 'blocks': {\n if (locales && field.localized) {\n locales.forEach((locale) => {\n const comparisonRows = comparison?.[field.name]?.[locale] ?? []\n const versionRows = version?.[field.name]?.[locale] ?? []\n count += countChangedFieldsInRows({ comparisonRows, field, locales, versionRows })\n })\n } else {\n const comparisonRows = comparison?.[field.name] ?? []\n const versionRows = version?.[field.name] ?? []\n count += countChangedFieldsInRows({ comparisonRows, field, locales, versionRows })\n }\n break\n }\n\n // Regular fields without nested fields.\n case 'checkbox':\n case 'code':\n case 'date':\n case 'email':\n case 'join':\n case 'json':\n case 'number':\n case 'point':\n case 'radio':\n case 'relationship':\n case 'richText':\n case 'select':\n case 'text':\n case 'textarea':\n case 'upload': {\n // Fields that have a name and contain data. We can just check if the data has changed.\n if (locales && field.localized) {\n locales.forEach((locale) => {\n if (\n fieldHasChanges(version?.[field.name]?.[locale], comparison?.[field.name]?.[locale])\n ) {\n count++\n }\n })\n } else if (fieldHasChanges(version?.[field.name], comparison?.[field.name])) {\n count++\n }\n break\n }\n // Fields that have nested fields, but don't nest their fields' data.\n case 'collapsible':\n case 'row': {\n count += countChangedFields({\n comparison,\n fields: field.fields,\n locales,\n version,\n })\n\n break\n }\n\n // Fields that have nested fields and nest their fields' data.\n case 'group': {\n if (locales && field.localized) {\n locales.forEach((locale) => {\n count += countChangedFields({\n comparison: comparison?.[field.name]?.[locale],\n fields: field.fields,\n locales,\n version: version?.[field.name]?.[locale],\n })\n })\n } else {\n count += countChangedFields({\n comparison: comparison?.[field.name],\n fields: field.fields,\n locales,\n version: version?.[field.name],\n })\n }\n break\n }\n\n // Each tab in a tabs field has nested fields. The fields data may be\n // nested or not depending on the existence of a name property.\n case 'tabs': {\n field.tabs.forEach((tab) => {\n if ('name' in tab && locales && tab.localized) {\n // Named localized tab\n locales.forEach((locale) => {\n count += countChangedFields({\n comparison: comparison?.[tab.name]?.[locale],\n fields: tab.fields,\n locales,\n version: version?.[tab.name]?.[locale],\n })\n })\n } else if ('name' in tab) {\n // Named tab\n count += countChangedFields({\n comparison: comparison?.[tab.name],\n fields: tab.fields,\n locales,\n version: version?.[tab.name],\n })\n } else {\n // Unnamed tab\n count += countChangedFields({\n comparison,\n fields: tab.fields,\n locales,\n version,\n })\n }\n })\n break\n }\n\n // UI fields don't have data and are not displayed in the version view\n // so we can ignore them.\n case 'ui': {\n break\n }\n\n default: {\n const _exhaustiveCheck: never = fieldType\n throw new Error(`Unexpected field.type in countChangedFields : ${String(fieldType)}`)\n }\n }\n })\n\n return count\n}\n\ntype countChangedFieldsInRowsArgs = {\n comparisonRows: unknown[]\n field: ArrayFieldClient | BlocksFieldClient\n locales: string[] | undefined\n versionRows: unknown[]\n}\n\nexport function countChangedFieldsInRows({\n comparisonRows = [],\n field,\n locales,\n versionRows = [],\n}: countChangedFieldsInRowsArgs) {\n let count = 0\n let i = 0\n\n while (comparisonRows[i] || versionRows[i]) {\n const comparisonRow = comparisonRows?.[i] || {}\n const versionRow = versionRows?.[i] || {}\n\n const { fields: rowFields } = getFieldsForRowComparison({\n baseVersionField: { type: 'text', fields: [], path: '', schemaPath: '' }, // Doesn't matter, as we don't need the versionFields output here\n comparisonRow,\n field,\n row: i,\n versionRow,\n })\n\n count += countChangedFields({\n comparison: comparisonRow,\n fields: rowFields,\n locales,\n version: versionRow,\n })\n\n i++\n }\n return count\n}\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ;AAChC,SAASC,yBAAyB,QAAQ;AAS1C;;;;AAIA,OAAO,SAASC,mBAAmB;EAAEC,UAAU;EAAEC,MAAM;EAAEC,OAAO;EAAEC;AAAO,CAAQ;EAC/E,IAAIC,KAAA,GAAQ;EAEZH,MAAA,CAAOI,OAAO,CAAEC,KAAA;IACd;IACA,IAAI,UAAUA,KAAA,IAASA,KAAA,CAAMC,IAAI,KAAK,MAAM;MAC1C;IACF;IACA,MAAMC,SAAA,GAAYF,KAAA,CAAMG,IAAI;IAC5B,QAAQD,SAAA;MACN;MACA;MACA,KAAK;MACL,KAAK;QAAU;UACb,IAAIN,OAAA,IAAWI,KAAA,CAAMI,SAAS,EAAE;YAC9BR,OAAA,CAAQG,OAAO,CAAEM,MAAA;cACf,MAAMC,cAAA,GAAiBZ,UAAA,GAAaM,KAAA,CAAMC,IAAI,CAAC,GAAGI,MAAA,CAAO,IAAI,EAAE;cAC/D,MAAME,WAAA,GAAcV,OAAA,GAAUG,KAAA,CAAMC,IAAI,CAAC,GAAGI,MAAA,CAAO,IAAI,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