@italia/video 0.1.0-alpha.1 → 1.0.0-alpha.4

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,5 +1,5 @@
1
1
  import { LitElement, css, html } from 'lit';
2
- import { property, state, customElement } from 'lit/decorators.js';
2
+ import { state, query, property, customElement } from 'lit/decorators.js';
3
3
  import { ifDefined } from 'lit/directives/if-defined.js';
4
4
  import { unsafeHTML } from 'lit/directives/unsafe-html.js';
5
5
  import { directive, Directive } from 'lit/directive.js';
@@ -14720,7 +14720,7 @@ var clockExports = requireClock();
14720
14720
 
14721
14721
  /**
14722
14722
  * @license
14723
- * Video.js 8.23.3 <http://videojs.com/>
14723
+ * Video.js 8.23.4 <http://videojs.com/>
14724
14724
  * Copyright Brightcove, Inc. <https://www.brightcove.com/>
14725
14725
  * Available under Apache License Version 2.0
14726
14726
  * <https://github.com/videojs/video.js/blob/main/LICENSE>
@@ -14731,7 +14731,7 @@ var clockExports = requireClock();
14731
14731
  */
14732
14732
 
14733
14733
 
14734
- var version$6 = "8.23.3";
14734
+ var version$6 = "8.23.4";
14735
14735
 
14736
14736
  /**
14737
14737
  * An Object that contains lifecycle hooks as keys which point to an array
@@ -18829,8 +18829,8 @@ class Component$1 {
18829
18829
  * Remove a child `Component` from this `Component`s list of children. Also removes
18830
18830
  * the child `Component`s element from this `Component`s element.
18831
18831
  *
18832
- * @param {Component} component
18833
- * The child `Component` to remove.
18832
+ * @param {string|Component} component
18833
+ * The name or instance of a child to remove.
18834
18834
  */
