{
  "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-item/mds-pref-language-item.tsx",
      "encapsulation": "shadow",
      "tag": "mds-pref-language-item",
      "docs": "",
      "docsTags": [
        {
          "name": "parent",
          "text": "mds-pref-language"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-pref-language-item>` web component represents a single selectable language option inside the language-preference picker [`<mds-pref-language>`](../mds-pref-language/AGENTS.md). It renders one row of the parent's dropdown and reports the user's choice up to the parent rather than changing the page language itself.\n\n#### Semantic Behavior\n\n- **Compound child only**: Must be placed as a direct default-slot child of `<mds-pref-language>`; it is not used standalone or mixed with other child types.\n- **Code validation**: `code` must match an entry in the bundled language dictionary; an unknown `code` logs a console warning and the item shows the code itself in place of a language name. When `code` is empty the item renders an error-toned fallback button instead of a language label.\n- **Label is derived, not authored**: The visible language name is looked up from `code` (e.g. `it` to `Italiano`), so consumers supply only the code, not the display text.\n- **Selection is parent-driven**: The `selected` prop is owned and toggled by `<mds-pref-language>`, which clears every sibling and sets only the active item.\n- **Click emits, does not commit**: Clicking the item emits the bubbling `mdsPrefLanguageItemSelect` event carrying `{ language: code }`. The parent updates selection state, persists the preference, applies the document language, and emits its own `mdsPrefLanguageChange` - this child performs none of that.\n\n#### Properties & Visual Configurations\n\nThe only meaningful prop is `code`: the BCP 47 / RFC 5646 language tag (such as `it`, `en`, `es`) that both keys the label lookup and is the payload emitted on selection. The accepted codes are the keys of the bundled language dictionary: the two-letter ISO 639-1 codes (`it`, `en`, `fr`, `de`, `zh`, ...) plus `ceb`, `haw` and `hmn`, which the parent cannot apply (its `set` accepts only `xx` / `xx-XX` codes).\n\n`selected` is a state flag managed by the parent rather than a configuration choice. Sizing and styling are fixed by the parent's layout, so this item exposes no `variant` / `tone` of its own; the shared ladders in [`agents/variants.md`](../../../../agents/variants.md) are applied internally and are not configurable from the host.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-pref-language-item>` 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 List Inside the Parent\n\nThe canonical form. Place one `<mds-pref-language-item>` per supported language as a direct child of [`<mds-pref-language>`](../mds-pref-language/AGENTS.md). Set `code` to a BCP 47 tag that exists in the bundled dictionary; the component resolves the display name automatically.\n\n```html\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=\"fr\"></mds-pref-language-item>\n</mds-pref-language>\n```\n\n#### Pre-selecting the Active Language\n\nPre-select through the parent, not through `selected`: `<mds-pref-language>` marks the item whose `code` matches its resolved language when it loads, and overwrites any `selected` written in the markup. Pass the language to the parent's `set` (or leave `set` on `auto`).\n\n```html\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=\"de\"></mds-pref-language-item>\n</mds-pref-language>\n```\n\n#### Listening for a Language Selection\n\nThe item emits `mdsPrefLanguageItemSelect` with `{ language: code }` when clicked. In most cases you should listen on the parent (`mdsPrefLanguageChange`) rather than on individual items - but listening on the item directly is valid when you need fine-grained control.\n\n```html\n<mds-pref-language>\n  <mds-pref-language-item code=\"it\" id=\"lang-it\"></mds-pref-language-item>\n  <mds-pref-language-item code=\"en\" id=\"lang-en\"></mds-pref-language-item>\n</mds-pref-language>\n\n<script>\n  document.querySelectorAll('mds-pref-language-item').forEach((item) => {\n    item.addEventListener('mdsPrefLanguageItemSelect', (e) => {\n      console.log('Lingua scelta:', e.detail.language);\n    });\n  });\n</script>\n```\n\n#### Offering a Large Language Set\n\nAdd as many items as needed - the parent lists them all in its dropdown. Each item only needs a `code`; the visible label is derived automatically.\n\n```html\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=\"fr\"></mds-pref-language-item>\n  <mds-pref-language-item code=\"de\"></mds-pref-language-item>\n  <mds-pref-language-item code=\"pt\"></mds-pref-language-item>\n  <mds-pref-language-item code=\"zh\"></mds-pref-language-item>\n  <mds-pref-language-item code=\"ar\"></mds-pref-language-item>\n</mds-pref-language>\n```\n\n#### Inside a Full Preferences Panel\n\n`<mds-pref-language>` and its items compose inside [`<mds-pref>`](../mds-pref/AGENTS.md) alongside the other preference controls. Place them as direct children of `<mds-pref>`.\n\n```html\n<mds-pref>\n  <mds-pref-mode></mds-pref-mode>\n  <mds-pref-contrast></mds-pref-contrast>\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",
        "3. Mistakes": "Common incorrect uses of `<mds-pref-language-item>`. 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 the Item Outside Its Parent\n\n`<mds-pref-language-item>` is a compound child and relies on `<mds-pref-language>` for selection management, dropdown layout, and language persistence. Using it standalone leaves the click handler dangling and the selection state unmanaged.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-language-item code=\"it\"></mds-pref-language-item>\n\n<!-- CORRECT -->\n<mds-pref-language>\n  <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n</mds-pref-language>\n```\n\n#### Do Not Set the Display Label Manually\n\nThe item derives its label from the `code` prop via the bundled dictionary. Attempting to pass display text in the default slot or as an attribute is not supported and will be ignored by the render function.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-language-item code=\"it\">Italiano</mds-pref-language-item>\n\n<!-- CORRECT -->\n<mds-pref-language-item code=\"it\"></mds-pref-language-item>\n```\n\n#### Do Not Use an Undocumented or Misspelled Language Code\n\n`code` must exactly match a key in the bundled dictionary (e.g. `\"it\"`, `\"en\"`, `\"fr\"`). An unknown code logs a console warning when the item loads or its `code` changes, and the item shows the raw code instead of a language name. Use the two-letter BCP 47 tag, not a locale variant like `\"it-IT\"`.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-language-item code=\"it-IT\"></mds-pref-language-item>\n<mds-pref-language-item code=\"italian\"></mds-pref-language-item>\n\n<!-- CORRECT -->\n<mds-pref-language-item code=\"it\"></mds-pref-language-item>\n```\n\n#### Do Not Manage the `selected` Prop by Hand Across Items\n\nThe parent marks only the item matching the active language when it loads, overwriting the `selected` written in the markup, and clears every sibling on each pick. If you toggle `selected` yourself from script, several items can show as selected at once, out of step with the stored preference.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-language>\n  <mds-pref-language-item code=\"it\" selected></mds-pref-language-item>\n  <mds-pref-language-item code=\"en\" selected></mds-pref-language-item>\n</mds-pref-language>\n\n<!-- CORRECT -->\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```\n\n#### Do Not Listen for Native `click` to Detect Language Selection\n\nThe component emits `mdsPrefLanguageItemSelect` (or the parent emits `mdsPrefLanguageChange`). A native `click` carries no `detail`, so it skips the event payload that carries the selected language code, and it does not tell you that the parent has committed the pick.\n\n```html\n<!-- INCORRECT -->\n<script>\n  document.querySelector('mds-pref-language-item').addEventListener('click', () => {\n    // no language code available here\n  });\n</script>\n\n<!-- CORRECT -->\n<script>\n  document.querySelector('mds-pref-language').addEventListener('mdsPrefLanguageChange', (e) => {\n    console.log('Lingua selezionata:', e.detail.language);\n  });\n</script>\n```\n\n#### Do Not Set `selected=\"false\"` to Deselect\n\n`selected` is a boolean attribute: a false boolean is written by removing the attribute ([`agents/conventions.md`](../../../../agents/conventions.md)), or by setting the prop to `false` from script. Stencil does parse `\"false\"` as `false`, but the attribute stays in the markup until the component hydrates and its reflection removes it, so a `[selected]` selector or any code reading the attribute sees it set in the meantime. Inside `<mds-pref-language>` the parent owns `selected` anyway.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-language-item code=\"it\" selected=\"false\"></mds-pref-language-item>\n\n<!-- CORRECT -->\n<mds-pref-language-item code=\"it\"></mds-pref-language-item>\n```\n"
      },
      "props": [
        {
          "name": "code",
          "type": "string",
          "complexType": {
            "original": "string",
            "resolved": "string",
            "references": {}
          },
          "mutable": false,
          "attr": "code",
          "reflectToAttr": true,
          "docs": "Specifies the language code based on HTML `lang` attribute",
          "docsTags": [
            {
              "name": "example",
              "text": "'it'"
            }
          ],
          "values": [
            {
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "selected",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "selected",
          "reflectToAttr": true,
          "docs": "Specifies if the element is selected",
          "docsTags": [
            {
              "name": "default",
              "text": "false"
            }
          ],
          "default": "false",
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [
        {
          "event": "mdsPrefLanguageItemSelect",
          "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 trigger the language",
          "docsTags": []
        }
      ],
      "listeners": [],
      "styles": [],
      "slots": [],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-button"
      ],
      "dependencyGraph": {
        "mds-pref-language-item": [
          "mds-button"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ]
      },
      "storybook": "ui-preferences-language-item--docs"
    }
  ]
}
