{
  "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-upload/mds-input-upload.tsx",
      "encapsulation": "shadow",
      "tag": "mds-input-upload",
      "docs": "",
      "docsTags": [
        {
          "name": "category",
          "text": "forms"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-input-upload>` web component is the Magma Design System file-upload control. It wraps a hidden native `<input type=\"file\">` in a drag-and-drop drop zone with progress, per-file previews, validation and optional sorting, exposing the selected files to a surrounding `<form>` through form association.\n\n#### Semantic Behavior\n\n- **Form association**: Like a native `<input type=\"file\" multiple>`, the form submits every accepted file under `name`, one entry per file, in the order they were added; rejected files are not submitted, and without `name` nothing is. Post the form as `multipart/form-data` to send the file contents. A form reset clears every selected file.\n- **Disabled fieldset**: A disabled `<fieldset>` around the component disables it as `disabled` does, like a native control: no file can be added or removed and the files are left out of the form, until the fieldset is enabled.\n- **Validity reporting**: Per-file errors are reported as native validity flags - too many files, oversize, or wrong type - and the joined messages become the validation message.\n- **Drag-and-drop**: The drop zone reacts to drag events; on dragenter the prompt text swaps to a drag hint, restoring on dragleave or drop.\n- **Per-file validation**: Each added file is checked against `accept` (MIME, wildcard MIME, or extension), `maxFileSize`, and `maxFiles`; valid files render as success previews, invalid ones render as error previews with a localized message and are excluded from the form value.\n- **Change event**: `mdsInputUploadChange` fires with the current valid `FileList` (or `null`) on every add, cancel, or reset.\n- **Imperative API**: Exposes `getFiles()`, `getFilesError()`, and `reset()` methods for host-driven control.\n- **Localization**: All UI strings resolve against the host language (el / en / es / it).\n\n#### Properties & Visual Configurations\n\n- **`accept`** declares the allowed file types as a comma-separated list of MIME types, wildcard MIME types (e.g. `image/*`), or extensions; it both filters the native picker and drives the human-readable extension hint shown to the user.\n- **`maxFileSize`** caps the size of any single file in MB (default `20`); files above it are rejected with a size error.\n- **`maxFiles`** caps how many files may be uploaded (default `1`) and enables multi-file selection when greater than one.\n- **`disabled`** disables the component, like a disabled native file input: the picker and cancel buttons, the sort tabs and the delete action of the previews are disabled, a dropped file is refused, and the files are left out of the form. Code can still set the files through `initialValue` or clear them with `reset()`.\n- **`name`** is the name the accepted files are submitted under with the form.\n- **`initialValue`** seeds the control with files already present, before or after the first render; reassigning it re-runs the add pipeline.\n- **`sort`** controls whether the sort chooser is shown. When `sort` is set to `'date'` or `'status'`, the files start in that order and the sort tab bar appears once more than one file is present; the user's choice from the tab bar then stays in place as files are added, the highlighted tab is always the order applied, and the choice persists to `localStorage`. Changing `sort` applies the new order. When `sort` is omitted, no tab bar is shown and the last `localStorage` preference (defaulting to `'date'`) is applied silently.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-input-upload>` 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#### Single-File Upload (Default)\n\nThe simplest form. Without any attributes the drop zone accepts one file of any type up to 20 MB. Inside a `<form>` it submits the accepted files under its `name`, as a native file input does: post the form as `multipart/form-data` to send their contents.\n\n```html\n<form action=\"/upload\" method=\"post\" enctype=\"multipart/form-data\">\n  <mds-input-upload name=\"allegato\"></mds-input-upload>\n  <mds-button type=\"submit\" label=\"Invia\" variant=\"primary\" tone=\"strong\"></mds-button>\n</form>\n```\n\nTo send the form with your own code, `new FormData(form)` carries the files too.\n\n```html\n<form id=\"modulo-upload\" action=\"/upload\">\n  <mds-input-upload name=\"allegato\"></mds-input-upload>\n  <mds-button type=\"submit\" label=\"Invia\" variant=\"primary\" tone=\"strong\"></mds-button>\n</form>\n\n<script>\n  document.querySelector('#modulo-upload').addEventListener('submit', async (e) => {\n    e.preventDefault();\n    await fetch(e.target.action, { method: 'POST', body: new FormData(e.target) });\n  });\n</script>\n```\n\n#### Restricting Accepted File Types\n\nSet `accept` to a comma-separated list of MIME types, wildcard MIME types, or extensions. The native file picker and the per-file validator both respect the same value.\n\n```html\n<!-- Solo PDF -->\n<mds-input-upload accept=\".pdf\"></mds-input-upload>\n\n<!-- Immagini di qualsiasi formato -->\n<mds-input-upload accept=\"image/*\"></mds-input-upload>\n\n<!-- Mix di MIME esplicito ed estensione -->\n<mds-input-upload accept=\"application/pdf, image/jpeg, .png\"></mds-input-upload>\n```\n\n#### Limiting File Size\n\nSet `max-file-size` (in MB) to reject files above that threshold. Each oversized file is shown as an error preview with a localized message and excluded from the form value.\n\n```html\n<mds-input-upload accept=\"image/*\" max-file-size=\"5\"></mds-input-upload>\n```\n\n#### Multi-File Upload\n\nSet `max-files` to a number greater than one to enable multiple selection. The native picker switches to multi-select mode automatically; the progress bar tracks how many slots are filled. The form submits one `name` entry per accepted file.\n\n```html\n<mds-input-upload\n  name=\"allegati\"\n  accept=\".pdf, image/jpeg, image/png\"\n  max-file-size=\"70\"\n  max-files=\"3\"\n></mds-input-upload>\n```\n\n#### Seeding with Initial Files\n\nPass a `FileList` or `File[]` to `initialValue` to prepopulate the control - useful when editing an existing record that already has attachments. The files reach the previews, `getFiles()`, the form value and `mdsInputUploadChange` whether you assign them before or after the first render. Reassigning the prop re-runs the add pipeline, including validation.\n\n```html\n<mds-input-upload id=\"allegati\"></mds-input-upload>\n<script>\n  const upload = document.querySelector('#allegati');\n  // seed with files already loaded from the server as File objects\n  upload.initialValue = existingFiles;\n</script>\n```\n\n#### Listening for File Changes\n\nThe `mdsInputUploadChange` event fires with the current valid `FileList` (or `null`) on every add, remove, or reset. Use it to drive UI outside the component - for example to enable a submit button only when files are present.\n\n```html\n<mds-input-upload id=\"doc-upload\" accept=\".pdf\" max-files=\"5\"></mds-input-upload>\n<script>\n  document.querySelector('#doc-upload').addEventListener('mdsInputUploadChange', (e) => {\n    const files = e.detail;\n    console.log('File selezionati:', files ? files.length : 0);\n  });\n</script>\n```\n\n#### Programmatic Control via Methods\n\nUse the imperative API for host-driven workflows. `getFiles()` returns the accepted files (an empty `FileList` when there are none), `getFilesError()` returns any validation errors, and `reset()` clears all selections.\n\n```html\n<mds-input-upload id=\"upload-contratto\" accept=\".pdf\" max-file-size=\"10\"></mds-input-upload>\n<mds-button id=\"btn-verifica\" label=\"Verifica\"></mds-button>\n<mds-button id=\"btn-annulla\" label=\"Annulla\" tone=\"outline\"></mds-button>\n<script>\n  const upload = document.querySelector('#upload-contratto');\n\n  document.querySelector('#btn-verifica').addEventListener('click', async () => {\n    const errors = await upload.getFilesError();\n    if (errors) {\n      console.warn('Errori nei file:', errors);\n      return;\n    }\n    const files = await upload.getFiles();\n    console.log('Pronti per il caricamento:', files);\n  });\n\n  document.querySelector('#btn-annulla').addEventListener('click', () => {\n    upload.reset();\n  });\n</script>\n```\n\n#### Exposing the Sort Chooser\n\nSetting `sort` to `\"date\"` or `\"status\"` makes the sort tab bar visible once more than one file is present. The files start in the `sort` order; once the user picks another order from the tab bar, it stays in place as files are added, and the choice is persisted to `localStorage`. The highlighted tab is always the order applied. When `sort` is omitted, no tab bar is shown and the last `localStorage` preference is applied silently.\n\n```html\n<!-- Mostra il selettore di ordinamento, avviato su \"per data\" -->\n<mds-input-upload sort=\"date\" max-files=\"5\"></mds-input-upload>\n\n<!-- Mostra il selettore di ordinamento, avviato su \"per stato\" -->\n<mds-input-upload sort=\"status\" max-files=\"5\"></mds-input-upload>\n```\n\n#### Form Reset Behavior\n\nThe component is form-associated: a form reset clears every selected file automatically, without calling `reset()` explicitly.\n\n```html\n<form id=\"modulo-allegati\">\n  <mds-input-upload name=\"allegati\" accept=\".pdf\" max-files=\"3\"></mds-input-upload>\n  <mds-button type=\"submit\" label=\"Invia\" variant=\"primary\" tone=\"strong\"></mds-button>\n  <mds-button type=\"reset\" label=\"Cancella tutto\" variant=\"error\" tone=\"outline\"></mds-button>\n</form>\n```\n\n#### CSS Customization\n\nStyle the component only through its public `--mds-input-upload-min-cols` CSS custom property, the minimum number of columns of the file list. Set it on the host or a parent selector. The drag area takes its colours from the semantic color roles ([`agents/color.md`](../../../../agents/color.md)), so dark mode keeps working without overrides.\n\n```css\n.upload-area-evidenziata mds-input-upload {\n  --mds-input-upload-min-cols: 2;\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-input-upload>`. 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 Replace the Component with a Raw `<input type=\"file\">`\n\n`<input type=\"file\">` gives you no drag-drop, no per-file validation, no progress bar, and no consistent styling. Use `<mds-input-upload>` whenever a file upload is needed.\n\n```html\n<!-- INCORRECT -->\n<input type=\"file\" accept=\".pdf\" multiple>\n\n<!-- CORRECT -->\n<mds-input-upload accept=\".pdf\" max-files=\"5\"></mds-input-upload>\n```\n\n#### Do Not Listen to the Native `change` Event\n\nThe internal `<input type=\"file\">` lives inside shadow DOM; its native `change` event may not bubble out or may fire before internal validation completes. Always listen to the documented `mdsInputUploadChange` event instead.\n\n```html\n<!-- INCORRECT -->\n<mds-input-upload id=\"uploader\"></mds-input-upload>\n<script>\n  document.querySelector('#uploader').addEventListener('change', (e) => {\n    console.log(e.target.files); // undefined - input is in shadow DOM\n  });\n</script>\n\n<!-- CORRECT -->\n<mds-input-upload id=\"uploader\"></mds-input-upload>\n<script>\n  document.querySelector('#uploader').addEventListener('mdsInputUploadChange', (e) => {\n    console.log(e.detail); // valid FileList or null\n  });\n</script>\n```\n\n#### Do Not Append the Files to a `FormData` Built from the Form\n\nThe component already submits its accepted files under `name`: a `FormData` built from the form carries them, and appending them again sends every file twice. Give the component a `name` and let the form carry the files.\n\n```html\n<!-- INCORRECT - every file is sent twice -->\n<form id=\"modulo\">\n  <mds-input-upload name=\"allegati\" max-files=\"3\"></mds-input-upload>\n</form>\n<script type=\"module\">\n  const form = document.querySelector('#modulo');\n  const data = new FormData(form);\n  const files = await form.querySelector('mds-input-upload').getFiles();\n  Array.from(files).forEach((file) => data.append('allegati', file));\n</script>\n\n<!-- CORRECT -->\n<form id=\"modulo\">\n  <mds-input-upload name=\"allegati\" max-files=\"3\"></mds-input-upload>\n</form>\n<script type=\"module\">\n  const data = new FormData(document.querySelector('#modulo'));\n</script>\n```\n\n#### Do Not Reach into Shadow DOM for the Hidden Input\n\nThe hidden `<input type=\"file\">` is an implementation detail inside shadow DOM. Do not query it or read `.files` directly. Use the `getFiles()` method or listen to `mdsInputUploadChange`.\n\n```html\n<!-- INCORRECT -->\n<mds-input-upload id=\"upload\"></mds-input-upload>\n<script>\n  const input = document.querySelector('#upload').shadowRoot.querySelector('input[type=\"file\"]');\n  console.log(input.files); // fragile - implementation detail\n</script>\n\n<!-- CORRECT -->\n<mds-input-upload id=\"upload\"></mds-input-upload>\n<script type=\"module\">\n  const files = await document.querySelector('#upload').getFiles();\n  console.log(files);\n</script>\n```\n\n#### Do Not Omit `sort` When You Want the Sort Chooser Visible\n\nThe sort tab bar only appears when `sort` is explicitly set to `\"date\"` or `\"status\"` and more than one file is present. Omitting `sort` silently applies the user's last `localStorage` preference and hides the chooser. Set `sort` when you want users to be able to switch the order interactively.\n\n```html\n<!-- INCORRECT - sort chooser never appears because sort is omitted -->\n<mds-input-upload max-files=\"10\"></mds-input-upload>\n\n<!-- CORRECT - sort chooser appears once more than one file is added -->\n<mds-input-upload max-files=\"10\" sort=\"date\"></mds-input-upload>\n```\n\n#### Do Not Customize Through Undocumented Internal Selectors\n\nThe only supported customization surface is the public `--mds-input-upload-min-cols` CSS custom property. Do not target internal classes or parts not listed in the API.\n\n```css\n/* INCORRECT */\nmds-input-upload >>> .drag-area {\n  background: lightblue;\n}\nmds-input-upload .main-action {\n  display: none;\n}\n\n/* CORRECT */\nmds-input-upload {\n  --mds-input-upload-min-cols: 2;\n}\n```\n\n#### Do Not Use `initialValue` for Each New File Added by the User\n\n`initialValue` is for seeding the control once with pre-existing data - for example files already saved to a server. Every assignment re-runs the add pipeline, which emits `mdsInputUploadChange` again (files already accepted are skipped by name, so nothing is added): reassigning it from that event, as below, loops without end. Let the component manage user-selected files through its own UI.\n\n```html\n<!-- INCORRECT - misusing initialValue as a live file binding -->\n<mds-input-upload id=\"uploader\"></mds-input-upload>\n<script>\n  document.querySelector('#uploader').addEventListener('mdsInputUploadChange', (e) => {\n    document.querySelector('#uploader').initialValue = e.detail; // causes re-processing\n  });\n</script>\n\n<!-- CORRECT - just read the value when you need it -->\n<mds-input-upload id=\"uploader\"></mds-input-upload>\n<script>\n  document.querySelector('#uploader').addEventListener('mdsInputUploadChange', (e) => {\n    const files = e.detail; // use directly without re-assigning initialValue\n    console.log('File correnti:', files ? files.length : 0);\n  });\n</script>\n```\n"
      },
      "props": [
        {
          "name": "accept",
          "type": "string",
          "complexType": {
            "original": "string",
            "resolved": "string",
            "references": {}
          },
          "mutable": false,
          "attr": "accept",
          "reflectToAttr": true,
          "docs": "Defines the file types the file input should accept, as the accept attribute of a native\nfile input: MIME types (`image/*` included) and extensions, separated by commas",
          "docsTags": [
            {
              "name": "example",
              "text": "'.pdf,image/*'"
            },
            {
              "name": "default",
              "text": "''"
            }
          ],
          "default": "''",
          "values": [
            {
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "disabled",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "disabled",
          "reflectToAttr": true,
          "docs": "Disables the component, like a disabled native file input: no file can be added, dropped or\nremoved, and the files are left out of the form. A disabled `<fieldset>` around the component\ndoes the same.",
          "docsTags": [
            {
              "name": "default",
              "text": "false"
            }
          ],
          "default": "false",
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "initialValue",
          "type": "FileList | File[] | undefined",
          "complexType": {
            "original": "FileList | File[]",
            "resolved": "FileList | File[] | undefined",
            "references": {
              "FileList": {
                "location": "global",
                "id": "global::FileList"
              },
              "File": {
                "location": "global",
                "id": "global::File"
              }
            }
          },
          "mutable": false,
          "reflectToAttr": false,
          "docs": "Specifies initial files uploaded",
          "docsTags": [],
          "values": [
            {
              "type": "FileList"
            },
            {
              "type": "File[]"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "maxFileSize",
          "type": "number",
          "complexType": {
            "original": "number",
            "resolved": "number",
            "references": {}
          },
          "mutable": false,
          "attr": "max-file-size",
          "reflectToAttr": true,
          "docs": "Specifies the max size of a single file that can be uploaded in MB",
          "docsTags": [
            {
              "name": "default",
              "text": "20"
            }
          ],
          "default": "20",
          "values": [
            {
              "type": "number"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "maxFiles",
          "type": "number",
          "complexType": {
            "original": "number",
            "resolved": "number",
            "references": {}
          },
          "mutable": false,
          "attr": "max-files",
          "reflectToAttr": true,
          "docs": "Specifies the max number of files that can be uploaded",
          "docsTags": [
            {
              "name": "default",
              "text": "1"
            }
          ],
          "default": "1",
          "values": [
            {
              "type": "number"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "name",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "name",
          "reflectToAttr": true,
          "docs": "The name the accepted files are submitted under with the form, one entry per file",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "sort",
          "type": "\"date\" | \"status\" | undefined",
          "complexType": {
            "original": "AttachmentSort",
            "resolved": "\"date\" | \"status\" | undefined",
            "references": {
              "AttachmentSort": {
                "location": "import",
                "path": "./meta/types",
                "id": "src/components/mds-input-upload/meta/types.ts::AttachmentSort",
                "referenceLocation": "AttachmentSort"
              }
            }
          },
          "mutable": false,
          "attr": "sort",
          "reflectToAttr": true,
          "docs": "Specifies the order the files start sorted by, status or date of upload, and shows the sort tabs that let the user change it; if not defined the tabs are hidden and the order is the user's last choice",
          "docsTags": [],
          "values": [
            {
              "value": "date",
              "type": "string"
            },
            {
              "value": "status",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [
        {
          "name": "getFiles",
          "returns": {
            "type": "Promise<FileList | null>",
            "docs": ""
          },
          "complexType": {
            "signature": "() => Promise<FileList | null>",
            "parameters": [],
            "references": {
              "Promise": {
                "location": "global",
                "id": "global::Promise"
              },
              "FileList": {
                "location": "global",
                "id": "global::FileList"
              }
            },
            "return": "Promise<FileList | null>"
          },
          "signature": "getFiles() => Promise<FileList | null>",
          "parameters": [],
          "docs": "Returns a promise of the accepted files as a FileList, empty if there's none",
          "docsTags": []
        },
        {
          "name": "getFilesError",
          "returns": {
            "type": "Promise<FileError[] | null>",
            "docs": ""
          },
          "complexType": {
            "signature": "() => Promise<FileError[] | null>",
            "parameters": [],
            "references": {
              "Promise": {
                "location": "global",
                "id": "global::Promise"
              },
              "FileError": {
                "location": "import",
                "path": "./meta/types",
                "id": "src/components/mds-input-upload/meta/types.ts::FileError",
                "referenceLocation": "FileError"
              }
            },
            "return": "Promise<FileError[] | null>"
          },
          "signature": "getFilesError() => Promise<FileError[] | null>",
          "parameters": [],
          "docs": "Returns a promise of files error or null if there's none",
          "docsTags": []
        },
        {
          "name": "reset",
          "returns": {
            "type": "Promise<void>",
            "docs": ""
          },
          "complexType": {
            "signature": "() => Promise<void>",
            "parameters": [],
            "references": {
              "Promise": {
                "location": "global",
                "id": "global::Promise"
              }
            },
            "return": "Promise<void>"
          },
          "signature": "reset() => Promise<void>",
          "parameters": [],
          "docs": "Reset component's files",
          "docsTags": []
        }
      ],
      "events": [
        {
          "event": "mdsInputUploadChange",
          "detail": "FileList | null",
          "bubbles": true,
          "complexType": {
            "original": "FileList | null",
            "resolved": "FileList | null",
            "references": {
              "FileList": {
                "location": "global",
                "id": "global::FileList"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when the component files are changed",
          "docsTags": []
        }
      ],
      "listeners": [],
      "styles": [
        {
          "name": "--mds-input-upload-drag-area-background-color",
          "annotation": "prop",
          "docs": "Sets the background-color of the drag area.",
          "visibility": "internal"
        },
        {
          "name": "--mds-input-upload-drag-area-background-color-on-drag",
          "annotation": "prop",
          "docs": "Set the background color of the drag area when a file is dragged over it.",
          "visibility": "internal"
        },
        {
          "name": "--mds-input-upload-drag-area-border",
          "annotation": "prop",
          "docs": "Sets the border of the drag area.",
          "visibility": "internal"
        },
        {
          "name": "--mds-input-upload-drag-area-border-on-drag",
          "annotation": "prop",
          "docs": "Set the border of the drag area when a file is dragged over it.",
          "visibility": "internal"
        },
        {
          "name": "--mds-input-upload-min-cols",
          "annotation": "prop",
          "docs": "Set the minimum number of columns for the file list.",
          "visibility": "public"
        }
      ],
      "slots": [],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-icon",
        "mds-text",
        "mds-button",
        "mds-progress",
        "mds-tab",
        "mds-tab-item",
        "mds-file-preview"
      ],
      "dependencyGraph": {
        "mds-input-upload": [
          "mds-icon",
          "mds-text",
          "mds-button",
          "mds-progress",
          "mds-tab",
          "mds-tab-item",
          "mds-file-preview"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ],
        "mds-progress": [
          "mds-radial-progress"
        ],
        "mds-radial-progress": [
          "mds-icon",
          "mds-text"
        ],
        "mds-tab-item": [
          "mds-button"
        ],
        "mds-file-preview": [
          "mds-button",
          "mds-img",
          "mds-icon",
          "mds-text",
          "mds-badge"
        ],
        "mds-img": [
          "mds-icon",
          "mds-text",
          "mds-button"
        ],
        "mds-badge": [
          "mds-text"
        ]
      },
      "storybook": "form-input-upload--docs"
    }
  ]
}
