@italia/popover 0.1.0-alpha.2 → 1.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,19 +1,67 @@
1
- # Popover Web Component
1
+ # \<it-popover>
2
2
 
3
- Questo package contiene il web component `<it-popover>`, conforme agli standard del progetto e con stili Bootstrap Italia.
3
+ This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
4
4
 
5
- ## Utilizzo
5
+ ## Installation
6
6
 
7
+ ```bash
8
+ npm i @italia/popover
7
9
  ```
8
10
 
11
+ ## Usage
12
+
13
+ ```html
14
+ <script type="module">
15
+ import '@italia/popover';
16
+ </script>
17
+
18
+ <it-popover></it-popover>
19
+ ```
20
+
21
+ ## Linting and formatting
22
+
23
+ To scan the project for linting and formatting errors, run
24
+
25
+ ```bash
26
+ npm run lint
27
+ ```
28
+
29
+ To automatically fix linting and formatting errors, run
30
+
31
+ ```bash
32
+ npm run format
33
+ ```
34
+
35
+ ## Testing with Web Test Runner
36
+
37
+ To execute a single test run:
38
+
39
+ ```bash
40
+ npm run test
41
+ ```
42
+
43
+ To run the tests in interactive watch mode run:
44
+
45
+ ```bash
46
+ npm run test:watch
9
47
  ```
10
48
 
11
- ## Sviluppo
49
+ ## Demoing with Storybook
50
+
51
+ To run a local instance of Storybook for your component, run
52
+
53
+ ```bash
54
+ npm run storybook
55
+ ```
56
+
57
+ To build a production version of Storybook, run
58
+
59
+ ```bash
60
+ npm run storybook:build
61
+ ```
12
62
 
13
- - Stili: solo SCSS, no CSS inline
14
- - Test: web-test-runner
15
- - Storie: Storybook
63
+ ## Tooling configs
16
64
 
17
- ## License
65
+ For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
18
66
 
19
- Vedi LICENSE.
67
+ If you customize the configuration a lot, you can consider moving them to individual files.
@@ -36,6 +36,15 @@
36
36
  "attribute": "open",
37
37
  "reflects": true
38
38
  },
39
+ {
40
+ "kind": "field",
41
+ "name": "controlled",
42
+ "type": {
43
+ "text": "boolean"
44
+ },
45
+ "default": "false",
46
+ "attribute": "controlled"
47
+ },
39
48
  {
40
49
  "kind": "field",
41
50
  "name": "placement",
@@ -94,6 +103,11 @@
94
103
  "name": "_setChildrenProperties",
95
104
  "privacy": "private"
96
105
  },
106
+ {
107
+ "kind": "method",
108
+ "name": "setupStandardEvents",
109
+ "privacy": "protected"
110
+ },
97
111
  {
98
112
  "kind": "method",
99
113
  "name": "_createArrow",
@@ -158,6 +172,14 @@
158
172
  "default": "false",
159
173
  "fieldName": "open"
160
174
  },
175
+ {
176
+ "name": "controlled",
177
+ "type": {
178
+ "text": "boolean"
179
+ },
180
+ "default": "false",
181
+ "fieldName": "controlled"
182
+ },
161
183
  {
162
184
  "name": "placement",
163
185
  "type": {
@@ -193,6 +215,139 @@
193
215
  }
194
216
  }
195
217
  ]
