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