@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,23 +1,10 @@
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-A2XDPVTm.js';
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-BVfEYZab.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';
5
5
  import 'lit/directive.js';
6
6
 
7
7
  var styles = css`@charset "UTF-8";
8
- /***************************** 1 ****************************************/
9
- /***************************** 2 ****************************************/
10
- /***************************** 1 ****************************************/
11
- /***************************** 2 ****************************************/
12
- /***************************** 1 ****************************************/
13
- /***************************** 2 ****************************************/
14
- /***************************** 3 ****************************************/
15
- /***************************** 1 ****************************************/
16
- /***************************** 2 ****************************************/
17
- /***************************** 3 ****************************************/
18
- /***************************** NEUTRAL 1 ****************************************/
19
- /***************************** NEUTRAL 2 ****************************************/
20
- /***************************** NEUTRAL 2 / 3 ****************************************/
21
8
  *,
22
9
  *::before,
23
10
  *::after {
@@ -784,6 +771,10 @@ a .avatar:hover p {
784
771
  overflow: hidden;
785
772
  }
786
773
 
774
+ .avatar-upload-wrapper {
775
+ position: relative;
776
+ display: inline-block;
777
+ }
787
778
  .avatar-upload-wrapper .avatar-upload-icon {
788
779
  position: absolute;
789
780
  right: 4px;
@@ -791,30 +782,23 @@ a .avatar:hover p {
791
782
  display: flex;
792
783
  align-items: center;
793
784
  justify-content: center;
794
- width: 26px;
795
- height: 26px;
785
+ width: 32px;
786
+ height: 32px;
796
787
  border: 2px solid var(--bsi-color-border-inverse);
797
788
  border-radius: 50%;
798
789
  background: hsl(210, 6.2290689886%, 92.535%);
799
790
  pointer-events: none;
800
- }
801
- .avatar-upload-wrapper .avatar-upload-icon > svg {
802
- width: 16px;
803
- height: 16px;
791
+ z-index: 1;
804
792
  }
805
793
  .avatar-upload-wrapper.size-sm .avatar {
806
794
  width: 80px;
807
795
  height: 80px;
808
796
  }
809
797
  .avatar-upload-wrapper.size-sm .avatar-upload-icon {
810
- right: 4px;
811
- bottom: 6px;
812
- width: 18px;
813
- height: 18px;
814
- }
815
- .avatar-upload-wrapper.size-sm .avatar-upload-icon > svg {
816
- width: 12px;
817
- height: 12px;
798
+ right: 6px;
799
+ bottom: 8px;
800
+ width: 24px;
801
+ height: 24px;
818
802
  }
819
803
 
820
804
  .upload-dragdrop {
@@ -1030,186 +1014,6 @@ a .avatar:hover p {
1030
1014
  display: none;
1031
1015
  }
1032
1016
  }
1033
- .valid-feedback {
1034
- display: none;
1035
- width: 100%;
1036
- margin-top: 0.25rem;
1037
- font-size: 0.875rem;
1038
- color: hsl(160, 100%, 25%);
1039
- }
1040
-
1041
- .valid-tooltip {
1042
- position: absolute;
1043
- top: 100%;
1044
- z-index: 5;
1045
- display: none;
1046
- max-width: 100%;
1047
- padding: 1rem 1rem;
1048
- margin-top: 0.1rem;
1049
- font-size: 0.875rem;
1050
- color: hsl(0, 0%, 100%);
1051
- background-color: rgb(0, 127.5, 85);
1052
- border-radius: 4px;
1053
- }
1054
-
1055
- .was-validated :valid ~ .valid-feedback,
1056
- .was-validated :valid ~ .valid-tooltip,
1057
- .is-valid ~ .valid-feedback,
1058
- .is-valid ~ .valid-tooltip {
1059
- display: block;
1060
- }
1061
-
1062
- .was-validated .form-control:valid, .form-control.is-valid {
1063
- border-color: hsl(160, 100%, 25%);
1064
- padding-right: calc(1.5em + 0.75rem);
1065
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='hsl%28160, 100%, 25%%29' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
1066
- background-repeat: no-repeat;
1067
- background-position: right calc(0.375em + 0.1875rem) center;
1068
- background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
1069
- }
1070
- .was-validated .form-control:valid:focus, .form-control.is-valid:focus {
1071
- border-color: hsl(160, 100%, 25%);
1072
- box-shadow: 0 0 0 0.25rem rgba(0, 127.5, 85, 0.25);
1073
- }
1074
-
1075
- .was-validated textarea.form-control:valid, textarea.form-control.is-valid {
1076
- padding-right: calc(1.5em + 0.75rem);
1077
- background-position: top calc(0.375em + 0.1875rem) right calc(0.375em + 0.1875rem);
1078
- }
1079
-
1080
- .was-validated .form-select:valid, .form-select.is-valid {
1081
- border-color: hsl(160, 100%, 25%);
1082
- }
1083
- .was-validated .form-select:valid:not([multiple]):not([size]), .was-validated .form-select:valid:not([multiple])[size="1"], .form-select.is-valid:not([multiple]):not([size]), .form-select.is-valid:not([multiple])[size="1"] {
1084
- padding-right: 4.125rem;
1085
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='hsl%280, 0%, 15%%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"), url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='hsl%28160, 100%, 25%%29' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
1086
- background-position: right 0.75rem center, center right 2.25rem;
1087
- background-size: 16px 12px, calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
1088
- }
1089
- .was-validated .form-select:valid:focus, .form-select.is-valid:focus {
1090
- border-color: hsl(160, 100%, 25%);
1091
- box-shadow: 0 0 0 0.25rem rgba(0, 127.5, 85, 0.25);
1092
- }
1093
-
1094
- .was-validated .form-control-color:valid, .form-control-color.is-valid {
1095
- width: calc(3rem + calc(1.5em + 0.75rem));
1096
- }
1097
-
1098
- .was-validated .form-check-input:valid, .form-check-input.is-valid {
1099
- border-color: hsl(160, 100%, 25%);
1100
- }
1101
- .was-validated .form-check-input:valid:checked, .form-check-input.is-valid:checked {
1102
- background-color: hsl(160, 100%, 25%);
1103
- }
1104
- .was-validated .form-check-input:valid:focus, .form-check-input.is-valid:focus {
1105
- box-shadow: 0 0 0 0.25rem rgba(0, 127.5, 85, 0.25);
1106
- }
1107
- .was-validated .form-check-input:valid ~ .form-check-label, .form-check-input.is-valid ~ .form-check-label {
1108
- color: hsl(160, 100%, 25%);
1109
- }
1110
-
1111
- .form-check-inline .form-check-input ~ .valid-feedback {
1112
- margin-left: 0.5em;
1113
- }
1114
-
1115
- .was-validated .input-group > .form-control:not(:focus):valid, .input-group > .form-control:not(:focus).is-valid,
1116
- .was-validated .input-group > .form-select:not(:focus):valid,
1117
- .input-group > .form-select:not(:focus).is-valid,
1118
- .was-validated .input-group > .form-floating:not(:focus-within):valid,
1119
- .input-group > .form-floating:not(:focus-within).is-valid {
1120
- z-index: 3;
1121
- }
1122
-
1123
- .invalid-feedback {
1124
- display: none;
1125
- width: 100%;
1126
- margin-top: 0.25rem;
1127
- font-size: 0.875rem;
1128
- color: hsl(350, 60%, 50%);
1129
- }
1130
-
1131
- .invalid-tooltip {
1132
- position: absolute;
1133
- top: 100%;
1134
- z-index: 5;
1135
- display: none;
1136
- max-width: 100%;
1137
- padding: 1rem 1rem;
1138
- margin-top: 0.1rem;
1139
- font-size: 0.875rem;
1140
- color: hsl(0, 0%, 100%);
1141
- background-color: rgb(204, 51, 76.5);
1142
- border-radius: 4px;
1143
- }
1144
-
1145
- .was-validated :invalid ~ .invalid-feedback,
1146
- .was-validated :invalid ~ .invalid-tooltip,
1147
- .is-invalid ~ .invalid-feedback,
1148
- .is-invalid ~ .invalid-tooltip {
1149
- display: block;
1150
- }
1151
-
1152
- .was-validated .form-control:invalid, .form-control.is-invalid {
1153
- border-color: hsl(350, 60%, 50%);
1154
- padding-right: calc(1.5em + 0.75rem);
1155
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='hsl%28350, 60%, 50%%29'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='hsl%28350, 60%, 50%%29' stroke='none'/%3e%3c/svg%3e");
1156
- background-repeat: no-repeat;
1157
- background-position: right calc(0.375em + 0.1875rem) center;
1158
- background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
1159
- }
1160
- .was-validated .form-control:invalid:focus, .form-control.is-invalid:focus {
1161
- border-color: hsl(350, 60%, 50%);
1162
- box-shadow: 0 0 0 0.25rem rgba(204, 51, 76.5, 0.25);
1163
- }
1164
-
1165
- .was-validated textarea.form-control:invalid, textarea.form-control.is-invalid {
1166
- padding-right: calc(1.5em + 0.75rem);
1167
- background-position: top calc(0.375em + 0.1875rem) right calc(0.375em + 0.1875rem);
1168
- }
1169
-
1170
- .was-validated .form-select:invalid, .form-select.is-invalid {
1171
- border-color: hsl(350, 60%, 50%);
1172
- }
1173
- .was-validated .form-select:invalid:not([multiple]):not([size]), .was-validated .form-select:invalid:not([multiple])[size="1"], .form-select.is-invalid:not([multiple]):not([size]), .form-select.is-invalid:not([multiple])[size="1"] {
1174
- padding-right: 4.125rem;
1175
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='hsl%280, 0%, 15%%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"), url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='hsl%28350, 60%, 50%%29'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='hsl%28350, 60%, 50%%29' stroke='none'/%3e%3c/svg%3e");
1176
- background-position: right 0.75rem center, center right 2.25rem;
1177
- background-size: 16px 12px, calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
1178
- }
1179
- .was-validated .form-select:invalid:focus, .form-select.is-invalid:focus {
1180
- border-color: hsl(350, 60%, 50%);
1181
- box-shadow: 0 0 0 0.25rem rgba(204, 51, 76.5, 0.25);
1182
- }
1183
-
1184
- .was-validated .form-control-color:invalid, .form-control-color.is-invalid {
1185
- width: calc(3rem + calc(1.5em + 0.75rem));
1186
- }
1187
-
1188
- .was-validated .form-check-input:invalid, .form-check-input.is-invalid {
1189
- border-color: hsl(350, 60%, 50%);
1190
- }
1191
- .was-validated .form-check-input:invalid:checked, .form-check-input.is-invalid:checked {
1192
- background-color: hsl(350, 60%, 50%);
1193
- }
1194
- .was-validated .form-check-input:invalid:focus, .form-check-input.is-invalid:focus {
1195
- box-shadow: 0 0 0 0.25rem rgba(204, 51, 76.5, 0.25);
1196
- }
1197
- .was-validated .form-check-input:invalid ~ .form-check-label, .form-check-input.is-invalid ~ .form-check-label {
1198
- color: hsl(350, 60%, 50%);
1199
- }
1200
-
1201
- .form-check-inline .form-check-input ~ .invalid-feedback {
1202
- margin-left: 0.5em;
1203
- }
1204
-
1205
- .was-validated .input-group > .form-control:not(:focus):invalid, .input-group > .form-control:not(:focus).is-invalid,
1206
- .was-validated .input-group > .form-select:not(:focus):invalid,
1207
- .input-group > .form-select:not(:focus).is-invalid,
1208
- .was-validated .input-group > .form-floating:not(:focus-within):invalid,
1209
- .input-group > .form-floating:not(:focus-within).is-invalid {
1210
- z-index: 4;
1211
- }
1212
-
1213
1017
  body {
1214
1018
  font-family: var(--bsi-font-sans);
1215
1019
  }
@@ -1512,9 +1316,6 @@ blockquote.blockquote-card.dark .blockquote-footer,
1512
1316
  margin-top: 0.25rem;
1513
1317
  font-size: 0.75rem;
1514
1318
  }
1515
- .form-feedback.just-validate-error-label {
1516
- color: var(--bsi-color-text-danger);
1517
- }
1518
1319
 
1519
1320
  .input-group-text:has(~ [data-focus-mouse=true]:not(.btn)),
1520
1321
  [data-focus-mouse=true]:not(.btn) ~ .input-group-text,
@@ -1536,20 +1337,44 @@ button:has(~ .is-invalid),
1536
1337
  display: none;
1537
1338
  }
1538
1339
 
1539
- .just-validate-success-field {
1540
- border-color: var(--bsi-color-border-success) !important;
1340
+ .is-valid,
1341
+ .is-invalid {
1541
1342
  padding-right: calc(1.5em + 0.75rem) !important;
1542
- 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");
1343
+ }
1344
+ .is-valid[type=number],
1345
+ .is-invalid[type=number] {
1346
+ padding-right: calc(1.5em + 0.75rem + var(--bsi-form-control-spacing) + 1rem) !important;
1347
+ }
1348
+
1349
+ .was-validated &:valid,
1350
+ .is-valid {
1351
+ border-color: var(--bsi-color-border-success) !important;
1352
+ 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>');
1353
+ }
1354
+ .was-validated &:valid ~ .warning-feedback,
1355
+ .is-valid ~ .warning-feedback {
1356
+ display: block;
1543
1357
  }
1544
1358
 
1545
- .input-group-text:has(~ .just-validate-success-field),
1546
- .just-validate-success-field ~ .input-group-text,
1547
- button:has(~ .just-validate-success-field),
1548
- .just-validate-success-field + button {
1359
+ .was-validated &:invalid,
1360
+ .is-invalid {
1361
+ border-color: var(--bsi-color-border-danger) !important;
1362
+ 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>');
1363
+ }
1364
+
1365
+ .form-control.warning {
1366
+ border-color: var(--bsi-color-border-warning) !important;
1367
+ 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>');
1368
+ }
1369
+
1370
+ .input-group-text:has(~ .is-valid),
1371
+ .is-valid ~ .input-group-text,
1372
+ button:has(~ .is-valid),
1373
+ .is-valid + button {
1549
1374
  border-color: var(--bsi-color-border-success);
1550
1375
  }
1551
1376
 
1552
- .just-validate-success-field + .input-group-text.align-buttons,
1377
+ .is-valid + .input-group-text.align-buttons,
1553
1378
  .is-invalid + .input-group-text.align-buttons {
1554
1379
  right: 30px;
1555
1380
  }
@@ -1558,33 +1383,132 @@ button:has(~ .just-validate-success-field),
1558
1383
  bottom: 22px;
1559
1384
  }
1560
1385
 
1561
- .autocomplete__wrapper .form-feedback.just-validate-error-label {
1386
+ .autocomplete__wrapper .form-feedback {
1562
1387
  position: absolute;
1563
1388
  }
1564
1389
 
1565
1390
  textarea.form-control {
1566
- background-position: top 0.3em right 0.3em !important;
1567
- background-size: 37px 30% !important;
1391
+ background-position: top 0.5em right !important;
1392
+ }
1393
+
1394
+ .text-primary {
1395
+ --bsi-text-opacity: 1;
1396
+ color: rgba(var(--bsi-primary-rgb), var(--bsi-text-opacity)) !important;
1397
+ }
1398
+
1399
+ .text-secondary {
1400
+ --bsi-text-opacity: 1;
1401
+ color: hsl(210, 33%, 28%) !important;
1568
1402
  }
1569
- textarea.is-invalid {
1570
- border-bottom-style: solid;
1571
- border-bottom-width: 1px;
1403
+
1404
+ .text-success {
1405
+ --bsi-text-opacity: 1;
1406
+ color: rgba(var(--bsi-success-rgb), var(--bsi-text-opacity)) !important;
1572
1407
  }
1573
- textarea.just-validate-success-field {
1574
- border-bottom-style: solid;
1575
- border-bottom-width: 1px;
1408
+
1409
+ .text-info {
1410
+ --bsi-text-opacity: 1;
1411
+ color: rgba(var(--bsi-info-rgb), var(--bsi-text-opacity)) !important;
1576
1412
  }
1577
1413
 
1578
- input[type=checkbox].is-invalid,
1579
- input[type=radio].is-invalid {
1580
- --bsi-form-checkbox-border-color: var(--bsi-color-border-danger);
1414
+ .text-warning {
1415
+ --bsi-text-opacity: 1;
1416
+ color: rgba(var(--bsi-warning-rgb), var(--bsi-text-opacity)) !important;
1581
1417
  }
1582
1418
 
1583
- select.is-invalid {
1584
- border: 1px solid var(--bsi-color-border-danger);
1419
+ .text-danger {
1420
+ --bsi-text-opacity: 1;
1421
+ color: rgba(var(--bsi-danger-rgb), var(--bsi-text-opacity)) !important;
1585
1422
  }
1586
- select.just-validate-success-field {
1587
- border: 1px solid var(--bsi-color-border-success);
1423
+
1424
+ .text-light {
1425
+ --bsi-text-opacity: 1;
1426
+ color: rgba(var(--bsi-light-rgb), var(--bsi-text-opacity)) !important;
1427
+ }
1428
+
1429
+ .text-dark {
1430
+ --bsi-text-opacity: 1;
1431
+ color: rgba(var(--bsi-dark-rgb), var(--bsi-text-opacity)) !important;
1432
+ }
1433
+
1434
+ .text-black {
1435
+ --bsi-text-opacity: 1;
1436
+ color: rgba(var(--bsi-black-rgb), var(--bsi-text-opacity)) !important;
1437
+ }
1438
+
1439
+ .text-white {
1440
+ --bsi-text-opacity: 1;
1441
+ color: rgba(var(--bsi-white-rgb), var(--bsi-text-opacity)) !important;
1442
+ }
1443
+
1444
+ .text-100 {
1445
+ --bsi-text-opacity: 1;
1446
+ color: rgba(var(--bsi-100-rgb), var(--bsi-text-opacity)) !important;
1447
+ }
1448
+
1449
+ .text-200 {
1450
+ --bsi-text-opacity: 1;
1451
+ color: rgba(var(--bsi-200-rgb), var(--bsi-text-opacity)) !important;
1452
+ }
1453
+
1454
+ .text-300 {
1455
+ --bsi-text-opacity: 1;
1456
+ color: rgba(var(--bsi-300-rgb), var(--bsi-text-opacity)) !important;
1457
+ }
1458
+
1459
+ .text-400 {
1460
+ --bsi-text-opacity: 1;
1461
+ color: rgba(var(--bsi-400-rgb), var(--bsi-text-opacity)) !important;
1462
+ }
1463
+
1464
+ .text-500 {
1465
+ --bsi-text-opacity: 1;
1466
+ color: rgba(var(--bsi-500-rgb), var(--bsi-text-opacity)) !important;
1467
+ }
1468
+
1469
+ .text-600 {
1470
+ --bsi-text-opacity: 1;
1471
+ color: rgba(var(--bsi-600-rgb), var(--bsi-text-opacity)) !important;
1472
+ }
1473
+
1474
+ .text-700 {
1475
+ --bsi-text-opacity: 1;
1476
+ color: rgba(var(--bsi-700-rgb), var(--bsi-text-opacity)) !important;
1477
+ }
1478
+
1479
+ .text-800 {
1480
+ --bsi-text-opacity: 1;
1481
+ color: rgba(var(--bsi-800-rgb), var(--bsi-text-opacity)) !important;
1482
+ }
1483
+
1484
+ .text-900 {
1485
+ --bsi-text-opacity: 1;
1486
+ color: rgba(var(--bsi-900-rgb), var(--bsi-text-opacity)) !important;
1487
+ }
1488
+
1489
+ .text-body {
1490
+ --bsi-text-opacity: 1;
1491
+ color: rgba(var(--bsi-body-color-rgb), var(--bsi-text-opacity)) !important;
1492
+ }
1493
+
1494
+ .text-muted {
1495
+ --bsi-text-opacity: 1;
1496
+ color: hsl(210, 17%, 44%) !important;
1497
+ }
1498
+
1499
+ .text-black-50 {
1500
+ --bsi-text-opacity: 1;
1501
+ color: rgba(0, 0, 0, 0.5) !important;
1502
+ }
1503
+
1504
+ .text-white-50 {
1505
+ --bsi-text-opacity: 1;
1506
+ color: rgba(255, 255, 255, 0.5) !important;
1507
+ }
1508
+
1509
+ .text-reset {
1510
+ --bsi-text-opacity: 1;
1511
+ color: inherit !important;
1588
1512
  }
1589
1513
 
1590
1514
  :host {
@@ -1592,10 +1516,6 @@ select.just-validate-success-field {
1592
1516
  display: inline-block;
1593
1517
  }
1594
1518
 
1595
- .it-form__control {
1596
- display: none;
1597
- }
1598
-
1599
1519
  input.upload-avatar {
1600
1520
  position: absolute;
1601
1521
  z-index: 1;
@@ -1660,10 +1580,6 @@ input.upload-avatar {
1660
1580
  display: none;
1661
1581
  }
1662
1582
 
1663
- .invalid-feedback:not([hidden]) {
1664
- display: block;
1665
- }
1666
-
1667
1583
  .avatar-upload-wrapper:focus-within:not(:hover) {
1668
1584
  box-shadow: 0 0 0 2px hsl(0, 0%, 100%), 0 0 0 5px hsl(0, 0%, 0%) !important;
1669
1585
  outline: 3px solid rgba(0, 0, 0, 0) !important;
@@ -1741,12 +1657,18 @@ let ItUploadAvatar = class ItUploadAvatar extends FormControl {
1741
1657
  if (changedProperties.has('src') && !this._currentSrc) {
1742
1658
  this._currentSrc = this.src;
1743
1659
  }
1744
- }
1745
- updated(changedProperties) {
1746
- super.updated?.(changedProperties);
1747
- // Re-evaluate validity whenever the form value changes.
1748
- if (changedProperties.has('_currentFile') || changedProperties.has('_currentSrc')) {
1749
- this.handleValidationMessages();
1660
+ // Keep the displayed validation message in sync with the value here (pre-render) rather
1661
+ // than in updated(), so picking/clearing a file refreshes it without scheduling a second
1662
+ // render — avoids Lit's "scheduled an update after an update completed" warning. The native
1663
+ // `?required` attribute still drives checkValidity()/the constraint bubble. Guarded by
1664
+ // `hasUpdated` because `inputElement` only exists once the first render has produced the DOM.
1665
+ if (this.hasUpdated &&
1666
+ !this.customValidation &&
1667
+ (changedProperties.has('_currentFile') || changedProperties.has('_currentSrc'))) {
1668
+ const hasValue = Boolean(this._currentFile || this._currentSrc);
1669
+ const message = this.required && !hasValue ? this.$t('validityRequired') : '';
1670
+ this.inputElement?.setCustomValidity(message);
1671
+ this.validationMessage = message;
1750
1672
  }
1751
1673
  }
1752
1674
  _handleFileChange(e) {
@@ -1769,13 +1691,15 @@ let ItUploadAvatar = class ItUploadAvatar extends FormControl {
1769
1691
  composed: true,
1770
1692
  }));
1771
1693
  }
1772
- // Forward wrapper clicks to the hidden file input.
1773
- // If the click already originated from the label (which has a `for` association), skip to
1774
1694
  render() {
1775
1695
  const labelText = this.$t('upload_avatar_label');
1696
+ const fileInputLabel = this.required ? labelText : labelText;
1776
1697
  const overlayText = this.overlayLabel ?? this.$t('upload_avatar_overlay_label');
1777
- const proxyValue = this._currentSrc || this._currentFile?.name || '';
1778
- const isInvalid = this.formControlController.submittedOnce && this.validationMessage.length > 0;
1698
+ // A pre-filled `src` or a freshly selected file both satisfy `required`.
1699
+ const hasValue = Boolean(this._currentFile || this._currentSrc);
1700
+ const showValidation = this.formControlController.submittedOnce || this.customValidation;
1701
+ const isInvalid = showValidation && this.validationMessage.length > 0;
1702
+ const feedbackId = `invalid-feedback-${this._id}`;
1779
1703
  return html `