218
+ },
219
+ {
220
+ "kind": "javascript-module",
221
+ "path": "stories/it-popover.stories.ts",
222
+ "declarations": [
223
+ {
224
+ "kind": "variable",
225
+ "name": "meta",
226
+ "default": "{ title: 'Componenti/Popover', component: 'it-popover', tags: ['alpha', 'web-component', 'a11y-ok'], args: { placement: 'right', }, argTypes: { placement: { control: 'select', options: [ 'top', 'right', 'bottom', 'left', 'top-start', 'top-end', 'right-start', 'right-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end', ], table: { defaultValue: { summary: 'bottom-start' }, }, }, }, parameters: { layout: 'padded', docs: { source: { excludeDecorators: true }, }, }, } satisfies Meta<PopoverProps>"
227
+ },
228
+ {
229
+ "kind": "variable",
230
+ "name": "Base",
231
+ "type": {
232
+ "text": "Story"
233
+ },
234
+ "default": "{ ...meta, render: (args) => html` <it-popover placement=${ifDefined(args.placement)}> <it-button slot=\"trigger\" variant=\"primary\"> Opzioni utente, clicca per aprire </it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> `, tags: ['!autodocs', '!dev'], }"
235
+ },
236
+ {
237
+ "kind": "variable",
238
+ "name": "Posizione",
239
+ "type": {
240
+ "text": "Story"
241
+ },
242
+ "default": "{ ...meta, render: () => html` <it-popover placement=\"bottom-start\" style=\"grid-column:2\"> <it-button slot=\"trigger\" variant=\"primary\">Giù</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> <it-popover placement=\"top-start\" style=\"grid-row:3;grid-column:2\"> <it-button slot=\"trigger\" variant=\"primary\">Su</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> <it-popover placement=\"left\" style=\"grid-row:2;grid-column:3\"> <it-button slot=\"trigger\" variant=\"primary\">Sinistra</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> <it-popover placement=\"right\" style=\"grid-row:2;grid-column:1\"> <it-button slot=\"trigger\" variant=\"primary\">Destra</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Titolo del popover</h4> <div class=\"popover-body\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue.</div> </div> </it-popover> `, decorators: [(Story) => html`<div style=\"display:grid;gap:.5rem;grid:1fr 1fr 1fr/1fr 1fr 1fr;\">${Story()}</div>`], argTypes: { ...disabledControls() }, }"
243
+ },
244
+ {
245
+ "kind": "variable",
246
+ "name": "ConIconaELink",
247
+ "type": {
248
+ "text": "Story"
249
+ },
250
+ "default": "{ ...meta, name: 'Titolo con icona e link', render: () => { const handleLinkClick = (e: Event) => { e.preventDefault(); }; return html` <it-popover> <it-button slot=\"trigger\" variant=\"primary\"> Popover con icona e link </it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\"> <it-icon name=\"it-help-circle\" size=\"sm\"></it-icon> Titolo con icona </h4> <div class=\"popover-body\"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel finibus augue. <a href=\"#\" class=\"popover-inner-link\" @click=${handleLinkClick}> Leggi tutto <it-icon name=\"it-arrow-right\" size=\"xs\" color=\"primary\"></it-icon> </a> </div> </div> </it-popover> `; }, decorators: [(Story) => html`<div style=\"height:200px\">${Story()}</div>`], argTypes: { ...disabledControls() }, }"
251
+ },
252
+ {
253
+ "kind": "variable",
254
+ "name": "ElementiDisabilitati",
255
+ "type": {
256
+ "text": "Story"
257
+ },
258
+ "default": "{ ...meta, name: 'Elementi disabilitati', render: () => html` <it-popover placement=\"right\"> <it-button slot=\"trigger\" variant=\"primary\" disabled> Pulsante disabilitato, il popover non si apre </it-button> <div slot=\"content\" class=\"popover\"> <div class=\"popover-body\">Popover disabilitato</div> </div> </it-popover> `, argTypes: { ...disabledControls() }, }"
259
+ },
260
+ {
261
+ "kind": "variable",
262
+ "name": "ElementiDisabilitatiConHover",
263
+ "type": {
264
+ "text": "Story"
265
+ },
266
+ "default": "{ ...meta, name: 'Elementi disabilitati con hover', render: () => { const handleMouseEnter = (e: Event) => { const button = e.target as HTMLElement; const popover = button.closest('it-popover'); popover?.openPopover(); }; const handleMouseLeave = (e: Event) => { const button = e.target as HTMLElement; const popover = button.closest('it-popover'); popover?.closePopover(); }; const handleFocus = (e: Event) => { const button = e.target as HTMLElement; const popover = button.closest('it-popover'); popover?.openPopover(); }; const handleBlur = (e: FocusEvent) => { const target = e.relatedTarget as HTMLElement; if (!target?.closest?.('it-popover')) { const button = e.target as HTMLElement; const popover = button.closest('it-popover'); popover?.closePopover(); } }; return html` <it-popover placement=\"right\"> <it-button slot=\"trigger\" variant=\"primary\" disabled @mouseenter=${handleMouseEnter} @mouseleave=${handleMouseLeave} @focus=${handleFocus} @blur=${handleBlur} > Pulsante disabilitato </it-button> <div slot=\"content\" class=\"popover\" @blur=${handleBlur}> <div class=\"popover-body\">Pulsante disabilitato, qui puoi spiegare il perché</div> </div> </it-popover> `; }, argTypes: { ...disabledControls() }, }"
267
+ },
268
+ {
269
+ "kind": "variable",
270
+ "name": "AttivazioneControllata",
271
+ "type": {
272
+ "text": "Story"
273
+ },
274
+ "default": "{ ...meta, name: 'Attivazione controllata', tags: ['!dev'], render: () => html` <it-popover controlled placement=\"right\"> <it-button slot=\"trigger\" variant=\"primary\" id=\"controlled-trigger\"> Popover controllato </it-button> <div slot=\"content\" class=\"popover\"> <div class=\"popover-inner\"> <div class=\"popover-body\">Questo popover non si aprirà e questo testo non si vedrà.</div> </div> </div> </it-popover> `, argTypes: { ...disabledControls() }, }"
275
+ },
276
+ {
277
+ "kind": "variable",
278
+ "name": "Eventi",
279
+ "type": {
280
+ "text": "Story"
281
+ },
282
+ "default": "{ ...meta, render: () => { const handleOpen = (e: CustomEvent) => { console.log('Popover aperto', e); }; const handleClose = (e: CustomEvent) => { console.log('Popover chiuso', e); }; return html` <it-popover @it-popover-open=${handleOpen} @it-popover-close=${handleClose} placement=\"right\"> <it-button slot=\"trigger\" variant=\"primary\">Popover con eventi</it-button> <div slot=\"content\" class=\"popover\"> <h4 class=\"popover-header\">Eventi del Popover</h4> <div class=\"popover-body\">Apri e chiudi questo popover per vedere gli eventi nella console.</div> </div> </it-popover> `; }, argTypes: { ...disabledControls() }, }"
283
+ }
284
+ ],
285
+ "exports": [
286
+ {
287
+ "kind": "js",
288
+ "name": "default",
289
+ "declaration": {
290
+ "name": "meta",
291
+ "module": "stories/it-popover.stories.ts"
292
+ }
293
+ },
294
+ {
295
+ "kind": "js",
296
+ "name": "Base",
297
+ "declaration": {
298
+ "name": "Base",
299
+ "module": "stories/it-popover.stories.ts"
300
+ }
301
+ },
302
+ {
303
+ "kind": "js",
304
+ "name": "Posizione",
305
+ "declaration": {
306
+ "name": "Posizione",
307
+ "module": "stories/it-popover.stories.ts"
308
+ }
309
+ },
310
+ {
311
+ "kind": "js",
312
+ "name": "ConIconaELink",
313
+ "declaration": {
314
+ "name": "ConIconaELink",
315
+ "module": "stories/it-popover.stories.ts"
316
+ }
317
+ },
318
+ {
319
+ "kind": "js",
320
+ "name": "ElementiDisabilitati",
321
+ "declaration": {
322
+ "name": "ElementiDisabilitati",
323
+ "module": "stories/it-popover.stories.ts"
324
+ }
325
+ },
326
+ {
327
+ "kind": "js",
328
+ "name": "ElementiDisabilitatiConHover",
329
+ "declaration": {
330
+ "name": "ElementiDisabilitatiConHover",
331
+ "module": "stories/it-popover.stories.ts"
332
+ }
333
+ },
334
+ {
335
+ "kind": "js",
336
+ "name": "AttivazioneControllata",
337
+ "declaration": {
338
+ "name": "AttivazioneControllata",
339
+ "module": "stories/it-popover.stories.ts"
340
+ }
341
+ },
342
+ {
343
+ "kind": "js",
344
+ "name": "Eventi",
345
+ "declaration": {
346
+ "name": "Eventi",
347
+ "module": "stories/it-popover.stories.ts"
348
+ }
349
+ }
350
+ ]
196
351
  }
