@italia/upload 1.0.0-alpha.9 → 1.0.0-beta.1

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.
@@ -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;AAqBrE,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,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,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;IA4CjB,MAAM;CAoDhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,qBAAqB,EAAE,gBAAgB,CAAC;KACzC;CACF"}
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,EAAsB,MAAM,iBAAiB,CAAC;AAWzF,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;IAYpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,OAAO;IA2Bf,OAAO,CAAC,kBAAkB;IAyB1B,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,kBAAkB;IA0DjB,MAAM;CA4ChB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,qBAAqB,EAAE,gBAAgB,CAAC;KACzC;CACF"}
@@ -1,24 +1,55 @@
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-A2XDPVTm.js';
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-BVfEYZab.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';
6
7
  import 'lit/directive.js';
7
8
 
9
+ /**
10
+ * Dispatches a cancelable custom event and runs the provided default action
11
+ * only if the consumer did not call `event.preventDefault()`.
12
+ *
13
+ * This is the shared convention used across components (Tabs, Modal, Chip, Alert,
14
+ * Forward, Back) to provide a sensible default JavaScript behavior out of the box
15
+ * while letting consumers intercept and override it. Notification deliberately does
16
+ * NOT use this: its show/close are always caller-initiated (no default markup-driven
17
+ * trigger to override), so there was no real use case for blocking them — see
18
+ * it-notification.ts for the plain (non-cancelable) events it fires instead.
19
+ *
20
+ * ```js
21
+ * el.addEventListener('it-alert-close', (e) => {
22
+ * e.preventDefault(); // block the default removal
23
+ * fetchConfirmation().then((ok) => { // async logic runs after prevention
24
+ * if (ok) e.target.close();
25
+ * });
26
+ * });
27
+ * ```
28
+ *
29
+ * Note: `preventDefault()` must be called synchronously inside the listener.
30
+ * Async code can run afterward; call the component's public method when ready.
31
+ *
32
+ * @param host the element dispatching the event
33
+ * @param name the event name (kebab-case, `it-` prefixed)
34
+ * @param detail the event `detail` payload
35
+ * @param defaultAction the behavior executed when the event is not prevented
36
+ * @returns the dispatched event (inspect `defaultPrevented` if needed)
37
+ */
38
+ function dispatchCancelable(host, name, detail, defaultAction) {
39
+ const event = new CustomEvent(name, {
40
+ bubbles: true,
41
+ composed: true,
42
+ cancelable: true,
43
+ detail,
44
+ });
45
+ host.dispatchEvent(event);
46
+ if (!event.defaultPrevented) {
47
+ defaultAction();
48
+ }
49
+ return event;
50
+ }
51
+
8
52
  var styles = css`@charset "UTF-8";
9
- /***************************** 1 ****************************************/
10
- /***************************** 2 ****************************************/
11
- /***************************** 1 ****************************************/
12
- /***************************** 2 ****************************************/
13
- /***************************** 1 ****************************************/
14
- /***************************** 2 ****************************************/
15
- /***************************** 3 ****************************************/
16
- /***************************** 1 ****************************************/
17
- /***************************** 2 ****************************************/
18
- /***************************** 3 ****************************************/
19
- /***************************** NEUTRAL 1 ****************************************/
20
- /***************************** NEUTRAL 2 ****************************************/
21
- /***************************** NEUTRAL 2 / 3 ****************************************/
22
53
  *,
23
54
  *::before,
24
55
  *::after {
@@ -519,6 +550,10 @@ progress {
519
550
  overflow: hidden;
520
551
  }
521
552
 
553
+ .avatar-upload-wrapper {
554
+ position: relative;
555
+ display: inline-block;
556
+ }
522
557
  .avatar-upload-wrapper .avatar-upload-icon {
523
558
  position: absolute;
524
559
  right: 4px;
@@ -526,30 +561,23 @@ progress {
526
561
  display: flex;
527
562
  align-items: center;
528
563
  justify-content: center;
529
- width: 26px;
530
- height: 26px;
564
+ width: 32px;
565
+ height: 32px;
531
566
  border: 2px solid var(--bsi-color-border-inverse);
532
567
  border-radius: 50%;
533
568
  background: hsl(210, 6.2290689886%, 92.535%);
534
569
  pointer-events: none;
535
- }
536
- .avatar-upload-wrapper .avatar-upload-icon > svg {
537
- width: 16px;
538
- height: 16px;
570
+ z-index: 1;
539
571
  }
540
572
  .avatar-upload-wrapper.size-sm .avatar {
541
573
  width: 80px;
542
574
  height: 80px;
543
575
  }
544
576
  .avatar-upload-wrapper.size-sm .avatar-upload-icon {
545
- right: 4px;
546
- bottom: 6px;
547
- width: 18px;
548
- height: 18px;
549
- }
550
- .avatar-upload-wrapper.size-sm .avatar-upload-icon > svg {
551
- width: 12px;
552
- height: 12px;
577
+ right: 6px;
578
+ bottom: 8px;
579
+ width: 24px;
580
+ height: 24px;
553
581
  }
554
582
 
555
583
  .upload-dragdrop {
@@ -770,9 +798,6 @@ progress {
770
798
  margin-top: 0.25rem;
771
799
  font-size: 0.75rem;
772
800
  }
773
- .form-feedback.just-validate-error-label {
774
- color: var(--bsi-color-text-danger);
775
- }
776
801
 
777
802
  .input-group-text:has(~ [data-focus-mouse=true]:not(.btn)),
778
803
  [data-focus-mouse=true]:not(.btn) ~ .input-group-text,
@@ -794,20 +819,44 @@ button:has(~ .is-invalid),
794
819
  display: none;
795
820
  }
796
821
 
797
- .just-validate-success-field {
798
- border-color: var(--bsi-color-border-success) !important;
822
+ .is-valid,
823
+ .is-invalid {
799
824
  padding-right: calc(1.5em + 0.75rem) !important;
800
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23008055' viewBox='0 0 192 512'%3E%3Cpath d='M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z'/%3E%3C/svg%3E");
825
+ }
826
+ .is-valid[type=number],
827
+ .is-invalid[type=number] {
828
+ padding-right: calc(1.5em + 0.75rem + var(--bsi-form-control-spacing) + 1rem) !important;
801
829
  }
802
830
 
803
- .input-group-text:has(~ .just-validate-success-field),
804
- .just-validate-success-field ~ .input-group-text,
805
- button:has(~ .just-validate-success-field),
806
- .just-validate-success-field + button {
831
+ .was-validated &:valid,
832
+ .is-valid {
833
+ border-color: var(--bsi-color-border-success) !important;
834
+ background-image: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="%23008055" xmlns="http://www.w3.org/2000/svg"><path d="M9.6,16.9L4,11.4l0.8-0.7l4.8,4.8l8.5-8.4l0.7,0.7L9.6,16.9z" /></svg>');
835
+ }
836
+ .was-validated &:valid ~ .warning-feedback,
837
+ .is-valid ~ .warning-feedback {
838
+ display: block;
839
+ }
840
+
841
+ .was-validated &:invalid,
842
+ .is-invalid {
843
+ border-color: var(--bsi-color-border-danger) !important;
844
+ background-image: url('data:image/svg+xml,<svg width="24" fill="%23cc334d" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.7,12l6.7,6.6l-0.8,0.8L12,12.7l-6.6,6.7l-0.8-0.8l6.7-6.6L4.6,5.4l0.8-0.8l6.6,6.7l6.6-6.7l0.8,0.8L12.7,12z" /></svg>');
845
+ }
846
+
847
+ .form-control.warning {
848
+ border-color: var(--bsi-color-border-warning) !important;
849
+ background-image: url('data:image/svg+xml,<svg width="24" height="24" fill="%23995c00" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.5,17h-1V2h1V17z M12.5,20h-1v2h1V20z" /></svg>');
850
+ }
851
+
852
+ .input-group-text:has(~ .is-valid),
853
+ .is-valid ~ .input-group-text,
854
+ button:has(~ .is-valid),
855
+ .is-valid + button {
807
856
  border-color: var(--bsi-color-border-success);
808
857
  }
809
858
 
810
- .just-validate-success-field + .input-group-text.align-buttons,
859
+ .is-valid + .input-group-text.align-buttons,
811
860
  .is-invalid + .input-group-text.align-buttons {
812
861
  right: 30px;
813
862
  }
@@ -816,33 +865,12 @@ button:has(~ .just-validate-success-field),
816
865
  bottom: 22px;
817
866
  }
818
867
 
819
- .autocomplete__wrapper .form-feedback.just-validate-error-label {
868
+ .autocomplete__wrapper .form-feedback {
820
869
  position: absolute;
821
870
  }
822
871
 
823
872
  textarea.form-control {
824
- background-position: top 0.3em right 0.3em !important;
825
- background-size: 37px 30% !important;
826
- }
827
- textarea.is-invalid {
828
- border-bottom-style: solid;
829
- border-bottom-width: 1px;
830
- }
831
- textarea.just-validate-success-field {
832
- border-bottom-style: solid;
833
- border-bottom-width: 1px;
834
- }
835
-
836
- input[type=checkbox].is-invalid,
837
- input[type=radio].is-invalid {
838
- --bsi-form-checkbox-border-color: var(--bsi-color-border-danger);
839
- }
840
-
841
- select.is-invalid {
842
- border: 1px solid var(--bsi-color-border-danger);
843
- }
844
- select.just-validate-success-field {
845
- border: 1px solid var(--bsi-color-border-success);
873
+ background-position: top 0.5em right !important;
846
874
  }
847
875
 
848
876
  body {
@@ -1142,11 +1170,132 @@ blockquote.blockquote-card.dark .blockquote-footer,
1142
1170
  text-transform: uppercase;
1143
1171
  }
1144
1172
 
1173
+ .text-primary {
1174
+ --bsi-text-opacity: 1;
1175
+ color: rgba(var(--bsi-primary-rgb), var(--bsi-text-opacity)) !important;
1176
+ }
1177
+
1178
+ .text-secondary {
1179
+ --bsi-text-opacity: 1;
1180
+ color: hsl(210, 33%, 28%) !important;
1181
+ }
1182
+
1183
+ .text-success {
1184
+ --bsi-text-opacity: 1;
1185
+ color: rgba(var(--bsi-success-rgb), var(--bsi-text-opacity)) !important;
1186
+ }
1187
+
1188
+ .text-info {
1189
+ --bsi-text-opacity: 1;
1190
+ color: rgba(var(--bsi-info-rgb), var(--bsi-text-opacity)) !important;
1191
+ }
1192
+
1193
+ .text-warning {
1194
+ --bsi-text-opacity: 1;
1195
+ color: rgba(var(--bsi-warning-rgb), var(--bsi-text-opacity)) !important;
1196
+ }
1197
+
1198
+ .text-danger {
1199
+ --bsi-text-opacity: 1;
1200
+ color: rgba(var(--bsi-danger-rgb), var(--bsi-text-opacity)) !important;
1201
+ }
1202
+
1203
+ .text-light {
1204
+ --bsi-text-opacity: 1;
1205
+ color: rgba(var(--bsi-light-rgb), var(--bsi-text-opacity)) !important;
1206
+ }
1207
+
1208
+ .text-dark {
1209
+ --bsi-text-opacity: 1;
1210
+ color: rgba(var(--bsi-dark-rgb), var(--bsi-text-opacity)) !important;
1211
+ }
1212
+
1213
+ .text-black {
1214
+ --bsi-text-opacity: 1;
1215
+ color: rgba(var(--bsi-black-rgb), var(--bsi-text-opacity)) !important;
1216
+ }
1217
+
1218
+ .text-white {
1219
+ --bsi-text-opacity: 1;
1220
+ color: rgba(var(--bsi-white-rgb), var(--bsi-text-opacity)) !important;
1221
+ }
1222
+
1223
+ .text-100 {
1224
+ --bsi-text-opacity: 1;
1225
+ color: rgba(var(--bsi-100-rgb), var(--bsi-text-opacity)) !important;
1226
+ }
1227
+
1228
+ .text-200 {
1229
+ --bsi-text-opacity: 1;
1230
+ color: rgba(var(--bsi-200-rgb), var(--bsi-text-opacity)) !important;
1231
+ }
1232
+
1233
+ .text-300 {
1234
+ --bsi-text-opacity: 1;
1235
+ color: rgba(var(--bsi-300-rgb), var(--bsi-text-opacity)) !important;
1236
+ }
1237
+
1238
+ .text-400 {
1239
+ --bsi-text-opacity: 1;
1240
+ color: rgba(var(--bsi-400-rgb), var(--bsi-text-opacity)) !important;
1241
+ }
1242
+
1243
+ .text-500 {
1244
+ --bsi-text-opacity: 1;
1245
+ color: rgba(var(--bsi-500-rgb), var(--bsi-text-opacity)) !important;
1246
+ }
1247
+
1248
+ .text-600 {
1249
+ --bsi-text-opacity: 1;
1250
+ color: rgba(var(--bsi-600-rgb), var(--bsi-text-opacity)) !important;
1251
+ }
1252
+
1253
+ .text-700 {
1254
+ --bsi-text-opacity: 1;
1255
+ color: rgba(var(--bsi-700-rgb), var(--bsi-text-opacity)) !important;
1256
+ }
1257
+
1258
+ .text-800 {
1259
+ --bsi-text-opacity: 1;
1260
+ color: rgba(var(--bsi-800-rgb), var(--bsi-text-opacity)) !important;
1261
+ }
1262
+
1263
+ .text-900 {
1264
+ --bsi-text-opacity: 1;
1265
+ color: rgba(var(--bsi-900-rgb), var(--bsi-text-opacity)) !important;
1266
+ }
1267
+
1268
+ .text-body {
1269
+ --bsi-text-opacity: 1;
1270
+ color: rgba(var(--bsi-body-color-rgb), var(--bsi-text-opacity)) !important;
1271
+ }
1272
+
1273
+ .text-muted {
1274
+ --bsi-text-opacity: 1;
1275
+ color: hsl(210, 17%, 44%) !important;
1276
+ }
1277
+
1278
+ .text-black-50 {
1279
+ --bsi-text-opacity: 1;
1280
+ color: rgba(0, 0, 0, 0.5) !important;
1281
+ }
1282
+
1283
+ .text-white-50 {
1284
+ --bsi-text-opacity: 1;
1285
+ color: rgba(255, 255, 255, 0.5) !important;
1286
+ }
1287
+
1288
+ .text-reset {
1289
+ --bsi-text-opacity: 1;
1290
+ color: inherit !important;
1291
+ }
1292
+
1145
1293
  :host {
1146
1294
  display: inline-block;
1147
1295
  }
1148
1296
 
1149
- .it-form__control {
1297
+ .upload-dragdrop.loading .upload-dragdrop-select-wrap,
1298
+ .upload-dragdrop.success .upload-dragdrop-select-wrap {
1150
1299
  display: none;
1151
1300
  }
1152
1301
 
@@ -1171,8 +1320,15 @@ blockquote.blockquote-card.dark .blockquote-footer,
1171
1320
  display: flex;
1172
1321
  align-items: center;
1173
1322
  gap: var(--bsi-spacing-xxs, 8px);
1323
+ }
1324
+
1325
+ .upload-dragdrop-text :is(h1, h2, h3, h4, h6) {
1326
+ margin: 0;
1327
+ color: var(--bsi-color-text-base);
1174
1328
  }`;
