monobill-mintui 0.6.683 → 0.6.685
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/components/form/Form.d.ts +2 -0
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/components/form/browser.js +38 -24
- package/dist/components/form/index.cjs +1 -1
- package/dist/components/form/index.js +38 -24
- package/dist/components/select/Select.d.ts +1 -0
- package/dist/components/select/Select.d.ts.map +1 -1
- package/dist/components/select/browser.js +53 -42
- package/dist/components/select/index.cjs +1 -1
- package/dist/components/select/index.js +53 -42
- package/dist/index.cjs +2 -2
- package/dist/index.css +1 -1
- package/dist/index.js +91 -66
- package/dist/select.css +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,8 @@ declare class MintForm extends HTMLElement {
|
|
|
19
19
|
private _reactiveDataObserver;
|
|
20
20
|
private _lastDataSnapshot;
|
|
21
21
|
private _lastAppliedDataSnapshot;
|
|
22
|
+
/** Invalidates delayed form-data applications after clear/reset or a data source change. */
|
|
23
|
+
private _formDataApplyGeneration;
|
|
22
24
|
constructor();
|
|
23
25
|
connectedCallback(): void;
|
|
24
26
|
disconnectedCallback(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.ts"],"names":[],"mappings":"AAOA,cAAM,QAAS,SAAQ,WAAW;IAChC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,kBAAkB,CAAoC;IAC9D,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,kBAAkB,CAAkD;IAC5E,OAAO,CAAC,oBAAoB,CAAkD;IAC9E,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,aAAa,CAAuE;IAC5F,uFAAuF;IACvF,OAAO,CAAC,yBAAyB,CAAkC;IACnE,OAAO,CAAC,2BAA2B,CAGhC;IACH,OAAO,CAAC,0BAA0B,CAAkE;IACpG,OAAO,CAAC,4BAA4B,CAAwC;IAC5E,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,iBAAiB,CAAmC;IAC5D,OAAO,CAAC,wBAAwB,CAAmC;;
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.ts"],"names":[],"mappings":"AAOA,cAAM,QAAS,SAAQ,WAAW;IAChC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,kBAAkB,CAAoC;IAC9D,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,kBAAkB,CAAkD;IAC5E,OAAO,CAAC,oBAAoB,CAAkD;IAC9E,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,aAAa,CAAuE;IAC5F,uFAAuF;IACvF,OAAO,CAAC,yBAAyB,CAAkC;IACnE,OAAO,CAAC,2BAA2B,CAGhC;IACH,OAAO,CAAC,0BAA0B,CAAkE;IACpG,OAAO,CAAC,4BAA4B,CAAwC;IAC5E,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,iBAAiB,CAAmC;IAC5D,OAAO,CAAC,wBAAwB,CAAmC;IACnE,4FAA4F;IAC5F,OAAO,CAAC,wBAAwB,CAAI;;IAMpC,iBAAiB,IAAI,IAAI;IAyCzB,oBAAoB,IAAI,IAAI;IAY5B;;;OAGG;IACH,KAAK,IAAI,IAAI;IAeb;;;OAGG;IACH,KAAK,IAAI,IAAI;IAoBb;;;OAGG;IACH,MAAM,IAAI,IAAI;IAad,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAqC9F,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAErC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EA+CzC;IAGD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAE3C;IAED,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,EAgB/C;IAED,OAAO,CAAC,OAAO;IAmBf,OAAO,CAAC,oBAAoB;IAoB5B,OAAO,CAAC,oBAAoB;YAYd,aAAa;YA2Gb,WAAW;YAkJX,yBAAyB;YAiBzB,uBAAuB;IA2BrC,OAAO,CAAC,iBAAiB;IA+GzB,kGAAkG;IAClG,OAAO,CAAC,2BAA2B;IAkBnC;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAuEjC,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,SAAS;IAuBjB,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,cAAc;IAsDtB,OAAO,CAAC,iBAAiB;IAgDzB,OAAO,CAAC,kBAAkB;IA2I1B,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,YAAY;IAoBpB;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI;IAI9D,OAAO,CAAC,kBAAkB;IAuB1B,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,cAAc;IAiFtB,OAAO,CAAC,kBAAkB;IA4I1B,OAAO,CAAC,kBAAkB;IAmD1B,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,oBAAoB;IA0K5B,OAAO,CAAC,iBAAiB;IAoCzB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,wBAAwB;IAsBhC,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,sBAAsB;IA6B9B,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,uBAAuB;IAK/B;;;OAGG;IACH,OAAO,CAAC,8BAA8B;IA8EtC,OAAO,CAAC,gCAAgC;IAgCxC,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,qBAAqB;IAoD7B,OAAO,CAAC,oBAAoB;IAuD5B,wFAAwF;IACxF,OAAO,CAAC,iBAAiB;IAIzB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA2B5B;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAIvB;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAyDhC;;OAEG;IACH,OAAO,CAAC,yBAAyB;CAUlC;AAsCD,eAAe,QAAQ,CAAA"}
|
|
@@ -27,7 +27,7 @@ var t = class extends HTMLElement {
|
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
29
|
constructor() {
|
|
30
|
-
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, this._lastAppliedDataSnapshot = null;
|
|
30
|
+
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, this._lastAppliedDataSnapshot = null, this._formDataApplyGeneration = 0;
|
|
31
31
|
}
|
|
32
32
|
connectedCallback() {
|
|
33
33
|
this._render(), this._ensureSubmitHandler(), this._setupBlurValidation();
|
|
@@ -47,10 +47,12 @@ var t = class extends HTMLElement {
|
|
|
47
47
|
this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._restoreSubmittingAttributeState(), this._cleanupBlurValidation(), this._stopReactiveDataObserver();
|
|
48
48
|
}
|
|
49
49
|
reset() {
|
|
50
|
-
this._clearErrors(), this._formData ? (this._lastAppliedDataSnapshot = null, this._applyFormData()) : this.clear();
|
|
50
|
+
this._clearErrors(), this._formDataApplyGeneration += 1, this._formData ? (this._lastAppliedDataSnapshot = null, this._applyFormData()) : this.clear();
|
|
51
51
|
}
|
|
52
52
|
clear() {
|
|
53
|
-
this._clearErrors(), this._form && this._form.reset(), this._resetCustomFields();
|
|
53
|
+
this._clearErrors(), this._formDataApplyGeneration += 1, this._form && this._form.reset(), this._resetCustomFields();
|
|
54
|
+
let e = this._formData ? this._getObjectValue(this._formData) : null;
|
|
55
|
+
e && typeof e == "object" && !Array.isArray(e) && (this._lastAppliedDataSnapshot = this._createDataSnapshot(this._extractReactiveData(e)));
|
|
54
56
|
}
|
|
55
57
|
submit() {
|
|
56
58
|
if (this._form) {
|
|
@@ -79,13 +81,13 @@ var t = class extends HTMLElement {
|
|
|
79
81
|
return this._formData;
|
|
80
82
|
}
|
|
81
83
|
set data(e) {
|
|
82
|
-
this._stopReactiveDataObserver(), this._reactiveDataProxy = null, this._lastDataSnapshot = null, this._lastAppliedDataSnapshot = null, e && typeof e == "object" && !Array.isArray(e) ? (this._formData = e, this._isReactiveObject(e) ? this._setupObjectDataObserver(e) : this._lastDataSnapshot = this._createDataSnapshot(e)) : e == null ? this._formData = null : this._parseFormData(e), this.isConnected && this._form && requestAnimationFrame(() => {
|
|
84
|
+
e !== this._formData && (this._formDataApplyGeneration += 1, this._stopReactiveDataObserver(), this._reactiveDataProxy = null, this._lastDataSnapshot = null, this._lastAppliedDataSnapshot = null, e && typeof e == "object" && !Array.isArray(e) ? (this._formData = e, this._isReactiveObject(e) ? this._setupObjectDataObserver(e) : this._lastDataSnapshot = this._createDataSnapshot(e)) : e == null ? this._formData = null : this._parseFormData(e), this.isConnected && this._form && requestAnimationFrame(() => {
|
|
83
85
|
requestAnimationFrame(() => {
|
|
84
86
|
requestAnimationFrame(() => {
|
|
85
87
|
this._applyFormData();
|
|
86
88
|
});
|
|
87
89
|
});
|
|
88
|
-
});
|
|
90
|
+
}));
|
|
89
91
|
}
|
|
90
92
|
get headers() {
|
|
91
93
|
return this._headers;
|
|
@@ -593,33 +595,40 @@ var t = class extends HTMLElement {
|
|
|
593
595
|
if (!this._formData || !this._form) return;
|
|
594
596
|
let e = this._getObjectValue(this._formData);
|
|
595
597
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
596
|
-
let t =
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
598
|
+
let t = (e, t) => {
|
|
599
|
+
let n = /* @__PURE__ */ new Set();
|
|
600
|
+
return t ? (Object.keys(e).forEach((r) => {
|
|
601
|
+
JSON.stringify(t[r]) !== JSON.stringify(e[r]) && n.add(r);
|
|
602
|
+
}), Object.keys(t).forEach((t) => {
|
|
603
|
+
t in e || n.add(t);
|
|
604
|
+
}), n) : (Object.keys(e).forEach((e) => n.add(e)), n);
|
|
605
|
+
};
|
|
606
|
+
if (t(this._createDataSnapshot(this._extractReactiveData(e)), this._lastAppliedDataSnapshot).size === 0) return;
|
|
607
|
+
let n = this._formDataApplyGeneration, r = () => {
|
|
608
|
+
if (n !== this._formDataApplyGeneration) return;
|
|
609
|
+
let e = this._formData ? this._getObjectValue(this._formData) : null;
|
|
610
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
611
|
+
let r = this._createDataSnapshot(this._extractReactiveData(e)), i = t(r, this._lastAppliedDataSnapshot);
|
|
612
|
+
i.size !== 0 && (i.forEach((e) => {
|
|
613
|
+
let t = r[e], i = this._getFieldElements(e);
|
|
614
|
+
if (i.length === 0) {
|
|
607
615
|
setTimeout(() => {
|
|
616
|
+
if (n !== this._formDataApplyGeneration) return;
|
|
608
617
|
let t = this._getFieldElements(e);
|
|
609
618
|
if (t.length === 0) return;
|
|
610
|
-
let
|
|
611
|
-
if (!
|
|
612
|
-
let
|
|
613
|
-
this._applyValueToField(t, e,
|
|
619
|
+
let r = this._formData ? this._getObjectValue(this._formData) : null;
|
|
620
|
+
if (!r || typeof r != "object" || Array.isArray(r)) return;
|
|
621
|
+
let i = this._extractReactiveData(r)[e];
|
|
622
|
+
this._applyValueToField(t, e, i);
|
|
614
623
|
}, 300);
|
|
615
624
|
return;
|
|
616
625
|
}
|
|
617
|
-
this._applyValueToField(
|
|
618
|
-
}), this._lastAppliedDataSnapshot =
|
|
626
|
+
this._applyValueToField(i, e, t);
|
|
627
|
+
}), this._lastAppliedDataSnapshot = r);
|
|
619
628
|
};
|
|
620
629
|
requestAnimationFrame(() => {
|
|
621
630
|
requestAnimationFrame(() => {
|
|
622
|
-
|
|
631
|
+
r();
|
|
623
632
|
});
|
|
624
633
|
});
|
|
625
634
|
}
|
|
@@ -822,7 +831,12 @@ var t = class extends HTMLElement {
|
|
|
822
831
|
let n = this._getObjectValue(this._formData);
|
|
823
832
|
if (!n || typeof n != "object" || Array.isArray(n)) return;
|
|
824
833
|
let r = this._getFieldElements(t), i = this._extractFieldValue(r.length ? r : [e]);
|
|
825
|
-
n[t] = this._normalizeReactiveValue(r, i)
|
|
834
|
+
n[t] = this._normalizeReactiveValue(r, i);
|
|
835
|
+
let a = this._createDataSnapshot(n);
|
|
836
|
+
this._lastDataSnapshot = a, this._lastAppliedDataSnapshot = {
|
|
837
|
+
...this._lastAppliedDataSnapshot || a,
|
|
838
|
+
[t]: a[t]
|
|
839
|
+
};
|
|
826
840
|
}
|
|
827
841
|
_normalizeReactiveValue(e, t) {
|
|
828
842
|
if (t instanceof FileList) return Array.from(t);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunks/register-element-tCL_F1YI.js`);var t=class extends HTMLElement{static get observedAttributes(){return[`action`,`method`,`enctype`,`data-form-data`,`loading`,`headers`,`submitting`]}constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._attrSubmittingMintFields=new Map,this._attrSubmittingNativeFields=new Map,this._attrSubmittingMintButtons=new Map,this._attrSubmittingNativeButtons=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null,this._lastAppliedDataSnapshot=null}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();let e=this.getAttribute(`headers`);e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupObjectDataObserver(this._formData):this._lastDataSnapshot||=this._createDataSnapshot(this._formData),this._applyFormData();else{let e=this.getAttribute(`data-form-data`);e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState(),this._applySubmittingAttributeState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener(`submit`,this._hostSubmitHandler),this._restoreSubmittingAttributeState(),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?(this._lastAppliedDataSnapshot=null,this._applyFormData()):this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}submit(){if(this._form){if(typeof this._form.requestSubmit==`function`){this._form.requestSubmit();return}this._handleSubmit(new Event(`submit`,{bubbles:!0,cancelable:!0}))}}attributeChangedCallback(e,t,n){e===`form-data`?(this._parseFormData(n),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e===`headers`?this._parseHeaders(n):e===`loading`?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():e===`submitting`?this.isConnected&&this._form?requestAnimationFrame(()=>{this._applySubmittingAttributeState()}):this._applySubmittingAttributeState():this._applyFormAttributes()}get data(){return this._formData}set data(e){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,this._lastAppliedDataSnapshot=null,e&&typeof e==`object`&&!Array.isArray(e)?(this._formData=e,this._isReactiveObject(e)?this._setupObjectDataObserver(e):this._lastDataSnapshot=this._createDataSnapshot(e)):e==null?this._formData=null:this._parseFormData(e),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(e){if(e&&typeof e==`object`&&!Array.isArray(e))this._headers=e;else if(e==null)this._headers=null;else if(typeof e==`string`)try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add(`mint-form-host`),!this._form){for(this._form=document.createElement(`form`),this._form.classList.add(`mint-form-content`),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._submitHandler=e=>{e.preventDefault(),e.stopImmediatePropagation(),this._handleSubmit(e)},this._form.addEventListener(`submit`,this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;let e=this.getAttribute(`action`)||``,t=this.getAttribute(`method`)||``,n=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=n}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();let t=this._collectValidationRules(),n=new FormData(this._form),r=this._formDataToValues(n);if(this._formData){let e=this._getObjectValue(this._formData);e&&typeof e==`object`&&!Array.isArray(e)&&(r={...this._extractReactiveData(e),...r})}let i=this._collectLiveControlValues();if(r={...r,...i},!this._validate(r,t)){this.dispatchEvent(new CustomEvent(`invalid`,{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}let a=new CustomEvent(`submit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),a.form=this;let o=new CustomEvent(`mintFormSubmit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});if(o.form=this,this.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented)return;let s=this.getAttribute(`action`),c=this.getAttribute(`method`);if(!(!s||!c)){this._setButtonsSubmitting();try{let e=await this._submitData(n,r);this.dispatchEvent(new CustomEvent(`submitsuccess`,{detail:e,bubbles:!0,cancelable:!0}))}catch(e){e?.status===422&&e?.data?.errors&&this._applyServerErrors(e.data.errors),this.dispatchEvent(new CustomEvent(`submiterror`,{detail:{error:e},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){let n=this.getAttribute(`action`),r=this.getAttribute(`method`),i=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;if(!n)return{status:0,ok:!0,data:{values:t}};let a=Array.from(e.values()).some(e=>e instanceof File),o=null,s={},c=n;if(typeof window<`u`&&window.mintForm?.defaults?.headers?.common&&Object.assign(s,window.mintForm.defaults.headers.common),this._headers&&Object.assign(s,this._headers),r===`GET`){let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),c+=(n.includes(`?`)?`&`:`?`)+t.toString()}else if(i===`multipart/form-data`||a)o=e;else if(i===`application/json`)o=JSON.stringify(t),s[`Content-Type`]=`application/json`;else{let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),o=t,s[`Content-Type`]=`application/x-www-form-urlencoded`}if(typeof fetch==`function`)try{let e=await fetch(c,{method:r||`POST`,body:r===`GET`?null:o,headers:s}),t=await e.text().catch(()=>``),n=t;try{n=JSON.parse(t)}catch{}if(!e.ok){let t={status:e.status,data:n,response:{status:e.status,data:n}};throw await this._applyErrorInterceptors(t)}let i={status:e.status,ok:e.ok,data:n};return await this._applySuccessInterceptors(i)}catch(e){if(e.response)throw e;let t={status:e.status||0,data:e.data||e.message||`Network error`,response:{status:e.status||0,data:e.data||e.message||`Network error`}};throw await this._applyErrorInterceptors(t)}let l=this;return await new Promise(async(e,t)=>{let n=new XMLHttpRequest;n.open(r||`POST`,c,!0),Object.entries(s).forEach(([e,t])=>n.setRequestHeader(e,t)),n.onload=async function(){let{status:r,responseText:i}=n;if(r>=200&&r<300){let n=i;try{n=JSON.parse(i)}catch{}try{let t={status:r,ok:!0,data:n};e(await l._applySuccessInterceptors(t))}catch(e){t(e)}}else{let e=i;try{e=JSON.parse(i)}catch{}try{let n={status:r,data:e,response:{status:r,data:e}};t(await l._applyErrorInterceptors(n))}catch(e){t(e)}}},n.onerror=async function(){try{let e={status:n.status||0,data:n.responseText||`Network error`,response:{status:n.status||0,data:n.responseText||`Network error`}};t(await l._applyErrorInterceptors(e))}catch(e){t(e)}},n.send(r===`GET`?null:o)})}async _applySuccessInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return e;let t=e,n=window.mintForm.interceptors.response.handlers;for(let e of n)e.fulfilled&&(t=await e.fulfilled(t));return t}async _applyErrorInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return Promise.reject(e);let t=e,n=window.mintForm.interceptors.response.handlers;for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.rejected)try{if(t=await r.rejected(t),t!==void 0)return t}catch(e){t=e}}return Promise.reject(t)}_formDataToValues(e){let t={};return e.forEach((e,n)=>{e instanceof File?(t[n]||(t[n]=[]),t[n].push(e)):n in t?Array.isArray(t[n])?(t[n].length>0&&t[n][0]instanceof File,t[n].push(e)):t[n]=[t[n],e]:t[n]=e}),this._form&&(Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n&&e.files!==void 0&&e.files){let r=e.files;if(r.length>0){let e=Array.from(r);t[n]&&Array.isArray(t[n])?e.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=e}}}),Array.from(this._form.querySelectorAll(`input[type="file"][name]`)).forEach(e=>{let n=e.name;if(n&&e.files&&e.files.length>0){let r=Array.from(e.files);t[n]&&Array.isArray(t[n])?r.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=r}}),Array.from(this._form.querySelectorAll(`mint-tags[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n){let r=[];e.tags===void 0?typeof e.getTags==`function`&&(r=e.getTags()):r=e.tags,Array.isArray(r)&&r.length>0?t[n]=r.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):t[n]=[]}})),t}_isControlDisabledForSubmit(e){let t=e;for(;t&&t!==this._form;){if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLButtonElement)&&t.disabled)return!0;let e=t.getAttribute(`disabled`);if(e!==null&&e!==`false`)return!0;t=t.parentElement}return!1}_collectLiveControlValues(){let e={};if(!this._form)return e;let t=new Set,n=Array.from(this._form.querySelectorAll([`input[name]`,`textarea[name]`,`select[name]`,`mint-input[name]`,`mint-select[name]`,`mint-date-picker[name]`,`mint-datetime-picker[name]`,`mint-time-picker[name]`,`mint-dropzone[name]`,`mint-checkbox[name]`,`mint-choice[name]`,`mint-switch[name]`,`mint-tags[name]`].join(`,`)));for(let e of n){let n=e.getAttribute(`name`);!n||this._isControlDisabledForSubmit(e)||t.add(n)}for(let n of t){let t=this._getFieldElements(n).filter(e=>!this._isControlDisabledForSubmit(e));if(t.length!==0)try{let r=this._extractFieldValue(t),i=r instanceof FileList?Array.from(r):r,a=e=>e instanceof HTMLInputElement?e.type===`checkbox`||e.type===`radio`:[`MINT-CHECKBOX`,`MINT-CHOICE`,`MINT-SWITCH`].includes(e.tagName),o=t.length===1&&[`MINT-CHECKBOX`,`MINT-SWITCH`].includes(t[0].tagName);if(t.every(a)&&!o&&(i===``||i==null||Array.isArray(i)&&i.length===0))continue;e[n]=i}catch{}}return e}_collectValidationRules(){let e={};return this._form&&Array.from(this._form.querySelectorAll(`[name][validation]`)).forEach(t=>{let n=t.getAttribute(`name`)||``,r=t.getAttribute(`validation`);if(!n||!r)return;let i=this._parseRules(r);i.length&&(e[n]=i)}),e}_parseRules(e){if(!e)return[];try{let t=e.replace(/'/g,`"`),n=JSON.parse(t);if(Array.isArray(n))return n.map(e=>String(e))}catch{}return e.split(`,`).map(e=>e.trim()).filter(Boolean)}_validate(e,t){let n=!0;return this._errors={},Object.entries(t||{}).forEach(([e,t])=>{let r=Array.isArray(t)?t:[t],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(n=!1,this._errors[e]=o,this._flagFieldError(i,o)):this._clearFieldError(i)}),n}_validateField(e){let t=this._collectValidationRules();if(!t[e])return;let n=t[e],r=Array.isArray(n)?n:[n],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(this._errors[e]=o,this._flagFieldError(i,o)):(this._clearFieldError(i),delete this._errors[e])}_validateRules(e,t){for(let n of t){let[t,r]=n.split(`:`);switch(t){case`required`:if(e==null||e===!1||typeof e==`string`&&e.trim()===``||e instanceof FileList&&e.length===0||Array.isArray(e)&&e.length===0)return`This field is required.`;break;case`string`:if(typeof e!=`string`)return`Must be a string.`;break;case`email`:if(typeof e==`string`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()))return`Enter a valid email.`;break;case`number`:{let t=Number(e);if(Number.isNaN(t))return`Must be a number.`;break}case`min`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length<t)return`Must be at least ${t} characters.`;if(Array.isArray(e)&&e.length<t)return`Select at least ${t}.`;if(e instanceof FileList&&e.length<t)return`Upload at least ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<t)return`Must be at least ${t}.`;break}case`max`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length>t)return`Must be at most ${t} characters.`;if(Array.isArray(e)&&e.length>t)return`Select no more than ${t}.`;if(e instanceof FileList&&e.length>t)return`Upload no more than ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>t)return`Must be at most ${t}.`;break}default:break}}return null}_getFieldElements(e){if(!this._form)return[];let t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),n=t.filter(e=>e.tagName===`MINT-SELECT`);if(n.length>0){let r=[];return n.forEach(t=>{let n=t.querySelector(`select[name="`+e+`"]`);n&&r.push(n)}),t.filter(e=>e.tagName!==`MINT-SELECT`).concat(r)}if(t.filter(e=>e.tagName===`MINT-TAGS`).length>0)return t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`));let r=t.filter(e=>e.tagName===`INPUT`&&e.closest(`mint-tags`));if(r.length>0){let e=[];return r.forEach(t=>{let n=t.closest(`mint-tags`);n&&!e.includes(n)&&e.push(n)}),t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`)).concat(e)}return t}_extractFieldValue(e){if(e.length===0)return``;let t=e.find(e=>e instanceof HTMLSelectElement);if(t)return t.multiple?Array.from(t.selectedOptions).map(e=>e.value):t.value;if(e.length>1){let t=e.filter(e=>e instanceof HTMLInputElement);if(t.length>0&&t.length===e.length){let e=t.filter(e=>e.checked);if(t.every(e=>e.type===`radio`))return e.length>0?e[0].value||`on`:``;if(t.every(e=>e.type===`checkbox`))return e.map(e=>e.value||`on`)}let n=e.filter(e=>e.tagName===`MINT-CHOICE`);if(n.length>0&&n.length===e.length){let e=n.find(e=>typeof e.getValue==`function`?e.getValue()!==``:e.querySelector(`mint-choice-option[checked]`)!==null);if(e){if(typeof e.getValue==`function`)return e.getValue();let t=e.querySelector(`mint-choice-option[checked]`);if(t)return t.getAttribute(`value`)||``}return``}let r=e.filter(e=>e.tagName===`MINT-CHECKBOX`);if(r.length>0&&r.length===e.length)return r.filter(e=>e.checked===void 0?e.hasAttribute(`checked`):e.checked).map(e=>e.getAttribute(`value`)||`on`)}let n=e[0];if(n instanceof HTMLInputElement)return n.type===`file`?n.files:n.type===`checkbox`||n.type===`radio`?n.checked?n.value||`on`:``:n.value;if(n instanceof HTMLTextAreaElement)return n.value;if(n.tagName===`MINT-SELECT`){let e=n.querySelector(`select`);if(e)return e.multiple?Array.from(e.selectedOptions).map(e=>e.value):e.value;if(typeof n.getValue==`function`){let e=n.getValue();if(e!=null&&e!==``)return e}return n.getAttribute(`value`)||``}if(n.tagName===`MINT-DROPZONE`&&n.files!==void 0)return n.files;if(n.tagName===`MINT-TAGS`){let e=null;return n.tags===void 0?typeof n.getTags==`function`&&(e=n.getTags()):e=n.tags,Array.isArray(e)?e.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):[]}return n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`?!!(n.checked===void 0?n.hasAttribute(`checked`):n.checked):n.tagName===`MINT-CHOICE`?(typeof n.getValue==`function`?n.getValue():``)||``:n.value===void 0?n.getAttribute(`value`)||``:n.value}_flagFieldError(e,t){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.setAttribute(`aria-invalid`,`true`);let n=this._resolveHost(e);n&&(n.setAttribute(`error`,`true`),n.setAttribute(`error-message`,t),n.setAttribute(`data-mint-form-error`,`true`))})}_clearFieldError(e){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute(`aria-invalid`);let t=this._resolveHost(e);t&&(t.removeAttribute(`error`),t.removeAttribute(`error-message`),t.removeAttribute(`data-mint-form-error`))})}_clearErrors(){this.querySelectorAll(`[data-mint-form-error]`).forEach(e=>{let t=e;t.removeAttribute(`error`),t.removeAttribute(`error-message`),t.removeAttribute(`data-mint-form-error`)}),this._form&&this._form.querySelectorAll(`[aria-invalid="true"]`).forEach(e=>{e.removeAttribute(`aria-invalid`)}),this._errors={}}setFormErrors(e){this._applyServerErrors(e)}_applyServerErrors(e){this._clearErrors(),Object.entries(e).forEach(([e,t])=>{let n=Array.isArray(t)?t[0]||`Validation error`:t||`Validation error`,r=this._getFieldElements(e);r.length>0&&(this._errors[e]=n,this._flagFieldError(r,n))})}_parseFormData(e){if(!e){this._formData=null;return}if(typeof e==`object`&&!Array.isArray(e)){this._formData=e;return}if(typeof e==`string`)try{this._formData=JSON.parse(e)}catch{this._formData=null}else this._formData=null}_parseHeaders(e){if(!e){this._headers=null;return}if(typeof e==`string`)try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;let e=this._getObjectValue(this._formData);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=this._extractReactiveData(e),n=this._createDataSnapshot(t),r=this._lastAppliedDataSnapshot,i=new Set;if(r?(Object.keys(n).forEach(e=>{let t=r[e],a=n[e];JSON.stringify(t)!==JSON.stringify(a)&&i.add(e)}),Object.keys(r).forEach(e=>{e in n||i.add(e)})):Object.keys(n).forEach(e=>i.add(e)),i.size===0)return;let a=()=>{i.forEach(e=>{let t=n[e],r=this._getFieldElements(e);if(r.length===0){setTimeout(()=>{let t=this._getFieldElements(e);if(t.length===0)return;let n=this._formData?this._getObjectValue(this._formData):null;if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n[e];this._applyValueToField(t,e,r)},300);return}this._applyValueToField(r,e,t)}),this._lastAppliedDataSnapshot=n};requestAnimationFrame(()=>{requestAnimationFrame(()=>{a()})})}_applyValueToField(e,t,n){e.forEach(e=>{let r=e.tagName;try{if(r===`MINT-INPUT`)e.value!==void 0&&(e.value=n||``);else if(r===`MINT-DATE-PICKER`)typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-TIME-PICKER`)typeof e.setValue==`function`?e.setValue(n==null?``:String(n)):e.value!==void 0&&(e.value=n==null?``:String(n));else if(r===`MINT-SELECT`||r===`SELECT`)if(r===`SELECT`){let t=e,r=t.closest(`mint-select`);if(r&&typeof r.setValue==`function`)r.setValue(n);else if(t.multiple){let e=Array.isArray(n)?n.map(e=>String(e)):n==null||n===``?[]:[String(n)];Array.from(t.options).forEach(t=>{t.selected=e.includes(t.value)})}else t.value=n==null?``:String(n)}else typeof e.setValue==`function`&&e.setValue(n);else if(r===`MINT-CHOICE`)typeof e.setValue==`function`?e.setValue(n==null?``:String(n)):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=e.getAttribute(`value`)===n});else if(r===`MINT-CHECKBOX`||r===`MINT-SWITCH`){let t=n===!0||n===`true`||n===`on`||n===1||n===`1`;e.checked===void 0?t?e.setAttribute(`checked`,`true`):e.removeAttribute(`checked`):e.checked=t}else if(r===`MINT-TAGS`)if(Array.isArray(n)){let t=new Map;try{let n=e.getAttribute(`predefined-tags`);if(n){let e=JSON.parse(n);Array.isArray(e)&&(t=new Map(e.map(e=>{if(typeof e==`string`){let t=e.trim();return t?[t.toLowerCase(),t]:null}if(!e||typeof e!=`object`)return null;let t=String(e.value??``).trim();if(!t)return null;let n=String(e.label??t);return[t.toLowerCase(),n]}).filter(e=>e!==null)))}}catch{}e.tags!==void 0&&(e.tags=n.map(e=>{if(typeof e==`string`||typeof e==`number`){let n=String(e).trim();return{value:n,label:t.get(n.toLowerCase())||n,dismissable:!0}}if(e&&typeof e==`object`){let n=String(e.value??``).trim(),r=t.get(n.toLowerCase())||String(e.label??n);return{...e,value:n,label:r,dismissable:e.dismissable!==!1}}return e}))}else e.tags!==void 0&&(e.tags=[]);else if(e instanceof HTMLInputElement){if(e.type===`file`)return;e.type===`checkbox`||e.type===`radio`?e.checked=n===!0||n===`true`||n===`on`||n===1||n===`1`:e.value=n||``}else (e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(e.value=n||``)}catch(e){console.warn(`Failed to set value for field ${t}:`,e)}})}_resetCustomFields(){this.querySelectorAll(`mint-input, mint-date-picker, mint-datetime-picker, mint-time-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`).forEach(e=>{e.removeAttribute(`error`),e.removeAttribute(`error-message`);let t=e.tagName;if(t===`MINT-INPUT`)try{e.value=``}catch{}else if(t===`MINT-DATE-PICKER`)try{e.setValue?.(``)}catch{}else if(t===`MINT-SELECT`)try{e.setValue?.(``)}catch{}else if(t===`MINT-DROPZONE`){let t=e.querySelector(`input[type="file"]`);t&&(t.value=``)}else if(t===`MINT-CHECKBOX`||t===`MINT-SWITCH`)try{if(e.checked!==void 0)e.checked=!1;else{e.removeAttribute(`checked`);let t=e.querySelector(`input[type="checkbox"], input[type="radio"]`);t&&(t.checked=!1)}}catch{}else if(t===`MINT-CHOICE`)try{typeof e.setValue==`function`?e.setValue(``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=!1})}catch{}else if(t===`MINT-TAGS`)try{e.tags=[]}catch{}})}_resolveHost(e){if(e.tagName===`MINT-CHOICE-OPTION`){let t=e.closest(`mint-choice`);if(t)return t}return e.closest(`mint-input, mint-date-picker, mint-datetime-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)||e}_setupBlurValidation(){if(!this._form)return;let e=e=>{let t=e.target;if(!t)return;let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;let i=this._extractFieldValue([n]),a=i!=null&&(typeof i==`string`?i.trim()!==``:i instanceof FileList||Array.isArray(i)?i.length>0:!0),o=n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&(t.hasAttribute(`aria-invalid`)||t.closest(`[data-mint-form-error]`)),s=!!n.closest(`mint-tags`),c=n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`||n.tagName===`MINT-CHOICE`||t instanceof HTMLElement&&(t.closest(`mint-checkbox, mint-switch, mint-choice`)||t.closest(`mint-choice-option`)),l=n.tagName===`MINT-DATE-PICKER`||t instanceof HTMLElement&&t.closest(`mint-date-picker, mint-datetime-picker`);(a||o||s||c||l)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`blur`,e,!0),this._fieldBlurHandlers.set(this._form,e);let t=e=>{let t=e.target;if(!t)return;if(!(t instanceof HTMLInputElement&&t.type===`file`)){let e=this._findFieldElement(t),n=e?this._getFieldName(e):null;e&&n&&this._syncFieldToReactiveData(e,n)}if(e.type===`tags-change`&&t.tagName===`MINT-TAGS`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLSelectElement||t.tagName===`MINT-SELECT`||t.closest(`mint-select`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(e.type===`choice-change`&&t.tagName===`MINT-CHOICE`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLInputElement&&t.type===`checkbox`||t.tagName===`MINT-CHECKBOX`||t.tagName===`MINT-SWITCH`||t.closest(`mint-checkbox, mint-switch`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);r&&this._collectValidationRules()[r]&&(n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&t.hasAttribute(`aria-invalid`))&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`change`,t,!0),this._form.addEventListener(`input`,t,!0),this._form.addEventListener(`tags-change`,t,!0),this._form.addEventListener(`choice-change`,t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){let t=e.closest(`mint-input, mint-date-picker, mint-datetime-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`);if(t&&t.hasAttribute(`name`))return t;if(e.hasAttribute(`name`)&&(e.tagName.startsWith(`MINT-`)||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)||(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute(`name`))return e;let n=e;for(;n&&n!==this._form;){if(n.hasAttribute(`name`))return n;n=n.parentElement}return null}_getFieldName(e){return e.hasAttribute(`name`)||e.tagName.startsWith(`MINT-`)?e.getAttribute(`name`):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.name||null}_syncFieldToReactiveData(e,t){if(!this._formData||!t)return;let n=this._getObjectValue(this._formData);if(!n||typeof n!=`object`||Array.isArray(n))return;let r=this._getFieldElements(t),i=this._extractFieldValue(r.length?r:[e]);n[t]=this._normalizeReactiveValue(r,i),this._lastDataSnapshot=this._createDataSnapshot(n)}_normalizeReactiveValue(e,t){if(t instanceof FileList)return Array.from(t);if(Array.isArray(t))return t;let n=e[0];return e.length===1&&(n instanceof HTMLInputElement&&n.type===`checkbox`||n?.tagName===`MINT-CHECKBOX`||n?.tagName===`MINT-SWITCH`)?!!t:t??``}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){let e=this._fieldBlurHandlers.get(this._form);e&&this._form.removeEventListener(`blur`,e,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){let e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener(`change`,e,!0),this._form.removeEventListener(`input`,e,!0),this._form.removeEventListener(`tags-change`,e,!0),this._form.removeEventListener(`choice-change`,e,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&=(this._observer.disconnect(),null)}_syncDropzoneFiles(){this._form&&Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{typeof e.syncFiles==`function`&&e.syncFiles()})}_isSubmittingAttrActive(){let e=this.getAttribute(`submitting`);return e!==null&&e!==`false`}_applySubmittingAttributeState(){if(this._form){if(!this._isSubmittingAttrActive()){this._restoreSubmittingAttributeState();return}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-datetime-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`).forEach(e=>{let t=e.getAttribute(`disabled`)===`true`;this._attrSubmittingMintFields.set(e,t),t||e.setAttribute(`disabled`,`true`),typeof e.render==`function`&&e.render()}),this._form.querySelectorAll(`input, textarea, select`).forEach(e=>{if(e.closest(`mint-input, mint-select, mint-date-picker, mint-datetime-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags, mint-button`)||e instanceof HTMLInputElement&&e.type===`hidden`)return;let t=e.disabled;this._attrSubmittingNativeFields.set(e,t),t||(e.disabled=!0)}),Array.from(this.querySelectorAll(`mint-button`)).forEach(e=>{let t=e.getAttribute(`disabled`)===`true`,n=e.getAttribute(`loading`)===`true`;this._attrSubmittingMintButtons.set(e,{disabled:t,loading:n});let r=(e.getAttribute(`type`)||e.getAttribute(`button-type`)||`default`)===`submit`;t||e.setAttribute(`disabled`,`true`),r&&!n&&e.setAttribute(`loading`,`true`),typeof e.render==`function`&&e.render()}),Array.from(this.querySelectorAll(`button`)).forEach(e=>{if(e.closest(`mint-button, mint-input, mint-select, mint-date-picker, mint-datetime-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`))return;let t=e.disabled;this._attrSubmittingNativeButtons.set(e,t),t||(e.disabled=!0)}))}}_restoreSubmittingAttributeState(){this._attrSubmittingMintFields.forEach((e,t)=>{e?t.setAttribute(`disabled`,`true`):t.removeAttribute(`disabled`),typeof t.render==`function`&&t.render()}),this._attrSubmittingMintFields.clear(),this._attrSubmittingNativeFields.forEach((e,t)=>{t.disabled=e}),this._attrSubmittingNativeFields.clear(),this._attrSubmittingMintButtons.forEach((e,t)=>{e.disabled?t.setAttribute(`disabled`,`true`):t.removeAttribute(`disabled`),e.loading?t.setAttribute(`loading`,`true`):t.removeAttribute(`loading`),typeof t.render==`function`&&t.render()}),this._attrSubmittingMintButtons.clear(),this._attrSubmittingNativeButtons.forEach((e,t)=>{t.disabled=e}),this._attrSubmittingNativeButtons.clear()}_propagateLoadingState(){if(!this._form)return;let e=this.getAttribute(`loading`),t=e!==null&&e!==`false`;Array.from(this._form.querySelectorAll(`mint-input, mint-select, mint-date-picker, mint-datetime-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)).forEach(e=>{t?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();let e=Array.from(this.querySelectorAll(`mint-button`)),t=Array.from(this.querySelectorAll(`button`));e.forEach(e=>{let t=e.getAttribute(`disabled`)===`true`,n=e.getAttribute(`loading`)===`true`;this._buttonStates.set(e,{disabled:t,loading:n});let r=(e.getAttribute(`type`)||e.getAttribute(`button-type`)||`default`)===`submit`;t||e.setAttribute(`disabled`,`true`),r&&e.setAttribute(`loading`,`true`),typeof e.render==`function`&&e.render()}),t.forEach(e=>{if(e.closest(`mint-button`))return;let t=e.disabled;this._buttonStates.set(e,{disabled:t,loading:!1}),t||(e.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;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`));t.forEach(t=>{if(e&&this._attrSubmittingMintButtons.has(t))return;let n=this._buttonStates.get(t);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())}),n.forEach(t=>{if(t.closest(`mint-button`)||e&&this._attrSubmittingNativeButtons.has(t))return;let n=this._buttonStates.get(t);n&&(t.disabled=n.disabled)}),this._buttonStates.clear()}_isReactiveObject(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}_createDataSnapshot(e){try{let t=this._extractReactiveData(e);return JSON.parse(JSON.stringify(t))}catch{return{...this._extractReactiveData(e)}}}_extractReactiveData(e){if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>this._extractReactiveData(e));let t=this._getObjectValue(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this._extractReactiveData(t[n]));return e}return t}_hasDataChanged(e,t){try{return JSON.stringify(e)!==JSON.stringify(t)}catch{return!0}}_getObjectValue(e){return e}_setupObjectDataObserver(e){if(this._stopReactiveDataObserver(),!this.isConnected)return;let t=this._getObjectValue(e);if(t&&typeof t==`object`&&!Array.isArray(t))this._lastDataSnapshot=this._createDataSnapshot(t);else{this._lastDataSnapshot=null;return}let n=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}let e=this._getObjectValue(this._formData);if(e&&typeof e==`object`&&!Array.isArray(e)){let t=this._createDataSnapshot(e);this._hasDataChanged(t,this._lastDataSnapshot)&&(this._lastDataSnapshot=t,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(n):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(n)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null,this._lastAppliedDataSnapshot=null}};customElements.get(`mint-form`)||e.t(`mint-form`,t),typeof window<`u`&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(e,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:e,rejected:t}),window.mintForm.interceptors.response.handlers.length-1})),module.exports=t;
|
|
1
|
+
const e=require(`../chunks/register-element-tCL_F1YI.js`);var t=class extends HTMLElement{static get observedAttributes(){return[`action`,`method`,`enctype`,`data-form-data`,`loading`,`headers`,`submitting`]}constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._attrSubmittingMintFields=new Map,this._attrSubmittingNativeFields=new Map,this._attrSubmittingMintButtons=new Map,this._attrSubmittingNativeButtons=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null,this._lastAppliedDataSnapshot=null,this._formDataApplyGeneration=0}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();let e=this.getAttribute(`headers`);e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupObjectDataObserver(this._formData):this._lastDataSnapshot||=this._createDataSnapshot(this._formData),this._applyFormData();else{let e=this.getAttribute(`data-form-data`);e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState(),this._applySubmittingAttributeState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener(`submit`,this._hostSubmitHandler),this._restoreSubmittingAttributeState(),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formDataApplyGeneration+=1,this._formData?(this._lastAppliedDataSnapshot=null,this._applyFormData()):this.clear()}clear(){this._clearErrors(),this._formDataApplyGeneration+=1,this._form&&this._form.reset(),this._resetCustomFields();let e=this._formData?this._getObjectValue(this._formData):null;e&&typeof e==`object`&&!Array.isArray(e)&&(this._lastAppliedDataSnapshot=this._createDataSnapshot(this._extractReactiveData(e)))}submit(){if(this._form){if(typeof this._form.requestSubmit==`function`){this._form.requestSubmit();return}this._handleSubmit(new Event(`submit`,{bubbles:!0,cancelable:!0}))}}attributeChangedCallback(e,t,n){e===`form-data`?(this._parseFormData(n),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e===`headers`?this._parseHeaders(n):e===`loading`?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():e===`submitting`?this.isConnected&&this._form?requestAnimationFrame(()=>{this._applySubmittingAttributeState()}):this._applySubmittingAttributeState():this._applyFormAttributes()}get data(){return this._formData}set data(e){e!==this._formData&&(this._formDataApplyGeneration+=1,this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,this._lastAppliedDataSnapshot=null,e&&typeof e==`object`&&!Array.isArray(e)?(this._formData=e,this._isReactiveObject(e)?this._setupObjectDataObserver(e):this._lastDataSnapshot=this._createDataSnapshot(e)):e==null?this._formData=null:this._parseFormData(e),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})}))}get headers(){return this._headers}set headers(e){if(e&&typeof e==`object`&&!Array.isArray(e))this._headers=e;else if(e==null)this._headers=null;else if(typeof e==`string`)try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add(`mint-form-host`),!this._form){for(this._form=document.createElement(`form`),this._form.classList.add(`mint-form-content`),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._submitHandler=e=>{e.preventDefault(),e.stopImmediatePropagation(),this._handleSubmit(e)},this._form.addEventListener(`submit`,this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;let e=this.getAttribute(`action`)||``,t=this.getAttribute(`method`)||``,n=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=n}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();let t=this._collectValidationRules(),n=new FormData(this._form),r=this._formDataToValues(n);if(this._formData){let e=this._getObjectValue(this._formData);e&&typeof e==`object`&&!Array.isArray(e)&&(r={...this._extractReactiveData(e),...r})}let i=this._collectLiveControlValues();if(r={...r,...i},!this._validate(r,t)){this.dispatchEvent(new CustomEvent(`invalid`,{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}let a=new CustomEvent(`submit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),a.form=this;let o=new CustomEvent(`mintFormSubmit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});if(o.form=this,this.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented)return;let s=this.getAttribute(`action`),c=this.getAttribute(`method`);if(!(!s||!c)){this._setButtonsSubmitting();try{let e=await this._submitData(n,r);this.dispatchEvent(new CustomEvent(`submitsuccess`,{detail:e,bubbles:!0,cancelable:!0}))}catch(e){e?.status===422&&e?.data?.errors&&this._applyServerErrors(e.data.errors),this.dispatchEvent(new CustomEvent(`submiterror`,{detail:{error:e},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){let n=this.getAttribute(`action`),r=this.getAttribute(`method`),i=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;if(!n)return{status:0,ok:!0,data:{values:t}};let a=Array.from(e.values()).some(e=>e instanceof File),o=null,s={},c=n;if(typeof window<`u`&&window.mintForm?.defaults?.headers?.common&&Object.assign(s,window.mintForm.defaults.headers.common),this._headers&&Object.assign(s,this._headers),r===`GET`){let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),c+=(n.includes(`?`)?`&`:`?`)+t.toString()}else if(i===`multipart/form-data`||a)o=e;else if(i===`application/json`)o=JSON.stringify(t),s[`Content-Type`]=`application/json`;else{let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),o=t,s[`Content-Type`]=`application/x-www-form-urlencoded`}if(typeof fetch==`function`)try{let e=await fetch(c,{method:r||`POST`,body:r===`GET`?null:o,headers:s}),t=await e.text().catch(()=>``),n=t;try{n=JSON.parse(t)}catch{}if(!e.ok){let t={status:e.status,data:n,response:{status:e.status,data:n}};throw await this._applyErrorInterceptors(t)}let i={status:e.status,ok:e.ok,data:n};return await this._applySuccessInterceptors(i)}catch(e){if(e.response)throw e;let t={status:e.status||0,data:e.data||e.message||`Network error`,response:{status:e.status||0,data:e.data||e.message||`Network error`}};throw await this._applyErrorInterceptors(t)}let l=this;return await new Promise(async(e,t)=>{let n=new XMLHttpRequest;n.open(r||`POST`,c,!0),Object.entries(s).forEach(([e,t])=>n.setRequestHeader(e,t)),n.onload=async function(){let{status:r,responseText:i}=n;if(r>=200&&r<300){let n=i;try{n=JSON.parse(i)}catch{}try{let t={status:r,ok:!0,data:n};e(await l._applySuccessInterceptors(t))}catch(e){t(e)}}else{let e=i;try{e=JSON.parse(i)}catch{}try{let n={status:r,data:e,response:{status:r,data:e}};t(await l._applyErrorInterceptors(n))}catch(e){t(e)}}},n.onerror=async function(){try{let e={status:n.status||0,data:n.responseText||`Network error`,response:{status:n.status||0,data:n.responseText||`Network error`}};t(await l._applyErrorInterceptors(e))}catch(e){t(e)}},n.send(r===`GET`?null:o)})}async _applySuccessInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return e;let t=e,n=window.mintForm.interceptors.response.handlers;for(let e of n)e.fulfilled&&(t=await e.fulfilled(t));return t}async _applyErrorInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return Promise.reject(e);let t=e,n=window.mintForm.interceptors.response.handlers;for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.rejected)try{if(t=await r.rejected(t),t!==void 0)return t}catch(e){t=e}}return Promise.reject(t)}_formDataToValues(e){let t={};return e.forEach((e,n)=>{e instanceof File?(t[n]||(t[n]=[]),t[n].push(e)):n in t?Array.isArray(t[n])?(t[n].length>0&&t[n][0]instanceof File,t[n].push(e)):t[n]=[t[n],e]:t[n]=e}),this._form&&(Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n&&e.files!==void 0&&e.files){let r=e.files;if(r.length>0){let e=Array.from(r);t[n]&&Array.isArray(t[n])?e.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=e}}}),Array.from(this._form.querySelectorAll(`input[type="file"][name]`)).forEach(e=>{let n=e.name;if(n&&e.files&&e.files.length>0){let r=Array.from(e.files);t[n]&&Array.isArray(t[n])?r.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=r}}),Array.from(this._form.querySelectorAll(`mint-tags[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n){let r=[];e.tags===void 0?typeof e.getTags==`function`&&(r=e.getTags()):r=e.tags,Array.isArray(r)&&r.length>0?t[n]=r.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):t[n]=[]}})),t}_isControlDisabledForSubmit(e){let t=e;for(;t&&t!==this._form;){if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLButtonElement)&&t.disabled)return!0;let e=t.getAttribute(`disabled`);if(e!==null&&e!==`false`)return!0;t=t.parentElement}return!1}_collectLiveControlValues(){let e={};if(!this._form)return e;let t=new Set,n=Array.from(this._form.querySelectorAll([`input[name]`,`textarea[name]`,`select[name]`,`mint-input[name]`,`mint-select[name]`,`mint-date-picker[name]`,`mint-datetime-picker[name]`,`mint-time-picker[name]`,`mint-dropzone[name]`,`mint-checkbox[name]`,`mint-choice[name]`,`mint-switch[name]`,`mint-tags[name]`].join(`,`)));for(let e of n){let n=e.getAttribute(`name`);!n||this._isControlDisabledForSubmit(e)||t.add(n)}for(let n of t){let t=this._getFieldElements(n).filter(e=>!this._isControlDisabledForSubmit(e));if(t.length!==0)try{let r=this._extractFieldValue(t),i=r instanceof FileList?Array.from(r):r,a=e=>e instanceof HTMLInputElement?e.type===`checkbox`||e.type===`radio`:[`MINT-CHECKBOX`,`MINT-CHOICE`,`MINT-SWITCH`].includes(e.tagName),o=t.length===1&&[`MINT-CHECKBOX`,`MINT-SWITCH`].includes(t[0].tagName);if(t.every(a)&&!o&&(i===``||i==null||Array.isArray(i)&&i.length===0))continue;e[n]=i}catch{}}return e}_collectValidationRules(){let e={};return this._form&&Array.from(this._form.querySelectorAll(`[name][validation]`)).forEach(t=>{let n=t.getAttribute(`name`)||``,r=t.getAttribute(`validation`);if(!n||!r)return;let i=this._parseRules(r);i.length&&(e[n]=i)}),e}_parseRules(e){if(!e)return[];try{let t=e.replace(/'/g,`"`),n=JSON.parse(t);if(Array.isArray(n))return n.map(e=>String(e))}catch{}return e.split(`,`).map(e=>e.trim()).filter(Boolean)}_validate(e,t){let n=!0;return this._errors={},Object.entries(t||{}).forEach(([e,t])=>{let r=Array.isArray(t)?t:[t],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(n=!1,this._errors[e]=o,this._flagFieldError(i,o)):this._clearFieldError(i)}),n}_validateField(e){let t=this._collectValidationRules();if(!t[e])return;let n=t[e],r=Array.isArray(n)?n:[n],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(this._errors[e]=o,this._flagFieldError(i,o)):(this._clearFieldError(i),delete this._errors[e])}_validateRules(e,t){for(let n of t){let[t,r]=n.split(`:`);switch(t){case`required`:if(e==null||e===!1||typeof e==`string`&&e.trim()===``||e instanceof FileList&&e.length===0||Array.isArray(e)&&e.length===0)return`This field is required.`;break;case`string`:if(typeof e!=`string`)return`Must be a string.`;break;case`email`:if(typeof e==`string`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()))return`Enter a valid email.`;break;case`number`:{let t=Number(e);if(Number.isNaN(t))return`Must be a number.`;break}case`min`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length<t)return`Must be at least ${t} characters.`;if(Array.isArray(e)&&e.length<t)return`Select at least ${t}.`;if(e instanceof FileList&&e.length<t)return`Upload at least ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<t)return`Must be at least ${t}.`;break}case`max`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length>t)return`Must be at most ${t} characters.`;if(Array.isArray(e)&&e.length>t)return`Select no more than ${t}.`;if(e instanceof FileList&&e.length>t)return`Upload no more than ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>t)return`Must be at most ${t}.`;break}default:break}}return null}_getFieldElements(e){if(!this._form)return[];let t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),n=t.filter(e=>e.tagName===`MINT-SELECT`);if(n.length>0){let r=[];return n.forEach(t=>{let n=t.querySelector(`select[name="`+e+`"]`);n&&r.push(n)}),t.filter(e=>e.tagName!==`MINT-SELECT`).concat(r)}if(t.filter(e=>e.tagName===`MINT-TAGS`).length>0)return t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`));let r=t.filter(e=>e.tagName===`INPUT`&&e.closest(`mint-tags`));if(r.length>0){let e=[];return r.forEach(t=>{let n=t.closest(`mint-tags`);n&&!e.includes(n)&&e.push(n)}),t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`)).concat(e)}return t}_extractFieldValue(e){if(e.length===0)return``;let t=e.find(e=>e instanceof HTMLSelectElement);if(t)return t.multiple?Array.from(t.selectedOptions).map(e=>e.value):t.value;if(e.length>1){let t=e.filter(e=>e instanceof HTMLInputElement);if(t.length>0&&t.length===e.length){let e=t.filter(e=>e.checked);if(t.every(e=>e.type===`radio`))return e.length>0?e[0].value||`on`:``;if(t.every(e=>e.type===`checkbox`))return e.map(e=>e.value||`on`)}let n=e.filter(e=>e.tagName===`MINT-CHOICE`);if(n.length>0&&n.length===e.length){let e=n.find(e=>typeof e.getValue==`function`?e.getValue()!==``:e.querySelector(`mint-choice-option[checked]`)!==null);if(e){if(typeof e.getValue==`function`)return e.getValue();let t=e.querySelector(`mint-choice-option[checked]`);if(t)return t.getAttribute(`value`)||``}return``}let r=e.filter(e=>e.tagName===`MINT-CHECKBOX`);if(r.length>0&&r.length===e.length)return r.filter(e=>e.checked===void 0?e.hasAttribute(`checked`):e.checked).map(e=>e.getAttribute(`value`)||`on`)}let n=e[0];if(n instanceof HTMLInputElement)return n.type===`file`?n.files:n.type===`checkbox`||n.type===`radio`?n.checked?n.value||`on`:``:n.value;if(n instanceof HTMLTextAreaElement)return n.value;if(n.tagName===`MINT-SELECT`){let e=n.querySelector(`select`);if(e)return e.multiple?Array.from(e.selectedOptions).map(e=>e.value):e.value;if(typeof n.getValue==`function`){let e=n.getValue();if(e!=null&&e!==``)return e}return n.getAttribute(`value`)||``}if(n.tagName===`MINT-DROPZONE`&&n.files!==void 0)return n.files;if(n.tagName===`MINT-TAGS`){let e=null;return n.tags===void 0?typeof n.getTags==`function`&&(e=n.getTags()):e=n.tags,Array.isArray(e)?e.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):[]}return n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`?!!(n.checked===void 0?n.hasAttribute(`checked`):n.checked):n.tagName===`MINT-CHOICE`?(typeof n.getValue==`function`?n.getValue():``)||``:n.value===void 0?n.getAttribute(`value`)||``:n.value}_flagFieldError(e,t){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.setAttribute(`aria-invalid`,`true`);let n=this._resolveHost(e);n&&(n.setAttribute(`error`,`true`),n.setAttribute(`error-message`,t),n.setAttribute(`data-mint-form-error`,`true`))})}_clearFieldError(e){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute(`aria-invalid`);let t=this._resolveHost(e);t&&(t.removeAttribute(`error`),t.removeAttribute(`error-message`),t.removeAttribute(`data-mint-form-error`))})}_clearErrors(){this.querySelectorAll(`[data-mint-form-error]`).forEach(e=>{let t=e;t.removeAttribute(`error`),t.removeAttribute(`error-message`),t.removeAttribute(`data-mint-form-error`)}),this._form&&this._form.querySelectorAll(`[aria-invalid="true"]`).forEach(e=>{e.removeAttribute(`aria-invalid`)}),this._errors={}}setFormErrors(e){this._applyServerErrors(e)}_applyServerErrors(e){this._clearErrors(),Object.entries(e).forEach(([e,t])=>{let n=Array.isArray(t)?t[0]||`Validation error`:t||`Validation error`,r=this._getFieldElements(e);r.length>0&&(this._errors[e]=n,this._flagFieldError(r,n))})}_parseFormData(e){if(!e){this._formData=null;return}if(typeof e==`object`&&!Array.isArray(e)){this._formData=e;return}if(typeof e==`string`)try{this._formData=JSON.parse(e)}catch{this._formData=null}else this._formData=null}_parseHeaders(e){if(!e){this._headers=null;return}if(typeof e==`string`)try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;let e=this._getObjectValue(this._formData);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=(e,t)=>{let n=new Set;return t?(Object.keys(e).forEach(r=>{JSON.stringify(t[r])!==JSON.stringify(e[r])&&n.add(r)}),Object.keys(t).forEach(t=>{t in e||n.add(t)}),n):(Object.keys(e).forEach(e=>n.add(e)),n)};if(t(this._createDataSnapshot(this._extractReactiveData(e)),this._lastAppliedDataSnapshot).size===0)return;let n=this._formDataApplyGeneration,r=()=>{if(n!==this._formDataApplyGeneration)return;let e=this._formData?this._getObjectValue(this._formData):null;if(!e||typeof e!=`object`||Array.isArray(e))return;let r=this._createDataSnapshot(this._extractReactiveData(e)),i=t(r,this._lastAppliedDataSnapshot);i.size!==0&&(i.forEach(e=>{let t=r[e],i=this._getFieldElements(e);if(i.length===0){setTimeout(()=>{if(n!==this._formDataApplyGeneration)return;let t=this._getFieldElements(e);if(t.length===0)return;let r=this._formData?this._getObjectValue(this._formData):null;if(!r||typeof r!=`object`||Array.isArray(r))return;let i=this._extractReactiveData(r)[e];this._applyValueToField(t,e,i)},300);return}this._applyValueToField(i,e,t)}),this._lastAppliedDataSnapshot=r)};requestAnimationFrame(()=>{requestAnimationFrame(()=>{r()})})}_applyValueToField(e,t,n){e.forEach(e=>{let r=e.tagName;try{if(r===`MINT-INPUT`)e.value!==void 0&&(e.value=n||``);else if(r===`MINT-DATE-PICKER`)typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-TIME-PICKER`)typeof e.setValue==`function`?e.setValue(n==null?``:String(n)):e.value!==void 0&&(e.value=n==null?``:String(n));else if(r===`MINT-SELECT`||r===`SELECT`)if(r===`SELECT`){let t=e,r=t.closest(`mint-select`);if(r&&typeof r.setValue==`function`)r.setValue(n);else if(t.multiple){let e=Array.isArray(n)?n.map(e=>String(e)):n==null||n===``?[]:[String(n)];Array.from(t.options).forEach(t=>{t.selected=e.includes(t.value)})}else t.value=n==null?``:String(n)}else typeof e.setValue==`function`&&e.setValue(n);else if(r===`MINT-CHOICE`)typeof e.setValue==`function`?e.setValue(n==null?``:String(n)):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=e.getAttribute(`value`)===n});else if(r===`MINT-CHECKBOX`||r===`MINT-SWITCH`){let t=n===!0||n===`true`||n===`on`||n===1||n===`1`;e.checked===void 0?t?e.setAttribute(`checked`,`true`):e.removeAttribute(`checked`):e.checked=t}else if(r===`MINT-TAGS`)if(Array.isArray(n)){let t=new Map;try{let n=e.getAttribute(`predefined-tags`);if(n){let e=JSON.parse(n);Array.isArray(e)&&(t=new Map(e.map(e=>{if(typeof e==`string`){let t=e.trim();return t?[t.toLowerCase(),t]:null}if(!e||typeof e!=`object`)return null;let t=String(e.value??``).trim();if(!t)return null;let n=String(e.label??t);return[t.toLowerCase(),n]}).filter(e=>e!==null)))}}catch{}e.tags!==void 0&&(e.tags=n.map(e=>{if(typeof e==`string`||typeof e==`number`){let n=String(e).trim();return{value:n,label:t.get(n.toLowerCase())||n,dismissable:!0}}if(e&&typeof e==`object`){let n=String(e.value??``).trim(),r=t.get(n.toLowerCase())||String(e.label??n);return{...e,value:n,label:r,dismissable:e.dismissable!==!1}}return e}))}else e.tags!==void 0&&(e.tags=[]);else if(e instanceof HTMLInputElement){if(e.type===`file`)return;e.type===`checkbox`||e.type===`radio`?e.checked=n===!0||n===`true`||n===`on`||n===1||n===`1`:e.value=n||``}else (e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(e.value=n||``)}catch(e){console.warn(`Failed to set value for field ${t}:`,e)}})}_resetCustomFields(){this.querySelectorAll(`mint-input, mint-date-picker, mint-datetime-picker, mint-time-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`).forEach(e=>{e.removeAttribute(`error`),e.removeAttribute(`error-message`);let t=e.tagName;if(t===`MINT-INPUT`)try{e.value=``}catch{}else if(t===`MINT-DATE-PICKER`)try{e.setValue?.(``)}catch{}else if(t===`MINT-SELECT`)try{e.setValue?.(``)}catch{}else if(t===`MINT-DROPZONE`){let t=e.querySelector(`input[type="file"]`);t&&(t.value=``)}else if(t===`MINT-CHECKBOX`||t===`MINT-SWITCH`)try{if(e.checked!==void 0)e.checked=!1;else{e.removeAttribute(`checked`);let t=e.querySelector(`input[type="checkbox"], input[type="radio"]`);t&&(t.checked=!1)}}catch{}else if(t===`MINT-CHOICE`)try{typeof e.setValue==`function`?e.setValue(``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=!1})}catch{}else if(t===`MINT-TAGS`)try{e.tags=[]}catch{}})}_resolveHost(e){if(e.tagName===`MINT-CHOICE-OPTION`){let t=e.closest(`mint-choice`);if(t)return t}return e.closest(`mint-input, mint-date-picker, mint-datetime-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)||e}_setupBlurValidation(){if(!this._form)return;let e=e=>{let t=e.target;if(!t)return;let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;let i=this._extractFieldValue([n]),a=i!=null&&(typeof i==`string`?i.trim()!==``:i instanceof FileList||Array.isArray(i)?i.length>0:!0),o=n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&(t.hasAttribute(`aria-invalid`)||t.closest(`[data-mint-form-error]`)),s=!!n.closest(`mint-tags`),c=n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`||n.tagName===`MINT-CHOICE`||t instanceof HTMLElement&&(t.closest(`mint-checkbox, mint-switch, mint-choice`)||t.closest(`mint-choice-option`)),l=n.tagName===`MINT-DATE-PICKER`||t instanceof HTMLElement&&t.closest(`mint-date-picker, mint-datetime-picker`);(a||o||s||c||l)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`blur`,e,!0),this._fieldBlurHandlers.set(this._form,e);let t=e=>{let t=e.target;if(!t)return;if(!(t instanceof HTMLInputElement&&t.type===`file`)){let e=this._findFieldElement(t),n=e?this._getFieldName(e):null;e&&n&&this._syncFieldToReactiveData(e,n)}if(e.type===`tags-change`&&t.tagName===`MINT-TAGS`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLSelectElement||t.tagName===`MINT-SELECT`||t.closest(`mint-select`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(e.type===`choice-change`&&t.tagName===`MINT-CHOICE`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLInputElement&&t.type===`checkbox`||t.tagName===`MINT-CHECKBOX`||t.tagName===`MINT-SWITCH`||t.closest(`mint-checkbox, mint-switch`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);r&&this._collectValidationRules()[r]&&(n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&t.hasAttribute(`aria-invalid`))&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`change`,t,!0),this._form.addEventListener(`input`,t,!0),this._form.addEventListener(`tags-change`,t,!0),this._form.addEventListener(`choice-change`,t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){let t=e.closest(`mint-input, mint-date-picker, mint-datetime-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`);if(t&&t.hasAttribute(`name`))return t;if(e.hasAttribute(`name`)&&(e.tagName.startsWith(`MINT-`)||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)||(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute(`name`))return e;let n=e;for(;n&&n!==this._form;){if(n.hasAttribute(`name`))return n;n=n.parentElement}return null}_getFieldName(e){return e.hasAttribute(`name`)||e.tagName.startsWith(`MINT-`)?e.getAttribute(`name`):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.name||null}_syncFieldToReactiveData(e,t){if(!this._formData||!t)return;let n=this._getObjectValue(this._formData);if(!n||typeof n!=`object`||Array.isArray(n))return;let r=this._getFieldElements(t),i=this._extractFieldValue(r.length?r:[e]);n[t]=this._normalizeReactiveValue(r,i);let a=this._createDataSnapshot(n);this._lastDataSnapshot=a,this._lastAppliedDataSnapshot={...this._lastAppliedDataSnapshot||a,[t]:a[t]}}_normalizeReactiveValue(e,t){if(t instanceof FileList)return Array.from(t);if(Array.isArray(t))return t;let n=e[0];return e.length===1&&(n instanceof HTMLInputElement&&n.type===`checkbox`||n?.tagName===`MINT-CHECKBOX`||n?.tagName===`MINT-SWITCH`)?!!t:t??``}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){let e=this._fieldBlurHandlers.get(this._form);e&&this._form.removeEventListener(`blur`,e,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){let e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener(`change`,e,!0),this._form.removeEventListener(`input`,e,!0),this._form.removeEventListener(`tags-change`,e,!0),this._form.removeEventListener(`choice-change`,e,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&=(this._observer.disconnect(),null)}_syncDropzoneFiles(){this._form&&Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{typeof e.syncFiles==`function`&&e.syncFiles()})}_isSubmittingAttrActive(){let e=this.getAttribute(`submitting`);return e!==null&&e!==`false`}_applySubmittingAttributeState(){if(this._form){if(!this._isSubmittingAttrActive()){this._restoreSubmittingAttributeState();return}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-datetime-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`).forEach(e=>{let t=e.getAttribute(`disabled`)===`true`;this._attrSubmittingMintFields.set(e,t),t||e.setAttribute(`disabled`,`true`),typeof e.render==`function`&&e.render()}),this._form.querySelectorAll(`input, textarea, select`).forEach(e=>{if(e.closest(`mint-input, mint-select, mint-date-picker, mint-datetime-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags, mint-button`)||e instanceof HTMLInputElement&&e.type===`hidden`)return;let t=e.disabled;this._attrSubmittingNativeFields.set(e,t),t||(e.disabled=!0)}),Array.from(this.querySelectorAll(`mint-button`)).forEach(e=>{let t=e.getAttribute(`disabled`)===`true`,n=e.getAttribute(`loading`)===`true`;this._attrSubmittingMintButtons.set(e,{disabled:t,loading:n});let r=(e.getAttribute(`type`)||e.getAttribute(`button-type`)||`default`)===`submit`;t||e.setAttribute(`disabled`,`true`),r&&!n&&e.setAttribute(`loading`,`true`),typeof e.render==`function`&&e.render()}),Array.from(this.querySelectorAll(`button`)).forEach(e=>{if(e.closest(`mint-button, mint-input, mint-select, mint-date-picker, mint-datetime-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`))return;let t=e.disabled;this._attrSubmittingNativeButtons.set(e,t),t||(e.disabled=!0)}))}}_restoreSubmittingAttributeState(){this._attrSubmittingMintFields.forEach((e,t)=>{e?t.setAttribute(`disabled`,`true`):t.removeAttribute(`disabled`),typeof t.render==`function`&&t.render()}),this._attrSubmittingMintFields.clear(),this._attrSubmittingNativeFields.forEach((e,t)=>{t.disabled=e}),this._attrSubmittingNativeFields.clear(),this._attrSubmittingMintButtons.forEach((e,t)=>{e.disabled?t.setAttribute(`disabled`,`true`):t.removeAttribute(`disabled`),e.loading?t.setAttribute(`loading`,`true`):t.removeAttribute(`loading`),typeof t.render==`function`&&t.render()}),this._attrSubmittingMintButtons.clear(),this._attrSubmittingNativeButtons.forEach((e,t)=>{t.disabled=e}),this._attrSubmittingNativeButtons.clear()}_propagateLoadingState(){if(!this._form)return;let e=this.getAttribute(`loading`),t=e!==null&&e!==`false`;Array.from(this._form.querySelectorAll(`mint-input, mint-select, mint-date-picker, mint-datetime-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)).forEach(e=>{t?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();let e=Array.from(this.querySelectorAll(`mint-button`)),t=Array.from(this.querySelectorAll(`button`));e.forEach(e=>{let t=e.getAttribute(`disabled`)===`true`,n=e.getAttribute(`loading`)===`true`;this._buttonStates.set(e,{disabled:t,loading:n});let r=(e.getAttribute(`type`)||e.getAttribute(`button-type`)||`default`)===`submit`;t||e.setAttribute(`disabled`,`true`),r&&e.setAttribute(`loading`,`true`),typeof e.render==`function`&&e.render()}),t.forEach(e=>{if(e.closest(`mint-button`))return;let t=e.disabled;this._buttonStates.set(e,{disabled:t,loading:!1}),t||(e.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;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`));t.forEach(t=>{if(e&&this._attrSubmittingMintButtons.has(t))return;let n=this._buttonStates.get(t);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())}),n.forEach(t=>{if(t.closest(`mint-button`)||e&&this._attrSubmittingNativeButtons.has(t))return;let n=this._buttonStates.get(t);n&&(t.disabled=n.disabled)}),this._buttonStates.clear()}_isReactiveObject(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}_createDataSnapshot(e){try{let t=this._extractReactiveData(e);return JSON.parse(JSON.stringify(t))}catch{return{...this._extractReactiveData(e)}}}_extractReactiveData(e){if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>this._extractReactiveData(e));let t=this._getObjectValue(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this._extractReactiveData(t[n]));return e}return t}_hasDataChanged(e,t){try{return JSON.stringify(e)!==JSON.stringify(t)}catch{return!0}}_getObjectValue(e){return e}_setupObjectDataObserver(e){if(this._stopReactiveDataObserver(),!this.isConnected)return;let t=this._getObjectValue(e);if(t&&typeof t==`object`&&!Array.isArray(t))this._lastDataSnapshot=this._createDataSnapshot(t);else{this._lastDataSnapshot=null;return}let n=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}let e=this._getObjectValue(this._formData);if(e&&typeof e==`object`&&!Array.isArray(e)){let t=this._createDataSnapshot(e);this._hasDataChanged(t,this._lastDataSnapshot)&&(this._lastDataSnapshot=t,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(n):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(n)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null,this._lastAppliedDataSnapshot=null}};customElements.get(`mint-form`)||e.t(`mint-form`,t),typeof window<`u`&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(e,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:e,rejected:t}),window.mintForm.interceptors.response.handlers.length-1})),module.exports=t;
|
|
@@ -15,7 +15,7 @@ var t = class extends HTMLElement {
|
|
|
15
15
|
];
|
|
16
16
|
}
|
|
17
17
|
constructor() {
|
|
18
|
-
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, this._lastAppliedDataSnapshot = null;
|
|
18
|
+
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, this._lastAppliedDataSnapshot = null, this._formDataApplyGeneration = 0;
|
|
19
19
|
}
|
|
20
20
|
connectedCallback() {
|
|
21
21
|
this._render(), this._ensureSubmitHandler(), this._setupBlurValidation();
|
|
@@ -35,10 +35,12 @@ var t = class extends HTMLElement {
|
|
|
35
35
|
this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._restoreSubmittingAttributeState(), this._cleanupBlurValidation(), this._stopReactiveDataObserver();
|
|
36
36
|
}
|
|
37
37
|
reset() {
|
|
38
|
-
this._clearErrors(), this._formData ? (this._lastAppliedDataSnapshot = null, this._applyFormData()) : this.clear();
|
|
38
|
+
this._clearErrors(), this._formDataApplyGeneration += 1, this._formData ? (this._lastAppliedDataSnapshot = null, this._applyFormData()) : this.clear();
|
|
39
39
|
}
|
|
40
40
|
clear() {
|
|
41
|
-
this._clearErrors(), this._form && this._form.reset(), this._resetCustomFields();
|
|
41
|
+
this._clearErrors(), this._formDataApplyGeneration += 1, this._form && this._form.reset(), this._resetCustomFields();
|
|
42
|
+
let e = this._formData ? this._getObjectValue(this._formData) : null;
|
|
43
|
+
e && typeof e == "object" && !Array.isArray(e) && (this._lastAppliedDataSnapshot = this._createDataSnapshot(this._extractReactiveData(e)));
|
|
42
44
|
}
|
|
43
45
|
submit() {
|
|
44
46
|
if (this._form) {
|
|
@@ -67,13 +69,13 @@ var t = class extends HTMLElement {
|
|
|
67
69
|
return this._formData;
|
|
68
70
|
}
|
|
69
71
|
set data(e) {
|
|
70
|
-
this._stopReactiveDataObserver(), this._reactiveDataProxy = null, this._lastDataSnapshot = null, this._lastAppliedDataSnapshot = null, e && typeof e == "object" && !Array.isArray(e) ? (this._formData = e, this._isReactiveObject(e) ? this._setupObjectDataObserver(e) : this._lastDataSnapshot = this._createDataSnapshot(e)) : e == null ? this._formData = null : this._parseFormData(e), this.isConnected && this._form && requestAnimationFrame(() => {
|
|
72
|
+
e !== this._formData && (this._formDataApplyGeneration += 1, this._stopReactiveDataObserver(), this._reactiveDataProxy = null, this._lastDataSnapshot = null, this._lastAppliedDataSnapshot = null, e && typeof e == "object" && !Array.isArray(e) ? (this._formData = e, this._isReactiveObject(e) ? this._setupObjectDataObserver(e) : this._lastDataSnapshot = this._createDataSnapshot(e)) : e == null ? this._formData = null : this._parseFormData(e), this.isConnected && this._form && requestAnimationFrame(() => {
|
|
71
73
|
requestAnimationFrame(() => {
|
|
72
74
|
requestAnimationFrame(() => {
|
|
73
75
|
this._applyFormData();
|
|
74
76
|
});
|
|
75
77
|
});
|
|
76
|
-
});
|
|
78
|
+
}));
|
|
77
79
|
}
|
|
78
80
|
get headers() {
|
|
79
81
|
return this._headers;
|
|
@@ -581,33 +583,40 @@ var t = class extends HTMLElement {
|
|
|
581
583
|
if (!this._formData || !this._form) return;
|
|
582
584
|
let e = this._getObjectValue(this._formData);
|
|
583
585
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
584
|
-
let t =
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
586
|
+
let t = (e, t) => {
|
|
587
|
+
let n = /* @__PURE__ */ new Set();
|
|
588
|
+
return t ? (Object.keys(e).forEach((r) => {
|
|
589
|
+
JSON.stringify(t[r]) !== JSON.stringify(e[r]) && n.add(r);
|
|
590
|
+
}), Object.keys(t).forEach((t) => {
|
|
591
|
+
t in e || n.add(t);
|
|
592
|
+
}), n) : (Object.keys(e).forEach((e) => n.add(e)), n);
|
|
593
|
+
};
|
|
594
|
+
if (t(this._createDataSnapshot(this._extractReactiveData(e)), this._lastAppliedDataSnapshot).size === 0) return;
|
|
595
|
+
let n = this._formDataApplyGeneration, r = () => {
|
|
596
|
+
if (n !== this._formDataApplyGeneration) return;
|
|
597
|
+
let e = this._formData ? this._getObjectValue(this._formData) : null;
|
|
598
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
599
|
+
let r = this._createDataSnapshot(this._extractReactiveData(e)), i = t(r, this._lastAppliedDataSnapshot);
|
|
600
|
+
i.size !== 0 && (i.forEach((e) => {
|
|
601
|
+
let t = r[e], i = this._getFieldElements(e);
|
|
602
|
+
if (i.length === 0) {
|
|
595
603
|
setTimeout(() => {
|
|
604
|
+
if (n !== this._formDataApplyGeneration) return;
|
|
596
605
|
let t = this._getFieldElements(e);
|
|
597
606
|
if (t.length === 0) return;
|
|
598
|
-
let
|
|
599
|
-
if (!
|
|
600
|
-
let
|
|
601
|
-
this._applyValueToField(t, e,
|
|
607
|
+
let r = this._formData ? this._getObjectValue(this._formData) : null;
|
|
608
|
+
if (!r || typeof r != "object" || Array.isArray(r)) return;
|
|
609
|
+
let i = this._extractReactiveData(r)[e];
|
|
610
|
+
this._applyValueToField(t, e, i);
|
|
602
611
|
}, 300);
|
|
603
612
|
return;
|
|
604
613
|
}
|
|
605
|
-
this._applyValueToField(
|
|
606
|
-
}), this._lastAppliedDataSnapshot =
|
|
614
|
+
this._applyValueToField(i, e, t);
|
|
615
|
+
}), this._lastAppliedDataSnapshot = r);
|
|
607
616
|
};
|
|
608
617
|
requestAnimationFrame(() => {
|
|
609
618
|
requestAnimationFrame(() => {
|
|
610
|
-
|
|
619
|
+
r();
|
|
611
620
|
});
|
|
612
621
|
});
|
|
613
622
|
}
|
|
@@ -810,7 +819,12 @@ var t = class extends HTMLElement {
|
|
|
810
819
|
let n = this._getObjectValue(this._formData);
|
|
811
820
|
if (!n || typeof n != "object" || Array.isArray(n)) return;
|
|
812
821
|
let r = this._getFieldElements(t), i = this._extractFieldValue(r.length ? r : [e]);
|
|
813
|
-
n[t] = this._normalizeReactiveValue(r, i)
|
|
822
|
+
n[t] = this._normalizeReactiveValue(r, i);
|
|
823
|
+
let a = this._createDataSnapshot(n);
|
|
824
|
+
this._lastDataSnapshot = a, this._lastAppliedDataSnapshot = {
|
|
825
|
+
...this._lastAppliedDataSnapshot || a,
|
|
826
|
+
[t]: a[t]
|
|
827
|
+
};
|
|
814
828
|
}
|
|
815
829
|
_normalizeReactiveValue(e, t) {
|
|
816
830
|
if (t instanceof FileList) return Array.from(t);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/select/Select.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAA;AACtB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,wBAAwB,CAAA;AAC/B,OAAO,0BAA0B,CAAA;AACjC,OAAO,kBAAkB,CAAA;AAIzB,cAAM,UAAW,SAAQ,WAAW;IAClC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,GAAG,CAA2D;IAEtE,iBAAiB,IAAI,IAAI;IAiBzB,oBAAoB,IAAI,IAAI;IAM5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAoB9F,IAAI,KAAK,IAAI,MAAM,GAAG,MAAM,EAAE,CAG7B;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAA0B;IAC5D,IAAI,MAAM,IAAI,MAAM,EAAE,CAGrB;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAA2B;IACtD,QAAQ,IAAI,MAAM,GAAG,MAAM,EAAE;IAC7B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAa9B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,cAAc;IAEtB,OAAO,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/select/Select.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAA;AACtB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,wBAAwB,CAAA;AAC/B,OAAO,0BAA0B,CAAA;AACjC,OAAO,kBAAkB,CAAA;AAIzB,cAAM,UAAW,SAAQ,WAAW;IAClC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,sBAAsB,CAA+C;IAC7E,OAAO,CAAC,GAAG,CAA2D;IAEtE,iBAAiB,IAAI,IAAI;IAiBzB,oBAAoB,IAAI,IAAI;IAM5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAoB9F,IAAI,KAAK,IAAI,MAAM,GAAG,MAAM,EAAE,CAG7B;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAA0B;IAC5D,IAAI,MAAM,IAAI,MAAM,EAAE,CAGrB;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAA2B;IACtD,QAAQ,IAAI,MAAM,GAAG,MAAM,EAAE;IAC7B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAa9B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,cAAc;IAEtB,OAAO,CAAC,MAAM;IAyJd,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,SAAS;IAqBjB,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,UAAU;IAsElB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,YAAY;IAqBpB,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,SAAS;CAUlB;AAGD,eAAe,UAAU,CAAA"}
|
|
@@ -286,7 +286,7 @@ customElements.get("mint-native-select") || e("mint-native-select", n);
|
|
|
286
286
|
//#region src/components/select/Select.ts
|
|
287
287
|
var r = "data-mint-select-part", i = class extends HTMLElement {
|
|
288
288
|
constructor(...e) {
|
|
289
|
-
super(...e), this._native = null, this._trigger = null, this._popover = null, this._list = null, this._observer = null, this._syncing = !1, this._typeahead = "", this._typeaheadTimer = null, this._id = `mint-select-${Math.random().toString(36).slice(2, 10)}`;
|
|
289
|
+
super(...e), this._native = null, this._trigger = null, this._popover = null, this._list = null, this._observer = null, this._syncing = !1, this._typeahead = "", this._typeaheadTimer = null, this._pointerSelectedOption = null, this._id = `mint-select-${Math.random().toString(36).slice(2, 10)}`;
|
|
290
290
|
}
|
|
291
291
|
static get observedAttributes() {
|
|
292
292
|
return [
|
|
@@ -421,62 +421,62 @@ var r = "data-mint-select-part", i = class extends HTMLElement {
|
|
|
421
421
|
return this._native?.selectedOptions[0] || this.options().find((e) => e.value === this.value);
|
|
422
422
|
}
|
|
423
423
|
render() {
|
|
424
|
-
let e = this._native?.value
|
|
424
|
+
let e = this._native?.value || this.getAttribute("value") || "", t = this._native?.multiple ? Array.from(this._native.selectedOptions, (e) => e.value) : [], n = t.length ? t : this.parseValues(this.getAttribute("values"));
|
|
425
425
|
this._syncing = !0, Array.from(this.children).forEach((e) => {
|
|
426
426
|
e.hasAttribute(r) && e.remove();
|
|
427
427
|
});
|
|
428
|
-
let
|
|
429
|
-
if (
|
|
428
|
+
let i = this.getAttribute("label")?.trim() || "", a = this.getAttribute("id") || this._id;
|
|
429
|
+
if (i) {
|
|
430
430
|
let e = document.createElement("label");
|
|
431
|
-
e.setAttribute(r, "label"), e.className = "mint-select-label", e.htmlFor = `${
|
|
431
|
+
e.setAttribute(r, "label"), e.className = "mint-select-label", e.htmlFor = `${a}-trigger`, e.textContent = i, this.append(e);
|
|
432
432
|
}
|
|
433
|
-
let
|
|
434
|
-
|
|
435
|
-
let
|
|
436
|
-
|
|
437
|
-
let
|
|
438
|
-
if (
|
|
433
|
+
let o = document.createElement("div");
|
|
434
|
+
o.setAttribute(r, "wrap"), o.className = "mint-select-control-wrap", o.style.position = "relative", this.append(o);
|
|
435
|
+
let s = document.createElement("button");
|
|
436
|
+
s.type = "button", s.id = `${a}-trigger`, s.className = "mint-select-trigger", s.disabled = this.isDisabled() || this.isLoading(), s.setAttribute("role", "combobox"), s.setAttribute("aria-busy", String(this.isLoading())), s.setAttribute("aria-haspopup", "listbox"), s.setAttribute("aria-expanded", "false"), s.setAttribute("aria-required", String(this.isRequired())), s.setAttribute("aria-invalid", String(this.hasError()));
|
|
437
|
+
let c = this.getAttribute("aria-labelledby"), l = this.getAttribute("aria-label")?.trim();
|
|
438
|
+
if (c ? s.setAttribute("aria-labelledby", c) : !i && l ? s.setAttribute("aria-label", l) : i && s.setAttribute("aria-labelledby", `${a}-label`), i) {
|
|
439
439
|
let e = this.querySelector(`[${r}="label"]`);
|
|
440
|
-
e && (e.id = `${
|
|
440
|
+
e && (e.id = `${a}-label`);
|
|
441
441
|
}
|
|
442
|
-
let l = document.createElement("span");
|
|
443
|
-
l.className = "mint-select-value", o.append(l);
|
|
444
442
|
let u = document.createElement("span");
|
|
445
|
-
u.className = "mint-select-
|
|
446
|
-
let d =
|
|
447
|
-
|
|
448
|
-
let f =
|
|
449
|
-
f.
|
|
450
|
-
let p =
|
|
443
|
+
u.className = "mint-select-value", s.append(u);
|
|
444
|
+
let d = document.createElement("span");
|
|
445
|
+
d.className = "mint-select-caret", d.setAttribute("aria-hidden", "true"), d.innerHTML = "<mint-icon name=\"caret-up\"></mint-icon><mint-icon name=\"caret-down\"></mint-icon>", s.append(d), o.append(s);
|
|
446
|
+
let f = null;
|
|
447
|
+
this.isLoading() ? (f = document.createElement("div"), f.className = "mint-select-skeleton", f.setAttribute("aria-hidden", "true"), f.style.cssText = "position:absolute;inset:0;z-index:1;border:1px solid var(--mint-color-border,#dfe6e0);border-radius:.5rem;background:var(--mint-color-surface-muted,#e8eee9);animation:mint-select-pulse 1.4s ease-in-out infinite;", o.append(f), s.style.visibility = "hidden", this.setAttribute("aria-busy", "true")) : this.removeAttribute("aria-busy");
|
|
448
|
+
let p = document.createElement("select");
|
|
449
|
+
p.setAttribute(r, "native"), p.className = "mint-select-native-control", p.id = `${a}-native`, p.name = this.getAttribute("name") || "", p.multiple = this.isMultiple(), this.hasAttribute("form") && p.setAttribute("form", this.getAttribute("form") || ""), p.required = this.isRequired(), p.disabled = this.isDisabled(), p.tabIndex = -1, p.setAttribute("aria-hidden", "true"), p.setAttribute("aria-invalid", String(this.hasError()));
|
|
450
|
+
let m = [
|
|
451
451
|
this.getAttribute("aria-describedby"),
|
|
452
|
-
|
|
453
|
-
this.getAttribute("info") ? `${
|
|
454
|
-
this.getAttribute("error-message") ? `${
|
|
452
|
+
i ? `${a}-label` : "",
|
|
453
|
+
this.getAttribute("info") ? `${a}-info` : "",
|
|
454
|
+
this.getAttribute("error-message") ? `${a}-error` : ""
|
|
455
455
|
].filter(Boolean).join(" ");
|
|
456
|
-
if (
|
|
456
|
+
if (m && p.setAttribute("aria-describedby", m), this.options().forEach((e) => p.append(e.cloneNode(!0))), !p.options.length) {
|
|
457
457
|
let e = document.createElement("option");
|
|
458
|
-
e.value = "", e.textContent = this.getAttribute("placeholder") || "Select an option", e.disabled = !0,
|
|
458
|
+
e.value = "", e.textContent = this.getAttribute("placeholder") || "Select an option", e.disabled = !0, p.append(e);
|
|
459
459
|
}
|
|
460
|
-
if (
|
|
461
|
-
let
|
|
462
|
-
|
|
463
|
-
e.selected =
|
|
460
|
+
if (p.multiple) {
|
|
461
|
+
let t = n.length ? n : this.parseValues(this.getAttribute("values")).length ? this.parseValues(this.getAttribute("values")) : e ? [e] : [];
|
|
462
|
+
t.length && Array.from(p.options).forEach((e) => {
|
|
463
|
+
e.selected = t.includes(e.value);
|
|
464
464
|
});
|
|
465
|
-
} else
|
|
466
|
-
|
|
467
|
-
let
|
|
468
|
-
|
|
469
|
-
let
|
|
470
|
-
|
|
471
|
-
let
|
|
472
|
-
if (
|
|
465
|
+
} else p.value = e;
|
|
466
|
+
o.append(p), this._native = p, this._trigger = s;
|
|
467
|
+
let h = document.createElement("mint-popover");
|
|
468
|
+
h.className = "mint-select-popover", h.setAttribute(r, "popover"), h.setAttribute("trigger-id", s.id), h.setAttribute("trigger-toggle", "false"), h.setAttribute("direction", "down"), h.setAttribute("trigger-align", "start"), h.setAttribute("align-selected", "true"), h.setAttribute("distance", "4"), h.setAttribute("padding", "0"), h.setAttribute("aria-label", i ? `${i} options` : "Select options");
|
|
469
|
+
let g = document.createElement("div");
|
|
470
|
+
g.className = "mint-select-options", g.id = `${a}-listbox`, g.setAttribute("role", "listbox"), g.setAttribute("aria-multiselectable", String(this.isMultiple())), s.setAttribute("aria-controls", g.id), h.append(g), this.append(h), this._popover = h, this._list = g, this.renderOptions(), this.updateDisplay(), this.bindEvents();
|
|
471
|
+
let _ = this.getAttribute("info");
|
|
472
|
+
if (_) {
|
|
473
473
|
let e = document.createElement("div");
|
|
474
|
-
e.setAttribute(r, "info"), e.className = "mint-select-info", e.id = `${
|
|
474
|
+
e.setAttribute(r, "info"), e.className = "mint-select-info", e.id = `${a}-info`, e.textContent = _, this.append(e);
|
|
475
475
|
}
|
|
476
|
-
let
|
|
477
|
-
if (this.hasError() &&
|
|
476
|
+
let v = this.getAttribute("error-message");
|
|
477
|
+
if (this.hasError() && v) {
|
|
478
478
|
let e = document.createElement("div");
|
|
479
|
-
e.setAttribute(r, "error"), e.className = "mint-select-error", e.id = `${
|
|
479
|
+
e.setAttribute(r, "error"), e.className = "mint-select-error", e.id = `${a}-error`, e.textContent = v, this.append(e);
|
|
480
480
|
}
|
|
481
481
|
this._syncing = !1;
|
|
482
482
|
}
|
|
@@ -517,9 +517,20 @@ var r = "data-mint-select-part", i = class extends HTMLElement {
|
|
|
517
517
|
t ? this.selectOption(t.dataset.value || "") : this.openPopover();
|
|
518
518
|
} else e.key === " " && (e.preventDefault(), this.openPopover());
|
|
519
519
|
else e.key === "Escape" && this._popover.hasAttribute("open") ? (e.preventDefault(), this._popover.close(), this._trigger.focus()) : e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && this.typeahead(e.key);
|
|
520
|
+
}, this._list.onpointerdown = (e) => {
|
|
521
|
+
let t = e.target.closest("[role=\"option\"]");
|
|
522
|
+
if (!t || t.disabled) return;
|
|
523
|
+
e.preventDefault();
|
|
524
|
+
let n = t.dataset.value || "";
|
|
525
|
+
this._pointerSelectedOption = {
|
|
526
|
+
value: n,
|
|
527
|
+
time: Date.now()
|
|
528
|
+
}, this.selectOption(n);
|
|
520
529
|
}, this._list.onclick = (e) => {
|
|
521
530
|
let t = e.target.closest("[role=\"option\"]");
|
|
522
|
-
|
|
531
|
+
if (!t || t.disabled) return;
|
|
532
|
+
let n = t.dataset.value || "", r = this._pointerSelectedOption?.value === n && Date.now() - this._pointerSelectedOption.time < 1e3;
|
|
533
|
+
this._pointerSelectedOption = null, r || this.selectOption(n);
|
|
523
534
|
}, this._list.onkeydown = (e) => {
|
|
524
535
|
let t = Array.from(this._list.querySelectorAll("[role=\"option\"]:not(:disabled)")), n = t.indexOf(e.target), r = n;
|
|
525
536
|
if (e.key === "ArrowDown") r = Math.min(t.length - 1, n + 1);
|