197
352
  ]
198
353
  }
@@ -1,9 +1,11 @@
1
1
  import { BaseComponent } from '@italia/globals';
2
+ import { PropertyValues } from 'lit';
2
3
  import { type Placement } from '@floating-ui/dom';
3
4
  type PopoverPlacement = Placement;
4
5
  export declare class ItPopover extends BaseComponent {
5
6
  static styles: import("lit").CSSResultGroup;
6
7
  open: boolean;
8
+ controlled: boolean;
7
9
  placement: PopoverPlacement;
8
10
  private _triggerSlot;
9
11
  private _contentSlot;
@@ -12,8 +14,9 @@ export declare class ItPopover extends BaseComponent {
12
14
  private _arrowElement?;
13
15
  private _cleanup?;
14
16
  private _setChildrenProperties;
15
- connectedCallback(): void;
17
+ protected setupStandardEvents(): void;
16
18
  disconnectedCallback(): void;
19
+ protected firstUpdated(_changedProperties: PropertyValues): void;
17
20
  updated(changedProps: Map<string, any>): void;
18
21
  private _createArrow;
19
22
  private _show;
@@ -1 +1 @@
1
- {"version":3,"file":"it-popover.d.ts","sourceRoot":"","sources":["../../src/it-popover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAA2D,KAAK,SAAS,EAAQ,MAAM,kBAAkB,CAAC;AAGjH,KAAK,gBAAgB,GAAG,SAAS,CAAC;AAElC,qBACa,SAAU,SAAQ,aAAa;IAC1C,MAAM,CAAC,MAAM,+BAAU;IAEqB,IAAI,UAAS;IAE7B,SAAS,EAAE,gBAAgB,CAAkB;IAE1C,OAAO,CAAC,YAAY,CAAmB;IAEvC,OAAO,CAAC,YAAY,CAAmB;IAEtE,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,CAAC,aAAa,CAAC,CAAc;IAEpC,OAAO,CAAC,QAAQ,CAAC,CAAa;IAE9B,OAAO,CAAC,sBAAsB;IAc9B,iBAAiB;IAKjB,oBAAoB;IAMpB,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAatC,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,KAAK;IAuDb,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,gBAAgB,CAQtB;IAEF,OAAO,CAAC,aAAa;IAId,MAAM;IAIN,WAAW;IAIX,YAAY;IAInB,MAAM;CAMP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
1
+ {"version":3,"file":"it-popover.d.ts","sourceRoot":"","sources":["../../src/it-popover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAC;AAC3C,OAAO,EAA2D,KAAK,SAAS,EAAQ,MAAM,kBAAkB,CAAC;AAGjH,KAAK,gBAAgB,GAAG,SAAS,CAAC;AAElC,qBACa,SAAU,SAAQ,aAAa;IAC1C,MAAM,CAAC,MAAM,+BAAU;IAEqB,IAAI,UAAS;IAE5B,UAAU,UAAS;IAEpB,SAAS,EAAE,gBAAgB,CAAkB;IAE1C,OAAO,CAAC,YAAY,CAAmB;IAEvC,OAAO,CAAC,YAAY,CAAmB;IAEtE,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,CAAC,aAAa,CAAC,CAAc;IAEpC,OAAO,CAAC,QAAQ,CAAC,CAAa;IAE9B,OAAO,CAAC,sBAAsB;IAwB9B,SAAS,CAAC,mBAAmB;IAoB7B,oBAAoB;IAMpB,SAAS,CAAC,YAAY,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAKhE,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAatC,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,KAAK;IAuDb,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,gBAAgB,CAQtB;IAEF,OAAO,CAAC,aAAa;IAId,MAAM;IAIN,WAAW;IAIX,YAAY;IAInB,MAAM;CAMP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
@@ -436,6 +436,7 @@ const interactions = new WeakMap();
436
436
  /** A reactive controller to allow form controls to participate in form submission, validation, etc. */
437
437
  class FormControlController {
438
438
  constructor(host, options) {
439
+ this.submittedOnce = false;
439
440
  this.handleFormData = (event) => {
440
441
  // console.log('handleFormData');
441
442
  const disabled = this.options.disabled(this.host);
@@ -457,6 +458,17 @@ class FormControlController {
457
458
  event.formData.append(name, value);
458
459
  }
459
460
  break;
461
+ case 'it-checkbox':
462
+ if (this.host.checked) {
463
+ if (event.formData.getAll(name).indexOf(value) < 0) {
464
+ // handle group checkbox
465
+ event.formData.append(name, value);
466
+ }
467
+ }
468
+ break;
469
+ case 'it-checkbox-group':
470
+ // non settare valori in formData, perchè ogni singola checkbox setta il suo valore
471
+ break;
460
472
  default:
461
473
  if (Array.isArray(value)) {
462
474
  value.forEach((val) => {
@@ -478,13 +490,30 @@ class FormControlController {
478
490
  this.setUserInteracted(control, true);
479
491
  });
480
492
  }
481
- if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {
493
+ const resReportValidity = reportValidity(this.host);
494
+ if (this.form && !this.form.noValidate && !disabled && !resReportValidity) {
482
495
  event.preventDefault();
483
496
  // event.stopImmediatePropagation(); // se lo attiviamo, valida un campo alla volta
497
+ // Scroll al primo controllo non valido
498
+ const formControls = formCollections.get(this.form);
499
+ if (formControls) {
500
+ for (const control of formControls) {
501
+ if (!control.validity?.valid) {
502
+ // Scroll smooth verso il controllo non valido
503
+ control.scrollIntoView({
504
+ behavior: 'smooth',
505
+ block: 'center',
506
+ });
507
+ break;
508
+ }
509
+ }
510
+ }
484
511
  }
512
+ this.submittedOnce = true;
485
513
  };
486
514
  this.handleFormReset = () => {
487
515
  this.options.setValue(this.host, '');
516
+ this.submittedOnce = false;
488
517
  this.setUserInteracted(this.host, false);
489
518
  interactions.set(this.host, []);
490
519
  };
@@ -649,6 +678,7 @@ class FormControlController {
649
678
  if (!formCollection) {
650
679
  return;
651
680
  }
681
+ this.submittedOnce = false;
652
682
  // Remove this host from the form's collection
653
683
  formCollection.delete(this.host);
654
684
  // Check to make sure there's no other form controls in the collection. If we do this
@@ -745,6 +775,10 @@ class FormControlController {
745
775
  host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);
746
776
  host.toggleAttribute('data-user-valid', isValid && hasInteracted);
747
777
  }
778
+ userInteracted() {
779
+ const hasInteracted = Boolean(userInteractedControls.has(this.host));
780
+ return hasInteracted;
781
+ }
748
782
  /**
749
783
  * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything
750
784
  * that affects constraint validation changes so the component receives the correct validity states.
@@ -781,6 +815,7 @@ const translation = {
781
815
  $name: 'Italiano',
782
816
  $dir: 'ltr',
783
817
  validityRequired: 'Questo campo è obbligatorio.',
818
+ validityGroupRequired: "Scegli almeno un'opzione",
784
819
  validityPattern: 'Il valore non corrisponde al formato richiesto.',
785
820
  validityMinlength: 'Il valore deve essere lungo almeno {minlength} caratteri.',
786
821
  validityMaxlength: 'Il valore deve essere lungo al massimo {maxlength} caratteri.',
@@ -825,24 +860,27 @@ class FormControl extends BaseLocalizedComponent {
825
860
  this.maxlength = -1;
826
861
  /** If the input is required. */
827
862
  this.required = false;
863
+ /* For grouped input, like checkbox-group */
864
+ this.isInGroup = false;
828
865
  this.validationMessage = '';
829
866
  }
830
867
  /** Gets the validity state object */
831
868
  get validity() {
832
869
  return this.inputElement?.validity;
833
870
  }
871
+ /** Gets the associated form, if one exists. */
872
+ getForm() {
873
+ return this.formControlController.getForm();
874
+ }
834
875
  // Form validation methods
835
876
  checkValidity() {
836
877
  const inputValid = this.inputElement?.checkValidity() ?? true; // this.inputElement.checkValidity() è la validazione del browser
837
878
  return inputValid;
838
879
  }
839
- /** Gets the associated form, if one exists. */
840
- getForm() {
841
- return this.formControlController.getForm();
842
- }
843
880
  /** Checks for validity and shows the browser's validation message if the control is invalid. */
844
881
  reportValidity() {
845
- const ret = this.inputElement.checkValidity();
882
+ // const ret = this.inputElement.checkValidity();
883
+ const ret = this.checkValidity(); // chiama la checkValidity, che se è stata overridata chiama quella
846
884
  this.handleValidationMessages();
847
885
  return ret; // this.inputElement.reportValidity();
848
886
  }
@@ -887,7 +925,8 @@ class FormControl extends BaseLocalizedComponent {
887
925
  handleValidationMessages() {
888
926
  if (!this.customValidation) {
889
927
  const _v = this.inputElement.validity;
890
- if (_v.valueMissing) {
928
+ const isRequiredHandledByGroup = this.isInGroup === true;
929
+ if (_v.valueMissing && !isRequiredHandledByGroup) {
891
930
  this.setCustomValidity(this.$t('validityRequired'));
892
931
  }
893
932
  else if (_v.patternMismatch) {
@@ -958,7 +997,7 @@ class FormControl extends BaseLocalizedComponent {
958
997
  if (this.customValidation) {
959
998
  this.setCustomValidity(this.validationText ?? '');
960
999
  }
961
- else {
1000
+ else if (this.formControlController.userInteracted()) {
962
1001
  this.formControlController.updateValidity();
963
1002
  }
964
1003
  }
@@ -1026,11 +1065,23 @@ __decorate([
1026
1065
  ,
1027
1066
  __metadata("design:type", Object)
1028
1067
  ], FormControl.prototype, "required", void 0);
1068
+ __decorate([
1069
+ property({ type: Boolean }),
1070
+ __metadata("design:type", Object)
1071
+ ], FormControl.prototype, "isInGroup", void 0);
1029
1072
  __decorate([
1030
1073
  state(),
1031
1074
  __metadata("design:type", Object)
1032
1075
  ], FormControl.prototype, "validationMessage", void 0);
1033
1076
 
1077
+ if (typeof window !== 'undefined') {
1078
+ window._itAnalytics = window._itAnalytics || {};
1079
+ window._itAnalytics = {
1080
+ ...window._itAnalytics,
1081
+ version: '1.0.0-alpha.5',
1082
+ };
1083
+ }
1084
+
1034
1085
  /**
1035
1086
  * Custom positioning reference element.
1036
1087
  * @see https://floating-ui.com/docs/virtual-elements
@@ -2748,13 +2799,14 @@ var styles = css`/***************************** 1 ******************************
2748
2799
  /***************************** NEUTRAL 2 ****************************************/
2749
2800
  /***************************** NEUTRAL 2 / 3 ****************************************/
2750
2801
  :host {
2751
- --bs-dropdown-background: var(--bs-color-background-inverse);
2802
+ --bsi-dropdown-background: var(--bsi-color-background-inverse);
2752
2803
  }`;
2753
2804
 
2754
2805
  let ItPopover = class ItPopover extends BaseComponent {
2755
2806
  constructor() {
2756
2807
  super(...arguments);
2757
2808
  this.open = false;
2809
+ this.controlled = false;
2758
2810
  this.placement = 'bottom-start';
2759
2811
  this._onDocumentClick = (event) => {
2760
2812
  if (!this.open)
@@ -2773,27 +2825,57 @@ let ItPopover = class ItPopover extends BaseComponent {
2773
2825
  }
2774
2826
  _setChildrenProperties() {
2775
2827
  if (this._triggerElement && this._triggerElement.tagName === 'IT-BUTTON') {
2828
+ if (this._triggerElement.disabled) {
2829
+ this._triggerElement.removeAttribute('it-aria-haspopup');
2830
+ this._triggerElement.expanded = undefined;
2831
+ return;
2832
+ }
2776
2833
  if (!this._triggerElement.hasAttribute('it-aria-haspopup')) {
2777
2834
  this._triggerElement?.setAttribute('it-aria-haspopup', 'true');
2778
2835
  }
2779
2836
  this._triggerElement.expanded = this.open;
2780
2837
  }
2781
2838
  else {
2839
+ if (this._triggerElement?.hasAttribute('disabled')) {
2840
+ this._triggerElement.removeAttribute('aria-haspopup');
2841
+ this._triggerElement.removeAttribute('aria-expanded');
2842
+ return;
2843
+ }
2782
2844
  if (!this._triggerElement?.hasAttribute('aria-haspopup')) {
2783
2845
  this._triggerElement?.setAttribute('aria-haspopup', 'true');
2784
2846
  }
2785
2847
  this._triggerElement?.setAttribute('aria-expanded', String(this.open));
2786
2848
  }
2787
2849
  }
2788
- connectedCallback() {
2789
- super.connectedCallback?.();
2850
+ setupStandardEvents() {
2790
2851
  document.addEventListener('click', this._onDocumentClick);
2852
+ this._triggerElement?.addEventListener('click', (e) => {
2853
+ e.preventDefault();
2854
+ this.toggle();
2855
+ });
2856
+ this._triggerElement?.addEventListener('keydown', (e) => {
2857
+ if (e.key === 'Escape' && this.open) {
2858
+ this.closePopover();
2859
+ this._triggerElement?.focus();
2860
+ }
2861
+ });
2862
+ this._contentElement?.addEventListener('keydown', (e) => {
2863
+ if (e.key === 'Escape' && this.open) {
2864
+ this.closePopover();
2865
+ this._triggerElement?.focus();
2866
+ }
2867
+ });
2791
2868
  }
2792
2869
  disconnectedCallback() {
2793
2870
  super.disconnectedCallback?.();
2794
2871
  document.removeEventListener('click', this._onDocumentClick);
2795
2872
  this._cleanup?.();
2796
2873
  }
2874
+ firstUpdated(_changedProperties) {
2875
+ super.firstUpdated(_changedProperties);
2876
+ if (!this.controlled)
2877
+ this.setupStandardEvents();
2878
+ }
2797
2879
  updated(changedProps) {
2798
2880
  this._setChildrenProperties();
2799
2881
  if (changedProps.has('open')) {
@@ -2893,6 +2975,10 @@ __decorate([
2893
2975
  property({ type: Boolean, reflect: true }),
2894
2976
  __metadata("design:type", Object)
2895
2977
  ], ItPopover.prototype, "open", void 0);
2978
+ __decorate([
2979
+ property({ type: Boolean }),
2980
+ __metadata("design:type", Object)
2981
+ ], ItPopover.prototype, "controlled", void 0);
2896
2982
  __decorate([
2897
2983
  property({ type: String }),
2898
2984
  __metadata("design:type", String)