monobill-mintui 0.6.2 → 0.6.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.
package/dist/index.js CHANGED
@@ -1173,7 +1173,7 @@ var o = class extends HTMLElement {
1173
1173
  }
1174
1174
  getAlignContent() {
1175
1175
  let e = (this.getAttribute("align-content") || "").trim().toLowerCase();
1176
- return e === "left" || e === "right" || e === "center" ? e : "";
1176
+ return e === "start" || e === "end" || e === "middle" ? e : "";
1177
1177
  }
1178
1178
  getStackClasses() {
1179
1179
  let e = this.getDirection(), t = this.getTextAlign(), n = this.getGap(), r = this.getAlignContent(), i = [
@@ -1181,7 +1181,7 @@ var o = class extends HTMLElement {
1181
1181
  e === "horizontal" ? "flex-row" : "flex-col",
1182
1182
  `gap-${n}`
1183
1183
  ];
1184
- return r && (e === "horizontal" ? r === "left" ? i.push("justify-start") : r === "right" ? i.push("justify-end") : i.push("justify-center") : r === "left" ? i.push("items-start") : r === "right" ? i.push("items-end") : i.push("items-center")), t && (i.push(`text-${t}`), i.push(`[&>*]:text-${t}`), i.push(`[&>*_.mint-button-content]:text-${t}`), t === "left" ? (i.push("[&>mint-button]:!justify-start"), i.push("[&>mint-button>button]:!justify-start")) : t === "right" ? (i.push("[&>mint-button]:!justify-end"), i.push("[&>mint-button>button]:!justify-end")) : t === "center" && (i.push("[&>mint-button]:!justify-center"), i.push("[&>mint-button>button]:!justify-center"))), i.join(" ");
1184
+ return r && (e === "horizontal" ? r === "start" ? i.push("justify-start") : r === "end" ? i.push("justify-end") : i.push("justify-center") : r === "start" ? i.push("items-start") : r === "end" ? i.push("items-end") : i.push("items-center")), t && (i.push(`text-${t}`), i.push(`[&>*]:text-${t}`), i.push(`[&>*_.mint-button-content]:text-${t}`), t === "left" ? (i.push("[&>mint-button]:!justify-start"), i.push("[&>mint-button>button]:!justify-start")) : t === "right" ? (i.push("[&>mint-button]:!justify-end"), i.push("[&>mint-button>button]:!justify-end")) : t === "center" && (i.push("[&>mint-button]:!justify-center"), i.push("[&>mint-button>button]:!justify-center"))), i.join(" ");
1185
1185
  }
1186
1186
  render() {
1187
1187
  let e = this.getStackClasses(), t = this.getTextAlign();
@@ -5150,11 +5150,12 @@ var T = class extends HTMLElement {
5150
5150
  "enctype",
5151
5151
  "data-form-data",
5152
5152
  "loading",
5153
- "headers"
5153
+ "headers",
5154
+ "submitting"
5154
5155
  ];
5155
5156
  }
5156
5157
  constructor() {
5157
- super(), this._form = null, this._submitHandler = null, this._hostSubmitHandler = null, this._errors = {}, this._fieldBlurHandlers = /* @__PURE__ */ new Map(), this._fieldChangeHandlers = /* @__PURE__ */ new Map(), this._observer = null, this._formData = null, this._headers = null, this._buttonStates = /* @__PURE__ */ new Map(), this._reactiveDataProxy = null, this._reactiveDataObserver = null, this._lastDataSnapshot = null;
5158
+ super(), this._form = null, this._submitHandler = null, this._hostSubmitHandler = null, this._errors = {}, this._fieldBlurHandlers = /* @__PURE__ */ new Map(), this._fieldChangeHandlers = /* @__PURE__ */ new Map(), this._observer = null, this._formData = null, this._headers = null, this._buttonStates = /* @__PURE__ */ new Map(), this._attrSubmittingMintFields = /* @__PURE__ */ new Map(), this._attrSubmittingNativeFields = /* @__PURE__ */ new Map(), this._attrSubmittingMintButtons = /* @__PURE__ */ new Map(), this._attrSubmittingNativeButtons = /* @__PURE__ */ new Map(), this._reactiveDataProxy = null, this._reactiveDataObserver = null, this._lastDataSnapshot = null;
5158
5159
  }
5159
5160
  connectedCallback() {
5160
5161
  this._render(), this._ensureSubmitHandler(), this._setupBlurValidation();
@@ -5166,12 +5167,12 @@ var T = class extends HTMLElement {
5166
5167
  let e = this.getAttribute("data-form-data");
5167
5168
  e && (this._parseFormData(e), this._applyFormData());
5168
5169
  }
5169
- this._propagateLoadingState();
5170
+ this._propagateLoadingState(), this._applySubmittingAttributeState();
5170
5171
  });
