@egov-moldova/mud-site-kit 1.0.3 → 1.0.5

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 (71) hide show
  1. package/README.md +22 -19
  2. package/assets/header/evosign-logo.svg +12 -0
  3. package/assets/header/guvernul-emblem.svg +10 -0
  4. package/assets/header/mconnect-logo.svg +32 -0
  5. package/assets/header/mdate-logo.svg +36 -0
  6. package/assets/header/mdelivery-logo.svg +36 -0
  7. package/assets/header/mdocs-logo.svg +40 -0
  8. package/assets/header/mlearn-logo.svg +62 -0
  9. package/assets/header/mnotify-logo.svg +36 -0
  10. package/assets/header/mpass-logo.svg +36 -0
  11. package/assets/header/mpay-logo.svg +39 -0
  12. package/assets/header/mpower-logo.svg +28 -0
  13. package/assets/header/msign-logo.svg +36 -0
  14. package/assets/m-products/png/edemocratie.png +0 -0
  15. package/assets/m-products/png/fod.png +0 -0
  16. package/assets/m-products/png/k8s.png +0 -0
  17. package/mud-site-kit.esm.js +1192 -221
  18. package/mud-site-kit.esm.js.map +1 -1
  19. package/mud-site-kit.iife.js +617 -40
  20. package/mud-site-kit.iife.js.map +1 -1
  21. package/package.json +1 -1
  22. package/types/components/footer/data/contacts.d.ts +45 -0
  23. package/types/components/footer/data/evosign.d.ts +2 -0
  24. package/types/components/footer/data/index.d.ts +15 -0
  25. package/types/components/footer/data/links.production.d.ts +8 -0
  26. package/types/components/footer/data/mconnect.d.ts +2 -0
  27. package/types/components/footer/data/mdate.d.ts +2 -0
  28. package/types/components/footer/data/mdelivery.d.ts +2 -0
  29. package/types/components/footer/data/mlearn.d.ts +2 -0
  30. package/types/components/footer/data/mnotify.d.ts +2 -0
  31. package/types/components/footer/data/mpass.d.ts +2 -0
  32. package/types/components/footer/data/mpower.d.ts +2 -0
  33. package/types/components/footer/data/msign.d.ts +2 -0
  34. package/types/components/footer/data/shared.d.ts +3 -0
  35. package/types/components/footer/data/texts.d.ts +53 -0
  36. package/types/components/footer/footer.styles.d.ts +2 -0
  37. package/types/components/footer/footer.template.d.ts +18 -0
  38. package/types/components/footer/index.d.ts +4 -0
  39. package/types/components/footer/mud-footer.d.ts +34 -0
  40. package/types/components/footer/resources/footer.assets.d.ts +4 -0
  41. package/types/components/footer/resources/footer.icons.d.ts +2 -0
  42. package/types/components/footer/types/footer.types.d.ts +113 -0
  43. package/types/components/header/data/evosign.d.ts +2 -0
  44. package/types/components/header/data/index.d.ts +17 -0
  45. package/types/components/header/data/links.production.d.ts +8 -0
  46. package/types/components/header/data/mconnect.d.ts +2 -0
  47. package/types/components/header/data/mdate.d.ts +2 -0
  48. package/types/components/header/data/mdelivery.d.ts +2 -0
  49. package/types/components/header/data/mdocs.d.ts +2 -0
  50. package/types/components/header/data/mlearn.d.ts +2 -0
  51. package/types/components/header/data/mnotify.d.ts +2 -0
  52. package/types/components/header/data/mpass.d.ts +2 -0
  53. package/types/components/header/data/mpay.d.ts +2 -0
  54. package/types/components/header/data/mpower.d.ts +2 -0
  55. package/types/components/header/data/msign.d.ts +2 -0
  56. package/types/components/header/data/shared.d.ts +3 -0
  57. package/types/components/header/data/texts.d.ts +18 -0
  58. package/types/components/header/header.styles.d.ts +2 -0
  59. package/types/components/header/header.template.d.ts +34 -0
  60. package/types/components/header/index.d.ts +4 -0
  61. package/types/components/header/mud-header.d.ts +69 -0
  62. package/types/components/header/resources/header.assets.d.ts +4 -0
  63. package/types/components/header/resources/header.icons.d.ts +3 -0
  64. package/types/components/header/types/header.types.d.ts +86 -0
  65. package/types/i18n.d.ts +2 -2
  66. package/types/index.d.ts +3 -2
  67. package/types/{mud-widget.d.ts → mud-component.d.ts} +6 -6
  68. package/types/mud-loader.d.ts +1 -1
  69. package/types/widgets/footer/mud-footer.d.ts +2 -2
  70. /package/types/{widgets → components}/mproducts-logo/index.d.ts +0 -0
  71. /package/types/{widgets → components}/mproducts-logo/mud-mproducts-logo.d.ts +0 -0
