@daracl/form 0.0.18 → 0.0.19
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/daracl.form.css +163 -63
- package/dist/daracl.form.min.css +2 -2
- package/dist/daracl.form.min.umd.js +30 -30
- package/dist/daracl.form.min.umd.js.map +1 -1
- package/dist/daracl.form.umd.js +26 -6
- package/dist/daracl.form.umd.js.map +1 -1
- package/dist/index.cjs +26 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -6
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +24 -24
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +397 -392
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
- package/style/base/_base.scss +18 -9
- package/style/components/_field-container.scss +2 -1
- package/style/components/_file-list.scss +30 -4
- package/style/components/_form-field.scss +3 -2
- package/style/components/_form-group.scss +5 -1
- package/style/components/_grid-field.scss +0 -1
- package/style/components/_icon.scss +12 -2
- package/style/components/_label.scss +16 -10
- package/style/components/_tab.scss +1 -2
- package/style/daracl.form.css +204 -128
- package/style/daracl.form.css.map +1 -1
- package/style/daracl.form.min.css +1 -1
- package/style/daracl.form.min.css.map +1 -1
- package/style/daracl.form.scss +24 -15
- package/style/themes/_common.scss +6 -1
- package/style/themes/_dark.scss +24 -12
- package/style/themes/_light.scss +10 -4
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @daracl/form v0.0.
|
|
2
|
+
* @daracl/form v0.0.19
|
|
3
3
|
* Copyright 2023-2026 darainfo;
|
|
4
4
|
* Licensed MIT
|
|
5
5
|
*/
|
|
6
|
-
(function(
|
|
6
|
+
(function(H){typeof define=="function"&&define.amd?define(H):H()})(function(){"use strict";function H(s){return Array.isArray(s)}function Ye(s){return s==null}function ne(s){return typeof s=="string"||s instanceof String}function _e(s){return Ye(s)?!0:ne(s)?s.trim()==="":Array.isArray(s)?s.length===0:typeof s=="object"?Object.keys(s).length===0:!1}function Y(s){return typeof s=="function"||s instanceof Function}function je(s,e=!1){return e===!0?!Number.isNaN(s):(typeof s=="number"||ne(s)&&s.trim()!==""&&!isNaN(parseFloat(s)))&&isFinite(Number(s))}function w(s,e,t="0"){return Ee(s,e,t,"l")}function B(s,e,t="0"){return Ee(s,e,t,"l",!0)}function Ee(s,e,t,i="l",n=!1){let l="";_e(s)?l="":l=ne(s)?s:`${s}`;const a=l.length;if(a>e)return n?l.slice(0,e):l;const o=e-a;if(o<1)return l;const r=t.repeat(o);return i==="l"?r+l:l+r}const le={"&":"&","<":"<",">":">",'"':""","'":"'"},X=s=>{let e=s;return e&&Object.keys(le).forEach(t=>{e=e.replaceAll(t,le[t])}),e},ze=(s,e)=>s.hasOwnProperty(e),M=s=>s===null||s===""||typeof s>"u"||typeof s=="string"&&(s===""||s.replace(/\s/g,"")===""),v=s=>typeof s>"u",$e=s=>typeof s=="function",ae=s=>typeof s=="string",F=s=>M(s)?!1:(s=+s,!isNaN(s)),x=s=>H(s),C=s=>v(s)||s==null,_=s=>s&&s.renderType==="tab",be=s=>s&&s.renderType==="grid",We=s=>(s.$xssName=Me(s),s.label=X(s.label),s),we=s=>be(s.$parent)||_(s.$parent),Me=s=>{if(v(s.$xssName)){let e=s.name;return e&&Object.keys(le).forEach(t=>{e=e.replaceAll(t,"_")}),"df_"+e}return s.$xssName},Pe=s=>{let e=0;if(s.length==0)return e;for(let t=0;t<s.length;t++){let i=s.charCodeAt(t);e=(e<<5)-e+i,e=e&e}return String(e).replaceAll(/-/g,"_")},Be=s=>s.renderType==="hidden",j=s=>{const e=document.createElement("template");return e.innerHTML=s,e.content.firstElementChild};function re(s){if(typeof s!="object"||s===null)return!1;let e=s;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(s)===e}function Fe(s){return typeof s=="object"&&s!==null&&!x(s)}function Xe(s){return s instanceof Date&&!isNaN(s.valueOf())}const oe=(...s)=>{let e=s[0];if(!re(e)||C(e))return e;let t=1;Object.keys(e).length>0&&(t=0,e=x(e)?[]:{});const i=s.length;for(;t<i;t+=1)U(e,s[t]);return e};function U(s,e){return Fe(e)?Ue(s,e):x(e)?Ke(s,e):Xe(e)?new e.constructor(e):e}function Ue(s,e){if($e(e))return e;for(const t of Object.keys(e)){const i=e[t];v(i)||(i===null||$e(i)?s[t]=i:C(s[t])?s[t]=U(x(i)?[]:{},i):Fe(i)?U(s[t],i):s[t]=i)}return s}function Ke(s,e){const t=re(s);for(let i=0;i<e.length;i+=1){const n=e[i];let l;n==null?l=n:l=U(x(n)?[]:{},n),t?s[i]=l:s.push(l)}return s}class f{constructor(e,t,i){var n;this.enableView=!0,this.daraForm=e,this.field=t,this.rowElement=i,this.createField(),t.tooltip&&((n=i.querySelector(".df-tooltip"))==null||n.setAttribute("tooltip",t.tooltip))}setDefaultInfo(){if(v(this.field.defaultValue)?this.setValue("",!1):this.setValue(this.field.defaultValue,!1),!v(this.field.placeholder)){const e=this.getElement();e instanceof Element&&e.setAttribute("placeholder",this.field.placeholder)}}setDefaultOption(){this.setDisabled(this.field.disabled??!1)}addChildField(e){var t;(t=this.rowElement.querySelector(".df-field-container"))==null||t.append(e)}static isDataRender(){return!0}static isChildrenCreate(){return!0}getForm(){return this.daraForm}setValueItems(e){}static getDescriptionTemplate(e){const t=e.descriptionClass?X(e.descriptionClass):"",i=e.descriptionStyle?'style="'+X(e.descriptionStyle)+'"':"";return e.description?`<div class="df-description ${t}" ${i}>${e.description}</div>`:""}changeEventCall(e,t,i,n){var l;if(e.onChange){let a={field:e,evt:t,oldValue:e.$value,value:n};if((l=e.listItem)!=null&&l.list){let o=[];const r=f.valuesValueKey(e);for(let d of e.listItem.list){let h=d[r];if(ae(n)){if(h==n){o.push(d);break}}else x(n)&&n.includes(h)&&o.push(d)}a.valueItems=o}if(a.oldValue!=a.value&&e.onChange.call(null,a)===!1)return i.setValue(e.$value,!1),!1;e.$value=a.value}this.daraForm.conditionCheck()}focus(){this.getElement().focus()}isEnableView(){return this.enableView}show(){this.enableView=!0,this.rowElement.classList.remove("df-hidden")}hide(){this.enableView=!1,this.rowElement.classList.contains("df-hidden")||this.rowElement.classList.add("df-hidden")}setDescription(e){var i;const t=this.rowElement.querySelector(".df-description");if(t)t.textContent=e;else{const n=this.rowElement.querySelector(".df-field");if(n){const l=new DOMParser;this.field.description=e;const a=l.parseFromString(f.getDescriptionTemplate(this.field),"text/html").querySelector(".df-description");a&&((i=n.parentNode)==null||i.insertBefore(a,n.nextSibling))}}}setActive(e){}setDisabled(e){this.getElement()instanceof HTMLElement&&(e===!1?this.getElement().removeAttribute("disabled"):this.getElement().setAttribute("disabled",!0))}commonValidator(){}static valuesValueKey(e){var t;return(t=e.listItem)!=null&&t.valueField?e.listItem.valueField:"value"}static valuesLabelKey(e){var t;return(t=e.listItem)!=null&&t.labelField?e.listItem.labelField:"label"}static valuesLabelValue(e,t){let i=!1;const n=e.replace(/\{\{([A-Za-z0-9_.]*)\}\}/g,(l,a)=>(i=!0,t[a]||""));return i?n:t[e]||""}}const Ze={mobile:/^\d{3}-\d{3,4}-\d{4}$/,email:/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,url:/^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*(?:\.(?:[a-zA-Z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/,number:/\d$/,alpha:/^[a-zA-Z]+$/,"alpha-num":/^[a-zA-Z0-9]+$/,variable:/^[a-zA-Z0-9_$][a-zA-Z0-9_$]*$/,"number-char":/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]/,"upper-char":/^(?=.*?[A-Z])(?=.*?[a-z])/,"upper-char-special":/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$%^&*-])/,"upper-char-special-number":/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]/},De=(s,e,t)=>{if(!e.$instance.isEnableView())return{name:e.name,constraint:[]};typeof t>"u"&&(t={name:e.name,constraint:[]});const i=e.regexpType;return i&&!Ze[i].test(s)&&(t.regexp=i),t},xe=(s,e,t)=>{if(e.validator&&(t.validator=e.validator(e,s),typeof t.validator=="object")||(t=De(s,e,t),t.regexp))return t;if(e.different){const i=e.different.field,n=e.$instance.getForm().getField(i);if(!C(n)&&e.$instance.getValue()==n.$instance.getValue())return t.message=e.different.message,t}if(e.identical){const i=e.identical.field,n=e.$instance.getForm().getField(i);if(!C(n)&&e.$instance.getValue()!=n.$instance.getValue())return t.message=e.identical.message,t}return!0},de=(s,e)=>{if(!e.$instance.isEnableView())return!0;const t={name:e.name,constraint:[]},i=Number(s);if(e.required&&M(s))return t.constraint.push(y.REQUIRED),t;if(!F(s))return t.constraint.push(y.NAN),t;if(xe(s,e,t)!==!0)return t;const n=e.rule;if(n){const l=F(n.minimum),a=F(n.maximum);let o=!1,r=!1,d=!1,h=!1;l&&(n.exclusiveMinimum&&i<=n.minimum?r=!0:i<n.minimum&&(o=!0)),a&&(n.exclusiveMaximum&&i>=n.maximum?h=!0:i>n.maximum&&(d=!0)),l&&a&&(o||r||d||h)?n.exclusiveMinimum&&n.exclusiveMaximum&&(r||h)?t.constraint.push(y.BETWEEN_EXCLUSIVE_MINMAX):r?t.constraint.push(y.BETWEEN_EXCLUSIVE_MIN):h?t.constraint.push(y.BETWEEN_EXCLUSIVE_MAX):t.constraint.push(y.BETWEEN):(r&&t.constraint.push(y.EXCLUSIVE_MIN),h&&t.constraint.push(y.EXCLUSIVE_MAX),o&&t.constraint.push(y.MIN),d&&t.constraint.push(y.MAX))}return t.constraint.length>0?t:!0},$=(s,e,t)=>{if(t===!0){e.classList.remove("invalid"),e.classList.contains("valid")||e.classList.add("valid");const i=e.querySelector(".df-help-message");i&&(i.innerHTML="");return}if(e.classList.remove("valid"),e.classList.contains("invalid")||e.classList.add("invalid"),t!==!1){const i=N.validMessage(s,t);t.message&&i.push(t.message);const n=e.querySelector(".df-help-message");if(n&&i.length>0){const l=[];i.forEach(a=>{l.push(`<div>${a}</div>`)}),n.innerHTML=l.join("")}}},b=s=>{s.classList.remove("invalid"),s.classList.remove("valid")},he=(s,e,t)=>{e.addEventListener("input",i=>{I(s,i,t,t.getValue()),t.valid()})},Qe=(s,e,t)=>{e.addEventListener("keyup",i=>{const n=i.target.value;F(n)||(e.value=n.replace(/[^0-9\.\-\+]/g,""),i.preventDefault()),I(s,i,t,t.getValue()),t.valid()})},Ge=(s,e,t)=>{e.addEventListener("change",i=>{I(s,i,t,t.getValue()),t.valid()})},I=(s,e,t,i)=>{t.changeEventCall(s,e,t,i)};class Je extends f{constructor(e,t,i){super(i,e,t),this.mounted(),this.setDefaultOption(),this.setDefaultInfo()}mounted(){Qe(this.field,this.element,this)}createField(){const e=this.field,t=this.rowElement.querySelector(".df-field-container");t.innerHTML=`
|
|
7
7
|
<div class="df-field">
|
|
8
8
|
<input type="text" name="${e.$xssName}" class="df-form-field df-number df-help-icon" />
|
|
9
9
|
</div>
|
|
10
10
|
${f.getDescriptionTemplate(e)}
|
|
11
11
|
<div class="df-help-message"></div>
|
|
12
|
-
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=de(this.getValue(),this.field);return $(this.field,this.rowElement,e),e}}const
|
|
12
|
+
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=de(this.getValue(),this.field);return $(this.field,this.rowElement,e),e}}const O=(s,e)=>{if(!e.$instance.isEnableView())return!0;let t={name:e.name,constraint:[]};if(e.required&&M(s))return t.constraint.push(y.REQUIRED),t;const i=xe(s,e,t);if(i!==!0)return i;const n=e.rule;if(n){const l=s.length,a=F(n.minLength),o=F(n.maxLength);let r=!1,d=!1;if(a&&l<n.minLength&&(r=!0),o&&l>n.maxLength&&(d=!0),a&&o&&(r||d)?t.constraint.push(y.BETWEEN):(r&&t.constraint.push(y.MIN_LENGTH),d&&t.constraint.push(y.MAX_LENGTH)),t.constraint.length>0)return t}return!0};class et extends f{constructor(e,t,i){super(i,e,t),this.mounted(),this.setDefaultOption(),this.setDefaultInfo()}mounted(){he(this.field,this.element,this)}createField(){var n;const e=this.field,t=this.rowElement.querySelector(".df-field-container");let i=(n=e.rendererOptions)==null?void 0:n.rows;i=+i>0?i:3,t.innerHTML=`
|
|
13
13
|
<div class="df-field">
|
|
14
14
|
<textarea name="${e.$xssName}" rows="${i}" class="df-form-field df-textarea df-help-icon"></textarea>
|
|
15
15
|
</div>
|
|
16
16
|
${f.getDescriptionTemplate(e)}
|
|
17
17
|
<div class="df-help-message"></div>
|
|
18
|
-
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=
|
|
18
|
+
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=O(this.getValue(),this.field);return $(this.field,this.rowElement,e),e}}class ue extends f{constructor(e,t,i){var o,r,d,h,u;super(i,e,t);let n="";v(e.defaultValue)||(n=e.defaultValue);const l=ue.valuesValueKey(e);let a=!1;(r=(o=this.field.listItem)==null?void 0:o.list)==null||r.forEach(c=>{let p=c[l];c.selected&&(this.defaultSelected=p),p==n&&(a=!0)}),a?this.defaultSelected=n:this.defaultSelected||((d=e.rendererOptions)==null?void 0:d.disableDefaultOption)===!0&&(this.defaultSelected=((u=(h=this.field.listItem)==null?void 0:h.list)==null?void 0:u.length)>0&&this.field.listItem.list[0][l]||""),v(this.defaultSelected)&&(this.defaultSelected=""),this.mounted(),this.setDefaultOption(),this.setValue(this.defaultSelected,!1)}mounted(){Ge(this.field,this.element,this)}createField(){const e=this.field,t=this.rowElement.querySelector(".df-field-container");let i=` <div class="df-field"><select name="${e.$xssName}" class="df-form-field df-dropdown">
|
|
19
19
|
${this.dropdownValuesTemplate(e)}
|
|
20
20
|
</select> <i class="df-help-icon"></i></div>
|
|
21
21
|
${f.getDescriptionTemplate(e)}
|
|
22
22
|
<div class="df-help-message"></div>
|
|
23
|
-
`;t.innerHTML=i,this.element=t.querySelector(`[name="${e.$xssName}"]`)}setValueItems(e){if(this.field.listItem?this.field.listItem.list=e:this.field.listItem={list:e},this.element.innerHTML=this.dropdownValuesTemplate(this.field),!M(this.field.$value)){const t=this.field.$value;this.field.$value="",this.setValue(t)}}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setValue(this.defaultSelected,!1),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=this.getValue();let t=!0;return this.field.required&&e.length<1&&(t={name:this.field.name,constraint:[]},t.constraint.push(y.REQUIRED)),$(this.field,this.rowElement,t),t}dropdownValuesTemplate(e){var
|
|
23
|
+
`;t.innerHTML=i,this.element=t.querySelector(`[name="${e.$xssName}"]`)}setValueItems(e){if(this.field.listItem?this.field.listItem.list=e:this.field.listItem={list:e},this.element.innerHTML=this.dropdownValuesTemplate(this.field),!M(this.field.$value)){const t=this.field.$value;this.field.$value="",this.setValue(t)}}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setValue(this.defaultSelected,!1),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=this.getValue();let t=!0;return this.field.required&&e.length<1&&(t={name:this.field.name,constraint:[]},t.constraint.push(y.REQUIRED)),$(this.field,this.rowElement,t),t}dropdownValuesTemplate(e){var l,a,o;const t=f.valuesLabelKey(e),i=f.valuesValueKey(e);let n="";return((l=e.rendererOptions)==null?void 0:l.disableDefaultOption)!==!0&&(n+=`<option value="">${N.getMessage("selection")}</option>`),(o=(a=e.listItem)==null?void 0:a.list)==null||o.forEach(r=>{const d=`${r.selected?"selected":""} ${r.disabled?"disabled":""}`;v(r[i])&&r.label?n+=`<option value="${r.value||""}" ${d}>${r.label}</option>`:n+=`<option value="${r[i]}" ${d}>${f.valuesLabelValue(t,r)}</option>`}),n}}class tt extends f{constructor(e,t,i){super(i,e,t),this.mounted(),this.setDefaultOption(),this.setDefaultInfo()}mounted(){he(this.field,this.element,this)}createField(){const e=this.field,t=this.rowElement.querySelector(".df-field-container");t.innerHTML=`
|
|
24
24
|
<div class="df-field">
|
|
25
25
|
<input type="text" name="${e.$xssName}" class="df-form-field df-text df-help-icon" />
|
|
26
26
|
</div>
|
|
27
27
|
${f.getDescriptionTemplate(e)}
|
|
28
28
|
<div class="df-help-message"></div>
|
|
29
|
-
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=
|
|
29
|
+
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=O(this.getValue(),this.field);return $(this.field,this.rowElement,e),e}}function q(s,e,t,i){var c,p,S,L,k,se,Oe,qe,Ae;const n={rowStyleClass:ce(e.orientation),fieldClass:"",fieldStyle:"",labelClass:"",labelStyle:"",labelAlignClass:"",valueClass:"",valueStyle:"",tabAlignClass:""},l=((c=t==null?void 0:t.style)==null?void 0:c.labelWidth)??s.style.labelWidth??"3";let a=((p=t==null?void 0:t.style)==null?void 0:p.valueWidth)??s.style.valueWidth??"9";const o=((S=t==null?void 0:t.style)==null?void 0:S.position)??s.style.position,r=(L=e.style)==null?void 0:L.width,d=D[(k=e.style)==null?void 0:k.position]??D[o]??D.top;n.fieldClass=`${d[0]?"df-"+d[0]:""} ${((se=e.style)==null?void 0:se.customClass)||""}`,r&&(F(r)?n.fieldClass+=F(r)?` df-col-xs-${r}`:"":n.fieldStyle=F(r)?"":`width:${r};`),n.tabAlignClass="df-tab-al-"+(["right","center"].includes((Oe=e.style)==null?void 0:Oe.tabAlign)?e.style.tabAlign:"left");const h=((qe=e.style)==null?void 0:qe.labelWidth)||l;if(n.labelAlignClass=d[1],!i&&h&&!["top","bottom"].includes(d[0]))if(F(h)){const Re=+h;a=12-Re,n.labelClass=`df-col-xs-${Re}`,n.valueClass=n.labelStyle?"df-col-full":`df-col-xs-${a}`}else n.labelStyle=`width:${h};`;const u=((Ae=e.style)==null?void 0:Ae.valueWidth)||a;return i&&!["left","right"].includes(d[0])?n.valueClass="df-col-full":u&&!["top","bottom"].includes(d[0])?F(u)?n.valueClass=n.labelStyle?"df-col-full":`df-col-xs-${u}`:n.valueStyle=`width:${u};`:n.valueClass=n.labelStyle?"df-col-full":"",n.fieldClass=fe(n.fieldClass),n.labelClass=fe(n.labelClass),n.valueClass=fe(n.valueClass),n}function ce(s){return s==="horizontal"?"df-horizontal":"df-vertical"}function fe(s){return s.replace(/\s+/g," ").trim()}class me extends f{constructor(e,t,i){var o,r;super(i,e,t),this.defaultCheckValue=[],this.defaultCheckValue=[];let n=[];v(e.defaultValue)||(x(e.defaultValue)?n=e.defaultValue:n=[e.defaultValue]);const l=me.valuesValueKey(e);v(this.field.listItem)&&this.setValueItems([{label:"",value:"Y"}]);let a=!1;(r=(o=this.field.listItem)==null?void 0:o.list)==null||r.forEach(d=>{let h=d[l];d.selected&&this.defaultCheckValue.push(h||!0),n.includes(h)&&(a=!0)}),this.defaultCheckValue=a?n:this.defaultCheckValue,this.mounted(),this.setDefaultOption(),this.setValue(this.defaultCheckValue,!1)}mounted(){this.initEvent()}initEvent(){this.rowElement.querySelectorAll(this.getSelector()).forEach(t=>{t.addEventListener("change",i=>{I(this.field,i,this,this.getValue()),this.valid()})})}getSelector(){return`input[type="checkbox"][name="${this.field.$xssName}"]`}createField(){var o,r;const e=this.field,t=this.rowElement.querySelector(".df-field-container"),i=[],n=e.$xssName,l=f.valuesLabelKey(e),a=f.valuesValueKey(e);i.push(' <div class="df-field"><div class="df-field-group">'),(r=(o=e.listItem)==null?void 0:o.list)==null||r.forEach(d=>{const h=d[a];i.push(`
|
|
30
30
|
<span class="df-field-item ${ce(e.listItem.orientation??Le.horizontal)}">
|
|
31
31
|
<label>
|
|
32
|
-
<input type="checkbox" name="${
|
|
33
|
-
${f.valuesLabelValue(
|
|
32
|
+
<input type="checkbox" name="${n}" value="${h?X(h):""}" class="df-form-field df-checkbox" ${d.selected?"checked":""} ${d.disabled?"disabled":""} />
|
|
33
|
+
${f.valuesLabelValue(l,d)}
|
|
34
34
|
</label>
|
|
35
35
|
</span>
|
|
36
|
-
`)}),i.push(`<i class="df-form-icon df-help-icon"></i></div></div> ${f.getDescriptionTemplate(e)}<div class="df-help-message"></div>`),t.innerHTML=i.join("")}setValueItems(e){if(this.rowElement.querySelector(".df-field-container")&&(this.field.listItem?this.field.listItem.list=e:this.field.listItem={list:e},this.createField(),!M(this.field.$value))){const i=this.field.$value;this.field.$value="",this.setValue(i)}}getValue(){const e=this.rowElement.querySelectorAll(this.getSelector());if(e.length>1){const t=[];return e.forEach(i=>{const
|
|
36
|
+
`)}),i.push(`<i class="df-form-icon df-help-icon"></i></div></div> ${f.getDescriptionTemplate(e)}<div class="df-help-message"></div>`),t.innerHTML=i.join("")}setValueItems(e){if(this.rowElement.querySelector(".df-field-container")&&(this.field.listItem?this.field.listItem.list=e:this.field.listItem={list:e},this.createField(),!M(this.field.$value))){const i=this.field.$value;this.field.$value="",this.setValue(i)}}getValue(){const e=this.rowElement.querySelectorAll(this.getSelector());if(e.length>1){const t=[];return e.forEach(i=>{const n=i;n.checked&&t.push(n.value)}),t}else{const t=this.rowElement.querySelector(`[name="${this.field.$xssName}"]`);return t!=null&&t.checked?t.value?t.value:!0:t.value?"":!1}}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1&&(e=this.field.$value),this.field.$value=e,e===!0){this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked=!0;return}if(e===!1){this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked=!1;return}let i=[];x(e)?i=e:i.push(e),this.rowElement.querySelectorAll(this.getSelector()).forEach(l=>{l.checked=!1}),i.forEach(l=>{const a=this.rowElement.querySelector(`[name="${this.field.$xssName}"][value="${l}"]`);a&&(a.checked=!0)})}reset(){var e,t;((t=(e=this.field.listItem)==null?void 0:e.list)==null?void 0:t.length)==1&&this.defaultCheckValue.length==1?this.setValue(!0,!1):this.setValue(this.defaultCheckValue,!1),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.rowElement.querySelectorAll(`[name="${this.field.$xssName}"]`)}focus(){const e=this.getElement();e&&e.length>0&&this.getElement()[0].focus()}valid(){const e=this.getValue();let t=!0;return this.field.required&&x(e)&&e.length<1&&(t={name:this.field.name,constraint:[]},t.constraint.push(y.REQUIRED)),$(this.field,this.rowElement,t),t}}class pe extends f{constructor(e,t,i){var o,r,d,h,u;super(i,e,t),this.defaultCheckValue="";let n=[];v(e.defaultValue)||(n=e.defaultValue);const l=pe.valuesValueKey(e);let a=!1;(r=(o=this.field.listItem)==null?void 0:o.list)==null||r.forEach(c=>{let p=c[l];c.selected&&(this.defaultCheckValue=p),n==p&&(a=!0)}),a?this.defaultCheckValue=n:this.defaultCheckValue||(this.defaultCheckValue=((h=(d=this.field.listItem)==null?void 0:d.list)==null?void 0:h.length)>0?(u=this.field.listItem)==null?void 0:u.list[0][l]:""),this.mounted(),this.setDefaultOption(),this.setValue(this.defaultCheckValue,!1)}mounted(){this.initEvent()}initEvent(){this.rowElement.querySelectorAll(this.getSelector()).forEach(t=>{t.addEventListener("change",i=>{I(this.field,i,this,this.getValue()),this.valid()})})}getSelector(){return`input[type="radio"][name="${this.field.$xssName}"]`}createField(){var o,r;const e=this.field,t=this.rowElement.querySelector(".df-field-container"),i=[],n=e.$xssName,l=f.valuesLabelKey(e),a=f.valuesValueKey(e);i.push('<div class="df-field"><div class="df-field-group">'),(r=(o=e.listItem)==null?void 0:o.list)==null||r.forEach(d=>{const h=d[a];i.push(`<span class="df-field-item ${ce(e.orientation??Le.horizontal)}">
|
|
37
37
|
<label>
|
|
38
|
-
<input type="radio" name="${
|
|
39
|
-
${f.valuesLabelValue(
|
|
38
|
+
<input type="radio" name="${n}" value="${h}" class="df-form-field df-radio" ${d.selected?"checked":""} ${d.disabled?"disabled":""}/>
|
|
39
|
+
${f.valuesLabelValue(l,d)}
|
|
40
40
|
</label>
|
|
41
41
|
</span>
|
|
42
42
|
`)}),i.push(`<i class="df-form-icon df-help-icon"></i></div></div>
|
|
43
43
|
${f.getDescriptionTemplate(e)}
|
|
44
44
|
<div class="df-help-message"></div>
|
|
45
|
-
`),t.innerHTML=i.join(""),this.initEvent()}setValueItems(e){if(this.rowElement.querySelector(".df-field-container")&&(this.field.listItem?this.field.listItem.list=e:this.field.listItem={list:e},this.createField(),!M(this.field.$value))){const i=this.field.$value;this.field.$value="",this.setValue(i)}}getValue(){var e;return(e=this.rowElement.querySelector(`[name="${this.field.$xssName}"]:checked`))==null?void 0:e.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1&&(e=this.field.$value),this.field.$value=e,e===!0){this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked=!0;return}if(e===!1){this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked=!1;return}this.rowElement.querySelectorAll(this.getSelector()).forEach(
|
|
45
|
+
`),t.innerHTML=i.join(""),this.initEvent()}setValueItems(e){if(this.rowElement.querySelector(".df-field-container")&&(this.field.listItem?this.field.listItem.list=e:this.field.listItem={list:e},this.createField(),!M(this.field.$value))){const i=this.field.$value;this.field.$value="",this.setValue(i)}}getValue(){var e;return(e=this.rowElement.querySelector(`[name="${this.field.$xssName}"]:checked`))==null?void 0:e.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1&&(e=this.field.$value),this.field.$value=e,e===!0){this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked=!0;return}if(e===!1){this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked=!1;return}this.rowElement.querySelectorAll(this.getSelector()).forEach(n=>{let l=n;l.value==e?l.checked=!0:l.checked=!1})}reset(){this.setValue(this.defaultCheckValue,!1),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.rowElement.querySelectorAll(this.getSelector())}focus(){const e=this.getElement();e&&e.length>0&&this.getElement()[0].focus()}valid(){const e=this.getValue();let t=!0;return this.field.required&&M(e)&&(t={name:this.field.name,constraint:[]},t.constraint.push(y.REQUIRED)),$(this.field,this.rowElement,t),t}}class it extends f{constructor(e,t,i){super(i,e,t),this.mounted(),this.setDefaultOption(),this.setDefaultInfo()}mounted(){he(this.field,this.element,this)}createField(){const e=this.field,t=this.rowElement.querySelector(".df-field-container");t.innerHTML=`
|
|
46
46
|
<div class="df-field">
|
|
47
47
|
<input type="password" name="${e.$xssName}" class="df-form-field df-password df-help-icon" autocomplete="off" />
|
|
48
48
|
</div>
|
|
49
49
|
${f.getDescriptionTemplate(e)}
|
|
50
50
|
<div class="df-help-message"></div>
|
|
51
|
-
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=
|
|
51
|
+
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=O(this.getValue(),this.field);return $(this.field,this.rowElement,e),e}}const st=(s,e,t)=>{const i={name:e.name,constraint:[]};return e.required&&t.length<1?(i.constraint.push(y.REQUIRED),i):i.constraint.length>0?i:!0};class nt extends f{constructor(e,t,i){var n;super(i,e,t),this.removeIds=[],this.uploadFiles={},this.fileList=[],this.fileSeq=0,this.element=t.querySelector(`[name="${e.$xssName}"]`),this.fileList=((n=e.listItem)==null?void 0:n.list)||[],this.mounted(),this.setDefaultOption()}mounted(){this.element.addEventListener("change",e=>{var i;const t=(i=e.target)==null?void 0:i.files;if(t){let n=[];for(let l of t)n.push(l);this.addFiles(n)}I(this.field,e,this,this.fileList),this.valid()}),this.fileList.forEach(e=>{e.$seq=this.fileSeq+=1}),this.setFileList(this.fileList)}createField(){const e=this.field,t=this.rowElement.querySelector(".df-field-container");t.innerHTML=`
|
|
52
52
|
<div class="df-field">
|
|
53
53
|
<span class="df-file-wrapper">
|
|
54
54
|
<label class="df-file-label">
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
${f.getDescriptionTemplate(e)}
|
|
62
62
|
<div class="df-file-list"></div>
|
|
63
63
|
<div class="df-help-message"></div>
|
|
64
|
-
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}addFiles(e){let t=!1;const i=[];for(let
|
|
65
|
-
<div class="df-file-item" data-seq="${
|
|
66
|
-
${
|
|
67
|
-
<span class="df-file-name">${
|
|
68
|
-
</div>`)}),i.insertAdjacentHTML("beforeend",
|
|
64
|
+
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}addFiles(e){let t=!1;const i=[];for(let n of e){if(this.fileList.filter(o=>o.fileName==n.name&&o.fileSize==n.size&&o.lastModified==n.lastModified).length>0)continue;this.fileSeq+=1,this.uploadFiles[this.fileSeq]=n;let a={fileName:n.name,$seq:this.fileSeq,fileSize:n.size,lastModified:n.lastModified};i.push(a),t=!0}t&&(this.setFileList(i),this.fileList.push(...i))}setFileList(e,t){const i=this.rowElement.querySelector(".df-file-list");if(i){t===!0&&(i.innerHTML="");const n=[];e.forEach(l=>{n.push(`
|
|
65
|
+
<div class="df-file-item" data-seq="${l.$seq}">
|
|
66
|
+
${l.fileId?'<span class="df-file-icon df-file-download"></span>':'<span class="df-file-icon df-empty-icon"></span>'} <span class="df-file-icon df-file-remove"></span>
|
|
67
|
+
<span class="df-file-name">${l.fileName}</span >
|
|
68
|
+
</div>`)}),i.insertAdjacentHTML("beforeend",n.join("")),e.forEach(l=>{this.removeFileEvent(l,i),this.downloadFileEvent(l,i)})}}downloadFileEvent(e,t){const i=t.querySelector(`[data-seq="${e.$seq}"] .df-file-download`);i&&i.addEventListener("click",n=>{const l=n.target.closest(".df-file-item");if(l){const a=l.getAttribute("data-seq");if(a){const o=parseInt(a,10),r=this.fileList.findIndex(h=>h.$seq===o),d=this.fileList[r];if(d.url){location.href=d.url;return}if(this.field.fileDownload){this.field.fileDownload.call(null,{file:d,field:this.field});return}}}})}removeFileEvent(e,t){const i=t.querySelector(`[data-seq="${e.$seq}"] .df-file-remove`);i&&i.addEventListener("click",n=>{const l=n.target.closest(".df-file-item");if(l){const a=l.getAttribute("data-seq");if(a){const o=parseInt(a,10),r=this.fileList.findIndex(h=>h.$seq===o),d=this.fileList[r];this.fileList.splice(r,1),delete this.uploadFiles[o],l.remove(),d.fileId&&this.removeIds.push(d.fileId)}}this.valid()})}getValue(){return{uploadFile:Object.values(this.uploadFiles),removeIds:this.removeIds}}setValueItems(e){this.fileList=[],this.uploadFiles=[],this.removeIds=[];for(let t of e)t.$seq=this.fileSeq+=1,this.fileList.push(t);this.setFileList(this.fileList,!0)}setValue(e){H(e)&&this.setValueItems(e),this.element.value=""}reset(){this.setValue(""),this.setValueItems([]),b(this.rowElement)}getElement(){return this.element}valid(){const e=st(this.element,this.field,this.fileList);return $(this.field,this.rowElement,e),e}}class lt extends f{constructor(e,t,i){super(i,e,t),e.renderer?(this.customFunction=e.renderer,this.mounted(),this.setDefaultOption(),this.setDefaultInfo()):this.customFunction={}}mounted(){this.customFunction.mounted&&this.customFunction.mounted.call(this,this.field,this.rowElement)}static isDataRender(){return!1}createField(){const e=this.field,t=C(e.template)?"":ae(e.template)?e.template:e.template(),i=this.rowElement.querySelector(".df-field-container");i.innerHTML=` <div class="df-field">
|
|
69
69
|
${t}
|
|
70
70
|
</div>
|
|
71
71
|
${f.getDescriptionTemplate(e)}
|
|
72
|
-
<div class="df-help-message"></div>`}getValue(){return this.customFunction.getValue?this.customFunction.getValue.call(this,this.field,this.rowElement):""}setValue(e,t){this.customFunction.setValue&&(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1&&(e=this.field.$value),this.customFunction.setValue.call(this,e,this.field,this.rowElement)),this.field.$value=e}reset(){this.setDefaultInfo(),b(this.rowElement)}getElement(){return this.customFunction.getElement?this.customFunction.getElement.call(this,this.field,this.rowElement):null}valid(){if(this.customFunction.valid){const t=this.customFunction.valid.call(this,this.field,this.rowElement);$(this.field,this.rowElement,t);return}const e=
|
|
72
|
+
<div class="df-help-message"></div>`}getValue(){return this.customFunction.getValue?this.customFunction.getValue.call(this,this.field,this.rowElement):""}setValue(e,t){this.customFunction.setValue&&(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1&&(e=this.field.$value),this.customFunction.setValue.call(this,e,this.field,this.rowElement)),this.field.$value=e}reset(){this.setDefaultInfo(),b(this.rowElement)}getElement(){return this.customFunction.getElement?this.customFunction.getElement.call(this,this.field,this.rowElement):null}valid(){if(this.customFunction.valid){const t=this.customFunction.valid.call(this,this.field,this.rowElement);$(this.field,this.rowElement,t);return}const e=O(this.getValue(),this.field);return $(this.field,this.rowElement,e),e}focus(){this.customFunction.focus&&this.customFunction.focus.call(this,this.field,this.rowElement)}}class at extends f{constructor(e,t,i){super(i,e,t)}mounted(){}static isDataRender(){return!1}createField(){return""}getValue(){return null}setValue(e){}reset(){}getElement(){return this.rowElement}valid(){return!0}addChildField(e){let t=this.rowElement.querySelector(".df-field-container");t?t.append(e):this.rowElement.append(e)}focus(){}}class rt extends f{constructor(e,t,i){super(i,e,t),this.field.$value=e.defaultValue}mounted(){}createField(){return""}getValue(){return this.field.$value}setValue(e){this.field.$value=e}reset(){this.setValue(this.field.defaultValue)}getElement(){}valid(){return!0}}class ot extends f{constructor(e,t,i){super(i,e,t),this.mounted(),this.setDefaultOption()}mounted(){var e;(e=this.rowElement.querySelector(`#${this.field.$key}`))==null||e.addEventListener("click",t=>{this.field.onClick&&this.field.onClick.call(null,this.field)})}static isDataRender(){return!1}createField(){const e=this.field,t=this.rowElement.querySelector(".df-field-container");t.innerHTML=`
|
|
73
73
|
<button type="button" id="${e.$key}" class="df-btn">${e.label}</button> ${f.getDescriptionTemplate(e)}
|
|
74
74
|
`}getValue(){return""}setValue(e){}reset(){this.setDisabled(!1)}getElement(){return null}valid(){return!0}}class dt extends f{constructor(e,t,i){super(i,e,t),this.rangeNumElement=t.querySelector(".df-range-num"),this.mounted(),this.setDefaultOption(),this.setDefaultInfo()}mounted(){this.element.addEventListener("input",e=>{this.rangeNumElement.innerHTML=e.target.value,this.element.setAttribute("title",e.target.value),I(this.field,e,this,this.getValue()),this.valid()})}createField(){const e=this.field,t=this.rowElement.querySelector(".df-field-container");t.innerHTML=`
|
|
75
75
|
<div class="df-field">
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
</div>
|
|
79
79
|
${f.getDescriptionTemplate(e)}
|
|
80
80
|
<div class="df-help-message"></div>
|
|
81
|
-
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=de(this.getValue(),this.field);return $(this.field,this.rowElement,e),e}}let K={year:"Year",month:"Month",day:"Day",am:"AM",pm:"PM",today:"Today",ok:"Ok",months:{full:["January","February","March","April","May","June","July","August","September","October","November","December"],abbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},weeks:{full:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}},ht=class{constructor(){this.lang=K}setDefaultMessage(e){K=Object.assign(K,e)}set(e){this.lang=Object.assign({},K,e)}getMessage(e){return this.lang[e]}getMonthsMessage(e,t="abbr"){return this.lang.months[t][e]||""}getWeeksMessage(e,t="abbr"){return this.lang.weeks[t][e]||""}getMonthsIdx(e,t="abbr"){return t=="full"?this.lang.months.full.indexOf(e):this.lang.months.abbr.indexOf(e)}getWeeksIdx(e,t="abbr"){return t=="full"?this.lang.weeks.full.indexOf(e):this.lang.weeks.abbr.indexOf(e)}};const g=new ht,Z=["YY","YYYY","MMMM","MMM","MM","M","dddd","ddd","dd","d","DD","D","S","HH","H","hh","h","mm","m","ss","s","SSS","zzzz","zzz","zz","z","a","A"];let Q=0,V={year:"YYYY",month:"YYYY-MM",date:"YYYY-MM-DD",time:"HH:mm",datetime:"YYYY-MM-DD HH:mm"};const T=["ddtp-sun","ddtp-mon","ddtp-tue","ddtp-wed","ddtp-thu","ddtp-fri","ddtp-sat"];var m=(s=>(s.year="year",s.month="month",s.date="date",s.datetime="datetime",s.time="time",s))(m||{});Z.forEach(s=>{Q=Math.max(s.length,Q)});const Ve=(s,e)=>{e=e||"YYYY-MM-DD";const t=e.length;let i=[];for(let l=0;l<t;){let a=Math.min(Q,t-l);for(;a>0;a--){const o=e.substring(l,l+a);if(Z.includes(o)){try{i.push(ut[o](s))}catch(r){console.log(Z.includes(o),o,r)}break}}a<1?(i.push(e.substring(l,l+1)),l+=1):l+=a}return i.join("")},ut={YY:s=>String(s.getFullYear()).slice(-2),YYYY:s=>String(s.getFullYear()),M:s=>String(s.getMonth()+1),MM:s=>w(s.getMonth()+1,2),MMM:s=>g.getMonthsMessage(s.getMonth()),MMMM:s=>g.getMonthsMessage(s.getMonth(),"full"),D:s=>String(s.getDate()),DD:s=>w(s.getDate(),2),d:s=>String(s.getDate()),dd:s=>w(s.getDate(),2),ddd:s=>g.getWeeksMessage(s.getDay()),dddd:s=>g.getWeeksMessage(s.getDay(),"full"),H:s=>String(s.getHours()),HH:s=>w(s.getHours(),2),h:s=>Se(s),hh:s=>w(Se(s),2),a:s=>String(s.getFullYear()).slice(-2),A:s=>ct(s),m:s=>String(s.getMinutes()),mm:s=>w(s.getMinutes(),2),s:s=>String(s.getSeconds()),ss:s=>w(s.getSeconds(),2),SSS:s=>w(s.getMilliseconds(),3)};function Se(s){let e=s.getHours();return e>12?e-=12:e<1&&(e=12),e}function ct(s,e,t){let l=s.getHours()<12?"am":"pm";return l=g.getMessage(l),l=l.toUpperCase(),l}const z=(s,e)=>{if(s.length>1e3)return null;e=e||V.date;const t={year:new Date().getFullYear(),month:0,day:1,hour:0,minute:0,second:0,millisecond:0,isPm:!1,isH:!1,charIdx:0},i=e.length;let l=0;for(let a=0;a<i;){let r=Math.min(Q,i-a);for(;r>0;r--){const d=e.substring(a,a+r);if(Z.includes(d)){const h=mt[d],u=ft(s.substring(l),h[0]);h[1](t,u),l+=u.length;break}}r<1?(a+=1,l+=1):a+=r}t.hour!=null&&!t.isH&&(t.isPm&&+t.hour!=12?t.hour=+t.hour+12:!t.isPm&&+t.hour==12&&(t.hour=0));let n;return n=new Date(t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond),n},ft=(s,e)=>{const t=e.exec(s);return t==null?"":t[0]},E={twoOptional:/\d\d?/,two:/\d\d/,three:/\d{3}/,four:/\d{4}/},A=/[^\s]+/,mt={YY:[E.two,(s,e)=>(s.year=+((""+new Date().getFullYear()).substring(0,2)+e),s)],YYYY:[E.four,(s,e)=>(s.year=+e,s)],M:[E.twoOptional,(s,e)=>(s.month=+e-1,s)],MM:[E.two,(s,e)=>(s.month=+e-1,s)],MMM:[A,(s,e)=>(s.month=g.getMonthsIdx(e,"abbr"),s)],MMMM:[A,(s,e)=>(s.month=g.getMonthsIdx(e,"full"),s)],D:[E.twoOptional,(s,e)=>(s.day=+e,s)],DD:[E.two,(s,e)=>(s.day=+e,s)],d:[E.twoOptional,(s,e)=>(s.day=+e,s)],dd:[E.two,(s,e)=>(s.day=+e,s)],ddd:[A,(s,e)=>s],dddd:[A,(s,e)=>s],H:[E.twoOptional,(s,e)=>(s.hour=+e,s.isH=!0,s)],HH:[E.two,(s,e)=>(s.hour=+e,s.isH=!0,s)],h:[E.twoOptional,(s,e)=>(s.hour=+e,s)],hh:[E.two,(s,e)=>(s.hour=+e,s)],a:[A,(s,e)=>(g.getMessage("am")!=e.toLowerCase()&&(s.isPm=!0),s)],A:[A,(s,e)=>(g.getMessage("am")!=e.toLowerCase()&&(s.isPm=!0),s)],m:[E.twoOptional,(s,e)=>(s.minute=+e,s)],mm:[E.two,(s,e)=>(s.minute=+e,s)],s:[E.twoOptional,(s,e)=>(s.second=+e,s)],ss:[E.two,(s,e)=>(s.second=+e,s)],SSS:[E.three,(s,e)=>(s.millisecond=+e,s)]};function pt(s,e){let t=s;for(;t;){if(t==e)return!0;t=t.parentElement}return!1}class R{constructor(e){this.date=e}setYear(e){return this.date.setFullYear(e),this}addYear(e){return this.date.setFullYear(this.date.getFullYear()+e),this}addMonth(e){return this.date.setMonth(this.date.getMonth()+e),this}setMonth(e){return this.date.setMonth(e),this}setDate(e){return this.date.setDate(e),this}addDate(e){return this.date.setDate(this.date.getDate()+e),this}addWeek(e){return this.date.setDate(this.date.getDate()+e*7),this}addHours(e){return this.date.setHours(this.date.getHours()+e),this}setHour(e){return this.date.setHours(e),this}addMinutes(e){return this.date.setMinutes(this.date.getMinutes()+e),this}setMinutes(e){return this.date.setMinutes(e),this}addSeconds(e){return this.date.setSeconds(this.date.getSeconds()+e),this}addMilliseconds(e){return this.date.setMilliseconds(this.date.getMilliseconds()+e),this}compare(e){return this.date.valueOf()<e.valueOf()?-1:this.date.valueOf()>e.valueOf()?1:0}getYear(){return this.date.getFullYear()}getMonth(){return this.date.getMonth()+1}getDate(){return this.date.getDate()}getDay(){return this.date.getDay()}getTime(){return this.date.getTime()}format(e){return Ve(this.date,e)}clone(){return new R(new Date(this.date.valueOf()))}}let ge={inline:!1,weekStartDay:0,initialDate:"",autoClose:!0,isRTL:!1,mode:m.date,enableTodayBtn:!1,showMonthAfterYear:!1,isPositionFixed:!1,format:"",zIndex:1e3,minDate:"",maxDate:"",beforeDrawDate:s=>({check:!1,style:"",tooltip:""})};function gt(){var s;return document.getElementById("hiddenDaraDatetimeElement")==null&&((s=document.querySelector("body"))==null||s.insertAdjacentHTML("beforeend",'<div id="hiddenDaraDatetimeElement" class="daracl-datetime-hidden"></div>')),document.getElementById("hiddenDaraDatetimeElement")}let ve=0;const G=class Ye{constructor(e,t,i){var l;this.isInput=!1,this.isVisible=!1,this.minYear=-1,this.maxYear=-1,this.minMonth=-1,this.maxMonth=-1,this.dayOrder=[0,1,2,3,4,5,6],this._documentClickEvent=o=>{this.isVisible&&o.target!=this.targetElement&&!pt(o.target,this.datetimeElement)&&this.hide()},this.options=Object.assign({},ge,t),ve+=1;let n;if(typeof e=="string"?n=document.querySelector(e):n=e,!n)throw new Error(`${e} datetimepicker element not found`);this._viewMode=Object.keys(m).includes(this.options.mode)?this.options.mode:m.date,this.initMode=this._viewMode,g.set(i),this.initMode==m.year?this.dateFormat=this.options.format||V.year:this.initMode==m.month?this.dateFormat=this.options.format||V.month:this.initMode==m.time?this.dateFormat=this.options.format||V.time:this.initMode==m.datetime?this.dateFormat=this.options.format||V.datetime:this.dateFormat=this.options.format||V.date;let a;if(this.options.initialDate?typeof this.options.initialDate=="string"?a=new R(z(this.options.initialDate,this.dateFormat)||new Date):a=new R(this.options.initialDate):(a=new R(new Date),this.options.initialDate=a.format(this.dateFormat)),this.setWeekDays(),this.todayDate=a.format(V.date),this.currentDate=a,this.targetElement=n,this.minDate=this._minDate(),this.maxDate=this._maxDate(),this.options.inline)this.datetimeElement=n,this.datetimeElement.className=`daracl-datetime-wrapper ddtp-${ve} embed`;else{this.isInput=!0,this.targetElement.setAttribute("value",a.format(this.dateFormat));const o=document.createElement("div");o.className=`daracl-datetime-wrapper ddtp-${ve} layer`,o.setAttribute("style",`z-index:${this.options.zIndex};`),(l=gt())==null||l.appendChild(o),this.datetimeElement=o,this.initTargetEvent()}this.createDatetimeTemplate(),this.isTimeMode()?(this.hourInputEle=this.datetimeElement.querySelector(".ddtp-hour"),this.minuteInputEle=this.datetimeElement.querySelector(".ddtp-minute")):(this.hourInputEle={},this.minuteInputEle={}),this.changeViewMode(this._viewMode),this.initHeaderEvent(),this.initDateEvent(),this.initTimeEvent()}setWeekDays(){let e=this.options.weekStartDay;if(e!=0){(e<0||e>6)&&(e=0);for(let t=0;t<7;t++){let i=e+t;this.dayOrder[t]=i<7?i:i-7}}}static create(e,t,i){return new Ye(e,t,i)}static setDefaultFormat(e){Object.assign(V,e)}_minDate(){let e=this.options.minDate;if(e!=""){if(typeof e=="string"){const t=z(e,this.dateFormat);if(!t)return-1;e=t}return this.minYear=e.getFullYear(),this.minMonth=+(this.minYear+w(e.getMonth(),2)),new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0).getTime()}return-1}_maxDate(){let e=this.options.maxDate;if(e!=""){if(typeof e=="string"){const t=z(e,this.dateFormat);if(!t)return-1;e=t}return this.maxYear=e.getFullYear(),this.maxMonth=+(this.maxYear+w(e.getMonth(),2)),new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59).getTime()}return-1}set viewMode(e){this._viewMode!==e&&(this._viewMode=e,this.changeViewMode(e))}get viewMode(){return this._viewMode}changeViewMode(e){var t;(t=this.datetimeElement.querySelector(".ddtp-datetime"))==null||t.setAttribute("view-mode",e),e==="year"?this.yearDraw():e==="month"?this.monthDraw():this.dayDraw()}initHeaderEvent(){var e,t,i,l;const n=this.options.isRTL;(e=this.datetimeElement.querySelector(".ddtp-move-btn.prev"))==null||e.addEventListener("click",a=>{this.moveDate(n?"next":"prev",a)}),(t=this.datetimeElement.querySelector(".ddtp-move-btn.next"))==null||t.addEventListener("click",a=>{this.moveDate(n?"prev":"next",a)}),(i=this.datetimeElement.querySelector(".ddtp-header-year"))==null||i.addEventListener("click",a=>{this.viewMode=m.year}),(l=this.datetimeElement.querySelector(".ddtp-header-month"))==null||l.addEventListener("click",a=>{this.viewMode=m.month})}initDateEvent(){var e,t;(e=this.datetimeElement.querySelector(".ddtp-day-body"))==null||e.addEventListener("click",i=>{var l;const n=i.target;if(n.classList.contains("ddtp-day")||n.closest(".ddtp-day")){const o=(n.getAttribute("data-day")||"1").split(",");if(this.currentDate.setMonth(+o[0]-1),this.currentDate.setDate(+o[1]),this.isDayDisabled(this.currentDate))return;(l=this.datetimeElement.querySelector(".select"))==null||l.classList.remove("select"),n.classList.add("select"),this.isTimeMode()&&(this.currentDate.setHour(+this.hourInputEle.value),this.currentDate.setMinutes(+this.minuteInputEle.value)),this.dateChangeEvent(i)}}),(t=this.datetimeElement.querySelector(".ddtp-today"))==null||t.addEventListener("click",i=>{const l=new R(z(this.todayDate,V.date)||new Date);this.currentDate.setYear(l.getYear()),this.currentDate.setMonth(l.getMonth()-1),this.currentDate.setDate(l.getDate()),this.changeViewMode(this.initMode)})}isTimeMode(){return this._viewMode===m.time||this._viewMode===m.datetime}getTimeNumberValue(e){return je(e)?parseInt(e,10):0}initTimeEvent(){var e;if(!this.isTimeMode())return;let t=this.currentDate.format("HH");const i=this.datetimeElement,l=i.querySelector(".ddtp-hour"),n=i.querySelector(".ddtp-hour-range");l.value=t,n.value=t,l.addEventListener("input",d=>{const h=d.target;let u=this.getTimeNumberValue(h.value),c=B(u,2,"0");parseInt(c,10)>23&&(c="23"),l.value=c,n.value=c}),n.addEventListener("input",d=>{const h=d.target;l.value=B(h.value,2,"0")});let a=this.currentDate.format("mm");const o=i.querySelector(".ddtp-minute"),r=i.querySelector(".ddtp-minute-range");o.value=a,r.value=a,o.addEventListener("input",d=>{const h=d.target;let u=this.getTimeNumberValue(h.value),c=B(u,2,"0");parseInt(c,10)>59&&(c="59"),o.value=c,r.value=c}),r.addEventListener("input",d=>{const h=d.target;o.value=B(h.value,2,"0")}),(e=i.querySelector(".time-select"))==null||e.addEventListener("click",d=>{this.currentDate.setHour(+l.value),this.currentDate.setMinutes(+o.value),this.dateChangeEvent(d)})}moveDate(e,t){if(this._viewMode===m.date||this._viewMode===m.datetime){this.currentDate.setDate(1),this.currentDate.addMonth(e==="prev"?-1:1),this.dayDraw();return}if(this._viewMode===m.month){this.currentDate.setDate(1),this.currentDate.addYear(e==="prev"?-1:1),this.monthDraw();return}this._viewMode===m.year&&(this.currentDate.setDate(1),this.currentDate.addYear(e==="prev"?-16:16),this.yearDraw())}getDateValue(){return this.currentDate.format(this.dateFormat)}static setOptions(e){ge=Object.assign({},ge,e)}show(){if(this.isVisible)return;this.isVisible=!0;const e=yt();this.datetimeElement.classList.remove("hide"),this.datetimeElement.classList.add("show");const t=this.targetElement.getBoundingClientRect(),i=window.scrollY||document.documentElement.scrollTop,l=window.scrollX||document.documentElement.scrollLeft,n=this.datetimeElement.offsetHeight,a=this.targetElement.offsetHeight+2;let o=t.left+l,r=0;this.options.isPositionFixed?(r=t.top+a,o=t.left):t.top+a+n>e.clientHeight&&t.top>=n?r=i+t.top-n-2:r=i+t.top+a,this.datetimeElement.setAttribute("style",`${this.options.isPositionFixed?"position:fixed;":""}top:${r}px;left:${o}px;z-index:${this.options.zIndex}`),document.addEventListener("click",this._documentClickEvent)}hide(){this.isVisible=!1,!(this.options.onClose&&this.options.onClose()===!1)&&(this.datetimeElement.classList.remove("show"),this.datetimeElement.classList.add("hide"),document.removeEventListener("click",this._documentClickEvent))}initTargetEvent(){this.targetElement&&this.targetElement.addEventListener("click",e=>{this.show()})}afterChangeDatepicker(){const e=this.currentDate.format(this.dateFormat);this.options.afterChangeDatepicker&&H(this.options.afterChangeDatepicker)&&this.options.afterChangeDatepicker(e,this.viewMode)}beforeChangeDatepicker(){const e=this.currentDate.format(this.dateFormat);if(this.options.beforeChangeDatepicker&&H(this.options.beforeChangeDatepicker)){if(this.options.beforeChangeDatepicker(e,i=>{i!==!1&&this.refresh(!1)})===!1)return;this.refresh(!1);return}this.refresh(!1)}dateChangeEvent(e){const t=this.currentDate.format(this.dateFormat);this.options.onSelect&&this.options.onSelect(t,this.viewMode,e)===!1||(this.isInput&&this.targetElement.setAttribute("value",t),!this.options.inline&&this.options.autoClose&&this.hide())}createDatetimeTemplate(){const e=this.options.showMonthAfterYear;let t=`<div class="ddtp-datetime ${this.options.isRTL?"rtl":""}" view-mode="${this._viewMode}">
|
|
81
|
+
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=de(this.getValue(),this.field);return $(this.field,this.rowElement,e),e}}let K={year:"Year",month:"Month",day:"Day",am:"AM",pm:"PM",today:"Today",ok:"Ok",months:{full:["January","February","March","April","May","June","July","August","September","October","November","December"],abbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},weeks:{full:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}},ht=class{constructor(){this.lang=K}setDefaultMessage(e){K=Object.assign(K,e)}set(e){this.lang=Object.assign({},K,e)}getMessage(e){return this.lang[e]}getMonthsMessage(e,t="abbr"){return this.lang.months[t][e]||""}getWeeksMessage(e,t="abbr"){return this.lang.weeks[t][e]||""}getMonthsIdx(e,t="abbr"){return t=="full"?this.lang.months.full.indexOf(e):this.lang.months.abbr.indexOf(e)}getWeeksIdx(e,t="abbr"){return t=="full"?this.lang.weeks.full.indexOf(e):this.lang.weeks.abbr.indexOf(e)}};const g=new ht,Z=["YY","YYYY","MMMM","MMM","MM","M","dddd","ddd","dd","d","DD","D","S","HH","H","hh","h","mm","m","ss","s","SSS","zzzz","zzz","zz","z","a","A"];let Q=0,V={year:"YYYY",month:"YYYY-MM",date:"YYYY-MM-DD",time:"HH:mm",datetime:"YYYY-MM-DD HH:mm"};const T=["ddtp-sun","ddtp-mon","ddtp-tue","ddtp-wed","ddtp-thu","ddtp-fri","ddtp-sat"];var m=(s=>(s.year="year",s.month="month",s.date="date",s.datetime="datetime",s.time="time",s))(m||{});Z.forEach(s=>{Q=Math.max(s.length,Q)});const Ve=(s,e)=>{e=e||"YYYY-MM-DD";const t=e.length;let i=[];for(let n=0;n<t;){let a=Math.min(Q,t-n);for(;a>0;a--){const o=e.substring(n,n+a);if(Z.includes(o)){try{i.push(ut[o](s))}catch(r){console.log(Z.includes(o),o,r)}break}}a<1?(i.push(e.substring(n,n+1)),n+=1):n+=a}return i.join("")},ut={YY:s=>String(s.getFullYear()).slice(-2),YYYY:s=>String(s.getFullYear()),M:s=>String(s.getMonth()+1),MM:s=>w(s.getMonth()+1,2),MMM:s=>g.getMonthsMessage(s.getMonth()),MMMM:s=>g.getMonthsMessage(s.getMonth(),"full"),D:s=>String(s.getDate()),DD:s=>w(s.getDate(),2),d:s=>String(s.getDate()),dd:s=>w(s.getDate(),2),ddd:s=>g.getWeeksMessage(s.getDay()),dddd:s=>g.getWeeksMessage(s.getDay(),"full"),H:s=>String(s.getHours()),HH:s=>w(s.getHours(),2),h:s=>Se(s),hh:s=>w(Se(s),2),a:s=>String(s.getFullYear()).slice(-2),A:s=>ct(s),m:s=>String(s.getMinutes()),mm:s=>w(s.getMinutes(),2),s:s=>String(s.getSeconds()),ss:s=>w(s.getSeconds(),2),SSS:s=>w(s.getMilliseconds(),3)};function Se(s){let e=s.getHours();return e>12?e-=12:e<1&&(e=12),e}function ct(s,e,t){let n=s.getHours()<12?"am":"pm";return n=g.getMessage(n),n=n.toUpperCase(),n}const z=(s,e)=>{if(s.length>1e3)return null;e=e||V.date;const t={year:new Date().getFullYear(),month:0,day:1,hour:0,minute:0,second:0,millisecond:0,isPm:!1,isH:!1,charIdx:0},i=e.length;let n=0;for(let a=0;a<i;){let r=Math.min(Q,i-a);for(;r>0;r--){const d=e.substring(a,a+r);if(Z.includes(d)){const h=mt[d],u=ft(s.substring(n),h[0]);h[1](t,u),n+=u.length;break}}r<1?(a+=1,n+=1):a+=r}t.hour!=null&&!t.isH&&(t.isPm&&+t.hour!=12?t.hour=+t.hour+12:!t.isPm&&+t.hour==12&&(t.hour=0));let l;return l=new Date(t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond),l},ft=(s,e)=>{const t=e.exec(s);return t==null?"":t[0]},E={twoOptional:/\d\d?/,two:/\d\d/,three:/\d{3}/,four:/\d{4}/},A=/[^\s]+/,mt={YY:[E.two,(s,e)=>(s.year=+((""+new Date().getFullYear()).substring(0,2)+e),s)],YYYY:[E.four,(s,e)=>(s.year=+e,s)],M:[E.twoOptional,(s,e)=>(s.month=+e-1,s)],MM:[E.two,(s,e)=>(s.month=+e-1,s)],MMM:[A,(s,e)=>(s.month=g.getMonthsIdx(e,"abbr"),s)],MMMM:[A,(s,e)=>(s.month=g.getMonthsIdx(e,"full"),s)],D:[E.twoOptional,(s,e)=>(s.day=+e,s)],DD:[E.two,(s,e)=>(s.day=+e,s)],d:[E.twoOptional,(s,e)=>(s.day=+e,s)],dd:[E.two,(s,e)=>(s.day=+e,s)],ddd:[A,(s,e)=>s],dddd:[A,(s,e)=>s],H:[E.twoOptional,(s,e)=>(s.hour=+e,s.isH=!0,s)],HH:[E.two,(s,e)=>(s.hour=+e,s.isH=!0,s)],h:[E.twoOptional,(s,e)=>(s.hour=+e,s)],hh:[E.two,(s,e)=>(s.hour=+e,s)],a:[A,(s,e)=>(g.getMessage("am")!=e.toLowerCase()&&(s.isPm=!0),s)],A:[A,(s,e)=>(g.getMessage("am")!=e.toLowerCase()&&(s.isPm=!0),s)],m:[E.twoOptional,(s,e)=>(s.minute=+e,s)],mm:[E.two,(s,e)=>(s.minute=+e,s)],s:[E.twoOptional,(s,e)=>(s.second=+e,s)],ss:[E.two,(s,e)=>(s.second=+e,s)],SSS:[E.three,(s,e)=>(s.millisecond=+e,s)]};function pt(s,e){let t=s;for(;t;){if(t==e)return!0;t=t.parentElement}return!1}class R{constructor(e){this.date=e}setYear(e){return this.date.setFullYear(e),this}addYear(e){return this.date.setFullYear(this.date.getFullYear()+e),this}addMonth(e){return this.date.setMonth(this.date.getMonth()+e),this}setMonth(e){return this.date.setMonth(e),this}setDate(e){return this.date.setDate(e),this}addDate(e){return this.date.setDate(this.date.getDate()+e),this}addWeek(e){return this.date.setDate(this.date.getDate()+e*7),this}addHours(e){return this.date.setHours(this.date.getHours()+e),this}setHour(e){return this.date.setHours(e),this}addMinutes(e){return this.date.setMinutes(this.date.getMinutes()+e),this}setMinutes(e){return this.date.setMinutes(e),this}addSeconds(e){return this.date.setSeconds(this.date.getSeconds()+e),this}addMilliseconds(e){return this.date.setMilliseconds(this.date.getMilliseconds()+e),this}compare(e){return this.date.valueOf()<e.valueOf()?-1:this.date.valueOf()>e.valueOf()?1:0}getYear(){return this.date.getFullYear()}getMonth(){return this.date.getMonth()+1}getDate(){return this.date.getDate()}getDay(){return this.date.getDay()}getTime(){return this.date.getTime()}format(e){return Ve(this.date,e)}clone(){return new R(new Date(this.date.valueOf()))}}let ge={inline:!1,weekStartDay:0,initialDate:"",autoClose:!0,isRTL:!1,mode:m.date,enableTodayBtn:!1,showMonthAfterYear:!1,isPositionFixed:!1,format:"",zIndex:1e3,minDate:"",maxDate:"",beforeDrawDate:s=>({check:!1,style:"",tooltip:""})};function gt(){var s;return document.getElementById("hiddenDaraDatetimeElement")==null&&((s=document.querySelector("body"))==null||s.insertAdjacentHTML("beforeend",'<div id="hiddenDaraDatetimeElement" class="daracl-datetime-hidden"></div>')),document.getElementById("hiddenDaraDatetimeElement")}let ve=0;const G=class He{constructor(e,t,i){var n;this.isInput=!1,this.isVisible=!1,this.minYear=-1,this.maxYear=-1,this.minMonth=-1,this.maxMonth=-1,this.dayOrder=[0,1,2,3,4,5,6],this._documentClickEvent=o=>{this.isVisible&&o.target!=this.targetElement&&!pt(o.target,this.datetimeElement)&&this.hide()},this.options=Object.assign({},ge,t),ve+=1;let l;if(typeof e=="string"?l=document.querySelector(e):l=e,!l)throw new Error(`${e} datetimepicker element not found`);this._viewMode=Object.keys(m).includes(this.options.mode)?this.options.mode:m.date,this.initMode=this._viewMode,g.set(i),this.initMode==m.year?this.dateFormat=this.options.format||V.year:this.initMode==m.month?this.dateFormat=this.options.format||V.month:this.initMode==m.time?this.dateFormat=this.options.format||V.time:this.initMode==m.datetime?this.dateFormat=this.options.format||V.datetime:this.dateFormat=this.options.format||V.date;let a;if(this.options.initialDate?typeof this.options.initialDate=="string"?a=new R(z(this.options.initialDate,this.dateFormat)||new Date):a=new R(this.options.initialDate):(a=new R(new Date),this.options.initialDate=a.format(this.dateFormat)),this.setWeekDays(),this.todayDate=a.format(V.date),this.currentDate=a,this.targetElement=l,this.minDate=this._minDate(),this.maxDate=this._maxDate(),this.options.inline)this.datetimeElement=l,this.datetimeElement.className=`daracl-datetime-wrapper ddtp-${ve} embed`;else{this.isInput=!0,this.targetElement.setAttribute("value",a.format(this.dateFormat));const o=document.createElement("div");o.className=`daracl-datetime-wrapper ddtp-${ve} layer`,o.setAttribute("style",`z-index:${this.options.zIndex};`),(n=gt())==null||n.appendChild(o),this.datetimeElement=o,this.initTargetEvent()}this.createDatetimeTemplate(),this.isTimeMode()?(this.hourInputEle=this.datetimeElement.querySelector(".ddtp-hour"),this.minuteInputEle=this.datetimeElement.querySelector(".ddtp-minute")):(this.hourInputEle={},this.minuteInputEle={}),this.changeViewMode(this._viewMode),this.initHeaderEvent(),this.initDateEvent(),this.initTimeEvent()}setWeekDays(){let e=this.options.weekStartDay;if(e!=0){(e<0||e>6)&&(e=0);for(let t=0;t<7;t++){let i=e+t;this.dayOrder[t]=i<7?i:i-7}}}static create(e,t,i){return new He(e,t,i)}static setDefaultFormat(e){Object.assign(V,e)}_minDate(){let e=this.options.minDate;if(e!=""){if(typeof e=="string"){const t=z(e,this.dateFormat);if(!t)return-1;e=t}return this.minYear=e.getFullYear(),this.minMonth=+(this.minYear+w(e.getMonth(),2)),new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0).getTime()}return-1}_maxDate(){let e=this.options.maxDate;if(e!=""){if(typeof e=="string"){const t=z(e,this.dateFormat);if(!t)return-1;e=t}return this.maxYear=e.getFullYear(),this.maxMonth=+(this.maxYear+w(e.getMonth(),2)),new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59).getTime()}return-1}set viewMode(e){this._viewMode!==e&&(this._viewMode=e,this.changeViewMode(e))}get viewMode(){return this._viewMode}changeViewMode(e){var t;(t=this.datetimeElement.querySelector(".ddtp-datetime"))==null||t.setAttribute("view-mode",e),e==="year"?this.yearDraw():e==="month"?this.monthDraw():this.dayDraw()}initHeaderEvent(){var e,t,i,n;const l=this.options.isRTL;(e=this.datetimeElement.querySelector(".ddtp-move-btn.prev"))==null||e.addEventListener("click",a=>{this.moveDate(l?"next":"prev",a)}),(t=this.datetimeElement.querySelector(".ddtp-move-btn.next"))==null||t.addEventListener("click",a=>{this.moveDate(l?"prev":"next",a)}),(i=this.datetimeElement.querySelector(".ddtp-header-year"))==null||i.addEventListener("click",a=>{this.viewMode=m.year}),(n=this.datetimeElement.querySelector(".ddtp-header-month"))==null||n.addEventListener("click",a=>{this.viewMode=m.month})}initDateEvent(){var e,t;(e=this.datetimeElement.querySelector(".ddtp-day-body"))==null||e.addEventListener("click",i=>{var n;const l=i.target;if(l.classList.contains("ddtp-day")||l.closest(".ddtp-day")){const o=(l.getAttribute("data-day")||"1").split(",");if(this.currentDate.setMonth(+o[0]-1),this.currentDate.setDate(+o[1]),this.isDayDisabled(this.currentDate))return;(n=this.datetimeElement.querySelector(".select"))==null||n.classList.remove("select"),l.classList.add("select"),this.isTimeMode()&&(this.currentDate.setHour(+this.hourInputEle.value),this.currentDate.setMinutes(+this.minuteInputEle.value)),this.dateChangeEvent(i)}}),(t=this.datetimeElement.querySelector(".ddtp-today"))==null||t.addEventListener("click",i=>{const n=new R(z(this.todayDate,V.date)||new Date);this.currentDate.setYear(n.getYear()),this.currentDate.setMonth(n.getMonth()-1),this.currentDate.setDate(n.getDate()),this.changeViewMode(this.initMode)})}isTimeMode(){return this._viewMode===m.time||this._viewMode===m.datetime}getTimeNumberValue(e){return je(e)?parseInt(e,10):0}initTimeEvent(){var e;if(!this.isTimeMode())return;let t=this.currentDate.format("HH");const i=this.datetimeElement,n=i.querySelector(".ddtp-hour"),l=i.querySelector(".ddtp-hour-range");n.value=t,l.value=t,n.addEventListener("input",d=>{const h=d.target;let u=this.getTimeNumberValue(h.value),c=B(u,2,"0");parseInt(c,10)>23&&(c="23"),n.value=c,l.value=c}),l.addEventListener("input",d=>{const h=d.target;n.value=B(h.value,2,"0")});let a=this.currentDate.format("mm");const o=i.querySelector(".ddtp-minute"),r=i.querySelector(".ddtp-minute-range");o.value=a,r.value=a,o.addEventListener("input",d=>{const h=d.target;let u=this.getTimeNumberValue(h.value),c=B(u,2,"0");parseInt(c,10)>59&&(c="59"),o.value=c,r.value=c}),r.addEventListener("input",d=>{const h=d.target;o.value=B(h.value,2,"0")}),(e=i.querySelector(".time-select"))==null||e.addEventListener("click",d=>{this.currentDate.setHour(+n.value),this.currentDate.setMinutes(+o.value),this.dateChangeEvent(d)})}moveDate(e,t){if(this._viewMode===m.date||this._viewMode===m.datetime){this.currentDate.setDate(1),this.currentDate.addMonth(e==="prev"?-1:1),this.dayDraw();return}if(this._viewMode===m.month){this.currentDate.setDate(1),this.currentDate.addYear(e==="prev"?-1:1),this.monthDraw();return}this._viewMode===m.year&&(this.currentDate.setDate(1),this.currentDate.addYear(e==="prev"?-16:16),this.yearDraw())}getDateValue(){return this.currentDate.format(this.dateFormat)}static setOptions(e){ge=Object.assign({},ge,e)}show(){if(this.isVisible)return;this.isVisible=!0;const e=yt();this.datetimeElement.classList.remove("hide"),this.datetimeElement.classList.add("show");const t=this.targetElement.getBoundingClientRect(),i=window.scrollY||document.documentElement.scrollTop,n=window.scrollX||document.documentElement.scrollLeft,l=this.datetimeElement.offsetHeight,a=this.targetElement.offsetHeight+2;let o=t.left+n,r=0;this.options.isPositionFixed?(r=t.top+a,o=t.left):t.top+a+l>e.clientHeight&&t.top>=l?r=i+t.top-l-2:r=i+t.top+a,this.datetimeElement.setAttribute("style",`${this.options.isPositionFixed?"position:fixed;":""}top:${r}px;left:${o}px;z-index:${this.options.zIndex}`),document.addEventListener("click",this._documentClickEvent)}hide(){this.isVisible=!1,!(this.options.onClose&&this.options.onClose()===!1)&&(this.datetimeElement.classList.remove("show"),this.datetimeElement.classList.add("hide"),document.removeEventListener("click",this._documentClickEvent))}initTargetEvent(){this.targetElement&&this.targetElement.addEventListener("click",e=>{this.show()})}afterChangeDatepicker(){const e=this.currentDate.format(this.dateFormat);this.options.afterChangeDatepicker&&Y(this.options.afterChangeDatepicker)&&this.options.afterChangeDatepicker(e,this.viewMode)}beforeChangeDatepicker(){const e=this.currentDate.format(this.dateFormat);if(this.options.beforeChangeDatepicker&&Y(this.options.beforeChangeDatepicker)){if(this.options.beforeChangeDatepicker(e,i=>{i!==!1&&this.refresh(!1)})===!1)return;this.refresh(!1);return}this.refresh(!1)}dateChangeEvent(e){const t=this.currentDate.format(this.dateFormat);this.options.onSelect&&this.options.onSelect(t,this.viewMode,e)===!1||(this.isInput&&this.targetElement.setAttribute("value",t),!this.options.inline&&this.options.autoClose&&this.hide())}createDatetimeTemplate(){const e=this.options.showMonthAfterYear;let t=`<div class="ddtp-datetime ${this.options.isRTL?"rtl":""}" view-mode="${this._viewMode}">
|
|
82
82
|
<div class="ddtp-header">
|
|
83
83
|
<span class="${e?"ddtp-header-year":"ddtp-header-month"}"></span>
|
|
84
84
|
<span class="${e?"ddtp-header-month":"ddtp-header-year"}"></span>
|
|
@@ -138,34 +138,34 @@
|
|
|
138
138
|
<div class="ddtp-years">
|
|
139
139
|
</div>
|
|
140
140
|
</div>
|
|
141
|
-
</div>`;this.datetimeElement.innerHTML=t}refresh(e){if(this._viewMode===m.date||this._viewMode===m.datetime){this.dayDraw(e);return}if(this._viewMode===m.month){this.monthDraw(e);return}this._viewMode===m.year&&this.yearDraw(e)}yearDraw(e){var t;const i=this.currentDate.format("YYYY");if(e!==!1&&this.initMode==m.year){this.beforeChangeDatepicker();return}const
|
|
141
|
+
</div>`;this.datetimeElement.innerHTML=t}refresh(e){if(this._viewMode===m.date||this._viewMode===m.datetime){this.dayDraw(e);return}if(this._viewMode===m.month){this.monthDraw(e);return}this._viewMode===m.year&&this.yearDraw(e)}yearDraw(e){var t;const i=this.currentDate.format("YYYY");if(e!==!1&&this.initMode==m.year){this.beforeChangeDatepicker();return}const n=+i-8;this.datetimeElement.querySelector(".ddtp-header-year").textContent=`${n} ~ ${n+15}`;const l=Y(this.options.beforeDrawDate),a=l?this.options.beforeDrawDate:!1,o=[];for(let r=0;r<16;r++){const d=n+r;let u=this.isYearDisabled(d)?" disabled":"",c="";if(l&&a){const p=a({mode:this._viewMode,date:d});u+=p.style?" "+p.style:"",c=p.tooltip,c=c?`title="${c}"`:""}o.push(`<div class="ddtp-year ${u}" data-year="${d}" ${c}>${d}</div>`)}this.datetimeElement.querySelector(".ddtp-years").innerHTML=o.join(""),this.initMode==m.year&&this.afterChangeDatepicker(),(t=this.datetimeElement.querySelectorAll(".ddtp-year"))==null||t.forEach(r=>{r.addEventListener("click",d=>{const h=d.target;if(h){const u=h.getAttribute("data-year");if(u){const c=+u;if(this.isYearDisabled(c))return;if(this.initMode==m.year){if(this.isYearDisabled(c))return;this.currentDate.setYear(c),this.dateChangeEvent(d);return}this.currentDate.setYear(c),this.viewMode=this.initMode}}})})}monthDraw(e){var t;if(e!==!1&&this.initMode==m.month){this.beforeChangeDatepicker();return}const i=this.currentDate.format("YYYY");this.datetimeElement.querySelector(".ddtp-header-year").textContent=`${i}`;const n=this.datetimeElement.querySelectorAll(".ddtp-months > .ddtp-month");if(n.length>0){if(this.isYearDisabled(+i)){n.forEach(r=>{r.classList.contains("disabled")||r.classList.add("disabled")});return}n.forEach((r,d)=>{this.isMonthDisabled(+i,d)?r.classList.contains("disabled")||r.classList.add("disabled"):r.classList.remove("disabled")}),this.initMode==m.month&&this.afterChangeDatepicker();return}this.datetimeElement.querySelector(".ddtp-header-month").textContent=this.currentDate.format("MMMM");const l=Y(this.options.beforeDrawDate),a=l?this.options.beforeDrawDate:!1,o=[];for(let r=0;r<12;r++){let h=this.isMonthDisabled(+i,r)?" disabled":"",u="";if(l&&a){const c=a({mode:this._viewMode,date:i+"/"+(r+1)});h+=c.style?" "+c.style:"",u=c.tooltip,u=u?`title="${u}"`:""}o.push(`<div class="ddtp-month ${h}" data-month="${r}" ${u}>${g.getMonthsMessage(r,"abbr")}</div>`)}this.datetimeElement.querySelector(".ddtp-months").innerHTML=o.join(""),this.initMode==m.month&&this.afterChangeDatepicker(),(t=this.datetimeElement.querySelectorAll(".ddtp-month"))==null||t.forEach(r=>{r.addEventListener("click",d=>{const h=d.target;if(h){const u=h.getAttribute("data-month");if(u){if(this.isMonthDisabled(this.currentDate.getYear(),+u))return!1;if(this.initMode==m.month){this.currentDate.setMonth(+u),this.dateChangeEvent(d);return}this.currentDate.setMonth(+u),this.viewMode=this.initMode,this.dayDraw()}}})})}dayDraw(e){if(e!==!1&&(this.initMode==m.date||this.initMode==m.datetime)){this.beforeChangeDatepicker();return}let t=this.currentDate.clone();const i=t.getMonth();t.setDate(1),this.datetimeElement.querySelector(".ddtp-header-year").textContent=t.format("YYYY"),this.datetimeElement.querySelector(".ddtp-header-month").textContent=t.format("MMMM");let n=t.getDay();n=n-this.dayOrder[0],n>=0?t.addDate(-n):t.addDate(-(7+n));const l=Y(this.options.beforeDrawDate),a=l?this.options.beforeDrawDate:!1,o=[];for(let r=0;r<42;r++){let d;r==0?d=t:d=t.clone().addDate(r);const h=d.format(V.date);r%7==0&&o.push((r==0?"":"</tr>")+"<tr>");let u=this.isDayDisabled(d),c=T[this.dayOrder[r%7]];const p=d.getMonth();p!=i&&(p<i?c+=p==1?" new":" old":c+=i==1&&p==12?" old":" new"),c+=this.todayDate==h?" ddtp-today":"",c+=u?" disabled":"";let S="";if(l&&a){const L=a({mode:this._viewMode,item:d,date:d.format(this.dateFormat)});c+=L.style?" "+L.style:"",c+=L.check?" ddtp-event":"",S=L.tooltip,S=S?`title="${S}"`:""}o.push(`<td class="ddtp-day ${c}" data-day="${d.format("M,D")}" ${S}>`),o.push(`<span>${d.format("d")}</span>`),o.push("</td>")}o.push("</tr>"),this.datetimeElement.querySelector(".ddtp-day-body").innerHTML=o.join(""),(this.initMode==m.date||this.initMode==m.datetime)&&this.afterChangeDatepicker()}isDayDisabled(e){return this.minDate!=-1&&this.minDate>e.getTime()||this.maxDate!=-1&&this.maxDate<e.getTime()}isYearDisabled(e){return this.minYear!=-1&&this.minYear>e||this.maxYear!=-1&&this.maxYear<e}isMonthDisabled(e,t){if(this.isYearDisabled(e))return!0;let i=+(e+w(t,2));return this.minMonth!=-1&&this.minMonth>i||this.maxMonth!=-1&&this.maxMonth<i}static setMessage(e){g.setDefaultMessage(e)}};G.VERSION="0.0.13",G.format=Ve,G.parser=z;let vt=G;function yt(){return{clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0)}}class J extends f{constructor(e,t,i){super(i,e,t),this.mounted(),this.setDefaultOption(),this.setDefaultInfo()}mounted(){let e;this.field.rendererOptions=Object.assign({},this.field.rendererOptions),typeof this.field.rendererOptions.onSelect<"u"&&(e=typeof this.field.rendererOptions.onSelect),v(this.field.rendererOptions.mode)&&(this.field.renderType=="datemonth"||this.field.renderType=="datehour"?this.field.rendererOptions.mode=this.field.renderType.replace("date",""):this.field.rendererOptions.mode=this.field.renderType),this.field.rendererOptions.onSelect=(t,i)=>{e&&e(t,i),this.setValue(t),this.valid()},this.dateObj=new vt(this.element,this.field.rendererOptions,{})}createField(){const e=this.field,t=this.rowElement.querySelector(".df-field-container");t.innerHTML=`
|
|
142
142
|
<div class="df-field">
|
|
143
143
|
<input type="text" name="${e.$xssName}" class="df-form-field df-text df-help-icon" autocomplete="off" readonly/>
|
|
144
144
|
</div>
|
|
145
145
|
${f.getDescriptionTemplate(e)}
|
|
146
146
|
<div class="df-help-message"></div>
|
|
147
|
-
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=
|
|
147
|
+
`,this.element=t.querySelector(`[name="${e.$xssName}"]`)}getValue(){return this.element.value}setValue(e,t){if(t!==!1&&this.changeEventCall(this.field,null,this,e)===!1){this.element.value=this.field.$value;return}this.field.$value=e,this.element.value=e}reset(){this.setDefaultInfo(),this.setDisabled(!1),b(this.rowElement)}getElement(){return this.element}valid(){const e=O(this.getValue(),this.field);return $(this.field,this.rowElement,e),e}}class Et extends f{constructor(e,t,i){super(i,e,t),e.renderer?this.customFunction=e.renderer:this.customFunction={},this.mounted()}mounted(){this.customFunction.mounted&&this.customFunction.mounted.call(this,this.field,this.rowElement),this.tabContainerElement.querySelectorAll(".df-tab-item").forEach(e=>{e.addEventListener("click",t=>{this.clickEventHandler(e,t)})})}clickEventHandler(e,t){this.setActive(e.getAttribute("data-tab-id")??"")}setActive(e){var n,l;const t=this.tabContainerElement.querySelector(`[data-tab-id="${e}"]`);if(!t)return;if(!t.classList.contains("active")){for(let a of((n=t==null?void 0:t.parentElement)==null?void 0:n.children)??[])a.classList.remove("active");t.classList.add("active")}const i=this.rowElement.querySelector(`[tab-panel-id="${e}"]`);if(!(i!=null&&i.classList.contains("active"))){for(let a of((l=i==null?void 0:i.parentElement)==null?void 0:l.children)??[])a.classList.remove("active");i==null||i.classList.add("active")}}static isDataRender(){return!1}static isChildrenCreate(){return!1}createField(){var a,o;const e=this.field,t=this.daraForm.formTemplate,i=this.daraForm.getOptions(),n=this.rowElement.querySelector(".df-field-container");let l=q(i,e);if(n.innerHTML=`
|
|
148
148
|
<div class="df-field ">
|
|
149
|
-
<div class="df-tab-header ${
|
|
149
|
+
<div class="df-tab-header ${l.tabAlignClass}"></div>
|
|
150
150
|
</div>
|
|
151
151
|
<div class="df-tab-body"></div>
|
|
152
|
-
`,e.children){let r=!0;const d=this.getForm().getOptions();let h=
|
|
152
|
+
`,e.children){let r=!0;const d=this.getForm().getOptions();let h=q(d,e,null,t.isLabelHide(e));for(const u of e.children){u.$parent=e,t.addRowFieldInfo(u);let c=u.$key,p=`<span class="df-tab-item ${r?"active":""}" data-tab-id="${c}"><a href="javascript:;">${u.label}</a></span>`,S=`<div class="df-tab-panel ${r?"active":""}" tab-panel-id="${c}">${f.getDescriptionTemplate(u)}
|
|
153
153
|
<div class="df-tab-group"></div>
|
|
154
|
-
</div>`;const L=j(p),k=j(S);if(r=!1,L&&((a=
|
|
154
|
+
</div>`;const L=j(p),k=j(S);if(r=!1,L&&((a=n.querySelector(".df-tab-header"))==null||a.appendChild(L)),k&&((o=n.querySelector(".df-tab-body"))==null||o.appendChild(k),u.children)){let se={style:{width:d.style.width??"100%",labelWidth:d.style.labelWidth??3,valueWidth:d.style.valueWidth??9,position:d.style.position??"left-right"},useTypeValue:d.useTypeValue,autoCreate:!1,notValidMessage:"This form is not valid.",fields:[]};u.$tabForm=new W(document.createElement("div"),se),u.$instance=new u.$renderType(u,k==null?void 0:k.querySelector(".df-tab-group"),u.$tabForm),u.$tabForm.formTemplate.childTemplate(u,h)}}this.tabContainerElement=n}}getValue(){var i;if(this.customFunction.getValue)return this.customFunction.getValue.call(this,this.field,this.rowElement);let e={},t=this.getForm().getOptions().useTypeValue;for(const n of this.field.children){const l=(i=n.$tabForm)==null?void 0:i.getValue(!1);if(t)e[n.$validName]=l;else for(let[a,o]of Object.entries(l))e[a]=o}return e}setValue(e){var t;for(const i of this.field.children){let n=e[i.$validName];n&&((t=i.$tabForm)==null||t.setValue(n))}}reset(){}getElement(){return this.rowElement}valid(){var t;if(this.customFunction.valid){const i=this.customFunction.valid.call(this,this.field,this.rowElement);$(this.field,this.rowElement,i);return}const e=this.field;for(const i of e.children){const n=(t=i.$tabForm)==null?void 0:t.validForm();if(n&&n.length>0){const l=n[0];if(l.message)return l.message="["+this.field.label+"] "+l.message,l}}return!0}focus(){}}let ee=0;class $t extends f{constructor(e,t,i){super(i,e,t),this.allAddRowInfo={},e.renderer?this.customFunction=e.renderer:this.customFunction={};const n={style:{width:"100%",labelWidth:3,valueWidth:9,position:"left-right"},autoCreate:!1,notValidMessage:"This form is not valid.",fields:[]};this.gridForm=new W(document.createElement("div"),n),this.mounted(),this.setDefaultOption(),this.setDefaultInfo()}mounted(){var e;this.addRow(),this.customFunction.mounted&&this.customFunction.mounted.call(this,this.field,this.rowElement),(e=this.rowElement.querySelector(".df-grid-add-row-btn"))==null||e.addEventListener("click",t=>{this.addRow()})}static isDataRender(){return!1}static isChildrenCreate(){return!1}createField(){var a,o,r,d;const e=this.field,t=this.rowElement.querySelector(".df-field-container");let i=[],n=[],l=[];if(l.push(""),e.children){n.push("<colgroup>"),i.push("<tr>"),n.push('<col style="width:38px">'),i.push("<th>"),((a=e.rendererOptions)==null?void 0:a.disableAddButton)!==!0&&i.push('<button type="button" class="df-btn df-grid-add-row-btn" title="Add"><i class="df-icon df-add-icon"></i></button>'),i.push("</th>");for(const h of e.children)n.push(`<col style="width:${((o=h.style)==null?void 0:o.width)??"*"}">`),i.push(`<th class="df-grid-header">${h.label}</th>`);n.push("</colgroup>"),i.push("</tr>")}t.innerHTML=`
|
|
155
155
|
<div class="df-grid-field">
|
|
156
|
-
${
|
|
156
|
+
${l.join("")}
|
|
157
157
|
<div class="df-grid-container ${((r=e.style)==null?void 0:r.position)??""}" style="height:${((d=e.rendererOptions)==null?void 0:d.height)??"auto"};">
|
|
158
|
-
<table class="df-grid">${
|
|
158
|
+
<table class="df-grid">${n.join("")}<thead>${i.join("")}</thead><tbody></tbody></table>
|
|
159
159
|
</div>
|
|
160
160
|
</div>
|
|
161
|
-
`}addRow(e){var r,d,h;let t=[];const i=this.daraForm.getOptions(),
|
|
161
|
+
`}addRow(e){var r,d,h;let t=[];const i=this.daraForm.getOptions(),n=this.gridForm.formTemplate,l=this.field.$xssName;++ee;let a=[];t.push('<tr class="df-grid-row">'),t.push("<td>"),((r=this.field.rendererOptions)==null?void 0:r.disableRemoveButton)!==!0&&t.push(`<button type="button" data-row-idx="${ee}" class="df-btn df-grid-row-remove"><i class="df-icon df-remove-icon"></i></button>`),t.push("</td>");for(const u of this.field.children){let c=q(i,u,null,!0),p=oe({},u);a.push(p),p.$orgin=u,p.name=p.name+"_"+ee,p.$xssName=l+"_"+Me(p),n.addRowFieldInfo(p),t.push(`<td id="${p.$xssName}"><div class="df-field-container ${p.required?"required":""} " style="${c.valueStyle}"></div></td>`)}t.push("</tr>"),this.allAddRowInfo[ee]=a;const o=j(t.join(""));o&&((d=this.rowElement.querySelector("tbody"))==null||d.append(o),(h=o.querySelector(".df-grid-row-remove"))==null||h.addEventListener("click",u=>{this.removeRow(u)})),e=e??{};for(let u of a)u.$instance=new u.$renderType(u,o==null?void 0:o.querySelector(`#${u.$xssName}`),this.gridForm),e[u.$orgin.name]&&u.$instance.setValue(e[u.$orgin.name])}removeRow(e){var n;const i=e.target.closest("tr");if(i){let l=((n=e.currentTarget)==null?void 0:n.getAttribute("data-row-idx"))||"-1";this.removeFieldInfo(l),i.remove()}}removeFieldInfo(e){let t=[];if(console.log("rowIdx : ",e),C(e)){for(let i in this.allAddRowInfo)t=t.concat(this.allAddRowInfo[i]);this.allAddRowInfo={}}else if(e){const i=parseInt(e,10);t=t.concat(this.allAddRowInfo[i]),delete this.allAddRowInfo[i]}for(let i of t)this.gridForm.getFieldInfoMap().removeFieldInfo(i.name)}allRemoveRow(){var e;(e=this.rowElement.querySelector("tbody"))==null||e.replaceChildren(),this.removeFieldInfo()}getValue(){if(this.customFunction.getValue)return this.customFunction.getValue.call(this,this.field,this.rowElement);let e=[];const t=this.field.children,i=t.length;for(let n in this.allAddRowInfo){const l=this.allAddRowInfo[n];let a={};for(let o=0;o<i;o++){let r=t[o];a[r.name]=this.gridForm.getFieldValue(l[o].name)}e.push(a)}return e}setValue(e){this.field.$value=e;let t=[];x(e)?t=e:re(e)&&t.push(e),this.allRemoveRow();for(let i of t)this.addRow(i)}reset(){this.setDefaultInfo(),b(this.rowElement)}getElement(){return this.customFunction.getElement?this.customFunction.getElement.call(this,this.field,this.rowElement):null}valid(){if(this.customFunction.valid){const t=this.customFunction.valid.call(this,this.field,this.rowElement);$(this.field,this.rowElement,t);return}const e=this.gridForm.validForm();if(e.length>0){const t=e[0];if(t.message)return t.message="["+this.field.label+"] "+t.message,t}return!0}focus(){}}const y={NAN:"nan",MIN:"minimum",EXCLUSIVE_MIN:"exclusiveMinimum",MAX:"maximum",EXCLUSIVE_MAX:"exclusiveMaximum",MIN_LENGTH:"minLength",MAX_LENGTH:"maxLength",BETWEEN:"between",BETWEEN_EXCLUSIVE_MIN:"betweenExclusiveMin",BETWEEN_EXCLUSIVE_MAX:"betweenExclusiveMax",BETWEEN_EXCLUSIVE_MINMAX:"betweenExclusiveMinMax",REQUIRED:"required"},bt="dff",te={number:Je,textarea:et,dropdown:ue,checkbox:me,radio:pe,text:tt,password:it,file:nt,custom:lt,group:at,hidden:rt,button:ot,range:dt,datehour:J,datemonth:J,date:J,datetime:J,tab:Et,grid:$t},Le={horizontal:"horizontal"},D={"top-left":["top","df-txt-left"],"top-center":["top","df-txt-center"],"top-right":["top","df-txt-right"],"left-left":["","df-txt-left"],"left-center":["","df-txt-center"],"left-right":["","df-txt-right"],"right-right":["right","df-txt-right"],"right-center":["right","df-txt-center"],"right-left":["right","df-txt-left"],"bottom-left":["bottom","df-txt-left"],"bottom-center":["bottom","df-txt-center"],"bottom-right":["bottom","df-txt-right"]};D.top=D["top-left"],D.right=D["right-right"],D.left=D["left-left"],D.bottom=D["bottom-left"];let Ce={required:"{label} 필수 입력사항입니다.",fileButton:"파일찾기",selection:"선택",string:{minLength:"{minLength} 글자 이상으로 입력하세요.",maxLength:"{maxLength} 글자 이하로 입력하세요.",between:"{minLength} ~ {maxLength} 사이의 글자를 입력하세요."},number:{nan:"숫자만 입력 가능 합니다.",minimum:"{minimum} 값과 같거나 커야 합니다",exclusiveMinimum:"{minimum} 보다 커야 합니다",maximum:"{maximum} 값과 같거나 작아야 합니다",exclusiveMaximum:"{maximum} 보다 작아야 합니다.",between:"{minimum}~{maximum} 사이의 값을 입력하세요.",betweenExclusiveMin:"{minimum} 보다 크고 {maximum} 보다 같거나 작아야 합니다",betweenExclusiveMax:"{minimum} 보다 같거나 크고 {maximum} 보다 작아야 합니다",betweenExclusiveMinMax:"{minimum} 보다 크고 {maximum} 보다 작아야 합니다"},regexp:{mobile:"핸드폰 번호가 유효하지 않습니다.",email:"이메일이 유효하지 않습니다.",url:"URL이 유효하지 않습니다.",alpha:"영문만 입력 가능 합니다.","alpha-num":"영문과 숫자만 입력 가능 합니다.",number:"숫자만 입력 가능 합니다.",variable:"값이 유효하지 않습니다.","number-char":"숫자, 문자 각각 하나 이상 포함 되어야 합니다.","upper-char":"대문자가 하나 이상 포함 되어야 합니다.","upper-char-special":"대문자,소문자,특수문자 각각 하나 이상 포함 되어야 합니다.","upper-char-special-number":"대문자,소문자,특수문자,숫자 각각 하나 이상 포함 되어야합니다."}};class wt{constructor(){this.lang=Ce}set(e){this.lang=Object.assign({},Ce,e)}getMessage(e){return this.lang[e]}validMessage(e,t){let i="",n=[];t.regexp&&(i=this.lang.regexp[t.regexp],n.push(i)),(t.constraint??[]).forEach(o=>{o===y.REQUIRED&&(i=Te(this.lang.required,e),n.push(i)),e.renderType=="number"||e.renderType=="range"?(i=this.lang.number[o],n.push(i)):(i=this.lang.string[o],n.push(i))});const l=[],a=Object.assign({},{name:e.name,label:e.label},e.rule);return n.forEach(o=>{o&&l.push(Te(o,a))}),t.validator&&l.push(t.validator.message),l}}function Te(s,e){return s.replace(/\{{1,1}([A-Za-z0-9_.]*)\}{1,1}/g,(t,i)=>typeof e[i]<"u"?e[i]:t)}const N=new wt,Mt=s=>{let e;return s.renderType&&(e=te[s.renderType]),e&&(e.isDataRender()===!1||!v(s.name))?e:v(s.name)?s.children?te.group:te.hidden:te.text};class Ft{constructor(e,t){this.fieldIdx=0,this.allFieldInfo={},this.keyNameMap={},this.conditionFields=[],this.fieldPrefix=`${bt}_${Pe(e)}`,this.form=t}addField(e){We(e),this.fieldIdx+=1,e.$key=`${this.fieldPrefix}_${this.fieldIdx}`,e.$validName=e.name??e.label,this.keyNameMap[e.$validName]=e.$key,this.allFieldInfo[e.$key]=e,e.$renderType=Mt(e),e.conditional&&this.conditionFields.push(e.$key)}getFieldName(e){return this.allFieldInfo[this.keyNameMap[e]]}get(e){return this.allFieldInfo[e]}hasFieldName(e){return!!(this.keyNameMap[e]&&this.allFieldInfo[this.keyNameMap[e]])}getAllFieldInfo(){return this.allFieldInfo}removeFieldInfo(e){const t=this.keyNameMap[e];v(t)||(this.removeFieldInfoByKey(t),delete this.keyNameMap[e])}removeFieldInfoByKey(e){const t=this.allFieldInfo[e];t&&this.keyNameMap[t.$validName]===e&&delete this.keyNameMap[t.$validName],delete this.allFieldInfo[e],this.conditionFields=this.conditionFields.filter(i=>i!==e)}getAllFieldValue(e,t){const i=this.form.getOptions().useTypeValue;if(t!==!0){for(let[n,l]of Object.entries(this.allFieldInfo))e=ke(e,l,i);return e}return new Promise((n,l)=>{for(let[a,o]of Object.entries(this.allFieldInfo)){if(!o.$instance.isEnableView())continue;let r=this.getFieldValidation(o,!0);if(r!==!0){l(new Error(r.message,{cause:r}));return}e=ke(e,o,i)}n(e)})}getFormDataValue(e,t){if(t!==!0){let i=new FormData;for(let[n,l]of Object.entries(e))i.set(n,l);for(let[n,l]of Object.entries(this.allFieldInfo))Ie(i,l,l.$instance.getValue());return i}return new Promise((i,n)=>{let l=new FormData;for(let[a,o]of Object.entries(e))l.set(a,o);for(let[a,o]of Object.entries(this.allFieldInfo)){if(!o.$instance.isEnableView())continue;let r=this.getFieldValidation(o,!0);if(r!==!0){n(new Error(r.message,{cause:r}));return}Ie(l,o,o.$instance.getValue())}i(l)})}isConditionFieldCheck(e){let t=e;for(;typeof t<"u";){if(!this.isConditionField(t))return!1;t=t.$parent}return!0}isConditionField(e){if(!this.conditionFields.includes(e.$key))return!0;let t=!1;if(e.conditional.custom)t=e.conditional.custom.call(null,e);else if(e.conditional.field){const i=this.getFieldName(e.conditional.field);i&&e.conditional.eq==i.$instance.getValue()&&(t=!0)}return t}conditionCheck(){this.conditionFields.forEach(e=>{const t=this.allFieldInfo[e];this.isConditionField(t)?t.$instance.show():t.$instance.hide()})}getFieldValidation(e,t){if(!this.isConditionFieldCheck(e))return!0;const i=e.$instance;let n=i.valid();return n===!0?!0:(t&&i.focus(),n=n,v(n.message)&&(n.message=N.validMessage(e,n)[0]),n)}}function ke(s,e,t){if(we(e))return s;const i=e.$instance.getValue();if(e.renderType==="file"){const n=i.uploadFile;s[e.$validName]=n,s[e.$validName+"RemoveIds"]=i.removeIds}else if(t!==!0)if(_(e))for(let[n,l]of Object.entries(i))s[n]=l;else C(e.name)||(s[e.name]=i);else s[e.$validName]=i;return s}function Ie(s,e,t){if(we(e))return s;const i=e.$instance.getValue();if(e.renderType==="file"){const n=i.uploadFile;s.delete(e.$validName);for(let l of n)s.append(e.$validName,l);s.set(e.$validName+"RemoveIds",i.removeIds)}else if(t!==!0)if(_(e))for(let[n,l]of Object.entries(i))s.set(n,l);else C(e.name)||s.set(e.$validName,i);else s.set(e.$validName,i);return s}class Dt{constructor(e,t,i){this.addRowFields=[],this.daraform=e,this.options=e.getOptions(),this.formElement=t,this.fieldInfoMap=i}addRow(e){this.checkHiddenField(e)||(this.addRowFields=[],this.addRowTemplate(e))}addRowTemplate(e){let t=this.isLabelHide(e),i=q(this.options,e,null,t);this.addRowFieldInfo(e);const n=j(`
|
|
162
162
|
<div class="df-row df-form-group ${i.fieldClass}" id="${e.$key}">
|
|
163
163
|
${t?"":`<div class="df-label ${i.labelClass} ${i.labelAlignClass}" title="${e.label??""}" style="${i.labelStyle}">${this.getLabelTemplate(e)}</div>`}
|
|
164
164
|
|
|
165
165
|
<div class="df-field-container ${i.valueClass} ${e.required?"required":""}" style="${i.valueStyle}"></div>
|
|
166
166
|
</div>
|
|
167
|
-
`);
|
|
167
|
+
`);n&&(this.createField(e,n),this.formElement.append(n),e.children&&this.childTemplate(e,i))}createField(e,t){e.$instance=new e.$renderType(e,t,this.daraform)}childTemplate(e,t){let i=null,n=!0,l=!1;if(!e.$renderType.isChildrenCreate())return;const a=document.createElement("div");a.classList.add("df-row",t.rowStyleClass??"");let o=0;for(const r of e.children){if(C(r))throw new Error(`parent field :[${e.$validName}], children index ${o}, empty [${r}]`);if(r.$parent=e,++o,this.checkHiddenField(r))continue;this.addRowFieldInfo(r),n&&(i=r);let d=this.isLabelHide(r),h,u="";d?(h=q(this.options,r,i,!l),u=l?`<span class="df-label df-empty ${h.labelClass}" style="${h.labelStyle}"></span>`:""):(h=q(this.options,r,i,!1),u=`<span class="df-label ${h.labelClass} ${h.labelAlignClass}" title="${r.label??""}" style="${h.labelStyle}">${this.getLabelTemplate(r)}</span>`);const c=j(`<div class="df-form-group ${h.fieldClass}" style="${h.fieldStyle}" id="${r.$key}">
|
|
168
168
|
${u}
|
|
169
169
|
<span class="df-field-container ${h.valueClass} ${r.required?"required":""}" style="${h.valueStyle}"></span>
|
|
170
|
-
</div>`);c&&(this.createField(r,c),a.append(c),r.children&&this.childTemplate(r,r.children?h:t)),d||(
|
|
170
|
+
</div>`);c&&(this.createField(r,c),a.append(c),r.children&&this.childTemplate(r,r.children?h:t)),d||(l=!0),n=!1}e.$instance.addChildField(a)}getLabelTemplate(e){const t=e.required?'<span class="required"></span>':"",i=M(e.tooltip)?"":`<span class="df-tooltip">?<span class="df-tooltip-text">${e.tooltip}</span></span>`;return`<span class="df-label-text">${e.label??""}</span> ${i} ${t}`}isLabelHide(e){var t;return((t=e.style)==null?void 0:t.labelHide)||v(e.label)}checkHiddenField(e){return Be(e)?(this.fieldInfoMap.addField(e),e.$instance=new e.$renderType(e,null,this.daraform),!0):!1}addRowFieldInfo(e){if(!M(e.name)&&this.fieldInfoMap.hasFieldName(e.name))throw new Error(`Duplicate field name "${e.name}"`);this.fieldInfoMap.addField(e),this.addRowFields.push(e.$key)}}function xt(s){return oe({},ye,s)}function Vt(s){ye=oe({},ye,s)}let ye={style:{width:"100%",labelWidth:3,valueWidth:9,position:"left-right"},mode:"new",useTypeValue:!0,autoCreate:!0,notValidMessage:"This form is not valid.",fields:[]};const ie={},Ne="data-form-uid";let St=0;const P=class P{constructor(e,t,i){if(this.formValue={},this.changeListeners=[],this.changeMode=n=>{this.options.mode=n,this.formElement.setAttribute("data-df-mode",n);const l=this.formElement.querySelectorAll(".df-field input, .df-field textarea, .df-field select");n=="view"?l.forEach(a=>{a instanceof HTMLInputElement&&(a.readOnly=!0),a instanceof HTMLTextAreaElement&&(a.readOnly=!0)}):l.forEach(a=>{a instanceof HTMLInputElement&&(a.readOnly=!1),a instanceof HTMLTextAreaElement&&(a.readOnly=!1)})},this.resetForm=()=>{const n=this.fieldInfoMap.getAllFieldInfo();for(const l in n){const o=n[l].$instance;o&&typeof o.reset=="function"&&o.reset()}this.formValue={},this.conditionCheck()},this.resetField=n=>{this.fieldInfoMap.getFieldName(n).$instance.reset(),this.formValue[n]="",this.conditionCheck()},this.getFieldValue=n=>{const l=this.fieldInfoMap.getFieldName(n);return l?l.$instance.getValue():null},this.getValue=n=>this.fieldInfoMap.getAllFieldValue(this.formValue,n),this.getFormDataValue=n=>this.fieldInfoMap.getFormDataValue(this.formValue,n),this.setValue=(n,l)=>{l!==!1&&this.resetForm(),Object.keys(n).forEach(a=>{this._setFieldValue(a,n[a])}),this.conditionCheck()},this.setFieldValue=(n,l)=>{this._setFieldValue(n,l),this.conditionCheck()},this.setFieldItems=(n,l)=>{const a=this.fieldInfoMap.getFieldName(n);if(a)return a.$instance.setValueItems(l)},this.addField=n=>{this.options.fields.push(n),this.formTemplate.addRow(n),this.conditionCheck()},this.removeField=n=>{const l=this.fieldInfoMap.getFieldName(n);if(!l)return;const a=this.getRemoveFields(l);a.forEach(o=>{this.removeFormValue(o)}),this.removeFieldElement(l),this.removeParentChildField(l),a.forEach(o=>{this.fieldInfoMap.removeFieldInfoByKey(o.$key)}),this.conditionCheck()},this.isValidForm=()=>this.validForm().length<1,this.validForm=()=>{let n=[],l=this.options.autoFocus!==!1,a=!0;const o=this.fieldInfoMap.getAllFieldInfo();for(const r in o){const d=o[r];let h=this.fieldInfoMap.getFieldValidation(d,l);h!==!0&&(l=!1,be(d)?n=n.concat(h):(a&&(this.validTabCheck(d),a=!1),n.push(h)))}return n},this.isValidField=n=>{const l=this.fieldInfoMap.getFieldName(n);if(v(l))throw new Error(`Field name [${n}] not found`);const a=l.$instance;return a?a.valid()===!0:!0},this.getOptions=()=>this.options,this.subscribe=n=>(this.changeListeners.push(n),()=>{this.changeListeners=this.changeListeners.filter(l=>l!==n)}),this.destroy=()=>{this.formElement.className=this.orginFormStyleClass,this.formElement.replaceChildren();for(const n in this)ze(this,n)&&(delete this[n],delete ie[this.selector])},this.getFields=()=>this.options.fields,this.setFields=n=>{this.options.fields=n,this.createForm(n)},this.options=xt(t),N.set(i),e)this.orginFormStyleClass=e.className,e.classList.add("daracl-form"),this.selector=`df_${++St}`,e.setAttribute("name",this.selector),e.setAttribute(Ne,this.selector),this.options.style.width&&e.setAttribute("style",`width:${this.options.style.width};`),this.formElement=e,this.changeMode(this.options.mode??"new"),this.createForm(this.options.fields),this.options.autoCreate!==!1&&(ie[this.selector]=this);else throw new Error(`${e} form selector not found`)}static create(e,t,i){return new P(e,t,i)}static setMessage(e){N.set(e)}static setDefaultOptions(e,t){Vt(e),t&&N.set(t)}createForm(e){this.fieldInfoMap=new Ft(this.selector,this),this.formTemplate=new Dt(this,this.formElement,this.fieldInfoMap),this.options.autoCreate!==!1&&(e.forEach(t=>{this.formTemplate.addRow(t)}),this.conditionCheck(),this.options.onMounted&&this.options.onMounted.call(this))}getFieldElement(e){const t=this.fieldInfoMap.getFieldName(e);return t!=null&&t.$instance?t.$instance.getElement():null}getField(e){return this.fieldInfoMap.getFieldName(e)}_setFieldValue(e,t){this.formValue[e]=t;const i=this.fieldInfoMap.getFieldName(e);i&&i.$instance.setValue(t)}getRemoveFields(e,t=[]){var i;return t.push(e),(i=e.children)==null||i.forEach(n=>{n&&this.fieldInfoMap.get(n.$key)===n&&this.getRemoveFields(n,t)}),t}removeFieldElement(e){var o,r;const t=e.$parent;if(t&&_(t)){const d=t.$instance.getElement(),h=d.querySelector(`[data-tab-id="${e.$key}"]`),u=h==null?void 0:h.classList.contains("active");h==null||h.remove(),(o=d.querySelector(`[tab-panel-id="${e.$key}"]`))==null||o.remove();const c=d.querySelector(".df-tab-header .df-tab-item");u&&c&&t.$instance.setActive(c.getAttribute("data-tab-id")??"");return}const i=`[id="${e.$key}"]`;let n=(r=e.$instance)==null?void 0:r.getElement();(n instanceof NodeList||n instanceof HTMLCollection)&&(n=n[0]??null);const l=(n instanceof Element?n.closest(i):null)??this.formElement.querySelector(i),a=l==null?void 0:l.parentElement;l==null||l.remove(),t&&(a!=null&&a.classList.contains("df-row"))&&a.childElementCount<1&&a.remove()}removeParentChildField(e){const t=e.$parent?e.$parent.children:this.options.fields,i=t?t.indexOf(e):-1;i>-1&&(t==null||t.splice(i,1))}removeFormValue(e){const t=[e.name,e.$validName];e.renderType==="file"?t.push(e.$validName+"RemoveIds"):_(e)&&t.push(...Object.keys(e.$instance.getValue()??{})),e.$tabForm&&t.push(...Object.keys(e.$tabForm.getValue(!1)??{})),t.forEach(i=>{M(i)||delete this.formValue[i]})}validTabCheck(e){e.$parent&&(e.$parent.renderType=="tab"&&e.$parent.$instance.setActive(e.$key),this.validTabCheck(e.$parent))}conditionCheck(){this.fieldInfoMap.conditionCheck(),this.notifyChange()}notifyChange(){if(this.changeListeners.length<1)return;const e={form:this};this.changeListeners.forEach(t=>t(e))}setFieldDisabled(e,t){this.fieldInfoMap.getFieldName(e).$instance.setDisabled(t)}setFieldDescription(e,t){this.fieldInfoMap.getFieldName(e).$instance.setDescription(t)}static instance(e){let t;ae(e)?t=document.querySelector(e):t=e,t=t;let i=t.getAttribute(Ne);if(v(i)||M(i)){const n=Object.keys(ie);if(n.length>1)throw new Error(`selector empty : [${i}]`);return i=n[0],ie[i]}}getFieldInfoMap(){return this.fieldInfoMap}};P.VERSION="0.0.19",P.validator={string:(e,t)=>O(e,t),number:(e,t)=>de(e,t),regexp:(e,t)=>{let i={name:t.name,constraint:[]};return De(e,t,i)}};let W=P;typeof window<"u"&&(window.Daracl=window.Daracl||{},window.Daracl.form=W)});
|
|
171
171
|
//# sourceMappingURL=daracl.form.min.umd.js.map
|