@italia/transfer 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.
@@ -5,14 +5,80 @@ import { state, query, property, queryAssignedElements, customElement } from 'li
5
5
  import { live } from 'lit/directives/live.js';
6
6
  import { repeat } from 'lit/directives/repeat.js';
7
7
 
8
+ const ARIA_IDREF_ATTRIBUTES = new Map([
9
+ ['aria-activedescendant', 'ariaActivedescendantElement'],
10
+ ['aria-controls', 'ariaControlsElements'],
11
+ ['aria-describedby', 'ariaDescribedByElements'],
12
+ ['aria-details', 'ariaDetailsElements'],
13
+ ['aria-errormessage', 'ariaErrormessageElements'],
14
+ ['aria-flowto', 'ariaFlowtoElements'],
15
+ ['aria-labelledby', 'ariaLabelledByElements'],
16
+ ['aria-owns', 'ariaOwnsElements'],
17
+ ]);
18
+ function resolveAriaIdRefs(element, value) {
19
+ const ids = value
20
+ .trim()
21
+ .split(/\s+/)
22
+ .filter((id) => id.length > 0);
23
+ if (ids.length === 0)
24
+ return null;
25
+ const root = element.getRootNode();
26
+ let resolvedElements = [];
27
+ if (root instanceof ShadowRoot) {
28
+ resolvedElements = ids.map((id) => root.getElementById(id));
29
+ }
30
+ else if (root instanceof Document) {
31
+ resolvedElements = ids.map((id) => root.getElementById(id));
32
+ }
33
+ else {
34
+ resolvedElements = ids.map((id) => document.getElementById(id));
35
+ }
36
+ if (resolvedElements.filter((el) => el !== null).length === 0) {
37
+ resolvedElements = ids.map((id) => document.getElementById(id));
38
+ }
39
+ const validElements = resolvedElements.filter((el) => el !== null);
40
+ return validElements.length === ids.length ? validElements : null;
41
+ }
42
+ function setInternalsProperty(el, name, resolvedElements) {
43
+ if (name === 'aria-activedescendant') {
44
+ const [firstElement] = resolvedElements;
45
+ // eslint-disable-next-line no-param-reassign
46
+ el[name] = firstElement;
47
+ }
48
+ else {
49
+ // eslint-disable-next-line no-param-reassign
50
+ el[name] = resolvedElements;
51
+ }
52
+ }
8
53
  class SetAttributesDirective extends Directive {
9
54
  update(part, [attributes]) {
10
55
  const el = part.element;
56
+ const internals = el.internals ?? null;
11
57
  for (const [name, value] of Object.entries(attributes)) {
12
- if (value != null)
13
- el.setAttribute(name, value);
14
- else
58
+ if (value == null) {
15
59
  el.removeAttribute(name);
60
+ }
61
+ else {
62
+ const internalsPropertyName = ARIA_IDREF_ATTRIBUTES.get(name);
63
+ if (internalsPropertyName) {
64
+ const resolvedElements = resolveAriaIdRefs(el, String(value));
65
+ if (resolvedElements) {
66
+ if (internals) {
67
+ // Set on ElementInternals
68
+ setInternalsProperty(internals, internalsPropertyName, resolvedElements);
69
+ }
70
+ else {
71
+ // Set internals property on shadowdom item
72
+ el.setAttribute(name, String(value));
73
+ setInternalsProperty(el, internalsPropertyName, resolvedElements);
74
+ }
75
+ }
76
+ }
77
+ else {
78
+ // Non-ARIA IDREF attributes: set normally
79
+ el.setAttribute(name, String(value));
80
+ }
81
+ }
16
82
  }
17
83
  return null;
18
84
  }
@@ -83,7 +149,9 @@ function registerTranslation(...translation) {
83
149
  });
84
150
  update();
85
151
  }
