@pigment/auto-translate 1.6.0 → 1.6.1

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 (27) hide show
  1. package/README.md +15 -8
  2. package/dist/collections/translationExclusions.js +101 -4
  3. package/dist/collections/translationExclusions.js.map +1 -1
  4. package/dist/components/LockTranslation/actions/lockTranslations.d.ts +1 -1
  5. package/dist/components/LockTranslation/actions/lockTranslations.js +2 -2
  6. package/dist/components/LockTranslation/actions/lockTranslations.js.map +1 -1
  7. package/dist/components/LockTranslation/index.js +6 -3
  8. package/dist/components/LockTranslation/index.js.map +1 -1
  9. package/dist/components/OpenAiModelField.js +7 -4
  10. package/dist/components/OpenAiModelField.js.map +1 -1
  11. package/dist/components/TranslationControl.js +45 -51
  12. package/dist/components/TranslationControl.js.map +1 -1
  13. package/dist/globals/translationSettings.js +10 -10
  14. package/dist/globals/translationSettings.js.map +1 -1
  15. package/dist/services/translationService.js +4 -7
  16. package/dist/services/translationService.js.map +1 -1
  17. package/dist/utilities/fieldHelpers.d.ts +0 -29
  18. package/dist/utilities/fieldHelpers.js +0 -152
  19. package/dist/utilities/fieldHelpers.js.map +1 -1
  20. package/dist/utilities/injectTranslationControls.d.ts +1 -1
  21. package/dist/utilities/injectTranslationControls.js +16 -11
  22. package/dist/utilities/injectTranslationControls.js.map +1 -1
  23. package/package.json +36 -65
  24. package/dist/components/TranslationSettingsLock.css +0 -87
  25. package/dist/components/TranslationSettingsLock.d.ts +0 -9
  26. package/dist/components/TranslationSettingsLock.js +0 -155
  27. package/dist/components/TranslationSettingsLock.js.map +0 -1
@@ -117,41 +117,6 @@
117
117
  }
118
118
  }
119
119
  }
120
- /**
121
- * Recursively extracts all field paths and their values from a document
122
- */ export function extractFieldPaths(data, parentPath = '', fields) {
123
- const paths = [];
124
- if (!data || typeof data !== 'object') {
125
- return paths;
126
- }
127
- for (const [key, value] of Object.entries(data)){
128
- const currentPath = parentPath ? `${parentPath}.${key}` : key;
129
- // Skip internal fields
130
- if (key === 'id' || key === '_id' || key === 'createdAt' || key === 'updatedAt' || key === 'translationSync' || key === '__v') {
131
- continue;
132
- }
133
- // Add current field
134
- paths.push({
135
- parentPath,
136
- path: currentPath,
137
- value
138
- });
139
- // Recursively process nested objects
140
- if (value && typeof value === 'object' && !Array.isArray(value)) {
141
- paths.push(...extractFieldPaths(value, currentPath, fields));
142
- }
143
- // Process arrays
144
- if (Array.isArray(value)) {
145
- value.forEach((item, index)=>{
146
- const arrayPath = `${currentPath}.${index}`;
147
- if (item && typeof item === 'object') {
148
- paths.push(...extractFieldPaths(item, arrayPath, fields));
149
- }
150
- });
151
- }
152
- }
153
- return paths;
154
- }
155
120
  /**
156
121
  * Filters out excluded paths from data before translation
157
122
  */ export function filterExcludedPaths(data, excludedPaths) {
@@ -165,65 +130,6 @@
165
130
  }
166
131
  return filtered;
167
132
  }
168
- /**
169
- * Merges translated data back, respecting excluded paths
170
- */ export function mergeTranslatedData(originalData, translatedData, excludedPaths) {
171
- if (!translatedData || typeof translatedData !== 'object') {
172
- return originalData;
173
- }
174
- const merged = JSON.parse(JSON.stringify(originalData)) // Deep clone
175
- ;
176
- function merge(target, source, currentPath = '') {
177
- for(const key in source){
178
- const fullPath = currentPath ? `${currentPath}.${key}` : key;
179
- // Skip if this path is excluded
180
- if (isPathExcluded(fullPath, excludedPaths)) {
181
- continue;
182
- }
183
- // Skip internal fields
184
- if (key === 'id' || key === '_id' || key === 'createdAt' || key === 'updatedAt' || key === 'translationSync' || key === '__v') {
185
- continue;
186
- }
187
- if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
188
- if (!target[key]) {
189
- target[key] = {};
190
- }
191
- merge(target[key], source[key], fullPath);
192
- } else {
193
- target[key] = source[key];
194
- }
195
- }
196
- }
197
- merge(merged, translatedData);
198
- return merged;
199
- }
200
- /**
201
- * Checks if a path is excluded or if any parent path is excluded
202
- */ export function isPathExcluded(path, excludedPaths) {
203
- return excludedPaths.some((excludedPath)=>{
204
- // Exact match
205
- if (path === excludedPath) {
206
- return true;
207
- }
208
- // Check if path is a child of excluded path
209
- if (path.startsWith(`${excludedPath}.`)) {
210
- return true;
211
- }
212
- // Check if excluded path is a pattern match for arrays (e.g., content.0.title)
213
- const pathParts = path.split('.');
214
- const excludedParts = excludedPath.split('.');
215
- for(let i = 0; i < Math.min(pathParts.length, excludedParts.length); i++){
216
- if (excludedParts[i] !== pathParts[i]) {
217
- // Check if it's an array index difference
218
- if (!isNaN(Number(pathParts[i])) && !isNaN(Number(excludedParts[i]))) {
219
- continue;
220
- }
221
- return false;
222
- }
223
- }
224
- return excludedParts.length <= pathParts.length;
225
- });
226
- }
227
133
  /**
228
134
  * Deletes a path from an object using dot notation
229
135
  */ function deletePath(obj, path) {
@@ -237,63 +143,5 @@
237
143
  }
238
144
  delete current[parts[parts.length - 1]];
239
145
  }
240
- /**
241
- * Gets value at path using dot notation
242
- */ export function getValueAtPath(obj, path) {
243
- return path.split('.').reduce((current, part)=>current?.[part], obj);
244
- }
245
- /**
246
- * Sets value at path using dot notation
247
- */ export function setValueAtPath(obj, path, value) {
248
- const parts = path.split('.');
249
- let current = obj;
250
- for(let i = 0; i < parts.length - 1; i++){
251
- if (!current[parts[i]]) {
252
- current[parts[i]] = {};
253
- }
254
- current = current[parts[i]];
255
- }
256
- current[parts[parts.length - 1]] = value;
257
- }
258
- /**
259
- * Checks if a field is a localized field
260
- */ export function isLocalizedField(field) {
261
- return 'localized' in field && field.localized === true;
262
- }
263
- /**
264
- * Gets all localized field paths from a collection config
265
- */ export function getLocalizedFieldPaths(fields, parentPath = '') {
266
- const paths = [];
267
- for (const field of fields){
268
- if (!('name' in field)) {
269
- continue;
270
- }
271
- const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name;
272
- if (isLocalizedField(field)) {
273
- paths.push(fieldPath);
274
- }
275
- // Recursively check nested fields
276
- if ('fields' in field && Array.isArray(field.fields)) {
277
- paths.push(...getLocalizedFieldPaths(field.fields, fieldPath));
278
- }
279
- // Check blocks
280
- if (field.type === 'blocks' && 'blocks' in field && Array.isArray(field.blocks)) {
281
- for (const block of field.blocks){
282
- if ('fields' in block && Array.isArray(block.fields)) {
283
- paths.push(...getLocalizedFieldPaths(block.fields, fieldPath));
284
- }
285
- }
286
- }
287
- // Check group fields
288
- if (field.type === 'group' && 'fields' in field && Array.isArray(field.fields)) {
289
- paths.push(...getLocalizedFieldPaths(field.fields, fieldPath));
290
- }
291
- // Check array fields
292
- if (field.type === 'array' && 'fields' in field && Array.isArray(field.fields)) {
293
- paths.push(...getLocalizedFieldPaths(field.fields, fieldPath));
294
- }
295
- }
296
- return paths;
297
- }
298
146
 
