@leabankab/component-library 8.0.0 → 8.1.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 (39) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/dist/component-library.es.js +1496 -1231
  3. package/dist/component-library.es.js.map +1 -1
  4. package/dist/component-library.umd.js +2 -2
  5. package/dist/component-library.umd.js.map +1 -1
  6. package/dist/components/data-display/card.d.ts +25 -2
  7. package/dist/components/form/combo-field.d.ts +9 -1
  8. package/dist/components/form/email-input.d.ts +9 -1
  9. package/dist/components/form/field-parts.d.ts +16 -2
  10. package/dist/components/form/input.d.ts +7 -1
  11. package/dist/components/form/number-input-unit.d.ts +28 -0
  12. package/dist/components/form/number-input.d.ts +27 -5
  13. package/dist/components/form/phone-number-input/phone-number-input.d.ts +20 -1
  14. package/dist/cookie-consent-core-fntGUdFt.cjs +2 -0
  15. package/dist/cookie-consent-core-fntGUdFt.cjs.map +1 -0
  16. package/dist/{cookie-consent-core-mwVmy5nZ.mjs → cookie-consent-core-lX0QAEAo.mjs} +2 -1
  17. package/dist/cookie-consent-core-lX0QAEAo.mjs.map +1 -0
  18. package/dist/cookie-consent-react.cjs +1 -1
  19. package/dist/cookie-consent-react.mjs +1 -1
  20. package/dist/cookie-consent.cjs +1 -1
  21. package/dist/cookie-consent.css +1 -1
  22. package/dist/cookie-consent.mjs +1 -1
  23. package/dist/dev-panel/dev-panel.d.ts +52 -1
  24. package/dist/dev-panel/parts.d.ts +1 -1
  25. package/dist/dev-panel/use-dev-panel-labels.d.ts +1 -1
  26. package/dist/dev-panel.cjs +2 -2
  27. package/dist/dev-panel.cjs.map +1 -1
  28. package/dist/dev-panel.css +1 -1
  29. package/dist/dev-panel.mjs +384 -283
  30. package/dist/dev-panel.mjs.map +1 -1
  31. package/dist/index.css +1 -1
  32. package/dist/validation/email.d.ts +18 -0
  33. package/dist/validation/mobile-patterns.d.ts +10 -0
  34. package/dist/validation/national-id.d.ts +26 -0
  35. package/dist/validation/phone.d.ts +30 -0
  36. package/package.json +4 -2
  37. package/dist/cookie-consent-core-C4MP7GlV.cjs +0 -2
  38. package/dist/cookie-consent-core-C4MP7GlV.cjs.map +0 -1
  39. package/dist/cookie-consent-core-mwVmy5nZ.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookie-consent-core-mwVmy5nZ.mjs","names":[],"sources":["../src/cookie-consent/constants.ts","../src/cookie-consent/domain.ts","../src/cookie-consent/core.ts"],"sourcesContent":["/**\n * Bumping the revision invalidates every visitor's consent on every Lea Bank\n * app at once. Only change it here, then release all apps together.\n */\nexport const COOKIE_CONSENT_REVISION = 3;\n\nexport const COOKIE_CONSENT_CATEGORIES = [\n \"necessary\",\n \"preferences\",\n \"analytics\",\n \"marketing\",\n] as const;\n\nexport type CookieConsentCategory = (typeof COOKIE_CONSENT_CATEGORIES)[number];\n\nexport type ConsentState = Record<CookieConsentCategory, boolean>;\n\nexport type Market = \"se\" | \"fi\" | \"no\" | \"es\";\n\nexport const MARKET_DOMAINS: Record<Market, string> = {\n se: \"leabank.se\",\n fi: \"leabank.fi\",\n no: \"leabank.no\",\n es: \"leabank.es\",\n};\n\nexport const COOKIE_NAME = \"cc_cookie\";\n","import { COOKIE_NAME, MARKET_DOMAINS, type Market } from \"./constants\";\n\n/**\n * Returns the market's registrable domain when the page is served from it or\n * one of its subdomains. Anywhere else (localhost, `*.azurewebsites.net`,\n * which is on the Public Suffix List) the browser would reject the cookie, so\n * it stays host-only.\n */\nexport function resolveCookieDomain(\n hostname: string,\n market: Market,\n): string | undefined {\n const domain = MARKET_DOMAINS[market];\n const host = hostname.toLowerCase();\n\n return host === domain || host.endsWith(`.${domain}`) ? domain : undefined;\n}\n\n/**\n * Erases a host-only consent cookie left by an earlier, domain-less setup.\n * Without this it coexists with the domain cookie under the same name and a\n * stale value can win. A cookie written without `domain` only matches the\n * host-only one, so the shared cookie is kept.\n */\nexport function clearHostOnlyCookie(): void {\n document.cookie = `${COOKIE_NAME}=; path=/; max-age=0`;\n}\n","import * as CookieConsent from \"vanilla-cookieconsent\";\n\nimport {\n COOKIE_CONSENT_CATEGORIES,\n COOKIE_CONSENT_REVISION,\n COOKIE_NAME,\n type ConsentState,\n type CookieConsentCategory,\n type Market,\n} from \"./constants\";\nimport { clearHostOnlyCookie, resolveCookieDomain } from \"./domain\";\n\nexport interface InitCookieConsentOptions {\n market: Market;\n /**\n * Called with the visitor's choice once the library has loaded, when there\n * is a valid consent, and again whenever the choice changes.\n */\n onConsentChange?: (state: ConsentState) => void;\n}\n\nexport interface ConsentSnapshot {\n consent: ConsentState | null;\n /** Whether the settings dialog should be shown. */\n settingsOpen: boolean;\n /** The stored consent has been read and the choice can be changed. */\n ready: boolean;\n}\n\nconst serverSnapshot: ConsentSnapshot = {\n consent: null,\n settingsOpen: false,\n ready: false,\n};\n\nlet started = false;\nlet snapshot = serverSnapshot;\nconst listeners = new Set<() => void>();\n\nfunction update(patch: Partial<ConsentSnapshot>) {\n snapshot = { ...snapshot, ...patch };\n listeners.forEach((listener) => listener());\n}\n\n/** `null` on the server, before the visitor has chosen, or after a revision bump. */\nexport function getConsentState(): ConsentState | null {\n if (typeof window === \"undefined\" || !CookieConsent.validConsent()) {\n return null;\n }\n\n const accepted = new Set(CookieConsent.getUserPreferences().acceptedCategories);\n return Object.fromEntries(\n COOKIE_CONSENT_CATEGORIES.map((category) => [category, accepted.has(category)]),\n ) as ConsentState;\n}\n\n/**\n * Reads the shared consent and keeps it up to date. Only the first call has an\n * effect, and it is a no-op on the server. It shows nothing by itself: the\n * settings dialog is rendered by `CookieConsentProvider`.\n */\nexport function initCookieConsent({\n market,\n onConsentChange,\n}: InitCookieConsentOptions): void {\n if (typeof window === \"undefined\" || started) return;\n started = true;\n\n const domain = resolveCookieDomain(window.location.hostname, market);\n if (domain) clearHostOnlyCookie();\n\n const applyConsent = () => {\n const consent = getConsentState();\n update({ consent });\n if (consent) onConsentChange?.(consent);\n };\n\n // The full build with its UI unused: `run` still builds an empty consent\n // modal when consent is missing, so it goes into a detached `root` that never\n // reaches the page. The UI-less core build of 3.1.0 can't be used, because\n // its `run` throws.\n void CookieConsent.run({\n root: document.createElement(\"div\"),\n autoShow: false,\n language: {\n default: \"en\",\n translations: { en: { consentModal: {}, preferencesModal: { sections: [] } } },\n },\n revision: COOKIE_CONSENT_REVISION,\n cookie: {\n name: COOKIE_NAME,\n sameSite: \"Lax\",\n secure: true,\n ...(domain && { domain }),\n },\n categories: {\n necessary: { enabled: true, readOnly: true },\n preferences: { enabled: false, readOnly: false },\n analytics: {\n enabled: false,\n readOnly: false,\n autoClear: { cookies: [{ name: /^(_ga|_gid|_gat)/ }] },\n },\n marketing: {\n enabled: false,\n readOnly: false,\n autoClear: {\n cookies: [{ name: /^(_fbp|_fbc)/ }, { name: /^(_gcl_)/ }],\n },\n },\n },\n onFirstConsent: applyConsent,\n onChange: applyConsent,\n }).then(() => {\n const consent = getConsentState();\n update({\n consent,\n ready: true,\n settingsOpen: snapshot.settingsOpen || consent === null,\n });\n if (consent) onConsentChange?.(consent);\n });\n}\n\n/**\n * Stores the visitor's choice. `necessary` is always kept. Does nothing until\n * `initCookieConsent` has read the stored consent.\n */\nexport function setConsent(\n categories: readonly CookieConsentCategory[] | \"all\",\n): void {\n if (!snapshot.ready) return;\n\n CookieConsent.acceptCategory(\n categories === \"all\"\n ? \"all\"\n : [\"necessary\", ...categories.filter((category) => category !== \"necessary\")],\n );\n update({ consent: getConsentState(), settingsOpen: false });\n}\n\n/** Opens the settings dialog of the mounted `CookieConsentProvider`. */\nexport function openCookieSettings(): void {\n if (typeof window === \"undefined\") return;\n update({ settingsOpen: true });\n}\n\n/** Closes the settings dialog, unless the visitor has yet to choose. */\nexport function closeCookieSettings(): void {\n if (snapshot.consent === null) return;\n update({ settingsOpen: false });\n}\n\nexport function subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function getSnapshot(): ConsentSnapshot {\n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