@optionfactory/ful 6.0.5 → 6.0.7

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/dist/ful.iife.js CHANGED
@@ -1774,7 +1774,7 @@ var ful = (function (exports, ftl) {
1774
1774
  <ful-item data-tpl-each="files" data-tpl-var="file" data-tpl-data-name="file.name">
1775
1775
  <div>{{ file.name }}</div>
1776
1776
  <div>{{ #bytes:format(file.size) }}</div>
1777
- <button type="button" class="btn btn-sm btn-outline-danger bi bi-x-lg"></button>
1777
+ <button type="button" class="btn btn-sm btn-outline-danger bi bi-x-lg" alt="Rimuovi"></button>
1778
1778
  </ful-item>
1779
1779
  `,
1780
1780
  warning: `<ful-field-warning>{{ #l10n:t(key, args) }}</ful-field-warning>`
@@ -2023,20 +2023,22 @@ var ful = (function (exports, ftl) {
2023
2023
  if (this.#data !== null) {
2024
2024
  return
2025
2025
  }
2026
- const storageKey = `${this.#method}@${this.#url}`;
2027
- if (this.#revision !== null) {
2028
- const data = VersionedLocalStorage.load(storageKey, this.#revision);
2026
+ const raw = RemoteLoader.#revisionedData(this.#http, this.#method, this.#url, this.#revision);
2027
+ this.#data = this.#responseMapper(raw);
2028
+ }
2029
+ static async #revisionedData(http, method, url, revision){
2030
+ const storageKey = `${method}@${url}`;
2031
+ if (revision !== null) {
2032
+ const data = VersionedLocalStorage.load(storageKey, revision);
2029
2033
  if (data !== undefined) {
2030
- this.#data = data;
2031
- return;
2034
+ return data;
2032
2035
  }
2033
2036
  }
2034
- const data = await this.#http.request(this.#method, this.#url)
2035
- .fetchJson();
2036
- this.#data = this.#responseMapper(data);
2037
- if (this.#revision !== null) {
2038
- VersionedLocalStorage.save(storageKey, this.#revision, this.#data);
2037
+ const data = await http.request(method, url).fetchJson();
2038
+ if (revision !== null) {
2039
+ VersionedLocalStorage.save(storageKey, revision, data);
2039
2040
  }
2041
+ return data;
2040
2042
  }
2041
2043
  }
2042
2044
 
@@ -2643,7 +2645,7 @@ var ful = (function (exports, ftl) {
2643
2645
  static template = `
2644
2646
  <div data-tpl-class="klass">
2645
2647
  <div class="input-container">
2646
- <input class="form-check-input" type="checkbox" role="switch" form="" placeholder=" ">
2648
+ <input class="form-check-input" type="checkbox" data-tpl-role="isSwitch ? 'switch' : false" form="" placeholder=" ">
2647
2649
  </div>
2648
2650
  <div class="form-check-label">
2649
2651
  <label>{{{{ slots.default }}}}</label>
@@ -2662,8 +2664,9 @@ var ful = (function (exports, ftl) {
2662
2664
  this.internals.role = 'presentation';
2663
2665
  }
2664
2666
  render({ slots, observed, disabled }) {
2665
- const klass = this.getAttribute('type') == 'switch' ? "form-check form-switch" : "form-check";
2666
- const fragment = this.template().withOverlay({ slots, klass }).render();
2667
+ const isSwitch = this.getAttribute('type') == 'switch';
2668
+ const klass = isSwitch ? "form-check form-switch" : "form-check";
2669
+ const fragment = this.template().withOverlay({ slots, klass, isSwitch }).render();
2667
2670
  this.#container = fragment.firstElementChild;
2668
2671
  this.#input = fragment.querySelector("input");
2669
2672
  ftl.Attributes.forward('input-', this, this.#input);
@@ -2688,6 +2691,13 @@ var ful = (function (exports, ftl) {
2688
2691
  return;
2689
2692
  }
2690
2693
  this.value = !this.value;
2694
+ this.dispatchEvent(new CustomEvent('change', {
2695
+ bubbles: true,
2696
+ cancelable: false,
2697
+ detail: {
2698
+ value: this.value
2699
+ }
2700
+ }));
2691
2701
  });
2692
2702
  this.#fieldError = fragment.querySelector('ful-field-error');
2693
2703
  this.#input.ariaDescribedByElements = [this.#fieldError];