@@ -0,0 +1,69 @@
1
+ import { MudComponent } from '../../mud-component';
2
+ import type { HeaderLinks } from './types/header.types';
3
+ /**
4
+ * <mud-header variant="mpass"></mud-header>
5
+ *
6
+ * The language comes from <html lang> (ro | ru | en, default ro) and follows it when it changes.
7
+ * Choosing another language emits `mud-language-change`; the host app translates and updates <html lang>.
8
+ *
9
+ * Attributes
10
+ * variant required. mconnect | mdate | mpass | msign | mpower | mnotify | mdelivery | mlearn | evosign | mdocs | mpay
11
+ * buttons optional. Comma list overriding the variant's buttons: "login", "".
12
+ * current-url optional. Page URL used to mark the active menu link (default: location.href).
13
+ * assets-base optional. Folder URL that serves the logo files (default: ./assets/header/ next to the bundle).
14
+ * max-width optional. Max total width of the container, padding included: a CSS length (1100px, 80rem) or a number of pixels (default: 1270px).
15
+ * padding-x optional. Left and right padding of the content, same format (default: 16px).
16
+ * links optional. The app's own addresses as JSON, same as the `links` property: {"logo":"/","login":"/login","nav":{"catalog":"/{lang}/catalog"},"icons":{"cart":"/{lang}/cart"}}.
17
+ * cart-count optional. Number of items in the cart: shows a badge on the cart icon (0 or missing = no badge). The host app keeps it up to date.
18
+ * banner optional. banner="off" hides the site-wide alert banner on this page (it comes from data/shared.ts).
19
+ * banner-title optional. Overrides the site-wide banner: bold lead sentence. Used with the other banner-* attributes.
20
+ * banner-text optional. Rest of the banner message.
21
+ * banner-link-text optional. Underlined link text at the end.
22
+ * banner-link-href optional. Link target (opens in a new tab).
23
+ * banner-id optional. Cookie key. Closing the banner hides it for 30 days; a new id shows it again.
24
+ *
25
+ * Property
26
+ * links HeaderLinks. The addresses of the app (logo, login, menu links by id, icon links by id). They accept {lang}.
27
+ * There is no fallback: a link the app does not supply has no address and the console lists it. Generic links (government strip, banner) stay in the header.
28
+ *
29
+ * Events (bubble, composed)
30
+ * mud-language-change detail: { lang }
31
+ * mud-banner-close detail: { id }
32
+ */
33
+ export declare class MudHeader extends MudComponent {
34
+ private menuOpen;
35
+ private langOpen;
36
+ private bannerObserver?;
37
+ private _links?;
38
+ private reported;
39
+ /** Addresses supplied by the host app (the property wins over the `links` attribute). */
40
+ get links(): HeaderLinks | undefined;
41
+ set links(value: HeaderLinks | undefined);
42
+ private linksFromAttribute;
43
+ static get observedAttributes(): string[];
44
+ connectedCallback(): void;
45
+ disconnectedCallback(): void;
46
+ /** Following a link closes the menu and refreshes the active link. */
47
+ private readonly onRoute;
48
+ private readonly onKey;
49
+ private readonly onResize;
50
+ private lockScroll;
51
+ private setMenuOpen;
52
+ private setLangOpen;
53
+ private changeLang;
54
+ /** Items in the cart, from the optional cart-count attribute; anything but a positive whole number counts as empty. */
55
+ private get cartCount();
56
+ /** Tells the developer which app links have no address yet (once per change, not on every render). */
57
+ private reportMissing;
58
+ private get variant();
59
+ private buttons;
60
+ /** The banner to show: from the `banner-*` attributes, else the site-wide one in data/shared.ts; null when off or closed. */
61
+ private banner;
62
+ protected afterRender(): void;
63
+ /** The alert banner scrolls away with the page: the sticky offset is minus its height, so only the rest of the header stays pinned. */
64
+ private pinBelowBanner;
65
+ /** Maps an optional length attribute to a CSS custom property; without a valid value the default from the styles stays. */
66
+ private applyLength;
67
+ protected styles(): string;
68
+ protected template(): string;
69
+ }
@@ -0,0 +1,4 @@
1
+ /** Logo file for each key used in the data layer. The files live in ./assets and are copied to dist/assets/header. */
2
+ export declare const files: Record<string, string>;
3
+ /** URL of a logo. `base` (the `assets-base` attribute) overrides where the files are served from. */
4
+ export declare function logoUrl(key: string, base?: string | null): string;
@@ -0,0 +1,3 @@
1
+ /** Inline SVG icons for the header. `cart` is the `id` a variant icon can use; the rest are used by the template itself. */
2
+ declare const icons: Record<string, string>;
3
+ export default icons;
@@ -0,0 +1,86 @@
1
+ import type { Lang, Text } from '../../../i18n';
2
+ /** A generic menu link (the same in every environment): its address stays here. `newTab` opens it with target="_blank". */
3
+ export interface HeaderFixedLink {
4
+ label: Text;
5
+ href: string;
6
+ newTab?: boolean;
7
+ }
8
+ /** A menu link into the app itself. It has no address here: the host app supplies it by `id` (see HeaderLinks). */
9
+ export interface HeaderAppLink {
10
+ /** Key in `links.nav`, unique inside its variant. */
11
+ id: string;
12
+ label: Text;
13
+ newTab?: boolean;
14
+ }
15
+ export type HeaderLink = HeaderFixedLink | HeaderAppLink;
16
+ /** Buttons a variant can list in `buttons`; their label and address are in `shared.buttons`. */
17
+ export type HeaderButtonName = 'login';
18
+ /** Round icon link left of the buttons. `id` is a key of header.icons.ts and of `links.icons`; the address comes from the host app. */
19
+ export interface HeaderIcon {
20
+ id: string;
21
+ label: Text;
22
+ }
23
+ /**
24
+ * Addresses of the host app, set with the `links` property (or a JSON `links` attribute). Every address accepts `{lang}`.
25
+ * There is no fallback: a link the app does not supply is shown without an address and the console lists what is missing.
26
+ * Generic links (government strip, banner, menu links without an `id`) are not here: they stay in the header.
27
+ */
28
+ export interface HeaderLinks {
29
+ /** Logo and name. */
30
+ logo?: string;
31
+ /** "Log in" button. */
32
+ login?: string;
33
+ /** Menu links by `id`, see data/<variant>.ts. */
34
+ nav?: Record<string, string>;
35
+ /** Icon links by `id` (e.g. `cart`). */
36
+ icons?: Record<string, string>;
37
+ }
38
+ /** Everything that differs between headers. One object per variant, see data/<variant>.ts. */
39
+ export interface HeaderVariant {
40
+ name: string;
41
+ /** Key of the logo file, see resources/header.assets.ts. */
42
+ logo: string;
43
+ /** Lines under the name; each line is one non-wrapping row, so the box is as wide as the longest line. */
44
+ tagline: Text[];
45
+ /** Menu links next to the logo (a burger menu on small screens). */
46
+ nav?: HeaderLink[];
47
+ /** No buttons unless the variant asks for them. */
48
+ buttons?: HeaderButtonName[];
49
+ icons?: HeaderIcon[];
50
+ }
51
+ export interface HeaderBanner {
52
+ /** Switch the site-wide banner off with `false`. */
53
+ enabled: boolean;
54
+ /** Cookie key. Closing the banner hides it for 30 days; a new id shows it again. */
55
+ id: string;
56
+ title?: Text;
57
+ text?: Text;
58
+ linkText?: Text;
59
+ linkHref?: string;
60
+ }
61
+ export interface HeaderShared {
62
+ government: {
63
+ label: Text;
64
+ href: string;
65
+ };
66
+ buttons: Record<HeaderButtonName, {
67
+ label: Text;
68
+ }>;
69
+ /** Site-wide alert banner above the header, on every variant. */
70
+ banner: HeaderBanner;
71
+ languages: {
72
+ code: Lang;
73
+ label: string;
74
+ name: string;
75
+ }[];
76
+ /** Accessible names. */
77
+ labels: {
78
+ menu: Text;
79
+ closeMenu: Text;
80
+ language: Text;
81
+ closeBanner: Text;
82
+ banner: Text;
83
+ /** Cart link name when the cart is not empty; {count} is replaced with the number. */
84
+ cartCount: Text;
85
+ };
86
+ }
package/types/i18n.d.ts CHANGED
@@ -4,11 +4,11 @@ export type Lang = (typeof LANGS)[number];
4
4
  export type Localized = Record<Lang, string>;
