@italia/upload 1.0.0-alpha.17 → 1.0.0-alpha.18
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.
- package/custom-elements.json +50 -3
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/it-upload-avatar.d.ts +0 -1
- package/dist/src/it-upload-avatar.d.ts.map +1 -1
- package/dist/src/it-upload-avatar.js +24 -26
- package/dist/src/it-upload-avatar.js.map +1 -1
- package/dist/src/it-upload-drag-drop.d.ts +4 -0
- package/dist/src/it-upload-drag-drop.d.ts.map +1 -1
- package/dist/src/it-upload-drag-drop.js +58 -28
- package/dist/src/it-upload-drag-drop.js.map +1 -1
- package/dist/src/it-upload.js +1 -1
- package/dist/src/types.d.ts +2 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +6 -6
package/custom-elements.json
CHANGED
|
@@ -322,6 +322,16 @@
|
|
|
322
322
|
"description": "Custom illustration URL. If not set, the built-in illustration is used.",
|
|
323
323
|
"attribute": "illustration"
|
|
324
324
|
},
|
|
325
|
+
{
|
|
326
|
+
"kind": "field",
|
|
327
|
+
"name": "headingLevel",
|
|
328
|
+
"type": {
|
|
329
|
+
"text": "DragDropHeadingLevel"
|
|
330
|
+
},
|
|
331
|
+
"default": "'h5'",
|
|
332
|
+
"description": "Heading level for the title element. Defaults to 'h5'; visual size stays at h5.",
|
|
333
|
+
"attribute": "heading-level"
|
|
334
|
+
},
|
|
325
335
|
{
|
|
326
336
|
"kind": "field",
|
|
327
337
|
"name": "_currentFile",
|
|
@@ -395,6 +405,16 @@
|
|
|
395
405
|
"privacy": "private",
|
|
396
406
|
"default": "false"
|
|
397
407
|
},
|
|
408
|
+
{
|
|
409
|
+
"kind": "method",
|
|
410
|
+
"name": "getHeadingLevel",
|
|
411
|
+
"privacy": "protected",
|
|
412
|
+
"return": {
|
|
413
|
+
"type": {
|
|
414
|
+
"text": "DragDropHeadingLevel"
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
},
|
|
398
418
|
{
|
|
399
419
|
"kind": "field",
|
|
400
420
|
"name": "_formClass",
|
|
@@ -597,6 +617,15 @@
|
|
|
597
617
|
},
|
|
598
618
|
"description": "Custom illustration URL. If not set, the built-in illustration is used.",
|
|
599
619
|
"fieldName": "illustration"
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
"name": "heading-level",
|
|
623
|
+
"type": {
|
|
624
|
+
"text": "DragDropHeadingLevel"
|
|
625
|
+
},
|
|
626
|
+
"default": "'h5'",
|
|
627
|
+
"description": "Heading level for the title element. Defaults to 'h5'; visual size stays at h5.",
|
|
628
|
+
"fieldName": "headingLevel"
|
|
600
629
|
}
|
|
601
630
|
],
|
|
602
631
|
"superclass": {
|
|
@@ -1114,8 +1143,26 @@
|
|
|
1114
1143
|
{
|
|
1115
1144
|
"kind": "javascript-module",
|
|
1116
1145
|
"path": "src/types.ts",
|
|
1117
|
-
"declarations": [
|
|
1118
|
-
|
|
1146
|
+
"declarations": [
|
|
1147
|
+
{
|
|
1148
|
+
"kind": "variable",
|
|
1149
|
+
"name": "DRAG_DROP_HEADING_LEVELS",
|
|
1150
|
+
"type": {
|
|
1151
|
+
"text": "['h2', 'h3', 'h4', 'h5', 'h6']"
|
|
1152
|
+
},
|
|
1153
|
+
"default": "['h2', 'h3', 'h4', 'h5', 'h6']"
|
|
1154
|
+
}
|
|
1155
|
+
],
|
|
1156
|
+
"exports": [
|
|
1157
|
+
{
|
|
1158
|
+
"kind": "js",
|
|
1159
|
+
"name": "DRAG_DROP_HEADING_LEVELS",
|
|
1160
|
+
"declaration": {
|
|
1161
|
+
"name": "DRAG_DROP_HEADING_LEVELS",
|
|
1162
|
+
"module": "src/types.ts"
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
]
|
|
1119
1166
|
},
|
|
1120
1167
|
{
|
|
1121
1168
|
"kind": "javascript-module",
|
|
@@ -1247,7 +1294,7 @@
|
|
|
1247
1294
|
"type": {
|
|
1248
1295
|
"text": "Story"
|
|
1249
1296
|
},
|
|
1250
|
-
"default": "{ name: 'Esempio interattivo Drag & Drop', tags: ['!autodocs', '!dev'], args: { accept: '', illustration: '', disabled: false, required: false, }, argTypes: { accept: { description: 'Tipi di file accettati, es. \"image/*,.pdf\".', control: 'text', }, illustration: { description: 'URL illustrazione personalizzata. Se omesso viene usata quella predefinita.', control: 'text', }, disabled: { description: 'Disabilita il componente.', control: 'boolean', table: { defaultValue: { summary: 'false' } }, }, required: { description: 'Rende il campo obbligatorio nella validazione del form.', control: 'boolean', table: { defaultValue: { summary: 'false' } }, }, }, parameters: { docs: { canvas: { sourceState: 'closed' }, }, }, render: (params) => renderUploadDragDrop(params as Partial<UploadDragDropProps>), }"
|
|
1297
|
+
"default": "{ name: 'Esempio interattivo Drag & Drop', tags: ['!autodocs', '!dev'], args: { accept: '', illustration: '', disabled: false, required: false, 'heading-level': 'h3', }, argTypes: { accept: { description: 'Tipi di file accettati, es. \"image/*,.pdf\".', control: 'text', }, illustration: { description: 'URL illustrazione personalizzata. Se omesso viene usata quella predefinita.', control: 'text', }, 'heading-level': { description: 'Livello del titolo semantico nella gerarchia della pagina. La dimensione visiva rimane h5.', control: { type: 'select' }, options: DRAG_DROP_HEADING_LEVELS, table: { defaultValue: { summary: 'h5' } }, }, disabled: { description: 'Disabilita il componente.', control: 'boolean', table: { defaultValue: { summary: 'false' } }, }, required: { description: 'Rende il campo obbligatorio nella validazione del form.', control: 'boolean', table: { defaultValue: { summary: 'false' } }, }, }, parameters: { docs: { canvas: { sourceState: 'closed' }, }, }, render: (params) => renderUploadDragDrop(params as Partial<UploadDragDropProps>), }"
|
|
1251
1298
|
},
|
|
1252
1299
|
{
|
|
1253
1300
|
"kind": "variable",
|
package/dist/src/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { ItUpload } from './it-upload.js';
|
|
2
2
|
export { ItUploadAvatar } from './it-upload-avatar.js';
|
|
3
3
|
export { ItUploadDragDrop } from './it-upload-drag-drop.js';
|
|
4
|
-
import '../en-
|
|
4
|
+
import '../en-bhgshDbO.js';
|
|
5
5
|
import 'lit/directive.js';
|
|
6
6
|
import 'lit';
|
|
7
7
|
import 'lit/decorators.js';
|
|
8
8
|
import 'lit/directives/if-defined.js';
|
|
9
9
|
import 'lit/directives/when.js';
|
|
10
10
|
import '../utils-xlxkOHqp.js';
|
|
11
|
+
import 'lit/static-html.js';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -31,7 +31,6 @@ export declare class ItUploadAvatar extends FormControl {
|
|
|
31
31
|
private _currentFile;
|
|
32
32
|
connectedCallback(): void;
|
|
33
33
|
willUpdate(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
34
|
-
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
35
34
|
private _handleFileChange;
|
|
36
35
|
render(): import("lit").TemplateResult<1>;
|
|
37
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"it-upload-avatar.d.ts","sourceRoot":"","sources":["../../src/it-upload-avatar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAarE,qBACa,cAAe,SAAQ,WAAW;IAC7C,MAAM,CAAC,MAAM,+BAAU;IAEvB,OAAgB,iBAAiB;;;;;;;MAG/B;IAIF,mBAA4B,qBAAqB,EAAE,qBAAqB,CAGrE;IAGM,YAAY,EAAG,gBAAgB,CAAC;IAEzC,uDAAuD;IAEvD,GAAG,SAAM;IAET,4CAA4C;IAE5C,GAAG,SAAM;IAET,6DAA6D;IAE7D,IAAI,EAAE,IAAI,GAAG,IAAI,GA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AED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,cAAc,CAAC;KACpC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as registerTranslation, t as translation, a as translation$1, F as FormControl, _ as __decorate, b as __metadata, c as FormControlController } from '../en-
|
|
1
|
+
import { r as registerTranslation, t as translation, a as translation$1, F as FormControl, _ as __decorate, b as __metadata, c as FormControlController } from '../en-bhgshDbO.js';
|
|
2
2
|
import { css, nothing, html } from 'lit';
|
|
3
3
|
import { query, property, state, customElement } from 'lit/decorators.js';
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -1399,10 +1399,6 @@ select.just-validate-success-field {
|
|
|
1399
1399
|
display: inline-block;
|
|
1400
1400
|
}
|
|
1401
1401
|
|
|
1402
|
-
.it-form__control {
|
|
1403
|
-
display: none;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
1402
|
input.upload-avatar {
|
|
1407
1403
|
position: absolute;
|
|
1408
1404
|
z-index: 1;
|
|
@@ -1548,12 +1544,18 @@ let ItUploadAvatar = class ItUploadAvatar extends FormControl {
|
|
|
1548
1544
|
if (changedProperties.has('src') && !this._currentSrc) {
|
|
1549
1545
|
this._currentSrc = this.src;
|
|
1550
1546
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
//
|
|
1555
|
-
|
|
1556
|
-
|
|
1547
|
+
// Keep the displayed validation message in sync with the value here (pre-render) rather
|
|
1548
|
+
// than in updated(), so picking/clearing a file refreshes it without scheduling a second
|
|
1549
|
+
// render — avoids Lit's "scheduled an update after an update completed" warning. The native
|
|
1550
|
+
// `?required` attribute still drives checkValidity()/the constraint bubble. Guarded by
|
|
1551
|
+
// `hasUpdated` because `inputElement` only exists once the first render has produced the DOM.
|
|
1552
|
+
if (this.hasUpdated &&
|
|
1553
|
+
!this.customValidation &&
|
|
1554
|
+
(changedProperties.has('_currentFile') || changedProperties.has('_currentSrc'))) {
|
|
1555
|
+
const hasValue = Boolean(this._currentFile || this._currentSrc);
|
|
1556
|
+
const message = this.required && !hasValue ? this.$t('validityRequired') : '';
|
|
1557
|
+
this.inputElement?.setCustomValidity(message);
|
|
1558
|
+
this.validationMessage = message;
|
|
1557
1559
|
}
|
|
1558
1560
|
}
|
|
1559
1561
|
_handleFileChange(e) {
|
|
@@ -1576,13 +1578,14 @@ let ItUploadAvatar = class ItUploadAvatar extends FormControl {
|
|
|
1576
1578
|
composed: true,
|
|
1577
1579
|
}));
|
|
1578
1580
|
}
|
|
1579
|
-
// Forward wrapper clicks to the hidden file input.
|
|
1580
|
-
// If the click already originated from the label (which has a `for` association), skip to
|
|
1581
1581
|
render() {
|
|
1582
1582
|
const labelText = this.$t('upload_avatar_label');
|
|
1583
|
+
const fileInputLabel = this.required ? labelText : labelText;
|
|
1583
1584
|
const overlayText = this.overlayLabel ?? this.$t('upload_avatar_overlay_label');
|
|
1584
|
-
|
|
1585
|
+
// A pre-filled `src` or a freshly selected file both satisfy `required`.
|
|
1586
|
+
const hasValue = Boolean(this._currentFile || this._currentSrc);
|
|
1585
1587
|
const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;
|
|
1588
|
+
const feedbackId = `invalid-feedback-${this._id}`;
|
|
1586
1589
|
return html `
|
|
1587
1590
|
<div class="avatar-upload-wrapper size-${this.size}">
|
|
1588
1591
|
<it-avatar
|
|
@@ -1596,11 +1599,15 @@ let ItUploadAvatar = class ItUploadAvatar extends FormControl {
|
|
|
1596
1599
|
<div class="upload-avatar-container">
|
|
1597
1600
|
<input
|
|
1598
1601
|
type="file"
|
|
1599
|
-
class="upload-avatar"
|
|
1602
|
+
class="upload-avatar it-form__control"
|
|
1600
1603
|
id="${this._id}"
|
|
1601
1604
|
accept="${this.accept}"
|
|
1602
1605
|
?disabled="${this.disabled}"
|
|
1603
|
-
|
|
1606
|
+
?required="${this.required && !hasValue}"
|
|
1607
|
+
aria-label="${fileInputLabel}"
|
|
1608
|
+
aria-required="${this.required ? 'true' : nothing}"
|
|
1609
|
+
aria-invalid="${isInvalid ? 'true' : 'false'}"
|
|
1610
|
+
aria-describedby="${ifDefined(isInvalid ? feedbackId : undefined)}"
|
|
1604
1611
|
@change="${this._handleFileChange}"
|
|
1605
1612
|
/>
|
|
1606
1613
|
<label part="overlay-label" for="${this._id}" class="it-upload-avatar-label-container" aria-hidden="true">
|
|
@@ -1614,17 +1621,8 @@ let ItUploadAvatar = class ItUploadAvatar extends FormControl {
|
|
|
1614
1621
|
</div>
|
|
1615
1622
|
</div>
|
|
1616
1623
|
|
|
1617
|
-
<!-- Hidden proxy input: drives native required/validity checking via FormControl base class -->
|
|
1618
|
-
<input
|
|
1619
|
-
type="text"
|
|
1620
|
-
class="it-form__control"
|
|
1621
|
-
.value="${proxyValue}"
|
|
1622
|
-
?required="${this.required}"
|
|
1623
|
-
tabindex="-1"
|
|
1624
|
-
aria-hidden="true"
|
|
1625
|
-
/>
|
|
1626
|
-
|
|
1627
1624
|
<div
|
|
1625
|
+
id="${feedbackId}"
|
|
1628
1626
|
class="invalid-feedback form-feedback form-text just-validate-error-label"
|
|
1629
1627
|
role="alert"
|
|
1630
1628
|
?hidden=${!isInvalid}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"it-upload-avatar.js","sources":["../../../src/it-upload-avatar.ts"],"sourcesContent":["import { FormControl, FormControlController } from '@italia/globals';\nimport { registerTranslation } from '@italia/i18n';\nimport { html, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport it from './locales/it.js';\nimport en from './locales/en.js';\nimport styles from './upload-avatar.scss';\n\nregisterTranslation(it);\nregisterTranslation(en);\n\n@customElement('it-upload-avatar')\nexport class ItUploadAvatar extends FormControl {\n static styles = styles;\n\n static override shadowRootOptions = {\n ...FormControl.shadowRootOptions,\n delegatesFocus: true,\n };\n\n // Override the base FormControlController.\n // Value is the selected File, or falls back to the current src (pre-filled image satisfies required).\n protected override readonly formControlController: FormControlController = new FormControlController(this, {\n value: (el) => (el as ItUploadAvatar)._currentFile ?? ((el as ItUploadAvatar)._currentSrc || null),\n assumeInteractionOn: ['it-change'],\n });\n\n @query('.it-form__control')\n override inputElement!: HTMLInputElement;\n\n /** Current image source URL displayed in the avatar */\n @property({ type: String, reflect: true })\n src = '';\n\n /** Alt text for the current avatar image */\n @property({ type: String, reflect: true })\n alt = '';\n\n /** Size of the avatar. Accepts any BSI avatar size token. */\n @property({ type: String, reflect: true })\n size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' = 'xxl';\n\n /** Accepted file types, e.g. \"image/*\" */\n @property({ type: String })\n accept = 'image/*';\n\n /**\n * Text shown inside the desktop hover/focus overlay.\n * Defaults to the i18n key `upload_avatar_overlay_label` (\"Aggiorna\" / \"Update\").\n */\n @property({ type: String, attribute: 'overlay-label' })\n overlayLabel?: string;\n\n /** If true, the upload button is disabled */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n @state()\n private _currentSrc = '';\n\n /** The currently selected File (null until a new file is chosen). */\n @state()\n private _currentFile: File | null = null;\n\n override connectedCallback() {\n super.connectedCallback?.();\n this._currentSrc = this.src;\n }\n\n override willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n super.willUpdate?.(changedProperties);\n if (changedProperties.has('src') && !this._currentSrc) {\n this._currentSrc = this.src;\n }\n }\n\n override updated(changedProperties: Map<string | number | symbol, unknown>) {\n super.updated?.(changedProperties);\n // Re-evaluate validity whenever the form value changes.\n if (changedProperties.has('_currentFile') || changedProperties.has('_currentSrc')) {\n this.handleValidationMessages();\n }\n }\n\n private _handleFileChange(e: Event) {\n const input = e.target as HTMLInputElement;\n const file = input.files?.[0];\n if (!file) return;\n\n this._currentFile = file;\n\n const reader = new FileReader();\n reader.onload = (event) => {\n this._currentSrc = event.target?.result as string;\n this.requestUpdate();\n };\n reader.readAsDataURL(file);\n\n // Reset the native input\n input.value = '';\n\n this.dispatchEvent(\n new CustomEvent('it-change', {\n detail: { file, name: this.name, id: this.id },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n // Forward wrapper clicks to the hidden file input.\n // If the click already originated from the label (which has a `for` association), skip to\n\n override render() {\n const labelText = this.$t('upload_avatar_label');\n const overlayText = this.overlayLabel ?? this.$t('upload_avatar_overlay_label');\n const proxyValue = this._currentSrc || this._currentFile?.name || '';\n const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;\n\n return html`\n <div class=\"avatar-upload-wrapper size-${this.size}\">\n <it-avatar\n type=\"image\"\n size=\"${this.size}\"\n src=\"${ifDefined(this._currentSrc || undefined)}\"\n alt=\"${this.alt}\"\n class=\"avatar-upload\"\n ></it-avatar>\n\n <div class=\"upload-avatar-container\">\n <input\n type=\"file\"\n class=\"upload-avatar\"\n id=\"${this._id!}\"\n accept=\"${this.accept}\"\n ?disabled=\"${this.disabled}\"\n aria-label=\"${labelText}\"\n @change=\"${this._handleFileChange}\"\n />\n <label part=\"overlay-label\" for=\"${this._id!}\" class=\"it-upload-avatar-label-container\" aria-hidden=\"true\">\n <it-icon name=\"it-camera\" size=\"sm\" color=\"inverse\" aria-hidden=\"true\"></it-icon>\n <span class=\"it-upload-avatar-label\">${overlayText}</span>\n </label>\n </div>\n\n <div class=\"avatar-upload-icon\" aria-hidden=\"true\">\n <it-icon name=\"it-camera\" size=\"${this.size === 'xl' ? 'xs' : 'sm'}\"></it-icon>\n </div>\n </div>\n\n <!-- Hidden proxy input: drives native required/validity checking via FormControl base class -->\n <input\n type=\"text\"\n class=\"it-form__control\"\n .value=\"${proxyValue}\"\n ?required=\"${this.required}\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n />\n\n <div\n class=\"invalid-feedback form-feedback form-text just-validate-error-label\"\n role=\"alert\"\n ?hidden=${!isInvalid}\n >\n ${isInvalid ? this.validationMessage : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'it-up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CAAA;AAItB,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC1B,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAGT,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACiB,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAIjB,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACiC,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAlD9B,cAAc,GAAA,UAAA,CAAA;IAD1B,aAAa,CAAC,kBAAkB;AACpB,CAAA,EAAA,cAAc,CA6J1B;;;;"}
|
|
1
|
+
{"version":3,"file":"it-upload-avatar.js","sources":["../../../src/it-upload-avatar.ts"],"sourcesContent":["import { FormControl, FormControlController } from '@italia/globals';\nimport { registerTranslation } from '@italia/i18n';\nimport { html, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport it from './locales/it.js';\nimport en from './locales/en.js';\nimport styles from './upload-avatar.scss';\n\nregisterTranslation(it);\nregisterTranslation(en);\n\n@customElement('it-upload-avatar')\nexport class ItUploadAvatar extends FormControl {\n static styles = styles;\n\n static override shadowRootOptions = {\n ...FormControl.shadowRootOptions,\n delegatesFocus: true,\n };\n\n // Override the base FormControlController.\n // Value is the selected File, or falls back to the current src (pre-filled image satisfies required).\n protected override readonly formControlController: FormControlController = new FormControlController(this, {\n value: (el) => (el as ItUploadAvatar)._currentFile ?? ((el as ItUploadAvatar)._currentSrc || null),\n assumeInteractionOn: ['it-change'],\n });\n\n @query('.it-form__control')\n override inputElement!: HTMLInputElement;\n\n /** Current image source URL displayed in the avatar */\n @property({ type: String, reflect: true })\n src = '';\n\n /** Alt text for the current avatar image */\n @property({ type: String, reflect: true })\n alt = '';\n\n /** Size of the avatar. Accepts any BSI avatar size token. */\n @property({ type: String, reflect: true })\n size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' = 'xxl';\n\n /** Accepted file types, e.g. \"image/*\" */\n @property({ type: String })\n accept = 'image/*';\n\n /**\n * Text shown inside the desktop hover/focus overlay.\n * Defaults to the i18n key `upload_avatar_overlay_label` (\"Aggiorna\" / \"Update\").\n */\n @property({ type: String, attribute: 'overlay-label' })\n overlayLabel?: string;\n\n /** If true, the upload button is disabled */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n @state()\n private _currentSrc = '';\n\n /** The currently selected File (null until a new file is chosen). */\n @state()\n private _currentFile: File | null = null;\n\n override connectedCallback() {\n super.connectedCallback?.();\n this._currentSrc = this.src;\n }\n\n override willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n super.willUpdate?.(changedProperties);\n if (changedProperties.has('src') && !this._currentSrc) {\n this._currentSrc = this.src;\n }\n // Keep the displayed validation message in sync with the value here (pre-render) rather\n // than in updated(), so picking/clearing a file refreshes it without scheduling a second\n // render — avoids Lit's \"scheduled an update after an update completed\" warning. The native\n // `?required` attribute still drives checkValidity()/the constraint bubble. Guarded by\n // `hasUpdated` because `inputElement` only exists once the first render has produced the DOM.\n if (\n this.hasUpdated &&\n !this.customValidation &&\n (changedProperties.has('_currentFile') || changedProperties.has('_currentSrc'))\n ) {\n const hasValue = Boolean(this._currentFile || this._currentSrc);\n const message = this.required && !hasValue ? this.$t('validityRequired') : '';\n this.inputElement?.setCustomValidity(message);\n this.validationMessage = message;\n }\n }\n\n private _handleFileChange(e: Event) {\n const input = e.target as HTMLInputElement;\n const file = input.files?.[0];\n if (!file) return;\n\n this._currentFile = file;\n\n const reader = new FileReader();\n reader.onload = (event) => {\n this._currentSrc = event.target?.result as string;\n this.requestUpdate();\n };\n reader.readAsDataURL(file);\n\n // Reset the native input\n input.value = '';\n\n this.dispatchEvent(\n new CustomEvent('it-change', {\n detail: { file, name: this.name, id: this.id },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n override render() {\n const labelText = this.$t('upload_avatar_label');\n const fileInputLabel = this.required ? labelText : labelText;\n const overlayText = this.overlayLabel ?? this.$t('upload_avatar_overlay_label');\n // A pre-filled `src` or a freshly selected file both satisfy `required`.\n const hasValue = Boolean(this._currentFile || this._currentSrc);\n const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;\n const feedbackId = `invalid-feedback-${this._id}`;\n\n return html`\n <div class=\"avatar-upload-wrapper size-${this.size}\">\n <it-avatar\n type=\"image\"\n size=\"${this.size}\"\n src=\"${ifDefined(this._currentSrc || undefined)}\"\n alt=\"${this.alt}\"\n class=\"avatar-upload\"\n ></it-avatar>\n\n <div class=\"upload-avatar-container\">\n <input\n type=\"file\"\n class=\"upload-avatar it-form__control\"\n id=\"${this._id!}\"\n accept=\"${this.accept}\"\n ?disabled=\"${this.disabled}\"\n ?required=\"${this.required && !hasValue}\"\n aria-label=\"${fileInputLabel}\"\n aria-required=\"${this.required ? 'true' : nothing}\"\n aria-invalid=\"${isInvalid ? 'true' : 'false'}\"\n aria-describedby=\"${ifDefined(isInvalid ? feedbackId : undefined)}\"\n @change=\"${this._handleFileChange}\"\n />\n <label part=\"overlay-label\" for=\"${this._id!}\" class=\"it-upload-avatar-label-container\" aria-hidden=\"true\">\n <it-icon name=\"it-camera\" size=\"sm\" color=\"inverse\" aria-hidden=\"true\"></it-icon>\n <span class=\"it-upload-avatar-label\">${overlayText}</span>\n </label>\n </div>\n\n <div class=\"avatar-upload-icon\" aria-hidden=\"true\">\n <it-icon name=\"it-camera\" size=\"${this.size === 'xl' ? 'xs' : 'sm'}\"></it-icon>\n </div>\n </div>\n\n <div\n id=\"${feedbackId}\"\n class=\"invalid-feedback form-feedback form-text just-validate-error-label\"\n role=\"alert\"\n ?hidden=${!isInvalid}\n >\n ${isInvalid ? this.validationMessage : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'it-upload-avatar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M,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AACjC,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,KAAA,EAAA,MAAA,CAAA;AAIT,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AACa,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAIvD,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACR,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAOnB,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;;AACjC,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAItB,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC1B,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAGT,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACiB,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAIjB,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACiC,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAlD9B,cAAc,GAAA,UAAA,CAAA;IAD1B,aAAa,CAAC,kBAAkB;AACpB,CAAA,EAAA,cAAc,CA+J1B;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FormControl, FormControlController } from '@italia/globals';
|
|
2
|
+
import { type DragDropHeadingLevel } from './types.js';
|
|
2
3
|
export declare class ItUploadDragDrop extends FormControl {
|
|
3
4
|
static styles: import("lit").CSSResultGroup;
|
|
4
5
|
protected readonly formControlController: FormControlController;
|
|
@@ -7,6 +8,8 @@ export declare class ItUploadDragDrop extends FormControl {
|
|
|
7
8
|
accept?: string;
|
|
8
9
|
/** Custom illustration URL. If not set, the built-in illustration is used. */
|
|
9
10
|
illustration?: string;
|
|
11
|
+
/** Heading level for the title element. Defaults to 'h5'; visual size stays at h5. */
|
|
12
|
+
headingLevel: DragDropHeadingLevel;
|
|
10
13
|
/** The currently selected File (null until file is chosen/dropped). */
|
|
11
14
|
private _currentFile;
|
|
12
15
|
private _state;
|
|
@@ -16,6 +19,7 @@ export declare class ItUploadDragDrop extends FormControl {
|
|
|
16
19
|
private _fileType;
|
|
17
20
|
private _indeterminate;
|
|
18
21
|
private _autoStarted;
|
|
22
|
+
protected getHeadingLevel(): DragDropHeadingLevel;
|
|
19
23
|
private get _formClass();
|
|
20
24
|
/** Advance the donut progress. Value must be between 0 and 1. */
|
|
21
25
|
progress(value: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"it-upload-drag-drop.d.ts","sourceRoot":"","sources":["../../src/it-upload-drag-drop.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"it-upload-drag-drop.d.ts","sourceRoot":"","sources":["../../src/it-upload-drag-drop.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAWrE,OAAO,EAAE,KAAK,oBAAoB,EAA4B,MAAM,YAAY,CAAC;AAYjF,qBACa,gBAAiB,SAAQ,WAAW;IAC/C,MAAM,CAAC,MAAM,+BAAU;IAGvB,mBAA4B,qBAAqB,EAAE,qBAAqB,CAGrE;IAGM,YAAY,EAAG,gBAAgB,CAAC;IAEzC,+CAA+C;IAE/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,8EAA8E;IAE9E,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,sFAAsF;IAEtF,YAAY,EAAE,oBAAoB,CAAQ;IAE1C,uEAAuE;IAEvE,OAAO,CAAC,YAAY,CAAqB;IAGzC,OAAO,CAAC,MAAM,CAAyB;IAGvC,OAAO,CAAC,SAAS,CAAK;IAGtB,OAAO,CAAC,SAAS,CAAM;IAGvB,OAAO,CAAC,WAAW,CAAM;IAGzB,OAAO,CAAC,SAAS,CAAM;IAGvB,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,YAAY,CAAS;IAE7B,SAAS,CAAC,eAAe,IAAI,oBAAoB;IAIjD,OAAO,KAAK,UAAU,GAOrB;IAED,iEAAiE;IAC1D,QAAQ,CAAC,KAAK,EAAE,MAAM;IAM7B,wEAAwE;IACjE,KAAK;IAIZ,iCAAiC;IAC1B,OAAO;IAId,8CAA8C;IACvC,KAAK;IAWZ,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,YAAY;IAmBpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,OAAO;IAmCf,OAAO,CAAC,kBAAkB;IAiC1B,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,kBAAkB;IAwDjB,MAAM;CAgDhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,qBAAqB,EAAE,gBAAgB,CAAC;KACzC;CACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { r as registerTranslation, t as translation, a as translation$1, _ as __decorate, b as __metadata, F as FormControl, c as FormControlController } from '../en-
|
|
1
|
+
import { r as registerTranslation, t as translation, a as translation$1, _ as __decorate, b as __metadata, F as FormControl, c as FormControlController } from '../en-bhgshDbO.js';
|
|
2
2
|
import { css, nothing, html } from 'lit';
|
|
3
|
+
import { unsafeStatic, html as html$1 } from 'lit/static-html.js';
|
|
3
4
|
import { query, property, state, customElement } from 'lit/decorators.js';
|
|
4
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
6
|
import { f as formatSize } from '../utils-xlxkOHqp.js';
|
|
@@ -1133,10 +1134,15 @@ blockquote.blockquote-card.dark .blockquote-footer,
|
|
|
1133
1134
|
display: inline-block;
|
|
1134
1135
|
}
|
|
1135
1136
|
|
|
1136
|
-
.
|
|
1137
|
+
.upload-dragdrop.loading .upload-dragdrop-select-wrap,
|
|
1138
|
+
.upload-dragdrop.success .upload-dragdrop-select-wrap {
|
|
1137
1139
|
display: none;
|
|
1138
1140
|
}
|
|
1139
1141
|
|
|
1142
|
+
.invalid-feedback:not([hidden]) {
|
|
1143
|
+
display: block;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1140
1146
|
.upload-dragdrop-loading it-progress {
|
|
1141
1147
|
display: block;
|
|
1142
1148
|
width: 100%;
|
|
@@ -1158,8 +1164,15 @@ blockquote.blockquote-card.dark .blockquote-footer,
|
|
|
1158
1164
|
display: flex;
|
|
1159
1165
|
align-items: center;
|
|
1160
1166
|
gap: var(--bsi-spacing-xxs, 8px);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
.upload-dragdrop-text :is(h1, h2, h3, h4, h6) {
|
|
1170
|
+
margin: 0;
|
|
1171
|
+
color: var(--bsi-color-text-base);
|
|
1161
1172
|
}`;
|
|
1162
1173
|
|
|
1174
|
+
const DRAG_DROP_HEADING_LEVELS = ['h2', 'h3', 'h4', 'h5', 'h6'];
|
|
1175
|
+
|
|
1163
1176
|
registerTranslation(translation);
|
|
1164
1177
|
registerTranslation(translation$1);
|
|
1165
1178
|
// Base64‑encoded copy of bootstrap-italia/dist/assets/upload-drag-drop-icon.svg
|
|
@@ -1173,6 +1186,8 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
|
|
|
1173
1186
|
value: (el) => el._currentFile,
|
|
1174
1187
|
assumeInteractionOn: ['it-change'],
|
|
1175
1188
|
});
|
|
1189
|
+
/** Heading level for the title element. Defaults to 'h5'; visual size stays at h5. */
|
|
1190
|
+
this.headingLevel = 'h5';
|
|
1176
1191
|
/** The currently selected File (null until file is chosen/dropped). */
|
|
1177
1192
|
this._currentFile = null;
|
|
1178
1193
|
this._state = 'idle';
|
|
@@ -1183,6 +1198,9 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
|
|
|
1183
1198
|
this._indeterminate = false;
|
|
1184
1199
|
this._autoStarted = false;
|
|
1185
1200
|
}
|
|
1201
|
+
getHeadingLevel() {
|
|
1202
|
+
return DRAG_DROP_HEADING_LEVELS.includes(this.headingLevel) ? this.headingLevel : 'h5';
|
|
1203
|
+
}
|
|
1186
1204
|
get _formClass() {
|
|
1187
1205
|
return this.composeClass('upload-dragdrop', this._state === 'dragover' ? 'dragover' : '', this._state === 'loading' ? 'loading' : '', this._state === 'success' ? 'success' : '');
|
|
1188
1206
|
}
|
|
@@ -1335,6 +1353,11 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
|
|
|
1335
1353
|
const hasFile = this._fileName.length > 0;
|
|
1336
1354
|
// Title: slot or default per state
|
|
1337
1355
|
const titleText = hasFile ? this._fileName : this.$t('upload_dd_title');
|
|
1356
|
+
const fileInputLabel = this.required ? this.$t('upload_label') : this.$t('upload_label');
|
|
1357
|
+
const canSelect = this._state === 'idle' || this._state === 'dragover';
|
|
1358
|
+
const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;
|
|
1359
|
+
const feedbackId = `invalid-feedback-${this._id}`;
|
|
1360
|
+
const headingTag = unsafeStatic(this.getHeadingLevel());
|
|
1338
1361
|
return html `
|
|
1339
1362
|
<div class="upload-dragdrop-text">
|
|
1340
1363
|
${hasFile && this._fileWeight
|
|
@@ -1345,28 +1368,35 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
|
|
|
1345
1368
|
</p>
|
|
1346
1369
|
`
|
|
1347
1370
|
: nothing}
|
|
1348
|
-
|
|
1371
|
+
${html$1 `<${headingTag} class="h5">
|
|
1349
1372
|
<slot name="title">${titleText}</slot>
|
|
1350
|
-
|
|
1351
|
-
${this._state === 'idle' || this._state === 'dragover'
|
|
1373
|
+
</${headingTag}>`} ${canSelect
|
|
1352
1374
|
? html `
|
|
1353
1375
|
<p>
|
|
1354
1376
|
<slot name="description">${this.$t('upload_dd_description')}</slot>
|
|
1355
1377
|
</p>
|
|
1356
|
-
<p>
|
|
1357
|
-
<input
|
|
1358
|
-
type="file"
|
|
1359
|
-
class="upload-dragdrop-input"
|
|
1360
|
-
id="${this._id}"
|
|
1361
|
-
accept="${ifDefined(this.accept)}"
|
|
1362
|
-
?disabled="${this.disabled}"
|
|
1363
|
-
aria-label="${this.$t('upload_label')}"
|
|
1364
|
-
@change="${this._onFileInputChange}"
|
|
1365
|
-
/>
|
|
1366
|
-
<label for="${this._id}">${this.$t('upload_dd_select')}</label>
|
|
1367
|
-
</p>
|
|
1368
1378
|
`
|
|
1369
1379
|
: nothing}
|
|
1380
|
+
<!-- The file input is the form-control validity participant, so it must exist in every
|
|
1381
|
+
state for the FormControl base class to read its validity. It is the real focusable
|
|
1382
|
+
control native required/validity now anchors to (no hidden proxy). The select affordance
|
|
1383
|
+
(label) and this wrapper are hidden via CSS in loading/success states. -->
|
|
1384
|
+
<p class="upload-dragdrop-select-wrap">
|
|
1385
|
+
<input
|
|
1386
|
+
type="file"
|
|
1387
|
+
class="upload-dragdrop-input it-form__control"
|
|
1388
|
+
id="${this._id}"
|
|
1389
|
+
accept="${ifDefined(this.accept)}"
|
|
1390
|
+
?disabled="${this.disabled}"
|
|
1391
|
+
?required="${this.required && !this._currentFile}"
|
|
1392
|
+
aria-label="${fileInputLabel}"
|
|
1393
|
+
aria-required="${this.required ? 'true' : nothing}"
|
|
1394
|
+
aria-invalid="${isInvalid ? 'true' : 'false'}"
|
|
1395
|
+
aria-describedby="${ifDefined(isInvalid ? feedbackId : undefined)}"
|
|
1396
|
+
@change="${this._onFileInputChange}"
|
|
1397
|
+
/>
|
|
1398
|
+
${canSelect ? html `<label for="${this._id}">${this.$t('upload_dd_select')}</label>` : nothing}
|
|
1399
|
+
</p>
|
|
1370
1400
|
${this._state === 'loading' ? html `<p>${this.$t('upload_dd_status_loading')}</p>` : nothing}
|
|
1371
1401
|
${this._state === 'success' ? html `<p>${this.$t('upload_dd_status_success')}</p>` : nothing}
|
|
1372
1402
|
</div>
|
|
@@ -1375,6 +1405,7 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
|
|
|
1375
1405
|
render() {
|
|
1376
1406
|
const statusText = this._getStatusText();
|
|
1377
1407
|
const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;
|
|
1408
|
+
const feedbackId = `invalid-feedback-${this._id}`;
|
|
1378
1409
|
return html `
|
|
1379
1410
|
<div
|
|
1380
1411
|
part="drop-zone"
|
|
@@ -1408,17 +1439,12 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
|
|
|
1408
1439
|
<div role="status" aria-live="polite" aria-atomic="true" class="visually-hidden">${statusText}</div>
|
|
1409
1440
|
</div>
|
|
1410
1441
|
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
tabindex="-1"
|
|
1418
|
-
aria-hidden="true"
|
|
1419
|
-
/>
|
|
1420
|
-
|
|
1421
|
-
<div class="invalid-feedback form-feedback form-text just-validate-error-label" role="alert">
|
|
1442
|
+
<div
|
|
1443
|
+
id="${feedbackId}"
|
|
1444
|
+
class="invalid-feedback form-feedback form-text just-validate-error-label"
|
|
1445
|
+
role="alert"
|
|
1446
|
+
?hidden=${!isInvalid}
|
|
1447
|
+
>
|
|
1422
1448
|
${isInvalid ? this.validationMessage : nothing}
|
|
1423
1449
|
</div>
|
|
1424
1450
|
`;
|
|
@@ -1437,6 +1463,10 @@ __decorate([
|
|
|
1437
1463
|
property({ type: String }),
|
|
1438
1464
|
__metadata("design:type", String)
|
|
1439
1465
|
], ItUploadDragDrop.prototype, "illustration", void 0);
|
|
1466
|
+
__decorate([
|
|
1467
|
+
property({ type: String, attribute: 'heading-level' }),
|
|
1468
|
+
__metadata("design:type", String)
|
|
1469
|
+
], ItUploadDragDrop.prototype, "headingLevel", void 0);
|
|
1440
1470
|
__decorate([
|
|
1441
1471
|
state(),
|
|
1442
1472
|
__metadata("design:type", Object)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"it-upload-drag-drop.js","sources":["../../../src/it-upload-drag-drop.ts"],"sourcesContent":["/* eslint-disable class-methods-use-this */\nimport { FormControl, FormControlController } from '@italia/globals';\nimport { registerTranslation } from '@italia/i18n';\nimport { html, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport it from './locales/it.js';\nimport en from './locales/en.js';\nimport styles from './upload-drag-drop.scss';\nimport { formatSize } from './utils.js';\n\nregisterTranslation(it);\nregisterTranslation(en);\n\ntype DragDropState = 'idle' | 'dragover' | 'loading' | 'success';\n\n// Base64‑encoded copy of bootstrap-italia/dist/assets/upload-drag-drop-icon.svg\n// bundled inline so the component works standalone without a public assets path.\nconst DRAG_DROP_ICON_SRC =\n 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTgwcHgiIGhlaWdodD0iMTgwcHgiIHZpZXdCb3g9IjAgMCAxODAgMTgwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPHRpdGxlPmljb248L3RpdGxlPgogICAgPGcgaWQ9IlVwbG9hZCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAg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1OSA4OS4xODY5MTEsMjUuOTIxNjgxNSA4OS4wOTQwMzk3LDE5Ljg1NDUzODIgQzg5LjA5MzE4MTgsMTkuNzk4NDg5NSA4OS4wOTI3NTI4LDE5Ljc0MjQzNTEgODkuMDkyNzUyOCwxOS42ODYzNzk5IEw4OS4wOTI3NTI4LDAuODQyNjY2NjQ3IFoiIGZpbGw9IiNGRkZGRkYiPjwvcGF0aD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+';\n\n@customElement('it-upload-drag-drop')\nexport class ItUploadDragDrop extends FormControl {\n static styles = styles;\n\n // Override the base FormControlController: value is the selected File.\n protected override readonly formControlController: FormControlController = new FormControlController(this, {\n value: (el) => (el as ItUploadDragDrop)._currentFile,\n assumeInteractionOn: ['it-change'],\n });\n\n @query('.it-form__control')\n override inputElement!: HTMLInputElement;\n\n /** Accepted file types, e.g. \"image/*,.pdf\" */\n @property({ type: String })\n accept?: string;\n\n /** Custom illustration URL. If not set, the built-in illustration is used. */\n @property({ type: String })\n illustration?: string;\n\n /** The currently selected File (null until file is chosen/dropped). */\n @state()\n private _currentFile: File | null = null;\n\n @state()\n private _state: DragDropState = 'idle';\n\n @state()\n private _progress = 0;\n\n @state()\n private _fileName = '';\n\n @state()\n private _fileWeight = '';\n\n @state()\n private _fileType = '';\n\n @state()\n private _indeterminate = false;\n\n private _autoStarted = false;\n\n private get _formClass(): string {\n return this.composeClass(\n 'upload-dragdrop',\n this._state === 'dragover' ? 'dragover' : '',\n this._state === 'loading' ? 'loading' : '',\n this._state === 'success' ? 'success' : '',\n );\n }\n\n /** Advance the donut progress. Value must be between 0 and 1. */\n public progress(value: number) {\n this._indeterminate = false;\n const clamped = Math.min(1, Math.max(0, value));\n this._progress = Math.round(clamped * 100);\n }\n\n /** Transition to the loading state, starting the progress animation. */\n public start() {\n this._state = 'loading';\n }\n\n /** Mark upload as successful. */\n public success() {\n this._state = 'success';\n }\n\n /** Reset to idle state with progress at 0. */\n public reset() {\n this._state = 'idle';\n this._progress = 0;\n this._indeterminate = false;\n this._autoStarted = false;\n this._fileName = '';\n this._fileWeight = '';\n this._fileType = '';\n this._currentFile = null;\n }\n\n private _extractFileType(fileName: string): string {\n const ext = fileName.split('.').pop();\n return ext ? ext.toUpperCase() : '';\n }\n\n private _preventEvent(e: DragEvent) {\n e.preventDefault();\n e.stopPropagation();\n }\n\n private _onDragEnter(e: DragEvent) {\n this._preventEvent(e);\n if (this.disabled || this._state === 'success' || this._state === 'loading') return;\n const cancelled = !this.dispatchEvent(\n new CustomEvent('it-dd-start', {\n cancelable: true,\n bubbles: true,\n composed: true,\n detail: {},\n }),\n );\n if (!cancelled) {\n this.start();\n this._autoStarted = true;\n } else {\n this._state = 'dragover';\n }\n }\n\n private _onDragOver(e: DragEvent) {\n e.preventDefault();\n if (this.disabled || this._state === 'success') return;\n if (this._state === 'idle') this._state = 'dragover';\n }\n\n private _onDragLeave(e: DragEvent) {\n this._preventEvent(e);\n if (this.disabled) return;\n if (this._state === 'dragover') {\n this._state = 'idle';\n } else if (this._state === 'loading' && this._autoStarted && !this._currentFile) {\n this._state = 'idle';\n this._autoStarted = false;\n }\n }\n\n private _onDragEnd(e: DragEvent) {\n this._preventEvent(e);\n if (this.disabled) return;\n if (this._state === 'dragover') {\n this._state = 'idle';\n }\n }\n\n private _onDrop(e: DragEvent) {\n this._preventEvent(e);\n if (this.disabled || this._state === 'success') return;\n\n const file = e.dataTransfer?.files?.[0];\n if (!file) return;\n\n this._currentFile = file;\n this._fileName = file.name;\n this._fileWeight = formatSize(file.size);\n this._fileType = this._extractFileType(file.name);\n this._autoStarted = false;\n\n const dropCancelled = !this.dispatchEvent(\n new CustomEvent('it-dd-drop', {\n cancelable: true,\n bubbles: true,\n composed: true,\n detail: { file, name: this.name, id: this.id },\n }),\n );\n if (!dropCancelled) {\n if (this._state !== 'loading') this.start();\n this._indeterminate = true;\n }\n\n this.dispatchEvent(\n new CustomEvent('it-change', {\n detail: { file, name: this.name, id: this.id },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _onFileInputChange(e: Event) {\n const input = e.target as HTMLInputElement;\n const file = input.files?.[0];\n if (!file) return;\n\n this._currentFile = file;\n this._fileName = file.name;\n this._fileWeight = formatSize(file.size);\n this._fileType = this._extractFileType(file.name);\n input.value = '';\n\n const dropCancelled = !this.dispatchEvent(\n new CustomEvent('it-dd-drop', {\n cancelable: true,\n bubbles: true,\n composed: true,\n detail: { file, name: this.name, id: this.id },\n }),\n );\n if (!dropCancelled) {\n this.start();\n this._indeterminate = true;\n }\n\n this.dispatchEvent(\n new CustomEvent('it-change', {\n detail: { file, name: this.name, id: this.id },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _getStatusText(): string {\n switch (this._state) {\n case 'dragover':\n return this.$t('upload_dd_status_dragover');\n case 'loading':\n return this.$t('upload_dd_status_loading');\n case 'success':\n return this.$t('upload_dd_status_success');\n default:\n return '';\n }\n }\n\n private _renderTextContent() {\n const hasFile = this._fileName.length > 0;\n\n // Title: slot or default per state\n const titleText = hasFile ? this._fileName : this.$t('upload_dd_title');\n\n return html`\n <div class=\"upload-dragdrop-text\">\n ${hasFile && this._fileWeight\n ? html`\n <p class=\"upload-dragdrop-weight\">\n <it-icon name=\"it-file\" size=\"xs\" aria-hidden=\"true\" color=\"secondary\"></it-icon>\n <span>${this._fileType ? `${this._fileType} ` : ''}(${this._fileWeight})</span>\n </p>\n `\n : nothing}\n <h5>\n <slot name=\"title\">${titleText}</slot>\n </h5>\n ${this._state === 'idle' || this._state === 'dragover'\n ? html`\n <p>\n <slot name=\"description\">${this.$t('upload_dd_description')}</slot>\n </p>\n <p>\n <input\n type=\"file\"\n class=\"upload-dragdrop-input\"\n id=\"${this._id!}\"\n accept=\"${ifDefined(this.accept)}\"\n ?disabled=\"${this.disabled}\"\n aria-label=\"${this.$t('upload_label')}\"\n @change=\"${this._onFileInputChange}\"\n />\n <label for=\"${this._id!}\">${this.$t('upload_dd_select')}</label>\n </p>\n `\n : nothing}\n ${this._state === 'loading' ? html`<p>${this.$t('upload_dd_status_loading')}</p>` : nothing}\n ${this._state === 'success' ? html`<p>${this.$t('upload_dd_status_success')}</p>` : nothing}\n </div>\n `;\n }\n\n override render() {\n const statusText = this._getStatusText();\n const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;\n\n return html`\n <div\n part=\"drop-zone\"\n class=\"${this._formClass}\"\n @drag=\"${this._preventEvent}\"\n @dragstart=\"${this._preventEvent}\"\n @dragend=\"${this._onDragEnd}\"\n @dragover=\"${this._onDragOver}\"\n @dragenter=\"${this._onDragEnter}\"\n @dragleave=\"${this._onDragLeave}\"\n @drop=\"${this._onDrop}\"\n >\n <div class=\"upload-dragdrop-image\">\n <img src=\"${this.illustration ?? DRAG_DROP_ICON_SRC}\" alt=\"\" aria-hidden=\"true\" width=\"180\" height=\"180\" />\n <div class=\"upload-dragdrop-loading\" aria-hidden=\"${this._state !== 'loading' ? 'true' : nothing}\">\n <it-progress\n type=\"donut\"\n .value=\"${this._indeterminate ? 0 : this._progress}\"\n it-aria-label=\"${this.$t('upload_dd_progress_label')}\"\n ?show-value=\"${!this._indeterminate}\"\n ></it-progress>\n </div>\n <div class=\"upload-dragdrop-success\" aria-hidden=\"${this._state !== 'success' ? 'true' : nothing}\">\n <it-icon name=\"it-check\" aria-hidden=\"true\" color=\"inverse\"></it-icon>\n </div>\n </div>\n\n ${this._renderTextContent()}\n\n <!-- Accessible live region for state announcements -->\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" class=\"visually-hidden\">${statusText}</div>\n </div>\n\n <!-- Hidden proxy input: drives native required/validity checking via FormControl base class -->\n <input\n type=\"text\"\n class=\"it-form__control\"\n .value=\"${this._currentFile?.name || ''}\"\n ?required=\"${this.required}\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n />\n\n <div class=\"invalid-feedback form-feedback form-text just-validate-error-label\" role=\"alert\">\n ${isInvalid ? this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EAAA,WAAA,EAAA,MAAA,CAAA;AAGd,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACe,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAGf,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACiB,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAGjB,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACe,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAGf,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACuB,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AAxCpB,gBAAgB,GAAA,UAAA,CAAA;IAD5B,aAAa,CAAC,qBAAqB;AACvB,CAAA,EAAA,gBAAgB,CAyT5B;;;;"}
|
|
1
|
+
{"version":3,"file":"it-upload-drag-drop.js","sources":["../../../src/types.ts","../../../src/it-upload-drag-drop.ts"],"sourcesContent":["export type UploadFileStatus = 'loading' | 'success' | 'error';\n\nexport const DRAG_DROP_HEADING_LEVELS = ['h2', 'h3', 'h4', 'h5', 'h6'] as const;\nexport type DragDropHeadingLevel = (typeof DRAG_DROP_HEADING_LEVELS)[number];\n\nexport type UploadVariant = 'default' | 'gallery';\n\nexport interface UploadFile {\n id: string;\n name: string;\n size: number;\n status: UploadFileStatus;\n progress?: number;\n thumbnail?: string;\n}\n\n/** Internal representation that also carries the raw File reference */\nexport interface UploadInternalFile extends UploadFile {\n _raw: File;\n}\n","/* eslint-disable class-methods-use-this */\nimport { FormControl, FormControlController } from '@italia/globals';\nimport { registerTranslation } from '@italia/i18n';\nimport { html, nothing } from 'lit';\nimport { html as staticHtml, unsafeStatic } from 'lit/static-html.js';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport it from './locales/it.js';\nimport en from './locales/en.js';\nimport styles from './upload-drag-drop.scss';\nimport { formatSize } from './utils.js';\nimport { type DragDropHeadingLevel, DRAG_DROP_HEADING_LEVELS } from './types.js';\n\nregisterTranslation(it);\nregisterTranslation(en);\n\ntype DragDropState = 'idle' | 'dragover' | 'loading' | 'success';\n\n// Base64‑encoded copy of bootstrap-italia/dist/assets/upload-drag-drop-icon.svg\n// bundled inline so the component works standalone without a public assets path.\nconst DRAG_DROP_ICON_SRC =\n 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTgwcHgiIGhlaWdodD0iMTgwcHgiIHZpZXdCb3g9IjAgMCAxODAgMTgwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPHRpdGxlPmljb248L3RpdGxlPgogICAgPGcgaWQ9IlVwbG9hZCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IkFydGJvYXJkIj4KICAgICAgICAgICAgPGcgaWQ9Imljb24iPgogICAgICAgICAgICAgICAgPHJlY3QgaWQ9IlJlY3RhbmdsZSIgZmlsbD0iI0QxRTdGRiIgeD0iMCIgeT0iMCIgd2lkdGg9IjE4MCIgaGVpZ2h0PSIxODAiPjwvcmVjdD4KICAgICAgICAgICAgICAgIDxnIGlkPSJHcm91cC02LUNvcHkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEwNy44NTUxNzUsIDEwOS43MDIyNDgpIHJvdGF0ZSgtMTApIHRyYW5zbGF0ZSgtMTA3Ljg1NTE3NSwgLTEwOS43MDIyNDgpIHRyYW5zbGF0ZSg0OC4zNTUxNzUsIDM1LjIwMjI0OCkiPg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xsLXJ1bGU9Im5vbnplcm8iIHBvaW50cz0iMjAuMzkzMjQ1OCAxMDcuNjAwMDI4IDIwLjM5MzI0NTggOTkuMDk2MDkwNiA5OS44OTcxODI4IDk5LjA5NjA5MDYgOTkuODk3MTgyOCAxMDcuNjAwMDI4Ij48L3BvbHlnb24+CiAgICAgICAgICAgICAgICAgICAgPHBvbHlnb24gZmlsbD0iIzAwNTlCMyIgb3BhY2l0eT0iMC4yIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMDUuNDQ5MzYxLCA0MC42MTA1MzUpIHNjYWxlKC0xLCAxKSByb3RhdGUoOTApIHRyYW5zbGF0ZSgtMTA1LjQ0OTM2MSwgLTQwLjYxMDUzNSkiIHBvaW50cz0iOTIuMzA0MDQyMiAyNy40NzUwNDA5IDExOC41OTQ2ODEgNTMuNzQ2MDI5NiA5NS4yNDY0MDUyIDUzLjczNzc1ODkiPjwvcG9seWdvbj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNODkuMDkyNzUyOCwwLjg0MjY2NjY0NyBMMTE4LjU2MDYyNSwzMC4zOTE1OTQ3IEwxMDAuMjQ3NzMzLDMwLjY3MTkxNDYgQzk0LjE4MDU4OTQsMzAuNzY0Nzg1OSA4OS4xODY5MTEsMjUuOTIxNjgxNSA4OS4wOTQwMzk3LDE5Ljg1NDUzODIgQzg5LjA5MzE4MTgsMTkuNzk4NDg5NSA4OS4wOTI3NTI4LDE5Ljc0MjQzNTEgODkuMDkyNzUyOCwxOS42ODYzNzk5IEw4OS4wOTI3NTI4LDAuODQyNjY2NjQ3IFoiIGZpbGw9IiNGRkZGRkYiPjwvcGF0aD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+';\n\n@customElement('it-upload-drag-drop')\nexport class ItUploadDragDrop extends FormControl {\n static styles = styles;\n\n // Override the base FormControlController: value is the selected File.\n protected override readonly formControlController: FormControlController = new FormControlController(this, {\n value: (el) => (el as ItUploadDragDrop)._currentFile,\n assumeInteractionOn: ['it-change'],\n });\n\n @query('.it-form__control')\n override inputElement!: HTMLInputElement;\n\n /** Accepted file types, e.g. \"image/*,.pdf\" */\n @property({ type: String })\n accept?: string;\n\n /** Custom illustration URL. If not set, the built-in illustration is used. */\n @property({ type: String })\n illustration?: string;\n\n /** Heading level for the title element. Defaults to 'h5'; visual size stays at h5. */\n @property({ type: String, attribute: 'heading-level' })\n headingLevel: DragDropHeadingLevel = 'h5';\n\n /** The currently selected File (null until file is chosen/dropped). */\n @state()\n private _currentFile: File | null = null;\n\n @state()\n private _state: DragDropState = 'idle';\n\n @state()\n private _progress = 0;\n\n @state()\n private _fileName = '';\n\n @state()\n private _fileWeight = '';\n\n @state()\n private _fileType = '';\n\n @state()\n private _indeterminate = false;\n\n private _autoStarted = false;\n\n protected getHeadingLevel(): DragDropHeadingLevel {\n return DRAG_DROP_HEADING_LEVELS.includes(this.headingLevel) ? this.headingLevel : 'h5';\n }\n\n private get _formClass(): string {\n return this.composeClass(\n 'upload-dragdrop',\n this._state === 'dragover' ? 'dragover' : '',\n this._state === 'loading' ? 'loading' : '',\n this._state === 'success' ? 'success' : '',\n );\n }\n\n /** Advance the donut progress. Value must be between 0 and 1. */\n public progress(value: number) {\n this._indeterminate = false;\n const clamped = Math.min(1, Math.max(0, value));\n this._progress = Math.round(clamped * 100);\n }\n\n /** Transition to the loading state, starting the progress animation. */\n public start() {\n this._state = 'loading';\n }\n\n /** Mark upload as successful. */\n public success() {\n this._state = 'success';\n }\n\n /** Reset to idle state with progress at 0. */\n public reset() {\n this._state = 'idle';\n this._progress = 0;\n this._indeterminate = false;\n this._autoStarted = false;\n this._fileName = '';\n this._fileWeight = '';\n this._fileType = '';\n this._currentFile = null;\n }\n\n private _extractFileType(fileName: string): string {\n const ext = fileName.split('.').pop();\n return ext ? ext.toUpperCase() : '';\n }\n\n private _preventEvent(e: DragEvent) {\n e.preventDefault();\n e.stopPropagation();\n }\n\n private _onDragEnter(e: DragEvent) {\n this._preventEvent(e);\n if (this.disabled || this._state === 'success' || this._state === 'loading') return;\n const cancelled = !this.dispatchEvent(\n new CustomEvent('it-dd-start', {\n cancelable: true,\n bubbles: true,\n composed: true,\n detail: {},\n }),\n );\n if (!cancelled) {\n this.start();\n this._autoStarted = true;\n } else {\n this._state = 'dragover';\n }\n }\n\n private _onDragOver(e: DragEvent) {\n e.preventDefault();\n if (this.disabled || this._state === 'success') return;\n if (this._state === 'idle') this._state = 'dragover';\n }\n\n private _onDragLeave(e: DragEvent) {\n this._preventEvent(e);\n if (this.disabled) return;\n if (this._state === 'dragover') {\n this._state = 'idle';\n } else if (this._state === 'loading' && this._autoStarted && !this._currentFile) {\n this._state = 'idle';\n this._autoStarted = false;\n }\n }\n\n private _onDragEnd(e: DragEvent) {\n this._preventEvent(e);\n if (this.disabled) return;\n if (this._state === 'dragover') {\n this._state = 'idle';\n }\n }\n\n private _onDrop(e: DragEvent) {\n this._preventEvent(e);\n if (this.disabled || this._state === 'success') return;\n\n const file = e.dataTransfer?.files?.[0];\n if (!file) return;\n\n this._currentFile = file;\n this._fileName = file.name;\n this._fileWeight = formatSize(file.size);\n this._fileType = this._extractFileType(file.name);\n this._autoStarted = false;\n\n const dropCancelled = !this.dispatchEvent(\n new CustomEvent('it-dd-drop', {\n cancelable: true,\n bubbles: true,\n composed: true,\n detail: { file, name: this.name, id: this.id },\n }),\n );\n if (!dropCancelled) {\n if (this._state !== 'loading') this.start();\n this._indeterminate = true;\n }\n\n this.dispatchEvent(\n new CustomEvent('it-change', {\n detail: { file, name: this.name, id: this.id },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _onFileInputChange(e: Event) {\n const input = e.target as HTMLInputElement;\n const file = input.files?.[0];\n if (!file) return;\n\n this._currentFile = file;\n this._fileName = file.name;\n this._fileWeight = formatSize(file.size);\n this._fileType = this._extractFileType(file.name);\n input.value = '';\n\n const dropCancelled = !this.dispatchEvent(\n new CustomEvent('it-dd-drop', {\n cancelable: true,\n bubbles: true,\n composed: true,\n detail: { file, name: this.name, id: this.id },\n }),\n );\n if (!dropCancelled) {\n this.start();\n this._indeterminate = true;\n }\n\n this.dispatchEvent(\n new CustomEvent('it-change', {\n detail: { file, name: this.name, id: this.id },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _getStatusText(): string {\n switch (this._state) {\n case 'dragover':\n return this.$t('upload_dd_status_dragover');\n case 'loading':\n return this.$t('upload_dd_status_loading');\n case 'success':\n return this.$t('upload_dd_status_success');\n default:\n return '';\n }\n }\n\n private _renderTextContent() {\n const hasFile = this._fileName.length > 0;\n\n // Title: slot or default per state\n const titleText = hasFile ? this._fileName : this.$t('upload_dd_title');\n const fileInputLabel = this.required ? this.$t('upload_label') : this.$t('upload_label');\n const canSelect = this._state === 'idle' || this._state === 'dragover';\n const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;\n const feedbackId = `invalid-feedback-${this._id}`;\n const headingTag = unsafeStatic(this.getHeadingLevel());\n\n return html`\n <div class=\"upload-dragdrop-text\">\n ${hasFile && this._fileWeight\n ? html`\n <p class=\"upload-dragdrop-weight\">\n <it-icon name=\"it-file\" size=\"xs\" aria-hidden=\"true\" color=\"secondary\"></it-icon>\n <span>${this._fileType ? `${this._fileType} ` : ''}(${this._fileWeight})</span>\n </p>\n `\n : nothing}\n ${staticHtml`<${headingTag} class=\"h5\">\n <slot name=\"title\">${titleText}</slot>\n </${headingTag}>`} ${canSelect\n ? html`\n <p>\n <slot name=\"description\">${this.$t('upload_dd_description')}</slot>\n </p>\n `\n : nothing}\n <!-- The file input is the form-control validity participant, so it must exist in every\n state for the FormControl base class to read its validity. It is the real focusable\n control native required/validity now anchors to (no hidden proxy). The select affordance\n (label) and this wrapper are hidden via CSS in loading/success states. -->\n <p class=\"upload-dragdrop-select-wrap\">\n <input\n type=\"file\"\n class=\"upload-dragdrop-input it-form__control\"\n id=\"${this._id!}\"\n accept=\"${ifDefined(this.accept)}\"\n ?disabled=\"${this.disabled}\"\n ?required=\"${this.required && !this._currentFile}\"\n aria-label=\"${fileInputLabel}\"\n aria-required=\"${this.required ? 'true' : nothing}\"\n aria-invalid=\"${isInvalid ? 'true' : 'false'}\"\n aria-describedby=\"${ifDefined(isInvalid ? feedbackId : undefined)}\"\n @change=\"${this._onFileInputChange}\"\n />\n ${canSelect ? html`<label for=\"${this._id!}\">${this.$t('upload_dd_select')}</label>` : nothing}\n </p>\n ${this._state === 'loading' ? html`<p>${this.$t('upload_dd_status_loading')}</p>` : nothing}\n ${this._state === 'success' ? html`<p>${this.$t('upload_dd_status_success')}</p>` : nothing}\n </div>\n `;\n }\n\n override render() {\n const statusText = this._getStatusText();\n const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;\n const feedbackId = `invalid-feedback-${this._id}`;\n\n return html`\n <div\n part=\"drop-zone\"\n class=\"${this._formClass}\"\n @drag=\"${this._preventEvent}\"\n @dragstart=\"${this._preventEvent}\"\n @dragend=\"${this._onDragEnd}\"\n @dragover=\"${this._onDragOver}\"\n @dragenter=\"${this._onDragEnter}\"\n @dragleave=\"${this._onDragLeave}\"\n @drop=\"${this._onDrop}\"\n >\n <div class=\"upload-dragdrop-image\">\n <img src=\"${this.illustration ?? DRAG_DROP_ICON_SRC}\" alt=\"\" aria-hidden=\"true\" width=\"180\" height=\"180\" />\n <div class=\"upload-dragdrop-loading\" aria-hidden=\"${this._state !== 'loading' ? 'true' : nothing}\">\n <it-progress\n type=\"donut\"\n .value=\"${this._indeterminate ? 0 : this._progress}\"\n it-aria-label=\"${this.$t('upload_dd_progress_label')}\"\n ?show-value=\"${!this._indeterminate}\"\n ></it-progress>\n </div>\n <div class=\"upload-dragdrop-success\" aria-hidden=\"${this._state !== 'success' ? 'true' : nothing}\">\n <it-icon name=\"it-check\" aria-hidden=\"true\" color=\"inverse\"></it-icon>\n </div>\n </div>\n\n ${this._renderTextContent()}\n\n <!-- Accessible live region for state announcements -->\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" class=\"visually-hidden\">${statusText}</div>\n </div>\n\n <div\n id=\"${feedbackId}\"\n class=\"invalid-feedback form-feedback form-text just-validate-error-label\"\n role=\"alert\"\n ?hidden=${!isInvalid}\n >\n ${isInvalid ? this.validationMessage : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'it-upload-drag-drop': ItUploadDragDrop;\n }\n}\n"],"names":["it","en","staticHtml"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAG/B,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACc,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAGd,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACe,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAGf,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACiB,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAGjB,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACe,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAGf,UAAA,CAAA;AADP,IAAA,KAAK,EAAE;;AACuB,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AA5CpB,gBAAgB,GAAA,UAAA,CAAA;IAD5B,aAAa,CAAC,qBAAqB;AACvB,CAAA,EAAA,gBAAgB,CAyU5B;;;;"}
|
package/dist/src/it-upload.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as registerTranslation, t as translation, a as translation$1, _ as __decorate, b as __metadata, F as FormControl, c as FormControlController } from '../en-
|
|
1
|
+
import { r as registerTranslation, t as translation, a as translation$1, _ as __decorate, b as __metadata, F as FormControl, c as FormControlController } from '../en-bhgshDbO.js';
|
|
2
2
|
import { css, html, nothing } from 'lit';
|
|
3
3
|
import { query, queryAssignedElements, property, state, customElement } from 'lit/decorators.js';
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type UploadFileStatus = 'loading' | 'success' | 'error';
|
|
2
|
+
export declare const DRAG_DROP_HEADING_LEVELS: readonly ["h2", "h3", "h4", "h5", "h6"];
|
|
3
|
+
export type DragDropHeadingLevel = (typeof DRAG_DROP_HEADING_LEVELS)[number];
|
|
2
4
|
export type UploadVariant = 'default' | 'gallery';
|
|
3
5
|
export interface UploadFile {
|
|
4
6
|
id: string;
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;AAElD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uEAAuE;AACvE,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,IAAI,EAAE,IAAI,CAAC;CACZ"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/D,eAAO,MAAM,wBAAwB,yCAA0C,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;AAElD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uEAAuE;AACvE,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,IAAI,EAAE,IAAI,CAAC;CACZ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@italia/upload",
|
|
3
3
|
"description": "Web components it-upload, it-upload-avatar, it-upload-drag-drop del Design system .italia",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.18",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"bootstrap-italia": "3.0.0-beta.1",
|
|
40
40
|
"lit": "^3.3.0",
|
|
41
|
-
"@italia/globals": "^1.0.0-alpha.
|
|
42
|
-
"@italia/i18n": "^1.0.0-alpha.
|
|
41
|
+
"@italia/globals": "^1.0.0-alpha.18",
|
|
42
|
+
"@italia/i18n": "^1.0.0-alpha.18"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@italia/icon": "^1.0.0-alpha.
|
|
46
|
-
"@italia/avatar": "^1.0.0-alpha.
|
|
47
|
-
"@italia/progress": "^1.0.0-alpha.
|
|
45
|
+
"@italia/icon": "^1.0.0-alpha.18",
|
|
46
|
+
"@italia/avatar": "^1.0.0-alpha.18",
|
|
47
|
+
"@italia/progress": "^1.0.0-alpha.18"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@custom-elements-manifest/analyzer": "^0.10.3",
|