299
147
  //# sourceMappingURL=fieldHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/fieldHelpers.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport type { FieldPath } from '../types/index.js'\n\n/**\n * Field types whose stored value is an option/enum constant rather than\n * human-readable prose. The Postgres adapter persists these as native `enum`\n * columns, so translating their values (e.g. \"narrow\" -> \"schmal\") produces an\n * invalid enum value and makes the locale-row INSERT fail with\n * `invalid input value for enum`. These must never be sent to the translator.\n */\nconst NON_TRANSLATABLE_FIELD_TYPES = new Set(['select', 'radio'])\n\n/**\n * Container field types that hold nested fields rather than a leaf value.\n * Localization (`localized: true`) set on a named container (`group`, `array`,\n * `blocks`, named `tab`) cascades to every field nested within it.\n */\nconst CONTAINER_FIELD_TYPES = new Set(['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'])\n\nexport type OverlayOptions = {\n /**\n * Localization inherited from an ancestor container (`group`/`array`/`blocks`/\n * named `tab`) that has `localized: true`. When true, every nested field is\n * treated as localized.\n */\n inheritedLocalized?: boolean\n /**\n * When true, only fields that are localized (directly or via an ancestor\n * container) are kept from `translated`; every non-localized field is restored\n * from `original` so it is effectively excluded from translation.\n */\n localizedOnly?: boolean\n}\n\n/**\n * Walks a Payload field schema and copies canonical (untranslated) values from\n * `original` back into `translated`, in place. A field's value is restored when:\n *\n * - it is a `select`/`radio` field (enum-backed; always restored), or\n * - `localizedOnly` is enabled and the field is not localized (directly or via\n * a localized ancestor container).\n *\n * This works regardless of which translation strategy produced `translated`\n * (optimized, legacy, or a custom translator).\n */\nexport function overlayNonTranslatableValues(\n translated: any,\n original: any,\n fields: Field[] | undefined,\n options: OverlayOptions = {},\n): void {\n if (\n !Array.isArray(fields) ||\n !translated ||\n typeof translated !== 'object' ||\n !original ||\n typeof original !== 'object'\n ) {\n return\n }\n\n const { inheritedLocalized = false, localizedOnly = false } = options\n\n for (const field of fields as any[]) {\n const type = field?.type\n const name = typeof field?.name === 'string' ? field.name : undefined\n const isLocalized = inheritedLocalized || field?.localized === true\n\n // Container fields: recurse, cascading localization to nested fields.\n if (type && CONTAINER_FIELD_TYPES.has(type)) {\n const childOptions: OverlayOptions = { inheritedLocalized: isLocalized, localizedOnly }\n\n switch (type) {\n case 'array':\n if (name && Array.isArray(translated[name]) && Array.isArray(original[name])) {\n translated[name].forEach((item: any, index: number) => {\n overlayNonTranslatableValues(item, original[name][index], field.fields, childOptions)\n })\n } else if (localizedOnly && name && !isLocalized && original[name] !== undefined) {\n translated[name] = original[name]\n }\n break\n\n case 'blocks':\n if (name && Array.isArray(translated[name]) && Array.isArray(original[name])) {\n const blockDefs: any[] = Array.isArray(field.blocks) ? field.blocks : []\n translated[name].forEach((item: any, index: number) => {\n const originalItem = original[name][index]\n const blockType = item?.blockType ?? originalItem?.blockType\n const blockDef = blockDefs.find((b) => b?.slug === blockType)\n if (blockDef) {\n overlayNonTranslatableValues(item, originalItem, blockDef.fields, childOptions)\n }\n })\n } else if (localizedOnly && name && !isLocalized && original[name] !== undefined) {\n translated[name] = original[name]\n }\n break\n\n case 'collapsible':\n case 'row':\n // Presentational wrappers share the parent object and cannot be localized.\n overlayNonTranslatableValues(translated, original, field.fields, {\n inheritedLocalized,\n localizedOnly,\n })\n break\n\n case 'group':\n if (name) {\n overlayNonTranslatableValues(\n translated[name],\n original[name],\n field.fields,\n childOptions,\n )\n }\n break\n\n case 'tabs':\n if (Array.isArray(field.tabs)) {\n for (const tab of field.tabs) {\n const tabName = typeof tab?.name === 'string' ? tab.name : undefined\n const tabLocalized = inheritedLocalized || tab?.localized === true\n if (tabName) {\n overlayNonTranslatableValues(translated[tabName], original[tabName], tab.fields, {\n inheritedLocalized: tabLocalized,\n localizedOnly,\n })\n } else {\n // Unnamed tabs share the parent object.\n overlayNonTranslatableValues(translated, original, tab.fields, {\n inheritedLocalized,\n localizedOnly,\n })\n }\n }\n }\n break\n }\n\n continue\n }\n\n // Leaf fields: restore the original value when it must not be translated.\n if (!name) {\n continue\n }\n\n const isEnumField = Boolean(type && NON_TRANSLATABLE_FIELD_TYPES.has(type))\n const shouldRestore = isEnumField || (localizedOnly && !isLocalized)\n\n if (shouldRestore && original[name] !== undefined) {\n translated[name] = original[name]\n }\n }\n}\n\n/**\n * Recursively extracts all field paths and their values from a document\n */\nexport function extractFieldPaths(\n data: any,\n parentPath: string = '',\n fields?: Field[],\n): FieldPath[] {\n const paths: FieldPath[] = []\n\n if (!data || typeof data !== 'object') {\n return paths\n }\n\n for (const [key, value] of Object.entries(data)) {\n const currentPath = parentPath ? `${parentPath}.${key}` : key\n\n // Skip internal fields\n if (\n key === 'id' ||\n key === '_id' ||\n key === 'createdAt' ||\n key === 'updatedAt' ||\n key === 'translationSync' ||\n key === '__v'\n ) {\n continue\n }\n\n // Add current field\n paths.push({\n parentPath,\n path: currentPath,\n value,\n })\n\n // Recursively process nested objects\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n paths.push(...extractFieldPaths(value, currentPath, fields))\n }\n\n // Process arrays\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n const arrayPath = `${currentPath}.${index}`\n if (item && typeof item === 'object') {\n paths.push(...extractFieldPaths(item, arrayPath, fields))\n }\n })\n }\n }\n\n return paths\n}\n\n/**\n * Filters out excluded paths from data before translation\n */\nexport function filterExcludedPaths(data: any, excludedPaths: string[]): any {\n if (!data || typeof data !== 'object' || excludedPaths.length === 0) {\n return data\n }\n\n const filtered = JSON.parse(JSON.stringify(data)) // Deep clone\n\n for (const excludedPath of excludedPaths) {\n deletePath(filtered, excludedPath)\n }\n\n return filtered\n}\n\n/**\n * Merges translated data back, respecting excluded paths\n */\nexport function mergeTranslatedData(\n originalData: any,\n translatedData: any,\n excludedPaths: string[],\n): any {\n if (!translatedData || typeof translatedData !== 'object') {\n return originalData\n }\n\n const merged = JSON.parse(JSON.stringify(originalData)) // Deep clone\n\n function merge(target: any, source: any, currentPath: string = ''): void {\n for (const key in source) {\n const fullPath = currentPath ? `${currentPath}.${key}` : key\n\n // Skip if this path is excluded\n if (isPathExcluded(fullPath, excludedPaths)) {\n continue\n }\n\n // Skip internal fields\n if (\n key === 'id' ||\n key === '_id' ||\n key === 'createdAt' ||\n key === 'updatedAt' ||\n key === 'translationSync' ||\n key === '__v'\n ) {\n continue\n }\n\n if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {\n if (!target[key]) {\n target[key] = {}\n }\n merge(target[key], source[key], fullPath)\n } else {\n target[key] = source[key]\n }\n }\n }\n\n merge(merged, translatedData)\n return merged\n}\n\n/**\n * Checks if a path is excluded or if any parent path is excluded\n */\nexport function isPathExcluded(path: string, excludedPaths: string[]): boolean {\n return excludedPaths.some((excludedPath) => {\n // Exact match\n if (path === excludedPath) {\n return true\n }\n\n // Check if path is a child of excluded path\n if (path.startsWith(`${excludedPath}.`)) {\n return true\n }\n\n // Check if excluded path is a pattern match for arrays (e.g., content.0.title)\n const pathParts = path.split('.')\n const excludedParts = excludedPath.split('.')\n\n for (let i = 0; i < Math.min(pathParts.length, excludedParts.length); i++) {\n if (excludedParts[i] !== pathParts[i]) {\n // Check if it's an array index difference\n if (!isNaN(Number(pathParts[i])) && !isNaN(Number(excludedParts[i]))) {\n continue\n }\n return false\n }\n }\n\n return excludedParts.length <= pathParts.length\n })\n}\n\n/**\n * Deletes a path from an object using dot notation\n */\nfunction deletePath(obj: any, path: string): void {\n const parts = path.split('.')\n let current = obj\n\n for (let i = 0; i < parts.length - 1; i++) {\n if (!current[parts[i]]) {\n return\n }\n current = current[parts[i]]\n }\n\n delete current[parts[parts.length - 1]]\n}\n\n/**\n * Gets value at path using dot notation\n */\nexport function getValueAtPath(obj: any, path: string): any {\n return path.split('.').reduce((current, part) => current?.[part], obj)\n}\n\n/**\n * Sets value at path using dot notation\n */\nexport function setValueAtPath(obj: any, path: string, value: any): void {\n const parts = path.split('.')\n let current = obj\n\n for (let i = 0; i < parts.length - 1; i++) {\n if (!current[parts[i]]) {\n current[parts[i]] = {}\n }\n current = current[parts[i]]\n }\n\n current[parts[parts.length - 1]] = value\n}\n\n/**\n * Checks if a field is a localized field\n */\nexport function isLocalizedField(field: Field): boolean {\n return 'localized' in field && field.localized === true\n}\n\n/**\n * Gets all localized field paths from a collection config\n */\nexport function getLocalizedFieldPaths(fields: Field[], parentPath: string = ''): string[] {\n const paths: string[] = []\n\n for (const field of fields) {\n if (!('name' in field)) {\n continue\n }\n\n const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name\n\n if (isLocalizedField(field)) {\n paths.push(fieldPath)\n }\n\n // Recursively check nested fields\n if ('fields' in field && Array.isArray(field.fields)) {\n paths.push(...getLocalizedFieldPaths(field.fields, fieldPath))\n }\n\n // Check blocks\n if (field.type === 'blocks' && 'blocks' in field && Array.isArray(field.blocks)) {\n for (const block of field.blocks) {\n if ('fields' in block && Array.isArray(block.fields)) {\n paths.push(...getLocalizedFieldPaths(block.fields, fieldPath))\n }\n }\n }\n\n // Check group fields\n if (field.type === 'group' && 'fields' in field && Array.isArray(field.fields)) {\n paths.push(...getLocalizedFieldPaths(field.fields, fieldPath))\n }\n\n // Check array fields\n if (field.type === 'array' && 'fields' in field && Array.isArray(field.fields)) {\n paths.push(...getLocalizedFieldPaths(field.fields, fieldPath))\n }\n }\n\n return paths\n}\n"],"names":["NON_TRANSLATABLE_FIELD_TYPES","Set","CONTAINER_FIELD_TYPES","overlayNonTranslatableValues","translated","original","fields","options","Array","isArray","inheritedLocalized","localizedOnly","field","type","name","undefined","isLocalized","localized","has","childOptions","forEach","item","index","blockDefs","blocks","originalItem","blockType","blockDef","find","b","slug","tabs","tab","tabName","tabLocalized","isEnumField","Boolean","shouldRestore","extractFieldPaths","data","parentPath","paths","key","value","Object","entries","currentPath","push","path","arrayPath","filterExcludedPaths","excludedPaths","length","filtered","JSON","parse","stringify","excludedPath","deletePath","mergeTranslatedData","originalData","translatedData","merged","merge","target","source","fullPath","isPathExcluded","some","startsWith","pathParts","split","excludedParts","i","Math","min","isNaN","Number","obj","parts","current","getValueAtPath","reduce","part","setValueAtPath","isLocalizedField","getLocalizedFieldPaths","fieldPath","block"],"mappings":"AAIA;;;;;;CAMC,GACD,MAAMA,+BAA+B,IAAIC,IAAI;IAAC;IAAU;CAAQ;AAEhE;;;;CAIC,GACD,MAAMC,wBAAwB,IAAID,IAAI;IAAC;IAAS;IAAU;IAAe;IAAS;IAAO;CAAO;AAiBhG;;;;;;;;;;CAUC,GACD,OAAO,SAASE,6BACdC,UAAe,EACfC,QAAa,EACbC,MAA2B,EAC3BC,UAA0B,CAAC,CAAC;IAE5B,IACE,CAACC,MAAMC,OAAO,CAACH,WACf,CAACF,cACD,OAAOA,eAAe,YACtB,CAACC,YACD,OAAOA,aAAa,UACpB;QACA;IACF;IAEA,MAAM,EAAEK,qBAAqB,KAAK,EAAEC,gBAAgB,KAAK,EAAE,GAAGJ;IAE9D,KAAK,MAAMK,SAASN,OAAiB;QACnC,MAAMO,OAAOD,OAAOC;QACpB,MAAMC,OAAO,OAAOF,OAAOE,SAAS,WAAWF,MAAME,IAAI,GAAGC;QAC5D,MAAMC,cAAcN,sBAAsBE,OAAOK,cAAc;QAE/D,sEAAsE;QACtE,IAAIJ,QAAQX,sBAAsBgB,GAAG,CAACL,OAAO;YAC3C,MAAMM,eAA+B;gBAAET,oBAAoBM;gBAAaL;YAAc;YAEtF,OAAQE;gBACN,KA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N,MAAM,EAAEiF;QACrD;IACF;IAEA,OAAO9C;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/fieldHelpers.ts"],"sourcesContent":["import type { Field } from 'payload'\n\n/**\n * Field types whose stored value is an option/enum constant rather than\n * human-readable prose. The Postgres adapter persists these as native `enum`\n * columns, so translating their values (e.g. \"narrow\" -> \"schmal\") produces an\n * invalid enum value and makes the locale-row INSERT fail with\n * `invalid input value for enum`. These must never be sent to the translator.\n */\nconst NON_TRANSLATABLE_FIELD_TYPES = new Set(['select', 'radio'])\n\n/**\n * Container field types that hold nested fields rather than a leaf value.\n * Localization (`localized: true`) set on a named container (`group`, `array`,\n * `blocks`, named `tab`) cascades to every field nested within it.\n */\nconst CONTAINER_FIELD_TYPES = new Set(['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'])\n\nexport type OverlayOptions = {\n /**\n * Localization inherited from an ancestor container (`group`/`array`/`blocks`/\n * named `tab`) that has `localized: true`. When true, every nested field is\n * treated as localized.\n */\n inheritedLocalized?: boolean\n /**\n * When true, only fields that are localized (directly or via an ancestor\n * container) are kept from `translated`; every non-localized field is restored\n * from `original` so it is effectively excluded from translation.\n */\n localizedOnly?: boolean\n}\n\n/**\n * Walks a Payload field schema and copies canonical (untranslated) values from\n * `original` back into `translated`, in place. A field's value is restored when:\n *\n * - it is a `select`/`radio` field (enum-backed; always restored), or\n * - `localizedOnly` is enabled and the field is not localized (directly or via\n * a localized ancestor container).\n *\n * This works regardless of which translation strategy produced `translated`\n * (optimized, legacy, or a custom translator).\n */\nexport function overlayNonTranslatableValues(\n translated: any,\n original: any,\n fields: Field[] | undefined,\n options: OverlayOptions = {},\n): void {\n if (\n !Array.isArray(fields) ||\n !translated ||\n typeof translated !== 'object' ||\n !original ||\n typeof original !== 'object'\n ) {\n return\n }\n\n const { inheritedLocalized = false, localizedOnly = false } = options\n\n for (const field of fields as any[]) {\n const type = field?.type\n const name = typeof field?.name === 'string' ? field.name : undefined\n const isLocalized = inheritedLocalized || field?.localized === true\n\n // Container fields: recurse, cascading localization to nested fields.\n if (type && CONTAINER_FIELD_TYPES.has(type)) {\n const childOptions: OverlayOptions = { inheritedLocalized: isLocalized, localizedOnly }\n\n switch (type) {\n case 'array':\n if (name && Array.isArray(translated[name]) && Array.isArray(original[name])) {\n translated[name].forEach((item: any, index: number) => {\n overlayNonTranslatableValues(item, original[name][index], field.fields, childOptions)\n })\n } else if (localizedOnly && name && !isLocalized && original[name] !== undefined) {\n translated[name] = original[name]\n }\n break\n\n case 'blocks':\n if (name && Array.isArray(translated[name]) && Array.isArray(original[name])) {\n const blockDefs: any[] = Array.isArray(field.blocks) ? field.blocks : []\n translated[name].forEach((item: any, index: number) => {\n const originalItem = original[name][index]\n const blockType = item?.blockType ?? originalItem?.blockType\n const blockDef = blockDefs.find((b) => b?.slug === blockType)\n if (blockDef) {\n overlayNonTranslatableValues(item, originalItem, blockDef.fields, childOptions)\n }\n })\n } else if (localizedOnly && name && !isLocalized && original[name] !== undefined) {\n translated[name] = original[name]\n }\n break\n\n case 'collapsible':\n case 'row':\n // Presentational wrappers share the parent object and cannot be localized.\n overlayNonTranslatableValues(translated, original, field.fields, {\n inheritedLocalized,\n localizedOnly,\n })\n break\n\n case 'group':\n if (name) {\n overlayNonTranslatableValues(\n translated[name],\n original[name],\n field.fields,\n childOptions,\n )\n }\n break\n\n case 'tabs':\n if (Array.isArray(field.tabs)) {\n for (const tab of field.tabs) {\n const tabName = typeof tab?.name === 'string' ? tab.name : undefined\n const tabLocalized = inheritedLocalized || tab?.localized === true\n if (tabName) {\n overlayNonTranslatableValues(translated[tabName], original[tabName], tab.fields, {\n inheritedLocalized: tabLocalized,\n localizedOnly,\n })\n } else {\n // Unnamed tabs share the parent object.\n overlayNonTranslatableValues(translated, original, tab.fields, {\n inheritedLocalized,\n localizedOnly,\n })\n }\n }\n }\n break\n }\n\n continue\n }\n\n // Leaf fields: restore the original value when it must not be translated.\n if (!name) {\n continue\n }\n\n const isEnumField = Boolean(type && NON_TRANSLATABLE_FIELD_TYPES.has(type))\n const shouldRestore = isEnumField || (localizedOnly && !isLocalized)\n\n if (shouldRestore && original[name] !== undefined) {\n translated[name] = original[name]\n }\n }\n}\n\n/**\n * Filters out excluded paths from data before translation\n */\nexport function filterExcludedPaths(data: any, excludedPaths: string[]): any {\n if (!data || typeof data !== 'object' || excludedPaths.length === 0) {\n return data\n }\n\n const filtered = JSON.parse(JSON.stringify(data)) // Deep clone\n\n for (const excludedPath of excludedPaths) {\n deletePath(filtered, excludedPath)\n }\n\n return filtered\n}\n\n/**\n * Deletes a path from an object using dot notation\n */\nfunction deletePath(obj: any, path: string): void {\n const parts = path.split('.')\n let current = obj\n\n for (let i = 0; i < parts.length - 1; i++) {\n if (!current[parts[i]]) {\n return\n }\n current = current[parts[i]]\n }\n\n delete current[parts[parts.length - 1]]\n}\n"],"names":["NON_TRANSLATABLE_FIELD_TYPES","Set","CONTAINER_FIELD_TYPES","overlayNonTranslatableValues","translated","original","fields","options","Array","isArray","inheritedLocalized","localizedOnly","field","type","name","undefined","isLocalized","localized","has","childOptions","forEach","item","index","blockDefs","blocks","originalItem","blockType","blockDef","find","b","slug","tabs","tab","tabName","tabLocalized","isEnumField","Boolean","shouldRestore","filterExcludedPaths","data","excludedPaths","length","filtered","JSON","parse","stringify","excludedPath","deletePath","obj","path","parts","split","current","i"],"mappings":"AAEA;;;;;;CAMC,GACD,MAAMA,+BAA+B,IAAIC,IAAI;IAAC;IAAU;CAAQ;AAEhE;;;;CAIC,GACD,MAAMC,wBAAwB,IAAID,IAAI;IAAC;IAAS;IAAU;IAAe;IAAS;IAAO;CAAO;AAiBhG;;;;;;;;;;CAUC,GACD,OAAO,SAASE,6BACdC,UAAe,EACfC,QAAa,EACbC,MAA2B,EAC3BC,UAA0B,CAAC,CAAC;IAE5B,IACE,CAACC,MAAMC,OAAO,CAACH,WACf,CAACF,cACD,OAAOA,eAAe,YACtB,CAACC,YACD,OAAOA,aAAa,UACpB;QACA;IACF;IAEA,MAAM,EA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,WAAW;YACjDX,UAAU,CAACU,KAAK,GAAGT,QAAQ,CAACS,KAAK;QACnC;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASwB,oBAAoBC,IAAS,EAAEC,aAAuB;IACpE,IAAI,CAACD,QAAQ,OAAOA,SAAS,YAAYC,cAAcC,MAAM,KAAK,GAAG;QACnE,OAAOF;IACT;IAEA,MAAMG,WAAWC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN,OAAO,aAAa;;IAE/D,KAAK,MAAMO,gBAAgBN,cAAe;QACxCO,WAAWL,UAAUI;IACvB;IAEA,OAAOJ;AACT;AAEA;;CAEC,GACD,SAASK,WAAWC,GAAQ,EAAEC,IAAY;IACxC,MAAMC,QAAQD,KAAKE,KAAK,CAAC;IACzB,IAAIC,UAAUJ;IAEd,IAAK,IAAIK,IAAI,GAAGA,IAAIH,MAAMT,MAAM,GAAG,GAAGY,IAAK;QACzC,IAAI,CAACD,OAAO,CAACF,KAAK,CAACG,EAAE,CAAC,EAAE;YACtB;QACF;QACAD,UAAUA,OAAO,CAACF,KAAK,CAACG,EAAE,CAAC;IAC7B;IAEA,OAAOD,OAAO,CAACF,KAAK,CAACA,MAAMT,MAAM,GAAG,EAAE,CAAC;AACzC"}