86
- window.registerTranslation = registerTranslation;
152
+ if (typeof window !== 'undefined') {
153
+ window.registerTranslation = registerTranslation;
154
+ }
87
155
  /**
88
156
  * Localize Reactive Controller for components built with Lit
89
157
  *
@@ -378,6 +446,26 @@ class BaseComponent extends LitElement {
378
446
  // generate internal _id
379
447
  const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();
380
448
  this._id = this.generateId(prefix);
449
+ this.ariaAttributesObserver = new MutationObserver((mutations) => {
450
+ const shouldUpdate = mutations.some((mutation) => {
451
+ if (mutation.type !== 'attributes' || !mutation.attributeName) {
452
+ return false;
453
+ }
454
+ return mutation.attributeName === 'it-role' || mutation.attributeName.startsWith('it-aria-');
455
+ });
456
+ if (shouldUpdate) {
457
+ this.requestUpdate();
458
+ }
459
+ });
460
+ this.ariaAttributesObserver.observe(this, {
461
+ attributes: true,
462
+ attributeOldValue: true,
463
+ });
464
+ }
465
+ disconnectedCallback() {
466
+ this.ariaAttributesObserver?.disconnect();
467
+ this.ariaAttributesObserver = undefined;
468
+ super.disconnectedCallback();
381
469
  }
382
470
  }
383
471
  const BaseLocalizedComponent = LocalizeMixin(BaseComponent);
@@ -810,7 +898,7 @@ class FormControl extends BaseLocalizedComponent {
810
898
  });
811
899
  // TODO: verificare se serve davvero con il fatto che usiamo form-controller
812
900
  // static formAssociated = true;
813
- // @property()
901
+ // @property()
814
902
  // internals = this.attachInternals();
815
903
  this._touched = false;
816
904
  /** The name of the input, submitted as a name/value pair with form data. */
@@ -1054,11 +1142,54 @@ __decorate([
1054
1142
  __metadata("design:type", Object)
1055
1143
  ], FormControl.prototype, "validationMessage", void 0);
1056
1144
 
1145
+ /**
1146
+ * Dispatches a cancelable custom event and runs the provided default action
1147
+ * only if the consumer did not call `event.preventDefault()`.
1148
+ *
1149
+ * This is the shared convention used across components (Tabs, Modal, Chip, Alert,
1150
+ * Forward, Back) to provide a sensible default JavaScript behavior out of the box
1151
+ * while letting consumers intercept and override it. Notification deliberately does
1152
+ * NOT use this: its show/close are always caller-initiated (no default markup-driven
1153
+ * trigger to override), so there was no real use case for blocking them — see
1154
+ * it-notification.ts for the plain (non-cancelable) events it fires instead.
1155
+ *
1156
+ * ```js
1157
+ * el.addEventListener('it-alert-close', (e) => {
1158
+ * e.preventDefault(); // block the default removal
1159
+ * fetchConfirmation().then((ok) => { // async logic runs after prevention
1160
+ * if (ok) e.target.close();
1161
+ * });
1162
+ * });
1163
+ * ```
1164
+ *
1165
+ * Note: `preventDefault()` must be called synchronously inside the listener.
1166
+ * Async code can run afterward; call the component's public method when ready.
1167
+ *
1168
+ * @param host the element dispatching the event
1169
+ * @param name the event name (kebab-case, `it-` prefixed)
1170
+ * @param detail the event `detail` payload
1171
+ * @param defaultAction the behavior executed when the event is not prevented
1172
+ * @returns the dispatched event (inspect `defaultPrevented` if needed)
1173
+ */
1174
+ function dispatchCancelable(host, name, detail, defaultAction) {
1175
+ const event = new CustomEvent(name, {
1176
+ bubbles: true,
1177
+ composed: true,
1178
+ cancelable: true,
1179
+ detail,
1180
+ });
1181
+ host.dispatchEvent(event);
1182
+ if (!event.defaultPrevented) {
1183
+ defaultAction();
1184
+ }
1185
+ return event;
1186
+ }
1187
+
1057
1188
  if (typeof window !== 'undefined') {
1058
1189
  window._itAnalytics = window._itAnalytics || {};
1059
1190
  window._itAnalytics = {
1060
1191
  ...window._itAnalytics,
1061
- version: '1.0.0-alpha.9',
1192
+ version: '1.0.0-beta.1',
1062
1193
  };
1063
1194
  }
1064
1195
 
@@ -1075,35 +1206,7 @@ const translation = {
1075
1206
  transferSelectAll: 'Seleziona tutto',
1076
1207
  };
1077
1208
 
