@nysds/nys-fileinput 1.15.0 → 1.16.0-alpha4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ import { ifDefined as m } from "lit/directives/if-defined.js";
6
6
  * █ █ █ █▄▄▄█ ▀▀▀▄▄ █ █ ▀▀▀▄▄
7
7
  * █ ▀█ █ █▄▄▄█ █▄▄▀ █▄▄▄█
8
8
  *
9
- * Fileinput Component
9
+ * Fileinput Component v1.16.0-alpha4
10
10
  * Part of the New York State Design System
11
11
  * Repository: https://github.com/its-hcd/nysds
12
12
  * License: MIT
@@ -191,7 +191,7 @@ const f = class f extends h {
191
191
  const e = this.shadowRoot?.querySelector("input");
192
192
  if (!e) return;
193
193
  const t = this.errorMessage || "Please upload a file.";
194
- this.required && this._selectedFiles.length == 0 ? (this._internals.ariaRequired = "true", this._internals.setValidity({ valueMissing: !0 }, t, e)) : (this._internals.ariaRequired = "false", this._internals.setValidity({}, "", e));
194
+ this.required && this._selectedFiles.length == 0 ? (this._internals.ariaInvalid = "true", this._internals.setValidity({ valueMissing: !0 }, t, e)) : (this._internals.ariaInvalid = "false", this._internals.setValidity({}, "", e));
195
195
  }