@@ -2,4 +2,4 @@ import type { Field } from 'payload';
2
2
  /**
3
3
  * Recursively injects TranslationControl component into all localized fields
4
4
  */
5
- export declare function injectTranslationControls(fields: Field[], defaultLocale: string, parentPath?: string): Field[];
5
+ export declare function injectTranslationControls(fields: Field[], defaultLocale: string, parentPath?: string, inheritedLocalized?: boolean): Field[];
@@ -1,12 +1,15 @@
1
1
  /**
2
2
  * Recursively injects TranslationControl component into all localized fields
3
- */ export function injectTranslationControls(fields, defaultLocale, parentPath = '') {
3
+ */ export function injectTranslationControls(fields, defaultLocale, parentPath = '', // Localization inherited from an ancestor container (group/array/blocks/
4
+ // named tab) that has `localized: true`. Payload cascades localization to
5
+ // every nested field, so a field can be localized without setting the flag
6
+ // itself.
7
+ inheritedLocalized = false) {
4
8
  return fields.map((field)=>{
5
- // Skip fields without names
6
- if (!('name' in field)) {
7
- return field;
8
- }
9
- const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name;
9
+ // Fields without names (e.g. `row`, `collapsible`) don't add a path segment,
10
+ // but their nested fields still need to be walked below.
11
+ const hasName = 'name' in field;
12
+ const fieldPath = hasName ? parentPath ? `${parentPath}.${field.name}` : field.name : parentPath;
10
13
  // Clone the field to avoid mutations
11
14
  const clonedField = {
12
15
  ...field
@@ -19,7 +22,8 @@
19
22
  clonedField.type === 'array' || // Arrays are containers
20
23
  clonedField.type === 'tabs' // Tabs are UI containers
21
24
  ;
22
- if ('localized' in clonedField && clonedField.localized === true && !shouldSkipControl) {
25
+ const isLocalized = inheritedLocalized || clonedField.localized === true;
26
+ if (hasName && isLocalized && !shouldSkipControl) {
23
27
  // Initialize admin if not present
24
28
  if (!clonedField.admin) {
25
29
  clonedField.admin = {};
@@ -51,9 +55,9 @@
51
55
  });
52
56
  }
53
57
  }
54
- // Recursively inject into nested fields
58
+ // Recursively inject into nested fields, cascading localization to children
55
59
  if ('fields' in clonedField && Array.isArray(clonedField.fields)) {
56
- clonedField.fields = injectTranslationControls(clonedField.fields, defaultLocale, fieldPath);
60
+ clonedField.fields = injectTranslationControls(clonedField.fields, defaultLocale, fieldPath, isLocalized);
57
61
  }
58
62
  // Recursively inject into tabs
59
63
  // Note: Tabs fields themselves don't create a path segment
@@ -65,9 +69,10 @@
65
69
  // If the tab has a name, use it as the path segment
66
70
  // Otherwise, use the parent path (tabs field itself doesn't create a path)
67
71
  const tabPath = tab.name ? parentPath ? `${parentPath}.${tab.name}` : tab.name : parentPath;
72
+ const tabLocalized = isLocalized || tab.localized === true;
68
73
  return {
69
74
  ...tab,
70
- fields: injectTranslationControls(tab.fields, defaultLocale, tabPath)
75
+ fields: injectTranslationControls(tab.fields, defaultLocale, tabPath, tabLocalized)
71
76
  };
72
77
  }
73
78
  return tab;
@@ -79,7 +84,7 @@
79
84
  if (block.fields) {
80
85
  return {
81
86
  ...block,
82
- fields: injectTranslationControls(block.fields, defaultLocale, fieldPath)
87
+ fields: injectTranslationControls(block.fields, defaultLocale, fieldPath, isLocalized)
83
88
  };
84
89
  }
85
90
  return block;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/injectTranslationControls.ts"],"sourcesContent":["import type { Field } from 'payload'\n\n/**\n * Recursively injects TranslationControl component into all localized fields\n */\nexport function injectTranslationControls(\n fields: Field[],\n defaultLocale: string,\n parentPath: string = '',\n): Field[] {\n return fields.map((field) => {\n // Skip fields without names\n if (!('name' in field)) {\n return field\n }\n\n const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name\n\n // Clone the field to avoid mutations\n const clonedField: any = { ...field }\n\n // Inject TranslationControl if the field is localized\n // Skip for container fields - they're just UI/structural, not actual data fields\n // Only their nested fields should have translation controls\n const shouldSkipControl =\n clonedField.type === 'group' || // Groups are containers\n clonedField.type === 'blocks' || // Blocks are containers\n clonedField.type === 'array' || // Arrays are containers\n clonedField.type === 'tabs' // Tabs are UI containers\n\n if ('localized' in clonedField && clonedField.localized === true && !shouldSkipControl) {\n // Initialize admin if not present\n if (!clonedField.admin) {\n clonedField.admin = {}\n }\n\n // Initialize components if not present\n if (!clonedField.admin.components) {\n clonedField.admin.components = {}\n }\n\n // Initialize afterInput if not present\n if (!clonedField.admin.components.afterInput) {\n clonedField.admin.components.afterInput = []\n }\n\n // Ensure afterInput is an array\n if (!Array.isArray(clonedField.admin.components.afterInput)) {\n clonedField.admin.components.afterInput = [clonedField.admin.components.afterInput]\n }\n\n // Check if TranslationControl is already added\n const hasTranslationControl = clonedField.admin.components.afterInput.some(\n (component: any) =>\n typeof component === 'object' &&\n component.path === '@pigment/auto-translate/client#TranslationControl',\n )\n\n // Add TranslationControl if not already present\n if (!hasTranslationControl) {\n clonedField.admin.components.afterInput.push({\n clientProps: {\n defaultLocale, // Pass default locale to component\n fieldPath,\n },\n path: '@pigment/auto-translate/client#TranslationControl',\n })\n }\n }\n\n // Recursively inject into nested fields\n if ('fields' in clonedField && Array.isArray(clonedField.fields)) {\n clonedField.fields = injectTranslationControls(clonedField.fields, defaultLocale, fieldPath)\n }\n\n // Recursively inject into tabs\n // Note: Tabs fields themselves don't create a path segment\n // Named tabs (with 'name' property) create their own path segment\n // Unnamed tabs use the parent path\n if ('tabs' in clonedField && Array.isArray(clonedField.tabs)) {\n clonedField.tabs = clonedField.tabs.map((tab: any) => {\n if (tab.fields) {\n // If the tab has a name, use it as the path segment\n // Otherwise, use the parent path (tabs field itself doesn't create a path)\n const tabPath = tab.name \n ? (parentPath ? `${parentPath}.${tab.name}` : tab.name)\n : parentPath\n \n return {\n ...tab,\n fields: injectTranslationControls(tab.fields, defaultLocale, tabPath),\n }\n }\n return tab\n })\n }\n\n // Recursively inject into blocks\n if (clonedField.type === 'blocks' && 'blocks' in clonedField) {\n clonedField.blocks = clonedField.blocks.map((block: any) => {\n if (block.fields) {\n return {\n ...block,\n fields: injectTranslationControls(block.fields, defaultLocale, fieldPath),\n }\n }\n return block\n })\n }\n\n return clonedField as Field\n })\n}\n"],"names":["injectTranslationControls","fields","defaultLocale","parentPath","map","field","fieldPath","name","clonedField","shouldSkipControl","type","localized","admin","components","afterInput","Array","isArray","hasTranslationControl","some","component","path","push","clientProps","tabs","tab","tabPath","blocks","block"],"mappings":"AAEA;;CAEC,GACD,OAAO,SAASA,0BACdC,MAAe,EACfC,aAAqB,EACrBC,aAAqB,EAAE;IAEvB,OAAOF,OAAOG,GAAG,CAAC,CAACC;QACjB,4BAA4B;QAC5B,IAAI,CAAE,CAAA,UAAUA,KAAI,GAAI;YACtB,OAAOA;QACT;QAEA,MAAMC,YAAYH,aAAa,GAAGA,WAAW,CAAC,EAAEE,MAAME,IAAI,EAAE,GAAGF,MAAME,IAAI;QAEzE,qCAAqC;QACrC,MAAMC,cAAmB;YAAE,GAAGH,KAAK;QAAC;QAEpC,sDAAsD;QACtD,iFAAiF;QACjF,4DAA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AAGD,0BAA0BQ,YAAYP,MAAM,EAAEC,eAAeI;QACpF;QAEA,+BAA+B;QAC/B,2DAA2D;QAC3D,kEAAkE;QAClE,mCAAmC;QACnC,IAAI,UAAUE,eAAeO,MAAMC,OAAO,CAACR,YAAYe,IAAI,GAAG;YAC5Df,YAAYe,IAAI,GAAGf,YAAYe,IAAI,CAACnB,GAAG,CAAC,CAACoB;gBACvC,IAAIA,IAAIvB,MAAM,EAAE;oBACd,oDAAoD;oBACpD,2EAA2E;oBAC3E,MAAMwB,UAAUD,IAAIjB,IAAI,GACnBJ,aAAa,GAAGA,WAAW,CAAC,EAAEqB,IAAIjB,IAAI,EAAE,GAAGiB,IAAIjB,IAAI,GACpDJ;oBAEJ,OAAO;wBACL,GAAGqB,GAAG;wBACNvB,QAAQD,0BAA0BwB,IAAIvB,MAAM,EAAEC,eAAeuB;oBAC/D;gBACF;gBACA,OAAOD;YACT;QACF;QAEA,iCAAiC;QACjC,IAAIhB,YAAYE,IAAI,KAAK,YAAY,YAAYF,aAAa;YAC5DA,YAAYkB,MAAM,GAAGlB,YAAYkB,MAAM,CAACtB,GAAG,CAAC,CAACuB;gBAC3C,IAAIA,MAAM1B,MAAM,EAAE;oBAChB,OAAO;wBACL,GAAG0B,KAAK;wBACR1B,QAAQD,0BAA0B2B,MAAM1B,MAAM,EAAEC,eAAeI;oBACjE;gBACF;gBACA,OAAOqB;YACT;QACF;QAEA,OAAOnB;IACT;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/injectTranslationControls.ts"],"sourcesContent":["import type { Field } from 'payload'\n\n/**\n * Recursively injects TranslationControl component into all localized fields\n */\nexport function injectTranslationControls(\n fields: Field[],\n defaultLocale: string,\n parentPath: string = '',\n // Localization inherited from an ancestor container (group/array/blocks/\n // named tab) that has `localized: true`. Payload cascades localization to\n // every nested field, so a field can be localized without setting the flag\n // itself.\n inheritedLocalized: boolean = false,\n): Field[] {\n return fields.map((field) => {\n // Fields without names (e.g. `row`, `collapsible`) don't add a path segment,\n // but their nested fields still need to be walked below.\n const hasName = 'name' in field\n const fieldPath = hasName ? (parentPath ? `${parentPath}.${field.name}` : field.name) : parentPath\n\n // Clone the field to avoid mutations\n const clonedField: any = { ...field }\n\n // Inject TranslationControl if the field is localized\n // Skip for container fields - they're just UI/structural, not actual data fields\n // Only their nested fields should have translation controls\n const shouldSkipControl =\n clonedField.type === 'group' || // Groups are containers\n clonedField.type === 'blocks' || // Blocks are containers\n clonedField.type === 'array' || // Arrays are containers\n clonedField.type === 'tabs' // Tabs are UI containers\n\n const isLocalized = inheritedLocalized || clonedField.localized === true\n\n if (hasName && isLocalized && !shouldSkipControl) {\n // Initialize admin if not present\n if (!clonedField.admin) {\n clonedField.admin = {}\n }\n\n // Initialize components if not present\n if (!clonedField.admin.components) {\n clonedField.admin.components = {}\n }\n\n // Initialize afterInput if not present\n if (!clonedField.admin.components.afterInput) {\n clonedField.admin.components.afterInput = []\n }\n\n // Ensure afterInput is an array\n if (!Array.isArray(clonedField.admin.components.afterInput)) {\n clonedField.admin.components.afterInput = [clonedField.admin.components.afterInput]\n }\n\n // Check if TranslationControl is already added\n const hasTranslationControl = clonedField.admin.components.afterInput.some(\n (component: any) =>\n typeof component === 'object' &&\n component.path === '@pigment/auto-translate/client#TranslationControl',\n )\n\n // Add TranslationControl if not already present\n if (!hasTranslationControl) {\n clonedField.admin.components.afterInput.push({\n clientProps: {\n defaultLocale, // Pass default locale to component\n fieldPath,\n },\n path: '@pigment/auto-translate/client#TranslationControl',\n })\n }\n }\n\n // Recursively inject into nested fields, cascading localization to children\n if ('fields' in clonedField && Array.isArray(clonedField.fields)) {\n clonedField.fields = injectTranslationControls(\n clonedField.fields,\n defaultLocale,\n fieldPath,\n isLocalized,\n )\n }\n\n // Recursively inject into tabs\n // Note: Tabs fields themselves don't create a path segment\n // Named tabs (with 'name' property) create their own path segment\n // Unnamed tabs use the parent path\n if ('tabs' in clonedField && Array.isArray(clonedField.tabs)) {\n clonedField.tabs = clonedField.tabs.map((tab: any) => {\n if (tab.fields) {\n // If the tab has a name, use it as the path segment\n // Otherwise, use the parent path (tabs field itself doesn't create a path)\n const tabPath = tab.name\n ? (parentPath ? `${parentPath}.${tab.name}` : tab.name)\n : parentPath\n\n const tabLocalized = isLocalized || tab.localized === true\n\n return {\n ...tab,\n fields: injectTranslationControls(tab.fields, defaultLocale, tabPath, tabLocalized),\n }\n }\n return tab\n })\n }\n\n // Recursively inject into blocks\n if (clonedField.type === 'blocks' && 'blocks' in clonedField) {\n clonedField.blocks = clonedField.blocks.map((block: any) => {\n if (block.fields) {\n return {\n ...block,\n fields: injectTranslationControls(block.fields, defaultLocale, fieldPath, isLocalized),\n }\n }\n return block\n })\n }\n\n return clonedField as Field\n })\n}\n"],"names":["injectTranslationControls","fields","defaultLocale","parentPath","inheritedLocalized","map","field","hasName","fieldPath","name","clonedField","shouldSkipControl","type","isLocalized","localized","admin","components","afterInput","Array","isArray","hasTranslationControl","some","component","path","push","clientProps","tabs","tab","tabPath","tabLocalized","blocks","block"],"mappings":"AAEA;;CAEC,GACD,OAAO,SAASA,0BACdC,MAAe,EACfC,aAAqB,EACrBC,aAAqB,EAAE,EACvB,yEAAyE;AACzE,0EAA0E;AAC1E,2EAA2E;AAC3E,UAAU;AACVC,qBAA8B,KAAK;IAEnC,OAAOH,OAAOI,GAAG,CAAC,CAACC;QACjB,6EAA6E;QAC7E,yDAAyD;QACzD,MAAMC,UAAU,UAAUD;QAC1B,MAAME,YAAYD,UAAWJ,aAAa,GAAGA,WAAW,CAAC,EAAEG,MAAMG,IAAI,EAAE,GAAGH,MAAMG,IAAI,GAAIN;QAExF,qCAAqC;QACrC,MAAMO,cAAmB;YAAE,GAAGJ,KAAK;QAAC;QAEpC,sDAAsD;QACtD,iFAAiF;QACjF,4DAA4D;QAC5D,MAAMK,oBACJD,YAAYE,IAAI,KAAK,WAAa,wBAAwB;QAC1DF,YAAYE,IAAI,KAAK,YAAa,wBAAwB;QAC1DF,YAAYE,IAAI,KAAK,WAAa,w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QACnC,IAAI,UAAUH,eAAeQ,MAAMC,OAAO,CAACT,YAAYgB,IAAI,GAAG;YAC5DhB,YAAYgB,IAAI,GAAGhB,YAAYgB,IAAI,CAACrB,GAAG,CAAC,CAACsB;gBACvC,IAAIA,IAAI1B,MAAM,EAAE;oBACd,oDAAoD;oBACpD,2EAA2E;oBAC3E,MAAM2B,UAAUD,IAAIlB,IAAI,GACnBN,aAAa,GAAGA,WAAW,CAAC,EAAEwB,IAAIlB,IAAI,EAAE,GAAGkB,IAAIlB,IAAI,GACpDN;oBAEJ,MAAM0B,eAAehB,eAAec,IAAIb,SAAS,KAAK;oBAEtD,OAAO;wBACL,GAAGa,GAAG;wBACN1B,QAAQD,0BAA0B2B,IAAI1B,MAAM,EAAEC,eAAe0B,SAASC;oBACxE;gBACF;gBACA,OAAOF;YACT;QACF;QAEA,iCAAiC;QACjC,IAAIjB,YAAYE,IAAI,KAAK,YAAY,YAAYF,aAAa;YAC5DA,YAAYoB,MAAM,GAAGpB,YAAYoB,MAAM,CAACzB,GAAG,CAAC,CAAC0B;gBAC3C,IAAIA,MAAM9B,MAAM,EAAE;oBAChB,OAAO;wBACL,GAAG8B,KAAK;wBACR9B,QAAQD,0BAA0B+B,MAAM9B,MAAM,EAAEC,eAAeM,WAAWK;oBAC5E;gBACF;gBACA,OAAOkB;YACT;QACF;QAEA,OAAOrB;IACT;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pigment/auto-translate",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Automatic translation plugin for Payload CMS with field-level exclusion controls and performance optimizations",
5
5
  "keywords": [
6
6
  "payload",
@@ -47,40 +47,16 @@
47
47
  "files": [
48
48
  "dist"
49
49
  ],
50
- "scripts": {
51
- "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
52
- "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
53
- "build:types": "tsc --outDir dist --rootDir ./src",
54
- "clean": "rimraf {dist,*.tsbuildinfo}",
55
- "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
56
- "dev": "next dev dev",
57
- "dev:generate-importmap": "pnpm dev:payload generate:importmap",
58
- "dev:generate-types": "pnpm dev:payload generate:types",
59
- "dev:migrate": "pnpm dev:payload migrate",
60
- "dev:migrate:create": "pnpm dev:payload migrate:create",
61
- "dev:migrate:down": "pnpm dev:payload migrate:down",
62
- "dev:migrate:fresh": "pnpm dev:payload migrate:fresh",
63
- "dev:migrate:status": "pnpm dev:payload migrate:status",
64
- "dev:payload": "dotenv -e ./dev/.env -- cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
65
- "generate:importmap": "pnpm dev:generate-importmap",
66
- "generate:types": "pnpm dev:generate-types",
67
- "lint": "eslint",
68
- "lint:fix": "eslint ./src --fix",
69
- "prepublishOnly": "pnpm clean && pnpm build",
70
- "test": "pnpm test:int && pnpm test:e2e",
71
- "test:e2e": "playwright test",
72
- "test:int": "vitest"
73
- },
74
50
  "devDependencies": {
75
51
  "@eslint/eslintrc": "^3.2.0",
76
- "@payloadcms/db-mongodb": "3.85.0",
77
- "@payloadcms/db-postgres": "3.85.0",
78
- "@payloadcms/db-sqlite": "3.85.0",
52
+ "@payloadcms/db-mongodb": "3.90.1",
53
+ "@payloadcms/db-postgres": "3.90.1",
54
+ "@payloadcms/db-sqlite": "3.90.1",
79
55
  "@payloadcms/eslint-config": "3.28.0",
80
- "@payloadcms/next": "3.85.0",
81
- "@payloadcms/plugin-nested-docs": "3.85.0",
82
- "@payloadcms/richtext-lexical": "3.85.0",
83
- "@payloadcms/ui": "3.85.0",
56
+ "@payloadcms/next": "3.90.1",
57
+ "@payloadcms/plugin-nested-docs": "3.90.1",
58
+ "@payloadcms/richtext-lexical": "3.90.1",
59
+ "@payloadcms/ui": "3.90.1",
84
60
  "@playwright/test": "^1.52.0",
85
61
  "@swc-node/register": "1.10.9",
86
62
  "@swc/cli": "0.6.0",
@@ -91,12 +67,12 @@
91
67
  "cross-env": "^7.0.3",
92
68
  "dotenv-cli": "^11.0.0",
93
69
  "eslint": "^9.23.0",
94
- "eslint-config-next": "16.2.6",
70
+ "eslint-config-next": "16.3.5",
95
71
  "graphql": "^16.8.1",
96
72
  "mongodb-memory-server": "10.1.4",
97
- "next": "16.2.6",
73
+ "next": "16.3.5",
98
74
  "open": "^10.1.0",
99
- "payload": "3.85.0",
75
+ "payload": "3.90.1",
100
76
  "prettier": "^3.4.2",
101
77
  "qs-esm": "7.0.2",
102
78
  "react": "19.2.6",
@@ -113,38 +89,33 @@
113
89
  },
114
90
  "engines": {
115
91
  "node": "^20.9.0 || >=22",
116
- "pnpm": "^9 || ^10"
117
- },
118
- "publishConfig": {
119
- "exports": {
120
- ".": {
121
- "types": "./dist/index.d.ts",
122
- "import": "./dist/index.js",
123
- "default": "./dist/index.js"
124
- },
125
- "./client": {
126
- "types": "./dist/exports/client.d.ts",
127
- "import": "./dist/exports/client.js",
128
- "default": "./dist/exports/client.js"
129
- },
130
- "./rsc": {
131
- "types": "./dist/exports/rsc.d.ts",
132
- "import": "./dist/exports/rsc.js",
133
- "default": "./dist/exports/rsc.js"
134
- }
135
- },
136
- "main": "./dist/index.js",
137
- "types": "./dist/index.d.ts"
138
- },
139
- "pnpm": {
140
- "onlyBuiltDependencies": [
141
- "sharp",
142
- "esbuild",
143
- "unrs-resolver"
144
- ]
92
+ "pnpm": "^9 || ^10 || ^11"
145
93
  },
146
94
  "registry": "https://registry.npmjs.org/",
147
95
  "dependencies": {
148
96
  "openai": "^6.8.0"
97
+ },
98
+ "scripts": {
99
+ "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
100
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
101
+ "build:types": "tsc --outDir dist --rootDir ./src",
102
+ "clean": "rimraf {dist,*.tsbuildinfo}",
103
+ "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
104
+ "dev": "next dev dev",
105
+ "dev:generate-importmap": "pnpm dev:payload generate:importmap",
106
+ "dev:generate-types": "pnpm dev:payload generate:types",
107
+ "dev:migrate": "pnpm dev:payload migrate",
108
+ "dev:migrate:create": "pnpm dev:payload migrate:create",
109
+ "dev:migrate:down": "pnpm dev:payload migrate:down",
110
+ "dev:migrate:fresh": "pnpm dev:payload migrate:fresh",
111
+ "dev:migrate:status": "pnpm dev:payload migrate:status",
112
+ "dev:payload": "dotenv -e ./dev/.env -- cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
113
+ "generate:importmap": "pnpm dev:generate-importmap",
114
+ "generate:types": "pnpm dev:generate-types",
115
+ "lint": "eslint",
116
+ "lint:fix": "eslint ./src --fix",
117
+ "test": "pnpm test:int && pnpm test:e2e",
118
+ "test:e2e": "playwright test",
119
+ "test:int": "vitest"
149
120
  }
150
- }
121
+ }
@@ -1,87 +0,0 @@
1
- .translation-settings-lock-container {
2
- display: inline-flex;
3
- }
4
-
5
- .translation-settings-lock-button {
6
- display: inline-flex;
7
- align-items: center;
8
- gap: 0.5rem;
9
- padding: 0.5rem 1rem;
10
- border: 1.5px solid var(--theme-elevation-400);
11
- border-radius: var(--border-radius-s, 4px);
12
- background: var(--theme-elevation-0);
13
- cursor: pointer;
14
- font-size: 13px;
15
- font-weight: 600;
16
- transition: all 0.2s ease;
17
- white-space: nowrap;
18
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
19
- outline: none;
20
- }
21
-
22
- .translation-settings-lock-button:hover {
23
- background: var(--theme-elevation-100);
24
- border-color: var(--theme-elevation-500);
25
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
26
- }
27
-
28
- .translation-settings-lock-button.locked {
29
- background: var(--theme-error-50);
30
- border-color: var(--theme-error-500);
31
- color: var(--theme-error-800);
32
- }
33
-
34
- .translation-settings-lock-button.locked:hover {
35
- background: var(--theme-error-100);
36
- border-color: var(--theme-error-600);
37
- transform: translateY(-1px);
38
- box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
39
- }
40
-
41
- .translation-settings-lock-button.unlocked {
42
- background: var(--theme-success-50);
43
- border-color: var(--theme-success-500);
44
- color: var(--theme-success-800);
45
- }
46
-
47
- .translation-settings-lock-button.unlocked:hover {
48
- background: var(--theme-success-100);
49
- border-color: var(--theme-success-600);
50
- transform: translateY(-1px);
51
- box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
52
- }
53
-
54
- .translation-settings-lock-icon {
55
- font-size: 16px;
56
- line-height: 1;
57
- }
58
-
59
- .translation-settings-lock-label {
60
- font-weight: 600;
61
- letter-spacing: 0.01em;
62
- }
63
-
64
- /* Style for locked input fields */
65
- .translation-settings-locked {
66
- background-color: var(--theme-elevation-50) !important;
67
- cursor: not-allowed !important;
68
- opacity: 0.7;
69
- }
70
-
71
- /* Style for locked save button */
72
- .translation-settings-save-locked {
73
- opacity: 0.5;
74
- cursor: not-allowed !important;
75
- }
76
-
77
- /* Responsive adjustments */
78
- @media (max-width: 768px) {
79
- .translation-settings-lock-button {
80
- font-size: 12px;
81
- padding: 0.4rem 0.75rem;
82
- }
83
-
84
- .translation-settings-lock-icon {
85
- font-size: 14px;
86
- }
87
- }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import './TranslationSettingsLock.css';
3
- /**
4
- * Component that provides lock/unlock functionality for translation settings
5
- * - Fields are locked by default (read-only)
6
- * - User must click "Unlock" to edit
7
- * - After saving, fields automatically lock again
8
- */
9
- export declare const TranslationSettingsLock: React.FC;