1780
1704
  <div class="avatar-upload-wrapper size-${this.size}">
1781
1705
  <it-avatar
@@ -1789,11 +1713,16 @@ let ItUploadAvatar = class ItUploadAvatar extends FormControl {
1789
1713
  <div class="upload-avatar-container">
1790
1714
  <input
1791
1715
  type="file"
1792
- class="upload-avatar"
1716
+ class="upload-avatar it-form__control"
1793
1717
  id="${this._id}"
1794
1718
  accept="${this.accept}"
1795
1719
  ?disabled="${this.disabled}"
1796
- aria-label="${labelText}"
1720
+ ?required="${this.required && !hasValue}"
1721
+ ?formNoValidate="${this.customValidation}"
1722
+ aria-label="${fileInputLabel}"
1723
+ aria-required="${this.required ? 'true' : nothing}"
1724
+ aria-invalid="${isInvalid ? 'true' : nothing}"
1725
+ aria-describedby="${ifDefined(isInvalid ? feedbackId : undefined)}"
1797
1726
  @change="${this._handleFileChange}"
1798
1727
  />
1799
1728
  <label part="overlay-label" for="${this._id}" class="it-upload-avatar-label-container" aria-hidden="true">
@@ -1807,21 +1736,7 @@ let ItUploadAvatar = class ItUploadAvatar extends FormControl {
1807
1736
  </div>
1808
1737
  </div>
1809
1738
 
1810
- <!-- Hidden proxy input: drives native required/validity checking via FormControl base class -->
1811
- <input
1812
- type="text"
1813
- class="it-form__control"
1814
- .value="${proxyValue}"
1815
- ?required="${this.required}"
1816
- tabindex="-1"
1817
- aria-hidden="true"
1818
- />
1819
-
1820
- <div
1821
- class="invalid-feedback form-feedback form-text just-validate-error-label"
1822
- role="alert"
1823
- ?hidden=${!isInvalid}
1824
- >
1739
+ <div id="${feedbackId}" class="form-feedback text-danger" role="alert" ?hidden=${!isInvalid}>
1825
1740
  ${isInvalid ? this.validationMessage : nothing}
1826
1741
  </div>
1827
1742
  `;
@@ -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-upload-avatar': ItUploadAvatar;\n }\n}\n"],"names":["it","en"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AA,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,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 showValidation = this.formControlController.submittedOnce || this.customValidation;\n const isInvalid = showValidation && 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 ?formNoValidate=\"${this.customValidation}\"\n aria-label=\"${fileInputLabel}\"\n aria-required=\"${this.required ? 'true' : nothing}\"\n aria-invalid=\"${isInvalid ? 'true' : nothing}\"\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 id=\"${feedbackId}\" class=\"form-feedback text-danger\" role=\"alert\" ?hidden=${!isInvalid}>\n ${isInvalid ? this.validationMessage : nothing}\n </div>\n `;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,MAAA,CAAA;AAlD9B,cAAc,GAAA,UAAA,CAAA;IAD1B,aAAa,CAAC,kBAAkB;AACpB,CAAA,EAAA,cAAc,CA4J1B;;;;"}
@@ -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;