import type { Field } from 'payload' import { LIGHTBOX_FALLBACK, LIGHTBOX_FALLBACK_PL } from '../../modules/lightbox/texts.js' import { NOTIFICATION_FALLBACK, NOTIFICATION_FALLBACK_PL } from '../../modules/notifications/defaults.js' const EN = NOTIFICATION_FALLBACK.form const PL = NOTIFICATION_FALLBACK_PL.form /** A form text: the default in both languages is the placeholder. */ const formText = ( name: keyof typeof EN, label: { en: string; pl: string }, extra: { description?: { en: string; pl: string }; width?: string } = {}, ): Field => ({ name, type: 'text', admin: { placeholder: { en: EN[name], pl: PL[name] }, ...(extra.description ? { description: extra.description } : {}), ...(extra.width ? { width: extra.width } : {}), }, label, localized: true, }) /** * Fields for the Notifications global — localized user-facing texts for action * results (form submission outcomes, and future contexts). Every text is * localized: true so each language has its own value. Empty fields fall back to * the built-in defaults of the page's language (see modules/notifications/defaults). * * Grouped per context. `form` holds the outcomes of submitForm; more groups * (e.g. `newsletter`, `system`) can be added the same way without touching * consumers — getNotificationTexts resolves whatever exists, falling back * per field. */ export const notificationsFields: Field[] = [ { name: 'form', type: 'group', admin: { description: { en: 'Shown to visitors after they send a form; leave a field empty to use the default.', pl: 'Widoczne dla odwiedzających po wysłaniu formularza; zostaw pole puste, aby użyć domyślnej wartości.', }, }, fields: [ formText('success', { en: 'Sent', pl: 'Wysłano' }), formText('error', { en: 'Error', pl: 'Błąd' }), formText('validation', { en: 'Field error', pl: 'Błąd pola' }, { description: { en: 'Use {field} for the field label.', pl: 'Użyj {field}, aby wstawić etykietę pola.' }, }), formText('consent', { en: 'Consent missing', pl: 'Brak zgody' }, { description: { en: 'Shown when the privacy policy box is not ticked.', pl: 'Widoczny, gdy pole zgody na politykę prywatności nie jest zaznaczone.', }, }), formText('turnstile', { en: 'Spam check failed', pl: 'Błąd weryfikacji' }), formText('rateLimited', { en: 'Too many attempts', pl: 'Zbyt wiele prób' }), formText('notFound', { en: 'Form unavailable', pl: 'Formularz niedostępny' }), { type: 'collapsible', admin: { initCollapsed: true }, fields: [ formText('fileTooLarge', { en: 'File too large', pl: 'Plik za duży' }, { description: { en: 'Use {file} for the file name and {max} for the limit in MB.', pl: 'Użyj {file}, aby wstawić nazwę pliku, i {max} — limit w MB.' }, }), formText('fileType', { en: 'Wrong file type', pl: 'Niedozwolony typ pliku' }, { description: { en: 'Use {file} for the file name and {types} for the accepted types.', pl: 'Użyj {file}, aby wstawić nazwę pliku, i {types} — dozwolone typy.' }, }), formText('fileRefused', { en: 'File refused', pl: 'Plik odrzucony' }, { description: { en: 'For a program, an archive, macros or content that does not match; use {file} and {types}.', pl: 'Dla programu, archiwum, makr lub niezgodnej zawartości; użyj {file} i {types}.', }, }), formText('fileCount', { en: 'Too many files', pl: 'Za dużo plików' }, { description: { en: 'Use {field} for the field label and {max} for the limit.', pl: 'Użyj {field}, aby wstawić etykietę pola, i {max} — limit.' }, }), formText('fileNotSent', { en: 'File not sent', pl: 'Plik niewysłany' }, { description: { en: 'Shown when the file could not be sent by e-mail; use {file} for the file name.', pl: 'Widoczny, gdy pliku nie udało się wysłać e-mailem; użyj {file}, aby wstawić nazwę pliku.' }, }), formText('fileOptional', { en: 'Optional file hint', pl: 'Wskazówka: plik opcjonalny' }, { description: { en: 'Added to a file message when the file field is not required.', pl: 'Dodawana do komunikatu o pliku, gdy pole pliku nie jest wymagane.' }, }), formText('fileRemove', { en: 'Remove file button', pl: 'Przycisk usuwania pliku' }, { description: { en: 'Use {file} for the file name.', pl: 'Użyj {file}, aby wstawić nazwę pliku.' }, }), ], label: { en: 'Files', pl: 'Pliki' }, }, { type: 'row', fields: [ formText('next', { en: 'Next button', pl: 'Przycisk „Dalej”' }, { width: '33%' }), formText('back', { en: 'Back button', pl: 'Przycisk „Wstecz”' }, { width: '33%' }), formText('stepOf', { en: 'Step counter', pl: 'Licznik kroków' }, { description: { en: 'Use {current} and {total} for the numbers.', pl: 'Użyj {current} i {total}, aby wstawić liczby.' }, width: '34%', }), ], }, ], label: { en: 'Forms', pl: 'Formularze' }, }, ] const lightboxText = ( name: keyof typeof LIGHTBOX_FALLBACK, label: { en: string; pl: string }, width: string, description?: { en: string; pl: string }, ): Field => ({ name, type: 'text', admin: { placeholder: { en: LIGHTBOX_FALLBACK[name], pl: LIGHTBOX_FALLBACK_PL[name] }, width, ...(description ? { description } : {}) }, label, localized: true, }) /** * The "Image viewer" group (`lightbox`) — labels of the image viewer (). * Added by ipalKit `lightbox: true`; exported so a project can place it in its * own global instead. */ export const lightboxNotificationFields: Field = { name: 'lightbox', type: 'group', admin: { description: { en: 'Read by screen readers in the enlarged image view; leave a field empty to use the default.', pl: 'Odczytywane przez czytniki ekranu w podglądzie zdjęcia; zostaw pole puste, aby użyć domyślnej wartości.', }, }, fields: [ { type: 'row', fields: [ lightboxText('open', { en: 'Enlarge button', pl: 'Przycisk powiększenia' }, '50%', { en: 'The image description is added after it.', pl: 'Po tekście dodawany jest opis zdjęcia.', }), lightboxText('dialog', { en: 'Viewer name', pl: 'Nazwa podglądu' }, '50%'), ], }, { type: 'row', fields: [ lightboxText('previous', { en: 'Previous button', pl: 'Przycisk „Poprzednie”' }, '25%'), lightboxText('next', { en: 'Next button', pl: 'Przycisk „Następne”' }, '25%'), lightboxText('close', { en: 'Close button', pl: 'Przycisk „Zamknij”' }, '25%'), lightboxText('counter', { en: 'Image counter', pl: 'Licznik zdjęć' }, '25%', { en: 'Use {current} and {total} for the numbers.', pl: 'Użyj {current} i {total}, aby wstawić liczby.', }), ], }, ], label: { en: 'Image viewer', pl: 'Podgląd zdjęć' }, }