{
  "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-filter/mds-filter.tsx",
      "encapsulation": "shadow",
      "tag": "mds-filter",
      "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-filter-item` element/s."
        },
        {
          "name": "category",
          "text": "forms"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-filter>` web component is a compound container that groups a set of `<mds-filter-item>` chips into a single, scrollable filter bar, coordinating their selection state and exposing the active values as one combined change event. It has no native HTML equivalent: it orchestrates its children rather than rendering a control of its own.\n\n#### Semantic Behavior\n\n- **Compound parent**: Acts as the controller for slotted `<mds-filter-item>` children, driving their state in response to selection events.\n- **Group of toggles**: The host is a `group` named by `label`, and each item is a toggle button whose pressed state follows its selection: a screen reader hears which filters are on and how many results each one shows. Every item is a Tab stop; there is no arrow-key navigation.\n- **Selection coordination**: In single mode it enforces exclusive selection (selecting one deselects the others); in `multiple` mode it keeps every selected child active and tracks how many are selected.\n- **Selection set by the application**: The selection lives on the items' `selected`. Setting or clearing it from the application, or rendering an item already selected, is taken in as after a click: in single mode only the last item set stays selected, the reset button shows or hides, the strip scrolls to the item. No `mdsFilterChange` is emitted for it, and `autoReset` does not apply: the application already knows. Two items `selected` in the markup of a single-mode bar leave the last one selected, as a `<select>` does.\n- **Combined change event**: `mdsFilterChange` fires whenever the user changes the selection (an item, or the reset button), carrying both the `NodeList` of the children and a comma-joined string of the selected items' `value`s.\n- **Reset control**: When `reset` is set, a clear-all button appears once a filter is active, named in the page language (the `lang` of `<html>`) (\"Clear filters\"). A click clears all selections and emits `mdsFilterChange` with an empty `value`. While no filter is active the button is scaled away, out of the tab order and of the accessibility tree; without `reset` it is not rendered at all.\n- **Auto-scroll**: On each selection the bar scrolls horizontally to center the most recently selected item.\n- **Default slot**: The default slot is for `<mds-filter-item>` elements only, not arbitrary text or markup.\n\n#### Properties & Visual Configurations\n\n- **`multiple`** switches the bar from exclusive single-select behavior to allowing several items active at once; choose it when filters are additive rather than mutually exclusive.\n- **`reset`** opts the bar into showing a dedicated clear-all control whenever one or more filters are active.\n- **`autoReset`** automatically clears all selections once every item has been selected - useful in `multiple` mode where \"all selected\" is equivalent to \"no filter applied\".\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-filter>` 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 Single-Select Filter Bar\n\nThe canonical form. Slot `<mds-filter-item>` children directly; the parent enforces exclusive selection in single mode - selecting one item deselects all others. Always provide `value` on each item so the `mdsFilterChange` event carries meaningful data.\n\n```html\n<mds-filter label=\"Categoria\">\n  <mds-filter-item label=\"Tutti\" value=\"all\"></mds-filter-item>\n  <mds-filter-item label=\"Notizie\" value=\"news\"></mds-filter-item>\n  <mds-filter-item label=\"Comunicati\" value=\"press\" count=\"14\"></mds-filter-item>\n  <mds-filter-item label=\"Aggiornamenti\" value=\"updates\" count=\"3\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Listening to Selection Changes\n\nListen to `mdsFilterChange` on the parent. The event detail carries `value` (comma-joined string of selected `value` attributes) and `children` (the `NodeList` of the items, for advanced inspection).\n\n```html\n<mds-filter id=\"filter-stato\" label=\"Stato\">\n  <mds-filter-item label=\"Bozza\" value=\"draft\"></mds-filter-item>\n  <mds-filter-item label=\"Pubblicato\" value=\"published\"></mds-filter-item>\n  <mds-filter-item label=\"Archiviato\" value=\"archived\"></mds-filter-item>\n</mds-filter>\n\n<script>\n  document.getElementById('filter-stato').addEventListener('mdsFilterChange', (event) => {\n    console.log('Filtro attivo:', event.detail.value);\n  });\n</script>\n```\n\n#### Multi-Select Filter Bar\n\nSet `multiple` when filters are additive rather than mutually exclusive. All selected items stay active simultaneously; `mdsFilterChange` fires after each toggle.\n\n```html\n<mds-filter label=\"Etichette\" multiple>\n  <mds-filter-item label=\"Urgente\" value=\"urgent\" count=\"2\"></mds-filter-item>\n  <mds-filter-item label=\"In revisione\" value=\"review\" count=\"7\"></mds-filter-item>\n  <mds-filter-item label=\"Completato\" value=\"done\" count=\"31\"></mds-filter-item>\n  <mds-filter-item label=\"Annullato\" value=\"cancelled\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Reset Button\n\nSet `reset` to show a clear-all control whenever at least one item is active. The reset control is hidden when no filter is selected and becomes visible automatically when a selection is made. It is named in the page language (\"Clear filters\") and emits `mdsFilterChange` with an empty `value` when it clears the selection.\n\n```html\n<mds-filter label=\"Tipo documento\" multiple reset>\n  <mds-filter-item label=\"PDF\" value=\"pdf\" count=\"5\"></mds-filter-item>\n  <mds-filter-item label=\"Word\" value=\"doc\" count=\"12\"></mds-filter-item>\n  <mds-filter-item label=\"Immagine\" value=\"image\" count=\"8\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Auto-Reset on Full Selection\n\nUse `auto-reset` together with `multiple` when selecting all items is semantically identical to \"no filter applied\". Once every item is selected, the component clears all selections automatically.\n\n```html\n<mds-filter label=\"Priorita\" multiple auto-reset>\n  <mds-filter-item label=\"Alta\" value=\"high\"></mds-filter-item>\n  <mds-filter-item label=\"Media\" value=\"medium\"></mds-filter-item>\n  <mds-filter-item label=\"Bassa\" value=\"low\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Filter Item with Icon\n\nSupply `icon` on individual `<mds-filter-item>` children to add a glyph alongside the label. The icon slug follows iconsauce conventions; the spoken name comes from `label`, or from the icon slug when no label is present (`grid view` for `mi/baseline/grid-view`).\n\n```html\n<mds-filter label=\"Formato\">\n  <mds-filter-item label=\"Video\" value=\"video\" icon=\"mi/baseline/videocam\"></mds-filter-item>\n  <mds-filter-item label=\"Audio\" value=\"audio\" icon=\"mi/baseline/headset\"></mds-filter-item>\n  <mds-filter-item label=\"Testo\" value=\"text\" icon=\"mi/baseline/article\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Pre-Selected Item\n\nSet `selected` on a child at page load to reflect a filter that is already active (e.g. restored from a URL parameter or user preference). The parent picks up the initial state when it loads.\n\n```html\n<mds-filter label=\"Periodo\">\n  <mds-filter-item label=\"Oggi\" value=\"today\"></mds-filter-item>\n  <mds-filter-item label=\"Settimana corrente\" value=\"week\" selected></mds-filter-item>\n  <mds-filter-item label=\"Mese corrente\" value=\"month\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Setting the Selection from the Application\n\nWhen the filters live somewhere else - in the address, in a store, behind a \"Clear filters\" button outside the bar - set `selected` on the items: the bar follows as after the same clicks (single mode, reset button), without emitting `mdsFilterChange`. In a framework, bind `selected` on each item to the state.\n\n```html\n<mds-filter id=\"status\" label=\"Stato\" reset>\n  <mds-filter-item label=\"Nuove\" value=\"new\"></mds-filter-item>\n  <mds-filter-item label=\"Aperte\" value=\"open\"></mds-filter-item>\n  <mds-filter-item label=\"Chiuse\" value=\"closed\"></mds-filter-item>\n</mds-filter>\n<mds-button id=\"clear\" label=\"Rimuovi i filtri\" variant=\"dark\" tone=\"text\"></mds-button>\n```\n\n```js\nconst items = [...document.querySelectorAll('#status mds-filter-item')];\n\n// restore the filter from the address on load\nconst status = new URLSearchParams(location.search).get('status');\nitems.forEach((item) => {\n  item.selected = item.value === status;\n});\n\n// clear it from a button outside the bar\ndocument.querySelector('#clear').addEventListener('click', () => {\n  items.forEach((item) => {\n    item.selected = false;\n  });\n});\n```\n\n#### Disabled Item\n\nSet `disabled` on individual `<mds-filter-item>` children to block them: a disabled item leaves the tab order, ignores clicks and keys, is announced as unavailable (`aria-disabled`) and is painted in the disabled text colour.\n\n```html\n<mds-filter label=\"Stato pratica\">\n  <mds-filter-item label=\"Aperta\" value=\"open\" count=\"9\"></mds-filter-item>\n  <mds-filter-item label=\"In attesa\" value=\"pending\" count=\"2\"></mds-filter-item>\n  <mds-filter-item label=\"Chiusa\" value=\"closed\" disabled></mds-filter-item>\n</mds-filter>\n```\n\n#### Styling Customization\n\nStyle the filter bar only through its public `--mds-filter-*` CSS custom properties. Set them on the host or a parent selector; use the semantic color roles via `rgb(var(--magma-<role>))` and the `--spacing` scale so dark mode and high-contrast modes keep working.\n\n```css\n.filtri-personalizzati mds-filter {\n  --mds-filter-items-background: rgb(var(--magma-wash-strong));\n  --mds-filter-items-background-active: rgb(var(--magma-accent-surface));\n  --mds-filter-wrapper-shadow: 0 0 0 calc(var(--spacing) * 50) rgb(var(--magma-accent-border)) inset;\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-filter>`. 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 Slot Arbitrary Elements Instead of `mds-filter-item`\n\nThe default slot accepts only `<mds-filter-item>` elements. The parent wires its coordination logic - exclusive selection, scroll-centering, value aggregation - by querying for `mds-filter-item` children. Slotting plain buttons, spans, or any other element breaks all of that coordination.\n\n```html\n<!-- INCORRECT -->\n<mds-filter label=\"Tipo\">\n  <button>Notizie</button>\n  <button>Comunicati</button>\n</mds-filter>\n\n<!-- CORRECT -->\n<mds-filter label=\"Tipo\">\n  <mds-filter-item label=\"Notizie\" value=\"news\"></mds-filter-item>\n  <mds-filter-item label=\"Comunicati\" value=\"press\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Use `mds-filter-item` Outside `mds-filter`\n\n`<mds-filter-item>` communicates state upward via the `mdsFilterItemSelect` event, which `<mds-filter>` listens for internally. Used standalone, the item has no parent to coordinate selection, no auto-scroll, and no combined `mdsFilterChange` output.\n\n```html\n<!-- INCORRECT -->\n<div class=\"my-filter-bar\">\n  <mds-filter-item label=\"Tutti\" value=\"all\"></mds-filter-item>\n  <mds-filter-item label=\"Attivi\" value=\"active\"></mds-filter-item>\n</div>\n\n<!-- CORRECT -->\n<mds-filter>\n  <mds-filter-item label=\"Tutti\" value=\"all\"></mds-filter-item>\n  <mds-filter-item label=\"Attivi\" value=\"active\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Listen to Native `change` Instead of `mdsFilterChange`\n\n`<mds-filter>` emits the documented `mdsFilterChange` custom event. It contains no native form control, so no `change` or `input` event is ever fired; listening for them produces no result.\n\n```html\n<!-- INCORRECT -->\n<mds-filter id=\"f\" label=\"Stato\">\n  <mds-filter-item label=\"Aperto\" value=\"open\"></mds-filter-item>\n</mds-filter>\n<script>\n  document.getElementById('f').addEventListener('change', handler);\n</script>\n\n<!-- CORRECT -->\n<mds-filter id=\"f\" label=\"Stato\">\n  <mds-filter-item label=\"Aperto\" value=\"open\"></mds-filter-item>\n</mds-filter>\n<script>\n  document.getElementById('f').addEventListener('mdsFilterChange', handler);\n</script>\n```\n\n#### Do Not Set Boolean Props to the String `\"false\"`\n\n`auto-reset`, `multiple`, and `reset` are boolean attributes: remove the attribute entirely to deactivate it, as for every boolean. The runtime happens to read the string `\"false\"` as `false`, but the attribute stays in the markup until the component renders, and HTML, `[multiple]` selectors and `hasAttribute()` read a present attribute as set.\n\n```html\n<!-- INCORRECT -->\n<mds-filter multiple=\"false\" reset=\"false\" label=\"Tipo\">\n  <mds-filter-item label=\"Tutti\" value=\"all\"></mds-filter-item>\n</mds-filter>\n\n<!-- CORRECT -->\n<mds-filter label=\"Tipo\">\n  <mds-filter-item label=\"Tutti\" value=\"all\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Use `auto-reset` Without `multiple`\n\n`auto-reset` is meaningful only in `multiple` mode - it triggers when all items are simultaneously selected. In single-select mode only one item can ever be active, so the \"all selected\" condition is never reached and `auto-reset` has no effect.\n\n```html\n<!-- INCORRECT -->\n<mds-filter auto-reset label=\"Priorita\">\n  <mds-filter-item label=\"Alta\" value=\"high\"></mds-filter-item>\n  <mds-filter-item label=\"Bassa\" value=\"low\"></mds-filter-item>\n</mds-filter>\n\n<!-- CORRECT -->\n<mds-filter multiple auto-reset label=\"Priorita\">\n  <mds-filter-item label=\"Alta\" value=\"high\"></mds-filter-item>\n  <mds-filter-item label=\"Bassa\" value=\"low\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Omit `value` on `mds-filter-item`\n\nThe `mdsFilterChange` event's `value` field is a comma-joined string of the selected items' `value` attributes. Items without a `value` contribute an empty string to the output, making the combined value ambiguous and hard to parse in application code.\n\n```html\n<!-- INCORRECT -->\n<mds-filter label=\"Formato\">\n  <mds-filter-item label=\"PDF\"></mds-filter-item>\n  <mds-filter-item label=\"Word\"></mds-filter-item>\n</mds-filter>\n\n<!-- CORRECT -->\n<mds-filter label=\"Formato\">\n  <mds-filter-item label=\"PDF\" value=\"pdf\"></mds-filter-item>\n  <mds-filter-item label=\"Word\" value=\"doc\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Customize Via Undocumented Shadow Selectors\n\nThe supported customization surface for `<mds-filter>` is its public `--mds-filter-*` CSS custom properties. Piercing the shadow DOM via `>>>` or undocumented `::part()` names couples your code to the implementation and will break on minor releases.\n\n```css\n/* INCORRECT */\nmds-filter >>> .items {\n  background: white;\n}\nmds-filter::part(items-wrapper) {\n  border: 2px solid red;\n}\n\n/* CORRECT */\nmds-filter {\n  --mds-filter-items-background: rgb(var(--magma-wash-strong));\n  --mds-filter-wrapper-shadow: 0 0 0 calc(var(--spacing) * 50) rgb(var(--magma-accent-border)) inset;\n}\n```\n"
      },
      "props": [
        {
          "name": "autoReset",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "auto-reset",
          "reflectToAttr": true,
          "docs": "Sets an automatic reset of active filters if all filters are triggered",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "label",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "label",
          "reflectToAttr": false,
          "docs": "Sets the label of the filter group",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "multiple",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "multiple",
          "reflectToAttr": true,
          "docs": "Sets if the filter group can filter multiple filters simultaneously",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "reset",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "reset",
          "reflectToAttr": true,
          "docs": "Shows a reset button if one or more filters are active",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [
        {
          "event": "mdsFilterChange",
          "detail": "MdsFilterEventDetail",
          "bubbles": true,
          "complexType": {
            "original": "MdsFilterEventDetail",
            "resolved": "MdsFilterEventDetail",
            "references": {
              "MdsFilterEventDetail": {
                "location": "import",
                "path": "./meta/event-detail",
                "id": "src/components/mds-filter/meta/event-detail.ts::MdsFilterEventDetail",
                "referenceLocation": "MdsFilterEventDetail"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when the one of the children is changed",
          "docsTags": []
        }
      ],
      "listeners": [
        {
          "event": "mdsFilterItemSelect",
          "capture": false,
          "passive": false
        }
      ],
      "styles": [
        {
          "name": "--mds-filter-items-background",
          "annotation": "prop",
          "docs": "Sets the background-color of the items row area",
          "visibility": "public"
        },
        {
          "name": "--mds-filter-items-background-active",
          "annotation": "prop",
          "docs": "Sets the background-color of the items row area when a filter is active",
          "visibility": "public"
        },
        {
          "name": "--mds-filter-items-gap",
          "annotation": "prop",
          "docs": "Sets the gap between items",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-items-padding",
          "annotation": "prop",
          "docs": "Sets the padding of the items row area",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-items-radius",
          "annotation": "prop",
          "docs": "Sets the border-radius of the items row area",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-items-scroll-behavior",
          "annotation": "prop",
          "docs": "Sets the scroll-behavior animation;",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-label-gap",
          "annotation": "prop",
          "docs": "Sets the gap between the label and the items row area",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-label-padding",
          "annotation": "prop",
          "docs": "Sets the padding of the label",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-wrapper-shadow",
          "annotation": "prop",
          "docs": "Sets the shadow used as outline border",
          "visibility": "public"
        },
        {
          "name": "--mds-filter-wrapper-shadow-color",
          "annotation": "prop",
          "docs": "Sets the effect of the outline border",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-wrapper-shadow-opacity",
          "annotation": "prop",
          "docs": "Sets the opacity of the outline border",
          "visibility": "internal"
        }
      ],
      "slots": [
        {
          "name": "",
          "docs": "Add `mds-filter-item` element/s."
        }
      ],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-text",
        "mds-filter-item"
      ],
      "dependencyGraph": {
        "mds-filter": [
          "mds-text",
          "mds-filter-item"
        ],
        "mds-filter-item": [
          "mds-icon",
          "mds-text"
        ]
      },
      "storybook": "ui-filter--docs"
    }
  ]
}