5171
5172
  });
5172
5173
  }
5173
5174
  disconnectedCallback() {
5174
- this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._cleanupBlurValidation(), this._stopReactiveDataObserver();
5175
+ this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._restoreSubmittingAttributeState(), this._cleanupBlurValidation(), this._stopReactiveDataObserver();
5175
5176
  }
5176
5177
  reset() {
5177
5178
  this._clearErrors(), this._formData ? this._applyFormData() : this.clear();
@@ -5186,7 +5187,9 @@ var T = class extends HTMLElement {
5186
5187
  });
5187
5188
  })) : e === "headers" ? this._parseHeaders(n) : e === "loading" ? this.isConnected && this._form ? requestAnimationFrame(() => {
5188
5189
  this._propagateLoadingState();
5189
- }) : this._propagateLoadingState() : this._applyFormAttributes();
5190
+ }) : this._propagateLoadingState() : e === "submitting" ? this.isConnected && this._form ? requestAnimationFrame(() => {
5191
+ this._applySubmittingAttributeState();
5192
+ }) : this._applySubmittingAttributeState() : this._applyFormAttributes();
5190
5193
  }
5191
5194
  get data() {
5192
5195
  return this._formData;
@@ -5853,6 +5856,49 @@ var T = class extends HTMLElement {
5853
5856
  typeof e.syncFiles == "function" && e.syncFiles();
5854
5857
  });
5855
5858
  }