18835
18835
  removeChild(component) {
18836
18836
  if (typeof component === 'string') {
@@ -42943,7 +42943,7 @@ videojs.registerPlugin('qualityLevels', qualityLevels);
42943
42943
  // Include the version number.
42944
42944
  qualityLevels.VERSION = version$5;
42945
42945
 
42946
- /*! @name @videojs/http-streaming @version 3.17.0 @license Apache-2.0 */
42946
+ /*! @name @videojs/http-streaming @version 3.17.2 @license Apache-2.0 */
42947
42947
 
42948
42948
  /**
42949
42949
  * @file resolve-url.js - Handling how URLs are resolved and manipulated
@@ -44447,7 +44447,7 @@ const getStreamingNetworkErrorMetadata = ({
44447
44447
  } else if (request.aborted) {
44448
44448
  errorMetadata.errorType = videojs.Error.NetworkRequestAborted;
44449
44449
  } else if (request.timedout) {
44450
- errorMetadata.erroType = videojs.Error.NetworkRequestTimeout;
44450
+ errorMetadata.errorType = videojs.Error.NetworkRequestTimeout;
44451
44451
  } else if (isBadStatusOrParseFailure) {
44452
44452
  const errorType = parseFailure ? videojs.Error.NetworkBodyParserFailed : videojs.Error.NetworkBadStatus;
44453
44453
  errorMetadata.errorType = errorType;
@@ -45723,16 +45723,17 @@ class PlaylistLoader extends EventTarget$1 {
45723
45723
  */
45724
45724
 
45725
45725
  getKeyIdSet(playlist) {
45726
- if (playlist.contentProtection) {
45727
- const keyIds = new Set();
45728
- for (const keysystem in playlist.contentProtection) {
45726
+ const keyIds = new Set();
45727
+ if (!playlist || !playlist.contentProtection) {
45728
+ return keyIds;
45729
+ }
45730
+ for (const keysystem in playlist.contentProtection) {
45731
+ if (playlist.contentProtection[keysystem] && playlist.contentProtection[keysystem].attributes && playlist.contentProtection[keysystem].attributes.keyId) {
45729
45732
  const keyId = playlist.contentProtection[keysystem].attributes.keyId;
45730
- if (keyId) {
45731
- keyIds.add(keyId.toLowerCase());
45732
- }
45733
+ keyIds.add(keyId.toLowerCase());
45733
45734
  }
45734
- return keyIds;
45735
45735
  }
45736
+ return keyIds;
45736
45737
  }
45737
45738
  }
45738
45739
 
@@ -68788,7 +68789,7 @@ const initPlugin = function (player, options) {
68788
68789
  const reloadSourceOnError = function (options) {
68789
68790
  initPlugin(this, options);
68790
68791
  };
68791
- var version$4 = "3.17.0";
68792
+ var version$4 = "3.17.2";
68792
68793
  var version$3 = "7.1.0";
68793
68794
  var version$2 = "1.3.1";
68794
68795
  var version$1 = "7.2.0";
@@ -69995,45 +69996,6 @@ if (!videojs.getPlugin || !videojs.getPlugin('reloadSourceOnError')) {
69995
69996
  videojs.registerPlugin('reloadSourceOnError', reloadSourceOnError);
69996
69997
  }
69997
69998
 
69998
- /**
69999
- * @license
70000
- *
70001
- * Copyright IBM Corp. 2020, 2022
70002
- *
70003
- * This source code is licensed under the Apache-2.0 license found in the
70004
- * LICENSE file in the root directory of this source tree.
70005
- */
70006
- /**
70007
- * Form validation status.
70008
- */
70009
- var VALIDATION_STATUS;
70010
- (function (VALIDATION_STATUS) {
70011
- /**
70012
- * One indicating no validation error.
70013
- */
70014
- VALIDATION_STATUS["NO_ERROR"] = "";
70015
- /**
70016
- * One indicating that the value is invalid (generic).
70017
- */
70018
- VALIDATION_STATUS["INVALID"] = "invalid";
70019
- /**
70020
- * One indicating missing required value.
70021
- */
70022
- VALIDATION_STATUS["ERROR_REQUIRED"] = "required";
70023
- /**
70024
- * One indicating that the value does not match the pattern.
70025
- */
70026
- VALIDATION_STATUS["PATTERN"] = "pattern";
70027
- /**
70028
- * One indicating that the value is shorter than the minimum length.
70029
- */
70030
- VALIDATION_STATUS["MINLENGTH"] = "minlength";
70031
- /**
70032
- * One indicating that the value is less than the maximum length.
70033
- */
70034
- VALIDATION_STATUS["MAXLENGTH"] = "maxlength";
70035
- })(VALIDATION_STATUS || (VALIDATION_STATUS = {}));
70036
-
70037
69999
  class SetAttributesDirective extends Directive {
70038
70000
  update(part, [attributes]) {
70039
70001
  const el = part.element;
@@ -70056,6 +70018,8 @@ class SetAttributesDirective extends Directive {
70056
70018
  */
70057
70019
  directive(SetAttributesDirective);
70058
70020
 
70021
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
70022
+
70059
70023
  const connectedElements = new Set();
70060
70024
  if (window && !window.translations) {
70061
70025
  window.translations = new Map();
@@ -70265,10 +70229,11 @@ const LocalizeMixin = (Base) => class extends Base {
70265
70229
  constructor() {
70266
70230
  super(...arguments);
70267
70231
  this.localize = new LocalizeController(this);
70268
- // Provide default values to avoid definite assignment errors and avoid decorators
70269
- this.dir = '';
70270
- this.lang = '';
70271
70232
  }
70233
+ // Provide default values to avoid definite assignment errors and avoid decorators
70234
+ // commentati perchè danno problemi su React.js. Sono attributi nativi, e assegnare un valore di default a react da fastidio
70235
+ // dir: string = '';
70236
+ // lang: string = '';
70272
70237
  /**
70273
70238
  * Restituisce tutta l'utility di traduzione
70274
70239
  *
@@ -70361,9 +70326,21 @@ class Logger {
70361
70326
  class BaseComponent extends LitElement {
70362
70327
  constructor() {
70363
70328
  super();
70364
- this._ariaAttributes = {}; // tutti gli attributi aria-* passati al Web component
70329
+ this.composeClass = clsx;
70365
70330
  this.logger = new Logger(this.tagName.toLowerCase());
70366
70331
  }
70332
+ get _ariaAttributes() {
70333
+ const attributes = {};
70334
+ for (const attr of this.getAttributeNames()) {
70335
+ if (attr === 'it-role') {
70336
+ attributes.role = this.getAttribute(attr);
70337
+ }
70338
+ else if (attr.startsWith('it-aria-')) {
70339
+ attributes[attr.replace(/^it-/, '')] = this.getAttribute(attr);
70340
+ }
70341
+ }
70342
+ return attributes;
70343
+ }
70367
70344
  // eslint-disable-next-line class-methods-use-this
70368
70345
  generateId(prefix) {
70369
70346
  return `${prefix}-${Math.random().toString(36).slice(2)}`;
@@ -70373,25 +70350,22 @@ class BaseComponent extends LitElement {
70373
70350
  // new TrackFocus(element); // per il momento è stato disattivato perchè ci sono le pseudo classi ::focus-visible per fare quello che fa TrackFocus. Si possono aggiungere regole css in bsi-italia 3 dato che stiamo facendo una breaking release di bsi.
70374
70351
  }
70375
70352
  // eslint-disable-next-line class-methods-use-this
70376
- composeClass(...classes) {
70377
- let composedClass = '';
70378
- classes
70379
- .filter((c) => c.length > 0)
70380
- .forEach((newClass) => {
70381
- composedClass += ` ${newClass}`;
70382
- });
70383
- return composedClass.trim();
70384
- }
70385
- getAriaAttributes() {
70386
- for (const attr of this.getAttributeNames()) {
70387
- if (attr.startsWith('aria-')) {
70388
- this._ariaAttributes[attr] = this.getAttribute(attr);
70389
- }
70353
+ getActiveElement() {
70354
+ let active = document.activeElement;
70355
+ while (active && active.shadowRoot && active.shadowRoot.activeElement) {
70356
+ active = active.shadowRoot.activeElement;
70390
70357
  }
70358
+ return active;
70359
+ }
70360
+ get focusElement() {
70361
+ return this;
70362
+ }
70363
+ // eslint-disable-next-line class-methods-use-this
70364
+ get prefersReducedMotion() {
70365
+ return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
70391
70366
  }
70392
70367
  connectedCallback() {
70393
- super.connectedCallback?.();
70394
- this.getAriaAttributes();
70368
+ super.connectedCallback();
70395
70369
  // generate internal _id
70396
70370
  const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();
70397
70371
  this._id = this.generateId(prefix);
@@ -70399,6 +70373,668 @@ class BaseComponent extends LitElement {
70399
70373
  }
70400
70374
  const BaseLocalizedComponent = LocalizeMixin(BaseComponent);
70401
70375
 
70376
+ //
70377
+ // We store a WeakMap of forms + controls so we can keep references to all FormControl within a given form. As
70378
+ // elements connect and disconnect to/from the DOM, their containing form is used as the key and the form control is
70379
+ // added and removed from the form's set, respectively.
70380
+ //
70381
+ const formCollections = new WeakMap();
70382
+ //
70383
+ // We store a WeakMap of reportValidity() overloads so we can override it when form controls connect to the DOM and
70384
+ // restore the original behavior when they disconnect.
70385
+ //
70386
+ const reportValidityOverloads = new WeakMap();
70387
+ const checkValidityOverloads = new WeakMap();
70388
+ //
70389
+ // We store a Set of controls that users have interacted with. This allows us to determine the interaction state
70390
+ // without littering the DOM with additional data attributes.
70391
+ //
70392
+ const userInteractedControls = new WeakSet();
70393
+ //
70394
+ // We store a WeakMap of interactions for each form control so we can track when all conditions are met for validation.
70395
+ //
70396
+ const interactions = new WeakMap();
70397
+ /** A reactive controller to allow form controls to participate in form submission, validation, etc. */
70398
+ class FormControlController {
70399
+ constructor(host, options) {
70400
+ this.submittedOnce = false;
70401
+ this.handleFormData = (event) => {
70402
+ // console.log('handleFormData');
70403
+ const disabled = this.options.disabled(this.host);
70404
+ const name = this.options.name(this.host);
70405
+ const value = this.options.value(this.host);
70406
+ const tagName = this.host.tagName.toLowerCase();
70407
+ // For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by
70408
+ // injecting the name/value on a temporary button, so we can just skip them here.
70409
+ const isButton = tagName === 'it-button';
70410
+ if (this.host.isConnected &&
70411
+ !disabled &&
70412
+ !isButton &&
70413
+ typeof name === 'string' &&
70414
+ name.length > 0 &&
70415
+ typeof value !== 'undefined') {
70416
+ switch (tagName) {
70417
+ case 'it-radio':
70418
+ if (this.host.checked) {
70419
+ event.formData.append(name, value);
70420
+ }
70421
+ break;
70422
+ case 'it-checkbox':
70423
+ if (this.host.checked) {
70424
+ if (event.formData.getAll(name).indexOf(value) < 0) {
70425
+ // handle group checkbox
70426
+ event.formData.append(name, value);
70427
+ }
70428
+ }
70429
+ break;
70430
+ case 'it-checkbox-group':
70431
+ // non settare valori in formData, perchè ogni singola checkbox setta il suo valore
70432
+ break;
70433
+ default:
70434
+ if (Array.isArray(value)) {
70435
+ value.forEach((val) => {
70436
+ event.formData.append(name, val.toString());
70437
+ });
70438
+ }
70439
+ else {
70440
+ event.formData.append(name, value.toString());
70441
+ }
70442
+ }
70443
+ }
70444
+ };
70445
+ this.handleFormSubmit = (event) => {
70446
+ const disabled = this.options.disabled(this.host);
70447
+ const reportValidity = this.options.reportValidity;
70448
+ // Update the interacted state for all controls when the form is submitted
70449
+ if (this.form && !this.form.noValidate) {
70450
+ formCollections.get(this.form)?.forEach((control) => {
70451
+ this.setUserInteracted(control, true);
70452
+ });
70453
+ }
70454
+ const resReportValidity = reportValidity(this.host);
70455
+ if (this.form && !this.form.noValidate && !disabled && !resReportValidity) {
70456
+ event.preventDefault();
70457
+ // event.stopImmediatePropagation(); // se lo attiviamo, valida un campo alla volta
70458
+ // Scroll al primo controllo non valido
70459
+ const formControls = formCollections.get(this.form);
70460
+ if (formControls) {
70461
+ for (const control of formControls) {
70462
+ if (!control.validity?.valid) {
70463
+ // Scroll smooth verso il controllo non valido
70464
+ control.scrollIntoView({
70465
+ behavior: 'smooth',
70466
+ block: 'center',
70467
+ });
70468
+ break;
70469
+ }
70470
+ }
70471
+ }
70472
+ }
70473
+ this.submittedOnce = true;
70474
+ };
70475
+ this.handleFormReset = () => {
70476
+ this.options.setValue(this.host, '');
70477
+ this.submittedOnce = false;
70478
+ this.setUserInteracted(this.host, false);
70479
+ interactions.set(this.host, []);
70480
+ };
70481
+ this.handleInteraction = (event) => {
70482
+ const emittedEvents = interactions.get(this.host);
70483
+ if (!emittedEvents.includes(event.type)) {
70484
+ emittedEvents.push(event.type);
70485
+ }
70486
+ // Mark it as user-interacted as soon as all associated events have been emitted
70487
+ if (emittedEvents.length === this.options.assumeInteractionOn.length) {
70488
+ this.setUserInteracted(this.host, true);
70489
+ }
70490
+ };
70491
+ this.checkFormValidity = () => {
70492
+ // console.log('checkFormValidity');
70493
+ //
70494
+ // This is very similar to the `reportFormValidity` function, but it does not trigger native constraint validation
70495
+ // Allow the user to simply check if the form is valid and handling validity in their own way.
70496
+ //
70497
+ // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
70498
+ // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
70499
+ // be necessary once we can use ElementInternals.
70500
+ //
70501
+ // Note that we're also honoring the form's novalidate attribute.
70502
+ //
70503
+ if (this.form && !this.form.noValidate) {
70504
+ // This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
70505
+ // elements that support the constraint validation API.
70506
+ const elements = this.form.querySelectorAll('*');
70507
+ for (const element of elements) {
70508
+ if (typeof element.checkValidity === 'function') {
70509
+ if (!element.checkValidity()) {
70510
+ return false;
70511
+ }
70512
+ }
70513
+ }
70514
+ }
70515
+ return true;
70516
+ };
70517
+ this.reportFormValidity = () => {
70518
+ // console.log('reportFormValidity');
70519
+ //
70520
+ // FormControl work hard to act like regular form controls. They support the Constraint Validation API
70521
+ // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also
70522
+ // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using
70523
+ // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.
70524
+ //
70525
+ // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
70526
+ // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
70527
+ // be necessary once we can use ElementInternals.
70528
+ //
70529
+ // Note that we're also honoring the form's novalidate attribute.
70530
+ //
70531
+ if (this.form && !this.form.noValidate) {
70532
+ // This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
70533
+ // elements that support the constraint validation API.
70534
+ const elements = this.form.querySelectorAll('*');
70535
+ for (const element of elements) {
70536
+ if (typeof element.reportValidity === 'function') {
70537
+ if (!element.reportValidity()) {
70538
+ return false;
70539
+ }
70540
+ }
70541
+ }
70542
+ }
70543
+ return true;
70544
+ };
70545
+ (this.host = host).addController(this);
70546
+ this.options = {
70547
+ form: (input) => {
70548
+ // If there's a form attribute, use it to find the target form by id
70549
+ // Controls may not always reflect the 'form' property. For example, `<it-button>` doesn't reflect.
70550
+ const formId = input.form;
70551
+ if (formId) {
70552
+ const root = input.getRootNode();
70553
+ const form = root.querySelector(`#${formId}`);
70554
+ if (form) {
70555
+ return form;
70556
+ }
70557
+ }
70558
+ return input.closest('form');
70559
+ },
70560
+ name: (input) => input.name,
70561
+ value: (input) => input.value,
70562
+ disabled: (input) => input.disabled ?? false,
70563
+ reportValidity: (input) => typeof input.reportValidity === 'function' ? input.reportValidity() : true,
70564
+ checkValidity: (input) => (typeof input.checkValidity === 'function' ? input.checkValidity() : true),
70565
+ setValue: (input, value) => {
70566
+ // eslint-disable-next-line no-param-reassign
70567
+ input.value = value;
70568
+ },
70569
+ assumeInteractionOn: ['it-input'],
70570
+ ...options,
70571
+ };
70572
+ }
70573
+ hostConnected() {
70574
+ const form = this.options.form(this.host);
70575
+ if (form) {
70576
+ this.attachForm(form);
70577
+ }
70578
+ // Listen for interactions
70579
+ interactions.set(this.host, []);
70580
+ this.options.assumeInteractionOn.forEach((event) => {
70581
+ this.host.addEventListener(event, this.handleInteraction);
70582
+ });
70583
+ }
70584
+ hostDisconnected() {
70585
+ this.detachForm();
70586
+ // Clean up interactions
70587
+ interactions.delete(this.host);
70588
+ this.options.assumeInteractionOn.forEach((event) => {
70589
+ this.host.removeEventListener(event, this.handleInteraction);
70590
+ });
70591
+ }
70592
+ hostUpdated() {
70593
+ const form = this.options.form(this.host);
70594
+ // Detach if the form no longer exists
70595
+ if (!form) {
70596
+ this.detachForm();
70597
+ }
70598
+ // If the form has changed, reattach it
70599
+ if (form && this.form !== form) {
70600
+ this.detachForm();
70601
+ this.attachForm(form);
70602
+ }
70603
+ if (this.host.hasUpdated) {
70604
+ this.setValidity(this.host.validity.valid);
70605
+ }
70606
+ }
70607
+ attachForm(form) {
70608
+ if (form) {
70609
+ this.form = form;
70610
+ // Add this element to the form's collection
70611
+ if (formCollections.has(this.form)) {
70612
+ formCollections.get(this.form).add(this.host);
70613
+ }
70614
+ else {
70615
+ formCollections.set(this.form, new Set([this.host]));
70616
+ }
70617
+ this.form.addEventListener('formdata', this.handleFormData);
70618
+ this.form.addEventListener('submit', this.handleFormSubmit);
70619
+ this.form.addEventListener('reset', this.handleFormReset);
70620
+ // Overload the form's reportValidity() method so it looks at FormControl
70621
+ if (!reportValidityOverloads.has(this.form)) {
70622
+ reportValidityOverloads.set(this.form, this.form.reportValidity);
70623
+ this.form.reportValidity = () => this.reportFormValidity();
70624
+ }
70625
+ // Overload the form's checkValidity() method so it looks at FormControl
70626
+ if (!checkValidityOverloads.has(this.form)) {
70627
+ checkValidityOverloads.set(this.form, this.form.checkValidity);
70628
+ this.form.checkValidity = () => this.checkFormValidity();
70629
+ }
70630
+ }
70631
+ else {
70632
+ this.form = undefined;
70633
+ }
70634
+ }
70635
+ detachForm() {
70636
+ if (!this.form)
70637
+ return;
70638
+ const formCollection = formCollections.get(this.form);
70639
+ if (!formCollection) {
70640
+ return;
70641
+ }
70642
+ this.submittedOnce = false;
70643
+ // Remove this host from the form's collection
70644
+ formCollection.delete(this.host);
70645
+ // Check to make sure there's no other form controls in the collection. If we do this
70646
+ // without checking if any other controls are still in the collection, then we will wipe out the
70647
+ // validity checks for all other elements.
70648
+ // see: https://github.com/shoelace-style/shoelace/issues/1703
70649
+ if (formCollection.size <= 0) {
70650
+ this.form.removeEventListener('formdata', this.handleFormData);
70651
+ this.form.removeEventListener('submit', this.handleFormSubmit);
70652
+ this.form.removeEventListener('reset', this.handleFormReset);
70653
+ // Remove the overload and restore the original method
70654
+ if (reportValidityOverloads.has(this.form)) {
70655
+ this.form.reportValidity = reportValidityOverloads.get(this.form);
70656
+ reportValidityOverloads.delete(this.form);
70657
+ }
70658
+ if (checkValidityOverloads.has(this.form)) {
70659
+ this.form.checkValidity = checkValidityOverloads.get(this.form);
70660
+ checkValidityOverloads.delete(this.form);
70661
+ }
70662
+ // So it looks weird here to not always set the form to undefined. But I _think_ if we unattach this.form here,
70663
+ // we end up in this fun spot where future validity checks don't have a reference to the form validity handler.
70664
+ // First form element in sets the validity handler. So we can't clean up `this.form` until there are no other form elements in the form.
70665
+ this.form = undefined;
70666
+ }
70667
+ }
70668
+ // eslint-disable-next-line class-methods-use-this
70669
+ setUserInteracted(el, hasInteracted) {
70670
+ if (hasInteracted) {
70671
+ userInteractedControls.add(el);
70672
+ }
70673
+ else {
70674
+ userInteractedControls.delete(el);
70675
+ }
70676
+ el.requestUpdate();
70677
+ }
70678
+ doAction(type, submitter) {
70679
+ // console.log('doaction', type);
70680
+ if (this.form) {
70681
+ const button = document.createElement('button');
70682
+ button.type = type;
70683
+ button.style.position = 'absolute';
70684
+ button.style.width = '0';
70685
+ button.style.height = '0';
70686
+ button.style.clipPath = 'inset(50%)';
70687
+ button.style.overflow = 'hidden';
70688
+ button.style.whiteSpace = 'nowrap';
70689
+ // Pass name, value, and form attributes through to the temporary button
70690
+ if (submitter) {
70691
+ button.name = submitter.name;
70692
+ button.value = submitter.value;
70693
+ ['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach((attr) => {
70694
+ if (submitter.hasAttribute(attr)) {
70695
+ button.setAttribute(attr, submitter.getAttribute(attr));
70696
+ }
70697
+ });
70698
+ }
70699
+ this.form.append(button);
70700
+ button.click();
70701
+ button.remove();
70702
+ }
70703
+ }
70704
+ /** Returns the associated `<form>` element, if one exists. */
70705
+ getForm() {
70706
+ return this.form ?? null;
70707
+ }
70708
+ /** Resets the form, restoring all the control to their default value */
70709
+ reset(submitter) {
70710
+ this.doAction('reset', submitter);
70711
+ }
70712
+ /** Submits the form, triggering validation and form data injection. */
70713
+ submit(submitter) {
70714
+ // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
70715
+ // native submit button into the form, "click" it, then remove it to simulate a standard form submission.
70716
+ this.doAction('submit', submitter);
70717
+ }
70718
+ /**
70719
+ * Synchronously sets the form control's validity. Call this when you know the future validity but need to update
70720
+ * the host element immediately, i.e. before Lit updates the component in the next update.
70721
+ */
70722
+ setValidity(isValid) {
70723
+ const host = this.host;
70724
+ const hasInteracted = Boolean(userInteractedControls.has(host));
70725
+ const required = Boolean(host.required);
70726
+ //
70727
+ // We're mapping the following "states" to data attributes. In the future, we can use ElementInternals.states to
70728
+ // create a similar mapping, but instead of [data-invalid] it will look like :--invalid.
70729
+ //
70730
+ // See this RFC for more details: https://github.com/shoelace-style/shoelace/issues/1011
70731
+ //
70732
+ host.toggleAttribute('data-required', required);
70733
+ host.toggleAttribute('data-optional', !required);
70734
+ host.toggleAttribute('data-invalid', !isValid);
70735
+ host.toggleAttribute('data-valid', isValid);
70736
+ host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);
70737
+ host.toggleAttribute('data-user-valid', isValid && hasInteracted);
70738
+ }
70739
+ userInteracted() {
70740
+ const hasInteracted = Boolean(userInteractedControls.has(this.host));
70741
+ return hasInteracted;
70742
+ }
70743
+ /**
70744
+ * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything
70745
+ * that affects constraint validation changes so the component receives the correct validity states.
70746
+ */
70747
+ updateValidity() {
70748
+ const host = this.host;
70749
+ this.setValidity(host.validity.valid);
70750
+ }
70751
+ /**
70752
+ * Dispatches a non-bubbling, cancelable custom event of type `it-invalid`.
70753
+ * If the `it-invalid` event will be cancelled then the original `invalid`
70754
+ * event (which may have been passed as argument) will also be cancelled.
70755
+ * If no original `invalid` event has been passed then the `it-invalid`
70756
+ * event will be cancelled before being dispatched.
70757
+ */
70758
+ emitInvalidEvent(originalInvalidEvent) {
70759
+ const itInvalidEvent = new CustomEvent('it-invalid', {
70760
+ bubbles: false,
70761
+ composed: false,
70762
+ cancelable: true,
70763
+ detail: {},
70764
+ });
70765
+ if (!originalInvalidEvent) {
70766
+ itInvalidEvent.preventDefault();
70767
+ }
70768
+ if (!this.host.dispatchEvent(itInvalidEvent)) {
70769
+ originalInvalidEvent?.preventDefault();
70770
+ }
70771
+ }
70772
+ }
70773
+
70774
+ const translation$2 = {
70775
+ $code: 'it',
70776
+ $name: 'Italiano',
70777
+ $dir: 'ltr',
70778
+ validityRequired: 'Questo campo è obbligatorio.',
70779
+ validityGroupRequired: "Scegli almeno un'opzione",
70780
+ validityPattern: 'Il valore non corrisponde al formato richiesto.',
70781
+ validityMinlength: 'Il valore deve essere lungo almeno {minlength} caratteri.',
70782
+ validityMaxlength: 'Il valore deve essere lungo al massimo {maxlength} caratteri.',
70783
+ };
70784
+
70785
+ registerTranslation(translation$2);
70786
+ class FormControl extends BaseLocalizedComponent {
70787
+ constructor() {
70788
+ super(...arguments);
70789
+ this.formControlController = new FormControlController(this, {
70790
+ assumeInteractionOn: ['it-input', 'it-blur', 'it-change'],
70791
+ });
70792
+ // TODO: verificare se serve davvero con il fatto che usiamo form-controller
70793
+ // static formAssociated = true;
70794
+ // @property()
70795
+ // internals = this.attachInternals();
70796
+ this._touched = false;
70797
+ /** The name of the input, submitted as a name/value pair with form data. */
70798
+ this.name = '';
70799
+ /** The current value of the input, submitted as a name/value pair with form data. */
70800
+ this.value = '';
70801
+ /** If the input is disabled. */
70802
+ this.disabled = false;
70803
+ /**
70804
+ * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
70805
+ * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in
70806
+ * the same document or shadow root for this to work.
70807
+ */
70808
+ this.form = '';
70809
+ /** If you implement your custom validation and you won't to trigger default validation */
70810
+ this.customValidation = false;
70811
+ /** If your input is invalid from your custom validition, set this attribute with message validation */
70812
+ this.validationText = '';
70813
+ /**
70814
+ * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is
70815
+ * implied, allowing any numeric value. Only applies to date and number input types.
70816
+ */
70817
+ this.step = 'any';
70818
+ /** The input's minimum length. */
70819
+ this.minlength = -1;
70820
+ /** The input's maximum length. */
70821
+ this.maxlength = -1;
70822
+ /** If the input is required. */
70823
+ this.required = false;
70824
+ /* For grouped input, like checkbox-group */
70825
+ this.isInGroup = false;
70826
+ this.validationMessage = '';
70827
+ }
70828
+ /** Gets the validity state object */
70829
+ get validity() {
70830
+ return this.inputElement?.validity;
70831
+ }
70832
+ /** Gets the associated form, if one exists. */
70833
+ getForm() {
70834
+ return this.formControlController.getForm();
70835
+ }
70836
+ // Form validation methods
70837
+ checkValidity() {
70838
+ const inputValid = this.inputElement?.checkValidity() ?? true; // this.inputElement.checkValidity() è la validazione del browser
70839
+ return inputValid;
70840
+ }
70841
+ /** Checks for validity and shows the browser's validation message if the control is invalid. */
70842
+ reportValidity() {
70843
+ // const ret = this.inputElement.checkValidity();
70844
+ const ret = this.checkValidity(); // chiama la checkValidity, che se è stata overridata chiama quella
70845
+ this.handleValidationMessages();
70846
+ return ret; // this.inputElement.reportValidity();
70847
+ }
70848
+ /** Sets a custom validation message. Pass an empty string to restore validity. */
70849
+ setCustomValidity(message) {
70850
+ this.inputElement.setCustomValidity(message);
70851
+ this.validationMessage = this.inputElement.validationMessage;
70852
+ this.formControlController.updateValidity();
70853
+ }
70854
+ // Handlers
70855
+ _handleReady() {
70856
+ requestAnimationFrame(() => {
70857
+ this.dispatchEvent(new CustomEvent('it-input-ready', { bubbles: true, detail: { el: this.inputElement } }));
70858
+ });
70859
+ }
70860
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
70861
+ _handleInput(e) {
70862
+ this.handleValidationMessages();
70863
+ this.dispatchEvent(new CustomEvent('it-input', {
70864
+ detail: { value: this.inputElement.value, el: this.inputElement },
70865
+ bubbles: true,
70866
+ composed: true,
70867
+ }));
70868
+ }
70869
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
70870
+ _handleBlur(e) {
70871
+ this._touched = true;
70872
+ this.handleValidationMessages();
70873
+ this.dispatchEvent(new FocusEvent('it-blur', { bubbles: true, composed: true }));
70874
+ }
70875
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
70876
+ _handleFocus(e) {
70877
+ this.dispatchEvent(new FocusEvent('it-focus', { bubbles: true, composed: true }));
70878
+ }
70879
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
70880
+ _handleClick(e) {
70881
+ this.dispatchEvent(new MouseEvent('it-click', { bubbles: true, composed: true }));
70882
+ }
70883
+ /*
70884
+ Override default browser validation messages
70885
+ */
70886
+ handleValidationMessages() {
70887
+ if (!this.customValidation) {
70888
+ const _v = this.inputElement.validity;
70889
+ const isRequiredHandledByGroup = this.isInGroup === true;
70890
+ if (_v.valueMissing && !isRequiredHandledByGroup) {
70891
+ this.setCustomValidity(this.$t('validityRequired'));
70892
+ }
70893
+ else if (_v.patternMismatch) {
70894
+ this.setCustomValidity(this.$t('validityPattern'));
70895
+ }
70896
+ else if (_v.tooShort) {
70897
+ this.setCustomValidity(this.$t('validityMinlength').replace('{minlength}', this.minlength.toString()));
70898
+ }
70899
+ else if (_v.tooLong) {
70900
+ this.setCustomValidity(this.$t('validityMaxlength').replace('{maxlength}', this.maxlength.toString()));
70901
+ }
70902
+ else {
70903
+ /* nothing. Usa il messaggio di errore della validazione
70904
+ di default del browser per altri errori di validità come:
70905
+ - typeMismatch
70906
+ - rangeUnderflow
70907
+ - rangeOverflow
70908
+ - stepMismatch
70909
+ - badInput */
70910
+ const otherConstraintErrors = _v.typeMismatch || _v.rangeUnderflow || _v.rangeOverflow || _v.stepMismatch || _v.badInput;
70911
+ if (!otherConstraintErrors) {
70912
+ this.setCustomValidity('');
70913
+ }
70914
+ }
70915
+ }
70916
+ this.validationMessage = this.inputElement.validationMessage;
70917
+ }
70918
+ _handleInvalid(event) {
70919
+ this.formControlController.setValidity(false);
70920
+ this.formControlController.emitInvalidEvent(event);
70921
+ }
70922
+ _handleChange(e) {
70923
+ const target = e.target;
70924
+ let value;
70925
+ if (target instanceof HTMLInputElement) {
70926
+ switch (target.type) {
70927
+ case 'checkbox':
70928
+ case 'radio':
70929
+ value = target.checked;
70930
+ break;
70931
+ case 'file':
70932
+ value = target.files; // FileList
70933
+ break;
70934
+ default:
70935
+ value = target.value;
70936
+ }
70937
+ }
70938
+ else if (target instanceof HTMLSelectElement) {
70939
+ if (target.multiple) {
70940
+ value = Array.from(target.selectedOptions).map((o) => o.value);
70941
+ }
70942
+ else {
70943
+ value = target.value;
70944
+ }
70945
+ }
70946
+ else {
70947
+ // textarea o altri input con value
70948
+ value = target.value;
70949
+ }
70950
+ this.dispatchEvent(new CustomEvent('it-change', {
70951
+ detail: { value, el: target },
70952
+ bubbles: true,
70953
+ composed: true,
70954
+ }));
70955
+ }
70956
+ updated(changedProperties) {
70957
+ super.updated?.(changedProperties);
70958
+ if (this.customValidation) {
70959
+ this.setCustomValidity(this.validationText ?? '');
70960
+ }
70961
+ else if (this.formControlController.userInteracted()) {
70962
+ this.formControlController.updateValidity();
70963
+ }
70964
+ }
70965
+ }
70966
+ __decorate([
70967
+ state(),
70968
+ __metadata("design:type", Object)
70969
+ ], FormControl.prototype, "_touched", void 0);
70970
+ __decorate([
70971
+ query('.it-form__control'),
70972
+ __metadata("design:type", HTMLInputElement)
70973
+ ], FormControl.prototype, "inputElement", void 0);
70974
+ __decorate([
70975
+ property({ type: String, reflect: true }) // from FormControl
70976
+ ,
70977
+ __metadata("design:type", Object)
70978
+ ], FormControl.prototype, "name", void 0);
70979
+ __decorate([
70980
+ property({ reflect: true }),
70981
+ __metadata("design:type", Object)
70982
+ ], FormControl.prototype, "value", void 0);
70983
+ __decorate([
70984
+ property({ type: Boolean, reflect: true }) // from FormControl
70985
+ ,
70986
+ __metadata("design:type", Object)
70987
+ ], FormControl.prototype, "disabled", void 0);
70988
+ __decorate([
70989
+ property({ reflect: true, type: String }),
70990
+ __metadata("design:type", Object)
70991
+ ], FormControl.prototype, "form", void 0);
70992
+ __decorate([
70993
+ property({ type: Boolean, reflect: true, attribute: 'custom-validation' }),
70994
+ __metadata("design:type", Object)
70995
+ ], FormControl.prototype, "customValidation", void 0);
70996
+ __decorate([
70997
+ property({ attribute: 'validity-message', reflect: true }),
70998
+ __metadata("design:type", String)
70999
+ ], FormControl.prototype, "validationText", void 0);
71000
+ __decorate([
71001
+ property(),
71002
+ __metadata("design:type", String)
71003
+ ], FormControl.prototype, "pattern", void 0);
71004
+ __decorate([
71005
+ property(),
71006
+ __metadata("design:type", Object)
71007
+ ], FormControl.prototype, "min", void 0);
71008
+ __decorate([
71009
+ property(),
71010
+ __metadata("design:type", Object)
71011
+ ], FormControl.prototype, "max", void 0);
71012
+ __decorate([
71013
+ property(),
71014
+ __metadata("design:type", Object)
71015
+ ], FormControl.prototype, "step", void 0);
71016
+ __decorate([
71017
+ property({ type: Number }),
71018
+ __metadata("design:type", Object)
71019
+ ], FormControl.prototype, "minlength", void 0);
71020
+ __decorate([
71021
+ property({ type: Number }),
71022
+ __metadata("design:type", Object)
71023
+ ], FormControl.prototype, "maxlength", void 0);
71024
+ __decorate([
71025
+ property({ type: Boolean, reflect: true }) // from FormControl
71026
+ ,
71027
+ __metadata("design:type", Object)
71028
+ ], FormControl.prototype, "required", void 0);
71029
+ __decorate([
71030
+ property({ type: Boolean }),
71031
+ __metadata("design:type", Object)
71032
+ ], FormControl.prototype, "isInGroup", void 0);
71033
+ __decorate([
71034
+ state(),
71035
+ __metadata("design:type", Object)
71036
+ ], FormControl.prototype, "validationMessage", void 0);
71037
+
70402
71038
  /**
70403
71039
  * --------------------------------------------------------------------------
70404
71040
  * Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
@@ -70429,6 +71065,14 @@ const cookies = {
70429
71065
  clearAllRememberedChoices,
70430
71066
  };
70431
71067
 
71068
+ if (typeof window !== 'undefined') {
71069
+ window._itAnalytics = window._itAnalytics || {};
71070
+ window._itAnalytics = {
71071
+ ...window._itAnalytics,
71072
+ version: '1.0.0-alpha.4',
71073
+ };
71074
+ }
71075
+
70432
71076
  /* eslint-disable class-methods-use-this */
70433
71077
  /* eslint-disable prefer-destructuring */
70434
71078
  /* eslint-disable dot-notation */
@@ -73539,8 +74183,14 @@ video::-webkit-media-text-track-display {
73539
74183
  min-height: 450px;
73540
74184
  }
73541
74185
 
74186
+ .acceptoverlayable {
74187
+ aspect-ratio: 16 / 9;
74188
+ }
74189
+
73542
74190
  .acceptoverlay {
73543
74191
  --bs-acceptoverlay-color-text: #fff;
74192
+ --bs-form-control-label-color: #fff;
74193
+ --bs-form-checkbox-border-color: #fff;
73544
74194
  }
73545
74195
  .acceptoverlay a {
73546
74196
  color: var(--bs-acceptoverlay-color-text);
@@ -73576,7 +74226,7 @@ video::-webkit-media-text-track-display {
73576
74226
 
73577
74227
  :host {
73578
74228
  /*
73579
- * Regole spostate in design-web-components/styles/index.scss
74229
+ * Regole spostate in dev-kit-italia/styles/index.scss
73580
74230
  display: block;
73581
74231
  min-width: var(--it-videojs-default-width);
73582
74232
  */
@@ -73591,9 +74241,15 @@ video:not([width]) {
73591
74241
  width: var(--it-videojs-default-width);
73592
74242
  height: var(--it-videojs-default-height);
73593
74243
  }
73594
-
73595
- .vjs-fluid:not(.vjs-audio-only-mode) {
73596
- padding-top: 56.25%;
74244
+ .video-js .vjs-tech {
74245
+ position: inherit !important;
74246
+ height: auto !important;
74247
+ }
74248
+ .video-js.vjs-youtube .vjs-tech {
74249
+ aspect-ratio: 16 / 9;
74250
+ }
74251
+ .video-js:not(.vjs-audio-only-mode).vjs-fluid, .video-js:not(.vjs-audio-only-mode).vjs-16-9, .video-js:not(.vjs-audio-only-mode).vjs-4-3, .video-js:not(.vjs-audio-only-mode).vjs-9-16, .video-js:not(.vjs-audio-only-mode).vjs-1-1, .video-js:not(.vjs-audio-only-mode).vjs-youtube {
74252
+ height: auto;
73597
74253
  }`;
73598
74254
 
73599
74255
  registerTranslation(translation);
@@ -73727,26 +74383,28 @@ let ItVideo = class ItVideo extends BaseLocalizedComponent {
73727
74383
  initYoutubePlugin(videojsFn);
73728
74384
  }
73729
74385
  this.initPluginsFn?.(videojsFn); // se passata una funzione di init di ulteriori plugin, la chiama.
73730
- this.player = videojsFn(this.videoElement, mergedOptions, function onPlayerReady() {
73731
- this.addClass('vjs-theme-bootstrap-italia');
73732
- this.addClass('vjs-big-play-centered');
73733
- // Aggiungi i track manualmente
73734
- tracks.forEach((t) => {
73735
- this.addRemoteTextTrack({
73736
- kind: t.kind,
73737
- src: t.src,
73738
- srclang: t.srclang || this.language,
73739
- label: t.label,
73740
- default: !!t.default,
73741
- }, false);
73742
- });
73743
- if (focusPlayButton) {
73744
- const playButton = this.el()?.querySelector('.vjs-big-play-button');
73745
- if (playButton) {
73746
- playButton.focus();
74386
+ if (this.videoElement) {
74387
+ this.player = videojsFn(this.videoElement, mergedOptions, function onPlayerReady() {
74388
+ this.addClass('vjs-theme-bootstrap-italia');
74389
+ this.addClass('vjs-big-play-centered');
74390
+ // Aggiungi i track manualmente
74391
+ tracks.forEach((t) => {
74392
+ this.addRemoteTextTrack({
74393
+ kind: t.kind,
74394
+ src: t.src,
74395
+ srclang: t.srclang || this.language,
74396
+ label: t.label,
74397
+ default: !!t.default,
74398
+ }, false);
74399
+ });
74400
+ if (focusPlayButton) {
74401
+ const playButton = this.el()?.querySelector('.vjs-big-play-button');
74402
+ if (playButton) {
74403
+ playButton.focus();
74404
+ }
73747
74405
  }
73748
- }
73749
- });
74406
+ });
74407
+ }
73750
74408
  }
73751
74409
  }
73752
74410
  /*
@@ -73756,6 +74414,13 @@ let ItVideo = class ItVideo extends BaseLocalizedComponent {
73756
74414
  window.VIDEOJS_NO_DYNAMIC_STYLE = true; // Disabilita lo stile dinamico di Video.js
73757
74415
  this.initVideoPlayer();
73758
74416
  }
74417
+ willUpdate(changedProperties) {
74418
+ super.willUpdate(changedProperties);
74419
+ const changedLang = changedProperties.has('language');
74420
+ if (changedLang && this.player) {
74421
+ this.player.language(this.language);
74422
+ }
74423
+ }
73759
74424
  render() {
73760
74425
  const needsCookieConsent = this.needsCookieConsent();
73761
74426
  return needsCookieConsent
@@ -73775,10 +74440,14 @@ let ItVideo = class ItVideo extends BaseLocalizedComponent {
73775
74440
  ${this.$t('video_consent_accept')}
73776
74441
  </it-button>
73777
74442
 
73778
- <div class="form-check">
73779
- <input id="chk-remember" type="checkbox" @click=${() => this.acceptConsent(true)} />
73780
- <label for="chk-remember">${this.$t('video_consent_remember')}</label>
73781
- </div>
74443
+ <it-checkbox
74444
+ @click=${(e) => {
74445
+ e.preventDefault();
74446
+ e.stopPropagation();
74447
+ this.acceptConsent(true);
74448
+ }}
74449
+ ><span slot="label">${this.$t('video_consent_remember')}</span></it-checkbox
74450
+ >
73782
74451
  </div>
73783
74452
  </div>
73784
74453
  </div>
@@ -73821,7 +74490,7 @@ __decorate([
73821
74490
  __metadata("design:type", Object)
73822
74491
  ], ItVideo.prototype, "options", void 0);
73823
74492
  __decorate([
73824
- property({ type: String }),
74493
+ property({ type: String, attribute: 'lang', reflect: true }),
73825
74494
  __metadata("design:type", Object)
73826
74495
  ], ItVideo.prototype, "language", void 0);
73827
74496
  __decorate([