1175
1329
 
1330
+ const DRAG_DROP_HEADING_LEVELS = ['h2', 'h3', 'h4', 'h5', 'h6'];
1331
+
1176
1332
  registerTranslation(translation);
1177
1333
  registerTranslation(translation$1);
1178
1334
  // Base64‑encoded copy of bootstrap-italia/dist/assets/upload-drag-drop-icon.svg
@@ -1186,6 +1342,8 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
1186
1342
  value: (el) => el._currentFile,
1187
1343
  assumeInteractionOn: ['it-change'],
1188
1344
  });
1345
+ /** Heading level for the title element. Defaults to 'h5'; visual size stays at h5. */
1346
+ this.headingLevel = 'h5';
1189
1347
  /** The currently selected File (null until file is chosen/dropped). */
1190
1348
  this._currentFile = null;
1191
1349
  this._state = 'idle';
@@ -1196,6 +1354,9 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
1196
1354
  this._indeterminate = false;
1197
1355
  this._autoStarted = false;
1198
1356
  }
1357
+ getHeadingLevel() {
1358
+ return DRAG_DROP_HEADING_LEVELS.includes(this.headingLevel) ? this.headingLevel : 'h5';
1359
+ }
1199
1360
  get _formClass() {
1200
1361
  return this.composeClass('upload-dragdrop', this._state === 'dragover' ? 'dragover' : '', this._state === 'loading' ? 'loading' : '', this._state === 'success' ? 'success' : '');
1201
1362
  }
