{
  "timestamp": "2026-11-19T09:33:56",
  "compiler": {
    "name": "@stencil/core",
    "version": "4.45.4",
    "typescriptVersion": "5.8.3"
  },
  "storybook": "https://magma-design-system.github.io/magma/storybook/",
  "studio": "https://magma-design-system.github.io/magma/studio/",
  "components": [
    {
      "filePath": "src/components/mds-pref-language/mds-pref-language.tsx",
      "encapsulation": "shadow",
      "tag": "mds-pref-language",
      "docs": "",
      "docsTags": [
        {
          "name": "slot",
          "text": "- Add `mds-pref-language-item` element/s."
        },
        {
          "name": "category",
          "text": "preferences"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-pref-language>` web component is the language-preference control of the Magma Design System, usually slotted inside the [`<mds-pref>`](../mds-pref/AGENTS.md) panel alongside the other preference children. It renders a labelled tab trigger that opens a dropdown of `<mds-pref-language-item>` entries, letting users switch the active document language and persisting that choice.\n\n#### Semantic Behavior\n\n- **Usually inside `<mds-pref>`**: Placed as a direct slot child of `<mds-pref>`, alongside the other `mds-pref-*` controls; it also works on its own, since it applies and stores the language by itself. What it gives up on its own is in its mistakes. In turn it hosts its own `<mds-pref-language-item>` children, supplied via its default slot.\n- **Default slot hosts the items**: The default slot accepts one or more `<mds-pref-language-item>` elements; when the control loads, and whenever its items change, the item whose `code` matches the resolved language is marked selected; an item added after load is picked like the others (a later change of `set` does not move the selection).\n- **Selection orchestration**: Selecting an item clears the others, closes the dropdown, and resolves the new language - the children report up to this component, which centralizes the single-selection state.\n- **Language resolution & persistence**: When `set` is `auto` the active language is resolved in priority order from the persisted value, then the `<html lang>` attribute, then `navigator.language`. The resolved value is persisted and written to `<html lang>` - the single page-wide source of truth for the language. Every localized Magma component (including ones nested in shadow DOM) reacts automatically through a shared reactive store; there is no per-element `lang` override and no imperative refresh method. Applications that manage the language themselves can simply set `<html lang>`: the store observes it.\n- **Events bubbled to the parent**: Emits `mdsPrefLanguageChange` on every item pick, also when the picked language is already active (detail carries the selected `language` code; it fires just before the language is applied), and `mdsPrefChange` (detail `{ preference: 'language' }`), fired only when the resolved language actually changes, from a pick or from a new `set` value (the initial application on load does not emit). The latter is the event `<mds-pref>` listens to for its \"reload required\" notice, since application-level content may still need a reload; an application that follows `<html lang>` live sets `live-language` on the panel, which then shows no notice for the language.\n- **Invalid codes are ignored**: A `set` value that is neither `auto` nor a language tag (a primary subtag of two or three letters, such as `it` or `haw`, optionally followed by others, such as `it-IT`) is ignored with a console warning: the language in place stays, and on load the one `auto` resolves. A stored value that is no language tag is dropped.\n- **Default-language hint**: When the resolved language differs from the built-in default (`en`), a caption noting the default language is rendered.\n\n#### Properties & Visual Configurations\n\n- **`set`**: The desired language as a BCP 47 short tag (e.g. `it`, `en`, `es-ES`); the special value `auto` (default) defers to the persisted/page/system resolution chain described above. Region subtags are sanitized down to the two-letter language. Set an explicit value only to force a starting language regardless of the user's environment. Supported display languages are Italiano, English, Español and ελληνικά.\n- **`size`**: Sizes the nested tab trigger (`sm` / `md`). Inside `<mds-pref>`, the parent's `size` reaches this control on load and when it changes, and overwrites its own: set it on the parent.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-pref-language>` component, ordered from most common to most specialized. The examples assume a working knowledge of the shared component rules in [`agents/conventions.md`](../../../../agents/conventions.md).\n\n#### Basic Language Selector Inside `mds-pref`\n\nThe canonical usage. Nest `<mds-pref-language>` as a direct child of [`<mds-pref>`](../mds-pref/AGENTS.md) and populate its default slot with one [`<mds-pref-language-item>`](../mds-pref-language-item/AGENTS.md) per supported locale. The `code` attribute on each item must be a valid BCP 47 short tag.\n\n```html\n<mds-pref>\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"el\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Forcing a Starting Language with `set`\n\nPass an explicit BCP 47 tag to `set` to override the automatic resolution chain. Use this when the application dictates an initial language regardless of the user's browser setting or persisted preference.\n\n```html\n<mds-pref>\n  <mds-pref-language set=\"it\">\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"es\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Automatic Language Resolution (default)\n\nOmit `set` (or pass `set=\"auto\"`) to let the component resolve the active language in priority order: persisted user choice, then the page `<html lang>` attribute, then `navigator.language`. This is the right choice for most applications.\n\n```html\n<mds-pref>\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Sizing via `size`\n\nUse the `size` prop to size the tab trigger of a standalone control. Inside [`<mds-pref>`](../mds-pref/AGENTS.md), set `size` on the parent: it forwards it to every `mds-pref-*` child, so the group stays consistent.\n\n```html\n<mds-pref size=\"sm\">\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Listening for Language Changes\n\nListen to `mdsPrefLanguageChange` to react when the user picks a language (for example, to reload the page or re-fetch translated content). The event detail carries the selected `language` code string. It fires on every pick, also when the picked language is already the active one.\n\n```html\n<mds-pref>\n  <mds-pref-language id=\"lang-selector\">\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n\n<script>\n  document.querySelector('#lang-selector').addEventListener('mdsPrefLanguageChange', (e) => {\n    console.log('Nuova lingua selezionata:', e.detail.language);\n    // e.g. reload the page to apply the new locale\n    window.location.reload();\n  });\n</script>\n```\n\n#### Full Preference Panel with Language\n\n`<mds-pref-language>` is one of several preference children accepted by [`<mds-pref>`](../mds-pref/AGENTS.md). Compose it alongside the other controls to offer a complete preferences UI.\n\n```html\n<mds-pref>\n  <mds-pref-mode></mds-pref-mode>\n  <mds-pref-contrast></mds-pref-contrast>\n  <mds-pref-animation></mds-pref-animation>\n  <mds-pref-consumption></mds-pref-consumption>\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"es\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"el\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-pref-language>`. Each entry pairs the wrong form with the right one and a one-line reason. System-wide rules (boolean-as-string, shadow piercing, Tailwind color utilities, raw native event listening) live in [`agents/mistakes.md`](../../../../agents/mistakes.md) - they apply here too but are not repeated.\n\n#### Do Not Use Outside `mds-pref`\n\n`<mds-pref-language>` is a compound child designed to live inside [`<mds-pref>`](../mds-pref/AGENTS.md). As a standalone widget it still applies and persists the language, but it leaves the preference group: `<mds-pref>` forwards `size` changes to its `mds-pref-*` children and listens to their `mdsPrefChange` for the reload-required notice.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-language>\n  <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n  <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n</mds-pref-language>\n\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Do Not Slot Arbitrary HTML Instead of `mds-pref-language-item`\n\nThe default slot accepts only `<mds-pref-language-item>` elements. Slotting raw `<button>`, `<li>`, or other elements bypasses the selection orchestration and event wiring the parent depends on.\n\n```html\n<!-- INCORRECT -->\n<mds-pref>\n  <mds-pref-language>\n    <button>Italiano</button>\n    <button>English</button>\n  </mds-pref-language>\n</mds-pref>\n\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Do Not Pass an Unrecognized Language Code to `set`\n\nThe `set` prop must be either `\"auto\"` or a BCP 47 language tag: a primary subtag of two or three letters, the one of the item dictionary (`it`, `en`, `haw`), optionally followed by others (`it-IT`). Any other value - including language names like `\"italiano\"` or malformed strings like `\"en_US\"` - is ignored with a console warning and the language in place stays. Use the shortest primary subtag: `it`, not the ISO 639-2 `ita`, which has no item and no translation.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-language set=\"italiano\">...</mds-pref-language>\n<mds-pref-language set=\"en_US\">...</mds-pref-language>\n\n<!-- CORRECT -->\n<mds-pref-language set=\"it\">...</mds-pref-language>\n<mds-pref-language set=\"en\">...</mds-pref-language>\n<mds-pref-language set=\"es-ES\">...</mds-pref-language>\n```\n\n#### Do Not Set `selected` Manually on `mds-pref-language-item`\n\nThe parent `<mds-pref-language>` manages the `selected` state of each item automatically based on the active language: when it loads, and whenever its items change, it marks only the item whose `code` matches, and on each pick it clears the siblings. A `selected` written in the markup is overwritten on load; one set later from script leaves the visual selection out of step with the active language.\n\n```html\n<!-- INCORRECT -->\n<mds-pref>\n  <mds-pref-language set=\"it\">\n    <mds-pref-language-item code=\"it\" selected></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n\n<!-- CORRECT - the parent derives selection from `set` -->\n<mds-pref>\n  <mds-pref-language set=\"it\">\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Do Not Listen to `mdsPrefLanguageItemSelect` Instead of `mdsPrefLanguageChange`\n\n`mdsPrefLanguageItemSelect` is the item's own event, emitted by `<mds-pref-language-item>` and consumed by its parent. Application code should listen to `mdsPrefLanguageChange` on `<mds-pref-language>`: one listener for the whole list, fired after the parent has committed the selection (the language is applied right after it, so read it from `e.detail.language`).\n\n```html\n<!-- INCORRECT -->\n<script>\n  document.querySelector('mds-pref-language-item').addEventListener('mdsPrefLanguageItemSelect', (e) => {\n    console.log(e.detail.language);\n  });\n</script>\n\n<!-- CORRECT -->\n<script>\n  document.querySelector('mds-pref-language').addEventListener('mdsPrefLanguageChange', (e) => {\n    console.log(e.detail.language);\n  });\n</script>\n```\n\n#### Do Not Set Size via CSS Instead of the `size` Prop\n\nThe `size` prop is the only supported way to resize the internal tab trigger. Overriding dimensions with inline styles or CSS custom properties not listed in the component's documented surface couples your code to internal implementation details.\n\n```css\n/* INCORRECT */\nmds-pref-language mds-tab-item {\n  font-size: 10px;\n}\n```\n\n```html\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-language size=\"sm\">\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n"
      },
      "props": [
        {
          "name": "set",
          "type": "string",
          "complexType": {
            "original": "string",
            "resolved": "string",
            "references": {}
          },
          "mutable": true,
          "attr": "set",
          "reflectToAttr": true,
          "docs": "Specifies the language code based on HTML `lang` attribute\n\nA string representing the language version as defined in {@link https://datatracker.ietf.org/doc/html/rfc5646 RFC 5646: Tags for Identifying Languages (also known as BCP 47)}.\n\nSupported languages are Italiano, English, Español, ελληνικά",
          "docsTags": [
            {
              "name": "example",
              "text": "'en-US'"
            },
            {
              "name": "default",
              "text": "'auto'"
            }
          ],
          "default": "'auto'",
          "values": [
            {
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "size",
          "type": "\"md\" | \"sm\" | undefined",
          "complexType": {
            "original": "TabSizeType",
            "resolved": "\"md\" | \"sm\" | undefined",
            "references": {
              "TabSizeType": {
                "location": "import",
                "path": "@type/button",
                "id": "src/type/button.ts::TabSizeType",
                "referenceLocation": "TabSizeType"
              }
            }
          },
          "mutable": false,
          "attr": "size",
          "reflectToAttr": true,
          "docs": "Sets the size of the component items nested inside it",
          "docsTags": [],
          "values": [
            {
              "value": "md",
              "type": "string"
            },
            {
              "value": "sm",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [
        {
          "event": "mdsPrefChange",
          "detail": "MdsPrefChangeEventDetail",
          "bubbles": true,
          "complexType": {
            "original": "MdsPrefChangeEventDetail",
            "resolved": "MdsPrefChangeEventDetail",
            "references": {
              "MdsPrefChangeEventDetail": {
                "location": "import",
                "path": "@event/preference",
                "id": "src/event-detail/preference.ts::MdsPrefChangeEventDetail",
                "referenceLocation": "MdsPrefChangeEventDetail"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when the component is triggered",
          "docsTags": []
        },
        {
          "event": "mdsPrefLanguageChange",
          "detail": "MdsPrefLanguageEventDetail",
          "bubbles": true,
          "complexType": {
            "original": "MdsPrefLanguageEventDetail",
            "resolved": "MdsPrefLanguageEventDetail",
            "references": {
              "MdsPrefLanguageEventDetail": {
                "location": "import",
                "path": "@event/language",
                "id": "src/event-detail/language.ts::MdsPrefLanguageEventDetail",
                "referenceLocation": "MdsPrefLanguageEventDetail"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when the component changes the language selected from the click event of the dropdown list item",
          "docsTags": []
        }
      ],
      "listeners": [
        {
          "event": "mdsPrefLanguageItemSelect",
          "capture": false,
          "passive": false
        }
      ],
      "styles": [],
      "slots": [
        {
          "name": "",
          "docs": "Add `mds-pref-language-item` element/s."
        }
      ],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-text",
        "mds-tab",
        "mds-tab-item",
        "mds-dropdown"
      ],
      "dependencyGraph": {
        "mds-pref-language": [
          "mds-text",
          "mds-tab",
          "mds-tab-item",
          "mds-dropdown"
        ],
        "mds-tab-item": [
          "mds-button"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ]
      },
      "storybook": "ui-preferences-language--docs"
    }
  ]
}
