-
-
- {texts.message}
- {texts.privacyLink && (
- <>
- {' '}
-
- {texts.privacyLink.label}
-
- >
- )}
+ const settingsView = (
+
+
+
+ {icon && !modal && }
+ {texts.settingsTitle}
+
+ {modal && (
+
+ )}
+
+ {texts.settingsDescription &&
{texts.settingsDescription}
}
+
+ {CONSENT_CATEGORIES.map((cat) => (
+ -
+
+
+ {texts.categories[cat].title}
+
+
+ {texts.categories[cat].description}
-
-
-
-
+ {control(cat)}
+
+ ))}
+
+
{settingsActions.map(button)}
+
+ )
+
+ if (modal && showSettings) {
+ return (
+ {
+ if (event.target === event.currentTarget) {setShowSettings(false)}
+ }}
+ // klik w tło zamyka dialog; klawiatura: Escape (listener wyżej) i przycisk ✕
+ role="presentation"
+ >
+
+ {settingsView}
+
+
+ )
+ }
+
+ return (
+
+
+ {!showSettings ? (
+
+
+ {icon &&
}
+
+ {texts.eyebrow &&
{texts.eyebrow}
}
+ {texts.title &&
{texts.title}
}
+
+ {texts.message}
+ {texts.privacyLink && (
+ <>
+ {' '}
+
+ {texts.privacyLink.label}
+
+ >
+ )}
+
+
+
{order.map(button)}
) : (
-
-
-
- {texts.settingsTitle}
-
-
- {CONSENT_CATEGORIES.map((cat) => (
- -
-
-
- {texts.categories[cat].title}
-
-
- {texts.categories[cat].description}
-
-
- toggle(cat)}
- type="checkbox"
- />
-
- ))}
-
-
-
-
-
-
+ settingsView
)}
diff --git a/src/modules/consent/client.ts b/src/modules/consent/client.ts
index 08ca22a..45ff63f 100644
--- a/src/modules/consent/client.ts
+++ b/src/modules/consent/client.ts
@@ -2,7 +2,7 @@
export { ConsentProvider, useConsentContext } from './ConsentContext.js'
export { ConsentScript } from './ConsentScript.js'
export { CookieBanner } from './CookieBanner.js'
-export type { CookieBannerClassNames } from './CookieBanner.js'
+export type { CookieBannerAction, CookieBannerClassNames, CookieSettingsAction } from './CookieBanner.js'
export { CookieButton } from './CookieButton.js'
// Client-only consent exports — hook, provider, and UI components.
export { DEFAULT_COOKIE_MAP, useConsent } from './useConsent.js'
diff --git a/src/modules/consent/getConsentTexts.ts b/src/modules/consent/getConsentTexts.ts
index a4e74a8..49d1eef 100644
--- a/src/modules/consent/getConsentTexts.ts
+++ b/src/modules/consent/getConsentTexts.ts
@@ -13,6 +13,7 @@ const FALLBACK: ConsentTexts = {
buttons: {
acceptAll: 'Accept all',
back: 'Back',
+ close: 'Close',
reject: 'Reject',
save: 'Save preferences',
settings: 'Settings',
@@ -37,13 +38,17 @@ const FALLBACK: ConsentTexts = {
const FALLBACK_PRIVACY_LABEL = 'Privacy policy'
type CookieSettingsData = {
+ alwaysActiveLabel?: null | string
buttons?: null | Partial
categories?: Array<{ description?: null | string; key: string; title?: null | string }> | null
cookies?: Array<{ category?: null | string; duration?: null | string; name?: null | string; provider?: null | string; purpose?: null | string }> | null
+ eyebrow?: null | string
message?: null | string
policyVersion?: null | number
privacyLinkLabel?: null | string
+ settingsDescription?: null | string
settingsTitle?: null | string
+ title?: null | string
}
type PrivacyPage = { slug?: null | Record; title?: unknown } | null
@@ -135,6 +140,7 @@ export async function getConsentTexts({
buttons: {
acceptAll: g.buttons?.acceptAll || FALLBACK.buttons.acceptAll,
back: g.buttons?.back || FALLBACK.buttons.back,
+ close: g.buttons?.close || FALLBACK.buttons.close,
reject: g.buttons?.reject || FALLBACK.buttons.reject,
save: g.buttons?.save || FALLBACK.buttons.save,
settings: g.buttons?.settings || FALLBACK.buttons.settings,
@@ -143,6 +149,11 @@ export async function getConsentTexts({
message: g.message || FALLBACK.message,
privacyLink,
settingsTitle: g.settingsTitle || FALLBACK.settingsTitle,
+ // optional copy — no English fallback: empty in the panel = element not rendered
+ ...(g.eyebrow?.trim() ? { eyebrow: g.eyebrow.trim() } : {}),
+ ...(g.title?.trim() ? { title: g.title.trim() } : {}),
+ ...(g.settingsDescription?.trim() ? { settingsDescription: g.settingsDescription.trim() } : {}),
+ ...(g.alwaysActiveLabel?.trim() ? { alwaysActiveLabel: g.alwaysActiveLabel.trim() } : {}),
...(typeof g.policyVersion === 'number' && g.policyVersion >= 1 ? { version: Math.trunc(g.policyVersion) } : {}),
}
}
diff --git a/src/modules/consent/texts.ts b/src/modules/consent/texts.ts
index 7553171..fa8b4a1 100644
--- a/src/modules/consent/texts.ts
+++ b/src/modules/consent/texts.ts
@@ -1,18 +1,28 @@
import type { ConsentCategory } from './categories.js'
export type ConsentTexts = {
+ /** Badge next to the necessary category (e.g. "Always active"). Empty = no badge. */
+ alwaysActiveLabel?: string
buttons: {
acceptAll: string
back: string
+ /** Accessible label of the ✕ button closing the settings dialog. */
+ close: string
reject: string
save: string
settings: string
}
categories: Record
+ /** Small label above the banner title (e.g. "Privacy & cookies"). Empty = not shown. */
+ eyebrow?: string
message: string
/** null = no privacy-policy link shown */
privacyLink: { href: string; label: string } | null
+ /** Intro under the settings title. Empty = not shown. */
+ settingsDescription?: string
settingsTitle: string
+ /** Banner heading (e.g. "We respect your privacy"). Empty = not shown. */
+ title?: string
/** Policy version from the panel — a stored consent from another version asks again. */
version?: number
}
diff --git a/src/modules/integrations/status.ts b/src/modules/integrations/status.ts
index 601c90d..7bb39cb 100644
--- a/src/modules/integrations/status.ts
+++ b/src/modules/integrations/status.ts
@@ -54,7 +54,7 @@ export function buildIntegrationStatusBanner(statusField: string, label: string)
components: {
Field: {
clientProps: { label, statusField },
- path: '@intecion/ipal-kit/client#IntegrationStatusBanner',
+ path: '@intecion/ipal-kit/admin#IntegrationStatusBanner',
},
},
},
diff --git a/test/exports.test.ts b/test/exports.test.ts
index aff4825..f232917 100644
--- a/test/exports.test.ts
+++ b/test/exports.test.ts
@@ -35,3 +35,29 @@ describe('package exports', () => {
}
})
})
+
+describe('client entry', () => {
+ // Wszystko, co importuje /client, trafia do bundla strony publicznej — panel (@payloadcms/ui) to ~235 KB gz
+ test('does not pull admin UI (@payloadcms/ui, @payloadcms/next) into the site bundle', () => {
+ const seen = new Set()
+ const offenders: string[] = []
+ const resolve = (from: string, spec: string) => {
+ const base = path.resolve(path.dirname(from), spec).replace(/\.js$/, '')
+ return ['.ts', '.tsx', '/index.ts', '/index.tsx'].map((ext) => base + ext).find((f) => existsSync(f))
+ }
+ const walk = (file: string) => {
+ if (seen.has(file)) {return}
+ seen.add(file)
+ for (const m of readFileSync(file, 'utf8').matchAll(/(?:import|export)\s[^'"]*?from\s+['"](?[^'"]+)['"]/g)) {
+ const spec = m.groups!.spec
+ if (/^@payloadcms\/(?:ui|next)(?:\/|$)/.test(spec)) {offenders.push(`${path.relative(root, file)} → ${spec}`)}
+ if (spec.startsWith('.')) {
+ const next = resolve(file, spec)
+ if (next) {walk(next)}
+ }
+ }
+ }
+ walk(path.join(root, 'src/exports/client.ts'))
+ expect(offenders).toEqual([])
+ })
+})
diff --git a/test/integration.test.ts b/test/integration.test.ts
index 0980b7e..381be12 100644
--- a/test/integration.test.ts
+++ b/test/integration.test.ts
@@ -13,7 +13,7 @@ import { buildConfig, getPayload } from 'payload'
import { afterAll, beforeAll, describe, expect, test, vi } from 'vitest'
import { buildConsentLogEndpoint } from '../src/modules/consent/consentLog.js'
-import { getCookieTable } from '../src/modules/consent/getConsentTexts.js'
+import { getConsentTexts, getCookieTable } from '../src/modules/consent/getConsentTexts.js'
import { submitForm } from '../src/modules/forms/submitForm.js'
import { createContentHelpers } from '../src/modules/frontend/createContentHelpers.js'
import { createPageRoute } from '../src/modules/frontend/pageRoute.js'
@@ -304,6 +304,39 @@ describe('consent log', () => {
})
})
+describe('consent texts', () => {
+ const config = { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] } as const
+
+ test('optional banner copy is omitted when empty and passed through when set', async () => {
+ const empty = await getConsentTexts({ config, locale: 'pl', payload, privacyPolicy: false })
+ expect(empty.eyebrow).toBeUndefined()
+ expect(empty.title).toBeUndefined()
+ expect(empty.settingsDescription).toBeUndefined()
+ expect(empty.alwaysActiveLabel).toBeUndefined()
+ expect(empty.buttons.close).toBe('Close')
+
+ await payload.updateGlobal({
+ slug: 'cookie-settings' as never,
+ data: {
+ alwaysActiveLabel: 'Zawsze aktywne',
+ buttons: { close: 'Zamknij' },
+ eyebrow: 'Prywatność i cookies',
+ settingsDescription: 'Możesz zmienić wybór w dowolnym momencie.',
+ title: 'Szanujemy Twoją prywatność',
+ } as never,
+ locale: 'pl' as never,
+ })
+ const texts = await getConsentTexts({ config, locale: 'pl', payload, privacyPolicy: false })
+ expect(texts).toMatchObject({
+ alwaysActiveLabel: 'Zawsze aktywne',
+ buttons: { close: 'Zamknij' },
+ eyebrow: 'Prywatność i cookies',
+ settingsDescription: 'Możesz zmienić wybór w dowolnym momencie.',
+ title: 'Szanujemy Twoją prywatność',
+ })
+ })
+})
+
describe('cookie table', () => {
test('rows from Cookie Settings in the requested language', async () => {
await payload.updateGlobal({