{
  "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-table-header/mds-table-header.tsx",
      "encapsulation": "shadow",
      "tag": "mds-table-header",
      "docs": "This is a web-component from Maggioli Design System [Magma](https://magma.maggiolicloud.it), built with StencilJS, TypeScript, Storybook. It's based on the web-component standard and it's designed to be agnostic from the JavaScript framework you are using.",
      "docsTags": [
        {
          "name": "slot",
          "text": "- Add `mds-table-header-cell` element/s, one per column: the header is itself the row of\nthe column headings."
        },
        {
          "name": "part",
          "text": "actions - The heading of the Actions column, shown while rows have `slot=\"action\"` content"
        },
        {
          "name": "parent",
          "text": "mds-table"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-table-header>` web component is the header region of a Magma table, used exclusively as a direct slot child of its parent [`<mds-table>`](../mds-table/AGENTS.md). It plays the role of an HTML `<thead>`/header row, hosting the column-header cells and, when selection is enabled, the master \"select all\" control.\n\n#### Semantic Behavior\n\n- **Compound child only**: Must be slotted directly inside `<mds-table>` alongside `mds-table-body` (and optionally `mds-table-footer`); it is not used standalone. It is itself the header row: its own default slot accepts `mds-table-header-cell` element(s), one per column.\n- **Parent-driven selection state**: When `selectable` is true the header renders a master checkbox that the parent keeps in sync - `indeterminate` for partial selection and `checked` when all rows are selected, rows selected in the markup on load included.\n- **Selection reported upward**: Toggling the master checkbox selects or deselects every row, after which the table re-emits its own `mdsTableSelectionChange` event.\n- **Automatic actions column**: When any row exposes a `[slot=\"action\"]`, the header appends an extra header cell (exposed as the `actions` shadow part) labelled with the localized \"actions\" string.\n- **Localized labels**: The select-all/select-none switch title and the actions label are localized (el/en/es/it). The title says what a click on the switch does: select every row, or deselect them once every row is selected, however they got selected.\n\n#### Properties & Visual Configurations\n\nThis child is configured almost entirely by its parent rather than by author-set attributes.\n\n- **`selectable`**: Toggles rendering of the leading master-checkbox column. It is not normally set by hand - `<mds-table>` propagates its own `selectable` prop down to the header, so enabling selection on the table is what surfaces this control here.\n\nBeyond `selectable`, content is provided through the default slot (`mds-table-header-cell` elements); there are no shared `variant`/`tone` ladders on this component.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-table-header>` 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 Column Headers\n\nPlace `<mds-table-header>` as a direct child of `<mds-table>` and fill its default slot with one `<mds-table-header-cell>` per column. Use the `label` prop on each cell - it is the only text source the cell needs.\n\n```html\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Nome\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Email\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Data registrazione\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <!-- mds-table-row elements -->\n  </mds-table-body>\n</mds-table>\n```\n\n#### Sortable Columns\n\nAdd the `sortable` attribute on the `<mds-table-header-cell>` elements whose column should be sortable. The cell cycles through `none`, `ascending`, and `descending` on each click and re-orders the corresponding body rows automatically.\n\n```html\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell sortable label=\"Cognome\"></mds-table-header-cell>\n    <mds-table-header-cell sortable label=\"Data\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Note\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <!-- mds-table-row elements -->\n  </mds-table-body>\n</mds-table>\n```\n\n#### Selectable Table with Master Checkbox\n\nEnable row selection by adding `selectable` on `<mds-table>`. The table propagates the prop down to `<mds-table-header>`, which automatically renders the master \"select all\" checkbox as the first column. Never set `selectable` directly on `<mds-table-header>` - drive it from the table.\n\n```html\n<mds-table selectable>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Utente\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Ruolo\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <mds-table-row value=\"1\">\n      <mds-table-cell>Mario Rossi</mds-table-cell>\n      <mds-table-cell>Amministratore</mds-table-cell>\n    </mds-table-row>\n    <mds-table-row value=\"2\">\n      <mds-table-cell>Giulia Bianchi</mds-table-cell>\n      <mds-table-cell>Editor</mds-table-cell>\n    </mds-table-row>\n  </mds-table-body>\n</mds-table>\n```\n\n#### Reacting to Selection Changes\n\nListen for `mdsTableSelectionChange` on `<mds-table>` to receive the array of selected rows whenever the master checkbox or any individual row checkbox changes.\n\n```html\n<mds-table selectable id=\"tabella-utenti\">\n  <mds-table-header>\n    <mds-table-header-cell label=\"Utente\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Stato\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <mds-table-row value=\"alice\">\n      <mds-table-cell>Alice Verdi</mds-table-cell>\n      <mds-table-cell>Attivo</mds-table-cell>\n    </mds-table-row>\n    <mds-table-row value=\"bob\">\n      <mds-table-cell>Bob Neri</mds-table-cell>\n      <mds-table-cell>Sospeso</mds-table-cell>\n    </mds-table-row>\n  </mds-table-body>\n</mds-table>\n\n<script>\n  document.getElementById('tabella-utenti').addEventListener('mdsTableSelectionChange', (e) => {\n    console.log('Righe selezionate:', e.detail.rows);\n  });\n</script>\n```\n\n#### Actions Column - Automatic Header Cell\n\nWhen any `<mds-table-row>` exposes a `[slot=\"action\"]`, `<mds-table-header>` automatically appends a right-aligned, localized header cell (\"Action\", \"Azione\" in Italian). No extra markup is required in the header - just place your action buttons in the row slots. The column follows the rows at any time, not only on load: a table mounted empty and filled after a fetch gets it when the first row with actions arrives, and loses it when the last one goes (`<mds-table>` tells the header).\n\n```html\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Documento\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Dimensione\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <mds-table-row>\n      <mds-table-cell>Relazione annuale.pdf</mds-table-cell>\n      <mds-table-cell>2,4 MB</mds-table-cell>\n      <mds-button\n        slot=\"action\"\n        icon=\"mi/baseline/download\"\n        title=\"Scarica\"\n        variant=\"primary\"\n        tone=\"text\"\n      ></mds-button>\n    </mds-table-row>\n  </mds-table-body>\n</mds-table>\n```\n\n#### Batch Actions with Selection\n\nWhen `selectable` is set and the table has a `batch-action` slot, a batch-actions toolbar slides in whenever rows are selected. The toolbar is owned by `<mds-table>`: every selection change, from a row checkbox or from the master checkbox in `<mds-table-header>`, updates its count and visibility.\n\n```html\n<mds-table selectable>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Nome file\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Tipo\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <mds-table-row value=\"doc1\">\n      <mds-table-cell>contratto.pdf</mds-table-cell>\n      <mds-table-cell>PDF</mds-table-cell>\n    </mds-table-row>\n    <mds-table-row value=\"doc2\">\n      <mds-table-cell>allegato.docx</mds-table-cell>\n      <mds-table-cell>Word</mds-table-cell>\n    </mds-table-row>\n  </mds-table-body>\n  <mds-button slot=\"batch-action\" label=\"Elimina selezionati\" variant=\"error\" tone=\"text\"></mds-button>\n  <mds-button slot=\"batch-action\" label=\"Esporta\" variant=\"primary\" tone=\"outline\"></mds-button>\n</mds-table>\n```\n\n#### Styling the Actions Part\n\nThe auto-generated actions header cell is exposed as the `actions` shadow part. Target it with `::part(actions)` to adjust alignment or other visual properties.\n\n```css\nmds-table-header::part(actions) {\n  text-align: center;\n  min-width: 8rem;\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-table-header>`. 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 `<mds-table-header>` Outside `<mds-table>`\n\n`<mds-table-header>` calls `this.host.closest('mds-table')` during load to wire up selection and action-column detection. Used standalone or inside a raw `<table>` it finds no table: the actions column is never detected, the master checkbox selects nothing, and every selection and sorting feature breaks.\n\n```html\n<!-- INCORRECT -->\n<table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Nome\"></mds-table-header-cell>\n  </mds-table-header>\n</table>\n\n<!-- CORRECT -->\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Nome\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body><!-- rows --></mds-table-body>\n</mds-table>\n```\n\n#### Do Not Slot `<mds-table-row>` Inside `<mds-table-header>`\n\nThe default slot of `<mds-table-header>` expects `<mds-table-header-cell>` elements - one per column. Slotting `<mds-table-row>` (a body-row component) into the header produces broken layout and wrong ARIA roles.\n\n```html\n<!-- INCORRECT -->\n<mds-table>\n  <mds-table-header>\n    <mds-table-row>\n      <mds-table-cell>Cognome</mds-table-cell>\n      <mds-table-cell>Email</mds-table-cell>\n    </mds-table-row>\n  </mds-table-header>\n  <mds-table-body><!-- rows --></mds-table-body>\n</mds-table>\n\n<!-- CORRECT -->\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Cognome\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Email\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body><!-- rows --></mds-table-body>\n</mds-table>\n```\n\n#### Do Not Set `selectable` Directly on `<mds-table-header>`\n\n`selectable` on the header is an internal prop driven by `<mds-table>` - when the table loads and whenever its `selectable` changes, it pushes its own value down. Setting it by hand on the header bypasses that synchronisation path and can leave rows and the master checkbox out of sync.\n\n```html\n<!-- INCORRECT -->\n<mds-table>\n  <mds-table-header selectable>\n    <mds-table-header-cell label=\"Utente\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body><!-- rows --></mds-table-body>\n</mds-table>\n\n<!-- CORRECT -->\n<mds-table selectable>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Utente\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body><!-- rows --></mds-table-body>\n</mds-table>\n```\n\n#### Do Not Add a Manual \"Actions\" Header Cell\n\nThe component detects `[slot=\"action\"]` children in the table body and appends the localized \"Azione\" header cell automatically. Adding your own header cell for actions doubles the column and misaligns the grid.\n\n```html\n<!-- INCORRECT -->\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Nome\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Azioni\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <mds-table-row>\n      <mds-table-cell>Mario Rossi</mds-table-cell>\n      <mds-button slot=\"action\" icon=\"mi/baseline/delete\" title=\"Elimina\" variant=\"error\" tone=\"text\"></mds-button>\n    </mds-table-row>\n  </mds-table-body>\n</mds-table>\n\n<!-- CORRECT -->\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Nome\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <mds-table-row>\n      <mds-table-cell>Mario Rossi</mds-table-cell>\n      <mds-button slot=\"action\" icon=\"mi/baseline/delete\" title=\"Elimina\" variant=\"error\" tone=\"text\"></mds-button>\n    </mds-table-row>\n  </mds-table-body>\n</mds-table>\n```\n\n#### Do Not Call `setSelection` from Application Code\n\n`setSelection(selectedItems, totalItems)` is an internal method called by `<mds-table>` every time it counts the selected rows: on load, after each row selection change and when rows come and go. Calling it from application code duplicates the table's internal bookkeeping and can leave the checkbox in an inconsistent state. React to selection results via the `mdsTableSelectionChange` event instead.\n\n```html\n<!-- INCORRECT -->\n<script>\n  const header = document.querySelector('mds-table-header');\n  header.setSelection(2, 5); // do not call this from app code\n</script>\n\n<!-- CORRECT -->\n<script>\n  document.querySelector('mds-table').addEventListener('mdsTableSelectionChange', (e) => {\n    console.log('Selezione corrente:', e.detail.rows);\n  });\n</script>\n```\n\n#### Do Not Use Raw `<thead>` / `<th>` Instead of the Component\n\nMixing raw HTML table elements with the Magma compound disrupts the selection wiring, the automatic actions column, and the localized labels that `<mds-table-header>` provides.\n\n```html\n<!-- INCORRECT -->\n<mds-table>\n  <thead>\n    <tr>\n      <th>Nome</th>\n      <th>Email</th>\n    </tr>\n  </thead>\n  <mds-table-body><!-- rows --></mds-table-body>\n</mds-table>\n\n<!-- CORRECT -->\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Nome\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Email\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body><!-- rows --></mds-table-body>\n</mds-table>\n```\n"
      },
      "props": [
        {
          "name": "selectable",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "selectable",
          "reflectToAttr": false,
          "docs": "Enables the select-all checkbox in the header.",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [
        {
          "name": "setActions",
          "returns": {
            "type": "Promise<void>",
            "docs": ""
          },
          "complexType": {
            "signature": "(hasActions: boolean) => Promise<void>",
            "parameters": [
              {
                "name": "hasActions",
                "type": "boolean",
                "docs": "whether any row has actions"
              }
            ],
            "references": {
              "Promise": {
                "location": "global",
                "id": "global::Promise"
              }
            },
            "return": "Promise<void>"
          },
          "signature": "setActions(hasActions: boolean) => Promise<void>",
          "parameters": [
            {
              "name": "hasActions",
              "type": "boolean",
              "docs": "whether any row has actions"
            }
          ],
          "docs": "`internal` Shows or hides the Actions column: mds-table calls it whenever its rows gain or\nlose `slot=\"action\"` content, the header itself reads them only on load",
          "docsTags": [
            {
              "name": "param",
              "text": "hasActions whether any row has actions"
            }
          ]
        },
        {
          "name": "setSelection",
          "returns": {
            "type": "Promise<void>",
            "docs": ""
          },
          "complexType": {
            "signature": "(selectedItems: number, totalItems: number) => Promise<void>",
            "parameters": [
              {
                "name": "selectedItems",
                "type": "number",
                "docs": "the number of currently selected rows"
              },
              {
                "name": "totalItems",
                "type": "number",
                "docs": "the total number of selectable rows"
              }
            ],
            "references": {
              "Promise": {
                "location": "global",
                "id": "global::Promise"
              }
            },
            "return": "Promise<void>"
          },
          "signature": "setSelection(selectedItems: number, totalItems: number) => Promise<void>",
          "parameters": [
            {
              "name": "selectedItems",
              "type": "number",
              "docs": "the number of currently selected rows"
            },
            {
              "name": "totalItems",
              "type": "number",
              "docs": "the total number of selectable rows"
            }
          ],
          "docs": "Updates the header's select-all state from the number of selected rows.",
          "docsTags": [
            {
              "name": "param",
              "text": "selectedItems the number of currently selected rows"
            },
            {
              "name": "param",
              "text": "totalItems the total number of selectable rows"
            }
          ]
        }
      ],
      "events": [],
      "listeners": [],
      "styles": [],
      "slots": [
        {
          "name": "",
          "docs": "Add `mds-table-header-cell` element/s, one per column: the header is itself the row of\nthe column headings."
        }
      ],
      "parts": [
        {
          "name": "actions",
          "docs": "The heading of the Actions column, shown while rows have `slot=\"action\"` content"
        }
      ],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-table-cell",
        "mds-input-switch",
        "mds-table-header-cell"
      ],
      "dependencyGraph": {
        "mds-table-header": [
          "mds-table-cell",
          "mds-input-switch",
          "mds-table-header-cell"
        ],
        "mds-input-switch": [
          "mds-icon",
          "mds-text"
        ],
        "mds-table-header-cell": [
          "mds-button",
          "mds-text"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ]
      },
      "storybook": "layout-table-header--docs"
    }
  ]
}