5
5
  /** A text that is the same in every language (a plain string) or translated. */
6
6
  export type Text = string | Localized;
7
- /** Maps any `lang` value (`ru`, `ru-RU`, `EN`, ...) to a supported language. */
8
- export declare function resolveLang(raw: string | null | undefined): Lang;
9
7
  /** Language of the page, taken from `<html lang="...">`. */
10
8
  export declare function currentLang(): Lang;
11
9
  /** Calls `onChange` whenever `<html lang>` changes. Returns a function that stops watching. */
12
10
  export declare function watchLang(onChange: () => void): () => void;
13
11
  /** Picks the text for a language. */
14
12
  export declare function tr(text: Text, lang: Lang): string;
13
+ /** Fills the `{lang}` placeholder of a link (`https://site/{lang}/home`) with the page language. Links without it stay as they are. */
14
+ export declare function localizeHref(href: string, lang: Lang): string;
package/types/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { configureMud, loadMud } from './mud-loader';
2
- export { MudWidget } from './mud-widget';
2
+ export { MudComponent } from './mud-component';
3
3
  export * from './widgets/footer';
4
+ export * from './components/header';
4
5
  export * from './m-products';
5
- export * from './widgets/mproducts-logo';
6
+ export * from './components/mproducts-logo';
@@ -1,10 +1,10 @@
1
1
  import { type Lang } from './i18n';