5859
+ _isSubmittingAttrActive() {
5860
+ let e = this.getAttribute("submitting");
5861
+ return e !== null && e !== "false";
5862
+ }
5863
+ _applySubmittingAttributeState() {
5864
+ if (this._form) {
5865
+ if (!this._isSubmittingAttrActive()) {
5866
+ this._restoreSubmittingAttributeState();
5867
+ return;
5868
+ }
5869
+ this._attrSubmittingMintFields.size > 0 || this._attrSubmittingNativeFields.size > 0 || this._attrSubmittingMintButtons.size > 0 || this._attrSubmittingNativeButtons.size > 0 || (this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach((e) => {
5870
+ let t = e.getAttribute("disabled") === "true";
5871
+ this._attrSubmittingMintFields.set(e, t), t || e.setAttribute("disabled", "true"), typeof e.render == "function" && e.render();
5872
+ }), this._form.querySelectorAll("input, textarea, select").forEach((e) => {
5873
+ if (e.closest("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags, mint-button") || e instanceof HTMLInputElement && e.type === "hidden") return;
5874
+ let t = e.disabled;
5875
+ this._attrSubmittingNativeFields.set(e, t), t || (e.disabled = !0);
5876
+ }), Array.from(this.querySelectorAll("mint-button")).forEach((e) => {
5877
+ let t = e.getAttribute("disabled") === "true", n = e.getAttribute("loading") === "true";
5878
+ this._attrSubmittingMintButtons.set(e, {
5879
+ disabled: t,
5880
+ loading: n
5881
+ });
5882
+ let r = (e.getAttribute("type") || e.getAttribute("button-type") || "default") === "submit";
5883
+ t || e.setAttribute("disabled", "true"), r && !n && e.setAttribute("loading", "true"), typeof e.render == "function" && e.render();
5884
+ }), Array.from(this.querySelectorAll("button")).forEach((e) => {
5885
+ if (e.closest("mint-button")) return;
5886
+ let t = e.disabled;
5887
+ this._attrSubmittingNativeButtons.set(e, t), t || (e.disabled = !0);
5888
+ }));
5889
+ }
5890
+ }
5891
+ _restoreSubmittingAttributeState() {
5892
+ this._attrSubmittingMintFields.forEach((e, t) => {
5893
+ e ? t.setAttribute("disabled", "true") : t.removeAttribute("disabled"), typeof t.render == "function" && t.render();
5894
+ }), this._attrSubmittingMintFields.clear(), this._attrSubmittingNativeFields.forEach((e, t) => {
5895
+ t.disabled = e;
5896
+ }), this._attrSubmittingNativeFields.clear(), this._attrSubmittingMintButtons.forEach((e, t) => {
5897
+ e.disabled ? t.setAttribute("disabled", "true") : t.removeAttribute("disabled"), e.loading ? t.setAttribute("loading", "true") : t.removeAttribute("loading"), typeof t.render == "function" && t.render();
5898
+ }), this._attrSubmittingMintButtons.clear(), this._attrSubmittingNativeButtons.forEach((e, t) => {
5899
+ t.disabled = e;
5900
+ }), this._attrSubmittingNativeButtons.clear();
5901
+ }
5856
5902
  _propagateLoadingState() {
5857
5903
  if (!this._form) return;
5858
5904
  let e = this.getAttribute("loading"), t = e !== null && e !== "false";
@@ -5883,14 +5929,15 @@ var T = class extends HTMLElement {
5883
5929
  }
5884
5930
  _restoreButtonsState() {
5885
5931
  if (!this._form) return;
5886
- let e = Array.from(this.querySelectorAll("mint-button")), t = Array.from(this.querySelectorAll("button"));
5887
- e.forEach((e) => {
5888
- let t = this._buttonStates.get(e);
5889
- t && (t.disabled ? e.setAttribute("disabled", "true") : e.removeAttribute("disabled"), t.loading ? e.setAttribute("loading", "true") : e.removeAttribute("loading"), typeof e.render == "function" && e.render());
5890
- }), t.forEach((e) => {
5891
- if (e.closest("mint-button")) return;
5892
- let t = this._buttonStates.get(e);
5893
- t && (e.disabled = t.disabled);
5932
+ let e = this._isSubmittingAttrActive() && (this._attrSubmittingMintButtons.size > 0 || this._attrSubmittingNativeButtons.size > 0), t = Array.from(this.querySelectorAll("mint-button")), n = Array.from(this.querySelectorAll("button"));
5933
+ t.forEach((t) => {
5934
+ if (e && this._attrSubmittingMintButtons.has(t)) return;
5935
+ let n = this._buttonStates.get(t);
5936
+ n && (n.disabled ? t.setAttribute("disabled", "true") : t.removeAttribute("disabled"), n.loading ? t.setAttribute("loading", "true") : t.removeAttribute("loading"), typeof t.render == "function" && t.render());
5937
+ }), n.forEach((t) => {
5938
+ if (t.closest("mint-button") || e && this._attrSubmittingNativeButtons.has(t)) return;
5939
+ let n = this._buttonStates.get(t);
5940
+ n && (t.disabled = n.disabled);
5894
5941
  }), this._buttonStates.clear();
5895
5942
  }
5896
5943
  _isReactiveObject(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monobill-mintui",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "A modern framework-agnostic UI kit built as Web Components. Requires Tailwind CSS.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",