@hygular/core 1.0.0-beta.2 → 1.0.0

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
  /*!
2
- * Hygular v1.0.0-beta.2
2
+ * Hygular v1.0.0
3
3
  * (c) Eyruz Badalzada
4
4
  * Released under the MIT License
5
5
  * https://hygular.com
@@ -4287,7 +4287,6 @@ class Form {
4287
4287
  };
4288
4288
  requests.set(form, request);
4289
4289
  submitBtn?.classList.add(CONFIG.classes.loading);
4290
- if (submitBtn) submitBtn.disabled = true;
4291
4290
  removalObserver.observe(document.documentElement, {
4292
4291
  childList: true,
4293
4292
  subtree: true
@@ -4302,7 +4301,10 @@ class Form {
4302
4301
  });
4303
4302
  form.dispatchEvent(startEvent);
4304
4303
  if (startEvent.defaultPrevented || !isCurrent()) return;
4305
- const formData = new document.defaultView.FormData(form);
4304
+ const submitter = submitBtn?.form === form ? submitBtn : undefined;
4305
+ const formData = new document.defaultView.FormData(form, submitter);
4306
+ if (!isCurrent()) return;
4307
+ if (submitBtn) submitBtn.disabled = true;
4306
4308
  const url = new URL(form.action || document.defaultView.location.href);
4307
4309
  const hasBody = method !== "GET" && method !== "HEAD";
4308
4310
  if (!hasBody) {
@@ -4479,6 +4481,7 @@ class Range {
4479
4481
  #inputs;
4480
4482
  #isDual;
4481
4483
  #rafId=null;
4484
+ #resetTimer=null;
4482
4485
  #isRTL;
4483
4486
  #listeners=[];
4484
4487
  #tooltips;
@@ -4593,16 +4596,24 @@ class Range {
4593
4596
  this.#el.after(this.#ticksEl);
4594
4597
  }
4595
4598
  bindEvents() {
4599
+ const listen = (target, type, handler, opts) => {
4600
+ target.addEventListener(type, handler, opts);
4601
+ this.#listeners.push({
4602
+ target: target,
4603
+ type: type,
4604
+ handler: handler,
4605
+ opts: opts
4606
+ });
4607
+ };
4608
+ const root = this.#el.getRootNode();
4609
+ listen(root.isConnected ? root : this.#el.ownerDocument, "reset", event => {
4610
+ if (!this.#inputs.some(input => input.form === event.target)) return;
4611
+ if (this.#rafId) cancelAnimationFrame(this.#rafId);
4612
+ clearTimeout(this.#resetTimer);
4613
+ this.#resetTimer = setTimeout(() => this.update(), 0);
4614
+ }, true);
4596
4615
  this.#inputs.forEach((input, index) => {
4597
- const bind = (type, handler, opts) => {
4598
- input.addEventListener(type, handler, opts);
4599
- this.#listeners.push({
4600
- input: input,
4601
- type: type,
4602
- handler: handler,
4603
- opts: opts
4604
- });
4605
- };
4616
+ const bind = (type, handler, opts) => listen(input, type, handler, opts);
4606
4617
  bind("input", () => this._onInput(index));
4607
4618
  bind("change", () => this._onChange(index));
4608
4619
  bind("pointerdown", () => this.showTooltip(index), {
@@ -4722,9 +4733,10 @@ class Range {
4722
4733
  this.update();
4723
4734
  }
4724
4735
  dispose() {
4736
+ clearTimeout(this.#resetTimer);
4725
4737
  if (this.#rafId) cancelAnimationFrame(this.#rafId);
4726
4738
  this.#resizeObserver?.disconnect();
4727
- this.#listeners.forEach(({input: input, type: type, handler: handler, opts: opts}) => input.removeEventListener(type, handler, opts));
4739
+ this.#listeners.forEach(({target: target, type: type, handler: handler, opts: opts}) => target.removeEventListener(type, handler, opts));
4728
4740
  this.#listeners = [];
4729
4741
  this.#tooltips?.forEach(tip => tip.remove());
4730
4742
  this.#track?.remove();
@@ -4735,4 +4747,4 @@ class Range {
4735
4747
  }
4736
4748
 
4737
4749
  export { Alert as A, Components as C, Debug as D, Form as F, Modal as M, Popover as P, Range as R, Select as S, Tooltip as T, Toast as a, Carousel as b, DarkMode as c, Skeleton as d };
4738
- //# sourceMappingURL=Range-CAPV0fgM.js.map
4750
+ //# sourceMappingURL=Range-QfhWGhrF.js.map