Compare commits

...
2 Commits
Author SHA1 Message Date
Radosław Smoliński 12fbd424a5 1.12.3
CI / check (push) Canceled after 0s
2026-10-21 18:16:31 +02:00
Radosław SmolińskiandClaude Opus 5.5 6b4336f961 Detailed cookie settings window (CookieBanner settings="detailed")
A third settings mode next to 'inline' and 'modal': a large dialog where every consent
category is a card with its on/off control, description and an expandable list of the
cookies it covers (name, provider, purpose, duration), taken from Cookie Settings → Cookies
— the same rows as <CookieTable>. The developer picks the mode with one prop; the
component default stays 'inline', so existing sites are unchanged.

Cookie Settings gets a localized detailLabels group (list labels, English fallback);
getConsentTexts passes texts.cookies and texts.details, sharing the row mapping with
getCookieTable. New classNames slots and data-ipal handles for the cards and lists.

Docs for devs and agents: consent.md (modes compared, which to pick — new projects default
to 'detailed' when the cookie list is filled), AGENT.md, PROGRAMISTA §2.8/§2.11/§6, skills
ipal-setup, ipal-site, ipal-upgrade, ipal-locale-add, ipal-consent-check. Postgres/SQLite
projects need migrate:create for the new fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 18:16:30 +02:00
18 changed files with 279 additions and 55 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ export default async function LocaleLayout({ children, params }: Props) {
return (
<html lang={locale}>
<body>
<SiteProviders banner={<CookieBanner equalChoice />} logEndpoint="/api/ipal/consent" shell={await getSiteShell(locale)} stats={{ locale }}>
<SiteProviders banner={<CookieBanner controls="switch" equalChoice settings="detailed" />} logEndpoint="/api/ipal/consent" shell={await getSiteShell(locale)} stats={{ locale }}>
<main>{children}</main>
</SiteProviders>
</body>
+23
View File
@@ -8,6 +8,29 @@ wersji naraz przejdź po kolei wszystkie sekcje „Wymaga zmian w projekcie” o
wersji, którą masz. Nowe wydanie = nowa sekcja na górze; najstarsze usuwamy
dopiero powyżej 20.
## 1.12.3
### Nowe
- **Duże okno ustawień cookies ze szczegółami** — `<CookieBanner settings="detailed" />`. Każda kategoria to karta
z przełącznikiem (wł./wył.), opisem i rozwijaną listą ciasteczek, które obejmuje (nazwa, dostawca, cel, czas) —
z **Cookie Settings → Cookies**. Tryb wybiera programista: `'inline'` (domyślnie, bez zmian), `'modal'`,
`'detailed'`. Nowa grupa w globalu **Cookie Settings → Detail labels** (podpisy listy, per język; puste →
angielskie). `ConsentTexts` ma opcjonalne `cookies` i `details` (wypełnia je `getConsentTexts`). Nowe sloty
`classNames`: `categoryCard`, `cookies`, `cookiesToggle`, `cookieList`, `cookie`, `cookieName`, `cookieMeta`.
consent.md → „Duże okno ze szczegółami”.
### Dokumentacja
- consent.md: porównanie trzech trybów `settings`, który wybrać (brief milczy → `detailed` przy wypełnionej liście
Cookies), nowe pola w tabeli tekstów z panelu, sloty i uchwyty `data-ipal`.
- AGENT.md (§0b poz. 12, §7, compliance), PROGRAMISTA §2.8 / §2.11 / §6 poz. 46, skille `ipal-setup`, `ipal-site`,
`ipal-upgrade`, `ipal-locale-add` (Detail labels i Cookies w każdym języku), `ipal-consent-check` (import zasila
też okno `detailed` — sprawdź je po imporcie).
### Wymaga zmian w projekcie
1. Postgres/SQLite: nowe pola w globalu Cookie Settings → `payload migrate:create`. MongoDB bez zmian.
2. Opcjonalnie: `<CookieBanner settings="detailed" />`, wypełnij Cookie Settings → Cookies (skan:
`ipal-consent-check` → cookie-scan) i Detail labels w każdym języku.
## 1.12.2
### Poprawki
+1 -1
View File
@@ -15,7 +15,7 @@ Szczegóły API — jeden plik na moduł:
| Widget dostępności (opcjonalny) | [accessibility.md](./accessibility.md) |
| GA4, GTM, Meta Pixel, Clarity, LinkedIn, TikTok, `defer` | [analytics.md](./analytics.md) |
| Bloki, RenderBlocks, enhanceProps | [blocks.md](./blocks.md) |
| Zgoda cookies, baner | [consent.md](./consent.md) |
| Zgoda cookies, baner, okno ustawień (w pasku / modal / duże ze szczegółami ciasteczek) | [consent.md](./consent.md) |
| Strona w budowie — blokada podstron z popupem (narzędzie deweloperskie) | [construction.md](./construction.md) |
| Routing, archiwa, redirecty, Markdown, wyszukiwarka | [content.md](./content.md) |
| Email SMTP / Graph | [email.md](./email.md) |
+3 -2
View File
@@ -63,7 +63,7 @@ strona), **P** = test w panelu. Pełny kod: PROGRAMISTA.md §2.
| 9 | **Media / R2 / szybkość** | `Media` z `focalPoint`, `normalizeFilenameHook`, `buildOptimizeUploadHook`, `buildMediaPlaceholderHook` + pole; **zawsze** `buildR2Storage(['media'], { s3Storage })` + `@payloadcms/storage-s3`; `R2_*` w `.env.example`; `<MediaPreconnect/>`; `images: buildImagesConfig()` i `buildUploadSecurityHeaders()` w `next.config.ts`; `<Media>` projektu przez `mediaImageProps`/`videoProps` (§6.11b) | `buildR2Storage`, `mediaImageProps`, `videoProps`, `buildImagesConfig` | A, S |
| 10 | **Formularze** | każdy formularz z **seeda** (`scripts/seed-form-*.ts`: pola, potwierdzenie, mail do firmy **i** potwierdzenie do klienta, każdy język); blok z `<RenderForm>` + `formClasses.ts` (wygląd, raz); `actions.ts` = `createSubmitAction({ getCachedPayload, headers })`; `forms: {…}` w `ipalKit`; `email: mailAdapter()` | `RenderForm` (`/rsc`), `createSubmitAction`, `mailAdapter` | A, P |
| 11 | **Turnstile** | `<SiteProviders>` w `[locale]/layout.tsx` (wpina `TurnstileProvider` z kluczem z panelu); widget renderuje `RenderForm`; klucze w Site Integrations | `SiteProviders`, `getTurnstileConfig`, `TurnstileProvider` | A, P |
| 12 | Zgoda + analityka | `<SiteProviders logEndpoint="/api/ipal/consent" banner={<CookieBanner equalChoice />}>` (ConsentProvider, baner, CookieButton, Analytics w dobrej kolejności); ID narzędzi w panelu; lista ciasteczek ze skanu (cookie-scan → import) + `<CookieTable>` na stronie polityki cookies | consent.md, analytics.md | A, `ipal-consent-check` |
| 12 | Zgoda + analityka | `<SiteProviders logEndpoint="/api/ipal/consent" banner={<CookieBanner equalChoice settings="detailed" />}>` (ConsentProvider, baner, CookieButton, Analytics w dobrej kolejności); tryb okna ustawień (`settings`: `inline` / `modal` / `detailed`) wg designu, brief milczy → `detailed`, decyzja do „Ustaleń projektu”; ID narzędzi w panelu; lista ciasteczek ze skanu (cookie-scan → import) — zasila `<CookieTable>` na stronie polityki **i** listy w oknie `detailed`; Cookie Settings → Detail labels w każdym języku | consent.md, analytics.md | A, `ipal-consent-check` |
| 13 | Bezpieczeństwo | `buildSecurityHeaders` w `next.config.ts`; `twoFactor: { issuer, plugin: payloadTotp }`; CSP `report-only` → `enforce`; `IPAL_IP_HEADER` na produkcji | security.md, forms.md | A |
| 14 | Operacje | `src/app/api/health/route.ts` (`healthRoute`); `src/instrumentation.ts` z `assertEnv(ipalEnvRules({ storage: true, ipHeader: true }))`; staging z `IPAL_NOINDEX=1`; testy smoke (§8a) | `healthRoute`, `assertEnv`, `ipalEnvRules` | A |
| 15 | Strony systemowe | Site Settings → System Pages: homepage, 404, polityka prywatności, cookies; linki prawne w stopce przez rolę (`getSystemLinks(locale)`) | `getSystemLinks`, `getSystemPagePath`, `getNotFoundPage` | P |
@@ -844,6 +844,7 @@ projekcie → **ipal-plugin-gap**, nie kopia.
| Potrzeba | Użyj | Doc |
|---|---|---|
| Baner, ustawienia, przycisk cookies | `<SiteProviders banner={<CookieBanner …/>}>`, `CookieButton`, `useConsent` | consent.md |
| Okno ustawień: w pasku / małe / duże ze szczegółami ciasteczek | `<CookieBanner settings="inline" \| "modal" \| "detailed">` — nie buduj własnego okna ani listy ciasteczek | consent.md → „Duże okno ze szczegółami” |
| Skrypt zależny od zgody | `ConsentScript` | consent.md |
| Tabela ciasteczek na polityce | `<CookieTable>` (`/rsc`), `getCookieTable` | consent.md |
| GA4, GTM, Pixel, Clarity, LinkedIn, TikTok | ID w panelu — `SiteProviders` ładuje `Analytics` (`analytics={{ defer: true }}`) | analytics.md |
@@ -855,7 +856,7 @@ projekcie → **ipal-plugin-gap**, nie kopia.
**Compliance (PL/EU) — mechanizm z pluginu, treść od klienta:** strony polityk
jako System Pages, `CookieBanner` + `CookieButton`, checkbox `consent` w
formularzach (enforcement server-side), dane administratora w globalu, tabela
ciasteczek z panelu (`<CookieTable>`, skan: ipal-consent-check). Treści prawnych nie piszesz. Widget dostępności — tylko gdy klient
ciasteczek z panelu (`<CookieTable>` i okno `settings="detailed"`, skan: ipal-consent-check). Treści prawnych nie piszesz. Widget dostępności — tylko gdy klient
wymaga (accessibility.md).
**Bezpieczeństwo:** 2FA wymuszone (`ipalKit({ twoFactor: { issuer, plugin:
@@ -36,7 +36,7 @@ się załadować wcześniej tylko z sygnałem Consent Mode „denied” i bez ci
renderowany albo starsza wersja ipal-kit bez atrybutów `data-ipal` na przyciskach → **ipal-upgrade**.
Skrypt wymaga przycisków z `data-ipal="accept"` / `"reject"` — ma je
`CookieBanner` z pluginu. Własny baner w projekcie to naruszenie AGENT.md §7.
`CookieBanner` z pluginu w każdym trybie `settings` (`inline`, `modal`, `detailed`). Własny baner w projekcie to naruszenie AGENT.md §7.
## Lista ciasteczek do polityki cookies (cookie-scan)
@@ -55,7 +55,10 @@ Po każdej zmianie narzędzi (nowy piksel, czat, mapa, wideo) i przed oddaniem s
LOCALE=pl pnpm payload run .agents/skills/ipal-consent-check/scripts/import-cookies.ts cookie-scan/cookies.json
```
Łączy po nazwie, nie nadpisuje zmian redaktora (`OVERWRITE=1` wymusza). Nie usuwa ciasteczek,
których skan nie widział — to robi redaktor w panelu.
których skan nie widział — to robi redaktor w panelu. Ta sama lista zasila okno
`<CookieBanner settings="detailed">` (rozwijana lista pod każdą kategorią) — po imporcie otwórz
„Ustawienia” w banerze i sprawdź, że każda kategoria pokazuje swoje ciasteczka, a podpisy
(Cookie Settings → Detail labels) są w danym języku.
3. Strona polityki cookies pokazuje tabelę z panelu — **nie wklejaj listy do treści polityki**:
```tsx
import { getCookieTable, getConsentTexts } from '@intecion/ipal-kit'
@@ -1,6 +1,7 @@
/**
* Imports a cookie-scan result into Cookie Settings → Cookies (panel), so the
* cookie policy page (<CookieTable>) lists what the site really sets.
* cookie policy page (<CookieTable>) and the detailed consent window
* (<CookieBanner settings="detailed">) list what the site really sets.
*
* LOCALE=pl pnpm payload run .agents/skills/ipal-consent-check/scripts/import-cookies.ts cookie-scan/cookies.json
* # second language: scan again with --lang en, then import with LOCALE=en
+1 -1
View File
@@ -53,7 +53,7 @@ Uzupełnij w tej kolejności (panel albo skrypt Local API z `locale: 'de'`):
| Homepage/404/polityka | System Pages (relacje wspólne) + ich slug w `de` | `/de` → 404, link polityki pusty |
| Header / Footer — etykiety linków | globale nawigacji | puste pozycje menu |
| Site Settings — nazwa, opis, OG | Site Settings | tytuł/OG z fallbacku |
| Cookie Settings — wszystkie teksty + `privacyLinkLabel` | Cookie Settings | baner w innym języku (RODO: zgoda musi być zrozumiała) |
| Cookie Settings — wszystkie teksty + `privacyLinkLabel`, Detail labels, Cookies (`purpose`, `duration`) | Cookie Settings | baner / okno `detailed` w innym języku (RODO: zgoda musi być zrozumiała); skan + import z `--lang <kod>` (ipal-consent-check) |
| Notifications — `form.*` | Notifications | komunikaty formularza z angielskiego fallbacku |
| Forms — etykiety pól, potwierdzenie, Emails | Forms (każdy formularz) | formularz w złym języku |
| SEO tab — meta title/description | każda strona | duplikaty/braki w seo-check |
+3 -2
View File
@@ -39,7 +39,8 @@ tylko, gdy użytkownik o to poprosi. Pełna budowa strony: skill **ipal-site**.
przez `next/font` z `latin-ext`, `@source` na plugin (AGENT.md §6.11, przykład w `../ipal-block/resources/kod-sekcji.md`).
6. **Routing** — `proxy.ts` (`createProxy(i18nConfig, { NextResponse, markdown: true })`), `lib/content.ts`
(`createContentHelpers` z `markdownAlternate: true`, `summaryField`, `mcp` — PROGRAMISTA §2.7),
layout bez `<head>`: `<SiteProviders shell={await getSiteShell(locale)} logEndpoint banner={<CookieBanner equalChoice />}>`,
layout bez `<head>`: `<SiteProviders shell={await getSiteShell(locale)} logEndpoint banner={<CookieBanner equalChoice settings="detailed" />}>`
(tryb okna ustawień `inline` / `modal` / `detailed` wg designu — consent.md),
catch-all: `createPageRoute(content, { blocks, notFound, permanentRedirect, blockProps })` + literał `revalidate`,
`not-found.tsx`: `createNotFoundPage(content, { load: loadNotFoundView })` + `notFoundView.ts` z
`renderNotFoundView` (PROGRAMISTA §2.6–2.8, pages.md).
@@ -53,7 +54,7 @@ tylko, gdy użytkownik o to poprosi. Pełna budowa strony: skill **ipal-site**.
wpuszcza boty AI (PROGRAMISTA §2.8, AGENT.md §0b.5–8).
9. **Formularze** — skill **ipal-form**: blok z `<RenderForm>`, `formClasses.ts`, `createSubmitAction` raz, każdy formularz z seeda
(mail do firmy + potwierdzenie do klienta). Cookies: skan + import (ipal-consent-check), `<CookieTable>`
na stronie polityki cookies.
na stronie polityki cookies; ta sama lista pokazuje się w oknie `settings="detailed"` (Detail labels w panelu).
10. **Nawigacja** — skill **ipal-nav**.
11. **Kontrola kompletu** — `pnpm generate:types`, `pnpm payload generate:importmap`,
**ipal-audit** (pełny) = 0 błędów, w tym sekcja „missing: …” (§0b); po
+2 -2
View File
@@ -68,8 +68,8 @@ formularz z polami w JSX, trasa `api/contact`, `nodemailer`, reCAPTCHA (AGENT.md
Nie wymyślaj danych firmy, cen, opinii, liczb, certyfikatów, nazwisk.
2. `pnpm payload run scripts/seed-content.ts` → lista placeholderów trafia do raportu.
3. System Pages: Homepage, 404, polityka prywatności (strona istnieje; treść
polityki od klienta → placeholder). Cookie Settings, Notifications — teksty w
każdym języku.
polityki od klienta → placeholder). Cookie Settings (z Detail labels i listą Cookies
ze skanu), Notifications — teksty w każdym języku.
4. **ipal-locale-add → `locale-coverage`** = 0 braków (albo świadome w raporcie).
5. Obrazy: zostawiasz puste pola upload (redaktor dodaje) albo wgrywasz pliki z
briefu przez panel — przygotowane (WebP/JPG ≤ 1.5 MB, ≤ 2560 px).
+5
View File
@@ -50,6 +50,11 @@ własny spis treści (→ `extractHeadings` + `TableOfContents` + `headingIds`),
`CmsLink['appearance']` (typy linków bez stylu to teraz `CmsLinkPlain`). Cookie Settings: `buttons.save` →
`buttons.savePreferences` — w `migrate:create` wybierz **rename** kolumny, żeby zachować teksty.
**→ 1.12.3 (PROGRAMISTA §6, poz. 46):** Postgres/SQLite: `migrate:create` (nowa grupa Cookie Settings →
`detailLabels`, same nowe kolumny — bez rename). Własne okno ustawień cookies albo lista ciasteczek dopisana do
banera → `<CookieBanner settings="detailed">` i usuń kopię. Przy `detailed`: Cookie Settings → Cookies wypełnione
(skan, **ipal-consent-check**) i Detail labels w każdym języku.
## 2. Inwentaryzacja (bez zmian w kodzie)
Dla **każdej** pozycji tabeli PROGRAMISTA §6 pokaż dowód (grep / plik), czy
dotyczy projektu. Uruchom skill **ipal-audit** (`--quick`) i dołącz wynik.
+39 -4
View File
@@ -2,8 +2,9 @@
Banner zgody na cookies (GDPR): 4 kategorie (necessary / functional /
analytics / marketing), zapis w cookie z wersjonowaniem, Google Consent Mode,
treść z globala CookieSettings. Domyślny wygląd w czystym Tailwind,
nadpisywalny.
treść z globala CookieSettings. Okno ustawień w trzech trybach do wyboru
(`settings`: w pasku, małe okno, duże okno ze szczegółami ciasteczek). Domyślny
wygląd w czystym Tailwind, nadpisywalny.
## Zależność
@@ -177,7 +178,8 @@ Podany className zastępuje domyślny (nie dokleja się). Każdy element ma swó
| `actions` | rząd przycisków banera |
| `primaryButton`, `secondaryButton` | dwa style przycisków (domyślne dla wszystkich) |
| `acceptButton`, `rejectButton`, `settingsButton`, `saveButton`, `backButton` | pojedyncze przyciski — puste → `primaryButton` / `secondaryButton` |
| `overlay`, `dialog`, `closeButton` | modal ustawień (`settings="modal"`) |
| `overlay`, `dialog`, `closeButton` | modal ustawień (`settings="modal"` / `"detailed"`) |
| `categoryCard`, `cookies`, `cookiesToggle`, `cookieList`, `cookie`, `cookieName`, `cookieMeta` | duże okno (`settings="detailed"`): karta kategorii, rozwijana lista ciasteczek, jedno ciasteczko, nazwa, siatka dostawca / cel / czas |
| `settingsTitle`, `settingsDescription`, `categories`, `category`, `categoryTitle`, `categoryDescription` | widok ustawień |
| `control`, `controlThumb`, `badge` | checkbox / przełącznik, kciuk przełącznika, znacznik „Zawsze aktywne” |
| `settingsActions` | rząd przycisków pod kategoriami |
@@ -198,6 +200,36 @@ Podany className zastępuje domyślny (nie dokleja się). Każdy element ma swó
Domyślnie (bez tych propsów) baner wygląda i działa jak przed 1.10.0.
### Duże okno ze szczegółami (`settings="detailed"`, 1.12.3)
Trzy tryby ustawień do wyboru w projekcie — jeden prop:
| `settings` | Co widzi użytkownik po „Ustawienia” |
|---|---|
| `'inline'` (domyślnie) | kategorie w samym pasku banera |
| `'modal'` | małe okno na środku: kategoria + krótki opis + przełącznik |
| `'detailed'` | duże okno: każda kategoria to karta z przełącznikiem, opisem i rozwijaną listą jej ciasteczek (nazwa, dostawca, cel, czas przechowywania) |
```tsx
<CookieBanner equalChoice controls="switch" settings="detailed" />
```
Lista ciasteczek bierze się z **Cookie Settings → Cookies** (to samo źródło co `<CookieTable>` na stronie
polityki), filtrowana po kategorii — kategoria bez wpisów nie ma rozwijanej listy. Podpisy listy: **Cookie
Settings → Detail labels** (`cookies` — np. „Używane ciasteczka”, licznik dopisuje się sam; `provider`, `purpose`,
`duration`), per język; puste → angielskie. `getConsentTexts` przekazuje to w `texts.cookies` / `texts.details`
— nic nie trzeba podawać w kodzie. Zamykanie jak w `'modal'` (✕, Escape, klik w tło). Domyślna szerokość okna
`max-w-4xl` — zmiana przez `classNames.dialog`.
Który tryb wybrać: decyduje design projektu. Brief milczy → `'detailed'` (użytkownik widzi przy zgodzie, jakie
ciasteczka i od kogo — pełna informacja w miejscu decyzji), pod warunkiem że lista Cookies jest wypełniona ze skanu
(`ipal-consent-check` → cookie-scan); pusta lista = okno bez rozwijanych list, wtedy wystarczy `'modal'`. Decyzję
zapisz w `AGENTS.md` → „Ustalenia projektu”.
Nie buduj własnego okna ani listy ciasteczek w projekcie (AGENT.md §7). Wygląd zmieniasz tokenami i `classNames`;
gdy potrzebujesz całkiem innego układu, dane są w kontekście: `useConsentContext()` → `texts.cookies`,
`texts.details`, `state`, `savePreferences`.
Teksty z panelu (**Cookie Settings**, per język) — puste pole = element się nie pokazuje:
| Pole | Gdzie |
@@ -206,6 +238,8 @@ Teksty z panelu (**Cookie Settings**, per język) — puste pole = element się
| `title` | tytuł banera („Szanujemy Twoją prywatność”) |
| `settingsDescription` | opis pod tytułem ustawień |
| `alwaysActiveLabel` | znacznik przy „Niezbędne” zamiast wyłączonego przełącznika |
| `detailLabels.cookies` / `.provider` / `.purpose` / `.duration` | podpisy listy ciasteczek w oknie `settings="detailed"` (puste → angielskie) |
| `cookies` (lista) | ciasteczka per kategoria — okno `detailed` i `<CookieTable>`; `purpose`, `duration` per język |
| `buttons.close` | etykieta przycisku ✕ dla czytników ekranu (puste → „Close”) |
| `buttons.savePreferences` | „Zapisz” w ustawieniach (do 1.11.0 pole `save` — nazwa zarezerwowana w Mongoose; w kodzie dalej `texts.buttons.save`). MongoDB: od 1.12.2 plugin przy starcie kopiuje stare `save` (wszystkie języki), gdy `savePreferences` brak |
@@ -213,7 +247,8 @@ Nowe pola w globalu = migracja w projektach na Postgres/SQLite (`payload migrate
Elementy mają też stabilne uchwyty `data-ipal` do CSS i testów e2e (używa ich
`ipal-consent-check`): `banner`, `cookie-button` oraz przyciski `settings`, `reject`,
`accept`, `back`, `save`; w trybie modal także `consent-overlay`, `consent-dialog`, `close`.
`accept`, `back`, `save`; w trybie modal także `consent-overlay`, `consent-dialog`, `close`; w trybie detailed
dodatkowo `category-<kategoria>` (karta) i `cookies` (rozwijana lista).
Dostępność: dialog banera i `CookieButton` mają `aria-label` z **Cookie Settings →
title** albo **settingsTitle** (per język) — bez tekstów na sztywno w komponentach. Modal ma
+9 -1
View File
@@ -286,6 +286,12 @@ zmienisz albo wyłączysz: `banner={<CookieBanner classNames={…} />}` / `false
`analytics={{ defer: true }}` / `false`, `jsonLd={[buildNavigationJsonLd(…)]}`, `cookieMap`,
`preconnect={false}`. Zupełnie własny układ: te same dane z `shell` do providerów (consent.md).
Okno ustawień zgody wybierasz propem `settings` banera: `'inline'` (domyślnie — kategorie w pasku),
`'modal'` (małe okno na środku) albo `'detailed'` (duże okno: każda kategoria z przełącznikiem, opisem i
rozwijaną listą ciasteczek z Cookie Settings → Cookies). Przykład:
`banner={<CookieBanner equalChoice controls="switch" settings="detailed" />}` — opis: consent.md → „Duże okno ze
szczegółami”.
```tsx
// src/app/(frontend)/[locale]/[[...slug]]/page.tsx — PODWÓJNE nawiasy
import { notFound, permanentRedirect } from 'next/navigation'
@@ -402,7 +408,8 @@ pnpm dev
3. **Pages** — strona główna z tytułem **w każdym języku** (pusty slug EN = 404 na `/en`).
4. **Site Settings → System Pages** — Homepage (bez tego `/pl` → 404), 404,
polityki; archiwa kolekcji treści.
5. **Cookie Settings** — teksty banera per język.
5. **Cookie Settings** — teksty banera per język; **Cookies** (lista ze skanu, `ipal-consent-check`) i **Detail
labels** (podpisy listy w oknie `settings="detailed"`) — też w każdym języku.
6. **Notifications** — komunikaty formularzy per język.
7. **Site Integrations** — SMTP/Graph (From Name, From Address), Turnstile, ID
analityki/pikseli.
@@ -577,6 +584,7 @@ Rób po jednej pozycji, buduj, sprawdzaj. Kolejność wg wagi:
| 43 | **1.11.1** — `<Media>` ustawia kolor tła tylko dla JPEG | usuń warunek — `mediaImageProps` robi to sam (`placeholderColor`) | storage.md |
| 44 | **1.11.1** — `CmsLink['appearance']` zastąpione własnym typem, bo typ zależał od kolejności pól | typy per kształt: `CmsLink`, `CmsLinkPlain`, `CmsLinkNoLabel`; `pnpm generate:types` i popraw importy | links.md |
| 45 | **1.11.1** — opis formatu w etykiecie pola formularza / godzina jako tekst | pole **Placeholder** w panelu, typ **Time**; Postgres: `migrate:create` | forms.md |
| 46 | **1.12.3** — własne okno ustawień cookies / lista ciasteczek w banerze pisana w projekcie | `<CookieBanner settings="detailed">` (lista z Cookie Settings → Cookies, podpisy: Detail labels); usuń własną wersję; Postgres: `migrate:create` | consent.md |
| 33 | **1.9.2** — `src/fields/sectionHeader.ts`, `sectionSettings.ts`, `lib/navigation.ts`, ręczne `resolveLinkHref` w `CMSLink` | `buildSectionHeaderField`, `buildSectionSettingsField` (ten sam kształt danych — bez migracji), `resolveNav`, `resolveLink` z `lib/content` | blocks.md, links.md |
Po aktualizacji pakietu: `pnpm ipal:skills` (nowe wersje skilli), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep nowego symbolu w
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@intecion/ipal-kit",
"version": "1.12.2",
"version": "1.12.3",
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
"license": "MIT",
"repository": {
+15 -1
View File
@@ -100,6 +100,20 @@ export const cookieSettingsFields: Field[] = [
},
],
},
{
name: 'detailLabels',
type: 'group',
admin: {
description:
'Labels of the cookie list in the detailed settings window (CookieBanner settings="detailed"). The list itself comes from Cookies below.',
},
fields: [
{ name: 'cookies', type: 'text', admin: { description: 'Expander under each category, e.g. "Cookies used" — the count is added.' }, localized: true },
{ name: 'provider', type: 'text', localized: true },
{ name: 'purpose', type: 'text', localized: true },
{ name: 'duration', type: 'text', localized: true },
],
},
{
name: 'categories',
type: 'array',
@@ -122,7 +136,7 @@ export const cookieSettingsFields: Field[] = [
type: 'array',
admin: {
description:
'Cookies the site uses — shown on the cookie policy page (<CookieTable>). Fill it from a scan: ipal-consent-check → cookie-scan.',
'Cookies the site uses — shown on the cookie policy page (<CookieTable>) and per category in the detailed settings window. Fill it from a scan: ipal-consent-check → cookie-scan.',
initCollapsed: true,
},
fields: [
+105 -20
View File
@@ -32,6 +32,8 @@ export type CookieBannerClassNames = {
categories?: string
/** Settings view: one category row/card. */
category?: string
/** Detailed window: the card around one category (row + cookie list). */
categoryCard?: string
categoryDescription?: string
categoryTitle?: string
/** Settings dialog (modal mode): the ✕ button. */
@@ -42,7 +44,19 @@ export type CookieBannerClassNames = {
control?: string
/** Settings view: the switch knob (controls="switch"). */
controlThumb?: string
/** Settings dialog box (modal mode). */
/** Detailed window: one cookie in a category's list. */
cookie?: string
/** Detailed window: list of cookies under a category. */
cookieList?: string
/** Detailed window: provider / purpose / duration grid of one cookie. */
cookieMeta?: string
/** Detailed window: cookie name. */
cookieName?: string
/** Detailed window: <details> wrapping a category's cookie list. */
cookies?: string
/** Detailed window: the <summary> that expands the cookie list. */
cookiesToggle?: string
/** Settings dialog box (modal mode; detailed mode uses a wider default). */
dialog?: string
/** Small label above the banner title (CookieSettings → eyebrow). */
eyebrow?: string
@@ -111,12 +125,19 @@ const defaults: Required<CookieBannerClassNames> = {
body: 'mx-auto max-w-4xl',
categories: 'flex flex-col gap-3',
category: 'flex items-start justify-between gap-4',
categoryCard: `flex flex-col gap-3 ${radius} border p-4 ${border}`,
categoryDescription: `text-xs ${mutedText}`,
categoryTitle: `text-sm font-medium ${strongText}`,
closeButton: `shrink-0 ${radius} p-1 ${mutedText} hover:bg-[var(--ipal-hover,#f5f5f5)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]`,
content: 'flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between',
control: 'mt-1 h-4 w-4 shrink-0 accent-[var(--ipal-primary,#2563eb)]',
controlThumb: 'pointer-events-none inline-block size-5 rounded-full bg-white shadow transition-transform translate-x-0.5 data-[checked=true]:translate-x-[1.375rem]',
cookie: `flex flex-col gap-1 border-t pt-2 first:border-t-0 first:pt-0 ${border}`,
cookieList: 'mt-3 flex flex-col gap-2',
cookieMeta: `grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs ${mutedText}`,
cookieName: `font-mono text-xs font-semibold ${strongText}`,
cookies: 'group',
cookiesToggle: `inline-flex cursor-pointer select-none items-center gap-1 text-xs font-medium ${accent} hover:underline [&::-webkit-details-marker]:hidden`,
dialog: `relative max-h-[90vh] w-full max-w-2xl overflow-y-auto ${radius} border p-6 shadow-2xl ${surface} ${border}`,
eyebrow: `mb-1 text-xs font-semibold uppercase tracking-wider ${accent}`,
icon: `h-6 w-6 shrink-0 ${accent}`,
@@ -137,6 +158,9 @@ const defaults: Required<CookieBannerClassNames> = {
}
/** Default switch track (controls="switch") — the checkbox default doesn't fit a <button>. */
/** Default dialog for settings="detailed" — wider and taller than the modal one. */
const DETAILED_DIALOG = `relative max-h-[90vh] w-full max-w-4xl overflow-y-auto ${radius} border p-6 shadow-2xl sm:p-8 ${surface} ${border}`
const SWITCH_TRACK =
'relative inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full bg-[var(--ipal-border,#d4d4d4)] transition-colors data-[checked=true]:bg-[var(--ipal-primary,#2563eb)] disabled:cursor-default disabled:opacity-60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ipal-primary,#2563eb)]'
@@ -155,10 +179,14 @@ type CookieBannerProps = {
/** Banner buttons, in this order. Default ['settings', 'reject', 'accept']. */
order?: CookieBannerAction[]
/**
* Where category settings open: in the banner itself (default) or in a centred
* dialog over a dimmed page ('modal' — closes with ✕, Escape or a click outside).
* Where category settings open:
* - 'inline' (default) — in the banner itself;
* - 'modal' — a centred dialog over a dimmed page (closes with ✕, Escape or a click outside);
* - 'detailed' — like 'modal', but a large window: each category is a card with its
* on/off control, description and an expandable list of its cookies (name, provider,
* purpose, duration) from Cookie Settings → Cookies.
*/
settings?: 'inline' | 'modal'
settings?: 'detailed' | 'inline' | 'modal'
/** Buttons under the categories, in this order. Default ['back', 'save']. */
settingsActions?: CookieSettingsAction[]
}
@@ -180,7 +208,8 @@ export function CookieBanner({
const [showSettings, setShowSettings] = useState(false)
const [choices, setChoices] = useState<Record<ConsentCategory, boolean>>(state)
const closeRef = useRef<HTMLButtonElement>(null)
const modal = settings === 'modal'
const modal = settings !== 'inline'
const detailed = settings === 'detailed'
useEffect(() => {
setChoices(state)
@@ -273,11 +302,68 @@ export function CookieBanner({
)
}
const cookieList = (cat: ConsentCategory) => {
const rows = texts.cookies?.filter((row) => row.category === cat) ?? []
const labels = texts.details
if (!labels || rows.length === 0) {return null}
return (
<details className={cn('cookies')} data-ipal="cookies">
<summary className={cn('cookiesToggle')}>
<svg aria-hidden="true" className="transition-transform group-open:rotate-90" fill="none" height="14" stroke="currentColor" strokeLinecap="round" strokeWidth="2" viewBox="0 0 24 24" width="14">
<path d="m9 18 6-6-6-6" />
</svg>
{labels.cookies} ({rows.length})
</summary>
<ul className={cn('cookieList')}>
{rows.map((row) => (
<li className={cn('cookie')} key={row.name}>
<code className={cn('cookieName')}>{row.name}</code>
<dl className={cn('cookieMeta')}>
{row.provider && (
<>
<dt>{labels.provider}</dt>
<dd>{row.provider}</dd>
</>
)}
{row.purpose && (
<>
<dt>{labels.purpose}</dt>
<dd>{row.purpose}</dd>
</>
)}
{row.duration && (
<>
<dt>{labels.duration}</dt>
<dd>{row.duration}</dd>
</>
)}
</dl>
</li>
))}
</ul>
</details>
)
}
const categoryRow = (cat: ConsentCategory) => (
<>
<div>
<p className={cn('categoryTitle')} id={`ipal-consent-${cat}`}>
{texts.categories[cat].title}
</p>
<p className={cn('categoryDescription')} id={`ipal-consent-${cat}-desc`}>
{texts.categories[cat].description}
</p>
</div>
{control(cat)}
</>
)
const settingsView = (
<div className="flex flex-col gap-4">
<div className="flex items-start justify-between gap-4">
<h2 className={cn('settingsTitle')} id="ipal-consent-title">
{icon && !modal && <Cookie aria-hidden="true" className={cn('icon')} />}
{icon && (!modal || detailed) && <Cookie aria-hidden="true" className={cn('icon')} />}
{texts.settingsTitle}
</h2>
{modal && (
@@ -290,19 +376,18 @@ export function CookieBanner({
</div>
{texts.settingsDescription && <p className={cn('settingsDescription')}>{texts.settingsDescription}</p>}
<ul className={cn('categories')}>
{CONSENT_CATEGORIES.map((cat) => (
<li className={cn('category')} key={cat}>
<div>
<p className={cn('categoryTitle')} id={`ipal-consent-${cat}`}>
{texts.categories[cat].title}
</p>
<p className={cn('categoryDescription')} id={`ipal-consent-${cat}-desc`}>
{texts.categories[cat].description}
</p>
</div>
{control(cat)}
</li>
))}
{CONSENT_CATEGORIES.map((cat) =>
detailed ? (
<li className={cn('categoryCard')} data-ipal={`category-${cat}`} key={cat}>
<div className={cn('category')}>{categoryRow(cat)}</div>
{cookieList(cat)}
</li>
) : (
<li className={cn('category')} key={cat}>
{categoryRow(cat)}
</li>
),
)}
</ul>
<div className={cn('settingsActions')}>{settingsActions.map(button)}</div>
</div>
@@ -321,7 +406,7 @@ export function CookieBanner({
// klik w tło zamyka dialog; klawiatura: Escape (listener wyżej) i przycisk ✕
role="presentation"
>
<div aria-labelledby="ipal-consent-title" aria-modal="true" className={cn('dialog')} data-ipal="consent-dialog" role="dialog">
<div aria-labelledby="ipal-consent-title" aria-modal="true" className={classNames?.dialog ?? (detailed ? DETAILED_DIALOG : defaults.dialog)} data-ipal="consent-dialog" role="dialog">
{settingsView}
</div>
</div>
+24 -16
View File
@@ -1,7 +1,7 @@
import type { BasePayload } from 'payload'
import type { I18nConfig } from '../i18n/index.js'
import type { ConsentTexts } from './texts.js'
import type { ConsentTexts, CookieTableRow } from './texts.js'
import { resolveLocalized } from '../i18n/resolveLocalized.js'
import { getSystemPagePath } from '../pages/index.js'
@@ -28,6 +28,7 @@ const FALLBACK: ConsentTexts = {
title: 'Necessary',
},
},
details: { cookies: 'Cookies used', duration: 'Duration', provider: 'Provider', purpose: 'Purpose' },
message:
'We use cookies to run the site, analyze traffic, and improve your experience. You can accept all, reject non-essential, or choose which to allow.',
privacyLink: null,
@@ -49,6 +50,7 @@ type CookieSettingsData = {
} & Partial<Omit<ConsentTexts['buttons'], 'save'>>) | null
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
detailLabels?: null | Partial<Record<keyof NonNullable<ConsentTexts['details']>, null | string>>
eyebrow?: null | string
message?: null | string
policyVersion?: null | number
@@ -153,6 +155,13 @@ export async function getConsentTexts({
settings: g.buttons?.settings || FALLBACK.buttons.settings,
},
categories,
cookies: toCookieRows(g.cookies),
details: {
cookies: g.detailLabels?.cookies?.trim() || FALLBACK.details!.cookies,
duration: g.detailLabels?.duration?.trim() || FALLBACK.details!.duration,
provider: g.detailLabels?.provider?.trim() || FALLBACK.details!.provider,
purpose: g.detailLabels?.purpose?.trim() || FALLBACK.details!.purpose,
},
message: g.message || FALLBACK.message,
privacyLink,
settingsTitle: g.settingsTitle || FALLBACK.settingsTitle,
@@ -165,12 +174,19 @@ export async function getConsentTexts({
}
}
export type CookieTableRow = {
category: ConsentCategory
duration?: string
name: string
provider?: string
purpose?: string
export type { CookieTableRow } from './texts.js'
/** Named rows only; an unknown category falls back to necessary. */
function toCookieRows(cookies: CookieSettingsData['cookies']): CookieTableRow[] {
return (cookies ?? [])
.filter((c) => typeof c.name === 'string' && c.name.trim())
.map((c) => ({
name: c.name!.trim(),
category: (CONSENT_CATEGORIES as readonly string[]).includes(c.category ?? '') ? (c.category as ConsentCategory) : 'necessary',
...(c.provider?.trim() ? { provider: c.provider.trim() } : {}),
...(c.purpose?.trim() ? { purpose: c.purpose.trim() } : {}),
...(c.duration?.trim() ? { duration: c.duration.trim() } : {}),
}))
}
/**
@@ -180,15 +196,7 @@ export type CookieTableRow = {
export async function getCookieTable({ locale, payload }: { locale?: string; payload: BasePayload }): Promise<CookieTableRow[]> {
try {
const g = await getGlobal<CookieSettingsData>(payload, 'cookie-settings', { locale })
return (g.cookies ?? [])
.filter((c) => typeof c.name === 'string' && c.name.trim())
.map((c) => ({
name: c.name!.trim(),
category: (CONSENT_CATEGORIES as readonly string[]).includes(c.category ?? '') ? (c.category as ConsentCategory) : 'necessary',
...(c.provider?.trim() ? { provider: c.provider.trim() } : {}),
...(c.purpose?.trim() ? { purpose: c.purpose.trim() } : {}),
...(c.duration?.trim() ? { duration: c.duration.trim() } : {}),
}))
return toCookieRows(g.cookies)
} catch {
return []
}
+23
View File
@@ -13,6 +13,20 @@ export type ConsentTexts = {
settings: string
}
categories: Record<ConsentCategory, { description: string; title: string }>
/**
* Cookie Settings → Cookies in this language — listed per category in the
* detailed settings window (<CookieBanner settings="detailed">). Optional so
* hand-built texts keep compiling; getConsentTexts always fills it.
*/
cookies?: CookieTableRow[]
/** Labels of the cookie list in the detailed settings window. No labels = no list. */
details?: {
/** Expander per category, e.g. "Cookies used" — the count is appended. */
cookies: string
duration: string
provider: string
purpose: string
}
/** Small label above the banner title (e.g. "Privacy & cookies"). Empty = not shown. */
eyebrow?: string
message: string
@@ -26,3 +40,12 @@ export type ConsentTexts = {
/** Policy version from the panel — a stored consent from another version asks again. */
version?: number
}
/** One row of Cookie Settings → Cookies, resolved to a single language. */
export type CookieTableRow = {
category: ConsentCategory
duration?: string
name: string
provider?: string
purpose?: string
}
+17
View File
@@ -351,6 +351,23 @@ describe('cookie table', () => {
expect(await getCookieTable({ locale: 'pl', payload })).toEqual([
{ name: '_ga', category: 'analytics', duration: '2 lata', provider: 'Google', purpose: 'Statystyki' },
])
// the same rows feed the detailed settings window, with English labels until the panel has them
const texts = await getConsentTexts({ config: { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] }, locale: 'pl', payload, privacyPolicy: false })
expect(texts.cookies).toEqual([{ name: '_ga', category: 'analytics', duration: '2 lata', provider: 'Google', purpose: 'Statystyki' }])
expect(texts.details).toEqual({ cookies: 'Cookies used', duration: 'Duration', provider: 'Provider', purpose: 'Purpose' })
await payload.updateGlobal({
slug: 'cookie-settings' as never,
data: { detailLabels: { cookies: 'Używane ciasteczka', duration: 'Czas', provider: 'Dostawca', purpose: 'Cel' } } as never,
locale: 'pl' as never,
})
expect((await getConsentTexts({ config: { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] }, locale: 'pl', payload, privacyPolicy: false })).details).toEqual({
cookies: 'Używane ciasteczka',
duration: 'Czas',
provider: 'Dostawca',
purpose: 'Cel',
})
})
})