{
  "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-cell/mds-table-header-cell.tsx",
      "encapsulation": "shadow",
      "tag": "mds-table-header-cell",
      "docs": "",
      "docsTags": [
        {
          "name": "part",
          "text": "action - The `mds-button` that sorts the column, with the `label`: only when `sortable`"
        },
        {
          "name": "part",
          "text": "label - The `label` of a column that is not `sortable`"
        },
        {
          "name": "parent",
          "text": "mds-table-header"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-table-header-cell>` web component is the column-header cell of a Magma data table. It is a compound child of [`<mds-table-header>`](../mds-table-header/AGENTS.md) and plays the role of a native `<th>` (`columnheader`), rendering the column label and, when enabled, acting as the interactive sort control for its column.\n\n#### Semantic Behavior\n\n- **Compound child only**: Must be placed as a direct slot child of `<mds-table-header>`; it is not used standalone, and its sorting acts on the body rows within the enclosing `mds-table`.\n- **Header role and ARIA sort**: Reflects its current sort state through `aria-sort`, mirroring the `direction` prop (`none` / `ascending` / `descending`).\n- **Position-based sorting**: The cell sorts the matching `mds-table-cell` of every body row by column position; values come from each cell's `value` (falling back to trimmed text), with numeric values compared numerically and others compared alphabetically. With `sorting=\"external\"` on the table it moves no row: the application renders them in the order asked.\n- **Tri-state sort cycle**: Each activation advances the column through `none` -> `ascending` -> `descending` and back to `none`; the `none` state restores the order the rows had before any column sorted them (rows removed in the meantime stay out, rows added go last).\n- **Sort event**: Every click emits `mdsTableHeaderCellSort`, which bubbles to the table, with `{ direction, index, sortKey }`: the new direction, the position of the column and its `sort-key`. A `direction` set by the application emits nothing, the application already knows it.\n- **Single active sort column**: Sorting a column resets every sibling header cell to `none`, so only one column drives the order at a time.\n- **Conditional rendering**: When `sortable` is set the cell renders a clickable sorter (with an up / down / unfold-more icon reflecting `direction`); otherwise it renders a plain label with no interaction.\n\n#### Properties & Visual Configurations\n\n- **`sortable`**: Opt a column into interactive sorting. Leave it unset for purely descriptive columns (label only); set it when the column's values should be reorderable by the user.\n- **`direction`**: The reflected sort state of the column (`none`, `ascending`, `descending`), which drives the sort icon and `aria-sort`. Set from outside (or in the markup) it acts like the clicks that lead there: it sorts the rows, or only shows the order with `sorting=\"external\"`, resets the other columns to `none`, and the next click goes on from it.\n- **`sortKey`** (`sort-key`): Names the column in `mdsTableHeaderCellSort`, typically the field the back end sorts by, so the application does not depend on the position of the column.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-table-header-cell>` 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#### Plain Header Cell\n\nThe simplest form: a non-sortable column header that renders a styled label. Omit `sortable` for columns whose values should not be reordered.\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=\"Ruolo\"></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>\n      <mds-table-cell>Mario Rossi</mds-table-cell>\n      <mds-table-cell>Amministratore</mds-table-cell>\n      <mds-table-cell>Attivo</mds-table-cell>\n    </mds-table-row>\n  </mds-table-body>\n</mds-table>\n```\n\n#### Sortable Column Header\n\nAdd the `sortable` boolean attribute to enable the tri-state click cycle (`none` -> `ascending` -> `descending` -> `none`). The component manages sorting internally - no JavaScript wiring is required.\n\n```html\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Cognome\" sortable></mds-table-header-cell>\n    <mds-table-header-cell label=\"Dipartimento\" sortable></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>\n      <mds-table-cell>Bianchi</mds-table-cell>\n      <mds-table-cell>Risorse Umane</mds-table-cell>\n      <mds-table-cell>-</mds-table-cell>\n    </mds-table-row>\n    <mds-table-row>\n      <mds-table-cell>Amendola</mds-table-cell>\n      <mds-table-cell>Informatica</mds-table-cell>\n      <mds-table-cell>-</mds-table-cell>\n    </mds-table-row>\n  </mds-table-body>\n</mds-table>\n```\n\n#### Mixing Sortable and Non-Sortable Columns\n\nPlace `sortable` only on columns whose values are meaningfully orderable. Action columns or complex-content columns should remain non-sortable.\n\n```html\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"ID\" sortable></mds-table-header-cell>\n    <mds-table-header-cell label=\"Descrizione\" sortable></mds-table-header-cell>\n    <mds-table-header-cell label=\"Importo\" sortable></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 value=\"1\">1</mds-table-cell>\n      <mds-table-cell>Abbonamento annuale</mds-table-cell>\n      <mds-table-cell value=\"120\">120,00 EUR</mds-table-cell>\n      <mds-table-cell><mds-button label=\"Modifica\" tone=\"text\" variant=\"primary\"></mds-button></mds-table-cell>\n    </mds-table-row>\n    <mds-table-row>\n      <mds-table-cell value=\"2\">2</mds-table-cell>\n      <mds-table-cell>Licenza mensile</mds-table-cell>\n      <mds-table-cell value=\"15\">15,00 EUR</mds-table-cell>\n      <mds-table-cell><mds-button label=\"Modifica\" tone=\"text\" variant=\"primary\"></mds-button></mds-table-cell>\n    </mds-table-row>\n  </mds-table-body>\n</mds-table>\n```\n\n#### Providing Numeric Values for Correct Sort Order\n\nWhen a column displays formatted text (currency, percentages) but should sort numerically, set the `value` prop on each `<mds-table-cell>` to the raw numeric string. The header cell reads `value` first and falls back to text content.\n\n```html\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Prodotto\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Punteggio\" sortable></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <mds-table-row>\n      <mds-table-cell>Prodotto A</mds-table-cell>\n      <mds-table-cell value=\"8.5\">8,5 / 10</mds-table-cell>\n    </mds-table-row>\n    <mds-table-row>\n      <mds-table-cell>Prodotto B</mds-table-cell>\n      <mds-table-cell value=\"10\">10 / 10</mds-table-cell>\n    </mds-table-row>\n    <mds-table-row>\n      <mds-table-cell>Prodotto C</mds-table-cell>\n      <mds-table-cell value=\"2.3\">2,3 / 10</mds-table-cell>\n    </mds-table-row>\n  </mds-table-body>\n</mds-table>\n```\n\n#### Setting the Direction from Outside\n\nSet `direction` to sort by a column without a click - for example from a sort order kept in the address. It sorts the rows as the clicks that lead there would, resets the other columns to `none`, and the next click goes on with the cycle from it. `none` brings back the original order. No `mdsTableHeaderCellSort` is emitted: the application set it.\n\n```html\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Data\" sortable direction=\"descending\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Categoria\" sortable></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <!-- rows -->\n  </mds-table-body>\n</mds-table>\n```\n\n```js\ndocument.querySelector('mds-table-header-cell').direction = 'none';\n```\n\n#### Sorting by the Back End\n\nWhen the table shows one page of a larger set, give the table `sorting=\"external\"` and each sortable column a `sort-key`. A click then moves no row: listen to `mdsTableHeaderCellSort` and load the rows in the order asked. See the pattern with `mds-paginator` in [`mds-table`](../mds-table/AGENTS.md).\n\n```html\n<mds-table sorting=\"external\">\n  <mds-table-header>\n    <mds-table-header-cell label=\"Numero\" sortable sort-key=\"number\"></mds-table-header-cell>\n    <mds-table-header-cell label=\"Ricevuta il\" sortable sort-key=\"received\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body>\n    <!-- the rows of the current page -->\n  </mds-table-body>\n</mds-table>\n```\n\n```js\ndocument.querySelector('mds-table').addEventListener('mdsTableHeaderCellSort', (event) => {\n  const { sortKey, direction } = event.detail; // 'received', 'descending'\n  loadFirstPage(direction === 'none' ? undefined : { sortKey, direction });\n});\n```\n\n#### Styling Customization\n\nTarget the `label` or `action` shadow parts for glyph-level overrides. Set them on the host or a parent selector.\n\n```css\nmds-table-header-cell::part(label) {\n  font-weight: var(--font-weight-semibold);\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-table-header-cell>`. 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-table-header`\n\n`<mds-table-header-cell>` is a compound child component and relies on traversing the DOM to locate its sibling cells and the `<mds-table-body>` for sorting. Using it outside `<mds-table-header>` breaks both the layout and the sort logic.\n\n```html\n<!-- INCORRECT -->\n<div class=\"table-head\">\n  <mds-table-header-cell label=\"Nome\" sortable></mds-table-header-cell>\n</div>\n\n<!-- CORRECT -->\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Nome\" sortable></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body><!-- rows --></mds-table-body>\n</mds-table>\n```\n\n#### Do Not Let the Cells Sort a Table with Pages\n\nBy default a sortable header cell reorders the rows in the DOM. On a table that shows one page of a larger set that sorts the page on screen, not the data: the first row is not the first of the set.\n\n```html\n<!-- INCORRECT -->\n<mds-table>\n  <mds-table-header>\n    <mds-table-header-cell label=\"Numero\" sortable></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body><!-- one page of rows --></mds-table-body>\n</mds-table>\n<mds-paginator pages=\"12\"></mds-paginator>\n\n<!-- CORRECT - the back end sorts, after mdsTableHeaderCellSort -->\n<mds-table sorting=\"external\">\n  <mds-table-header>\n    <mds-table-header-cell label=\"Numero\" sortable sort-key=\"number\"></mds-table-header-cell>\n  </mds-table-header>\n  <mds-table-body><!-- one page of rows --></mds-table-body>\n</mds-table>\n<mds-paginator pages=\"12\"></mds-paginator>\n```\n\n#### Do Not Use `sortable=\"false\"` to Disable Sorting\n\n`sortable` is a boolean attribute. Stencil reads the exact string `\"false\"` as `false`, but the attribute stays on the element, where attribute selectors and any code that tests for its presence still read it as set. Remove the attribute entirely to produce a non-sortable header cell.\n\n```html\n<!-- INCORRECT -->\n<mds-table-header-cell label=\"Stato\" sortable=\"false\"></mds-table-header-cell>\n\n<!-- CORRECT -->\n<mds-table-header-cell label=\"Stato\"></mds-table-header-cell>\n```\n\n#### Do Not Slot Content Instead of Using the `label` Prop\n\nThe component renders its label through the `label` prop; there is no documented slot. Placing text or elements as children of the host puts them in an unsupported slot and they will not appear.\n\n```html\n<!-- INCORRECT -->\n<mds-table-header-cell sortable>\n  <span>Cognome</span>\n</mds-table-header-cell>\n\n<!-- CORRECT -->\n<mds-table-header-cell label=\"Cognome\" sortable></mds-table-header-cell>\n```\n\n#### Do Not Pierce Shadow DOM to Style the Sort Button\n\nThe sort button is an internal `<mds-button>` inside the shadow root. Use the documented `::part(action)` instead of undocumented selectors.\n\n```css\n/* INCORRECT */\nmds-table-header-cell >>> .action {\n  background-color: red;\n}\n\n/* CORRECT */\nmds-table-header-cell::part(action) {\n  /* use only documented part-level overrides */\n}\n```\n\n#### Do Not Wrap the Cell in a Native `<th>`\n\n`<mds-table-header-cell>` already carries `role=\"columnheader\"` and manages `aria-sort`. Wrapping it inside a native `<th>` doubles the ARIA semantics and produces invalid table structure.\n\n```html\n<!-- INCORRECT -->\n<thead>\n  <tr>\n    <th><mds-table-header-cell label=\"Nome\"></mds-table-header-cell></th>\n  </tr>\n</thead>\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>\n```\n"
      },
      "props": [
        {
          "name": "direction",
          "type": "\"ascending\" | \"descending\" | \"none\"",
          "complexType": {
            "original": "SortDirectionType",
            "resolved": "\"ascending\" | \"descending\" | \"none\"",
            "references": {
              "SortDirectionType": {
                "location": "import",
                "path": "./meta/types",
                "id": "src/components/mds-table-header-cell/meta/types.ts::SortDirectionType",
                "referenceLocation": "SortDirectionType"
              }
            }
          },
          "mutable": true,
          "attr": "direction",
          "reflectToAttr": true,
          "docs": "Specifies the current sort direction of the column. Set from outside, it sorts the rows like a\nclick, or only shows the order when the table has `sorting=\"external\"`.",
          "docsTags": [
            {
              "name": "default",
              "text": "'none'"
            }
          ],
          "default": "'none'",
          "values": [
            {
              "value": "ascending",
              "type": "string"
            },
            {
              "value": "descending",
              "type": "string"
            },
            {
              "value": "none",
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "label",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "label",
          "reflectToAttr": true,
          "docs": "Sets a label for the cell",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "sortKey",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "sort-key",
          "reflectToAttr": true,
          "docs": "Names the column in the `mdsTableHeaderCellSort` event, for example the field the back end\nsorts by",
          "docsTags": [
            {
              "name": "example",
              "text": "'createdAt'"
            }
          ],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "sortable",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "sortable",
          "reflectToAttr": true,
          "docs": "Tells the component to make the cell able to sort the table columns items",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [
        {
          "event": "mdsTableHeaderCellSort",
          "detail": "MdsTableHeaderCellSortEventDetail",
          "bubbles": true,
          "complexType": {
            "original": "MdsTableHeaderCellSortEventDetail",
            "resolved": "MdsTableHeaderCellSortEventDetail",
            "references": {
              "MdsTableHeaderCellSortEventDetail": {
                "location": "import",
                "path": "./meta/event-detail",
                "id": "src/components/mds-table-header-cell/meta/event-detail.ts::MdsTableHeaderCellSortEventDetail",
                "referenceLocation": "MdsTableHeaderCellSortEventDetail"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when the user changes the sort direction of the column, at every step of the cycle. With\n`sorting=\"external\"` on the table the rows are not moved: the application renders them in the\norder asked.",
          "docsTags": []
        }
      ],
      "listeners": [],
      "styles": [],
      "slots": [],
      "parts": [
        {
          "name": "action",
          "docs": "The `mds-button` that sorts the column, with the `label`: only when `sortable`"
        },
        {
          "name": "label",
          "docs": "The `label` of a column that is not `sortable`"
        }
      ],
      "states": [],
      "dependents": [
        "mds-table-header"
      ],
      "dependencies": [
        "mds-button",
        "mds-text"
      ],
      "dependencyGraph": {
        "mds-table-header-cell": [
          "mds-button",
          "mds-text"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ],
        "mds-table-header": [
          "mds-table-header-cell"
        ]
      },
      "storybook": "layout-table-header-cell--docs"
    }
  ]
}
