{
  "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-input-date-range-preselection/mds-input-date-range-preselection.tsx",
      "encapsulation": "shadow",
      "tag": "mds-input-date-range-preselection",
      "docs": "",
      "docsTags": [
        {
          "name": "slot",
          "text": "- Add the `text string` of the preselection, as `Last 7 days`: it becomes the label of\nthe button that applies the range. **Avoid** `HTML elements` or `components`, which end up\ninside an `mds-button`."
        },
        {
          "name": "parent",
          "text": "mds-input-date-range"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-input-date-range-preselection>` web component is a compound child of [`<mds-input-date-range>`](../mds-input-date-range/AGENTS.md). It renders a clickable shortcut button (a quick range like \"Last 7 days\" or \"This month\") that, when activated, fills the parent's date range with a predefined `start`/`end` pair instead of requiring the user to pick dates manually on the calendar.\n\n#### Semantic Behavior\n\n- **Compound child**: Placed as a direct child of `<mds-input-date-range>`, it assigns itself to the parent's `calendar-preselection` slot. A `slot` set by the author is kept, so it can also sit in the `preselection` slot of [`<mds-calendar>`](../mds-calendar/AGENTS.md): there it applies nothing itself, and its click reaches the page, which sets the range.\n- **Click drives the parent**: On click it applies its `start`/`end` range to the parent, which populates and validates the range, syncs the form value, emits the parent's `mdsInputDateRangeValueChange` if the range changed, and closes the dropdown after the parent's `delay` (unless it is `0`).\n- **Selection is parent-managed**: Choosing one preselection clears the active state on its siblings and marks the active one; the parent also re-marks a preselection as selected when the range changes to match its dates (including single-day matches where `end` is undefined); a range set at first load is not matched until it changes or the user leaves the component.\n\n#### Properties & Visual Configurations\n\n- **`start`** (required) and **`end`**: Define the ISO date range this shortcut applies. Provide both for a true range; omit `end` to express a single-day preselection.\n- **`selected`**: Reflects whether this preselection is currently the active one. Treat it as read-only in normal use - the parent sets it; do not hand-toggle it to drive selection.\n\nThe default slot holds the human-readable label. Visual states (default, hover, selected) follow the theme: the component has no public CSS custom property and does not expose `variant`/`tone` props of its own.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-input-date-range-preselection>` 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 Preset Range Shortcuts\n\nPlace one or more `<mds-input-date-range-preselection>` elements as direct children of [`<mds-input-date-range>`](../mds-input-date-range/AGENTS.md). Each element needs a `start` date (ISO format) and a human-readable label in its default slot. The component auto-assigns itself to the parent's `calendar-preselection` slot.\n\n```html\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n    Questo mese\n  </mds-input-date-range-preselection>\n  <mds-input-date-range-preselection start=\"2025-05-01\" end=\"2025-05-31\">\n    Mese scorso\n  </mds-input-date-range-preselection>\n  <mds-input-date-range-preselection start=\"2025-01-01\" end=\"2025-12-31\">\n    Anno corrente\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n```\n\n#### Single-Day Shortcut (omit `end`)\n\nOmit the `end` attribute to create a single-day preselection. The parent matches it as active whenever its current range is a single day equal to `start`.\n\n```html\n<mds-input-date-range name=\"data-singola\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-05\">\n    Oggi\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n```\n\n#### Multiple Preset Windows Together\n\nGroup semantically related shortcuts - short-term, medium-term, and long-term - so users can jump to the most common reporting windows without picking the dates on the calendar (the presets sit in the calendar dropdown, next to the calendar). Only one item carries `selected` at a time; the parent manages it automatically.\n\n```html\n<mds-input-date-range name=\"finestra-report\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-05-29\" end=\"2025-06-04\">\n    Ultima settimana\n  </mds-input-date-range-preselection>\n  <mds-input-date-range-preselection start=\"2025-05-01\" end=\"2025-05-31\">\n    Ultimo mese\n  </mds-input-date-range-preselection>\n  <mds-input-date-range-preselection start=\"2025-01-01\" end=\"2025-06-30\">\n    Ultimo semestre\n  </mds-input-date-range-preselection>\n  <mds-input-date-range-preselection start=\"2024-01-01\" end=\"2024-12-31\">\n    Anno precedente\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n```\n\n#### Reading the Selected Value via Parent Events\n\nListen to the parent's `mdsInputDateRangeValueChange` event to read the chosen range. The preselection component itself fires no event - the parent owns the value contract.\n\n```html\n<mds-input-date-range id=\"date-range\" name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n    Questo mese\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n\n<script>\n  document.getElementById('date-range').addEventListener('mdsInputDateRangeValueChange', (e) => {\n    console.log(e.detail.startDate, e.detail.endDate);\n  });\n</script>\n```\n\n#### Styling Customization\n\n`<mds-input-date-range-preselection>` has no public CSS custom property and no shadow part: it paints its three visual states - default, hover, and selected - from the semantic color roles ([`agents/color.md`](../../../../agents/color.md)), so dark mode and themes keep working without overrides. The parent marks the active shortcut with `selected`; do not restyle the states by hand.\n",
        "3. Mistakes": "Common incorrect uses of `<mds-input-date-range-preselection>`. 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-input-date-range>`\n\nThe component applies its range only as a direct child of [`<mds-input-date-range>`](../mds-input-date-range/AGENTS.md). Used standalone it renders a button that applies nothing: `closest('mds-input-date-range')` returns null, and the click only reaches the listeners of the page.\n\n```html\n<!-- INCORRECT -->\n<mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n  Questo mese\n</mds-input-date-range-preselection>\n\n<!-- CORRECT -->\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n    Questo mese\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n```\n\n#### Do Not Set `selected` Manually to Drive Selection\n\n`selected` is a read-only output attribute managed entirely by the parent. Setting it by hand does not apply the range, does not clear sibling active states, and will be overwritten by the parent on the next range change.\n\n```html\n<!-- INCORRECT -->\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\" selected>\n    Questo mese\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n\n<!-- CORRECT: set the range on the parent; it marks the matching preset when the range changes -->\n<mds-input-date-range name=\"periodo\" start-date=\"2025-06-01\" end-date=\"2025-06-30\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n    Questo mese\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n```\n\n#### Do Not Set `selected` as a Boolean String\n\n`selected` is a boolean attribute: remove it to deselect the item - but again, prefer letting the parent control it. A string value is fragile: `\"false\"` is read as `false` on this component, but the attribute stays on the element until the component renders (attribute selectors and scripts reading it see it set). Never write a boolean as a string.\n\n```html\n<!-- INCORRECT -->\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\" selected=\"false\">\n    Questo mese\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n\n<!-- CORRECT: remove the attribute entirely -->\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n    Questo mese\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n```\n\n#### Do Not Use HTML in the Default Slot\n\nThe default slot is the plain-text label read by the internal `<mds-button>`. Placing HTML elements inside it breaks button layout and may be stripped by the shadow DOM projection.\n\n```html\n<!-- INCORRECT -->\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n    <strong>Questo mese</strong>\n    <small>(giu)</small>\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n\n<!-- CORRECT -->\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n    Questo mese (giu)\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n```\n\n#### Do Not Provide Only the `end` Date Without `start`\n\n`start` is a required prop; omitting it leaves the component without a valid range anchor and the parent cannot apply any preselection. `end` is optional and meaningful only together with `start`.\n\n```html\n<!-- INCORRECT -->\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection end=\"2025-06-30\">\n    Fine mese\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n\n<!-- CORRECT -->\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n    Questo mese\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n```\n\n#### Do Not Customize via Undocumented Shadow Parts or Internal Selectors\n\nThe component has no public CSS custom property and no shadow part: its three visual states come from the semantic color roles and the `selected` state the parent sets. Targeting the inner `mds-button` or its shadow internals couples your code to implementation details that can change without notice.\n\n```css\n/* INCORRECT */\nmds-input-date-range-preselection .action {\n  background: blue;\n}\nmds-input-date-range-preselection::part(button) {\n  border-radius: 0;\n}\n```\n\n```html\n<!-- CORRECT: no override, the states follow the theme and the parent sets selected -->\n<mds-input-date-range name=\"periodo\">\n  <mds-input-date slot=\"start\"></mds-input-date>\n  <mds-input-date slot=\"end\"></mds-input-date>\n  <mds-input-date-range-preselection start=\"2025-06-01\" end=\"2025-06-30\">\n    Questo mese\n  </mds-input-date-range-preselection>\n</mds-input-date-range>\n```\n"
      },
      "props": [
        {
          "name": "end",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "end",
          "reflectToAttr": true,
          "docs": "Sets the end date of the preselection",
          "docsTags": [
            {
              "name": "description",
              "text": "It's in ISO format (YYYY-MM-DD)."
            },
            {
              "name": "example",
              "text": "'2025-06-30'"
            }
          ],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "selected",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": true,
          "attr": "selected",
          "reflectToAttr": true,
          "docs": "Sets the preselection date range",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "start",
          "type": "string",
          "complexType": {
            "original": "string",
            "resolved": "string",
            "references": {}
          },
          "mutable": false,
          "attr": "start",
          "reflectToAttr": true,
          "docs": "Sets the start date of the preselection",
          "docsTags": [
            {
              "name": "description",
              "text": "It's in ISO format (YYYY-MM-DD)."
            },
            {
              "name": "example",
              "text": "'2025-06-01'"
            }
          ],
          "values": [
            {
              "type": "string"
            }
          ],
          "optional": false,
          "required": true,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [],
      "listeners": [],
      "styles": [
        {
          "name": "--mds-date-range-preselection-default-background",
          "annotation": "prop",
          "docs": "Background used for the default (unselected) preselection state",
          "visibility": "internal"
        },
        {
          "name": "--mds-date-range-preselection-default-border",
          "annotation": "prop",
          "docs": "Border color used for the default preselection state",
          "visibility": "internal"
        },
        {
          "name": "--mds-date-range-preselection-default-color",
          "annotation": "prop",
          "docs": "Text color used in the default preselection state",
          "visibility": "internal"
        },
        {
          "name": "--mds-date-range-preselection-hover-background",
          "annotation": "prop",
          "docs": "Background used when a preselection item is hovered",
          "visibility": "internal"
        },
        {
          "name": "--mds-date-range-preselection-hover-border",
          "annotation": "prop",
          "docs": "Border color used on hover state",
          "visibility": "internal"
        },
        {
          "name": "--mds-date-range-preselection-hover-color",
          "annotation": "prop",
          "docs": "Text color used on hover state",
          "visibility": "internal"
        },
        {
          "name": "--mds-date-range-preselection-selected-background",
          "annotation": "prop",
          "docs": "Background used for the selected preselection state",
          "visibility": "internal"
        },
        {
          "name": "--mds-date-range-preselection-selected-border",
          "annotation": "prop",
          "docs": "Border color used for the selected preselection state",
          "visibility": "internal"
        },
        {
          "name": "--mds-date-range-preselection-selected-color",
          "annotation": "prop",
          "docs": "Text color used in the selected preselection state",
          "visibility": "internal"
        }
      ],
      "slots": [
        {
          "name": "",
          "docs": "Add the `text string` of the preselection, as `Last 7 days`: it becomes the label of\nthe button that applies the range. **Avoid** `HTML elements` or `components`, which end up\ninside an `mds-button`."
        }
      ],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-button"
      ],
      "dependencyGraph": {
        "mds-input-date-range-preselection": [
          "mds-button"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ]
      },
      "storybook": "form-input-date-range-preselection--docs"
    }
  ]
}
