{
  "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-paginator/mds-paginator.tsx",
      "encapsulation": "shadow",
      "tag": "mds-paginator",
      "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": "category",
          "text": "navigation"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-paginator>` web component is the page-navigation control of the Magma Design System. It renders a horizontal strip of numbered page items framed by previous/next arrows, replacing an ad-hoc set of links or buttons with a single self-managing control.\n\n#### Semantic Behavior\n\n- **Self-rendered children**: The paginator generates its own page items internally from `pages`; authors do not slot the items.\n- **Page change event**: Selecting a page (or an arrow) emits `mdsPaginatorChange` with a detail of `{ page, caller }`, where `caller` is the `mds-paginator-item` that triggered the change.\n- **Bounds clamping**: Navigation requests below `1` or above `pages` are ignored, so the arrows can never move past the valid range.\n- **Arrow disabling**: The back arrow is disabled on the first page and the forward arrow on the last page; a disabled arrow leaves the tab order.\n- **Arrow names**: The arrows are icon-only buttons, named in the page language (the `lang` of `<html>`): \"Previous page\" and \"Next page\".\n- **Auto-scroll into view**: When `pages` exceeds two, the strip scrolls so the active page is centered; selecting an item re-centers it, and so does focusing an item from the keyboard (tabbing through the pages). Pointer interaction never scrolls the strip before the click lands, so the clicked page is always the one selected. Scroll motion is themeable via `--mds-paginator-scroll-behavior`.\n- **Initial sync**: On load the component navigates to the provided `currentPage`, emitting the change event and scrolling the strip to match.\n\n#### Properties & Visual Configurations\n\n- **`pages`** is the total number of pages the control should represent and drives how many items are rendered; with `0` only the arrows appear.\n- **`currentPage`** marks which item is selected and which arrows are disabled; set it to control the paginator from outside, or read it back after a `mdsPaginatorChange` to follow user navigation.\n\nThis component does not use the shared `variant` / `tone` ladders defined in [`agents/variants.md`](../../../../agents/variants.md); its appearance is tuned only through the CSS custom properties documented in [`AGENTS.md`](AGENTS.md).\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-paginator>` 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 Paginator\n\nProvide `pages` with the total number of pages. The component renders all items and the previous/next arrows automatically. The `pages` prop is all that is required for a working paginator.\n\n```html\n<mds-paginator pages=\"20\"></mds-paginator>\n```\n\n#### Starting on a Specific Page\n\nSet `current-page` to pre-select an initial page. On load the component emits `mdsPaginatorChange` and scrolls the strip to center the active item.\n\n```html\n<mds-paginator pages=\"32\" current-page=\"16\"></mds-paginator>\n```\n\n#### Listening to Page Changes\n\nListen for `mdsPaginatorChange` to react to navigation. The event detail carries `{ page, caller }` where `page` is the newly selected page number and `caller` is the `mds-paginator-item` that triggered the change.\n\n```html\n<mds-paginator id=\"pager\" pages=\"10\"></mds-paginator>\n\n<script>\n  document.getElementById('pager').addEventListener('mdsPaginatorChange', (e) => {\n    const nuovaPagina = e.detail.page;\n    // Aggiorna la tabella o la lista con i dati della nuova pagina\n    caricaDati(nuovaPagina);\n  });\n</script>\n```\n\n#### Controlled Navigation from Outside\n\nWrite `current-page` programmatically to drive the paginator from application state - for example when a search resets pagination to page 1.\n\n```html\n<mds-paginator id=\"pager\" pages=\"15\" current-page=\"1\"></mds-paginator>\n\n<script>\n  function resettaPaginazione() {\n    document.getElementById('pager').currentPage = 1;\n  }\n</script>\n```\n\n#### Single-Page and Two-Page Edge Cases\n\nWhen `pages` is `1` only the first/last item and the arrows appear (the scrollable strip is omitted). When `pages` is `2` both the first and last items render without the strip. Both are valid states - pass the real page count without special-casing.\n\n```html\n<!-- Una sola pagina: solo gli arrow e la pagina 1 -->\n<mds-paginator pages=\"1\"></mds-paginator>\n\n<!-- Due pagine: pagina 1 e pagina 2, nessuna strip -->\n<mds-paginator pages=\"2\"></mds-paginator>\n```\n\n#### Styling the Page Strip Background\n\nOverride `--mds-paginator-background` on the host to change the background of the scrollable pages area. Use a Magma color token wrapped in `rgb(var(...))` so dark mode keeps working.\n\n```css\n.mia-tabella mds-paginator {\n  --mds-paginator-background: rgb(var(--magma-wash-strong));\n}\n```\n\n#### Disabling Scroll Animation\n\nSet `--mds-paginator-scroll-behavior` to `auto` to remove the animated scroll when jumping between pages - useful for contexts that already honour `prefers-reduced-motion` at application level.\n\n```css\n.stampa mds-paginator {\n  --mds-paginator-scroll-behavior: auto;\n}\n```\n\n#### Styling Individual Items\n\nThe items the paginator renders live in its shadow DOM and expose no shadow parts, but they inherit their public `--mds-paginator-item-*` CSS custom properties, documented on [`mds-paginator-item`](../mds-paginator-item/AGENTS.md): set them on the `mds-paginator` host (or a parent selector) to restyle every page item at once. Use the semantic color roles so dark mode keeps working.\n\n```css\n.archivio mds-paginator {\n  --mds-paginator-item-radius: var(--magma-radius-md);\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-paginator>`. 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 `mds-paginator-item` Manually\n\n`<mds-paginator>` generates all its child items from the `pages` prop and accepts no slots. Manually added `<mds-paginator-item>` children are never rendered, so they have no effect.\n\n```html\n<!-- INCORRECT -->\n<mds-paginator pages=\"5\">\n  <mds-paginator-item selected>3</mds-paginator-item>\n</mds-paginator>\n\n<!-- CORRECT -->\n<mds-paginator pages=\"5\" current-page=\"3\"></mds-paginator>\n```\n\n#### Do Not Use `mds-paginator-item` Outside `mds-paginator`\n\n`<mds-paginator-item>` is an internal sub-part. Its `disabled`, `selected`, and `icon` props are managed exclusively by the parent. Using it standalone produces controls that look like page items but do nothing: the page logic lives in the parent.\n\n```html\n<!-- INCORRECT -->\n<mds-paginator-item>1</mds-paginator-item>\n<mds-paginator-item selected>2</mds-paginator-item>\n\n<!-- CORRECT -->\n<mds-paginator pages=\"5\" current-page=\"2\"></mds-paginator>\n```\n\n#### Do Not Set `pages` to Zero to \"Hide\" the Paginator\n\nWhen `pages` is `0` only the two arrows render, which is visually incomplete and confusing. To conditionally hide the paginator, remove it from the DOM entirely or set `display: none` on the host.\n\n```html\n<!-- INCORRECT -->\n<mds-paginator pages=\"0\"></mds-paginator>\n\n<!-- CORRECT: create the paginator only when there are pages -->\n<div id=\"paginazione\"></div>\n<script>\n  if (totalePagine > 0) {\n    const pager = document.createElement('mds-paginator');\n    pager.pages = totalePagine;\n    document.getElementById('paginazione').append(pager);\n  }\n</script>\n```\n\n#### Do Not Listen for Native `click` to Detect Page Changes\n\nA native `click` bubbles out of the shadow DOM for any click on the control, but it carries no page number. Use the documented `mdsPaginatorChange` event instead, which carries the selected page number in `event.detail.page`.\n\n```html\n<!-- INCORRECT -->\n<mds-paginator id=\"pager\" pages=\"10\"></mds-paginator>\n<script>\n  document.getElementById('pager').addEventListener('click', (e) => {\n    // detail.page is undefined - this is the wrong event\n    console.log(e.detail?.page);\n  });\n</script>\n\n<!-- CORRECT -->\n<mds-paginator id=\"pager\" pages=\"10\"></mds-paginator>\n<script>\n  document.getElementById('pager').addEventListener('mdsPaginatorChange', (e) => {\n    console.log(e.detail.page);\n  });\n</script>\n```\n\n#### Do Not Pierce Shadow DOM to Style Items\n\nInternal `mds-paginator-item` elements live in shadow DOM. Targeting them with `>>>`, `/deep/`, or unrecognised `::part()` names breaks on any release. Use the documented `--mds-paginator-*` CSS custom properties on the host instead, the `--mds-paginator-item-*` ones included: the items inherit them.\n\n```css\n/* INCORRECT */\nmds-paginator >>> mds-paginator-item {\n  border-radius: 4px;\n}\n\n/* CORRECT */\nmds-paginator {\n  --mds-paginator-background: rgb(var(--magma-wash-strong));\n  --mds-paginator-item-radius: var(--magma-radius-sm);\n}\n```\n"
      },
      "props": [
        {
          "name": "currentPage",
          "type": "number",
          "complexType": {
            "original": "number",
            "resolved": "number",
            "references": {}
          },
          "mutable": true,
          "attr": "current-page",
          "reflectToAttr": true,
          "docs": "Specifies the current page selected in the paginator",
          "docsTags": [
            {
              "name": "default",
              "text": "1"
            }
          ],
          "default": "1",
          "values": [
            {
              "type": "number"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "pages",
          "type": "number",
          "complexType": {
            "original": "number",
            "resolved": "number",
            "references": {}
          },
          "mutable": false,
          "attr": "pages",
          "reflectToAttr": false,
          "docs": "Specifies the number of total pages to be handled",
          "docsTags": [
            {
              "name": "default",
              "text": "0"
            }
          ],
          "default": "0",
          "values": [
            {
              "type": "number"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [
        {
          "event": "mdsPaginatorChange",
          "detail": "MdsPaginatorEventDetail",
          "bubbles": true,
          "complexType": {
            "original": "MdsPaginatorEventDetail",
            "resolved": "MdsPaginatorEventDetail",
            "references": {
              "MdsPaginatorEventDetail": {
                "location": "import",
                "path": "./meta/event-detail",
                "id": "src/components/mds-paginator/meta/event-detail.ts::MdsPaginatorEventDetail",
                "referenceLocation": "MdsPaginatorEventDetail"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when a page is changed",
          "docsTags": []
        }
      ],
      "listeners": [],
      "styles": [
        {
          "name": "--mds-paginator-background",
          "annotation": "prop",
          "docs": "Sets the background-color of the pages area, behind the items",
          "visibility": "public"
        },
        {
          "name": "--mds-paginator-scroll-behavior",
          "annotation": "prop",
          "docs": "Sets the scroll-behavior animation",
          "visibility": "public"
        }
      ],
      "slots": [],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-paginator-item"
      ],
      "dependencyGraph": {
        "mds-paginator": [
          "mds-paginator-item"
        ],
        "mds-paginator-item": [
          "mds-icon",
          "mds-text"
        ]
      },
      "storybook": "ui-paginator--docs"
    }
  ]
}