@@ -1236,17 +1397,11 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
1236
1397
  this._preventEvent(e);
1237
1398
  if (this.disabled || this._state === 'success' || this._state === 'loading')
1238
1399
  return;
1239
- const cancelled = !this.dispatchEvent(new CustomEvent('it-dd-start', {
1240
- cancelable: true,
1241
- bubbles: true,
1242
- composed: true,
1243
- detail: {},
1244
- }));
1245
- if (!cancelled) {
1400
+ const event = dispatchCancelable(this, 'it-dd-start', {}, () => {
1246
1401
  this.start();
1247
1402
  this._autoStarted = true;
1248
- }
1249
- else {
1403
+ });
1404
+ if (event.defaultPrevented) {
1250
1405
  this._state = 'dragover';
1251
1406
  }
1252
1407
  }
@@ -1289,17 +1444,11 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
1289
1444
  this._fileWeight = formatSize(file.size);
1290
1445
  this._fileType = this._extractFileType(file.name);
1291
1446
  this._autoStarted = false;
1292
- const dropCancelled = !this.dispatchEvent(new CustomEvent('it-dd-drop', {
1293
- cancelable: true,
1294
- bubbles: true,
1295
- composed: true,
1296
- detail: { file, name: this.name, id: this.id },
1297
- }));
1298
- if (!dropCancelled) {
1447
+ dispatchCancelable(this, 'it-dd-drop', { file, name: this.name, id: this.id }, () => {
1299
1448
  if (this._state !== 'loading')
1300
1449
  this.start();
1301
1450
  this._indeterminate = true;
1302
- }
1451
+ });
1303
1452
  this.dispatchEvent(new CustomEvent('it-change', {
1304
1453
  detail: { file, name: this.name, id: this.id },
1305
1454
  bubbles: true,
@@ -1316,16 +1465,10 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
1316
1465
  this._fileWeight = formatSize(file.size);
1317
1466
  this._fileType = this._extractFileType(file.name);
1318
1467
  input.value = '';
1319
- const dropCancelled = !this.dispatchEvent(new CustomEvent('it-dd-drop', {
1320
- cancelable: true,
1321
- bubbles: true,
1322
- composed: true,
1323
- detail: { file, name: this.name, id: this.id },
1324
- }));
1325
- if (!dropCancelled) {
1468
+ dispatchCancelable(this, 'it-dd-drop', { file, name: this.name, id: this.id }, () => {
1326
1469
  this.start();
1327
1470
  this._indeterminate = true;
1328
- }
1471
+ });
1329
1472
  this.dispatchEvent(new CustomEvent('it-change', {
1330
1473
  detail: { file, name: this.name, id: this.id },
1331
1474
  bubbles: true,
@@ -1348,6 +1491,12 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
1348
1491
  const hasFile = this._fileName.length > 0;
1349
1492
  // Title: slot or default per state
1350
1493
  const titleText = hasFile ? this._fileName : this.$t('upload_dd_title');
1494
+ const fileInputLabel = this.required ? this.$t('upload_label') : this.$t('upload_label');
1495
+ const canSelect = this._state === 'idle' || this._state === 'dragover';
1496
+ const showValidation = this.formControlController.submittedOnce || this.customValidation;
1497
+ const isInvalid = showValidation && this.validationMessage.length > 0;
1498
+ const feedbackId = `invalid-feedback-${this._id}`;
1499
+ const headingTag = unsafeStatic(this.getHeadingLevel());
1351
1500
  return html `
1352
1501
  <div class="upload-dragdrop-text">
1353
1502
  ${hasFile && this._fileWeight
@@ -1358,28 +1507,36 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
1358
1507
  </p>
1359
1508
  `
1360
1509
  : nothing}
1361
- <h5>
1510
+ ${html$1 `<${headingTag} class="h5">
1362
1511
  <slot name="title">${titleText}</slot>
1363
- </h5>
1364
- ${this._state === 'idle' || this._state === 'dragover'
1512
+ </${headingTag}>`} ${canSelect
1365
1513
  ? html `
1366
1514
  <p>
1367
1515
  <slot name="description">${this.$t('upload_dd_description')}</slot>
1368
1516
  </p>
1369
- <p>
1370
- <input
1371
- type="file"
1372
- class="upload-dragdrop-input"
1373
- id="${this._id}"
1374
- accept="${ifDefined(this.accept)}"
1375
- ?disabled="${this.disabled}"
1376
- aria-label="${this.$t('upload_label')}"
1377
- @change="${this._onFileInputChange}"
1378
- />
1379
- <label for="${this._id}">${this.$t('upload_dd_select')}</label>
1380
- </p>
1381
1517
  `
1382
1518
  : nothing}
1519
+ <!-- The file input is the form-control validity participant, so it must exist in every
1520
+ state for the FormControl base class to read its validity. It is the real focusable
1521
+ control native required/validity now anchors to (no hidden proxy). The select affordance
1522
+ (label) and this wrapper are hidden via CSS in loading/success states. -->
1523
+ <p class="upload-dragdrop-select-wrap">
1524
+ <input
1525
+ type="file"
1526
+ class="upload-dragdrop-input it-form__control"
1527
+ id="${this._id}"
1528
+ accept="${ifDefined(this.accept)}"
1529
+ ?disabled="${this.disabled}"
1530
+ ?required="${this.required && !this._currentFile}"
1531
+ ?formNoValidate="${this.customValidation}"
1532
+ aria-label="${fileInputLabel}"
1533
+ aria-required="${this.required ? 'true' : nothing}"
1534
+ aria-invalid="${isInvalid ? 'true' : nothing}"
1535
+ aria-describedby="${ifDefined(isInvalid ? feedbackId : undefined)}"
1536
+ @change="${this._onFileInputChange}"
1537
+ />
1538
+ ${canSelect ? html `<label for="${this._id}">${this.$t('upload_dd_select')}</label>` : nothing}
1539
+ </p>
1383
1540
  ${this._state === 'loading' ? html `<p>${this.$t('upload_dd_status_loading')}</p>` : nothing}
1384
1541
  ${this._state === 'success' ? html `<p>${this.$t('upload_dd_status_success')}</p>` : nothing}
1385
1542
  </div>
@@ -1387,7 +1544,9 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
1387
1544
  }
1388
1545
  render() {
1389
1546
  const statusText = this._getStatusText();
1390
- const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;
1547
+ const showValidation = this.formControlController.submittedOnce || this.customValidation;
1548
+ const isInvalid = showValidation && this.validationMessage.length > 0;
1549
+ const feedbackId = `invalid-feedback-${this._id}`;
1391
1550
  return html `
1392
1551
  <div
1393
1552
  part="drop-zone"
@@ -1421,17 +1580,7 @@ let ItUploadDragDrop = class ItUploadDragDrop extends FormControl {
1421
1580
  <div role="status" aria-live="polite" aria-atomic="true" class="visually-hidden">${statusText}</div>
1422
1581
  </div>
1423
1582
 
1424
- <!-- Hidden proxy input: drives native required/validity checking via FormControl base class -->
1425
- <input
1426
- type="text"
1427
- class="it-form__control"
1428
- .value="${this._currentFile?.name || ''}"
1429
- ?required="${this.required}"
1430
- tabindex="-1"
1431
- aria-hidden="true"
1432
- />
1433
-
1434
- <div class="invalid-feedback form-feedback form-text just-validate-error-label" role="alert">
1583
+ <div id="${feedbackId}" class="form-feedback text-danger" role="alert" ?hidden=${!isInvalid}>
1435
1584
  ${isInvalid ? this.validationMessage : nothing}
1436
1585
  </div>
1437
1586
  `;
@@ -1450,6 +1599,10 @@ __decorate([
1450
1599
  property({ type: String }),
1451
1600
  __metadata("design:type", String)
1452
1601
  ], ItUploadDragDrop.prototype, "illustration", void 0);
1602
+ __decorate([
1603
+ property({ type: String, attribute: 'heading-level' }),
1604
+ __metadata("design:type", String)
1605
+ ], ItUploadDragDrop.prototype, "headingLevel", void 0);
1453
1606
  __decorate([
1454
1607
  state(),
1455
1608
  __metadata("design:type", Object)