1078
- var styles = css`/***************************** 1 ****************************************/
1079
- /***************************** 2 ****************************************/
1080
- /***************************** 1 ****************************************/
1081
- /***************************** 2 ****************************************/
1082
- /***************************** 1 ****************************************/
1083
- /***************************** 2 ****************************************/
1084
- /***************************** 3 ****************************************/
1085
- /***************************** 1 ****************************************/
1086
- /***************************** 2 ****************************************/
1087
- /***************************** 3 ****************************************/
1088
- /***************************** NEUTRAL 1 ****************************************/
1089
- /***************************** NEUTRAL 2 ****************************************/
1090
- /***************************** NEUTRAL 2 / 3 ****************************************/
1091
- .form-check [type=checkbox]:focus + label,
1092
- .form-check [type=radio]:focus + label {
1093
- border-color: hsl(0, 0%, 0%) !important;
1094
- box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
1095
- outline: 3px solid transparent !important;
1096
- outline-offset: 3px !important;
1097
- }
1098
-
1099
- .form-check [type=checkbox]:focus[data-focus-mouse=true] + label,
1100
- .form-check [type=radio]:focus[data-focus-mouse=true] + label {
1101
- border-color: inherit !important;
1102
- box-shadow: none !important;
1103
- outline: none !important;
1104
- }
1105
-
1106
- *,
1209
+ var styles = css`*,
1107
1210
  *::before,