196
196
  _setValidityMessage(e = "") {
197
197
  const t = this.shadowRoot?.querySelector("input");
@@ -1 +1 @@
1
- {"version":3,"file":"nys-fileinput.js","sources":["../src/validateFileHeader.ts","../src/nys-fileitem.ts","../src/nys-fileinput.ts"],"sourcesContent":["// The main function for file validation based only on extension and `accept` attribute.\nexport async function validateFileHeader(\n file: File,\n accept: string,\n): Promise<boolean> {\n // 1) If no accept attribute is defined, assume anything is allowed\n if (!accept || accept.trim() === \"\") return true;\n\n // 2) Normalize and parse the accept attribute\n const acceptItems = accept\n .toLowerCase()\n .split(\",\")\n .map((a) => a.trim());\n\n // 3) Get the file extension\n const filename = file.name.toLowerCase();\n const fileExt = filename.includes(\".\") ? filename.split(\".\").pop()! : \"\";\n\n // 4) Check if extension matches any of the accept items\n for (const acceptItem of acceptItems) {\n // Direct extension match (e.g. \".pdf\")\n if (acceptItem.startsWith(\".\") && acceptItem.slice(1) === fileExt) {\n return true;\n }\n\n // Wildcard /* (e.g. \"image/*\") -> match common prefixes\n if (\n acceptItem.endsWith(\"/*\") &&\n file.type.startsWith(acceptItem.slice(0, -1))\n ) {\n return true;\n }\n\n // Exact MIME match\n if (file.type === acceptItem) {\n return true;\n }\n }\n\n // 5) Not matched\n return false;\n}\n","import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-fileitem.scss?inline\";\n\n/**\n * **Internal component.** Displays an individual file within `nys-fileinput` with status and progress.\n *\n * Rendered automatically by `nys-fileinput` for each selected file. Shows filename, upload status\n * (pending/processing/done/error), progress bar during upload, and error messages. Remove button emits event.\n *\n * @summary Internal file item display with status, progress bar, and remove action.\n * @element nys-fileitem\n *\n * @fires nys-fileRemove - Fired when remove button is clicked. Detail: `{filename}`.\n */\nexport class NysFileItem extends LitElement {\n static styles = unsafeCSS(styles);\n static shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** Name of the file being displayed. */\n @property({ type: String }) filename = \"\";\n\n /**\n * Upload status: `pending` (queued), `processing` (uploading), `done` (complete), `error` (failed).\n * @default \"pending\"\n */\n @property({ type: String }) status:\n | \"pending\"\n | \"processing\"\n | \"done\"\n | \"error\" = \"pending\";\n\n /** Upload progress percentage (0-100). Only shown when status is `processing`. */\n @property({ type: Number }) progress = 0;\n\n /** Error message displayed when status is `error`. */\n @property({ type: String }) errorMessage = \"\";\n\n private _handleRemove() {\n this.dispatchEvent(\n new CustomEvent(\"nys-fileRemove\", {\n detail: { filename: this.filename },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private splitFilename(filename: string) {\n const lastDotIndex = filename.lastIndexOf(\".\");\n const extension = lastDotIndex !== -1 ? filename.slice(lastDotIndex) : \"\"; // e.g. \".pdf\"\n const name =\n lastDotIndex !== -1 ? filename.slice(0, lastDotIndex) : filename;\n\n const startPart = name.slice(0, name.length - 3);\n const endPart = name.slice(-3);\n\n return { startPart, endPart, extension };\n }\n\n render() {\n const { startPart, endPart, extension } = this.splitFilename(this.filename);\n\n return html`\n <div\n class=\"file-item ${this.status}\"\n aria-busy=${this.status === \"processing\" ? \"true\" : \"false\"}\n aria-label=\"You have selected ${this.filename}\"\n >\n <div class=\"file-item__main\" role=\"group\">\n <nys-icon\n class=\"file-icon\"\n name=${this.status === \"processing\"\n ? \"progress_activity\"\n : this.status === \"error\"\n ? \"error\"\n : \"attach_file\"}\n size=\"2xl\"\n ></nys-icon>\n <div class=\"file-item__info\">\n <div class=\"file-item__info-name\">\n <span class=\"file-item__info-name-start\">${startPart}</span>\n <span class=\"file-item__info-name-end\"\n >${endPart}${extension}</span\n >\n </div>\n ${this.errorMessage\n ? html`<p\n class=\"file-item__error\"\n role=\"alert\"\n aria-live=\"assertive\"\n aria-invalid=\"true\"\n aria-errormessage=${this.errorMessage}\n id=\"${this.filename}-error\"\n >\n ${this.errorMessage}\n </p>`\n : null}\n </div>\n <nys-button\n circle\n icon=\"close\"\n ariaLabel=\"close button\"\n size=\"sm\"\n variant=\"ghost\"\n @nys-click=${this._handleRemove}\n ariaLabel=\"Remove file: ${this.filename}\"\n ></nys-button>\n </div>\n ${this.status === \"processing\"\n ? html`<div\n class=\"file-item__progress-container\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n aria-valuenow=\"${this.progress}\"\n aria-label=\"Upload progress for ${this.filename}\"\n >\n <progress value=${this.progress} max=\"100\"></progress>\n </div>`\n : null}\n </div>\n `;\n }\n}\n\ncustomElements.define(\"nys-fileitem\", NysFileItem);\n","import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { validateFileHeader } from \"./validateFileHeader\";\nimport \"./nys-fileitem\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-fileinput.scss?inline\";\n\nlet fileinputIdCounter = 0;\n\ninterface FileWithProgress {\n file: File;\n progress: number;\n status: \"pending\" | \"processing\" | \"done\" | \"error\";\n errorMsg?: string;\n}\n\n/**\n * A file input for uploading files with support for multiple files, drag-and-drop, and progress tracking.\n * Validates file types via magic bytes (not just extension). Form-associated via ElementInternals.\n *\n * Use for document uploads, image uploads, or any file submission. Enable `dropzone` for drag-and-drop UI.\n *\n * @summary File input with drag-and-drop, validation, and progress tracking.\n * @element nys-fileinput\n *\n * @slot description - Custom HTML description content.\n *\n * @fires nys-change - Fired when files are added or removed. Detail: `{id, files}`.\n *\n * @example Single file upload\n * ```html\n * <nys-fileinput label=\"Upload document\" accept=\".pdf,.doc\" required></nys-fileinput>\n * ```\n *\n * @example Multiple files with dropzone\n * ```html\n * <nys-fileinput label=\"Upload images\" accept=\"image/*\" multiple dropzone></nys-fileinput>\n * ```\n */\n\nexport class NysFileinput extends LitElement {\n static styles = unsafeCSS(styles);\n static shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** Unique identifier. Auto-generated if not provided. */\n @property({ type: String, reflect: true }) id = \"\";\n\n /** Name for form submission. */\n @property({ type: String, reflect: true }) name = \"\";\n\n /** Visible label text. */\n @property({ type: String }) label = \"\";\n\n /** Helper text below label. Use slot for custom HTML. */\n @property({ type: String }) description = \"\";\n\n /** Allows selecting multiple files. */\n @property({ type: Boolean }) multiple = false;\n\n /** Form `id` to associate with. */\n @property({ type: String, reflect: true }) form: string | null = null;\n\n /** Tooltip text shown on hover/focus of info icon. */\n @property({ type: String }) tooltip = \"\";\n\n /** Accepted file types. Use MIME types (`image/*`) or extensions (`.pdf`). Validated via magic bytes. */\n @property({ type: String }) accept = \"\";\n\n /** Prevents interaction. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Requires at least one file to be uploaded. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Shows \"Optional\" flag. */\n @property({ type: Boolean, reflect: true }) optional = false;\n\n /** Shows error message when true. */\n @property({ type: Boolean, reflect: true }) showError = false;\n\n /** Error message text. Shown only when `showError` is true. */\n @property({ type: String }) errorMessage = \"\";\n\n /** Enables drag-and-drop zone UI. */\n @property({ type: Boolean }) dropzone = false;\n\n /**\n * Component width: `lg` (384px) or `full` (100%, default).\n * @default \"full\"\n */\n @property({ type: String, reflect: true }) width: \"lg\" | \"full\" = \"full\";\n\n /** Adjusts colors for dark backgrounds. */\n @property({ type: Boolean, reflect: true }) inverted = false;\n\n private _selectedFiles: FileWithProgress[] = [];\n private _dragActive = false;\n private get _isDropDisabled(): boolean {\n return this.disabled || (!this.multiple && this._selectedFiles.length > 0);\n }\n\n private get _buttonAriaLabel(): string {\n if (this._selectedFiles.length === 0) {\n return this.multiple ? \"Choose files: \" : \"Choose file: \";\n }\n\n return this.multiple ? \"Change files: \" : \"Change file: \";\n }\n\n private get _buttonAriaDescription(): string {\n if (this._selectedFiles.length === 0)\n return `${this.label + \" \" + this.description}`;\n\n const hasInvalidFiles = this._selectedFiles.some(\n (file) => file.status === \"error\",\n );\n\n let base = \"\";\n\n if (this._selectedFiles.length === 1) {\n base = `You have selected ${this._selectedFiles[0].file.name}.`;\n } else {\n const fileNames = this._selectedFiles.map((f) => f.file.name).join(\", \");\n base = `You have selected ${this._selectedFiles.length} files: ${fileNames}`;\n }\n\n const error = hasInvalidFiles\n ? \" Error: One or more files are not valid file types.\"\n : \"\";\n\n return `${base}${error}`;\n }\n\n private get _innerNysButton(): HTMLElement | null {\n const nysButton = this.renderRoot.querySelector(\n '[name=\"file-btn\"]',\n ) as HTMLButtonElement | null;\n const innerButton = nysButton?.shadowRoot?.querySelector(\n \"button\",\n ) as HTMLElement | null;\n return innerButton;\n }\n\n private _internals: ElementInternals;\n\n /**\n * Lifecycle methods\n * --------------------------------------------------------------------------\n */\n\n static formAssociated = true; // allows use of elementInternals' API\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n }\n\n // Generate a unique ID if one is not provided\n connectedCallback() {\n super.connectedCallback();\n if (!this.id) {\n this.id = `nys-fileinput-${Date.now()}-${fileinputIdCounter++}`;\n }\n\n this.addEventListener(\"invalid\", this._handleInvalid);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener(\"invalid\", this._handleInvalid);\n }\n\n firstUpdated() {\n // This ensures our element always participates in the form\n this._setValue();\n }\n\n /**\n * Form Integration\n * --------------------------------------------------------------------------\n */\n private _setValue() {\n // for multiple file uploads, we upload File object as an array\n if (this.multiple) {\n const files = this._selectedFiles.map((entry) => entry.file);\n\n if (files.length > 0) {\n const formData = new FormData();\n files.forEach((file) => {\n formData.append(this.name, file);\n });\n this._internals.setFormValue(formData);\n } else {\n this._internals.setFormValue(null);\n }\n } else {\n const singleFile = this._selectedFiles[0]?.file || null;\n this._internals.setFormValue(singleFile);\n }\n\n this._manageRequire(); // Check validation when value is set\n }\n\n // Called to internally set the initial internalElement required flag.\n private _manageRequire() {\n const input = this.shadowRoot?.querySelector(\"input\");\n if (!input) return;\n\n const message = this.errorMessage || \"Please upload a file.\";\n const isInvalid = this.required && this._selectedFiles.length == 0;\n\n if (isInvalid) {\n this._internals.ariaRequired = \"true\"; // Screen readers should announce error\n this._internals.setValidity({ valueMissing: true }, message, input);\n } else {\n this._internals.ariaRequired = \"false\"; // Reset when valid\n this._internals.setValidity({}, \"\", input);\n }\n }\n\n private _setValidityMessage(message: string = \"\") {\n const input = this.shadowRoot?.querySelector(\"input\");\n if (!input) return;\n\n // Toggle the HTML <div> tag error message\n this.showError = message === (this.errorMessage || \"Please upload a file.\");\n\n // If user sets errorMessage, this will always override the native validation message\n if (this.errorMessage?.trim() && message !== \"\") {\n message = this.errorMessage;\n }\n\n this._internals.setValidity(\n message ? { customError: true } : {},\n message,\n input,\n );\n }\n\n private _validate() {\n const hasErrorFiles = this._selectedFiles.some(\n (entry) => entry.status === \"error\",\n );\n const isEmpty = this.required && this._selectedFiles.length === 0;\n\n let message = \"\";\n if (isEmpty) {\n message = this.errorMessage || \"Please upload a file.\";\n } else if (hasErrorFiles) {\n message = \"One or more files are invalid.\";\n }\n\n this._setValidityMessage(message);\n }\n\n // This helper function is called to perform the element's native validation.\n checkValidity(): boolean {\n const input = this.shadowRoot?.querySelector(\"input\");\n return input ? input.checkValidity() : true;\n }\n\n // Called automatically when the parent form is reset\n public formResetCallback() {\n this._selectedFiles = [];\n const input = this.shadowRoot?.querySelector(\n \".hidden-file-input\",\n ) as HTMLInputElement | null;\n\n if (input) {\n input.value = \"\";\n }\n\n this._internals.setFormValue(null);\n\n // Reset validation UI\n this.showError = false;\n this.errorMessage = \"\";\n this._internals.setValidity({});\n\n // Re-render UI\n this.requestUpdate();\n }\n\n private _handleInvalid(event: Event) {\n event.preventDefault();\n this._validate();\n\n const innerButton = this._innerNysButton;\n if (innerButton) {\n // Focus only if this is the first invalid element (top-down approach)\n const form = this._internals.form;\n if (form) {\n const elements = Array.from(form.elements) as Array<\n HTMLElement & { checkValidity?: () => boolean }\n >;\n // Find the first element in the form that is invalid\n const firstInvalidElement = elements.find(\n (element) =>\n typeof element.checkValidity === \"function\" &&\n !element.checkValidity(),\n );\n if (firstInvalidElement === this) {\n innerButton.focus();\n innerButton.classList.add(\"active-focus\"); // This class styling is found within <nys-button>\n }\n } else {\n // If not part of a form, simply focus.\n innerButton.focus();\n innerButton.classList.add(\"active-focus\"); // This class styling is found within <nys-button>\n }\n }\n }\n\n /**\n * Functions\n * --------------------------------------------------------------------------\n */\n\n // Store the files to be displayed\n private async _saveSelectedFiles(file: File) {\n const isDuplicate = this._selectedFiles.some(\n (existingFile) => existingFile.file.name == file.name,\n );\n if (isDuplicate) return;\n\n if (!this.multiple && this._selectedFiles.length >= 1) return;\n\n const entry: FileWithProgress = {\n file,\n progress: 0,\n status: \"pending\",\n };\n\n this._selectedFiles.push(entry);\n await this._processFile(entry);\n\n // Now that the file is added, update form value and validation\n this._setValue();\n this._validate();\n }\n\n // Read the contents of stored files, this will indicate loading progress of the uploaded files\n private async _processFile(entry: FileWithProgress) {\n entry.status = \"processing\";\n\n try {\n const isValid = await validateFileHeader(entry.file, this.accept);\n if (!isValid) {\n entry.status = \"error\";\n entry.errorMsg = \"File type is invalid.\";\n this.requestUpdate();\n return;\n }\n\n const reader = new FileReader();\n\n reader.onprogress = (e) => {\n if (e.lengthComputable) {\n const percentage = Math.round((e.loaded * 100) / e.total);\n entry.progress = percentage;\n this.requestUpdate();\n }\n };\n\n reader.onload = () => {\n entry.progress = 100;\n entry.status = \"done\";\n this.requestUpdate();\n };\n\n reader.onerror = () => {\n entry.status = \"error\";\n entry.errorMsg = \"Failed to load file.\";\n this.requestUpdate();\n };\n\n reader.readAsArrayBuffer(entry.file);\n } catch {\n entry.status = \"error\";\n entry.errorMsg = \"Error validating file.\";\n this.requestUpdate();\n }\n }\n\n private _dispatchChangeEvent() {\n this.dispatchEvent(\n new CustomEvent(\"nys-change\", {\n detail: { id: this.id, files: this._selectedFiles },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _openFileDialog() {\n const input = this.renderRoot.querySelector(\n \".hidden-file-input\",\n ) as HTMLInputElement;\n\n input?.click();\n }\n\n private _handlePostFileSelectionFocus() {\n if (this.multiple) {\n const innerButton = this._innerNysButton;\n\n if (innerButton) {\n innerButton.focus();\n }\n } else {\n this._focusFirstFileItemIfSingleMode();\n }\n }\n\n private async _focusFirstFileItemIfSingleMode() {\n if (!this.multiple) {\n await this.updateComplete;\n const fileItem = this.renderRoot.querySelector(\n \"nys-fileitem\",\n ) as HTMLElement;\n\n const innerFileItemMainContainer = fileItem?.shadowRoot?.querySelector(\n \".file-item\",\n ) as HTMLElement | null;\n\n if (innerFileItemMainContainer) {\n innerFileItemMainContainer.setAttribute(\"tabindex\", \"-1\");\n innerFileItemMainContainer.focus();\n }\n }\n }\n\n /**\n * Event Handlers\n * --------------------------------------------------------------------------\n */\n\n // Access the selected files & add new files to the internal list via the hidden <input type=\"file\">\n private _handleFileChange(e: Event) {\n const input = e.target as HTMLInputElement;\n const files = input.files;\n const newFiles = files ? Array.from(files) : []; // changes FileList to array\n\n // Store the uploaded files\n newFiles.map((file) => {\n this._saveSelectedFiles(file);\n });\n\n this.requestUpdate();\n this._dispatchChangeEvent();\n this._handlePostFileSelectionFocus();\n }\n\n private _handleFileRemove(e: CustomEvent) {\n const filenameToRemove = e.detail.filename;\n\n // Remove selected files\n this._selectedFiles = this._selectedFiles.filter(\n (existingFile) => existingFile.file.name !== filenameToRemove,\n );\n\n if (this._selectedFiles.length === 0) {\n const input = this.shadowRoot?.querySelector(\n \"input\",\n ) as HTMLInputElement | null;\n if (input) input.value = \"\";\n }\n\n this._setValue();\n this._validate();\n\n this.requestUpdate();\n this._dispatchChangeEvent();\n }\n\n private _onDragOver(e: DragEvent) {\n if (this.disabled) return;\n\n e.stopPropagation();\n e.preventDefault();\n if (!this._dragActive) {\n this._dragActive = true; // For styling purpose\n this.requestUpdate();\n }\n }\n\n // Mostly used for styling purpose\n private _onDragLeave(e: DragEvent) {\n if (this.disabled) return;\n\n e.stopPropagation();\n e.preventDefault();\n // Only reset if leaving the dropzone itself (not children)\n if (e.currentTarget === e.target) {\n this._dragActive = false; // For styling purpose\n this.requestUpdate();\n }\n }\n\n private _onDrop(e: DragEvent) {\n if (this.disabled) return;\n\n e.preventDefault();\n this._dragActive = false; // For styling purpose\n this.requestUpdate();\n\n const files = e.dataTransfer?.files;\n if (!files) return;\n\n const newFiles = Array.from(files);\n\n if (this.multiple) {\n newFiles.forEach((file) => {\n this._saveSelectedFiles(file);\n });\n } else {\n this._saveSelectedFiles(newFiles[0]);\n }\n\n this.requestUpdate();\n this._dispatchChangeEvent();\n }\n\n render() {\n return html`<div\n class=\"nys-fileinput\"\n @nys-fileRemove=${this._handleFileRemove}\n >\n <nys-label\n for=${this.id}\n label=${this.label}\n description=${this.description}\n flag=${this.required ? \"required\" : this.optional ? \"optional\" : \"\"}\n tooltip=${this.tooltip}\n ?inverted=${this.inverted}\n >\n <slot name=\"description\" slot=\"description\">${this.description}</slot>\n </nys-label>\n\n <input\n id=${this.id}\n class=\"hidden-file-input\"\n tabindex=\"-1\"\n type=\"file\"\n name=${this.name}\n accept=${this.accept}\n form=${ifDefined(this.form || undefined)}\n ?multiple=${this.multiple}\n ?required=${this.required}\n ?disabled=${this.disabled ||\n (!this.multiple && this._selectedFiles.length > 0)}\n aria-disabled=\"${this.disabled}\"\n aria-hidden=\"true\"\n @change=${this._handleFileChange}\n hidden\n />\n\n ${!this.dropzone\n ? html`<nys-button\n id=\"choose-files-btn\"\n name=\"file-btn\"\n label=${this.multiple ? \"Choose files\" : \"Choose file\"}\n variant=\"outline\"\n ariaLabel=${this._buttonAriaLabel}\n ariaDescription=${this._buttonAriaDescription}\n ?disabled=${this.disabled ||\n (!this.multiple && this._selectedFiles.length > 0)}\n @nys-click=${this._openFileDialog}\n ></nys-button>`\n : html`<div\n class=\"nys-fileinput__dropzone\n ${this._dragActive ? \"drag-active\" : \"\"}\n ${this._isDropDisabled ? \"disabled\" : \"\"}\n ${this.showError && !this._isDropDisabled ? \"error\" : \"\"}\"\n @click=${this._isDropDisabled\n ? null\n : (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n\n // Ignore clicks that originated within a nys-button\n if (target.closest(\"nys-button\")) return;\n\n // Only handle direct wrapper clicks (outside of buttons)\n this._openFileDialog();\n }}\n @dragover=${this._isDropDisabled ? null : this._onDragOver}\n @dragleave=${this._isDropDisabled ? null : this._onDragLeave}\n @drop=${this._isDropDisabled ? null : this._onDrop}\n aria-label=\"Drag files here or choose from folder\"\n >\n ${this._dragActive\n ? html`<p>Drop file to upload</p>`\n : html` <nys-button\n id=\"choose-files-btn-drag\"\n name=\"file-btn\"\n label=${this.multiple ? \"Choose files\" : \"Choose file\"}\n variant=\"outline\"\n ariaLabel=${this._buttonAriaLabel}\n ariaDescription=${this._buttonAriaDescription}\n ?disabled=${this._isDropDisabled}\n @nys-click=\"${(e: CustomEvent) => {\n e.preventDefault();\n e.stopPropagation();\n this._openFileDialog();\n }}\"\n ></nys-button>\n <p>or drag here</p>`}\n </div>`}\n ${this.showError\n ? html`\n <nys-errormessage\n ?showError=${this.showError}\n errorMessage=${this._internals.validationMessage ||\n this.errorMessage}\n ></nys-errormessage>\n `\n : null}\n ${this._selectedFiles.length > 0\n ? html`\n <ul>\n ${this._selectedFiles.map(\n (entry) =>\n html`<li>\n <nys-fileitem\n filename=${entry.file.name}\n status=${entry.status}\n progress=${entry.progress}\n errorMessage=${entry.errorMsg || \"\"}\n ></nys-fileitem>\n </li>`,\n )}\n </ul>\n `\n : null}\n </div>`;\n }\n}\n\nif (!customElements.get(\"nys-fileinput\")) {\n customElements.define(\"nys-fileinput\", NysFileinput);\n}\n"],"names":["LitElement","unsafeCSS","html","property","ifDefined","validateFileHeader","file","accept","acceptItems","a","filename","fileExt","acceptItem","_NysFileItem","lastDotIndex","extension","name","startPart","endPart","styles","NysFileItem","__decorateClass","fileinputIdCounter","_NysFileinput","hasInvalidFiles","base","fileNames","f","files","entry","formData","singleFile","input","message","hasErrorFiles","isEmpty","event","innerButton","form","element","existingFile","reader","e","percentage","innerFileItemMainContainer","filenameToRemove","newFiles","NysFileinput"],"mappings":"AACA,SAAA,cAAAA,GAAA,aAAAC,GAAA,QAAAC,SAAA;AAAA,SAAA,YAAAC,SAAA;AAAA,SAAA,aAAAC,SAAA;;;;;;;;;;;AAAA,eAAsBC,EACpBC,GACAC,GACkB;AAElB,MAAI,CAACA,KAAUA,EAAO,KAAA,MAAW,GAAI,QAAO;AAG5C,QAAMC,IAAcD,EACjB,YAAA,EACA,MAAM,GAAG,EACT,IAAI,CAACE,MAAMA,EAAE,KAAA,CAAM,GAGhBC,IAAWJ,EAAK,KAAK,YAAA,GACrBK,IAAUD,EAAS,SAAS,GAAG,IAAIA,EAAS,MAAM,GAAG,EAAE,IAAA,IAAS;AAGtE,aAAWE,KAAcJ;AAevB,QAbII,EAAW,WAAW,GA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iB,WAAA,SAAA;AAGA1B,EAAA;AAAA,EAA3BlB,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA7Bf4C,EA6BiB,WAAA,QAAA;AAGgB1B,EAAA;AAAA,EAA3ClB,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAhC/B4C,EAgCiC,WAAA,UAAA;AAGA1B,EAAA;AAAA,EAA3ClB,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAnC/B4C,EAmCiC,WAAA,UAAA;AAGA1B,EAAA;AAAA,EAA3ClB,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAtC/B4C,EAsCiC,WAAA,UAAA;AAGA1B,EAAA;AAAA,EAA3ClB,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAzC/B4C,EAyCiC,WAAA,WAAA;AAGhB1B,EAAA;AAAA,EAA3BlB,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA5Cf4C,EA4CiB,WAAA,cAAA;AAGC1B,EAAA;AAAA,EAA5BlB,EAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GA/ChB4C,EA+CkB,WAAA,UAAA;AAMc1B,EAAA;AAAA,EAA1ClB,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GArD9B4C,EAqDgC,WAAA,OAAA;AAGC1B,EAAA;AAAA,EAA3ClB,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAxD/B4C,EAwDiC,WAAA,UAAA;AAiiBzC,eAAe,IAAI,eAAe,KACrC,eAAe,OAAO,iBAAiBA,CAAY;"}
1
+ {"version":3,"file":"nys-fileinput.js","sources":["../src/validateFileHeader.ts","../src/nys-fileitem.ts","../src/nys-fileinput.ts"],"sourcesContent":["// The main function for file validation based only on extension and `accept` attribute.\nexport async function validateFileHeader(\n file: File,\n accept: string,\n): Promise<boolean> {\n // 1) If no accept attribute is defined, assume anything is allowed\n if (!accept || accept.trim() === \"\") return true;\n\n // 2) Normalize and parse the accept attribute\n const acceptItems = accept\n .toLowerCase()\n .split(\",\")\n .map((a) => a.trim());\n\n // 3) Get the file extension\n const filename = file.name.toLowerCase();\n const fileExt = filename.includes(\".\") ? filename.split(\".\").pop()! : \"\";\n\n // 4) Check if extension matches any of the accept items\n for (const acceptItem of acceptItems) {\n // Direct extension match (e.g. \".pdf\")\n if (acceptItem.startsWith(\".\") && acceptItem.slice(1) === fileExt) {\n return true;\n }\n\n // Wildcard /* (e.g. \"image/*\") -> match common prefixes\n if (\n acceptItem.endsWith(\"/*\") &&\n file.type.startsWith(acceptItem.slice(0, -1))\n ) {\n return true;\n }\n\n // Exact MIME match\n if (file.type === acceptItem) {\n return true;\n }\n }\n\n // 5) Not matched\n return false;\n}\n","import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-fileitem.scss?inline\";\n\n/**\n * **Internal component.** Displays an individual file within `nys-fileinput` with status and progress.\n *\n * Rendered automatically by `nys-fileinput` for each selected file. Shows filename, upload status\n * (pending/processing/done/error), progress bar during upload, and error messages. Remove button emits event.\n *\n * @summary Internal file item display with status, progress bar, and remove action.\n * @element nys-fileitem\n *\n * @fires nys-fileRemove - Fired when remove button is clicked. Detail: `{filename}`.\n */\nexport class NysFileItem extends LitElement {\n static styles = unsafeCSS(styles);\n static shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** Name of the file being displayed. */\n @property({ type: String }) filename = \"\";\n\n /**\n * Upload status: `pending` (queued), `processing` (uploading), `done` (complete), `error` (failed).\n * @default \"pending\"\n */\n @property({ type: String }) status:\n | \"pending\"\n | \"processing\"\n | \"done\"\n | \"error\" = \"pending\";\n\n /** Upload progress percentage (0-100). Only shown when status is `processing`. */\n @property({ type: Number }) progress = 0;\n\n /** Error message displayed when status is `error`. */\n @property({ type: String }) errorMessage = \"\";\n\n private _handleRemove() {\n this.dispatchEvent(\n new CustomEvent(\"nys-fileRemove\", {\n detail: { filename: this.filename },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private splitFilename(filename: string) {\n const lastDotIndex = filename.lastIndexOf(\".\");\n const extension = lastDotIndex !== -1 ? filename.slice(lastDotIndex) : \"\"; // e.g. \".pdf\"\n const name =\n lastDotIndex !== -1 ? filename.slice(0, lastDotIndex) : filename;\n\n const startPart = name.slice(0, name.length - 3);\n const endPart = name.slice(-3);\n\n return { startPart, endPart, extension };\n }\n\n render() {\n const { startPart, endPart, extension } = this.splitFilename(this.filename);\n\n return html`\n <div\n class=\"file-item ${this.status}\"\n aria-busy=${this.status === \"processing\" ? \"true\" : \"false\"}\n aria-label=\"You have selected ${this.filename}\"\n >\n <div class=\"file-item__main\" role=\"group\">\n <nys-icon\n class=\"file-icon\"\n name=${this.status === \"processing\"\n ? \"progress_activity\"\n : this.status === \"error\"\n ? \"error\"\n : \"attach_file\"}\n size=\"2xl\"\n ></nys-icon>\n <div class=\"file-item__info\">\n <div class=\"file-item__info-name\">\n <span class=\"file-item__info-name-start\">${startPart}</span>\n <span class=\"file-item__info-name-end\"\n >${endPart}${extension}</span\n >\n </div>\n ${this.errorMessage\n ? html`<p\n class=\"file-item__error\"\n role=\"alert\"\n aria-live=\"assertive\"\n aria-invalid=\"true\"\n aria-errormessage=${this.errorMessage}\n id=\"${this.filename}-error\"\n >\n ${this.errorMessage}\n </p>`\n : null}\n </div>\n <nys-button\n circle\n icon=\"close\"\n ariaLabel=\"close button\"\n size=\"sm\"\n variant=\"ghost\"\n @nys-click=${this._handleRemove}\n ariaLabel=\"Remove file: ${this.filename}\"\n ></nys-button>\n </div>\n ${this.status === \"processing\"\n ? html`<div\n class=\"file-item__progress-container\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n aria-valuenow=\"${this.progress}\"\n aria-label=\"Upload progress for ${this.filename}\"\n >\n <progress value=${this.progress} max=\"100\"></progress>\n </div>`\n : null}\n </div>\n `;\n }\n}\n\ncustomElements.define(\"nys-fileitem\", NysFileItem);\n","import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { validateFileHeader } from \"./validateFileHeader\";\nimport \"./nys-fileitem\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-fileinput.scss?inline\";\n\nlet fileinputIdCounter = 0;\n\ninterface FileWithProgress {\n file: File;\n progress: number;\n status: \"pending\" | \"processing\" | \"done\" | \"error\";\n errorMsg?: string;\n}\n\n/**\n * A file input for uploading files with support for multiple files, drag-and-drop, and progress tracking.\n * Validates file types via magic bytes (not just extension). Form-associated via ElementInternals.\n *\n * Use for document uploads, image uploads, or any file submission. Enable `dropzone` for drag-and-drop UI.\n *\n * @summary File input with drag-and-drop, validation, and progress tracking.\n * @element nys-fileinput\n *\n * @slot description - Custom HTML description content.\n *\n * @fires nys-change - Fired when files are added or removed. Detail: `{id, files}`.\n *\n * @example Single file upload\n * ```html\n * <nys-fileinput label=\"Upload document\" accept=\".pdf,.doc\" required></nys-fileinput>\n * ```\n *\n * @example Multiple files with dropzone\n * ```html\n * <nys-fileinput label=\"Upload images\" accept=\"image/*\" multiple dropzone></nys-fileinput>\n * ```\n */\n\nexport class NysFileinput extends LitElement {\n static styles = unsafeCSS(styles);\n static shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** Unique identifier. Auto-generated if not provided. */\n @property({ type: String, reflect: true }) id = \"\";\n\n /** Name for form submission. */\n @property({ type: String, reflect: true }) name = \"\";\n\n /** Visible label text. */\n @property({ type: String }) label = \"\";\n\n /** Helper text below label. Use slot for custom HTML. */\n @property({ type: String }) description = \"\";\n\n /** Allows selecting multiple files. */\n @property({ type: Boolean }) multiple = false;\n\n /** Form `id` to associate with. */\n @property({ type: String, reflect: true }) form: string | null = null;\n\n /** Tooltip text shown on hover/focus of info icon. */\n @property({ type: String }) tooltip = \"\";\n\n /** Accepted file types. Use MIME types (`image/*`) or extensions (`.pdf`). Validated via magic bytes. */\n @property({ type: String }) accept = \"\";\n\n /** Prevents interaction. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Requires at least one file to be uploaded. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Shows \"Optional\" flag. */\n @property({ type: Boolean, reflect: true }) optional = false;\n\n /** Shows error message when true. */\n @property({ type: Boolean, reflect: true }) showError = false;\n\n /** Error message text. Shown only when `showError` is true. */\n @property({ type: String }) errorMessage = \"\";\n\n /** Enables drag-and-drop zone UI. */\n @property({ type: Boolean }) dropzone = false;\n\n /**\n * Component width: `lg` (384px) or `full` (100%, default).\n * @default \"full\"\n */\n @property({ type: String, reflect: true }) width: \"lg\" | \"full\" = \"full\";\n\n /** Adjusts colors for dark backgrounds. */\n @property({ type: Boolean, reflect: true }) inverted = false;\n\n private _selectedFiles: FileWithProgress[] = [];\n private _dragActive = false;\n private get _isDropDisabled(): boolean {\n return this.disabled || (!this.multiple && this._selectedFiles.length > 0);\n }\n\n private get _buttonAriaLabel(): string {\n if (this._selectedFiles.length === 0) {\n return this.multiple ? \"Choose files: \" : \"Choose file: \";\n }\n\n return this.multiple ? \"Change files: \" : \"Change file: \";\n }\n\n private get _buttonAriaDescription(): string {\n if (this._selectedFiles.length === 0)\n return `${this.label + \" \" + this.description}`;\n\n const hasInvalidFiles = this._selectedFiles.some(\n (file) => file.status === \"error\",\n );\n\n let base = \"\";\n\n if (this._selectedFiles.length === 1) {\n base = `You have selected ${this._selectedFiles[0].file.name}.`;\n } else {\n const fileNames = this._selectedFiles.map((f) => f.file.name).join(\", \");\n base = `You have selected ${this._selectedFiles.length} files: ${fileNames}`;\n }\n\n const error = hasInvalidFiles\n ? \" Error: One or more files are not valid file types.\"\n : \"\";\n\n return `${base}${error}`;\n }\n\n private get _innerNysButton(): HTMLElement | null {\n const nysButton = this.renderRoot.querySelector(\n '[name=\"file-btn\"]',\n ) as HTMLButtonElement | null;\n const innerButton = nysButton?.shadowRoot?.querySelector(\n \"button\",\n ) as HTMLElement | null;\n return innerButton;\n }\n\n private _internals: ElementInternals;\n\n /**\n * Lifecycle methods\n * --------------------------------------------------------------------------\n */\n\n static formAssociated = true; // allows use of elementInternals' API\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n }\n\n // Generate a unique ID if one is not provided\n connectedCallback() {\n super.connectedCallback();\n if (!this.id) {\n this.id = `nys-fileinput-${Date.now()}-${fileinputIdCounter++}`;\n }\n\n this.addEventListener(\"invalid\", this._handleInvalid);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener(\"invalid\", this._handleInvalid);\n }\n\n firstUpdated() {\n // This ensures our element always participates in the form\n this._setValue();\n }\n\n /**\n * Form Integration\n * --------------------------------------------------------------------------\n */\n private _setValue() {\n // for multiple file uploads, we upload File object as an array\n if (this.multiple) {\n const files = this._selectedFiles.map((entry) => entry.file);\n\n if (files.length > 0) {\n const formData = new FormData();\n files.forEach((file) => {\n formData.append(this.name, file);\n });\n this._internals.setFormValue(formData);\n } else {\n this._internals.setFormValue(null);\n }\n } else {\n const singleFile = this._selectedFiles[0]?.file || null;\n this._internals.setFormValue(singleFile);\n }\n\n this._manageRequire(); // Check validation when value is set\n }\n\n // Called to internally set the initial internalElement required flag.\n private _manageRequire() {\n const input = this.shadowRoot?.querySelector(\"input\");\n if (!input) return;\n\n const message = this.errorMessage || \"Please upload a file.\";\n const isInvalid = this.required && this._selectedFiles.length == 0;\n\n if (isInvalid) {\n this._internals.ariaInvalid = \"true\"; // Screen readers should announce error\n this._internals.setValidity({ valueMissing: true }, message, input);\n } else {\n this._internals.ariaInvalid = \"false\"; // Reset when valid\n this._internals.setValidity({}, \"\", input);\n }\n }\n\n private _setValidityMessage(message: string = \"\") {\n const input = this.shadowRoot?.querySelector(\"input\");\n if (!input) return;\n\n // Toggle the HTML <div> tag error message\n this.showError = message === (this.errorMessage || \"Please upload a file.\");\n\n // If user sets errorMessage, this will always override the native validation message\n if (this.errorMessage?.trim() && message !== \"\") {\n message = this.errorMessage;\n }\n\n this._internals.setValidity(\n message ? { customError: true } : {},\n message,\n input,\n );\n }\n\n private _validate() {\n const hasErrorFiles = this._selectedFiles.some(\n (entry) => entry.status === \"error\",\n );\n const isEmpty = this.required && this._selectedFiles.length === 0;\n\n let message = \"\";\n if (isEmpty) {\n message = this.errorMessage || \"Please upload a file.\";\n } else if (hasErrorFiles) {\n message = \"One or more files are invalid.\";\n }\n\n this._setValidityMessage(message);\n }\n\n // This helper function is called to perform the element's native validation.\n checkValidity(): boolean {\n const input = this.shadowRoot?.querySelector(\"input\");\n return input ? input.checkValidity() : true;\n }\n\n // Called automatically when the parent form is reset\n public formResetCallback() {\n this._selectedFiles = [];\n const input = this.shadowRoot?.querySelector(\n \".hidden-file-input\",\n ) as HTMLInputElement | null;\n\n if (input) {\n input.value = \"\";\n }\n\n this._internals.setFormValue(null);\n\n // Reset validation UI\n this.showError = false;\n this.errorMessage = \"\";\n this._internals.setValidity({});\n\n // Re-render UI\n this.requestUpdate();\n }\n\n private _handleInvalid(event: Event) {\n event.preventDefault();\n this._validate();\n\n const innerButton = this._innerNysButton;\n if (innerButton) {\n // Focus only if this is the first invalid element (top-down approach)\n const form = this._internals.form;\n if (form) {\n const elements = Array.from(form.elements) as Array<\n HTMLElement & { checkValidity?: () => boolean }\n >;\n // Find the first element in the form that is invalid\n const firstInvalidElement = elements.find(\n (element) =>\n typeof element.checkValidity === \"function\" &&\n !element.checkValidity(),\n );\n if (firstInvalidElement === this) {\n innerButton.focus();\n innerButton.classList.add(\"active-focus\"); // This class styling is found within <nys-button>\n }\n } else {\n // If not part of a form, simply focus.\n innerButton.focus();\n innerButton.classList.add(\"active-focus\"); // This class styling is found within <nys-button>\n }\n }\n }\n\n /**\n * Functions\n * --------------------------------------------------------------------------\n */\n\n // Store the files to be displayed\n private async _saveSelectedFiles(file: File) {\n const isDuplicate = this._selectedFiles.some(\n (existingFile) => existingFile.file.name == file.name,\n );\n if (isDuplicate) return;\n\n if (!this.multiple && this._selectedFiles.length >= 1) return;\n\n const entry: FileWithProgress = {\n file,\n progress: 0,\n status: \"pending\",\n };\n\n this._selectedFiles.push(entry);\n await this._processFile(entry);\n\n // Now that the file is added, update form value and validation\n this._setValue();\n this._validate();\n }\n\n // Read the contents of stored files, this will indicate loading progress of the uploaded files\n private async _processFile(entry: FileWithProgress) {\n entry.status = \"processing\";\n\n try {\n const isValid = await validateFileHeader(entry.file, this.accept);\n if (!isValid) {\n entry.status = \"error\";\n entry.errorMsg = \"File type is invalid.\";\n this.requestUpdate();\n return;\n }\n\n const reader = new FileReader();\n\n reader.onprogress = (e) => {\n if (e.lengthComputable) {\n const percentage = Math.round((e.loaded * 100) / e.total);\n entry.progress = percentage;\n this.requestUpdate();\n }\n };\n\n reader.onload = () => {\n entry.progress = 100;\n entry.status = \"done\";\n this.requestUpdate();\n };\n\n reader.onerror = () => {\n entry.status = \"error\";\n entry.errorMsg = \"Failed to load file.\";\n this.requestUpdate();\n };\n\n reader.readAsArrayBuffer(entry.file);\n } catch {\n entry.status = \"error\";\n entry.errorMsg = \"Error validating file.\";\n this.requestUpdate();\n }\n }\n\n private _dispatchChangeEvent() {\n this.dispatchEvent(\n new CustomEvent(\"nys-change\", {\n detail: { id: this.id, files: this._selectedFiles },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _openFileDialog() {\n const input = this.renderRoot.querySelector(\n \".hidden-file-input\",\n ) as HTMLInputElement;\n\n input?.click();\n }\n\n private _handlePostFileSelectionFocus() {\n if (this.multiple) {\n const innerButton = this._innerNysButton;\n\n if (innerButton) {\n innerButton.focus();\n }\n } else {\n this._focusFirstFileItemIfSingleMode();\n }\n }\n\n private async _focusFirstFileItemIfSingleMode() {\n if (!this.multiple) {\n await this.updateComplete;\n const fileItem = this.renderRoot.querySelector(\n \"nys-fileitem\",\n ) as HTMLElement;\n\n const innerFileItemMainContainer = fileItem?.shadowRoot?.querySelector(\n \".file-item\",\n ) as HTMLElement | null;\n\n if (innerFileItemMainContainer) {\n innerFileItemMainContainer.setAttribute(\"tabindex\", \"-1\");\n innerFileItemMainContainer.focus();\n }\n }\n }\n\n /**\n * Event Handlers\n * --------------------------------------------------------------------------\n */\n\n // Access the selected files & add new files to the internal list via the hidden <input type=\"file\">\n private _handleFileChange(e: Event) {\n const input = e.target as HTMLInputElement;\n const files = input.files;\n const newFiles = files ? Array.from(files) : []; // changes FileList to array\n\n // Store the uploaded files\n newFiles.map((file) => {\n this._saveSelectedFiles(file);\n });\n\n this.requestUpdate();\n this._dispatchChangeEvent();\n this._handlePostFileSelectionFocus();\n }\n\n private _handleFileRemove(e: CustomEvent) {\n const filenameToRemove = e.detail.filename;\n\n // Remove selected files\n this._selectedFiles = this._selectedFiles.filter(\n (existingFile) => existingFile.file.name !== filenameToRemove,\n );\n\n if (this._selectedFiles.length === 0) {\n const input = this.shadowRoot?.querySelector(\n \"input\",\n ) as HTMLInputElement | null;\n if (input) input.value = \"\";\n }\n\n this._setValue();\n this._validate();\n\n this.requestUpdate();\n this._dispatchChangeEvent();\n }\n\n private _onDragOver(e: DragEvent) {\n if (this.disabled) return;\n\n e.stopPropagation();\n e.preventDefault();\n if (!this._dragActive) {\n this._dragActive = true; // For styling purpose\n this.requestUpdate();\n }\n }\n\n // Mostly used for styling purpose\n private _onDragLeave(e: DragEvent) {\n if (this.disabled) return;\n\n e.stopPropagation();\n e.preventDefault();\n // Only reset if leaving the dropzone itself (not children)\n if (e.currentTarget === e.target) {\n this._dragActive = false; // For styling purpose\n this.requestUpdate();\n }\n }\n\n private _onDrop(e: DragEvent) {\n if (this.disabled) return;\n\n e.preventDefault();\n this._dragActive = false; // For styling purpose\n this.requestUpdate();\n\n const files = e.dataTransfer?.files;\n if (!files) return;\n\n const newFiles = Array.from(files);\n\n if (this.multiple) {\n newFiles.forEach((file) => {\n this._saveSelectedFiles(file);\n });\n } else {\n this._saveSelectedFiles(newFiles[0]);\n }\n\n this.requestUpdate();\n this._dispatchChangeEvent();\n }\n\n render() {\n return html`<div\n class=\"nys-fileinput\"\n @nys-fileRemove=${this._handleFileRemove}\n >\n <nys-label\n for=${this.id}\n label=${this.label}\n description=${this.description}\n flag=${this.required ? \"required\" : this.optional ? \"optional\" : \"\"}\n tooltip=${this.tooltip}\n ?inverted=${this.inverted}\n >\n <slot name=\"description\" slot=\"description\">${this.description}</slot>\n </nys-label>\n\n <input\n id=${this.id}\n class=\"hidden-file-input\"\n tabindex=\"-1\"\n type=\"file\"\n name=${this.name}\n accept=${this.accept}\n form=${ifDefined(this.form || undefined)}\n ?multiple=${this.multiple}\n ?required=${this.required}\n ?disabled=${this.disabled ||\n (!this.multiple && this._selectedFiles.length > 0)}\n aria-disabled=\"${this.disabled}\"\n aria-hidden=\"true\"\n @change=${this._handleFileChange}\n hidden\n />\n\n ${!this.dropzone\n ? html`<nys-button\n id=\"choose-files-btn\"\n name=\"file-btn\"\n label=${this.multiple ? \"Choose files\" : \"Choose file\"}\n variant=\"outline\"\n ariaLabel=${this._buttonAriaLabel}\n ariaDescription=${this._buttonAriaDescription}\n ?disabled=${this.disabled ||\n (!this.multiple && this._selectedFiles.length > 0)}\n @nys-click=${this._openFileDialog}\n ></nys-button>`\n : html`<div\n class=\"nys-fileinput__dropzone\n ${this._dragActive ? \"drag-active\" : \"\"}\n ${this._isDropDisabled ? \"disabled\" : \"\"}\n ${this.showError && !this._isDropDisabled ? \"error\" : \"\"}\"\n @click=${this._isDropDisabled\n ? null\n : (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n\n // Ignore clicks that originated within a nys-button\n if (target.closest(\"nys-button\")) return;\n\n // Only handle direct wrapper clicks (outside of buttons)\n this._openFileDialog();\n }}\n @dragover=${this._isDropDisabled ? null : this._onDragOver}\n @dragleave=${this._isDropDisabled ? null : this._onDragLeave}\n @drop=${this._isDropDisabled ? null : this._onDrop}\n aria-label=\"Drag files here or choose from folder\"\n >\n ${this._dragActive\n ? html`<p>Drop file to upload</p>`\n : html` <nys-button\n id=\"choose-files-btn-drag\"\n name=\"file-btn\"\n label=${this.multiple ? \"Choose files\" : \"Choose file\"}\n variant=\"outline\"\n ariaLabel=${this._buttonAriaLabel}\n ariaDescription=${this._buttonAriaDescription}\n ?disabled=${this._isDropDisabled}\n @nys-click=\"${(e: CustomEvent) => {\n e.preventDefault();\n e.stopPropagation();\n this._openFileDialog();\n }}\"\n ></nys-button>\n <p>or drag here</p>`}\n </div>`}\n ${this.showError\n ? html`\n <nys-errormessage\n ?showError=${this.showError}\n errorMessage=${this._internals.validationMessage ||\n this.errorMessage}\n ></nys-errormessage>\n `\n : null}\n ${this._selectedFiles.length > 0\n ? html`\n <ul>\n ${this._selectedFiles.map(\n (entry) =>\n html`<li>\n <nys-fileitem\n filename=${entry.file.name}\n status=${entry.status}\n progress=${entry.progress}\n errorMessage=${entry.errorMsg || \"\"}\n ></nys-fileitem>\n </li>`,\n )}\n </ul>\n `\n : null}\n </div>`;\n }\n}\n\nif (!customElements.get(\"nys-fileinput\")) {\n customElements.define(\"nys-fileinput\", NysFileinput);\n}\n"],"names":["LitElement","unsafeCSS","html","property","ifDefined","validateFileHeader","file","accept","acceptItems","a","filename","fileExt","acceptItem","_NysFileItem","lastDotIndex","extension","name","startPart","endPart","styles","NysFileItem","__decorateClass","fileinputIdCounter","_NysFileinput","hasInvalidFiles","base","fileNames","f","files","entry","formData","singleFile","input","message","hasErrorFiles","isEmpty","event","innerButton","form","element","existingFile","reader","e","percentage","innerFileItemMainContainer","filenameToRemove","newFiles","NysFileinput"],"mappings":"AACA,SAAA,cAAAA,GAAA,aAAAC,GAAA,QAAAC,SAAA;AAAA,SAAA,YAAAC,SAAA;AAAA,SAAA,aAAAC,SAAA;;;;;;;;;;;AAAA,eAAsBC,EACpBC,GACAC,GACkB;AAElB,MAAI,CAACA,KAAUA,EAAO,KAAA,MAAW,GAAI,QAAO;AAG5C,QAAMC,IAAcD,EACjB,YAAA,EACA,MAAM,GAAG,EACT,IAAI,CAACE,MAAMA,EAAE,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fileinput",
3
- "version": "1.15.0",
3
+ "version": "1.16.0-alpha4",
4
4
  "description": "The Fileinput component from the NYS Design System.",
5
5
  "module": "dist/nys-fileinput.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,17 +16,17 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "dev": "tsc --emitDeclarationOnly && vite",
19
- "build": "tsc --emitDeclarationOnly && vite build",
19
+ "build": "vite build",
20
20
  "test": "vite build && wtr",
21
21
  "build:watch": "tsc --emitDeclarationOnly && vite build --watch",
22
22
  "test:watch": "vite build && wtr --watch",
23
23
  "lit-analyze": "lit-analyzer '**/*.ts'"
24
24
  },
25
25
  "dependencies": {
26
- "@nysds/nys-icon": "^1.15.0",
27
- "@nysds/nys-button": "^1.15.0",
28
- "@nysds/nys-label": "^1.15.0",
29
- "@nysds/nys-errormessage": "^1.15.0"
26
+ "@nysds/nys-icon": "^1.16.0-alpha4",
27
+ "@nysds/nys-button": "^1.16.0-alpha4",
28
+ "@nysds/nys-label": "^1.16.0-alpha4",
29
+ "@nysds/nys-errormessage": "^1.16.0-alpha4"
30
30
  },
31
31
  "devDependencies": {
32
32
  "lit": "^3.3.1",
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./nys-fileinput";
@@ -1,118 +0,0 @@
1
- import { LitElement } from "lit";
2
- import "./nys-fileitem";
3
- /**
4
- * A file input for uploading files with support for multiple files, drag-and-drop, and progress tracking.
5
- * Validates file types via magic bytes (not just extension). Form-associated via ElementInternals.
6
- *
7
- * Use for document uploads, image uploads, or any file submission. Enable `dropzone` for drag-and-drop UI.
8
- *
9
- * @summary File input with drag-and-drop, validation, and progress tracking.
10
- * @element nys-fileinput
11
- *
12
- * @slot description - Custom HTML description content.
13
- *
14
- * @fires nys-change - Fired when files are added or removed. Detail: `{id, files}`.
15
- *
16
- * @example Single file upload
17
- * ```html
18
- * <nys-fileinput label="Upload document" accept=".pdf,.doc" required></nys-fileinput>
19
- * ```
20
- *
21
- * @example Multiple files with dropzone
22
- * ```html
23
- * <nys-fileinput label="Upload images" accept="image/*" multiple dropzone></nys-fileinput>
24
- * ```
25
- */
26
- export declare class NysFileinput extends LitElement {
27
- static styles: import("lit").CSSResult;
28
- static shadowRootOptions: {
29
- delegatesFocus: boolean;
30
- clonable?: boolean;
31
- customElementRegistry?: CustomElementRegistry;
32
- mode: ShadowRootMode;
33
- serializable?: boolean;
34
- slotAssignment?: SlotAssignmentMode;
35
- };
36
- /** Unique identifier. Auto-generated if not provided. */
37
- id: string;
38
- /** Name for form submission. */
39
- name: string;
40
- /** Visible label text. */
41
- label: string;
42
- /** Helper text below label. Use slot for custom HTML. */
43
- description: string;
44
- /** Allows selecting multiple files. */
45
- multiple: boolean;
46
- /** Form `id` to associate with. */
47
- form: string | null;
48
- /** Tooltip text shown on hover/focus of info icon. */
49
- tooltip: string;
50
- /** Accepted file types. Use MIME types (`image/*`) or extensions (`.pdf`). Validated via magic bytes. */
51
- accept: string;
52
- /** Prevents interaction. */
53
- disabled: boolean;
54
- /** Requires at least one file to be uploaded. */
55
- required: boolean;
56
- /** Shows "Optional" flag. */
57
- optional: boolean;
58
- /** Shows error message when true. */
59
- showError: boolean;
60
- /** Error message text. Shown only when `showError` is true. */
61
- errorMessage: string;
62
- /** Enables drag-and-drop zone UI. */
63
- dropzone: boolean;
64
- /**
65
- * Component width: `lg` (384px) or `full` (100%, default).
66
- * @default "full"
67
- */
68
- width: "lg" | "full";
69
- /** Adjusts colors for dark backgrounds. */
70
- inverted: boolean;
71
- private _selectedFiles;
72
- private _dragActive;
73
- private get _isDropDisabled();
74
- private get _buttonAriaLabel();
75
- private get _buttonAriaDescription();
76
- private get _innerNysButton();
77
- private _internals;
78
- /**
79
- * Lifecycle methods
80
- * --------------------------------------------------------------------------
81
- */
82
- static formAssociated: boolean;
83
- constructor();
84
- connectedCallback(): void;
85
- disconnectedCallback(): void;
86
- firstUpdated(): void;
87
- /**
88
- * Form Integration
89
- * --------------------------------------------------------------------------
90
- */
91
- private _setValue;
92
- private _manageRequire;
93
- private _setValidityMessage;
94
- private _validate;
95
- checkValidity(): boolean;
96
- formResetCallback(): void;
97
- private _handleInvalid;
98
- /**
99
- * Functions
100
- * --------------------------------------------------------------------------
101
- */
102
- private _saveSelectedFiles;
103
- private _processFile;
104
- private _dispatchChangeEvent;
105
- private _openFileDialog;
106
- private _handlePostFileSelectionFocus;
107
- private _focusFirstFileItemIfSingleMode;
108
- /**
109
- * Event Handlers
110
- * --------------------------------------------------------------------------
111
- */
112
- private _handleFileChange;
113
- private _handleFileRemove;
114
- private _onDragOver;
115
- private _onDragLeave;
116
- private _onDrop;
117
- render(): import("lit-html").TemplateResult<1>;
118
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- import { LitElement } from "lit";
2
- /**
3
- * **Internal component.** Displays an individual file within `nys-fileinput` with status and progress.
4
- *
5
- * Rendered automatically by `nys-fileinput` for each selected file. Shows filename, upload status
6
- * (pending/processing/done/error), progress bar during upload, and error messages. Remove button emits event.
7
- *
8
- * @summary Internal file item display with status, progress bar, and remove action.
9
- * @element nys-fileitem
10
- *
11
- * @fires nys-fileRemove - Fired when remove button is clicked. Detail: `{filename}`.
12
- */
13
- export declare class NysFileItem extends LitElement {
14
- static styles: import("lit").CSSResult;
15
- static shadowRootOptions: {
16
- delegatesFocus: boolean;
17
- clonable?: boolean;
18
- customElementRegistry?: CustomElementRegistry;
19
- mode: ShadowRootMode;
20
- serializable?: boolean;
21
- slotAssignment?: SlotAssignmentMode;
22
- };
23
- /** Name of the file being displayed. */
24
- filename: string;
25
- /**
26
- * Upload status: `pending` (queued), `processing` (uploading), `done` (complete), `error` (failed).
27
- * @default "pending"
28
- */
29
- status: "pending" | "processing" | "done" | "error";
30
- /** Upload progress percentage (0-100). Only shown when status is `processing`. */
31
- progress: number;
32
- /** Error message displayed when status is `error`. */
33
- errorMessage: string;
34
- private _handleRemove;
35
- private splitFilename;
36
- render(): import("lit-html").TemplateResult<1>;
37
- }
@@ -1 +0,0 @@
1
- export declare function validateFileHeader(file: File, accept: string): Promise<boolean>;