import type { CollectionAfterChangeHook } from 'payload'; import type { I18nConfig } from '../i18n/index.js'; type BuildCrossLocaleFieldSyncArgs = { /** * The localized `blocks`/`array` field whose rows hold the shared fields. * Default 'layout'. */ arrayField?: string; /** * Slug of the collection this hook is attached to — needed to re-read and * update the other locales. (A hook can't discover its own collection.) */ collection: string; config: I18nConfig; /** * Fields WITHIN each row that are conceptually language-independent (a shared * media reference, an icon, a color) and should be propagated from the edited * locale to every other locale — e.g. ['image'] or ['image', 'backgroundImage']. * * Only fields with a value in the source are copied: clearing a field in one * language does NOT wipe it in the others (conservative, matches the hand- * rolled hooks this replaces). Text and other truly-localized fields are never * touched. */ fields: string[]; /** * Flag name set on `req` to break the update→afterChange→update loop. * Default '_ipalSyncingCrossLocale'. Override only if two syncs run on one * collection and must not share a guard. */ guardFlag?: string; }; /** * Propagates language-independent fields (images, icons…) that live INSIDE a * localized `blocks`/`array` field from the just-edited locale to every other * configured locale. * * Why this exists: Payload localizes an array/blocks field as a whole, so there * is no way to mark a single sub-field (the image) as non-localized — each * locale keeps its own copy of every row, image included. Without this, an * editor who picks images in Polish has to re-pick the SAME images in English, * German, … This hook does that copy automatically. * * A0-safe: the locale list comes from `config`, never a hard-coded array — add * a language in the panel and it's covered with no code change. (The hand-rolled * versions this replaces carried a literal `['pl','en',...]` that silently * dropped any locale not listed.) * * Row matching: by Payload row `id` when the same id exists in both locales * (robust to reordering and to several blocks of the same type); otherwise it * falls back to the positional index, but only when the block types at that * index match — so it never writes an image into a block of a different type. * * // collections/Pages.ts * import { buildCrossLocaleFieldSync } from '@intecion/ipal-kit' * hooks: { * afterChange: [ * buildCrossLocaleFieldSync({ config: i18nConfig, collection: 'pages', fields: ['image'] }), * ], * } */ export declare function buildCrossLocaleFieldSync(args: BuildCrossLocaleFieldSyncArgs): CollectionAfterChangeHook; export {};