{
  "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-file/mds-file.tsx",
      "encapsulation": "shadow",
      "tag": "mds-file",
      "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": "content"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-file>` web component is the Magma Design System control for representing a downloadable file as a rich, clickable card. It pairs a filename with an auto-detected file-type icon, badge, and human-readable description, and tracks whether the file has already been downloaded.\n\n#### Semantic Behavior\n\n- **Clickable card**: The whole host is a button (`role=\"button\"`, unless you set another role) in the tab order: a click, Enter or Space emits `mdsFileDownload`; the component itself does not fetch or download - the consumer wires the actual download to that event.\n- **Download event payload**: `mdsFileDownload` carries `description` (the `description` prop, or else the description of the detected type in the page language, the text the card shows), `extension` (empty for a filename without one), `filename`, the host element as `target`, and the detected `type`/format.\n- **Downloaded persistence**: On click the component records the file as downloaded in `localStorage`, under a key derived from the filename with a small non-cryptographic hash. Every later render of the same filename on the same origin shows the \"done\" indicator.\n- **Automatic file-type recognition**: From `filename` it derives the format icon, badge variant, and default description; `suffix` overrides this detection.\n- **Localization**: Descriptions and the \"already downloaded\" tooltip are resolved against the active locale.\n\n#### Properties & Visual Configurations\n\n- **`filename`** is the primary input: it provides the displayed title and drives icon, badge, suffix, and description detection. The name and extension are rendered separately, split at the last dot so the dots inside the name are kept (`report.v2.final.docx` shows `report.v2.final` and `.docx`; a leading dot belongs to the name, as in `.env`); the extension is shown only when not explicitly overridden by `suffix`, and a filename without one shows no extension and no badge.\n- **`suffix`** forces a specific file type from the supported format set when the filename's extension is missing or wrong; it bypasses automatic recognition.\n- **`description`** overrides the derived, localized file-type description when a custom label is needed.\n- **`preview`** supplies an image URL (logo or thumbnail) rendered as the preview surface instead of the generic format icon - use it when a meaningful visual of the file exists.\n- **`hideDownloadedIcon`** (default `false`) suppresses the persisted \"already downloaded\" indicator; set it when that affordance is not appropriate.\n- **`format`** is normally populated by the component itself from detection rather than set by the consumer.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-file>` 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 File Card\n\nThe minimal form. Pass `filename` with a real filename (including extension) and the component auto-detects the format icon, badge color, and localized description.\n\n```html\n<mds-file filename=\"relazione-annuale.pdf\"></mds-file>\n```\n\n#### Handling the Download Event\n\nThe component does not fetch or download anything by itself. Listen for `mdsFileDownload` and trigger the actual download in the event handler. The event detail carries `filename`, `extension`, `type`, `description`, and `target`.\n\n```html\n<mds-file filename=\"contratto-servizio.docx\" id=\"file-card\"></mds-file>\n\n<script>\n  document.getElementById('file-card').addEventListener('mdsFileDownload', (event) => {\n    const { filename, extension, type } = event.detail;\n    console.log(`Download avviato: ${filename} (${type})`);\n    // avvia il download effettivo dal server\n  });\n</script>\n```\n\n#### Forcing a File Type with `suffix`\n\nWhen the filename lacks an extension or carries a misleading one, use `suffix` to force a specific format from the supported set.\n\n```html\n<!-- filename senza estensione - forza il riconoscimento come PDF -->\n<mds-file filename=\"documento-firmato\" suffix=\"pdf\"></mds-file>\n\n<!-- estensione sconosciuta - forzata come archivio ZIP -->\n<mds-file filename=\"backup.bkp\" suffix=\"zip\"></mds-file>\n```\n\n#### Custom Description\n\nOverride the localized auto-generated description with a specific label relevant to the document context. Use `description` when the default type label (e.g. \"Documento Adobe\" for a PDF) is not informative enough.\n\n```html\n<mds-file\n  filename=\"verbale-cda-2024.pdf\"\n  description=\"Verbale approvato dal Consiglio di Amministrazione\"\n></mds-file>\n```\n\n#### Image Preview\n\nProvide `preview` with an image URL when a meaningful visual thumbnail is available - a logo, a reduced version of an image file, or a document cover. The preview replaces the generic format icon in the left panel.\n\n```html\n<mds-file\n  filename=\"logo-aziendale.png\"\n  preview=\"https://cdn.example.com/thumbnails/logo-aziendale-128.png\"\n></mds-file>\n```\n\n#### Hiding the \"Already Downloaded\" Indicator\n\nThe component shows a \"done\" indicator once the file has been downloaded, on every later render of the same filename. Add `hide-downloaded-icon` to suppress it when the affordance is not appropriate for the context (e.g. a list where every file is always shown as fresh).\n\n```html\n<mds-file filename=\"modulo-richiesta.xlsx\" hide-downloaded-icon></mds-file>\n```\n\nNote: this is the only valid way to turn the indicator off. Magma 1 used `show-downloaded-icon=\"false\"`; that prop no longer exists (the codemod turns it into `hide-downloaded-icon`).\n\n#### Rendering a List of Files\n\nPlace multiple `<mds-file>` cards inside a container and attach a single delegated event listener when the file list is dynamic.\n\n```html\n<div class=\"file-list\">\n  <mds-file filename=\"allegato-1.pdf\"></mds-file>\n  <mds-file filename=\"allegato-2.docx\"></mds-file>\n  <mds-file filename=\"allegato-3.xlsx\"></mds-file>\n</div>\n\n<script>\n  document.querySelector('.file-list').addEventListener('mdsFileDownload', (event) => {\n    const { filename } = event.detail;\n    avviaDownload(filename);\n  });\n</script>\n```\n\n#### Styling Customization\n\nStyle the preview panel only through its public `--mds-file-preview-color` CSS custom property. Use the semantic color roles via `rgb(var(--magma-<role>))` so dark mode and high-contrast modes keep working.\n\n```css\n.archivio-documenti mds-file {\n  --mds-file-preview-color: rgb(var(--magma-accent-fg));\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-file>`. 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 Expect the Component to Perform the Download\n\n`<mds-file>` is a display card, not a download trigger: it has no `href`. It emits `mdsFileDownload` and the consumer must wire the actual download logic to that event.\n\n```html\n<!-- INCORRECT - expecting the component to handle the download itself -->\n<mds-file filename=\"report.pdf\" href=\"/files/report.pdf\"></mds-file>\n\n<!-- CORRECT - consumer listens to the event and handles the download -->\n<mds-file filename=\"report.pdf\" id=\"card-report\"></mds-file>\n\n<script>\n  document.getElementById('card-report').addEventListener('mdsFileDownload', (e) => {\n    window.location.href = '/files/' + e.detail.filename;\n  });\n</script>\n```\n\n#### Do Not Set `format` Manually\n\n`format` is an internal reflected attribute automatically derived from the filename and suffix. Setting it directly has no guaranteed effect because the component overwrites it during `componentWillLoad` and on every `filename` change. Use `suffix` to control type detection.\n\n```html\n<!-- INCORRECT -->\n<mds-file filename=\"archivio\" format=\"document\"></mds-file>\n\n<!-- CORRECT - use suffix to override file-type detection -->\n<mds-file filename=\"archivio\" suffix=\"pdf\"></mds-file>\n```\n\n#### Do Not Pierce Shadow DOM to Style the Preview Panel\n\nThe supported customization surface is the public `--mds-file-preview-color` CSS custom property. Targeting internal elements with `>>>`, `/deep/`, or undocumented selectors couples your code to the Shadow DOM structure and will break on minor releases.\n\n```css\n/* INCORRECT */\nmds-file >>> .preview {\n  background-color: blue;\n}\n\n/* CORRECT */\nmds-file {\n  --mds-file-preview-color: rgb(var(--magma-accent-fg));\n}\n```\n\n#### Do Not Wrap `<mds-file>` in a Native Anchor or Button\n\nThe host is already focusable (`tabindex=\"0\"`) and emits its own interaction event. Wrapping it in `<a>` or `<button>` creates nested interactive controls and breaks keyboard semantics.\n\n```html\n<!-- INCORRECT -->\n<a href=\"/download/report.pdf\">\n  <mds-file filename=\"report.pdf\"></mds-file>\n</a>\n\n<!-- CORRECT - use the mdsFileDownload event to trigger navigation or download -->\n<mds-file filename=\"report.pdf\" id=\"file-report\"></mds-file>\n\n<script>\n  document.getElementById('file-report').addEventListener('mdsFileDownload', () => {\n    window.location.href = '/download/report.pdf';\n  });\n</script>\n```\n\n#### Do Not Use a Raw `<div>` or `<li>` as a File Row When `<mds-file>` Exists\n\n`<mds-file>` handles format detection, theming, accessibility focus, download persistence, and localization. Rolling a custom file row loses all of these affordances.\n\n```html\n<!-- INCORRECT -->\n<div class=\"file-row\" onclick=\"download('report.pdf')\">\n  <img src=\"pdf-icon.svg\" alt=\"PDF\" />\n  <span>report.pdf</span>\n</div>\n\n<!-- CORRECT -->\n<mds-file filename=\"report.pdf\"></mds-file>\n```\n"
      },
      "props": [
        {
          "name": "description",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "description",
          "reflectToAttr": false,
          "docs": "Overrides the default filetype description",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "filename",
          "type": "string",
          "complexType": {
            "original": "string",
            "resolved": "string",
            "references": {}
          },
          "mutable": false,
          "attr": "filename",
          "reflectToAttr": false,
          "docs": "The filename shown as component title, is used to auto assign one of the filetype known in the filetype dictionary",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "format",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": true,
          "attr": "format",
          "reflectToAttr": true,
          "docs": "The kind of file, recognised from the extension of `filename` or from `suffix`: it selects\nthe colours of the icon. The component writes it on load and whenever `filename` changes,\nset `suffix` to choose it",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "hideDownloadedIcon",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "hide-downloaded-icon",
          "reflectToAttr": false,
          "docs": "Hides the download icon",
          "docsTags": [
            {
              "name": "default",
              "text": "false"
            }
          ],
          "default": "false",
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "preview",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "preview",
          "reflectToAttr": false,
          "docs": "The image preview src if available of a file, useful if you have a logo to display, or a smaller version of a bigger image",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "suffix",
          "type": "\"7z\" | \"ace\" | \"ai\" | \"db\" | \"default\" | \"dmg\" | \"doc\" | \"docm\" | \"docx\" | \"eml\" | \"eps\" | \"exe\" | \"flac\" | \"gif\" | \"heic\" | \"htm\" | \"html\" | \"jpe\" | \"jpeg\" | \"jpg\" | \"js\" | \"json\" | \"jsx\" | \"m2v\" | \"mp2\" | \"mp3\" | \"mp4\" | \"mp4v\" | \"mpeg\" | \"mpg\" | \"mpg4\" | \"mpga\" | \"odf\" | \"odp\" | \"ods\" | \"odt\" | \"ole\" | \"p7m\" | \"pdf\" | \"php\" | \"png\" | \"ppt\" | \"rar\" | \"rtf\" | \"sass\" | \"shtml\" | \"svg\" | \"tar\" | \"tiff\" | \"ts\" | \"tsd\" | \"txt\" | \"wav\" | \"webp\" | \"xar\" | \"xls\" | \"xlsx\" | \"xml\" | \"zip\" | undefined",
          "complexType": {
            "original": "ExtensionSuffixType",
            "resolved": "\"7z\" | \"ace\" | \"ai\" | \"db\" | \"default\" | \"dmg\" | \"doc\" | \"docm\" | \"docx\" | \"eml\" | \"eps\" | \"exe\" | \"flac\" | \"gif\" | \"heic\" | \"htm\" | \"html\" | \"jpe\" | \"jpeg\" | \"jpg\" | \"js\" | \"json\" | \"jsx\" | \"m2v\" | \"mp2\" | \"mp3\" | \"mp4\" | \"mp4v\" | \"mpeg\" | \"mpg\" | \"mpg4\" | \"mpga\" | \"odf\" | \"odp\" | \"ods\" | \"odt\" | \"ole\" | \"p7m\" | \"pdf\" | \"php\" | \"png\" | \"ppt\" | \"rar\" | \"rtf\" | \"sass\" | \"shtml\" | \"svg\" | \"tar\" | \"tiff\" | \"ts\" | \"tsd\" | \"txt\" | \"wav\" | \"webp\" | \"xar\" | \"xls\" | \"xlsx\" | \"xml\" | \"zip\" | undefined",
            "references": {
              "ExtensionSuffixType": {
                "location": "import",
                "path": "@type/file-types",
                "id": "src/type/file-types.ts::ExtensionSuffixType",
                "referenceLocation": "ExtensionSuffixType"
              }
            }
          },
          "mutable": false,
          "attr": "suffix",
          "reflectToAttr": true,
          "docs": "Overrides the automatic filetype recongition by forcing the suffix to one of the available formats choosen",
          "docsTags": [],
          "values": [
            {
              "value": "7z",
              "type": "string"
            },
            {
              "value": "ace",
              "type": "string"
            },
            {
              "value": "ai",
              "type": "string"
            },
            {
              "value": "db",
              "type": "string"
            },
            {
              "value": "default",
              "type": "string"
            },
            {
              "value": "dmg",
              "type": "string"
            },
            {
              "value": "doc",
              "type": "string"
            },
            {
              "value": "docm",
              "type": "string"
            },
            {
              "value": "docx",
              "type": "string"
            },
            {
              "value": "eml",
              "type": "string"
            },
            {
              "value": "eps",
              "type": "string"
            },
            {
              "value": "exe",
              "type": "string"
            },
            {
              "value": "flac",
              "type": "string"
            },
            {
              "value": "gif",
              "type": "string"
            },
            {
              "value": "heic",
              "type": "string"
            },
            {
              "value": "htm",
              "type": "string"
            },
            {
              "value": "html",
              "type": "string"
            },
            {
              "value": "jpe",
              "type": "string"
            },
            {
              "value": "jpeg",
              "type": "string"
            },
            {
              "value": "jpg",
              "type": "string"
            },
            {
              "value": "js",
              "type": "string"
            },
            {
              "value": "json",
              "type": "string"
            },
            {
              "value": "jsx",
              "type": "string"
            },
            {
              "value": "m2v",
              "type": "string"
            },
            {
              "value": "mp2",
              "type": "string"
            },
            {
              "value": "mp3",
              "type": "string"
            },
            {
              "value": "mp4",
              "type": "string"
            },
            {
              "value": "mp4v",
              "type": "string"
            },
            {
              "value": "mpeg",
              "type": "string"
            },
            {
              "value": "mpg",
              "type": "string"
            },
            {
              "value": "mpg4",
              "type": "string"
            },
            {
              "value": "mpga",
              "type": "string"
            },
            {
              "value": "odf",
              "type": "string"
            },
            {
              "value": "odp",
              "type": "string"
            },
            {
              "value": "ods",
              "type": "string"
            },
            {
              "value": "odt",
              "type": "string"
            },
            {
              "value": "ole",
              "type": "string"
            },
            {
              "value": "p7m",
              "type": "string"
            },
            {
              "value": "pdf",
              "type": "string"
            },
            {
              "value": "php",
              "type": "string"
            },
            {
              "value": "png",
              "type": "string"
            },
            {
              "value": "ppt",
              "type": "string"
            },
            {
              "value": "rar",
              "type": "string"
            },
            {
              "value": "rtf",
              "type": "string"
            },
            {
              "value": "sass",
              "type": "string"
            },
            {
              "value": "shtml",
              "type": "string"
            },
            {
              "value": "svg",
              "type": "string"
            },
            {
              "value": "tar",
              "type": "string"
            },
            {
              "value": "tiff",
              "type": "string"
            },
            {
              "value": "ts",
              "type": "string"
            },
            {
              "value": "tsd",
              "type": "string"
            },
            {
              "value": "txt",
              "type": "string"
            },
            {
              "value": "wav",
              "type": "string"
            },
            {
              "value": "webp",
              "type": "string"
            },
            {
              "value": "xar",
              "type": "string"
            },
            {
              "value": "xls",
              "type": "string"
            },
            {
              "value": "xlsx",
              "type": "string"
            },
            {
              "value": "xml",
              "type": "string"
            },
            {
              "value": "zip",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [
        {
          "event": "mdsFileDownload",
          "detail": "MdsFileEventDetail",
          "bubbles": true,
          "complexType": {
            "original": "MdsFileEventDetail",
            "resolved": "MdsFileEventDetail",
            "references": {
              "MdsFileEventDetail": {
                "location": "import",
                "path": "./meta/event-detail",
                "id": "src/components/mds-file/meta/event-detail.ts::MdsFileEventDetail",
                "referenceLocation": "MdsFileEventDetail"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when the component is clicked, returning file infos",
          "docsTags": []
        }
      ],
      "listeners": [],
      "styles": [
        {
          "name": "--mds-file-preview-color",
          "annotation": "prop",
          "docs": "Sets the text color used in the file preview",
          "visibility": "public"
        },
        {
          "name": "--mds-file-preview-icon-background",
          "annotation": "prop",
          "docs": "Sets the background color of the file preview icon",
          "visibility": "internal"
        },
        {
          "name": "--mds-file-preview-icon-color",
          "annotation": "prop",
          "docs": "Sets the color of the file preview icon",
          "visibility": "internal"
        }
      ],
      "slots": [],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-icon",
        "mds-text",
        "mds-badge"
      ],
      "dependencyGraph": {
        "mds-file": [
          "mds-icon",
          "mds-text",
          "mds-badge"
        ],
        "mds-badge": [
          "mds-text"
        ]
      },
      "storybook": "ui-file--docs"
    }
  ]
}
