@egov-moldova/mud-site-kit 1.0.8 → 1.0.9
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.
- package/README.md +1 -0
- package/assets/footer-v2/mpay-logo.svg +39 -0
- package/mud-site-kit.esm.js +1577 -480
- package/mud-site-kit.esm.js.map +1 -1
- package/mud-site-kit.iife.js +660 -111
- package/mud-site-kit.iife.js.map +1 -1
- package/package.json +1 -1
- package/types/components/cookie-banner/consent.d.ts +40 -0
- package/types/components/cookie-banner/cookie-banner.styles.d.ts +2 -0
- package/types/components/cookie-banner/cookie-banner.template.d.ts +17 -0
- package/types/components/cookie-banner/data/index.d.ts +2 -0
- package/types/components/cookie-banner/data/services.d.ts +9 -0
- package/types/components/cookie-banner/data/texts.d.ts +2 -0
- package/types/components/cookie-banner/index.d.ts +3 -0
- package/types/components/cookie-banner/mud-cookie-banner.d.ts +61 -0
- package/types/components/cookie-banner/types/cookie-banner.types.d.ts +36 -0
- package/types/components/footer-v2/data/index.d.ts +1 -0
- package/types/components/footer-v2/data/mpay.d.ts +2 -0
- package/types/components/privacy-policy/data/index.d.ts +2 -0
- package/types/components/privacy-policy/data/sections.d.ts +6 -0
- package/types/components/privacy-policy/data/texts.d.ts +2 -0
- package/types/components/privacy-policy/index.d.ts +3 -0
- package/types/components/privacy-policy/mud-privacy-policy.d.ts +32 -0
- package/types/components/privacy-policy/privacy-policy.styles.d.ts +2 -0
- package/types/components/privacy-policy/privacy-policy.template.d.ts +10 -0
- package/types/components/privacy-policy/types/privacy-policy.types.d.ts +44 -0
- package/types/index.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egov-moldova/mud-site-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Native custom elements (mud-*) for the AGE platforms, built on the MUD design system (@egov-moldova/mud). Ships as an ES module and a CDN script.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** The remembered choice, and how it reaches Google (Consent Mode v2 through Google Tag Manager, which carries GA4) and Microsoft Clarity. */
|
|
2
|
+
export declare const CONSENT_KEY = "mud-cookie-consent";
|
|
3
|
+
/** How long a choice is kept before the banner asks again: 180 days (about 6 months). */
|
|
4
|
+
export declare const CONSENT_MAX_AGE_MS: number;
|
|
5
|
+
export interface StoredConsent {
|
|
6
|
+
analytics: boolean;
|
|
7
|
+
}
|
|
8
|
+
type ClarityFn = ((...args: unknown[]) => void) & {
|
|
9
|
+
q?: unknown[];
|
|
10
|
+
};
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
clarity?: ClarityFn;
|
|
14
|
+
dataLayer?: unknown[];
|
|
15
|
+
gtag?: (...args: unknown[]) => void;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export interface ConsentTargets {
|
|
19
|
+
/** Microsoft Clarity project id. */
|
|
20
|
+
clarityId: string | null;
|
|
21
|
+
/** Google Tag Manager container id (GTM-XXXXXXX); the container carries GA4. */
|
|
22
|
+
gtmId: string | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The saved choice, or null when there is none, it is malformed, it has no time, or it is older than `CONSENT_MAX_AGE_MS`
|
|
26
|
+
* (or dated in the future). An expired value is removed, and the banner asks again.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readConsent(): StoredConsent | null;
|
|
29
|
+
export declare function writeConsent(consent: StoredConsent): void;
|
|
30
|
+
/** True when Google or Clarity code is already in the page (loaded by the banner earlier, or by the app). */
|
|
31
|
+
export declare function isTrackingRunning(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Puts the choice into effect for both tools. Nothing is loaded until this is called with a user answer (a saved one counts).
|
|
34
|
+
* - Google (GA4 through GTM): see `applyGoogle`.
|
|
35
|
+
* - Clarity: allowed loads it once and tells it `analytics_Storage: granted`. Refused: it is not loaded; if it is already
|
|
36
|
+
* running (the choice was withdrawn) it is told `denied` and its cookies are cleared.
|
|
37
|
+
* Advertising storage is always `denied`: the platforms do not use ads.
|
|
38
|
+
*/
|
|
39
|
+
export declare function applyAnalyticsConsent(analytics: boolean, { clarityId, gtmId }: ConsentTargets): void;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "/* Cookie banner styles, scoped by the shadow DOM. Colours, radii and type come from the MUD tokens on the page; the fallbacks keep it usable without them. */\n\n/* Placed by the component: fixed at the bottom centre of the window, up to 792px wide.\n Spacing: 16px from the bottom and, when the window is barely wider than the banner, 16px from each side;\n the safe areas (home bar, notch) are added on top. Wider windows centre it with the auto margins.\n The page can override any of it with CSS on the tag (for example `position: static` to place it inside a layout). */\n:host {\n display: block;\n position: fixed;\n inset-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));\n inset-block-end: max(16px, env(safe-area-inset-bottom));\n margin-inline: auto;\n z-index: var(--mud-cookie-banner-z-index, 1000);\n container-type: inline-size;\n max-inline-size: 792px;\n min-inline-size: 0;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.mud-cookie-banner,\n.mud-cookie-banner * {\n box-sizing: border-box;\n}\n\n.mud-cookie-banner {\n display: flex;\n flex-direction: column;\n background: var(--color-background-base-default, #fff);\n border: 1.5px solid var(--color-border-base-default, #d9d9d9);\n border-radius: var(--border-radius-16, 16px);\n box-shadow: 0 0 0.5px 0 rgba(0, 0, 0, 0.15), 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 5px 12px 0 rgba(0, 0, 0, 0.08);\n font-family: var(--font-family-primary, \"Onest\", system-ui, -apple-system, sans-serif);\n color: var(--color-text-base-default, #121212);\n overflow: hidden;\n /* A short window: the choices scroll inside the banner instead of running off the screen. */\n max-block-size: calc(100vh - 32px);\n max-block-size: calc(100dvh - 32px);\n}\n\n.mud-cookie-banner__header {\n padding: var(--spacing-20, 20px) var(--spacing-20, 20px) 0 var(--spacing-40, 40px);\n}\n\n.mud-cookie-banner__title {\n margin: 0;\n font-size: var(--font-size-20, 20px);\n line-height: var(--line-height-28, 28px);\n font-weight: var(--font-weight-semibold, 600);\n letter-spacing: -0.2px;\n}\n\n.mud-cookie-banner__body {\n margin: 0;\n padding: var(--spacing-8, 8px) var(--spacing-40, 40px) var(--spacing-16, 16px);\n font-size: var(--font-size-14, 14px);\n line-height: var(--line-height-20, 20px);\n font-weight: var(--font-weight-regular, 400);\n color: var(--color-text-base-secondary, #383838);\n overflow-wrap: anywhere;\n}\n\n.mud-cookie-banner__footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--spacing-12, 12px);\n padding: var(--spacing-12, 12px) var(--spacing-40, 40px) var(--spacing-20, 20px);\n}\n\n.mud-cookie-banner__group {\n display: flex;\n align-items: center;\n gap: var(--spacing-12, 12px);\n inline-size: 414px;\n flex-shrink: 0;\n}\n\n.mud-cookie-banner__group mud-button {\n flex: 1 1 0;\n min-inline-size: 0;\n}\n\n/* Preferences view (Extended state): the cookie choices. */\n.mud-cookie-banner__header {\n display: flex;\n align-items: center;\n gap: var(--spacing-12, 12px);\n}\n\n.mud-cookie-banner__title {\n flex: 1 1 0;\n min-inline-size: 0;\n}\n\n.mud-cookie-banner__close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n inline-size: 32px;\n block-size: 32px;\n padding: 0;\n border: 0;\n border-radius: var(--border-radius-full, 999px);\n background: var(--color-background-base-tertiary, #f1f1f1);\n color: var(--color-text-base-default, #121212);\n cursor: pointer;\n}\n\n.mud-cookie-banner__close:focus-visible,\n.mud-cookie-banner__more:focus-visible {\n outline: 2px solid var(--color-border-brand-default, #0058d2);\n outline-offset: 2px;\n}\n\n.mud-cookie-banner__close mud-icon {\n inline-size: 16px;\n block-size: 16px;\n}\n\n.mud-cookie-banner__content {\n display: flex;\n flex-direction: column;\n min-block-size: 0;\n overflow-y: auto;\n gap: var(--spacing-24, 24px);\n padding: var(--spacing-8, 8px) var(--spacing-40, 40px);\n}\n\n.mud-cookie-banner__content .mud-cookie-banner__body {\n padding: 0;\n}\n\n.mud-cookie-banner__body--wide {\n max-inline-size: 623px;\n}\n\n.mud-cookie-banner__body--narrow,\n.mud-cookie-banner__title-narrow {\n display: none;\n}\n\n.mud-cookie-banner__rows {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-12, 12px);\n padding: var(--spacing-8, 8px) var(--spacing-20, 20px) var(--spacing-12, 12px);\n background: var(--color-background-base-secondary, #f5f5f5);\n border-radius: var(--border-radius-12, 12px);\n}\n\n.mud-cookie-banner__row {\n display: grid;\n grid-template-columns: minmax(0, 1fr) auto;\n grid-template-areas: \"head control\" \"desc control\";\n align-items: center;\n column-gap: var(--spacing-40, 40px);\n row-gap: var(--spacing-8, 8px);\n padding: var(--spacing-12, 12px) 0;\n}\n\n.mud-cookie-banner__row-head {\n grid-area: head;\n display: flex;\n align-items: center;\n gap: var(--spacing-16, 16px);\n min-inline-size: 0;\n}\n\n.mud-cookie-banner__row-title {\n font-size: var(--font-size-16, 16px);\n line-height: var(--line-height-24, 24px);\n font-weight: var(--font-weight-medium, 500);\n color: var(--color-text-base-default, #121212);\n}\n\n.mud-cookie-banner__tag {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n block-size: 20px;\n min-inline-size: 32px;\n padding: 0 var(--spacing-6, 6px);\n border: 1.5px solid var(--color-border-brand-default, #0058d2);\n border-radius: var(--border-radius-4, 4px);\n font-size: var(--font-size-12, 12px);\n line-height: var(--line-height-16, 16px);\n font-weight: var(--font-weight-medium, 500);\n color: var(--color-text-brand-on-secondary, #0058d2);\n}\n\n.mud-cookie-banner__control {\n grid-area: control;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.mud-cookie-banner__check {\n inline-size: 48px;\n block-size: 48px;\n color: var(--color-text-brand-default, #0058d2);\n}\n\n.mud-cookie-banner__row-desc {\n grid-area: desc;\n position: relative;\n min-inline-size: 0;\n}\n\n.mud-cookie-banner__row-text {\n margin: 0;\n font-size: var(--font-size-14, 14px);\n line-height: var(--line-height-20, 20px);\n font-weight: var(--font-weight-regular, 400);\n color: var(--color-text-base-tertiary, #757575);\n overflow-wrap: anywhere;\n}\n\n/* \"...more\" sits at the end of the second line, over the cut text (narrow banner only). */\n.mud-cookie-banner__more {\n display: none;\n position: absolute;\n inset-inline-end: 0;\n inset-block-end: 0;\n padding: 0 0 0 var(--spacing-4, 4px);\n border: 0;\n background: var(--color-background-base-secondary, #f5f5f5);\n font: inherit;\n font-size: var(--font-size-14, 14px);\n line-height: var(--line-height-20, 20px);\n font-weight: var(--font-weight-medium, 500);\n color: var(--color-text-base-default, #121212);\n cursor: pointer;\n}\n\n.mud-cookie-banner__more::before {\n content: \"...\";\n font-weight: var(--font-weight-regular, 400);\n color: var(--color-text-base-tertiary, #757575);\n}\n\n/* The separator of the design: 4px tall, with a 1px subtle line in the middle. */\n.mud-cookie-banner__separator {\n block-size: 4px;\n flex-shrink: 0;\n background: linear-gradient(var(--color-border-base-subtle, #e6e6e6), var(--color-border-base-subtle, #e6e6e6)) center / 100% 1px no-repeat;\n}\n\n.mud-cookie-banner__footer--preferences {\n justify-content: flex-end;\n}\n\n.mud-cookie-banner__save {\n inline-size: 201px;\n}\n\n/* Narrow container (not viewport): stacked, full-width buttons, Accept on top. */\n@container (max-width: 540px) {\n .mud-cookie-banner {\n border-radius: var(--border-radius-12, 12px);\n }\n\n .mud-cookie-banner__header {\n padding: var(--spacing-24, 24px) var(--spacing-12, 12px) 0 var(--spacing-16, 16px);\n }\n\n .mud-cookie-banner__title {\n font-size: var(--font-size-22, 22px);\n line-height: var(--line-height-30, 30px);\n letter-spacing: -0.22px;\n }\n\n .mud-cookie-banner__body {\n padding: var(--spacing-16, 16px);\n font-size: var(--font-size-16, 16px);\n line-height: var(--line-height-24, 24px);\n }\n\n .mud-cookie-banner__footer {\n flex-direction: column;\n align-items: stretch;\n gap: var(--spacing-8, 8px);\n padding: var(--spacing-12, 12px) var(--spacing-16, 16px) var(--spacing-24, 24px);\n }\n\n .mud-cookie-banner__group {\n flex-direction: column-reverse;\n inline-size: 100%;\n gap: var(--spacing-8, 8px);\n }\n\n .mud-cookie-banner__group mud-button {\n flex: 0 0 auto;\n }\n\n .mud-cookie-banner__customize {\n order: 1;\n }\n\n .mud-cookie-banner__content {\n gap: var(--spacing-20, 20px);\n padding: var(--spacing-16, 16px);\n }\n\n /* Narrow design: the title stays \"Cookie Usage Disclosure\" and the text is the one of the notice. */\n .mud-cookie-banner__body--wide,\n .mud-cookie-banner__title-wide {\n display: none;\n }\n\n .mud-cookie-banner__title-narrow {\n display: inline;\n }\n\n .mud-cookie-banner__content .mud-cookie-banner__body--narrow {\n display: block;\n }\n\n .mud-cookie-banner__rows {\n gap: var(--spacing-8, 8px);\n padding: var(--spacing-16, 16px) var(--spacing-20, 20px);\n border-radius: var(--border-radius-8, 8px);\n }\n\n .mud-cookie-banner__row {\n grid-template-areas: \"head control\" \"desc desc\";\n column-gap: var(--spacing-16, 16px);\n row-gap: var(--spacing-12, 12px);\n }\n\n .mud-cookie-banner__row-title {\n font-size: var(--font-size-18, 18px);\n line-height: var(--line-height-28, 28px);\n }\n\n .mud-cookie-banner__check {\n display: none;\n }\n\n /* A row without a control (Necessary): the title line takes the whole width, so the tag sits at the right edge. */\n .mud-cookie-banner__row--static {\n grid-template-columns: minmax(0, 1fr);\n grid-template-areas: \"head\" \"desc\";\n }\n\n .mud-cookie-banner__row-title {\n flex: 1 1 0;\n min-inline-size: 0;\n }\n\n .mud-cookie-banner__row-desc:not(.is-expanded) .mud-cookie-banner__row-text {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n overflow: hidden;\n }\n\n .mud-cookie-banner__row-desc.is-clamped:not(.is-expanded) .mud-cookie-banner__more {\n display: block;\n }\n\n .mud-cookie-banner__footer--preferences {\n padding: var(--spacing-12, 12px) var(--spacing-16, 16px) var(--spacing-24, 24px);\n }\n\n .mud-cookie-banner__save {\n inline-size: 100%;\n }\n\n .mud-cookie-banner__footer mud-button {\n inline-size: 100%;\n }\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Lang } from '../../i18n';
|
|
2
|
+
import type { CookieBannerService, CookieBannerTexts } from './types/cookie-banner.types';
|
|
3
|
+
export interface CookieBannerContext {
|
|
4
|
+
lang: Lang;
|
|
5
|
+
texts?: CookieBannerTexts;
|
|
6
|
+
/** Address of the privacy policy (accepts {lang}). Without it the link is not shown. */
|
|
7
|
+
privacyHref?: string | null;
|
|
8
|
+
/** Which view is shown: the notice (Default) or the cookie choices (Extended). */
|
|
9
|
+
view?: 'banner' | 'preferences';
|
|
10
|
+
/** Rows with a switch in the preferences view. Defaults to the shared list in data/services.ts. */
|
|
11
|
+
services?: CookieBannerService[];
|
|
12
|
+
/** Current state of each switch, by id. */
|
|
13
|
+
selection?: Record<string, boolean>;
|
|
14
|
+
/** Ids of the rows whose description is shown in full on a narrow banner (the "more" link was used). */
|
|
15
|
+
expanded?: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function cookieBannerTemplate(ctx: CookieBannerContext): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CookieBannerService } from '../types/cookie-banner.types';
|
|
2
|
+
/**
|
|
3
|
+
* Categories the user can switch on or off. Shared by every platform and maintained here:
|
|
4
|
+
* to add one, add a row. The switches are off by default (consent is opt-in).
|
|
5
|
+
*
|
|
6
|
+
* `analytics` covers the analytics tools (Microsoft Clarity and/or Google Analytics). Its switch drives Google's
|
|
7
|
+
* `analytics_storage` and Clarity's `analytics_Storage` consent signals. The text is generic: a site may use either or both.
|
|
8
|
+
*/
|
|
9
|
+
export declare const services: CookieBannerService[];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { MudComponent } from '../../mud-component';
|
|
2
|
+
/**
|
|
3
|
+
* <mud-cookie-banner gtm-id="GTM-XXXXXXX" clarity-id="YOUR_PROJECT_ID" privacy-href="/{lang}/privacy"></mud-cookie-banner>
|
|
4
|
+
*
|
|
5
|
+
* Cookie consent notice. Default view: title, text and three buttons (Manage cookies, Allow only necessary, Allow all).
|
|
6
|
+
* Manage cookies opens the choices (Necessary cookies, always on, and one switch row per category), confirmed with
|
|
7
|
+
* "Confirm choices"; the close button goes back. The language comes from <html lang> (ro | ru | en, default ro).
|
|
8
|
+
*
|
|
9
|
+
* The component owns the consent: it remembers the choice in localStorage (`mud-cookie-consent`), hides itself after a
|
|
10
|
+
* choice and stays hidden on the next visits. One "Statistics" switch drives both tools, each optional:
|
|
11
|
+
* - `gtm-id`: Google Tag Manager (GA4 lives in the container). loaded only after the user allowed statistics (Consent Mode v2:
|
|
12
|
+
* defaults `denied`, then `analytics_storage` granted, then the container). A refusal is also sent if it is already running.
|
|
13
|
+
* Until the user answers, nothing from either tool is loaded.
|
|
14
|
+
* - `clarity-id`: Microsoft Clarity is loaded only after the user allowed statistics and is told the choice
|
|
15
|
+
* (`analytics_Storage` granted or denied).
|
|
16
|
+
* Advertising storage is always denied.
|
|
17
|
+
* The signal is sent when the user confirms (Allow all, Allow only necessary, Confirm choices), never when a switch is moved.
|
|
18
|
+
*
|
|
19
|
+
* Placement is done by the component: fixed at the bottom centre of the window, up to 792px wide, 16px from the bottom and from the sides on a narrow
|
|
20
|
+
* window, above the page (z-index 1000, or --mud-cookie-banner-z-index). The host only declares it. To place it inside a layout
|
|
21
|
+
* instead, override on the tag with CSS, for example `mud-cookie-banner { position: static }`.
|
|
22
|
+
*
|
|
23
|
+
* Attributes
|
|
24
|
+
* gtm-id optional. Google Tag Manager container id (GTM-XXXXXXX). Without it Google is not touched.
|
|
25
|
+
* clarity-id optional. Microsoft Clarity project id. Without it nothing is loaded; the choice is still remembered.
|
|
26
|
+
* privacy-href optional. Address of the privacy policy, accepts {lang}. Without it the link is not shown.
|
|
27
|
+
* no-reload optional. By default the page reloads when the user withdraws a choice that was running, so the scripts stop.
|
|
28
|
+
* hidden standard attribute, hides the banner. The component sets it after a choice.
|
|
29
|
+
*
|
|
30
|
+
* Methods
|
|
31
|
+
* open() shows the banner again (for a "Cookie settings" link in the footer), so the user can change the choice.
|
|
32
|
+
* Declarative form: any element with the attribute `data-mud-cookie-settings` does the same on click.
|
|
33
|
+
*
|
|
34
|
+
* Events (bubble, composed). Informational: the component already acted.
|
|
35
|
+
* mud-cookie-banner-choice detail: { choice: 'accept' | 'reject' | 'customize' | 'save', services: { analytics: boolean } }
|
|
36
|
+
*/
|
|
37
|
+
export declare class MudCookieBanner extends MudComponent {
|
|
38
|
+
private resizeObserver?;
|
|
39
|
+
private view;
|
|
40
|
+
private expanded;
|
|
41
|
+
/** State of each switch. Everything is off until the user chooses (consent is opt-in). */
|
|
42
|
+
private selection;
|
|
43
|
+
static get observedAttributes(): string[];
|
|
44
|
+
connectedCallback(): void;
|
|
45
|
+
disconnectedCallback(): void;
|
|
46
|
+
/** Shows the banner again, for example from a "Cookie settings" link. The switches start from the saved choice. */
|
|
47
|
+
open(): void;
|
|
48
|
+
protected afterRender(): void;
|
|
49
|
+
private choose;
|
|
50
|
+
/** Reloads the page. A method of its own so a host (or a test) can replace it. */
|
|
51
|
+
protected reloadPage(): void;
|
|
52
|
+
/** Any element with `data-mud-cookie-settings` (a link or button, even inside another component's shadow DOM) opens the banner. */
|
|
53
|
+
private onSettingsClick;
|
|
54
|
+
private applyConsent;
|
|
55
|
+
/** Buttons are 48px tall (size lg) when the banner itself is narrow, 40px (md) otherwise. */
|
|
56
|
+
private observeWidth;
|
|
57
|
+
/** On a narrow banner the descriptions are cut at two lines; "more" only shows where text was actually cut. */
|
|
58
|
+
private markClamped;
|
|
59
|
+
protected styles(): string;
|
|
60
|
+
protected template(): string;
|
|
61
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Localized, Text } from '../../../i18n';
|
|
2
|
+
/** Texts of the banner, each in every supported language. */
|
|
3
|
+
export interface CookieBannerTexts {
|
|
4
|
+
title: Localized;
|
|
5
|
+
body: Localized;
|
|
6
|
+
privacy: Localized;
|
|
7
|
+
/** Opens the preferences view. */
|
|
8
|
+
customize: Localized;
|
|
9
|
+
/** Refuses everything that is not necessary. */
|
|
10
|
+
reject: Localized;
|
|
11
|
+
accept: Localized;
|
|
12
|
+
/** Preferences view (the "Extended" state of the design). */
|
|
13
|
+
preferencesTitle: Localized;
|
|
14
|
+
preferencesBody: Localized;
|
|
15
|
+
necessaryTitle: Localized;
|
|
16
|
+
necessaryBadge: Localized;
|
|
17
|
+
necessaryBody: Localized;
|
|
18
|
+
save: Localized;
|
|
19
|
+
more: Localized;
|
|
20
|
+
close: Localized;
|
|
21
|
+
}
|
|
22
|
+
/** A category of cookies the user can switch on or off. The list is fixed in the component. */
|
|
23
|
+
export interface CookieBannerService {
|
|
24
|
+
id: string;
|
|
25
|
+
name: Text;
|
|
26
|
+
description: Text;
|
|
27
|
+
/** Initial state of the switch. Off by default: consent is opt-in. */
|
|
28
|
+
checked?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** Which button the user pressed. `save` is the confirm button of the preferences view. */
|
|
31
|
+
export type CookieBannerChoice = 'accept' | 'reject' | 'customize' | 'save';
|
|
32
|
+
/** `detail` of the `mud-cookie-banner-choice` event. `services` is the state of every switch, by id. */
|
|
33
|
+
export interface CookieBannerChoiceDetail {
|
|
34
|
+
choice: CookieBannerChoice;
|
|
35
|
+
services: Record<string, boolean>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PrivacyPolicySection } from '../types/privacy-policy.types';
|
|
2
|
+
/**
|
|
3
|
+
* The text of the policy, shared by every platform and maintained here. Romanian is the reference text; Russian and English
|
|
4
|
+
* follow it block by block. Texts accept `**bold**`, `[label](https://address)` and `[label]({privacy})` (the host's privacy policy).
|
|
5
|
+
*/
|
|
6
|
+
export declare const sections: PrivacyPolicySection[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MudComponent } from '../../mud-component';
|
|
2
|
+
/**
|
|
3
|
+
* <mud-privacy-policy privacy-href="/{lang}/privacy" scroll-offset="80"></mud-privacy-policy>
|
|
4
|
+
*
|
|
5
|
+
* The cookie policy page content: title, last-updated date, a "Cookie settings" button and the numbered sections.
|
|
6
|
+
* The text (ro | ru | en) is kept in the component ([data/sections.ts](./data/sections.ts)); the language comes from <html lang>.
|
|
7
|
+
* The rest of the page (header, footer, breadcrumbs, back link, "Page contents" list) belongs to the host.
|
|
8
|
+
*
|
|
9
|
+
* "Cookie settings" carries `data-mud-cookie-settings`, so a <mud-cookie-banner> on the same page opens when it is clicked.
|
|
10
|
+
*
|
|
11
|
+
* Attributes
|
|
12
|
+
* privacy-href optional. Address of the host's privacy policy, accepts {lang}. The last section sends the reader there;
|
|
13
|
+
* without it that mention is plain text.
|
|
14
|
+
* scroll-offset optional. Extra pixels left free above a section when it is scrolled to, for sticky bars such as the
|
|
15
|
+
* header (default 0). Also the property `scrollOffset`, or the CSS variable `--mud-privacy-policy-scroll-offset`
|
|
16
|
+
* on the tag (for example `var(--header-height)`).
|
|
17
|
+
*
|
|
18
|
+
* Methods
|
|
19
|
+
* scrollToSection(id) optional, for the host's own "Page contents" list. Scrolls to the section with that id (the ids are
|
|
20
|
+
* in `privacyPolicySections`) and returns false when there is none. A plain `#id` link cannot do this,
|
|
21
|
+
* because the sections are inside the shadow root.
|
|
22
|
+
*/
|
|
23
|
+
export declare class MudPrivacyPolicy extends MudComponent {
|
|
24
|
+
static get observedAttributes(): string[];
|
|
25
|
+
/** Extra pixels left free above a section when it is scrolled to. 0 when the attribute is missing or not a number. */
|
|
26
|
+
get scrollOffset(): number;
|
|
27
|
+
set scrollOffset(value: number);
|
|
28
|
+
scrollToSection(id: string): boolean;
|
|
29
|
+
protected styles(): string;
|
|
30
|
+
protected template(): string;
|
|
31
|
+
protected afterRender(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "/* Privacy policy styles, scoped by the shadow DOM. Colours, radii and type come from the MUD tokens on the page; the fallbacks keep it usable without them. */\n\n:host {\n display: block;\n font-family: var(--font-family-primary, \"Onest\", system-ui, -apple-system, sans-serif);\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.mud-privacy-policy,\n.mud-privacy-policy * {\n box-sizing: border-box;\n}\n\n.mud-privacy-policy {\n color: var(--color-text-base-secondary, #383838);\n font-size: var(--font-size-16, 16px);\n line-height: var(--line-height-24, 24px);\n}\n\n/* Header: title, update date, cookie settings */\n.mud-privacy-policy__header {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n margin-block-end: var(--spacing-24, 24px);\n}\n\n.mud-privacy-policy__title {\n margin: 0 0 var(--spacing-12, 12px);\n color: var(--color-text-base-default, #121212);\n font-size: 32px;\n font-weight: var(--font-weight-semibold, 600);\n line-height: 38.4px;\n}\n\n.mud-privacy-policy__updated {\n display: flex;\n align-items: center;\n gap: var(--spacing-4, 4px);\n margin: 0 0 var(--spacing-12, 12px);\n color: var(--color-text-base-tertiary, #757575);\n font-size: var(--font-size-14, 14px);\n line-height: 21px;\n}\n\n.mud-privacy-policy__settings {\n margin-block-end: var(--spacing-24, 24px);\n}\n\n/* The text */\n/* When a section is scrolled to, it stops 24px below the top edge plus the host's extra space for sticky bars:\n the `scroll-offset` attribute, or `--mud-privacy-policy-scroll-offset` set in CSS on the tag. */\n.mud-privacy-policy__section {\n scroll-margin-block-start: calc(var(--spacing-24, 24px) + var(--mud-privacy-policy-scroll-offset, 0px));\n}\n\n.mud-privacy-policy__section h2 {\n margin: 0 0 var(--spacing-16, 16px);\n color: var(--color-text-base-default, #121212);\n font-size: 24px;\n font-weight: 700;\n line-height: 33.6px;\n}\n\n.mud-privacy-policy__section h3 {\n margin: var(--spacing-24, 24px) 0 var(--spacing-8, 8px);\n color: var(--color-text-base-default, #121212);\n font-size: 18px;\n font-weight: var(--font-weight-semibold, 600);\n line-height: 28px;\n}\n\n.mud-privacy-policy__section p {\n margin: 0 0 var(--spacing-16, 16px);\n}\n\n.mud-privacy-policy__section ul {\n margin: 0 0 var(--spacing-16, 16px);\n padding-inline-start: var(--spacing-24, 24px);\n}\n\n.mud-privacy-policy__section li {\n margin-block-end: var(--spacing-8, 8px);\n overflow-wrap: anywhere;\n}\n\n.mud-privacy-policy__section + .mud-privacy-policy__section {\n margin-block-start: var(--spacing-32, 32px);\n}\n\n.mud-privacy-policy__section strong {\n color: var(--color-text-base-default, #121212);\n font-weight: var(--font-weight-semibold, 600);\n}\n\n.mud-privacy-policy__section a {\n color: var(--color-text-brand-default, #0058d2);\n text-decoration: underline;\n}\n\n.mud-privacy-policy__section a:focus-visible {\n outline: 2px solid var(--color-border-brand-default, #0058d2);\n outline-offset: 2px;\n}\n\n@media (min-width: 768px) {\n .mud-privacy-policy__title {\n font-size: 40px;\n line-height: 48px;\n }\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Lang } from '../../i18n';
|
|
2
|
+
import type { PrivacyPolicyContext } from './types/privacy-policy.types';
|
|
3
|
+
/** `2026-11-25` as "25 noiembrie 2026" / "25 ноября 2026 г." / "25 November 2026". A value that is not a date is shown as it is. */
|
|
4
|
+
export declare function formatDate(iso: string, lang: Lang): string;
|
|
5
|
+
/**
|
|
6
|
+
* Escapes a text, then turns its inline marks into markup: `**bold**` and `[label](https://address)`.
|
|
7
|
+
* `[label]({privacy})` links to `privacyHref` (already localised); without it only the label is shown.
|
|
8
|
+
*/
|
|
9
|
+
export declare function richText(text: string, privacyHref?: string | null): string;
|
|
10
|
+
export declare function privacyPolicyTemplate(ctx: PrivacyPolicyContext): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Lang, Localized } from '../../../i18n';
|
|
2
|
+
/**
|
|
3
|
+
* A piece of a section. Texts are plain text with inline marks: `**bold**` and `[label](https://address)`.
|
|
4
|
+
* The address `{privacy}` links to the privacy policy of the host (the `privacy-href` attribute); without it only the label is shown.
|
|
5
|
+
*/
|
|
6
|
+
export type PrivacyPolicyBlock =
|
|
7
|
+
/** A paragraph. */
|
|
8
|
+
{
|
|
9
|
+
type: 'paragraph';
|
|
10
|
+
text: Localized;
|
|
11
|
+
}
|
|
12
|
+
/** A subheading inside a section (3.1, 3.2, ...). */
|
|
13
|
+
| {
|
|
14
|
+
type: 'heading';
|
|
15
|
+
text: Localized;
|
|
16
|
+
}
|
|
17
|
+
/** A bulleted list. */
|
|
18
|
+
| {
|
|
19
|
+
type: 'list';
|
|
20
|
+
items: Localized[];
|
|
21
|
+
};
|
|
22
|
+
/** A numbered section of the policy. */
|
|
23
|
+
export interface PrivacyPolicySection {
|
|
24
|
+
/** Anchor id of the section. */
|
|
25
|
+
id: string;
|
|
26
|
+
title: Localized;
|
|
27
|
+
blocks: PrivacyPolicyBlock[];
|
|
28
|
+
}
|
|
29
|
+
export interface PrivacyPolicyTexts {
|
|
30
|
+
pageTitle: Localized;
|
|
31
|
+
/** Label before the date: "Last updated". */
|
|
32
|
+
updatedLabel: Localized;
|
|
33
|
+
/** Date of the last change of the policy, `YYYY-MM-DD`. Shown in the language of the page. */
|
|
34
|
+
updatedAt: string;
|
|
35
|
+
/** Opens the cookie banner so the choice can be changed. */
|
|
36
|
+
cookieSettings: Localized;
|
|
37
|
+
}
|
|
38
|
+
export interface PrivacyPolicyContext {
|
|
39
|
+
lang: Lang;
|
|
40
|
+
texts?: PrivacyPolicyTexts;
|
|
41
|
+
sections?: PrivacyPolicySection[];
|
|
42
|
+
/** Address of the privacy policy (accepts {lang}) for the `{privacy}` links of the text. Without it those links show only their label. */
|
|
43
|
+
privacyHref?: string | null;
|
|
44
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export { MudComponent } from './mud-component';
|
|
|
3
3
|
export * from './widgets/footer';
|
|
4
4
|
export * from './components/header';
|
|
5
5
|
export * from './components/footer-v2';
|
|
6
|
+
export * from './components/cookie-banner';
|
|
6
7
|
export * from './m-products';
|
|
7
8
|
export * from './components/mproducts-logo';
|
|
9
|
+
export * from "./components/privacy-policy";
|