2
2
  /**
3
- * Base class for mud-site-kit widgets: a native custom element with an open shadow root
4
- * that renders MUD components (<mud-*>). The language comes from <html lang>; widgets re-render when it changes. MUD design tokens are CSS custom properties
5
- * and cross the shadow boundary, so widgets inherit the theme from the page.
3
+ * Base class for mud-site-kit components: a native custom element with an open shadow root
4
+ * that renders MUD design-system elements (<mud-*>). The language comes from <html lang>; components re-render when it changes. MUD design tokens are CSS custom properties
5
+ * and cross the shadow boundary, so components inherit the theme from the page.
6
6
  */
7
- export declare abstract class MudWidget extends HTMLElement {
7
+ export declare abstract class MudComponent extends HTMLElement {
8
8
  protected readonly root: ShadowRoot;
9
9
  private stopWatchingLang?;
10
10
  constructor();
@@ -12,9 +12,9 @@ export declare abstract class MudWidget extends HTMLElement {
12
12
  static get observedAttributes(): string[];
13
13
  /** Page language (ro | ru | en), from <html lang>. */
14
14
  protected get pageLang(): Lang;
15
- /** Widget-specific CSS (added to the shadow root). */
15
+ /** Component-specific CSS (added to the shadow root). */
16
16
  protected styles(): string;
17
- /** Widget markup, composed from <mud-*> elements. */
17
+ /** Component markup, composed from <mud-*> elements. */
18
18
  protected abstract template(): string;
19
19
  /** Called after each render, to wire events. */
20
20
  protected afterRender(): void;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Override where the MUD runtime (mud.esm.js, mud.css, tokens, assets) is served from.
3
- * Must be called before the first widget connects. Defaults to `./mud/` next to the widget bundle.
3
+ * Must be called before the first component connects. Defaults to `./mud/` next to the component bundle.
4
4
  */
5
5
  export declare function configureMud(options: {
6
6
  baseUrl: string;
@@ -1,4 +1,4 @@
1
- import { MudWidget } from '../../mud-widget';
1
+ import { MudComponent } from '../../mud-component';
2
2
  /**
3
3
  * <mud-footer variant="mpass"></mud-footer>
4
4
  *
@@ -10,7 +10,7 @@ import { MudWidget } from '../../mud-widget';
10
10
  * max-width optional. Max total width of the container, padding included (content = max-width - 2 * padding-x): a CSS length (1100px, 80rem) or a number of pixels (default: 1270px).
11
11
  * padding-x optional. Left and right padding of the content, same format (default: 16px).
12
12
  */
13
- export declare class MudFooter extends MudWidget {
13
+ export declare class MudFooter extends MudComponent {
14
14
  static get observedAttributes(): string[];
15
15
  protected afterRender(): void;
16
16
  /** Maps an optional length attribute to a CSS custom property; without a valid value the default from the styles stays. */