1108
1211
  *::after {
1109
1212
  box-sizing: border-box;
@@ -1497,7 +1600,7 @@ input::-webkit-date-and-time-value {
1497
1600
  }
1498
1601
 
1499
1602
  select {
1500
- 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");
1603
+ 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%, 32%%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
1501
1604
  background-repeat: no-repeat;
1502
1605
  background-position: right var(--bsi-form-control-spacing) center;
1503
1606
  background-size: 16px 12px;
@@ -1510,7 +1613,6 @@ select:focus {
1510
1613
  }
1511
1614
  select[multiple], select[size]:not([size="1"]) {
1512
1615
  padding-right: 0.75rem;
1513
- background-image: none;
1514
1616
  }
1515
1617
  select:disabled {
1516
1618
  background-color: hsl(0, 0%, 90%);
@@ -1644,8 +1746,8 @@ input::-webkit-datetime-edit {
1644
1746
  .form-check [type=checkbox],
1645
1747
  .form-check [type=radio] {
1646
1748
  position: absolute;
1647
- top: 9px;
1648
- left: 9px;
1749
+ top: 0;
1750
+ left: 0;
1649
1751
  width: auto;
1650
1752
  margin-top: 0;
1651
1753
  margin-left: 0;
@@ -1667,6 +1769,19 @@ input::-webkit-datetime-edit {
1667
1769
  font-size: var(--bsi-label-font-size-l);
1668
1770
  }
1669
1771
  }
1772
+ .form-check [type=checkbox]:focus + label,
1773
+ .form-check [type=radio]:focus + label {
1774
+ border-color: hsl(0, 0%, 0%) !important;
1775
+ box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
1776
+ outline: 3px solid transparent !important;
1777
+ outline-offset: 3px !important;
1778
+ }
1779
+ .form-check [type=checkbox]:focus[data-focus-mouse=true] + label,
1780
+ .form-check [type=radio]:focus[data-focus-mouse=true] + label {
1781
+ border-color: inherit !important;
1782
+ box-shadow: none !important;
1783
+ outline: none !important;
1784
+ }
1670
1785
  .form-check input[type=checkbox] + label::after,
1671
1786
  .form-check input[type=checkbox] + label::before {
1672
1787
  position: absolute;
@@ -1713,6 +1828,9 @@ input::-webkit-datetime-edit {
1713
1828
  height: 0;
1714
1829
  border-color: transparent;
1715
1830
  }
1831
+ .form-check input[type=checkbox] + label:hover::after {
1832
+ border-color: var(--bsi-color-border-secondary-hover);
1833
+ }
1716
1834
  .form-check input[type=checkbox]:disabled + label {
1717
1835
  opacity: 1;
1718
1836
  cursor: not-allowed;
@@ -1754,6 +1872,9 @@ input::-webkit-datetime-edit {
1754
1872
  .form-check input[type=radio]:checked + label::before {
1755
1873
  border-color: var(--bsi-form-checked-color);
1756
1874
  }
1875
+ .form-check input[type=radio] + label:hover::before {
1876
+ border-color: var(--bsi-color-border-secondary-hover);
1877
+ }
1757
1878
  .form-check input[type=radio]:disabled + label {
1758
1879
  cursor: not-allowed;
1759
1880
  }
@@ -1840,21 +1961,6 @@ input::-webkit-datetime-edit {
1840
1961
  transition: none !important;
1841
1962
  }
1842
1963
  }
1843
- .form-check [type=checkbox]:focus + label,
1844
- .form-check [type=radio]:focus + label {
1845
- border-color: hsl(0, 0%, 0%) !important;
1846
- box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
1847
- outline: 3px solid transparent !important;
1848
- outline-offset: 3px !important;
1849
- }
1850
-
1851
- .form-check [type=checkbox]:focus[data-focus-mouse=true] + label,
1852
- .form-check [type=radio]:focus[data-focus-mouse=true] + label {
1853
- border-color: inherit !important;
1854
- box-shadow: none !important;
1855
- outline: none !important;
1856
- }
1857
-
1858
1964
  .form-control-plaintext {
1859
1965
  border: 0;
1860
1966
  --bsi-form-control-border-color: transparent;
@@ -1873,7 +1979,7 @@ input::-webkit-datetime-edit {
1873
1979
  .form-control {
1874
1980
  background-repeat: no-repeat;
1875
1981
  background-position: center right;
1876
- background-size: 45px 30%;
1982
+ background-size: 45px 20px;
1877
1983
  }
1878
1984
  .form-control:disabled {
1879
1985
  cursor: not-allowed;
@@ -1881,20 +1987,6 @@ input::-webkit-datetime-edit {
1881
1987
  border: 0;
1882
1988
  color: var(--bsi-color-text-disabled);
1883
1989
  }
1884
- .was-validated .form-control:valid, .form-control.is-valid {
1885
- 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");
1886
- }
1887
- .was-validated .form-control:invalid, .form-control.is-invalid {
1888
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23cc334d' viewBox='0 0 384 512'%3E%3Cpath d='M231.6 256l130.1-130.1c4.7-4.7 4.7-12.3 0-17l-22.6-22.6c-4.7-4.7-12.3-4.7-17 0L192 216.4 61.9 86.3c-4.7-4.7-12.3-4.7-17 0l-22.6 22.6c-4.7 4.7-4.7 12.3 0 17L152.4 256 22.3 386.1c-4.7 4.7-4.7 12.3 0 17l22.6 22.6c4.7 4.7 12.3 4.7 17 0L192 295.6l130.1 130.1c4.7 4.7 12.3 4.7 17 0l22.6-22.6c4.7-4.7 4.7-12.3 0-17L231.6 256z'/%3E%3C/svg%3E");
1889
- border-color: var(--bsi-color-border-danger);
1890
- }
1891
- .form-control.warning {
1892
- background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%0A%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M2%2012C2%206.47715%206.47715%202%2012%202C14.6522%202%2017.1957%203.05357%2019.0711%204.92893C20.9464%206.8043%2022%209.34784%2022%2012C22%2017.5228%2017.5228%2022%2012%2022C6.47715%2022%202%2017.5228%202%2012ZM3%2012C3%2016.9706%207.02944%2021%2012%2021C16.9706%2021%2021%2016.9706%2021%2012C21%207.02944%2016.9706%203%2012%203C7.02944%203%203%207.02944%203%2012ZM11.5%2014.2V5.7H12.7V14.2H11.5ZM12.6%2018.3V16.5H11.4V18.3H12.6Z%22/%3E%0A%3C/svg%3E") no-repeat;
1893
- border-color: var(--bsi-color-border-warning);
1894
- }
1895
- .form-control.is-valid ~ .warning-feedback {
1896
- display: block;
1897
- }
1898
1990
 
1899
1991
  .form-control-sm {
1900
1992
  --bsi-form-control-spacing: var(--bsi-spacing-xxs) var(--bsi-spacing-3xs);
@@ -1991,15 +2083,15 @@ textarea.form-control-lg {
1991
2083
  border-color: hsl(210, 100%, 40%);
1992
2084
  }
1993
2085
  .form-check-input:checked[type=checkbox] {
1994
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='hsl%280, 0%, 100%%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
2086
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='hsl(0, 0%, 100%)' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/></svg>"));
1995
2087
  }
1996
2088
  .form-check-input:checked[type=radio] {
1997
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='hsl%280, 0%, 100%%29'/%3e%3c/svg%3e");
2089
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='2' fill='hsl(0, 0%, 100%)'/></svg>"));
1998
2090
  }
1999
2091
  .form-check-input[type=checkbox]:indeterminate {
2000
2092
  background-color: hsl(210, 100%, 40%);
2001
2093
  border-color: hsl(210, 100%, 40%);
2002
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='hsl%280, 0%, 100%%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e");
2094
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='hsl(0, 0%, 100%)' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/></svg>"));
2003
2095
  }
2004
2096
  .form-check-input:disabled {
2005
2097
  pointer-events: none;
@@ -2017,7 +2109,7 @@ textarea.form-control-lg {
2017
2109
  .form-switch .form-check-input {
2018
2110
  width: 2em;
2019
2111
  margin-left: -2.5em;
2020
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e");
2112
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='rgba(0, 0, 0, 0.25)'/></svg>"));
2021
2113
  background-position: left center;
2022
2114
  border-radius: 2em;
2023
2115
  transition: background-position 0.15s ease-in-out;
@@ -2028,11 +2120,11 @@ textarea.form-control-lg {
2028
2120
  }
2029
2121
  }
2030
2122
  .form-switch .form-check-input:focus {
2031
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='hsl%28210, 17%, 44%%29'/%3e%3c/svg%3e");
2123
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='hsl(210, 17%, 44%)'/></svg>"));
2032
2124
  }
2033
2125
  .form-switch .form-check-input:checked {
2034
2126
  background-position: right center;
2035
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='hsl%280, 0%, 100%%29'/%3e%3c/svg%3e");
2127
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='hsl(0, 0%, 100%)'/></svg>"));
2036
2128
  }
2037
2129
  .form-switch.form-check-reverse {
2038
2130
  padding-right: 2.5em;
@@ -2174,9 +2266,6 @@ textarea.form-control-lg {
2174
2266
  margin-top: 0.25rem;
2175
2267
  font-size: 0.75rem;
2176
2268
  }
2177
- .form-feedback.just-validate-error-label {
2178
- color: var(--bsi-color-text-danger);
2179
- }
2180
2269
 
2181
2270
  .input-group-text:has(~ [data-focus-mouse=true]:not(.btn)),
2182
2271
  [data-focus-mouse=true]:not(.btn) ~ .input-group-text,
@@ -2198,20 +2287,44 @@ button:has(~ .is-invalid),
2198
2287
  display: none;
2199
2288
  }
2200
2289
 
2201
- .just-validate-success-field {
2202
- border-color: var(--bsi-color-border-success) !important;
2290
+ .is-valid,
2291
+ .is-invalid {
2203
2292
  padding-right: calc(1.5em + 0.75rem) !important;
2204
- 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");
2293
+ }
2294
+ .is-valid[type=number],
2295
+ .is-invalid[type=number] {
2296
+ padding-right: calc(1.5em + 0.75rem + var(--bsi-form-control-spacing) + 1rem) !important;
2205
2297
  }
2206
2298
 
2207
- .input-group-text:has(~ .just-validate-success-field),
2208
- .just-validate-success-field ~ .input-group-text,
2209
- button:has(~ .just-validate-success-field),
2210
- .just-validate-success-field + button {
2299
+ .was-validated &:valid,
2300
+ .is-valid {
2301
+ border-color: var(--bsi-color-border-success) !important;
2302
+ 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>');
2303
+ }
2304
+ .was-validated &:valid ~ .warning-feedback,
2305
+ .is-valid ~ .warning-feedback {
2306
+ display: block;
2307
+ }
2308
+
2309
+ .was-validated &:invalid,
2310
+ .is-invalid {
2311
+ border-color: var(--bsi-color-border-danger) !important;
2312
+ 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>');
2313
+ }
2314
+
2315
+ .form-control.warning {
2316
+ border-color: var(--bsi-color-border-warning) !important;
2317
+ 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>');
2318
+ }
2319
+
2320
+ .input-group-text:has(~ .is-valid),
2321
+ .is-valid ~ .input-group-text,
2322
+ button:has(~ .is-valid),
2323
+ .is-valid + button {
2211
2324
  border-color: var(--bsi-color-border-success);
2212
2325
  }
2213
2326
 
2214
- .just-validate-success-field + .input-group-text.align-buttons,
2327
+ .is-valid + .input-group-text.align-buttons,
2215
2328
  .is-invalid + .input-group-text.align-buttons {
2216
2329
  right: 30px;
2217
2330
  }
@@ -2220,33 +2333,12 @@ button:has(~ .just-validate-success-field),
2220
2333
  bottom: 22px;
2221
2334
  }
2222
2335
 
2223
- .autocomplete__wrapper .form-feedback.just-validate-error-label {
2336
+ .autocomplete__wrapper .form-feedback {
2224
2337
  position: absolute;
2225
2338
  }
2226
2339
 
2227
2340
  textarea.form-control {
2228
- background-position: top 0.3em right 0.3em !important;
2229
- background-size: 37px 30% !important;
2230
- }
2231
- textarea.is-invalid {
2232
- border-bottom-style: solid;
2233
- border-bottom-width: 1px;
2234
- }
2235
- textarea.just-validate-success-field {
2236
- border-bottom-style: solid;
2237
- border-bottom-width: 1px;
2238
- }
2239
-
2240
- input[type=checkbox].is-invalid,
2241
- input[type=radio].is-invalid {
2242
- --bsi-form-checkbox-border-color: var(--bsi-color-border-danger);
2243
- }
2244
-
2245
- select.is-invalid {
2246
- border: 1px solid var(--bsi-color-border-danger);
2247
- }
2248
- select.just-validate-success-field {
2249
- border: 1px solid var(--bsi-color-border-success);
2341
+ background-position: top 0.5em right !important;
2250
2342
  }
2251
2343
 
2252
2344
  .row {
@@ -3593,6 +3685,126 @@ select.just-validate-success-field {
3593
3685
  bottom: auto;
3594
3686
  }
3595
3687
 
3688
+ .text-primary {
3689
+ --bsi-text-opacity: 1;
3690
+ color: rgba(var(--bsi-primary-rgb), var(--bsi-text-opacity)) !important;
3691
+ }
3692
+
3693
+ .text-secondary {
3694
+ --bsi-text-opacity: 1;
3695
+ color: hsl(210, 33%, 28%) !important;
3696
+ }
3697
+
3698
+ .text-success {
3699
+ --bsi-text-opacity: 1;
3700
+ color: rgba(var(--bsi-success-rgb), var(--bsi-text-opacity)) !important;
3701
+ }
3702
+
3703
+ .text-info {
3704
+ --bsi-text-opacity: 1;
3705
+ color: rgba(var(--bsi-info-rgb), var(--bsi-text-opacity)) !important;
3706
+ }
3707
+
3708
+ .text-warning {
3709
+ --bsi-text-opacity: 1;
3710
+ color: rgba(var(--bsi-warning-rgb), var(--bsi-text-opacity)) !important;
3711
+ }
3712
+
3713
+ .text-danger {
3714
+ --bsi-text-opacity: 1;
3715
+ color: rgba(var(--bsi-danger-rgb), var(--bsi-text-opacity)) !important;
3716
+ }
3717
+
3718
+ .text-light {
3719
+ --bsi-text-opacity: 1;
3720
+ color: rgba(var(--bsi-light-rgb), var(--bsi-text-opacity)) !important;
3721
+ }
3722
+
3723
+ .text-dark {
3724
+ --bsi-text-opacity: 1;
3725
+ color: rgba(var(--bsi-dark-rgb), var(--bsi-text-opacity)) !important;
3726
+ }
3727
+
3728
+ .text-black {
3729
+ --bsi-text-opacity: 1;
3730
+ color: rgba(var(--bsi-black-rgb), var(--bsi-text-opacity)) !important;
3731
+ }
3732
+
3733
+ .text-white {
3734
+ --bsi-text-opacity: 1;
3735
+ color: rgba(var(--bsi-white-rgb), var(--bsi-text-opacity)) !important;
3736
+ }
3737
+
3738
+ .text-100 {
3739
+ --bsi-text-opacity: 1;
3740
+ color: rgba(var(--bsi-100-rgb), var(--bsi-text-opacity)) !important;
3741
+ }
3742
+
3743
+ .text-200 {
3744
+ --bsi-text-opacity: 1;
3745
+ color: rgba(var(--bsi-200-rgb), var(--bsi-text-opacity)) !important;
3746
+ }
3747
+
3748
+ .text-300 {
3749
+ --bsi-text-opacity: 1;
3750
+ color: rgba(var(--bsi-300-rgb), var(--bsi-text-opacity)) !important;
3751
+ }
3752
+
3753
+ .text-400 {
3754
+ --bsi-text-opacity: 1;
3755
+ color: rgba(var(--bsi-400-rgb), var(--bsi-text-opacity)) !important;
3756
+ }
3757
+
3758
+ .text-500 {
3759
+ --bsi-text-opacity: 1;
3760
+ color: rgba(var(--bsi-500-rgb), var(--bsi-text-opacity)) !important;
3761
+ }
3762
+
3763
+ .text-600 {
3764
+ --bsi-text-opacity: 1;
3765
+ color: rgba(var(--bsi-600-rgb), var(--bsi-text-opacity)) !important;
3766
+ }
3767
+
3768
+ .text-700 {
3769
+ --bsi-text-opacity: 1;
3770
+ color: rgba(var(--bsi-700-rgb), var(--bsi-text-opacity)) !important;
3771
+ }
3772
+
3773
+ .text-800 {
3774
+ --bsi-text-opacity: 1;
3775
+ color: rgba(var(--bsi-800-rgb), var(--bsi-text-opacity)) !important;
3776
+ }
3777
+
3778
+ .text-900 {
3779
+ --bsi-text-opacity: 1;
3780
+ color: rgba(var(--bsi-900-rgb), var(--bsi-text-opacity)) !important;
3781
+ }
3782
+
3783
+ .text-body {
3784
+ --bsi-text-opacity: 1;
3785
+ color: rgba(var(--bsi-body-color-rgb), var(--bsi-text-opacity)) !important;
3786
+ }
3787
+
3788
+ .text-muted {
3789
+ --bsi-text-opacity: 1;
3790
+ color: hsl(210, 17%, 44%) !important;
3791
+ }
3792
+
3793
+ .text-black-50 {
3794
+ --bsi-text-opacity: 1;
3795
+ color: rgba(0, 0, 0, 0.5) !important;
3796
+ }
3797
+
3798
+ .text-white-50 {
3799
+ --bsi-text-opacity: 1;
3800
+ color: rgba(255, 255, 255, 0.5) !important;
3801
+ }
3802
+
3803
+ .text-reset {
3804
+ --bsi-text-opacity: 1;
3805
+ color: inherit !important;
3806
+ }
3807
+
3596
3808
  :host {
3597
3809
  --it-transfer-border: 1px solid hsl(210, 3.6255162919%, 78.21%);
3598
3810
  --it-transfer-height: 240px;
@@ -3647,11 +3859,6 @@ select.just-validate-success-field {
3647
3859
 
3648
3860
  .form-check input:focus:not(:focus-visible) + label {
3649
3861
  box-shadow: none !important;
3650
- }
3651
-
3652
- .it-transfer .invalid-feedback {
3653
- display: block;
3654
- margin-top: 8px;
3655
3862
  }`;
3656
3863
 
3657
3864
  registerTranslation(translation);
@@ -3786,21 +3993,13 @@ let ItTransfer = class ItTransfer extends FormControl {
3786
3993
  }
3787
3994
  }
3788
3995
  // ── Actions ───────────────────────────────────────────────────────────────
3789
- _dispatch(action, items, nextSource, nextTarget) {
3790
- const detail = {
3996
+ _dispatch(action, items, nextSource, nextTarget, defaultAction) {
3997
+ dispatchCancelable(this, 'it-transfer', {
3791
3998
  action,
3792
3999
  items,
3793
4000
  source: nextSource.map((i) => i.value),
3794
4001
  target: nextTarget.map((i) => i.value),
3795
- };
3796
- const event = new CustomEvent('it-transfer', {
3797
- detail,
3798
- bubbles: true,
3799
- composed: true,
3800
- cancelable: true,
3801
- });
3802
- this.dispatchEvent(event);
3803
- return !event.defaultPrevented;
4002
+ }, defaultAction);
3804
4003
  }
3805
4004
  /** Move checked source items to the target list. */
3806
4005
  transfer() {
@@ -3809,12 +4008,12 @@ let ItTransfer = class ItTransfer extends FormControl {
3809
4008
  return;
3810
4009
  const nextSource = this._sourceItems.filter((i) => !this._sourceChecked.has(i.value));
3811
4010
  const nextTarget = [...this._targetItems, ...moving];
3812
- if (!this._dispatch('transfer', moving.map((i) => i.value), nextSource, nextTarget))
3813
- return;
3814
- this._sourceItems = nextSource;
3815
- this._targetItems = nextTarget;
3816
- this._sourceChecked = new Set();
3817
- this._syncValue();
4011
+ this._dispatch('transfer', moving.map((i) => i.value), nextSource, nextTarget, () => {
4012
+ this._sourceItems = nextSource;
4013
+ this._targetItems = nextTarget;
4014
+ this._sourceChecked = new Set();
4015
+ this._syncValue();
4016
+ });
3818
4017
  }
3819
4018
  /** Move checked target items back to the source list. */
3820
4019
  backtransfer() {
@@ -3823,21 +4022,44 @@ let ItTransfer = class ItTransfer extends FormControl {
3823
4022
  return;
3824
4023
  const nextTarget = this._targetItems.filter((i) => !this._targetChecked.has(i.value));
3825
4024
  const nextSource = [...this._sourceItems, ...moving];
3826
- if (!this._dispatch('backtransfer', moving.map((i) => i.value), nextSource, nextTarget))
3827
- return;
3828
- this._sourceItems = nextSource;
3829
- this._targetItems = nextTarget;
3830
- this._targetChecked = new Set();
3831
- this._syncValue();
4025
+ this._dispatch('backtransfer', moving.map((i) => i.value), nextSource, nextTarget, () => {
4026
+ this._sourceItems = nextSource;
4027
+ this._targetItems = nextTarget;
4028
+ this._targetChecked = new Set();
4029
+ this._syncValue();
4030
+ });
3832
4031
  }
3833
4032
  /** Reset both lists to their initial state. */
3834
4033
  reset() {
3835
4034
  const nextSource = this._initialSource.slice();
3836
4035
  const nextTarget = this._initialTarget.slice();
3837
- if (!this._dispatch('reset', [], nextSource, nextTarget))
3838
- return;
3839
- this._sourceItems = nextSource;
3840
- this._targetItems = nextTarget;
4036
+ this._dispatch('reset', [], nextSource, nextTarget, () => {
4037
+ this._sourceItems = nextSource;
4038
+ this._targetItems = nextTarget;
4039
+ this._sourceChecked = new Set();
4040
+ this._targetChecked = new Set();
4041
+ this._syncValue();
4042
+ });
4043
+ }
4044
+ /**
4045
+ * Applies the proposed state from a previously cancelled `it-transfer` event,
4046
+ * without re-dispatching the event.
4047
+ *
4048
+ * Use this after calling `event.preventDefault()` in an `it-transfer` listener
4049
+ * to resume the action once your async logic (validation, confirmation, etc.) resolves:
4050
+ *
4051
+ * ```js
4052
+ * el.addEventListener('it-transfer', async (e) => {
4053
+ * e.preventDefault();
4054
+ * const ok = await confirm('Procedere con il trasferimento?');
4055
+ * if (ok) el.commit(e.detail);
4056
+ * });
4057
+ * ```
4058
+ */
4059
+ commit(detail) {
4060
+ const known = new Map([...this._sourceItems, ...this._targetItems].map((i) => [i.value, i]));
4061
+ this._sourceItems = detail.source.flatMap((v) => (known.has(v) ? [known.get(v)] : []));
4062
+ this._targetItems = detail.target.flatMap((v) => (known.has(v) ? [known.get(v)] : []));
3841
4063
  this._sourceChecked = new Set();
3842
4064
  this._targetChecked = new Set();
3843
4065
  this._syncValue();
@@ -4032,11 +4254,7 @@ let ItTransfer = class ItTransfer extends FormControl {
4032
4254
 
4033
4255
  ${invalid
4034
4256
  ? html `
4035
- <div
4036
- role="alert"
4037
- id="invalid-feedback-${this._id}"
4038
- class="invalid-feedback form-feedback form-text just-validate-error-label"
4039
- >
4257
+ <div role="alert" id="invalid-feedback-${this._id}" class="form-feedback text-danger">
4040
4258
  ${validityMessage}
4041
4259
  </div>
4042
4260
  `