@italia/video 0.0.1-alpha.0 → 0.1.0-alpha.2

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,29 +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 missing required value.
70017
- */
70018
- VALIDATION_STATUS["ERROR_REQUIRED"] = "required";
70019
- })(VALIDATION_STATUS || (VALIDATION_STATUS = {}));
70020
-
70021
69999
  class SetAttributesDirective extends Directive {
70022
70000
  update(part, [attributes]) {
70023
70001
  const el = part.element;
@@ -70040,6 +70018,8 @@ class SetAttributesDirective extends Directive {
70040
70018
  */
70041
70019
  directive(SetAttributesDirective);
70042
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
+
70043
70023
  const connectedElements = new Set();
70044
70024
  if (window && !window.translations) {
70045
70025
  window.translations = new Map();
@@ -70249,10 +70229,11 @@ const LocalizeMixin = (Base) => class extends Base {
70249
70229
  constructor() {
70250
70230
  super(...arguments);
70251
70231
  this.localize = new LocalizeController(this);
70252
- // Provide default values to avoid definite assignment errors and avoid decorators
70253
- this.dir = '';
70254
- this.lang = '';
70255
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 = '';
70256
70237
  /**
70257
70238
  * Restituisce tutta l'utility di traduzione
70258
70239
  *
@@ -70345,9 +70326,21 @@ class Logger {
70345
70326
  class BaseComponent extends LitElement {
70346
70327
  constructor() {
70347
70328
  super();
70348
- this._ariaAttributes = {}; // tutti gli attributi aria-* passati al Web component
70329
+ this.composeClass = clsx;
70349
70330
  this.logger = new Logger(this.tagName.toLowerCase());
70350
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
+ }
70351
70344
  // eslint-disable-next-line class-methods-use-this
70352
70345
  generateId(prefix) {
70353
70346
  return `${prefix}-${Math.random().toString(36).slice(2)}`;
@@ -70357,25 +70350,22 @@ class BaseComponent extends LitElement {
70357
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.
70358
70351
  }
70359
70352
  // eslint-disable-next-line class-methods-use-this
70360
- composeClass(...classes) {
70361
- let composedClass = '';
70362
- classes
70363
- .filter((c) => c.length > 0)
70364
- .forEach((newClass) => {
70365
- composedClass += ` ${newClass}`;
70366
- });
70367
- return composedClass.trim();
70368
- }
70369
- getAriaAttributes() {
70370
- for (const attr of this.getAttributeNames()) {
70371
- if (attr.startsWith('aria-')) {
70372
- this._ariaAttributes[attr] = this.getAttribute(attr);
70373
- }
70353
+ getActiveElement() {
70354
+ let active = document.activeElement;
70355
+ while (active && active.shadowRoot && active.shadowRoot.activeElement) {
70356
+ active = active.shadowRoot.activeElement;
70374
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;
70375
70366
  }
70376
70367
  connectedCallback() {
70377
- super.connectedCallback?.();
70378
- this.getAriaAttributes();
70368
+ super.connectedCallback();
70379
70369
  // generate internal _id
70380
70370
  const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();
70381
70371
  this._id = this.generateId(prefix);
@@ -70383,6 +70373,625 @@ class BaseComponent extends LitElement {
70383
70373
  }
70384
70374
  const BaseLocalizedComponent = LocalizeMixin(BaseComponent);
70385
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.handleFormData = (event) => {
70401
+ // console.log('handleFormData');
70402
+ const disabled = this.options.disabled(this.host);
70403
+ const name = this.options.name(this.host);
70404
+ const value = this.options.value(this.host);
70405
+ const tagName = this.host.tagName.toLowerCase();
70406
+ // For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by
70407
+ // injecting the name/value on a temporary button, so we can just skip them here.
70408
+ const isButton = tagName === 'it-button';
70409
+ if (this.host.isConnected &&
70410
+ !disabled &&
70411
+ !isButton &&
70412
+ typeof name === 'string' &&
70413
+ name.length > 0 &&
70414
+ typeof value !== 'undefined') {
70415
+ switch (tagName) {
70416
+ case 'it-radio':
70417
+ if (this.host.checked) {
70418
+ event.formData.append(name, value);
70419
+ }
70420
+ break;
70421
+ default:
70422
+ if (Array.isArray(value)) {
70423
+ value.forEach((val) => {
70424
+ event.formData.append(name, val.toString());
70425
+ });
70426
+ }
70427
+ else {
70428
+ event.formData.append(name, value.toString());
70429
+ }
70430
+ }
70431
+ }
70432
+ };
70433
+ this.handleFormSubmit = (event) => {
70434
+ const disabled = this.options.disabled(this.host);
70435
+ const reportValidity = this.options.reportValidity;
70436
+ // Update the interacted state for all controls when the form is submitted
70437
+ if (this.form && !this.form.noValidate) {
70438
+ formCollections.get(this.form)?.forEach((control) => {
70439
+ this.setUserInteracted(control, true);
70440
+ });
70441
+ }
70442
+ if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {
70443
+ event.preventDefault();
70444
+ // event.stopImmediatePropagation(); // se lo attiviamo, valida un campo alla volta
70445
+ }
70446
+ };
70447
+ this.handleFormReset = () => {
70448
+ this.options.setValue(this.host, '');
70449
+ this.setUserInteracted(this.host, false);
70450
+ interactions.set(this.host, []);
70451
+ };
70452
+ this.handleInteraction = (event) => {
70453
+ const emittedEvents = interactions.get(this.host);
70454
+ if (!emittedEvents.includes(event.type)) {
70455
+ emittedEvents.push(event.type);
70456
+ }
70457
+ // Mark it as user-interacted as soon as all associated events have been emitted
70458
+ if (emittedEvents.length === this.options.assumeInteractionOn.length) {
70459
+ this.setUserInteracted(this.host, true);
70460
+ }
70461
+ };
70462
+ this.checkFormValidity = () => {
70463
+ // console.log('checkFormValidity');
70464
+ //
70465
+ // This is very similar to the `reportFormValidity` function, but it does not trigger native constraint validation
70466
+ // Allow the user to simply check if the form is valid and handling validity in their own way.
70467
+ //
70468
+ // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
70469
+ // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
70470
+ // be necessary once we can use ElementInternals.
70471
+ //
70472
+ // Note that we're also honoring the form's novalidate attribute.
70473
+ //
70474
+ if (this.form && !this.form.noValidate) {
70475
+ // This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
70476
+ // elements that support the constraint validation API.
70477
+ const elements = this.form.querySelectorAll('*');
70478
+ for (const element of elements) {
70479
+ if (typeof element.checkValidity === 'function') {
70480
+ if (!element.checkValidity()) {
70481
+ return false;
70482
+ }
70483
+ }
70484
+ }
70485
+ }
70486
+ return true;
70487
+ };
70488
+ this.reportFormValidity = () => {
70489
+ // console.log('reportFormValidity');
70490
+ //
70491
+ // FormControl work hard to act like regular form controls. They support the Constraint Validation API
70492
+ // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also
70493
+ // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using
70494
+ // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.
70495
+ //
70496
+ // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
70497
+ // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
70498
+ // be necessary once we can use ElementInternals.
70499
+ //
70500
+ // Note that we're also honoring the form's novalidate attribute.
70501
+ //
70502
+ if (this.form && !this.form.noValidate) {
70503
+ // This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
70504
+ // elements that support the constraint validation API.
70505
+ const elements = this.form.querySelectorAll('*');
70506
+ for (const element of elements) {
70507
+ if (typeof element.reportValidity === 'function') {
70508
+ if (!element.reportValidity()) {
70509
+ return false;
70510
+ }
70511
+ }
70512
+ }
70513
+ }
70514
+ return true;
70515
+ };
70516
+ (this.host = host).addController(this);
70517
+ this.options = {
70518
+ form: (input) => {
70519
+ // If there's a form attribute, use it to find the target form by id
70520
+ // Controls may not always reflect the 'form' property. For example, `<it-button>` doesn't reflect.
70521
+ const formId = input.form;
70522
+ if (formId) {
70523
+ const root = input.getRootNode();
70524
+ const form = root.querySelector(`#${formId}`);
70525
+ if (form) {
70526
+ return form;
70527
+ }
70528
+ }
70529
+ return input.closest('form');
70530
+ },
70531
+ name: (input) => input.name,
70532
+ value: (input) => input.value,
70533
+ disabled: (input) => input.disabled ?? false,
70534
+ reportValidity: (input) => typeof input.reportValidity === 'function' ? input.reportValidity() : true,
70535
+ checkValidity: (input) => (typeof input.checkValidity === 'function' ? input.checkValidity() : true),
70536
+ setValue: (input, value) => {
70537
+ // eslint-disable-next-line no-param-reassign
70538
+ input.value = value;
70539
+ },
70540
+ assumeInteractionOn: ['it-input'],
70541
+ ...options,
70542
+ };
70543
+ }
70544
+ hostConnected() {
70545
+ const form = this.options.form(this.host);
70546
+ if (form) {
70547
+ this.attachForm(form);
70548
+ }
70549
+ // Listen for interactions
70550
+ interactions.set(this.host, []);
70551
+ this.options.assumeInteractionOn.forEach((event) => {
70552
+ this.host.addEventListener(event, this.handleInteraction);
70553
+ });
70554
+ }
70555
+ hostDisconnected() {
70556
+ this.detachForm();
70557
+ // Clean up interactions
70558
+ interactions.delete(this.host);
70559
+ this.options.assumeInteractionOn.forEach((event) => {
70560
+ this.host.removeEventListener(event, this.handleInteraction);
70561
+ });
70562
+ }
70563
+ hostUpdated() {
70564
+ const form = this.options.form(this.host);
70565
+ // Detach if the form no longer exists
70566
+ if (!form) {
70567
+ this.detachForm();
70568
+ }
70569
+ // If the form has changed, reattach it
70570
+ if (form && this.form !== form) {
70571
+ this.detachForm();
70572
+ this.attachForm(form);
70573
+ }
70574
+ if (this.host.hasUpdated) {
70575
+ this.setValidity(this.host.validity.valid);
70576
+ }
70577
+ }
70578
+ attachForm(form) {
70579
+ if (form) {
70580
+ this.form = form;
70581
+ // Add this element to the form's collection
70582
+ if (formCollections.has(this.form)) {
70583
+ formCollections.get(this.form).add(this.host);
70584
+ }
70585
+ else {
70586
+ formCollections.set(this.form, new Set([this.host]));
70587
+ }
70588
+ this.form.addEventListener('formdata', this.handleFormData);
70589
+ this.form.addEventListener('submit', this.handleFormSubmit);
70590
+ this.form.addEventListener('reset', this.handleFormReset);
70591
+ // Overload the form's reportValidity() method so it looks at FormControl
70592
+ if (!reportValidityOverloads.has(this.form)) {
70593
+ reportValidityOverloads.set(this.form, this.form.reportValidity);
70594
+ this.form.reportValidity = () => this.reportFormValidity();
70595
+ }
70596
+ // Overload the form's checkValidity() method so it looks at FormControl
70597
+ if (!checkValidityOverloads.has(this.form)) {
70598
+ checkValidityOverloads.set(this.form, this.form.checkValidity);
70599
+ this.form.checkValidity = () => this.checkFormValidity();
70600
+ }
70601
+ }
70602
+ else {
70603
+ this.form = undefined;
70604
+ }
70605
+ }
70606
+ detachForm() {
70607
+ if (!this.form)
70608
+ return;
70609
+ const formCollection = formCollections.get(this.form);
70610
+ if (!formCollection) {
70611
+ return;
70612
+ }
70613
+ // Remove this host from the form's collection
70614
+ formCollection.delete(this.host);
70615
+ // Check to make sure there's no other form controls in the collection. If we do this
70616
+ // without checking if any other controls are still in the collection, then we will wipe out the
70617
+ // validity checks for all other elements.
70618
+ // see: https://github.com/shoelace-style/shoelace/issues/1703
70619
+ if (formCollection.size <= 0) {
70620
+ this.form.removeEventListener('formdata', this.handleFormData);
70621
+ this.form.removeEventListener('submit', this.handleFormSubmit);
70622
+ this.form.removeEventListener('reset', this.handleFormReset);
70623
+ // Remove the overload and restore the original method
70624
+ if (reportValidityOverloads.has(this.form)) {
70625
+ this.form.reportValidity = reportValidityOverloads.get(this.form);
70626
+ reportValidityOverloads.delete(this.form);
70627
+ }
70628
+ if (checkValidityOverloads.has(this.form)) {
70629
+ this.form.checkValidity = checkValidityOverloads.get(this.form);
70630
+ checkValidityOverloads.delete(this.form);
70631
+ }
70632
+ // So it looks weird here to not always set the form to undefined. But I _think_ if we unattach this.form here,
70633
+ // we end up in this fun spot where future validity checks don't have a reference to the form validity handler.
70634
+ // 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.
70635
+ this.form = undefined;
70636
+ }
70637
+ }
70638
+ // eslint-disable-next-line class-methods-use-this
70639
+ setUserInteracted(el, hasInteracted) {
70640
+ if (hasInteracted) {
70641
+ userInteractedControls.add(el);
70642
+ }
70643
+ else {
70644
+ userInteractedControls.delete(el);
70645
+ }
70646
+ el.requestUpdate();
70647
+ }
70648
+ doAction(type, submitter) {
70649
+ // console.log('doaction', type);
70650
+ if (this.form) {
70651
+ const button = document.createElement('button');
70652
+ button.type = type;
70653
+ button.style.position = 'absolute';
70654
+ button.style.width = '0';
70655
+ button.style.height = '0';
70656
+ button.style.clipPath = 'inset(50%)';
70657
+ button.style.overflow = 'hidden';
70658
+ button.style.whiteSpace = 'nowrap';
70659
+ // Pass name, value, and form attributes through to the temporary button
70660
+ if (submitter) {
70661
+ button.name = submitter.name;
70662
+ button.value = submitter.value;
70663
+ ['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach((attr) => {
70664
+ if (submitter.hasAttribute(attr)) {
70665
+ button.setAttribute(attr, submitter.getAttribute(attr));
70666
+ }
70667
+ });
70668
+ }
70669
+ this.form.append(button);
70670
+ button.click();
70671
+ button.remove();
70672
+ }
70673
+ }
70674
+ /** Returns the associated `<form>` element, if one exists. */
70675
+ getForm() {
70676
+ return this.form ?? null;
70677
+ }
70678
+ /** Resets the form, restoring all the control to their default value */
70679
+ reset(submitter) {
70680
+ this.doAction('reset', submitter);
70681
+ }
70682
+ /** Submits the form, triggering validation and form data injection. */
70683
+ submit(submitter) {
70684
+ // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
70685
+ // native submit button into the form, "click" it, then remove it to simulate a standard form submission.
70686
+ this.doAction('submit', submitter);
70687
+ }
70688
+ /**
70689
+ * Synchronously sets the form control's validity. Call this when you know the future validity but need to update
70690
+ * the host element immediately, i.e. before Lit updates the component in the next update.
70691
+ */
70692
+ setValidity(isValid) {
70693
+ const host = this.host;
70694
+ const hasInteracted = Boolean(userInteractedControls.has(host));
70695
+ const required = Boolean(host.required);
70696
+ //
70697
+ // We're mapping the following "states" to data attributes. In the future, we can use ElementInternals.states to
70698
+ // create a similar mapping, but instead of [data-invalid] it will look like :--invalid.
70699
+ //
70700
+ // See this RFC for more details: https://github.com/shoelace-style/shoelace/issues/1011
70701
+ //
70702
+ host.toggleAttribute('data-required', required);
70703
+ host.toggleAttribute('data-optional', !required);
70704
+ host.toggleAttribute('data-invalid', !isValid);
70705
+ host.toggleAttribute('data-valid', isValid);
70706
+ host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);
70707
+ host.toggleAttribute('data-user-valid', isValid && hasInteracted);
70708
+ }
70709
+ /**
70710
+ * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything
70711
+ * that affects constraint validation changes so the component receives the correct validity states.
70712
+ */
70713
+ updateValidity() {
70714
+ const host = this.host;
70715
+ this.setValidity(host.validity.valid);
70716
+ }
70717
+ /**
70718
+ * Dispatches a non-bubbling, cancelable custom event of type `it-invalid`.
70719
+ * If the `it-invalid` event will be cancelled then the original `invalid`
70720
+ * event (which may have been passed as argument) will also be cancelled.
70721
+ * If no original `invalid` event has been passed then the `it-invalid`
70722
+ * event will be cancelled before being dispatched.
70723
+ */
70724
+ emitInvalidEvent(originalInvalidEvent) {
70725
+ const itInvalidEvent = new CustomEvent('it-invalid', {
70726
+ bubbles: false,
70727
+ composed: false,
70728
+ cancelable: true,
70729
+ detail: {},
70730
+ });
70731
+ if (!originalInvalidEvent) {
70732
+ itInvalidEvent.preventDefault();
70733
+ }
70734
+ if (!this.host.dispatchEvent(itInvalidEvent)) {
70735
+ originalInvalidEvent?.preventDefault();
70736
+ }
70737
+ }
70738
+ }
70739
+
70740
+ const translation$2 = {
70741
+ $code: 'it',
70742
+ $name: 'Italiano',
70743
+ $dir: 'ltr',
70744
+ validityRequired: 'Questo campo è obbligatorio.',
70745
+ validityPattern: 'Il valore non corrisponde al formato richiesto.',
70746
+ validityMinlength: 'Il valore deve essere lungo almeno {minlength} caratteri.',
70747
+ validityMaxlength: 'Il valore deve essere lungo al massimo {maxlength} caratteri.',
70748
+ };
70749
+
70750
+ registerTranslation(translation$2);
70751
+ class FormControl extends BaseLocalizedComponent {
70752
+ constructor() {
70753
+ super(...arguments);
70754
+ this.formControlController = new FormControlController(this, {
70755
+ assumeInteractionOn: ['it-input', 'it-blur', 'it-change'],
70756
+ });
70757
+ // TODO: verificare se serve davvero con il fatto che usiamo form-controller
70758
+ // static formAssociated = true;
70759
+ // @property()
70760
+ // internals = this.attachInternals();
70761
+ this._touched = false;
70762
+ /** The name of the input, submitted as a name/value pair with form data. */
70763
+ this.name = '';
70764
+ /** The current value of the input, submitted as a name/value pair with form data. */
70765
+ this.value = '';
70766
+ /** If the input is disabled. */
70767
+ this.disabled = false;
70768
+ /**
70769
+ * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
70770
+ * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in
70771
+ * the same document or shadow root for this to work.
70772
+ */
70773
+ this.form = '';
70774
+ /** If you implement your custom validation and you won't to trigger default validation */
70775
+ this.customValidation = false;
70776
+ /** If your input is invalid from your custom validition, set this attribute with message validation */
70777
+ this.validationText = '';
70778
+ /**
70779
+ * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is
70780
+ * implied, allowing any numeric value. Only applies to date and number input types.
70781
+ */
70782
+ this.step = 'any';
70783
+ /** The input's minimum length. */
70784
+ this.minlength = -1;
70785
+ /** The input's maximum length. */
70786
+ this.maxlength = -1;
70787
+ /** If the input is required. */
70788
+ this.required = false;
70789
+ this.validationMessage = '';
70790
+ }
70791
+ /** Gets the validity state object */
70792
+ get validity() {
70793
+ return this.inputElement?.validity;
70794
+ }
70795
+ // Form validation methods
70796
+ checkValidity() {
70797
+ const inputValid = this.inputElement?.checkValidity() ?? true; // this.inputElement.checkValidity() è la validazione del browser
70798
+ return inputValid;
70799
+ }
70800
+ /** Gets the associated form, if one exists. */
70801
+ getForm() {
70802
+ return this.formControlController.getForm();
70803
+ }
70804
+ /** Checks for validity and shows the browser's validation message if the control is invalid. */
70805
+ reportValidity() {
70806
+ const ret = this.inputElement.checkValidity();
70807
+ this.handleValidationMessages();
70808
+ return ret; // this.inputElement.reportValidity();
70809
+ }
70810
+ /** Sets a custom validation message. Pass an empty string to restore validity. */
70811
+ setCustomValidity(message) {
70812
+ this.inputElement.setCustomValidity(message);
70813
+ this.validationMessage = this.inputElement.validationMessage;
70814
+ this.formControlController.updateValidity();
70815
+ }
70816
+ // Handlers
70817
+ _handleReady() {
70818
+ requestAnimationFrame(() => {
70819
+ this.dispatchEvent(new CustomEvent('it-input-ready', { bubbles: true, detail: { el: this.inputElement } }));
70820
+ });
70821
+ }
70822
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
70823
+ _handleInput(e) {
70824
+ this.handleValidationMessages();
70825
+ this.dispatchEvent(new CustomEvent('it-input', {
70826
+ detail: { value: this.inputElement.value, el: this.inputElement },
70827
+ bubbles: true,
70828
+ composed: true,
70829
+ }));
70830
+ }
70831
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
70832
+ _handleBlur(e) {
70833
+ this._touched = true;
70834
+ this.handleValidationMessages();
70835
+ this.dispatchEvent(new FocusEvent('it-blur', { bubbles: true, composed: true }));
70836
+ }
70837
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
70838
+ _handleFocus(e) {
70839
+ this.dispatchEvent(new FocusEvent('it-focus', { bubbles: true, composed: true }));
70840
+ }
70841
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
70842
+ _handleClick(e) {
70843
+ this.dispatchEvent(new MouseEvent('it-click', { bubbles: true, composed: true }));
70844
+ }
70845
+ /*
70846
+ Override default browser validation messages
70847
+ */
70848
+ handleValidationMessages() {
70849
+ if (!this.customValidation) {
70850
+ const _v = this.inputElement.validity;
70851
+ if (_v.valueMissing) {
70852
+ this.setCustomValidity(this.$t('validityRequired'));
70853
+ }
70854
+ else if (_v.patternMismatch) {
70855
+ this.setCustomValidity(this.$t('validityPattern'));
70856
+ }
70857
+ else if (_v.tooShort) {
70858
+ this.setCustomValidity(this.$t('validityMinlength').replace('{minlength}', this.minlength.toString()));
70859
+ }
70860
+ else if (_v.tooLong) {
70861
+ this.setCustomValidity(this.$t('validityMaxlength').replace('{maxlength}', this.maxlength.toString()));
70862
+ }
70863
+ else {
70864
+ /* nothing. Usa il messaggio di errore della validazione
70865
+ di default del browser per altri errori di validità come:
70866
+ - typeMismatch
70867
+ - rangeUnderflow
70868
+ - rangeOverflow
70869
+ - stepMismatch
70870
+ - badInput */
70871
+ const otherConstraintErrors = _v.typeMismatch || _v.rangeUnderflow || _v.rangeOverflow || _v.stepMismatch || _v.badInput;
70872
+ if (!otherConstraintErrors) {
70873
+ this.setCustomValidity('');
70874
+ }
70875
+ }
70876
+ }
70877
+ this.validationMessage = this.inputElement.validationMessage;
70878
+ }
70879
+ _handleInvalid(event) {
70880
+ this.formControlController.setValidity(false);
70881
+ this.formControlController.emitInvalidEvent(event);
70882
+ }
70883
+ _handleChange(e) {
70884
+ const target = e.target;
70885
+ let value;
70886
+ if (target instanceof HTMLInputElement) {
70887
+ switch (target.type) {
70888
+ case 'checkbox':
70889
+ case 'radio':
70890
+ value = target.checked;
70891
+ break;
70892
+ case 'file':
70893
+ value = target.files; // FileList
70894
+ break;
70895
+ default:
70896
+ value = target.value;
70897
+ }
70898
+ }
70899
+ else if (target instanceof HTMLSelectElement) {
70900
+ if (target.multiple) {
70901
+ value = Array.from(target.selectedOptions).map((o) => o.value);
70902
+ }
70903
+ else {
70904
+ value = target.value;
70905
+ }
70906
+ }
70907
+ else {
70908
+ // textarea o altri input con value
70909
+ value = target.value;
70910
+ }
70911
+ this.dispatchEvent(new CustomEvent('it-change', {
70912
+ detail: { value, el: target },
70913
+ bubbles: true,
70914
+ composed: true,
70915
+ }));
70916
+ }
70917
+ updated(changedProperties) {
70918
+ super.updated?.(changedProperties);
70919
+ if (this.customValidation) {
70920
+ this.setCustomValidity(this.validationText ?? '');
70921
+ }
70922
+ else {
70923
+ this.formControlController.updateValidity();
70924
+ }
70925
+ }
70926
+ }
70927
+ __decorate([
70928
+ state(),
70929
+ __metadata("design:type", Object)
70930
+ ], FormControl.prototype, "_touched", void 0);
70931
+ __decorate([
70932
+ query('.it-form__control'),
70933
+ __metadata("design:type", HTMLInputElement)
70934
+ ], FormControl.prototype, "inputElement", void 0);
70935
+ __decorate([
70936
+ property({ type: String, reflect: true }) // from FormControl
70937
+ ,
70938
+ __metadata("design:type", Object)
70939
+ ], FormControl.prototype, "name", void 0);
70940
+ __decorate([
70941
+ property({ reflect: true }),
70942
+ __metadata("design:type", Object)
70943
+ ], FormControl.prototype, "value", void 0);
70944
+ __decorate([
70945
+ property({ type: Boolean, reflect: true }) // from FormControl
70946
+ ,
70947
+ __metadata("design:type", Object)
70948
+ ], FormControl.prototype, "disabled", void 0);
70949
+ __decorate([
70950
+ property({ reflect: true, type: String }),
70951
+ __metadata("design:type", Object)
70952
+ ], FormControl.prototype, "form", void 0);
70953
+ __decorate([
70954
+ property({ type: Boolean, reflect: true, attribute: 'custom-validation' }),
70955
+ __metadata("design:type", Object)
70956
+ ], FormControl.prototype, "customValidation", void 0);
70957
+ __decorate([
70958
+ property({ attribute: 'validity-message', reflect: true }),
70959
+ __metadata("design:type", String)
70960
+ ], FormControl.prototype, "validationText", void 0);
70961
+ __decorate([
70962
+ property(),
70963
+ __metadata("design:type", String)
70964
+ ], FormControl.prototype, "pattern", void 0);
70965
+ __decorate([
70966
+ property(),
70967
+ __metadata("design:type", Object)
70968
+ ], FormControl.prototype, "min", void 0);
70969
+ __decorate([
70970
+ property(),
70971
+ __metadata("design:type", Object)
70972
+ ], FormControl.prototype, "max", void 0);
70973
+ __decorate([
70974
+ property(),
70975
+ __metadata("design:type", Object)
70976
+ ], FormControl.prototype, "step", void 0);
70977
+ __decorate([
70978
+ property({ type: Number }),
70979
+ __metadata("design:type", Object)
70980
+ ], FormControl.prototype, "minlength", void 0);
70981
+ __decorate([
70982
+ property({ type: Number }),
70983
+ __metadata("design:type", Object)
70984
+ ], FormControl.prototype, "maxlength", void 0);
70985
+ __decorate([
70986
+ property({ type: Boolean, reflect: true }) // from FormControl
70987
+ ,
70988
+ __metadata("design:type", Object)
70989
+ ], FormControl.prototype, "required", void 0);
70990
+ __decorate([
70991
+ state(),
70992
+ __metadata("design:type", Object)
70993
+ ], FormControl.prototype, "validationMessage", void 0);
70994
+
70386
70995
  /**
70387
70996
  * --------------------------------------------------------------------------
70388
70997
  * Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
@@ -71321,95 +71930,6 @@ var styles = css`/***************************** 1 ******************************
71321
71930
  /***************************** NEUTRAL 1 ****************************************/
71322
71931
  /***************************** NEUTRAL 2 ****************************************/
71323
71932
  /***************************** NEUTRAL 2 / 3 ****************************************/
71324
- .form-check .toggles label:has(input[type=checkbox]:focus:not([data-focus-mouse=true])), :focus:not([data-focus-mouse=true]),
71325
- .it-carousel-wrapper .splide__pagination button:focus:not([data-focus-mouse=true]),
71326
- .upload:focus:not([data-focus-mouse=true]) + label,
71327
- .upload-dragdrop-input:focus[type=file]:not([data-focus-mouse=true]) + label,
71328
- .avatar-upload:focus-within:not([data-focus-mouse=true]),
71329
- .rating input:focus:not([data-focus-mouse=true]) + label svg {
71330
- border-color: hsl(0, 0%, 0%) !important;
71331
- box-shadow: 0 0 0 2px var(--bs-color-border-inverse), 0 0 0 5px var(--bs-color-outline-focus) !important;
71332
- outline: 3px solid transparent !important;
71333
- outline-offset: 3px !important;
71334
- }
71335
-
71336
- .form-check .toggles label:has(input[type=checkbox]:focus[data-focus-mouse=true]), [data-focus-mouse=true]:not(.btn) {
71337
- border-color: inherit !important;
71338
- box-shadow: none !important;
71339
- outline: none !important;
71340
- }
71341
-
71342
- [tabindex="-1"]:focus:not(:focus-visible) {
71343
- box-shadow: none !important;
71344
- }
71345
-
71346
- p a:focus:not([data-focus-mouse=true], .btn) {
71347
- outline-offset: 0px !important;
71348
- outline: 3px hsl(0, 0%, 0%) solid !important;
71349
- background: hsl(0, 0%, 100%);
71350
- box-shadow: none !important;
71351
- color: hsl(210, 100%, 40%) !important;
71352
- }
71353
-
71354
- .shadow:focus:not([data-focus-mouse=true]),
71355
- .shadow-none:focus:not([data-focus-mouse=true]),
71356
- .shadow-sm:focus:not([data-focus-mouse=true]),
71357
- .shadow-lg:focus:not([data-focus-mouse=true]) {
71358
- box-shadow: 0 0 0 2px hsl(0, 0%, 100%), 0 0 0 5px hsl(0, 0%, 0%) !important;
71359
- }
71360
-
71361
- .avatar-group-stacked .avatar:focus:not([data-focus-mouse=true]) {
71362
- border: 0;
71363
- margin-left: -4px;
71364
- margin-top: 2px;
71365
- margin-right: 2px;
71366
- }
71367
- .avatar-group-stacked .avatar.avatar-dropdown .btn-dropdown:focus:not([data-focus-mouse=true]) {
71368
- height: 100%;
71369
- width: 100%;
71370
- border-radius: 50%;
71371
- }
71372
-
71373
- .chip button:focus:not([data-focus-mouse=true]) {
71374
- border-radius: 50%;
71375
- }
71376
-
71377
- .form-check .toggles label:has(input[type=checkbox]:focus:not([data-focus-mouse=true])) input,
71378
- .form-check .toggles label:has(input[type=checkbox]:focus:not([data-focus-mouse=true])) .lever {
71379
- border-color: inherit !important;
71380
- box-shadow: none !important;
71381
- outline: none !important;
71382
- }
71383
- .form-check.form-check-group :focus:not([data-focus-mouse=true]),
71384
- .form-check.form-check-group [type=checkbox]:focus + label,
71385
- .form-check.form-check-group [type=radio]:focus + label {
71386
- width: 100%;
71387
- }
71388
-
71389
- .bg-dark .btn:focus:not([data-focus-mouse=true]),
71390
- .bg-dark .it-carousel-wrapper .splide__pagination button.btn:focus:not([data-focus-mouse=true]),
71391
- .it-carousel-wrapper .splide__pagination .bg-dark button.btn:focus:not([data-focus-mouse=true]),
71392
- .bg-dark .upload:focus:not([data-focus-mouse=true]) + label.btn,
71393
- .bg-dark .upload-dragdrop-input:focus[type=file]:not([data-focus-mouse=true]) + label.btn,
71394
- .bg-dark .btn.avatar-upload:focus-within:not([data-focus-mouse=true]),
71395
- .bg-dark .rating input:focus:not([data-focus-mouse=true]) + label svg.btn,
71396
- .rating input:focus:not([data-focus-mouse=true]) + label .bg-dark svg.btn, .bg-dark .form-check .toggles label.btn:has(input[type=checkbox]:focus:not([data-focus-mouse=true])), .form-check .toggles .bg-dark label.btn:has(input[type=checkbox]:focus:not([data-focus-mouse=true])),
71397
- .back-to-top.dark:focus:not([data-focus-mouse=true]),
71398
- .it-carousel-wrapper .splide__pagination button.back-to-top.dark:focus:not([data-focus-mouse=true]),
71399
- .upload:focus:not([data-focus-mouse=true]) + label.back-to-top.dark,
71400
- .upload-dragdrop-input:focus[type=file]:not([data-focus-mouse=true]) + label.back-to-top.dark,
71401
- .back-to-top.dark.avatar-upload:focus-within:not([data-focus-mouse=true]),
71402
- .rating input:focus:not([data-focus-mouse=true]) + label svg.back-to-top.dark,
71403
- .form-check .toggles label.back-to-top.dark:has(input[type=checkbox]:focus:not([data-focus-mouse=true])) {
71404
- box-shadow: 0 0 0 2px hsl(0, 0%, 0%), 0 0 0 5px hsl(0, 0%, 100%) !important;
71405
- }
71406
-
71407
- .autocomplete__wrapper .autocomplete__menu .autocomplete__hint:focus,
71408
- .autocomplete__wrapper .autocomplete__menu .autocomplete__option:focus {
71409
- border: 3px solid hsl(0, 0%, 0%) !important;
71410
- box-shadow: none !important;
71411
- }
71412
-
71413
71933
  /* stylelint-disable */
71414
71934
  .vjs-svg-icon {
71415
71935
  display: inline-block;
@@ -73649,7 +74169,7 @@ video::-webkit-media-text-track-display {
73649
74169
 
73650
74170
  :host {
73651
74171
  /*
73652
- * Regole spostate in design-web-components/styles/index.scss
74172
+ * Regole spostate in dev-kit-italia/styles/index.scss
73653
74173
  display: block;
73654
74174
  min-width: var(--it-videojs-default-width);
73655
74175
  */
@@ -73829,6 +74349,13 @@ let ItVideo = class ItVideo extends BaseLocalizedComponent {
73829
74349
  window.VIDEOJS_NO_DYNAMIC_STYLE = true; // Disabilita lo stile dinamico di Video.js
73830
74350
  this.initVideoPlayer();
73831
74351
  }
74352
+ willUpdate(changedProperties) {
74353
+ super.willUpdate(changedProperties);
74354
+ const changedLang = changedProperties.has('language');
74355
+ if (changedLang && this.player) {
74356
+ this.player.language(this.language);
74357
+ }
74358
+ }
73832
74359
  render() {
73833
74360
  const needsCookieConsent = this.needsCookieConsent();
73834
74361
  return needsCookieConsent
@@ -73894,11 +74421,11 @@ __decorate([
73894
74421
  __metadata("design:type", Object)
73895
74422
  ], ItVideo.prototype, "options", void 0);
73896
74423
  __decorate([
73897
- property({ type: String }),
74424
+ property({ type: String, attribute: 'lang', reflect: true }),
73898
74425
  __metadata("design:type", Object)
73899
74426
  ], ItVideo.prototype, "language", void 0);
73900
74427
  __decorate([
73901
- property({ type: Object }),
74428
+ property({ type: Object, reflect: true }),
73902
74429
  __metadata("design:type", Object)
73903
74430
  ], ItVideo.prototype, "translations", void 0);
73904
74431
  __decorate([