@daracl/form 0.0.17 → 0.0.18
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/README.md +1 -1
- package/dist/DaraForm.d.ts +51 -2
- package/dist/FieldInfoMap.d.ts +8 -1
- package/dist/FormTemplate.d.ts +2 -2
- package/dist/constants.d.ts +5 -1
- package/dist/daracl.form.css +688 -0
- package/dist/daracl.form.min.css +10 -0
- package/dist/daracl.form.min.umd.js +171 -0
- package/dist/daracl.form.min.umd.js.map +1 -0
- package/dist/daracl.form.umd.js +4477 -0
- package/dist/daracl.form.umd.js.map +1 -0
- package/dist/defaultOption.d.ts +8 -0
- package/dist/event/renderEvents.d.ts +1 -1
- package/dist/global.d.ts +6 -0
- package/dist/index.cjs +1806 -519
- package/dist/index.cjs.map +1 -7
- package/dist/index.d.ts +7 -2
- package/dist/index.html +193 -348
- package/dist/index.js +4090 -3101
- package/dist/index.js.map +1 -7
- package/dist/index.min.cjs +171 -0
- package/dist/index.min.cjs.map +1 -0
- package/dist/index.min.js +2910 -0
- package/dist/index.min.js.map +1 -0
- package/dist/index.umd.d.ts +7 -0
- package/dist/renderer/ButtonRender.d.ts +2 -2
- package/dist/renderer/CheckboxRender.d.ts +2 -2
- package/dist/renderer/CustomRender.d.ts +2 -2
- package/dist/renderer/DateRender.d.ts +2 -2
- package/dist/renderer/DropdownRender.d.ts +2 -2
- package/dist/renderer/FileRender.d.ts +2 -2
- package/dist/renderer/GridRender.d.ts +2 -2
- package/dist/renderer/GroupRender.d.ts +2 -2
- package/dist/renderer/HiddenRender.d.ts +2 -2
- package/dist/renderer/NumberRender.d.ts +2 -2
- package/dist/renderer/PasswordRender.d.ts +2 -2
- package/dist/renderer/RadioRender.d.ts +2 -2
- package/dist/renderer/RangeRender.d.ts +2 -2
- package/dist/renderer/Render.d.ts +2 -2
- package/dist/renderer/TabRender.d.ts +2 -2
- package/dist/renderer/TextAreaRender.d.ts +2 -2
- package/dist/renderer/TextRender.d.ts +2 -2
- package/dist/types/FormField.d.ts +18 -13
- package/dist/types/FormOptions.d.ts +1 -1
- package/dist/types/style.d.ts +3 -0
- package/dist/util/renderFactory.d.ts +1 -1
- package/dist/util/styleUtils.d.ts +10 -12
- package/dist/util/utils.d.ts +1 -1
- package/package.json +129 -140
- package/style/abstracts/_index.scss +2 -0
- package/style/abstracts/_mixins.scss +22 -0
- package/style/abstracts/_variables.scss +1 -0
- package/style/base/_base.scss +59 -0
- package/style/base/_index.scss +1 -0
- package/style/components/_button.scss +16 -0
- package/style/components/_field-container.scss +41 -0
- package/style/components/_field-group.scss +16 -0
- package/style/components/_file-list.scss +33 -0
- package/style/components/_form-field.scss +47 -0
- package/style/components/_form-group.scss +90 -0
- package/style/components/_grid-field.scss +121 -0
- package/style/components/_icon.scss +16 -0
- package/style/components/_index.scss +11 -0
- package/style/components/_label.scss +59 -0
- package/style/components/_row.scss +88 -0
- package/style/components/_tab.scss +70 -0
- package/{dist/index.css → style/daracl.form.css} +19 -66
- package/style/daracl.form.css.map +1 -0
- package/style/daracl.form.min.css +2 -0
- package/style/daracl.form.min.css.map +1 -0
- package/style/daracl.form.scss +44 -691
- package/style/themes/_common.scss +13 -0
- package/style/themes/_dark.scss +20 -0
- package/style/themes/_index.scss +14 -0
- package/style/themes/_light.scss +20 -0
- package/style/themes/_mixin.scss +6 -0
- package/dist/commonVender.d.ts +0 -1
- package/dist/daracl.form.js +0 -5720
- package/dist/daracl.form.js.map +0 -1
- package/dist/daracl.form.min.js +0 -7
- package/dist/daracl.form.min.js.LICENSE.txt +0 -5
- package/dist/daracl.form.min.js.map +0 -1
- package/dist/daracl.vender.min.css +0 -5
- package/dist/daracl.vender.min.js +0 -2
- package/dist/daracl.vender.min.js.LICENSE.txt +0 -3
- package/dist/index.css.map +0 -7
- package/dist/indexVender.d.ts +0 -6
- package/dist/main.css +0 -6
- package/dist/main.css.map +0 -1
- package/src/index.ts +0 -5
- /package/dist/util/{Lanauage.d.ts → Language.d.ts} +0 -0
|
@@ -0,0 +1,2910 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @daracl/form v0.0.18
|
|
3
|
+
* Copyright 2023-2026 darainfo;
|
|
4
|
+
* Licensed MIT
|
|
5
|
+
*/
|
|
6
|
+
import { isArray as Se, leftPad as w, isNumeric as Re, leftPadClamp as P, isFunction as Y } from "@daracl/core";
|
|
7
|
+
const ae = {
|
|
8
|
+
"&": "&",
|
|
9
|
+
"<": "<",
|
|
10
|
+
">": ">",
|
|
11
|
+
'"': """,
|
|
12
|
+
"'": "'"
|
|
13
|
+
}, Q = (s) => {
|
|
14
|
+
let e = s;
|
|
15
|
+
return e && Object.keys(ae).forEach((t) => {
|
|
16
|
+
e = e.replaceAll(t, ae[t]);
|
|
17
|
+
}), e;
|
|
18
|
+
}, Ye = (s, e) => s.hasOwnProperty(e), D = (s) => s === null || s === "" || typeof s > "u" || typeof s == "string" && (s === "" || s.replace(/\s/g, "") === ""), y = (s) => typeof s > "u", be = (s) => typeof s == "function", oe = (s) => typeof s == "string", M = (s) => D(s) ? !1 : (s = +s, !isNaN(s)), L = (s) => Se(s), C = (s) => y(s) || s == null, j = (s) => s && s.renderType === "tab", Le = (s) => s && s.renderType === "grid", He = (s) => (s.$xssName = Te(s), s.label = Q(s.label), s), Ce = (s) => Le(s.$parent) || j(s.$parent), Te = (s) => {
|
|
19
|
+
if (y(s.$xssName)) {
|
|
20
|
+
let e = s.name;
|
|
21
|
+
return e && Object.keys(ae).forEach((t) => {
|
|
22
|
+
e = e.replaceAll(t, "_");
|
|
23
|
+
}), "df_" + e;
|
|
24
|
+
}
|
|
25
|
+
return s.$xssName;
|
|
26
|
+
}, _e = (s) => {
|
|
27
|
+
let e = 0;
|
|
28
|
+
if (s.length == 0) return e;
|
|
29
|
+
for (let t = 0; t < s.length; t++) {
|
|
30
|
+
let i = s.charCodeAt(t);
|
|
31
|
+
e = (e << 5) - e + i, e = e & e;
|
|
32
|
+
}
|
|
33
|
+
return String(e).replaceAll(/-/g, "_");
|
|
34
|
+
}, je = (s) => s.renderType === "hidden", z = (s) => {
|
|
35
|
+
const e = document.createElement("template");
|
|
36
|
+
return e.innerHTML = s, e.content.firstElementChild;
|
|
37
|
+
};
|
|
38
|
+
function de(s) {
|
|
39
|
+
if (typeof s != "object" || s === null)
|
|
40
|
+
return !1;
|
|
41
|
+
let e = s;
|
|
42
|
+
for (; Object.getPrototypeOf(e) !== null; )
|
|
43
|
+
e = Object.getPrototypeOf(e);
|
|
44
|
+
return Object.getPrototypeOf(s) === e;
|
|
45
|
+
}
|
|
46
|
+
function ke(s) {
|
|
47
|
+
return typeof s == "object" && s !== null && !L(s);
|
|
48
|
+
}
|
|
49
|
+
function ze(s) {
|
|
50
|
+
return s instanceof Date && !isNaN(s.valueOf());
|
|
51
|
+
}
|
|
52
|
+
const he = (...s) => {
|
|
53
|
+
let e = s[0];
|
|
54
|
+
if (!de(e) || C(e))
|
|
55
|
+
return e;
|
|
56
|
+
let t = 1;
|
|
57
|
+
Object.keys(e).length > 0 && (t = 0, e = L(e) ? [] : {});
|
|
58
|
+
const i = s.length;
|
|
59
|
+
for (; t < i; t += 1)
|
|
60
|
+
G(e, s[t]);
|
|
61
|
+
return e;
|
|
62
|
+
};
|
|
63
|
+
function G(s, e) {
|
|
64
|
+
return ke(e) ? We(s, e) : L(e) ? Pe(s, e) : ze(e) ? new e.constructor(e) : e;
|
|
65
|
+
}
|
|
66
|
+
function We(s, e) {
|
|
67
|
+
if (be(e))
|
|
68
|
+
return e;
|
|
69
|
+
for (const t of Object.keys(e)) {
|
|
70
|
+
const i = e[t];
|
|
71
|
+
y(i) || (i === null || be(i) ? s[t] = i : C(s[t]) ? s[t] = G(L(i) ? [] : {}, i) : ke(i) ? G(s[t], i) : s[t] = i);
|
|
72
|
+
}
|
|
73
|
+
return s;
|
|
74
|
+
}
|
|
75
|
+
function Pe(s, e) {
|
|
76
|
+
const t = de(s);
|
|
77
|
+
for (let i = 0; i < e.length; i += 1) {
|
|
78
|
+
const l = e[i];
|
|
79
|
+
let n;
|
|
80
|
+
l == null ? n = l : n = G(L(l) ? [] : {}, l), t ? s[i] = n : s.push(n);
|
|
81
|
+
}
|
|
82
|
+
return s;
|
|
83
|
+
}
|
|
84
|
+
class f {
|
|
85
|
+
constructor(e, t, i) {
|
|
86
|
+
var l;
|
|
87
|
+
this.enableView = !0, this.daraForm = e, this.field = t, this.rowElement = i, this.createField(), t.tooltip && ((l = i.querySelector(".df-tooltip")) == null || l.setAttribute("tooltip", t.tooltip));
|
|
88
|
+
}
|
|
89
|
+
setDefaultInfo() {
|
|
90
|
+
if (y(this.field.defaultValue) ? this.setValue("", !1) : this.setValue(this.field.defaultValue, !1), !y(this.field.placeholder)) {
|
|
91
|
+
const e = this.getElement();
|
|
92
|
+
e instanceof Element && e.setAttribute("placeholder", this.field.placeholder);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
setDefaultOption() {
|
|
96
|
+
this.setDisabled(this.field.disabled ?? !1);
|
|
97
|
+
}
|
|
98
|
+
addChildField(e) {
|
|
99
|
+
var t;
|
|
100
|
+
(t = this.rowElement.querySelector(".df-field-container")) == null || t.append(e);
|
|
101
|
+
}
|
|
102
|
+
static isDataRender() {
|
|
103
|
+
return !0;
|
|
104
|
+
}
|
|
105
|
+
static isChildrenCreate() {
|
|
106
|
+
return !0;
|
|
107
|
+
}
|
|
108
|
+
getForm() {
|
|
109
|
+
return this.daraForm;
|
|
110
|
+
}
|
|
111
|
+
setValueItems(e) {
|
|
112
|
+
}
|
|
113
|
+
static getDescriptionTemplate(e) {
|
|
114
|
+
const t = e.descriptionClass ? Q(e.descriptionClass) : "", i = e.descriptionStyle ? 'style="' + Q(e.descriptionStyle) + '"' : "";
|
|
115
|
+
return e.description ? `<div class="df-description ${t}" ${i}>${e.description}</div>` : "";
|
|
116
|
+
}
|
|
117
|
+
changeEventCall(e, t, i, l) {
|
|
118
|
+
var n;
|
|
119
|
+
if (e.onChange) {
|
|
120
|
+
let a = {
|
|
121
|
+
field: e,
|
|
122
|
+
evt: t,
|
|
123
|
+
oldValue: e.$value,
|
|
124
|
+
value: l
|
|
125
|
+
};
|
|
126
|
+
if ((n = e.listItem) != null && n.list) {
|
|
127
|
+
let o = [];
|
|
128
|
+
const r = f.valuesValueKey(e);
|
|
129
|
+
for (let d of e.listItem.list) {
|
|
130
|
+
let h = d[r];
|
|
131
|
+
if (oe(l)) {
|
|
132
|
+
if (h == l) {
|
|
133
|
+
o.push(d);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
} else L(l) && l.includes(h) && o.push(d);
|
|
137
|
+
}
|
|
138
|
+
a.valueItems = o;
|
|
139
|
+
}
|
|
140
|
+
if (a.oldValue != a.value && e.onChange.call(null, a) === !1)
|
|
141
|
+
return i.setValue(e.$value, !1), !1;
|
|
142
|
+
e.$value = a.value;
|
|
143
|
+
}
|
|
144
|
+
this.daraForm.conditionCheck();
|
|
145
|
+
}
|
|
146
|
+
focus() {
|
|
147
|
+
this.getElement().focus();
|
|
148
|
+
}
|
|
149
|
+
isEnableView() {
|
|
150
|
+
return this.enableView;
|
|
151
|
+
}
|
|
152
|
+
show() {
|
|
153
|
+
this.enableView = !0, this.rowElement.classList.remove("df-hidden");
|
|
154
|
+
}
|
|
155
|
+
hide() {
|
|
156
|
+
this.enableView = !1, this.rowElement.classList.contains("df-hidden") || this.rowElement.classList.add("df-hidden");
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 설명 추가
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
* @param {string} desc
|
|
163
|
+
*/
|
|
164
|
+
setDescription(e) {
|
|
165
|
+
var i;
|
|
166
|
+
const t = this.rowElement.querySelector(".df-description");
|
|
167
|
+
if (t)
|
|
168
|
+
t.textContent = e;
|
|
169
|
+
else {
|
|
170
|
+
const l = this.rowElement.querySelector(".df-field");
|
|
171
|
+
if (l) {
|
|
172
|
+
const n = new DOMParser();
|
|
173
|
+
this.field.description = e;
|
|
174
|
+
const a = n.parseFromString(f.getDescriptionTemplate(this.field), "text/html").querySelector(".df-description");
|
|
175
|
+
a && ((i = l.parentNode) == null || i.insertBefore(a, l.nextSibling));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
setActive(e) {
|
|
180
|
+
}
|
|
181
|
+
setDisabled(e) {
|
|
182
|
+
this.getElement() instanceof HTMLElement && (e === !1 ? this.getElement().removeAttribute("disabled") : this.getElement().setAttribute("disabled", !0));
|
|
183
|
+
}
|
|
184
|
+
commonValidator() {
|
|
185
|
+
}
|
|
186
|
+
static valuesValueKey(e) {
|
|
187
|
+
var t;
|
|
188
|
+
return (t = e.listItem) != null && t.valueField ? e.listItem.valueField : "value";
|
|
189
|
+
}
|
|
190
|
+
static valuesLabelKey(e) {
|
|
191
|
+
var t;
|
|
192
|
+
return (t = e.listItem) != null && t.labelField ? e.listItem.labelField : "label";
|
|
193
|
+
}
|
|
194
|
+
static valuesLabelValue(e, t) {
|
|
195
|
+
let i = !1;
|
|
196
|
+
const l = e.replace(/\{\{([A-Za-z0-9_.]*)\}\}/g, (n, a) => (i = !0, t[a] || ""));
|
|
197
|
+
return i ? l : t[e] || "";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const Be = {
|
|
201
|
+
mobile: /^\d{3}-\d{3,4}-\d{4}$/,
|
|
202
|
+
email: /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
|
|
203
|
+
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*)?$/,
|
|
204
|
+
number: /\d$/,
|
|
205
|
+
alpha: /^[a-zA-Z]+$/,
|
|
206
|
+
"alpha-num": /^[a-zA-Z0-9]+$/,
|
|
207
|
+
variable: /^[a-zA-Z0-9_$][a-zA-Z0-9_$]*$/,
|
|
208
|
+
"number-char": /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]/,
|
|
209
|
+
"upper-char": /^(?=.*?[A-Z])(?=.*?[a-z])/,
|
|
210
|
+
"upper-char-special": /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$%^&*-])/,
|
|
211
|
+
"upper-char-special-number": /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]/
|
|
212
|
+
}, Ie = (s, e, t) => {
|
|
213
|
+
if (!e.$instance.isEnableView())
|
|
214
|
+
return { name: e.name, constraint: [] };
|
|
215
|
+
typeof t > "u" && (t = { name: e.name, constraint: [] });
|
|
216
|
+
const i = e.regexpType;
|
|
217
|
+
return i && !Be[i].test(s) && (t.regexp = i), t;
|
|
218
|
+
}, qe = (s, e, t) => {
|
|
219
|
+
if (e.validator && (t.validator = e.validator(e, s), typeof t.validator == "object") || (t = Ie(s, e, t), t.regexp))
|
|
220
|
+
return t;
|
|
221
|
+
if (e.different) {
|
|
222
|
+
const i = e.different.field, l = e.$instance.getForm().getField(i);
|
|
223
|
+
if (!C(l) && e.$instance.getValue() == l.$instance.getValue())
|
|
224
|
+
return t.message = e.different.message, t;
|
|
225
|
+
}
|
|
226
|
+
if (e.identical) {
|
|
227
|
+
const i = e.identical.field, l = e.$instance.getForm().getField(i);
|
|
228
|
+
if (!C(l) && e.$instance.getValue() != l.$instance.getValue())
|
|
229
|
+
return t.message = e.identical.message, t;
|
|
230
|
+
}
|
|
231
|
+
return !0;
|
|
232
|
+
}, ue = (s, e) => {
|
|
233
|
+
if (!e.$instance.isEnableView())
|
|
234
|
+
return !0;
|
|
235
|
+
const t = { name: e.name, constraint: [] }, i = Number(s);
|
|
236
|
+
if (e.required && D(s))
|
|
237
|
+
return t.constraint.push(v.REQUIRED), t;
|
|
238
|
+
if (!M(s))
|
|
239
|
+
return t.constraint.push(v.NAN), t;
|
|
240
|
+
if (qe(s, e, t) !== !0)
|
|
241
|
+
return t;
|
|
242
|
+
const l = e.rule;
|
|
243
|
+
if (l) {
|
|
244
|
+
const n = M(l.minimum), a = M(l.maximum);
|
|
245
|
+
let o = !1, r = !1, d = !1, h = !1;
|
|
246
|
+
n && (l.exclusiveMinimum && i <= l.minimum ? r = !0 : i < l.minimum && (o = !0)), a && (l.exclusiveMaximum && i >= l.maximum ? h = !0 : i > l.maximum && (d = !0)), n && a && (o || r || d || h) ? l.exclusiveMinimum && l.exclusiveMaximum && (r || h) ? t.constraint.push(v.BETWEEN_EXCLUSIVE_MINMAX) : r ? t.constraint.push(v.BETWEEN_EXCLUSIVE_MIN) : h ? t.constraint.push(v.BETWEEN_EXCLUSIVE_MAX) : t.constraint.push(v.BETWEEN) : (r && t.constraint.push(v.EXCLUSIVE_MIN), h && t.constraint.push(v.EXCLUSIVE_MAX), o && t.constraint.push(v.MIN), d && t.constraint.push(v.MAX));
|
|
247
|
+
}
|
|
248
|
+
return t.constraint.length > 0 ? t : !0;
|
|
249
|
+
}, $ = (s, e, t) => {
|
|
250
|
+
if (t === !0) {
|
|
251
|
+
e.classList.remove("invalid"), e.classList.contains("valid") || e.classList.add("valid");
|
|
252
|
+
const i = e.querySelector(".df-help-message");
|
|
253
|
+
i && (i.innerHTML = "");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (e.classList.remove("valid"), e.classList.contains("invalid") || e.classList.add("invalid"), t !== !1) {
|
|
257
|
+
const i = I.validMessage(s, t);
|
|
258
|
+
t.message && i.push(t.message);
|
|
259
|
+
const l = e.querySelector(".df-help-message");
|
|
260
|
+
if (l && i.length > 0) {
|
|
261
|
+
const n = [];
|
|
262
|
+
i.forEach((a) => {
|
|
263
|
+
n.push(`<div>${a}</div>`);
|
|
264
|
+
}), l.innerHTML = n.join("");
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}, b = (s) => {
|
|
268
|
+
s.classList.remove("invalid"), s.classList.remove("valid");
|
|
269
|
+
}, ce = (s, e, t) => {
|
|
270
|
+
e.addEventListener("input", (i) => {
|
|
271
|
+
q(s, i, t, t.getValue()), t.valid();
|
|
272
|
+
});
|
|
273
|
+
}, Xe = (s, e, t) => {
|
|
274
|
+
e.addEventListener("keyup", (i) => {
|
|
275
|
+
const l = i.target.value;
|
|
276
|
+
M(l) || (e.value = l.replace(/[^0-9\.\-\+]/g, ""), i.preventDefault()), q(s, i, t, t.getValue()), t.valid();
|
|
277
|
+
});
|
|
278
|
+
}, Ue = (s, e, t) => {
|
|
279
|
+
e.addEventListener("change", (i) => {
|
|
280
|
+
q(s, i, t, t.getValue()), t.valid();
|
|
281
|
+
});
|
|
282
|
+
}, q = (s, e, t, i) => {
|
|
283
|
+
t.changeEventCall(s, e, t, i);
|
|
284
|
+
};
|
|
285
|
+
class Ke extends f {
|
|
286
|
+
constructor(e, t, i) {
|
|
287
|
+
super(i, e, t), this.mounted(), this.setDefaultOption(), this.setDefaultInfo();
|
|
288
|
+
}
|
|
289
|
+
mounted() {
|
|
290
|
+
Xe(this.field, this.element, this);
|
|
291
|
+
}
|
|
292
|
+
createField() {
|
|
293
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
294
|
+
t.innerHTML = `
|
|
295
|
+
<div class="df-field">
|
|
296
|
+
<input type="text" name="${e.$xssName}" class="df-form-field df-number df-help-icon" />
|
|
297
|
+
</div>
|
|
298
|
+
${f.getDescriptionTemplate(e)}
|
|
299
|
+
<div class="df-help-message"></div>
|
|
300
|
+
`, this.element = t.querySelector(`[name="${e.$xssName}"]`);
|
|
301
|
+
}
|
|
302
|
+
getValue() {
|
|
303
|
+
return this.element.value;
|
|
304
|
+
}
|
|
305
|
+
setValue(e, t) {
|
|
306
|
+
if (t !== !1 && this.changeEventCall(this.field, null, this, e) === !1) {
|
|
307
|
+
this.element.value = this.field.$value;
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
this.field.$value = e, this.element.value = e;
|
|
311
|
+
}
|
|
312
|
+
reset() {
|
|
313
|
+
this.setDefaultInfo(), this.setDisabled(!1), b(this.rowElement);
|
|
314
|
+
}
|
|
315
|
+
getElement() {
|
|
316
|
+
return this.element;
|
|
317
|
+
}
|
|
318
|
+
valid() {
|
|
319
|
+
const e = ue(this.getValue(), this.field);
|
|
320
|
+
return $(this.field, this.rowElement, e), e;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const R = (s, e) => {
|
|
324
|
+
if (!e.$instance.isEnableView())
|
|
325
|
+
return !0;
|
|
326
|
+
let t = { name: e.name, constraint: [] };
|
|
327
|
+
if (e.required && D(s))
|
|
328
|
+
return t.constraint.push(v.REQUIRED), t;
|
|
329
|
+
const i = qe(s, e, t);
|
|
330
|
+
if (i !== !0)
|
|
331
|
+
return i;
|
|
332
|
+
const l = e.rule;
|
|
333
|
+
if (l) {
|
|
334
|
+
const n = s.length, a = M(l.minLength), o = M(l.maxLength);
|
|
335
|
+
let r = !1, d = !1;
|
|
336
|
+
if (a && n < l.minLength && (r = !0), o && n > l.maxLength && (d = !0), a && o && (r || d) ? t.constraint.push(v.BETWEEN) : (r && t.constraint.push(v.MIN_LENGTH), d && t.constraint.push(v.MAX_LENGTH)), t.constraint.length > 0)
|
|
337
|
+
return t;
|
|
338
|
+
}
|
|
339
|
+
return !0;
|
|
340
|
+
};
|
|
341
|
+
class Ze extends f {
|
|
342
|
+
constructor(e, t, i) {
|
|
343
|
+
super(i, e, t), this.mounted(), this.setDefaultOption(), this.setDefaultInfo();
|
|
344
|
+
}
|
|
345
|
+
mounted() {
|
|
346
|
+
ce(this.field, this.element, this);
|
|
347
|
+
}
|
|
348
|
+
createField() {
|
|
349
|
+
var l;
|
|
350
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
351
|
+
let i = (l = e.rendererOptions) == null ? void 0 : l.rows;
|
|
352
|
+
i = +i > 0 ? i : 3, t.innerHTML = `
|
|
353
|
+
<div class="df-field">
|
|
354
|
+
<textarea name="${e.$xssName}" rows="${i}" class="df-form-field df-textarea df-help-icon"></textarea>
|
|
355
|
+
</div>
|
|
356
|
+
${f.getDescriptionTemplate(e)}
|
|
357
|
+
<div class="df-help-message"></div>
|
|
358
|
+
`, this.element = t.querySelector(`[name="${e.$xssName}"]`);
|
|
359
|
+
}
|
|
360
|
+
getValue() {
|
|
361
|
+
return this.element.value;
|
|
362
|
+
}
|
|
363
|
+
setValue(e, t) {
|
|
364
|
+
if (t !== !1 && this.changeEventCall(this.field, null, this, e) === !1) {
|
|
365
|
+
this.element.value = this.field.$value;
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
this.field.$value = e, this.element.value = e;
|
|
369
|
+
}
|
|
370
|
+
reset() {
|
|
371
|
+
this.setDefaultInfo(), this.setDisabled(!1), b(this.rowElement);
|
|
372
|
+
}
|
|
373
|
+
getElement() {
|
|
374
|
+
return this.element;
|
|
375
|
+
}
|
|
376
|
+
valid() {
|
|
377
|
+
const e = R(this.getValue(), this.field);
|
|
378
|
+
return $(this.field, this.rowElement, e), e;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
class fe extends f {
|
|
382
|
+
constructor(e, t, i) {
|
|
383
|
+
var o, r, d, h, u;
|
|
384
|
+
super(i, e, t);
|
|
385
|
+
let l = "";
|
|
386
|
+
y(e.defaultValue) || (l = e.defaultValue);
|
|
387
|
+
const n = fe.valuesValueKey(e);
|
|
388
|
+
let a = !1;
|
|
389
|
+
(r = (o = this.field.listItem) == null ? void 0 : o.list) == null || r.forEach((c) => {
|
|
390
|
+
let p = c[n];
|
|
391
|
+
c.selected && (this.defaultSelected = p), p == l && (a = !0);
|
|
392
|
+
}), a ? this.defaultSelected = l : 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][n] || ""), y(this.defaultSelected) && (this.defaultSelected = ""), this.mounted(), this.setDefaultOption(), this.setValue(this.defaultSelected, !1);
|
|
393
|
+
}
|
|
394
|
+
mounted() {
|
|
395
|
+
Ue(this.field, this.element, this);
|
|
396
|
+
}
|
|
397
|
+
createField() {
|
|
398
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
399
|
+
let i = ` <div class="df-field"><select name="${e.$xssName}" class="df-form-field df-dropdown">
|
|
400
|
+
${this.dropdownValuesTemplate(e)}
|
|
401
|
+
</select> <i class="df-help-icon"></i></div>
|
|
402
|
+
${f.getDescriptionTemplate(e)}
|
|
403
|
+
<div class="df-help-message"></div>
|
|
404
|
+
`;
|
|
405
|
+
t.innerHTML = i, this.element = t.querySelector(`[name="${e.$xssName}"]`);
|
|
406
|
+
}
|
|
407
|
+
setValueItems(e) {
|
|
408
|
+
if (this.field.listItem ? this.field.listItem.list = e : this.field.listItem = {
|
|
409
|
+
list: e
|
|
410
|
+
}, this.element.innerHTML = this.dropdownValuesTemplate(this.field), !D(this.field.$value)) {
|
|
411
|
+
const t = this.field.$value;
|
|
412
|
+
this.field.$value = "", this.setValue(t);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
getValue() {
|
|
416
|
+
return this.element.value;
|
|
417
|
+
}
|
|
418
|
+
setValue(e, t) {
|
|
419
|
+
if (t !== !1 && this.changeEventCall(this.field, null, this, e) === !1) {
|
|
420
|
+
this.element.value = this.field.$value;
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
this.field.$value = e, this.element.value = e;
|
|
424
|
+
}
|
|
425
|
+
reset() {
|
|
426
|
+
this.setValue(this.defaultSelected, !1), this.setDisabled(!1), b(this.rowElement);
|
|
427
|
+
}
|
|
428
|
+
getElement() {
|
|
429
|
+
return this.element;
|
|
430
|
+
}
|
|
431
|
+
valid() {
|
|
432
|
+
const e = this.getValue();
|
|
433
|
+
let t = !0;
|
|
434
|
+
return this.field.required && e.length < 1 && (t = { name: this.field.name, constraint: [] }, t.constraint.push(v.REQUIRED)), $(this.field, this.rowElement, t), t;
|
|
435
|
+
}
|
|
436
|
+
dropdownValuesTemplate(e) {
|
|
437
|
+
var n, a, o;
|
|
438
|
+
const t = f.valuesLabelKey(e), i = f.valuesValueKey(e);
|
|
439
|
+
let l = "";
|
|
440
|
+
return ((n = e.rendererOptions) == null ? void 0 : n.disableDefaultOption) !== !0 && (l += `<option value="">${I.getMessage("selection")}</option>`), (o = (a = e.listItem) == null ? void 0 : a.list) == null || o.forEach((r) => {
|
|
441
|
+
const d = `${r.selected ? "selected" : ""} ${r.disabled ? "disabled" : ""}`;
|
|
442
|
+
y(r[i]) && r.label ? l += `<option value="${r.value || ""}" ${d}>${r.label}</option>` : l += `<option value="${r[i]}" ${d}>${f.valuesLabelValue(t, r)}</option>`;
|
|
443
|
+
}), l;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
class Qe extends f {
|
|
447
|
+
constructor(e, t, i) {
|
|
448
|
+
super(i, e, t), this.mounted(), this.setDefaultOption(), this.setDefaultInfo();
|
|
449
|
+
}
|
|
450
|
+
mounted() {
|
|
451
|
+
ce(this.field, this.element, this);
|
|
452
|
+
}
|
|
453
|
+
createField() {
|
|
454
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
455
|
+
t.innerHTML = `
|
|
456
|
+
<div class="df-field">
|
|
457
|
+
<input type="text" name="${e.$xssName}" class="df-form-field df-text df-help-icon" />
|
|
458
|
+
</div>
|
|
459
|
+
${f.getDescriptionTemplate(e)}
|
|
460
|
+
<div class="df-help-message"></div>
|
|
461
|
+
`, this.element = t.querySelector(`[name="${e.$xssName}"]`);
|
|
462
|
+
}
|
|
463
|
+
getValue() {
|
|
464
|
+
return this.element.value;
|
|
465
|
+
}
|
|
466
|
+
setValue(e, t) {
|
|
467
|
+
if (t !== !1 && this.changeEventCall(this.field, null, this, e) === !1) {
|
|
468
|
+
this.element.value = this.field.$value;
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
this.field.$value = e, this.element.value = e;
|
|
472
|
+
}
|
|
473
|
+
reset() {
|
|
474
|
+
this.setDefaultInfo(), this.setDisabled(!1), b(this.rowElement);
|
|
475
|
+
}
|
|
476
|
+
getElement() {
|
|
477
|
+
return this.element;
|
|
478
|
+
}
|
|
479
|
+
valid() {
|
|
480
|
+
const e = R(this.getValue(), this.field);
|
|
481
|
+
return $(this.field, this.rowElement, e), e;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function A(s, e, t, i) {
|
|
485
|
+
var c, p, x, V, T, W, ve, ye, Ee;
|
|
486
|
+
const l = {
|
|
487
|
+
rowStyleClass: me(e.orientation),
|
|
488
|
+
fieldClass: "",
|
|
489
|
+
fieldStyle: "",
|
|
490
|
+
labelClass: "",
|
|
491
|
+
labelStyle: "",
|
|
492
|
+
labelAlignClass: "",
|
|
493
|
+
valueClass: "",
|
|
494
|
+
valueStyle: "",
|
|
495
|
+
tabAlignClass: ""
|
|
496
|
+
}, n = ((c = t == null ? void 0 : t.style) == null ? void 0 : c.labelWidth) ?? s.style.labelWidth ?? "3";
|
|
497
|
+
let a = ((p = t == null ? void 0 : t.style) == null ? void 0 : p.valueWidth) ?? s.style.valueWidth ?? "9";
|
|
498
|
+
const o = ((x = t == null ? void 0 : t.style) == null ? void 0 : x.position) ?? s.style.position, r = (V = e.style) == null ? void 0 : V.width, d = F[(T = e.style) == null ? void 0 : T.position] ?? F[o] ?? F.top;
|
|
499
|
+
l.fieldClass = `${d[0] ? "df-" + d[0] : ""} ${((W = e.style) == null ? void 0 : W.customClass) || ""}`, r && (M(r) ? l.fieldClass += M(r) ? ` df-col-xs-${r}` : "" : l.fieldStyle = M(r) ? "" : `width:${r};`), l.tabAlignClass = "df-tab-al-" + (["right", "center"].includes((ve = e.style) == null ? void 0 : ve.tabAlign) ? e.style.tabAlign : "left");
|
|
500
|
+
const h = ((ye = e.style) == null ? void 0 : ye.labelWidth) || n;
|
|
501
|
+
if (l.labelAlignClass = d[1], !i && h && !["top", "bottom"].includes(d[0]))
|
|
502
|
+
if (M(h)) {
|
|
503
|
+
const $e = +h;
|
|
504
|
+
a = 12 - $e, l.labelClass = `df-col-xs-${$e}`, l.valueClass = l.labelStyle ? "df-col-full" : `df-col-xs-${a}`;
|
|
505
|
+
} else
|
|
506
|
+
l.labelStyle = `width:${h};`;
|
|
507
|
+
const u = ((Ee = e.style) == null ? void 0 : Ee.valueWidth) || a;
|
|
508
|
+
return i && !["left", "right"].includes(d[0]) ? l.valueClass = "df-col-full" : u && !["top", "bottom"].includes(d[0]) ? M(u) ? l.valueClass = l.labelStyle ? "df-col-full" : `df-col-xs-${u}` : l.valueStyle = `width:${u};` : l.valueClass = l.labelStyle ? "df-col-full" : "", l.fieldClass = se(l.fieldClass), l.labelClass = se(l.labelClass), l.valueClass = se(l.valueClass), l;
|
|
509
|
+
}
|
|
510
|
+
function me(s) {
|
|
511
|
+
return s === "horizontal" ? "df-horizontal" : "df-vertical";
|
|
512
|
+
}
|
|
513
|
+
function se(s) {
|
|
514
|
+
return s.replace(/\s+/g, " ").trim();
|
|
515
|
+
}
|
|
516
|
+
class pe extends f {
|
|
517
|
+
constructor(e, t, i) {
|
|
518
|
+
var o, r;
|
|
519
|
+
super(i, e, t), this.defaultCheckValue = [], this.defaultCheckValue = [];
|
|
520
|
+
let l = [];
|
|
521
|
+
y(e.defaultValue) || (L(e.defaultValue) ? l = e.defaultValue : l = [e.defaultValue]);
|
|
522
|
+
const n = pe.valuesValueKey(e);
|
|
523
|
+
y(this.field.listItem) && this.setValueItems([{ label: "", value: "Y" }]);
|
|
524
|
+
let a = !1;
|
|
525
|
+
(r = (o = this.field.listItem) == null ? void 0 : o.list) == null || r.forEach((d) => {
|
|
526
|
+
let h = d[n];
|
|
527
|
+
d.selected && this.defaultCheckValue.push(h || !0), l.includes(h) && (a = !0);
|
|
528
|
+
}), this.defaultCheckValue = a ? l : this.defaultCheckValue, this.mounted(), this.setDefaultOption(), this.setValue(this.defaultCheckValue, !1);
|
|
529
|
+
}
|
|
530
|
+
mounted() {
|
|
531
|
+
this.initEvent();
|
|
532
|
+
}
|
|
533
|
+
initEvent() {
|
|
534
|
+
this.rowElement.querySelectorAll(this.getSelector()).forEach((t) => {
|
|
535
|
+
t.addEventListener("change", (i) => {
|
|
536
|
+
q(this.field, i, this, this.getValue()), this.valid();
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
getSelector() {
|
|
541
|
+
return `input[type="checkbox"][name="${this.field.$xssName}"]`;
|
|
542
|
+
}
|
|
543
|
+
createField() {
|
|
544
|
+
var o, r;
|
|
545
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container"), i = [], l = e.$xssName, n = f.valuesLabelKey(e), a = f.valuesValueKey(e);
|
|
546
|
+
i.push(' <div class="df-field"><div class="df-field-group">'), (r = (o = e.listItem) == null ? void 0 : o.list) == null || r.forEach((d) => {
|
|
547
|
+
const h = d[a];
|
|
548
|
+
i.push(`
|
|
549
|
+
<span class="df-field-item ${me(e.listItem.orientation ?? Ae.horizontal)}">
|
|
550
|
+
<label>
|
|
551
|
+
<input type="checkbox" name="${l}" value="${h ? Q(h) : ""}" class="df-form-field df-checkbox" ${d.selected ? "checked" : ""} ${d.disabled ? "disabled" : ""} />
|
|
552
|
+
${f.valuesLabelValue(n, d)}
|
|
553
|
+
</label>
|
|
554
|
+
</span>
|
|
555
|
+
`);
|
|
556
|
+
}), 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("");
|
|
557
|
+
}
|
|
558
|
+
setValueItems(e) {
|
|
559
|
+
if (this.rowElement.querySelector(".df-field-container") && (this.field.listItem ? this.field.listItem.list = e : this.field.listItem = {
|
|
560
|
+
list: e
|
|
561
|
+
}, this.createField(), !D(this.field.$value))) {
|
|
562
|
+
const i = this.field.$value;
|
|
563
|
+
this.field.$value = "", this.setValue(i);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
getValue() {
|
|
567
|
+
const e = this.rowElement.querySelectorAll(this.getSelector());
|
|
568
|
+
if (e.length > 1) {
|
|
569
|
+
const t = [];
|
|
570
|
+
return e.forEach((i) => {
|
|
571
|
+
const l = i;
|
|
572
|
+
l.checked && t.push(l.value);
|
|
573
|
+
}), t;
|
|
574
|
+
} else {
|
|
575
|
+
const t = this.rowElement.querySelector(`[name="${this.field.$xssName}"]`);
|
|
576
|
+
return t != null && t.checked ? t.value ? t.value : !0 : t.value ? "" : !1;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
setValue(e, t) {
|
|
580
|
+
if (t !== !1 && this.changeEventCall(this.field, null, this, e) === !1 && (e = this.field.$value), this.field.$value = e, e === !0) {
|
|
581
|
+
this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked = !0;
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
if (e === !1) {
|
|
585
|
+
this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked = !1;
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
let i = [];
|
|
589
|
+
L(e) ? i = e : i.push(e), this.rowElement.querySelectorAll(this.getSelector()).forEach((n) => {
|
|
590
|
+
n.checked = !1;
|
|
591
|
+
}), i.forEach((n) => {
|
|
592
|
+
const a = this.rowElement.querySelector(`[name="${this.field.$xssName}"][value="${n}"]`);
|
|
593
|
+
a && (a.checked = !0);
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
reset() {
|
|
597
|
+
var e, t;
|
|
598
|
+
((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);
|
|
599
|
+
}
|
|
600
|
+
getElement() {
|
|
601
|
+
return this.rowElement.querySelectorAll(`[name="${this.field.$xssName}"]`);
|
|
602
|
+
}
|
|
603
|
+
focus() {
|
|
604
|
+
const e = this.getElement();
|
|
605
|
+
e && e.length > 0 && this.getElement()[0].focus();
|
|
606
|
+
}
|
|
607
|
+
valid() {
|
|
608
|
+
const e = this.getValue();
|
|
609
|
+
let t = !0;
|
|
610
|
+
return this.field.required && L(e) && e.length < 1 && (t = { name: this.field.name, constraint: [] }, t.constraint.push(v.REQUIRED)), $(this.field, this.rowElement, t), t;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
class ge extends f {
|
|
614
|
+
constructor(e, t, i) {
|
|
615
|
+
var o, r, d, h, u;
|
|
616
|
+
super(i, e, t), this.defaultCheckValue = "";
|
|
617
|
+
let l = [];
|
|
618
|
+
y(e.defaultValue) || (l = e.defaultValue);
|
|
619
|
+
const n = ge.valuesValueKey(e);
|
|
620
|
+
let a = !1;
|
|
621
|
+
(r = (o = this.field.listItem) == null ? void 0 : o.list) == null || r.forEach((c) => {
|
|
622
|
+
let p = c[n];
|
|
623
|
+
c.selected && (this.defaultCheckValue = p), l == p && (a = !0);
|
|
624
|
+
}), a ? this.defaultCheckValue = l : 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][n] : ""), this.mounted(), this.setDefaultOption(), this.setValue(this.defaultCheckValue, !1);
|
|
625
|
+
}
|
|
626
|
+
mounted() {
|
|
627
|
+
this.initEvent();
|
|
628
|
+
}
|
|
629
|
+
initEvent() {
|
|
630
|
+
this.rowElement.querySelectorAll(this.getSelector()).forEach((t) => {
|
|
631
|
+
t.addEventListener("change", (i) => {
|
|
632
|
+
q(this.field, i, this, this.getValue()), this.valid();
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
getSelector() {
|
|
637
|
+
return `input[type="radio"][name="${this.field.$xssName}"]`;
|
|
638
|
+
}
|
|
639
|
+
createField() {
|
|
640
|
+
var o, r;
|
|
641
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container"), i = [], l = e.$xssName, n = f.valuesLabelKey(e), a = f.valuesValueKey(e);
|
|
642
|
+
i.push('<div class="df-field"><div class="df-field-group">'), (r = (o = e.listItem) == null ? void 0 : o.list) == null || r.forEach((d) => {
|
|
643
|
+
const h = d[a];
|
|
644
|
+
i.push(
|
|
645
|
+
`<span class="df-field-item ${me(e.orientation ?? Ae.horizontal)}">
|
|
646
|
+
<label>
|
|
647
|
+
<input type="radio" name="${l}" value="${h}" class="df-form-field df-radio" ${d.selected ? "checked" : ""} ${d.disabled ? "disabled" : ""}/>
|
|
648
|
+
${f.valuesLabelValue(n, d)}
|
|
649
|
+
</label>
|
|
650
|
+
</span>
|
|
651
|
+
`
|
|
652
|
+
);
|
|
653
|
+
}), i.push(`<i class="df-form-icon df-help-icon"></i></div></div>
|
|
654
|
+
${f.getDescriptionTemplate(e)}
|
|
655
|
+
<div class="df-help-message"></div>
|
|
656
|
+
`), t.innerHTML = i.join(""), this.initEvent();
|
|
657
|
+
}
|
|
658
|
+
setValueItems(e) {
|
|
659
|
+
if (this.rowElement.querySelector(".df-field-container") && (this.field.listItem ? this.field.listItem.list = e : this.field.listItem = {
|
|
660
|
+
list: e
|
|
661
|
+
}, this.createField(), !D(this.field.$value))) {
|
|
662
|
+
const i = this.field.$value;
|
|
663
|
+
this.field.$value = "", this.setValue(i);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
getValue() {
|
|
667
|
+
var e;
|
|
668
|
+
return (e = this.rowElement.querySelector(`[name="${this.field.$xssName}"]:checked`)) == null ? void 0 : e.value;
|
|
669
|
+
}
|
|
670
|
+
setValue(e, t) {
|
|
671
|
+
if (t !== !1 && this.changeEventCall(this.field, null, this, e) === !1 && (e = this.field.$value), this.field.$value = e, e === !0) {
|
|
672
|
+
this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked = !0;
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (e === !1) {
|
|
676
|
+
this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked = !1;
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
this.rowElement.querySelectorAll(this.getSelector()).forEach((l) => {
|
|
680
|
+
let n = l;
|
|
681
|
+
n.value == e ? n.checked = !0 : n.checked = !1;
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
reset() {
|
|
685
|
+
this.setValue(this.defaultCheckValue, !1), this.setDisabled(!1), b(this.rowElement);
|
|
686
|
+
}
|
|
687
|
+
getElement() {
|
|
688
|
+
return this.rowElement.querySelectorAll(this.getSelector());
|
|
689
|
+
}
|
|
690
|
+
focus() {
|
|
691
|
+
const e = this.getElement();
|
|
692
|
+
e && e.length > 0 && this.getElement()[0].focus();
|
|
693
|
+
}
|
|
694
|
+
valid() {
|
|
695
|
+
const e = this.getValue();
|
|
696
|
+
let t = !0;
|
|
697
|
+
return this.field.required && D(e) && (t = { name: this.field.name, constraint: [] }, t.constraint.push(v.REQUIRED)), $(this.field, this.rowElement, t), t;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
class Ge extends f {
|
|
701
|
+
constructor(e, t, i) {
|
|
702
|
+
super(i, e, t), this.mounted(), this.setDefaultOption(), this.setDefaultInfo();
|
|
703
|
+
}
|
|
704
|
+
mounted() {
|
|
705
|
+
ce(this.field, this.element, this);
|
|
706
|
+
}
|
|
707
|
+
createField() {
|
|
708
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
709
|
+
t.innerHTML = `
|
|
710
|
+
<div class="df-field">
|
|
711
|
+
<input type="password" name="${e.$xssName}" class="df-form-field df-password df-help-icon" autocomplete="off" />
|
|
712
|
+
</div>
|
|
713
|
+
${f.getDescriptionTemplate(e)}
|
|
714
|
+
<div class="df-help-message"></div>
|
|
715
|
+
`, this.element = t.querySelector(`[name="${e.$xssName}"]`);
|
|
716
|
+
}
|
|
717
|
+
getValue() {
|
|
718
|
+
return this.element.value;
|
|
719
|
+
}
|
|
720
|
+
setValue(e, t) {
|
|
721
|
+
if (t !== !1 && this.changeEventCall(this.field, null, this, e) === !1) {
|
|
722
|
+
this.element.value = this.field.$value;
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
this.field.$value = e, this.element.value = e;
|
|
726
|
+
}
|
|
727
|
+
reset() {
|
|
728
|
+
this.setDefaultInfo(), this.setDisabled(!1), b(this.rowElement);
|
|
729
|
+
}
|
|
730
|
+
getElement() {
|
|
731
|
+
return this.element;
|
|
732
|
+
}
|
|
733
|
+
valid() {
|
|
734
|
+
const e = R(this.getValue(), this.field);
|
|
735
|
+
return $(this.field, this.rowElement, e), e;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
const Je = (s, e, t) => {
|
|
739
|
+
const i = { name: e.name, constraint: [] };
|
|
740
|
+
return e.required && t.length < 1 ? (i.constraint.push(v.REQUIRED), i) : i.constraint.length > 0 ? i : !0;
|
|
741
|
+
};
|
|
742
|
+
class et extends f {
|
|
743
|
+
constructor(e, t, i) {
|
|
744
|
+
var l;
|
|
745
|
+
super(i, e, t), this.removeIds = [], this.uploadFiles = {}, this.fileList = [], this.fileSeq = 0, this.element = t.querySelector(`[name="${e.$xssName}"]`), this.fileList = ((l = e.listItem) == null ? void 0 : l.list) || [], this.mounted(), this.setDefaultOption();
|
|
746
|
+
}
|
|
747
|
+
mounted() {
|
|
748
|
+
this.element.addEventListener("change", (e) => {
|
|
749
|
+
var i;
|
|
750
|
+
const t = (i = e.target) == null ? void 0 : i.files;
|
|
751
|
+
if (t) {
|
|
752
|
+
let l = [];
|
|
753
|
+
for (let n of t)
|
|
754
|
+
l.push(n);
|
|
755
|
+
this.addFiles(l);
|
|
756
|
+
}
|
|
757
|
+
q(this.field, e, this, this.fileList), this.valid();
|
|
758
|
+
}), this.fileList.forEach((e) => {
|
|
759
|
+
e.$seq = this.fileSeq += 1;
|
|
760
|
+
}), this.setFileList(this.fileList);
|
|
761
|
+
}
|
|
762
|
+
createField() {
|
|
763
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
764
|
+
t.innerHTML = `
|
|
765
|
+
<div class="df-field">
|
|
766
|
+
<span class="df-file-wrapper">
|
|
767
|
+
<label class="df-file-label">
|
|
768
|
+
<input type="file" name="${e.$xssName}" class="df-form-field df-file" multiple />
|
|
769
|
+
${I.getMessage("fileButton")}
|
|
770
|
+
</label>
|
|
771
|
+
<i class="df-form-icon df-help-icon"></i>
|
|
772
|
+
</span>
|
|
773
|
+
</div>
|
|
774
|
+
${f.getDescriptionTemplate(e)}
|
|
775
|
+
<div class="df-file-list"></div>
|
|
776
|
+
<div class="df-help-message"></div>
|
|
777
|
+
`, this.element = t.querySelector(`[name="${e.$xssName}"]`);
|
|
778
|
+
}
|
|
779
|
+
addFiles(e) {
|
|
780
|
+
let t = !1;
|
|
781
|
+
const i = [];
|
|
782
|
+
for (let l of e) {
|
|
783
|
+
if (this.fileList.filter((o) => o.fileName == l.name && o.fileSize == l.size && o.lastModified == l.lastModified).length > 0) continue;
|
|
784
|
+
this.fileSeq += 1, this.uploadFiles[this.fileSeq] = l;
|
|
785
|
+
let a = {
|
|
786
|
+
fileName: l.name,
|
|
787
|
+
$seq: this.fileSeq,
|
|
788
|
+
fileSize: l.size,
|
|
789
|
+
lastModified: l.lastModified
|
|
790
|
+
};
|
|
791
|
+
i.push(a), t = !0;
|
|
792
|
+
}
|
|
793
|
+
t && (this.setFileList(i), this.fileList.push(...i));
|
|
794
|
+
}
|
|
795
|
+
setFileList(e, t) {
|
|
796
|
+
const i = this.rowElement.querySelector(".df-file-list");
|
|
797
|
+
if (i) {
|
|
798
|
+
t === !0 && (i.innerHTML = "");
|
|
799
|
+
const l = [];
|
|
800
|
+
e.forEach((n) => {
|
|
801
|
+
l.push(`
|
|
802
|
+
<div class="df-file-item" data-seq="${n.$seq}">
|
|
803
|
+
${n.fileId ? '<span class="df-file-icon df-file-download"></span>' : '<span class="df-file-icon"></span>'} <span class="df-file-icon df-file-remove"></span>
|
|
804
|
+
<span class="df-file-name">${n.fileName}</span >
|
|
805
|
+
</div>`);
|
|
806
|
+
}), i.insertAdjacentHTML("beforeend", l.join("")), e.forEach((n) => {
|
|
807
|
+
this.removeFileEvent(n, i), this.downloadFileEvent(n, i);
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* 파일 다운로드 이벤트 처리.
|
|
813
|
+
*
|
|
814
|
+
* @param item
|
|
815
|
+
* @param fileListElement
|
|
816
|
+
*/
|
|
817
|
+
downloadFileEvent(e, t) {
|
|
818
|
+
const i = t.querySelector(`[data-seq="${e.$seq}"] .df-file-download`);
|
|
819
|
+
i && i.addEventListener("click", (l) => {
|
|
820
|
+
const n = l.target.closest(".df-file-item");
|
|
821
|
+
if (n) {
|
|
822
|
+
const a = n.getAttribute("data-seq");
|
|
823
|
+
if (a) {
|
|
824
|
+
const o = parseInt(a, 10), r = this.fileList.findIndex((h) => h.$seq === o), d = this.fileList[r];
|
|
825
|
+
if (d.url) {
|
|
826
|
+
location.href = d.url;
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if (this.field.fileDownload) {
|
|
830
|
+
this.field.fileDownload.call(null, { file: d, field: this.field });
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* 파일 삭제 처리.
|
|
839
|
+
*
|
|
840
|
+
* @param item
|
|
841
|
+
* @param fileListElement
|
|
842
|
+
*/
|
|
843
|
+
removeFileEvent(e, t) {
|
|
844
|
+
const i = t.querySelector(`[data-seq="${e.$seq}"] .df-file-remove`);
|
|
845
|
+
i && i.addEventListener("click", (l) => {
|
|
846
|
+
const n = l.target.closest(".df-file-item");
|
|
847
|
+
if (n) {
|
|
848
|
+
const a = n.getAttribute("data-seq");
|
|
849
|
+
if (a) {
|
|
850
|
+
const o = parseInt(a, 10), r = this.fileList.findIndex((h) => h.$seq === o), d = this.fileList[r];
|
|
851
|
+
this.fileList.splice(r, 1), delete this.uploadFiles[o], n.remove(), d.fileId && this.removeIds.push(d.fileId);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
this.valid();
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
getValue() {
|
|
858
|
+
return {
|
|
859
|
+
uploadFile: Object.values(this.uploadFiles),
|
|
860
|
+
removeIds: this.removeIds
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
setValueItems(e) {
|
|
864
|
+
this.fileList = [], this.uploadFiles = [], this.removeIds = [];
|
|
865
|
+
for (let t of e)
|
|
866
|
+
t.$seq = this.fileSeq += 1, this.fileList.push(t);
|
|
867
|
+
this.setFileList(this.fileList, !0);
|
|
868
|
+
}
|
|
869
|
+
setValue(e) {
|
|
870
|
+
Se(e) && this.setValueItems(e), this.element.value = "";
|
|
871
|
+
}
|
|
872
|
+
reset() {
|
|
873
|
+
this.setValue(""), this.setValueItems([]), b(this.rowElement);
|
|
874
|
+
}
|
|
875
|
+
getElement() {
|
|
876
|
+
return this.element;
|
|
877
|
+
}
|
|
878
|
+
valid() {
|
|
879
|
+
const e = Je(this.element, this.field, this.fileList);
|
|
880
|
+
return $(this.field, this.rowElement, e), e;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
class tt extends f {
|
|
884
|
+
constructor(e, t, i) {
|
|
885
|
+
super(i, e, t), e.renderer ? (this.customFunction = e.renderer, this.mounted(), this.setDefaultOption(), this.setDefaultInfo()) : this.customFunction = {};
|
|
886
|
+
}
|
|
887
|
+
mounted() {
|
|
888
|
+
this.customFunction.mounted && this.customFunction.mounted.call(this, this.field, this.rowElement);
|
|
889
|
+
}
|
|
890
|
+
static isDataRender() {
|
|
891
|
+
return !1;
|
|
892
|
+
}
|
|
893
|
+
createField() {
|
|
894
|
+
const e = this.field, t = C(e.template) ? "" : oe(e.template) ? e.template : e.template(), i = this.rowElement.querySelector(".df-field-container");
|
|
895
|
+
i.innerHTML = ` <div class="df-field">
|
|
896
|
+
${t}
|
|
897
|
+
</div>
|
|
898
|
+
${f.getDescriptionTemplate(e)}
|
|
899
|
+
<div class="df-help-message"></div>`;
|
|
900
|
+
}
|
|
901
|
+
getValue() {
|
|
902
|
+
return this.customFunction.getValue ? this.customFunction.getValue.call(this, this.field, this.rowElement) : "";
|
|
903
|
+
}
|
|
904
|
+
setValue(e, t) {
|
|
905
|
+
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;
|
|
906
|
+
}
|
|
907
|
+
reset() {
|
|
908
|
+
this.setDefaultInfo(), b(this.rowElement);
|
|
909
|
+
}
|
|
910
|
+
getElement() {
|
|
911
|
+
return this.customFunction.getElement ? this.customFunction.getElement.call(this, this.field, this.rowElement) : null;
|
|
912
|
+
}
|
|
913
|
+
valid() {
|
|
914
|
+
if (this.customFunction.valid) {
|
|
915
|
+
const t = this.customFunction.valid.call(this, this.field, this.rowElement);
|
|
916
|
+
$(this.field, this.rowElement, t);
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
const e = R(this.getValue(), this.field);
|
|
920
|
+
return $(this.field, this.rowElement, e), e;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* focus
|
|
924
|
+
*/
|
|
925
|
+
focus() {
|
|
926
|
+
this.customFunction.focus && this.customFunction.focus.call(this, this.field, this.rowElement);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
class it extends f {
|
|
930
|
+
constructor(e, t, i) {
|
|
931
|
+
super(i, e, t);
|
|
932
|
+
}
|
|
933
|
+
mounted() {
|
|
934
|
+
}
|
|
935
|
+
static isDataRender() {
|
|
936
|
+
return !1;
|
|
937
|
+
}
|
|
938
|
+
createField() {
|
|
939
|
+
return "";
|
|
940
|
+
}
|
|
941
|
+
getValue() {
|
|
942
|
+
return null;
|
|
943
|
+
}
|
|
944
|
+
setValue(e) {
|
|
945
|
+
}
|
|
946
|
+
reset() {
|
|
947
|
+
}
|
|
948
|
+
getElement() {
|
|
949
|
+
return this.rowElement;
|
|
950
|
+
}
|
|
951
|
+
valid() {
|
|
952
|
+
return !0;
|
|
953
|
+
}
|
|
954
|
+
addChildField(e) {
|
|
955
|
+
let t = this.rowElement.querySelector(".df-field-container");
|
|
956
|
+
t ? t.append(e) : this.rowElement.append(e);
|
|
957
|
+
}
|
|
958
|
+
focus() {
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
class st extends f {
|
|
962
|
+
constructor(e, t, i) {
|
|
963
|
+
super(i, e, t), this.field.$value = e.defaultValue;
|
|
964
|
+
}
|
|
965
|
+
mounted() {
|
|
966
|
+
}
|
|
967
|
+
createField() {
|
|
968
|
+
return "";
|
|
969
|
+
}
|
|
970
|
+
getValue() {
|
|
971
|
+
return this.field.$value;
|
|
972
|
+
}
|
|
973
|
+
setValue(e) {
|
|
974
|
+
this.field.$value = e;
|
|
975
|
+
}
|
|
976
|
+
reset() {
|
|
977
|
+
this.setValue(this.field.defaultValue);
|
|
978
|
+
}
|
|
979
|
+
getElement() {
|
|
980
|
+
}
|
|
981
|
+
valid() {
|
|
982
|
+
return !0;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
class lt extends f {
|
|
986
|
+
constructor(e, t, i) {
|
|
987
|
+
super(i, e, t), this.mounted(), this.setDefaultOption();
|
|
988
|
+
}
|
|
989
|
+
mounted() {
|
|
990
|
+
var e;
|
|
991
|
+
(e = this.rowElement.querySelector(`#${this.field.$key}`)) == null || e.addEventListener("click", (t) => {
|
|
992
|
+
this.field.onClick && this.field.onClick.call(null, this.field);
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
static isDataRender() {
|
|
996
|
+
return !1;
|
|
997
|
+
}
|
|
998
|
+
createField() {
|
|
999
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
1000
|
+
t.innerHTML = `
|
|
1001
|
+
<button type="button" id="${e.$key}" class="df-btn">${e.label}</button> ${f.getDescriptionTemplate(e)}
|
|
1002
|
+
`;
|
|
1003
|
+
}
|
|
1004
|
+
getValue() {
|
|
1005
|
+
return "";
|
|
1006
|
+
}
|
|
1007
|
+
setValue(e) {
|
|
1008
|
+
}
|
|
1009
|
+
reset() {
|
|
1010
|
+
this.setDisabled(!1);
|
|
1011
|
+
}
|
|
1012
|
+
getElement() {
|
|
1013
|
+
return null;
|
|
1014
|
+
}
|
|
1015
|
+
valid() {
|
|
1016
|
+
return !0;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
class nt extends f {
|
|
1020
|
+
constructor(e, t, i) {
|
|
1021
|
+
super(i, e, t), this.rangeNumElement = t.querySelector(".df-range-num"), this.mounted(), this.setDefaultOption(), this.setDefaultInfo();
|
|
1022
|
+
}
|
|
1023
|
+
mounted() {
|
|
1024
|
+
this.element.addEventListener("input", (e) => {
|
|
1025
|
+
this.rangeNumElement.innerHTML = e.target.value, this.element.setAttribute("title", e.target.value), q(this.field, e, this, this.getValue()), this.valid();
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
createField() {
|
|
1029
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
1030
|
+
t.innerHTML = `
|
|
1031
|
+
<div class="df-field">
|
|
1032
|
+
<span class="df-range-num">${e.defaultValue ? e.defaultValue : 0}</span>
|
|
1033
|
+
<input type="range" name="${e.$xssName}" class="df-form-field df-range df-help-icon" min="${e.rule.minimum}" max="${e.rule.maximum}"/>
|
|
1034
|
+
</div>
|
|
1035
|
+
${f.getDescriptionTemplate(e)}
|
|
1036
|
+
<div class="df-help-message"></div>
|
|
1037
|
+
`, this.element = t.querySelector(`[name="${e.$xssName}"]`);
|
|
1038
|
+
}
|
|
1039
|
+
getValue() {
|
|
1040
|
+
return this.element.value;
|
|
1041
|
+
}
|
|
1042
|
+
setValue(e, t) {
|
|
1043
|
+
if (t !== !1 && this.changeEventCall(this.field, null, this, e) === !1) {
|
|
1044
|
+
this.element.value = this.field.$value;
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
this.field.$value = e, this.element.value = e;
|
|
1048
|
+
}
|
|
1049
|
+
reset() {
|
|
1050
|
+
this.setDefaultInfo(), this.setDisabled(!1), b(this.rowElement);
|
|
1051
|
+
}
|
|
1052
|
+
getElement() {
|
|
1053
|
+
return this.element;
|
|
1054
|
+
}
|
|
1055
|
+
valid() {
|
|
1056
|
+
const e = ue(this.getValue(), this.field);
|
|
1057
|
+
return $(this.field, this.rowElement, e), e;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
let B = {
|
|
1061
|
+
year: "Year",
|
|
1062
|
+
month: "Month",
|
|
1063
|
+
day: "Day",
|
|
1064
|
+
am: "AM",
|
|
1065
|
+
pm: "PM",
|
|
1066
|
+
today: "Today",
|
|
1067
|
+
ok: "Ok",
|
|
1068
|
+
months: {
|
|
1069
|
+
full: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
|
1070
|
+
abbr: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
|
1071
|
+
},
|
|
1072
|
+
weeks: {
|
|
1073
|
+
full: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
|
1074
|
+
abbr: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
|
1075
|
+
}
|
|
1076
|
+
}, at = class {
|
|
1077
|
+
constructor() {
|
|
1078
|
+
this.lang = B;
|
|
1079
|
+
}
|
|
1080
|
+
setDefaultMessage(e) {
|
|
1081
|
+
B = Object.assign(B, e);
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* 다국어 메시지 등록
|
|
1085
|
+
*
|
|
1086
|
+
* @public
|
|
1087
|
+
* @param {?Message} [lang] 둥록할 메시지
|
|
1088
|
+
*/
|
|
1089
|
+
set(e) {
|
|
1090
|
+
this.lang = Object.assign({}, B, e);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* 메시지 얻기
|
|
1094
|
+
*
|
|
1095
|
+
* @public
|
|
1096
|
+
* @param {string} messageKey 메시지 키
|
|
1097
|
+
* @returns {*}
|
|
1098
|
+
*/
|
|
1099
|
+
getMessage(e) {
|
|
1100
|
+
return this.lang[e];
|
|
1101
|
+
}
|
|
1102
|
+
getMonthsMessage(e, t = "abbr") {
|
|
1103
|
+
return this.lang.months[t][e] || "";
|
|
1104
|
+
}
|
|
1105
|
+
getWeeksMessage(e, t = "abbr") {
|
|
1106
|
+
return this.lang.weeks[t][e] || "";
|
|
1107
|
+
}
|
|
1108
|
+
getMonthsIdx(e, t = "abbr") {
|
|
1109
|
+
return t == "full" ? this.lang.months.full.indexOf(e) : this.lang.months.abbr.indexOf(e);
|
|
1110
|
+
}
|
|
1111
|
+
getWeeksIdx(e, t = "abbr") {
|
|
1112
|
+
return t == "full" ? this.lang.weeks.full.indexOf(e) : this.lang.weeks.abbr.indexOf(e);
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
const g = new at(), J = ["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"];
|
|
1116
|
+
let ee = 0, S = {
|
|
1117
|
+
year: "YYYY",
|
|
1118
|
+
month: "YYYY-MM",
|
|
1119
|
+
date: "YYYY-MM-DD",
|
|
1120
|
+
time: "HH:mm",
|
|
1121
|
+
datetime: "YYYY-MM-DD HH:mm"
|
|
1122
|
+
};
|
|
1123
|
+
const k = ["ddtp-sun", "ddtp-mon", "ddtp-tue", "ddtp-wed", "ddtp-thu", "ddtp-fri", "ddtp-sat"];
|
|
1124
|
+
var m = /* @__PURE__ */ ((s) => (s.year = "year", s.month = "month", s.date = "date", s.datetime = "datetime", s.time = "time", s))(m || {});
|
|
1125
|
+
J.forEach((s) => {
|
|
1126
|
+
ee = Math.max(s.length, ee);
|
|
1127
|
+
});
|
|
1128
|
+
const Ne = (s, e) => {
|
|
1129
|
+
e = e || "YYYY-MM-DD";
|
|
1130
|
+
const t = e.length;
|
|
1131
|
+
let i = [];
|
|
1132
|
+
for (let l = 0; l < t; ) {
|
|
1133
|
+
let a = Math.min(ee, t - l);
|
|
1134
|
+
for (; a > 0; a--) {
|
|
1135
|
+
const o = e.substring(l, l + a);
|
|
1136
|
+
if (J.includes(o)) {
|
|
1137
|
+
try {
|
|
1138
|
+
i.push(rt[o](s));
|
|
1139
|
+
} catch (r) {
|
|
1140
|
+
console.log(J.includes(o), o, r);
|
|
1141
|
+
}
|
|
1142
|
+
break;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
a < 1 ? (i.push(e.substring(l, l + 1)), l += 1) : l += a;
|
|
1146
|
+
}
|
|
1147
|
+
return i.join("");
|
|
1148
|
+
}, rt = {
|
|
1149
|
+
YY: (s) => String(s.getFullYear()).slice(-2),
|
|
1150
|
+
YYYY: (s) => String(s.getFullYear()),
|
|
1151
|
+
M: (s) => String(s.getMonth() + 1),
|
|
1152
|
+
MM: (s) => w(s.getMonth() + 1, 2),
|
|
1153
|
+
MMM: (s) => g.getMonthsMessage(s.getMonth()),
|
|
1154
|
+
MMMM: (s) => g.getMonthsMessage(s.getMonth(), "full"),
|
|
1155
|
+
D: (s) => String(s.getDate()),
|
|
1156
|
+
DD: (s) => w(s.getDate(), 2),
|
|
1157
|
+
d: (s) => String(s.getDate()),
|
|
1158
|
+
dd: (s) => w(s.getDate(), 2),
|
|
1159
|
+
ddd: (s) => g.getWeeksMessage(s.getDay()),
|
|
1160
|
+
dddd: (s) => g.getWeeksMessage(s.getDay(), "full"),
|
|
1161
|
+
H: (s) => String(s.getHours()),
|
|
1162
|
+
HH: (s) => w(s.getHours(), 2),
|
|
1163
|
+
h: (s) => we(s),
|
|
1164
|
+
hh: (s) => w(we(s), 2),
|
|
1165
|
+
a: (s) => String(s.getFullYear()).slice(-2),
|
|
1166
|
+
A: (s) => ot(s),
|
|
1167
|
+
m: (s) => String(s.getMinutes()),
|
|
1168
|
+
mm: (s) => w(s.getMinutes(), 2),
|
|
1169
|
+
s: (s) => String(s.getSeconds()),
|
|
1170
|
+
ss: (s) => w(s.getSeconds(), 2),
|
|
1171
|
+
SSS: (s) => w(s.getMilliseconds(), 3)
|
|
1172
|
+
};
|
|
1173
|
+
function we(s) {
|
|
1174
|
+
let e = s.getHours();
|
|
1175
|
+
return e > 12 ? e -= 12 : e < 1 && (e = 12), e;
|
|
1176
|
+
}
|
|
1177
|
+
function ot(s, e, t) {
|
|
1178
|
+
let l = s.getHours() < 12 ? "am" : "pm";
|
|
1179
|
+
return l = g.getMessage(l), l = l.toUpperCase(), l;
|
|
1180
|
+
}
|
|
1181
|
+
const H = (s, e) => {
|
|
1182
|
+
if (s.length > 1e3)
|
|
1183
|
+
return null;
|
|
1184
|
+
e = e || S.date;
|
|
1185
|
+
const t = {
|
|
1186
|
+
year: (/* @__PURE__ */ new Date()).getFullYear(),
|
|
1187
|
+
month: 0,
|
|
1188
|
+
day: 1,
|
|
1189
|
+
hour: 0,
|
|
1190
|
+
minute: 0,
|
|
1191
|
+
second: 0,
|
|
1192
|
+
millisecond: 0,
|
|
1193
|
+
isPm: !1,
|
|
1194
|
+
isH: !1,
|
|
1195
|
+
charIdx: 0
|
|
1196
|
+
}, i = e.length;
|
|
1197
|
+
let l = 0;
|
|
1198
|
+
for (let a = 0; a < i; ) {
|
|
1199
|
+
let r = Math.min(ee, i - a);
|
|
1200
|
+
for (; r > 0; r--) {
|
|
1201
|
+
const d = e.substring(a, a + r);
|
|
1202
|
+
if (J.includes(d)) {
|
|
1203
|
+
const h = ht[d], u = dt(s.substring(l), h[0]);
|
|
1204
|
+
h[1](t, u), l += u.length;
|
|
1205
|
+
break;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
r < 1 ? (a += 1, l += 1) : a += r;
|
|
1209
|
+
}
|
|
1210
|
+
t.hour != null && !t.isH && (t.isPm && +t.hour != 12 ? t.hour = +t.hour + 12 : !t.isPm && +t.hour == 12 && (t.hour = 0));
|
|
1211
|
+
let n;
|
|
1212
|
+
return n = new Date(t.year, t.month, t.day, t.hour, t.minute, t.second, t.millisecond), n;
|
|
1213
|
+
}, dt = (s, e) => {
|
|
1214
|
+
const t = e.exec(s);
|
|
1215
|
+
return t == null ? "" : t[0];
|
|
1216
|
+
}, E = {
|
|
1217
|
+
twoOptional: /\d\d?/,
|
|
1218
|
+
two: /\d\d/,
|
|
1219
|
+
three: /\d{3}/,
|
|
1220
|
+
four: /\d{4}/
|
|
1221
|
+
}, N = /[^\s]+/, ht = {
|
|
1222
|
+
YY: [
|
|
1223
|
+
E.two,
|
|
1224
|
+
(s, e) => (s.year = +(("" + (/* @__PURE__ */ new Date()).getFullYear()).substring(0, 2) + e), s)
|
|
1225
|
+
],
|
|
1226
|
+
YYYY: [
|
|
1227
|
+
E.four,
|
|
1228
|
+
(s, e) => (s.year = +e, s)
|
|
1229
|
+
],
|
|
1230
|
+
M: [
|
|
1231
|
+
E.twoOptional,
|
|
1232
|
+
(s, e) => (s.month = +e - 1, s)
|
|
1233
|
+
],
|
|
1234
|
+
MM: [
|
|
1235
|
+
E.two,
|
|
1236
|
+
(s, e) => (s.month = +e - 1, s)
|
|
1237
|
+
],
|
|
1238
|
+
MMM: [
|
|
1239
|
+
N,
|
|
1240
|
+
(s, e) => (s.month = g.getMonthsIdx(e, "abbr"), s)
|
|
1241
|
+
],
|
|
1242
|
+
MMMM: [
|
|
1243
|
+
N,
|
|
1244
|
+
(s, e) => (s.month = g.getMonthsIdx(e, "full"), s)
|
|
1245
|
+
],
|
|
1246
|
+
D: [
|
|
1247
|
+
E.twoOptional,
|
|
1248
|
+
(s, e) => (s.day = +e, s)
|
|
1249
|
+
],
|
|
1250
|
+
DD: [
|
|
1251
|
+
E.two,
|
|
1252
|
+
(s, e) => (s.day = +e, s)
|
|
1253
|
+
],
|
|
1254
|
+
d: [
|
|
1255
|
+
E.twoOptional,
|
|
1256
|
+
(s, e) => (s.day = +e, s)
|
|
1257
|
+
],
|
|
1258
|
+
dd: [
|
|
1259
|
+
E.two,
|
|
1260
|
+
(s, e) => (s.day = +e, s)
|
|
1261
|
+
],
|
|
1262
|
+
ddd: [
|
|
1263
|
+
N,
|
|
1264
|
+
(s, e) => s
|
|
1265
|
+
],
|
|
1266
|
+
dddd: [
|
|
1267
|
+
N,
|
|
1268
|
+
(s, e) => s
|
|
1269
|
+
],
|
|
1270
|
+
H: [
|
|
1271
|
+
E.twoOptional,
|
|
1272
|
+
(s, e) => (s.hour = +e, s.isH = !0, s)
|
|
1273
|
+
],
|
|
1274
|
+
HH: [
|
|
1275
|
+
E.two,
|
|
1276
|
+
(s, e) => (s.hour = +e, s.isH = !0, s)
|
|
1277
|
+
],
|
|
1278
|
+
h: [
|
|
1279
|
+
E.twoOptional,
|
|
1280
|
+
(s, e) => (s.hour = +e, s)
|
|
1281
|
+
],
|
|
1282
|
+
hh: [
|
|
1283
|
+
E.two,
|
|
1284
|
+
(s, e) => (s.hour = +e, s)
|
|
1285
|
+
],
|
|
1286
|
+
a: [
|
|
1287
|
+
N,
|
|
1288
|
+
(s, e) => (g.getMessage("am") != e.toLowerCase() && (s.isPm = !0), s)
|
|
1289
|
+
],
|
|
1290
|
+
A: [
|
|
1291
|
+
N,
|
|
1292
|
+
(s, e) => (g.getMessage("am") != e.toLowerCase() && (s.isPm = !0), s)
|
|
1293
|
+
],
|
|
1294
|
+
m: [
|
|
1295
|
+
E.twoOptional,
|
|
1296
|
+
(s, e) => (s.minute = +e, s)
|
|
1297
|
+
],
|
|
1298
|
+
mm: [
|
|
1299
|
+
E.two,
|
|
1300
|
+
(s, e) => (s.minute = +e, s)
|
|
1301
|
+
],
|
|
1302
|
+
s: [
|
|
1303
|
+
E.twoOptional,
|
|
1304
|
+
(s, e) => (s.second = +e, s)
|
|
1305
|
+
],
|
|
1306
|
+
ss: [
|
|
1307
|
+
E.two,
|
|
1308
|
+
(s, e) => (s.second = +e, s)
|
|
1309
|
+
],
|
|
1310
|
+
SSS: [
|
|
1311
|
+
E.three,
|
|
1312
|
+
(s, e) => (s.millisecond = +e, s)
|
|
1313
|
+
]
|
|
1314
|
+
};
|
|
1315
|
+
function ut(s, e) {
|
|
1316
|
+
let t = s;
|
|
1317
|
+
for (; t; ) {
|
|
1318
|
+
if (t == e)
|
|
1319
|
+
return !0;
|
|
1320
|
+
t = t.parentElement;
|
|
1321
|
+
}
|
|
1322
|
+
return !1;
|
|
1323
|
+
}
|
|
1324
|
+
class O {
|
|
1325
|
+
constructor(e) {
|
|
1326
|
+
this.date = e;
|
|
1327
|
+
}
|
|
1328
|
+
setYear(e) {
|
|
1329
|
+
return this.date.setFullYear(e), this;
|
|
1330
|
+
}
|
|
1331
|
+
addYear(e) {
|
|
1332
|
+
return this.date.setFullYear(this.date.getFullYear() + e), this;
|
|
1333
|
+
}
|
|
1334
|
+
addMonth(e) {
|
|
1335
|
+
return this.date.setMonth(this.date.getMonth() + e), this;
|
|
1336
|
+
}
|
|
1337
|
+
setMonth(e) {
|
|
1338
|
+
return this.date.setMonth(e), this;
|
|
1339
|
+
}
|
|
1340
|
+
setDate(e) {
|
|
1341
|
+
return this.date.setDate(e), this;
|
|
1342
|
+
}
|
|
1343
|
+
addDate(e) {
|
|
1344
|
+
return this.date.setDate(this.date.getDate() + e), this;
|
|
1345
|
+
}
|
|
1346
|
+
addWeek(e) {
|
|
1347
|
+
return this.date.setDate(this.date.getDate() + e * 7), this;
|
|
1348
|
+
}
|
|
1349
|
+
addHours(e) {
|
|
1350
|
+
return this.date.setHours(this.date.getHours() + e), this;
|
|
1351
|
+
}
|
|
1352
|
+
setHour(e) {
|
|
1353
|
+
return this.date.setHours(e), this;
|
|
1354
|
+
}
|
|
1355
|
+
addMinutes(e) {
|
|
1356
|
+
return this.date.setMinutes(this.date.getMinutes() + e), this;
|
|
1357
|
+
}
|
|
1358
|
+
setMinutes(e) {
|
|
1359
|
+
return this.date.setMinutes(e), this;
|
|
1360
|
+
}
|
|
1361
|
+
addSeconds(e) {
|
|
1362
|
+
return this.date.setSeconds(this.date.getSeconds() + e), this;
|
|
1363
|
+
}
|
|
1364
|
+
addMilliseconds(e) {
|
|
1365
|
+
return this.date.setMilliseconds(this.date.getMilliseconds() + e), this;
|
|
1366
|
+
}
|
|
1367
|
+
compare(e) {
|
|
1368
|
+
return this.date.valueOf() < e.valueOf() ? -1 : this.date.valueOf() > e.valueOf() ? 1 : 0;
|
|
1369
|
+
}
|
|
1370
|
+
getYear() {
|
|
1371
|
+
return this.date.getFullYear();
|
|
1372
|
+
}
|
|
1373
|
+
getMonth() {
|
|
1374
|
+
return this.date.getMonth() + 1;
|
|
1375
|
+
}
|
|
1376
|
+
getDate() {
|
|
1377
|
+
return this.date.getDate();
|
|
1378
|
+
}
|
|
1379
|
+
getDay() {
|
|
1380
|
+
return this.date.getDay();
|
|
1381
|
+
}
|
|
1382
|
+
getTime() {
|
|
1383
|
+
return this.date.getTime();
|
|
1384
|
+
}
|
|
1385
|
+
format(e) {
|
|
1386
|
+
return Ne(this.date, e);
|
|
1387
|
+
}
|
|
1388
|
+
clone() {
|
|
1389
|
+
return new O(new Date(this.date.valueOf()));
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
let le = {
|
|
1393
|
+
inline: !1,
|
|
1394
|
+
// layer or innerhtml
|
|
1395
|
+
weekStartDay: 0,
|
|
1396
|
+
initialDate: "",
|
|
1397
|
+
autoClose: !0,
|
|
1398
|
+
isRTL: !1,
|
|
1399
|
+
mode: m.date,
|
|
1400
|
+
enableTodayBtn: !1,
|
|
1401
|
+
showMonthAfterYear: !1,
|
|
1402
|
+
isPositionFixed: !1,
|
|
1403
|
+
format: "",
|
|
1404
|
+
zIndex: 1e3,
|
|
1405
|
+
minDate: "",
|
|
1406
|
+
maxDate: "",
|
|
1407
|
+
beforeDrawDate: (s) => ({
|
|
1408
|
+
check: !1,
|
|
1409
|
+
style: "",
|
|
1410
|
+
tooltip: ""
|
|
1411
|
+
})
|
|
1412
|
+
};
|
|
1413
|
+
function ct() {
|
|
1414
|
+
var s;
|
|
1415
|
+
return document.getElementById("hiddenDaraDatetimeElement") == null && ((s = document.querySelector("body")) == null || s.insertAdjacentHTML("beforeend", '<div id="hiddenDaraDatetimeElement" class="daracl-datetime-hidden"></div>')), document.getElementById("hiddenDaraDatetimeElement");
|
|
1416
|
+
}
|
|
1417
|
+
let ne = 0;
|
|
1418
|
+
const ie = class Oe {
|
|
1419
|
+
constructor(e, t, i) {
|
|
1420
|
+
var l;
|
|
1421
|
+
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) => {
|
|
1422
|
+
this.isVisible && o.target != this.targetElement && !ut(o.target, this.datetimeElement) && this.hide();
|
|
1423
|
+
}, this.options = Object.assign({}, le, t), ne += 1;
|
|
1424
|
+
let n;
|
|
1425
|
+
if (typeof e == "string" ? n = document.querySelector(e) : n = e, !n)
|
|
1426
|
+
throw new Error(`${e} datetimepicker element not found`);
|
|
1427
|
+
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 || S.year : this.initMode == m.month ? this.dateFormat = this.options.format || S.month : this.initMode == m.time ? this.dateFormat = this.options.format || S.time : this.initMode == m.datetime ? this.dateFormat = this.options.format || S.datetime : this.dateFormat = this.options.format || S.date;
|
|
1428
|
+
let a;
|
|
1429
|
+
if (this.options.initialDate ? typeof this.options.initialDate == "string" ? a = new O(H(this.options.initialDate, this.dateFormat) || /* @__PURE__ */ new Date()) : a = new O(this.options.initialDate) : (a = new O(/* @__PURE__ */ new Date()), this.options.initialDate = a.format(this.dateFormat)), this.setWeekDays(), this.todayDate = a.format(S.date), this.currentDate = a, this.targetElement = n, this.minDate = this._minDate(), this.maxDate = this._maxDate(), this.options.inline)
|
|
1430
|
+
this.datetimeElement = n, this.datetimeElement.className = `daracl-datetime-wrapper ddtp-${ne} embed`;
|
|
1431
|
+
else {
|
|
1432
|
+
this.isInput = !0, this.targetElement.setAttribute("value", a.format(this.dateFormat));
|
|
1433
|
+
const o = document.createElement("div");
|
|
1434
|
+
o.className = `daracl-datetime-wrapper ddtp-${ne} layer`, o.setAttribute("style", `z-index:${this.options.zIndex};`), (l = ct()) == null || l.appendChild(o), this.datetimeElement = o, this.initTargetEvent();
|
|
1435
|
+
}
|
|
1436
|
+
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();
|
|
1437
|
+
}
|
|
1438
|
+
setWeekDays() {
|
|
1439
|
+
let e = this.options.weekStartDay;
|
|
1440
|
+
if (e != 0) {
|
|
1441
|
+
(e < 0 || e > 6) && (e = 0);
|
|
1442
|
+
for (let t = 0; t < 7; t++) {
|
|
1443
|
+
let i = e + t;
|
|
1444
|
+
this.dayOrder[t] = i < 7 ? i : i - 7;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
static create(e, t, i) {
|
|
1449
|
+
return new Oe(e, t, i);
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* default date format setting
|
|
1453
|
+
* @example
|
|
1454
|
+
```
|
|
1455
|
+
setDefaultFormat({
|
|
1456
|
+
year: "YYYY",
|
|
1457
|
+
month: "YYYY-MM",
|
|
1458
|
+
date: "YYYY-MM-DD",
|
|
1459
|
+
time: "HH:mm",
|
|
1460
|
+
datetime: "YYYY-MM-DD HH:mm",
|
|
1461
|
+
});
|
|
1462
|
+
```
|
|
1463
|
+
* @public
|
|
1464
|
+
* @static
|
|
1465
|
+
* @param {*} dateFormat
|
|
1466
|
+
*/
|
|
1467
|
+
static setDefaultFormat(e) {
|
|
1468
|
+
Object.assign(S, e);
|
|
1469
|
+
}
|
|
1470
|
+
_minDate() {
|
|
1471
|
+
let e = this.options.minDate;
|
|
1472
|
+
if (e != "") {
|
|
1473
|
+
if (typeof e == "string") {
|
|
1474
|
+
const t = H(e, this.dateFormat);
|
|
1475
|
+
if (!t)
|
|
1476
|
+
return -1;
|
|
1477
|
+
e = t;
|
|
1478
|
+
}
|
|
1479
|
+
return this.minYear = e.getFullYear(), this.minMonth = +(this.minYear + w(e.getMonth(), 2)), new Date(e.getFullYear(), e.getMonth(), e.getDate(), 0, 0).getTime();
|
|
1480
|
+
}
|
|
1481
|
+
return -1;
|
|
1482
|
+
}
|
|
1483
|
+
_maxDate() {
|
|
1484
|
+
let e = this.options.maxDate;
|
|
1485
|
+
if (e != "") {
|
|
1486
|
+
if (typeof e == "string") {
|
|
1487
|
+
const t = H(e, this.dateFormat);
|
|
1488
|
+
if (!t)
|
|
1489
|
+
return -1;
|
|
1490
|
+
e = t;
|
|
1491
|
+
}
|
|
1492
|
+
return this.maxYear = e.getFullYear(), this.maxMonth = +(this.maxYear + w(e.getMonth(), 2)), new Date(e.getFullYear(), e.getMonth(), e.getDate(), 23, 59).getTime();
|
|
1493
|
+
}
|
|
1494
|
+
return -1;
|
|
1495
|
+
}
|
|
1496
|
+
set viewMode(e) {
|
|
1497
|
+
this._viewMode !== e && (this._viewMode = e, this.changeViewMode(e));
|
|
1498
|
+
}
|
|
1499
|
+
get viewMode() {
|
|
1500
|
+
return this._viewMode;
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* 모드 change
|
|
1504
|
+
* @param mode
|
|
1505
|
+
*/
|
|
1506
|
+
changeViewMode(e) {
|
|
1507
|
+
var t;
|
|
1508
|
+
(t = this.datetimeElement.querySelector(".ddtp-datetime")) == null || t.setAttribute("view-mode", e), e === "year" ? this.yearDraw() : e === "month" ? this.monthDraw() : this.dayDraw();
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* init header event
|
|
1512
|
+
*
|
|
1513
|
+
* @public
|
|
1514
|
+
*/
|
|
1515
|
+
initHeaderEvent() {
|
|
1516
|
+
var e, t, i, l;
|
|
1517
|
+
const n = this.options.isRTL;
|
|
1518
|
+
(e = this.datetimeElement.querySelector(".ddtp-move-btn.prev")) == null || e.addEventListener("click", (a) => {
|
|
1519
|
+
this.moveDate(n ? "next" : "prev", a);
|
|
1520
|
+
}), (t = this.datetimeElement.querySelector(".ddtp-move-btn.next")) == null || t.addEventListener("click", (a) => {
|
|
1521
|
+
this.moveDate(n ? "prev" : "next", a);
|
|
1522
|
+
}), (i = this.datetimeElement.querySelector(".ddtp-header-year")) == null || i.addEventListener("click", (a) => {
|
|
1523
|
+
this.viewMode = m.year;
|
|
1524
|
+
}), (l = this.datetimeElement.querySelector(".ddtp-header-month")) == null || l.addEventListener("click", (a) => {
|
|
1525
|
+
this.viewMode = m.month;
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* 날짜 달력 이벤트처리.
|
|
1530
|
+
*/
|
|
1531
|
+
initDateEvent() {
|
|
1532
|
+
var e, t;
|
|
1533
|
+
(e = this.datetimeElement.querySelector(".ddtp-day-body")) == null || e.addEventListener("click", (i) => {
|
|
1534
|
+
var l;
|
|
1535
|
+
const n = i.target;
|
|
1536
|
+
if (n.classList.contains("ddtp-day") || n.closest(".ddtp-day")) {
|
|
1537
|
+
const o = (n.getAttribute("data-day") || "1").split(",");
|
|
1538
|
+
if (this.currentDate.setMonth(+o[0] - 1), this.currentDate.setDate(+o[1]), this.isDayDisabled(this.currentDate))
|
|
1539
|
+
return;
|
|
1540
|
+
(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);
|
|
1541
|
+
}
|
|
1542
|
+
}), (t = this.datetimeElement.querySelector(".ddtp-today")) == null || t.addEventListener("click", (i) => {
|
|
1543
|
+
const l = new O(H(this.todayDate, S.date) || /* @__PURE__ */ new Date());
|
|
1544
|
+
this.currentDate.setYear(l.getYear()), this.currentDate.setMonth(l.getMonth() - 1), this.currentDate.setDate(l.getDate()), this.changeViewMode(this.initMode);
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
isTimeMode() {
|
|
1548
|
+
return this._viewMode === m.time || this._viewMode === m.datetime;
|
|
1549
|
+
}
|
|
1550
|
+
getTimeNumberValue(e) {
|
|
1551
|
+
return Re(e) ? parseInt(e, 10) : 0;
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* 시간 분 설정 이벤트 처리.
|
|
1555
|
+
*
|
|
1556
|
+
* @public
|
|
1557
|
+
*/
|
|
1558
|
+
initTimeEvent() {
|
|
1559
|
+
var e;
|
|
1560
|
+
if (!this.isTimeMode()) return;
|
|
1561
|
+
let t = this.currentDate.format("HH");
|
|
1562
|
+
const i = this.datetimeElement, l = i.querySelector(".ddtp-hour"), n = i.querySelector(".ddtp-hour-range");
|
|
1563
|
+
l.value = t, n.value = t, l.addEventListener("input", (d) => {
|
|
1564
|
+
const h = d.target;
|
|
1565
|
+
let u = this.getTimeNumberValue(h.value), c = P(u, 2, "0");
|
|
1566
|
+
parseInt(c, 10) > 23 && (c = "23"), l.value = c, n.value = c;
|
|
1567
|
+
}), n.addEventListener("input", (d) => {
|
|
1568
|
+
const h = d.target;
|
|
1569
|
+
l.value = P(h.value, 2, "0");
|
|
1570
|
+
});
|
|
1571
|
+
let a = this.currentDate.format("mm");
|
|
1572
|
+
const o = i.querySelector(".ddtp-minute"), r = i.querySelector(".ddtp-minute-range");
|
|
1573
|
+
o.value = a, r.value = a, o.addEventListener("input", (d) => {
|
|
1574
|
+
const h = d.target;
|
|
1575
|
+
let u = this.getTimeNumberValue(h.value), c = P(u, 2, "0");
|
|
1576
|
+
parseInt(c, 10) > 59 && (c = "59"), o.value = c, r.value = c;
|
|
1577
|
+
}), r.addEventListener("input", (d) => {
|
|
1578
|
+
const h = d.target;
|
|
1579
|
+
o.value = P(h.value, 2, "0");
|
|
1580
|
+
}), (e = i.querySelector(".time-select")) == null || e.addEventListener("click", (d) => {
|
|
1581
|
+
this.currentDate.setHour(+l.value), this.currentDate.setMinutes(+o.value), this.dateChangeEvent(d);
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
/**
|
|
1585
|
+
* 날짜 이동
|
|
1586
|
+
* @param moveMode // 앞뒤 이동 prev, next
|
|
1587
|
+
* @returns
|
|
1588
|
+
*/
|
|
1589
|
+
moveDate(e, t) {
|
|
1590
|
+
if (this._viewMode === m.date || this._viewMode === m.datetime) {
|
|
1591
|
+
this.currentDate.setDate(1), this.currentDate.addMonth(e === "prev" ? -1 : 1), this.dayDraw();
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
if (this._viewMode === m.month) {
|
|
1595
|
+
this.currentDate.setDate(1), this.currentDate.addYear(e === "prev" ? -1 : 1), this.monthDraw();
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
this._viewMode === m.year && (this.currentDate.setDate(1), this.currentDate.addYear(e === "prev" ? -16 : 16), this.yearDraw());
|
|
1599
|
+
}
|
|
1600
|
+
/**
|
|
1601
|
+
* get date value
|
|
1602
|
+
*
|
|
1603
|
+
* @returns
|
|
1604
|
+
*/
|
|
1605
|
+
getDateValue() {
|
|
1606
|
+
return this.currentDate.format(this.dateFormat);
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* 옵션 셋팅
|
|
1610
|
+
* @static
|
|
1611
|
+
* @param {DateTimePickerOptions} options
|
|
1612
|
+
*/
|
|
1613
|
+
static setOptions(e) {
|
|
1614
|
+
le = Object.assign({}, le, e);
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* 달력 보이기 처리.
|
|
1618
|
+
*
|
|
1619
|
+
* @returns
|
|
1620
|
+
*/
|
|
1621
|
+
show() {
|
|
1622
|
+
if (this.isVisible)
|
|
1623
|
+
return;
|
|
1624
|
+
this.isVisible = !0;
|
|
1625
|
+
const e = mt();
|
|
1626
|
+
this.datetimeElement.classList.remove("hide"), this.datetimeElement.classList.add("show");
|
|
1627
|
+
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;
|
|
1628
|
+
let o = t.left + l, r = 0;
|
|
1629
|
+
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);
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* 달력 숨기기
|
|
1633
|
+
*/
|
|
1634
|
+
hide() {
|
|
1635
|
+
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));
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* 타켓 이벤트 처리.
|
|
1639
|
+
*/
|
|
1640
|
+
initTargetEvent() {
|
|
1641
|
+
this.targetElement && this.targetElement.addEventListener("click", (e) => {
|
|
1642
|
+
this.show();
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* 날짜 변경후 이벤트
|
|
1647
|
+
*/
|
|
1648
|
+
afterChangeDatepicker() {
|
|
1649
|
+
const e = this.currentDate.format(this.dateFormat);
|
|
1650
|
+
this.options.afterChangeDatepicker && Y(this.options.afterChangeDatepicker) && this.options.afterChangeDatepicker(e, this.viewMode);
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* 날짜 변경 전 이벤트.
|
|
1654
|
+
* @returns void
|
|
1655
|
+
*/
|
|
1656
|
+
beforeChangeDatepicker() {
|
|
1657
|
+
const e = this.currentDate.format(this.dateFormat);
|
|
1658
|
+
if (this.options.beforeChangeDatepicker && Y(this.options.beforeChangeDatepicker)) {
|
|
1659
|
+
if (this.options.beforeChangeDatepicker(e, (i) => {
|
|
1660
|
+
i !== !1 && this.refresh(!1);
|
|
1661
|
+
}) === !1)
|
|
1662
|
+
return;
|
|
1663
|
+
this.refresh(!1);
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
this.refresh(!1);
|
|
1667
|
+
}
|
|
1668
|
+
dateChangeEvent(e) {
|
|
1669
|
+
const t = this.currentDate.format(this.dateFormat);
|
|
1670
|
+
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());
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* datepicker template 그리기
|
|
1674
|
+
*/
|
|
1675
|
+
createDatetimeTemplate() {
|
|
1676
|
+
const e = this.options.showMonthAfterYear;
|
|
1677
|
+
let t = `<div class="ddtp-datetime ${this.options.isRTL ? "rtl" : ""}" view-mode="${this._viewMode}">
|
|
1678
|
+
<div class="ddtp-header">
|
|
1679
|
+
<span class="${e ? "ddtp-header-year" : "ddtp-header-month"}"></span>
|
|
1680
|
+
<span class="${e ? "ddtp-header-month" : "ddtp-header-year"}"></span>
|
|
1681
|
+
|
|
1682
|
+
<span class="ddtp-date-move">
|
|
1683
|
+
<a href="javascript:;" class="ddtp-move-btn prev">
|
|
1684
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>
|
|
1685
|
+
</a>
|
|
1686
|
+
<a href="javascript:;" class="ddtp-move-btn next">
|
|
1687
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>
|
|
1688
|
+
</a>
|
|
1689
|
+
</span>
|
|
1690
|
+
</div>
|
|
1691
|
+
<div class="ddtp-body">
|
|
1692
|
+
<table class="ddtp-days">
|
|
1693
|
+
<thead class="ddtp-day-header">
|
|
1694
|
+
<tr>
|
|
1695
|
+
<td class="ddtp-day-label ${k[this.dayOrder[0]]}">${g.getWeeksMessage(this.dayOrder[0])}</td>
|
|
1696
|
+
<td class="ddtp-day-label ${k[this.dayOrder[1]]}">${g.getWeeksMessage(this.dayOrder[1])}</td>
|
|
1697
|
+
<td class="ddtp-day-label ${k[this.dayOrder[2]]}">${g.getWeeksMessage(this.dayOrder[2])}</td>
|
|
1698
|
+
<td class="ddtp-day-label ${k[this.dayOrder[3]]}">${g.getWeeksMessage(this.dayOrder[3])}</td>
|
|
1699
|
+
<td class="ddtp-day-label ${k[this.dayOrder[4]]}">${g.getWeeksMessage(this.dayOrder[4])}</td>
|
|
1700
|
+
<td class="ddtp-day-label ${k[this.dayOrder[5]]}">${g.getWeeksMessage(this.dayOrder[5])}</td>
|
|
1701
|
+
<td class="ddtp-day-label ${k[this.dayOrder[6]]}">${g.getWeeksMessage(this.dayOrder[6])}</td>
|
|
1702
|
+
</tr>
|
|
1703
|
+
</thead>
|
|
1704
|
+
<tbody class="ddtp-day-body">
|
|
1705
|
+
</tbody>
|
|
1706
|
+
|
|
1707
|
+
<tfoot class="ddtp-day-footer">
|
|
1708
|
+
<td colspan="7">
|
|
1709
|
+
<div style="width:99%;text-align:center;margin-top: 5px;${this.options.enableTodayBtn ? "" : "display:none;"}"><button type="button" class="ddtp-today">${g.getMessage("today")}</button></div>
|
|
1710
|
+
<div class="footer-tooltip"></div>
|
|
1711
|
+
</td>
|
|
1712
|
+
</tfoot>
|
|
1713
|
+
</table>
|
|
1714
|
+
|
|
1715
|
+
<div class="ddtp-times">
|
|
1716
|
+
<div class="time-container">
|
|
1717
|
+
<div class="ddtp-time">
|
|
1718
|
+
<span>H: </span><input type="number" class="ddtp-hour" min="0" max="23" maxlength="2">
|
|
1719
|
+
<input type="range" min="0" max="23" class="ddtp-hour-range">
|
|
1720
|
+
</div>
|
|
1721
|
+
<div class="ddtp-time">
|
|
1722
|
+
<span>M: </span><input type="number" class="ddtp-minute" min="0" max="59" size="2" maxlength="2">
|
|
1723
|
+
<input type="range" min="0" max="59" class="ddtp-minute-range">
|
|
1724
|
+
</div>
|
|
1725
|
+
</div>
|
|
1726
|
+
<div class="ddtp-btn">
|
|
1727
|
+
<button type="button" class="time-select">${g.getMessage("ok")}</button>
|
|
1728
|
+
</div>
|
|
1729
|
+
</div>
|
|
1730
|
+
|
|
1731
|
+
<div class="ddtp-months">
|
|
1732
|
+
</div>
|
|
1733
|
+
|
|
1734
|
+
<div class="ddtp-years">
|
|
1735
|
+
</div>
|
|
1736
|
+
</div>
|
|
1737
|
+
</div>`;
|
|
1738
|
+
this.datetimeElement.innerHTML = t;
|
|
1739
|
+
}
|
|
1740
|
+
refresh(e) {
|
|
1741
|
+
if (this._viewMode === m.date || this._viewMode === m.datetime) {
|
|
1742
|
+
this.dayDraw(e);
|
|
1743
|
+
return;
|
|
1744
|
+
}
|
|
1745
|
+
if (this._viewMode === m.month) {
|
|
1746
|
+
this.monthDraw(e);
|
|
1747
|
+
return;
|
|
1748
|
+
}
|
|
1749
|
+
this._viewMode === m.year && this.yearDraw(e);
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* 년 달력 그리기
|
|
1753
|
+
*/
|
|
1754
|
+
yearDraw(e) {
|
|
1755
|
+
var t;
|
|
1756
|
+
const i = this.currentDate.format("YYYY");
|
|
1757
|
+
if (e !== !1 && this.initMode == m.year) {
|
|
1758
|
+
this.beforeChangeDatepicker();
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1761
|
+
const l = +i - 8;
|
|
1762
|
+
this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${l} ~ ${l + 15}`;
|
|
1763
|
+
const n = Y(this.options.beforeDrawDate), a = n ? this.options.beforeDrawDate : !1, o = [];
|
|
1764
|
+
for (let r = 0; r < 16; r++) {
|
|
1765
|
+
const d = l + r;
|
|
1766
|
+
let u = this.isYearDisabled(d) ? " disabled" : "", c = "";
|
|
1767
|
+
if (n && a) {
|
|
1768
|
+
const p = a({ mode: this._viewMode, date: d });
|
|
1769
|
+
u += p.style ? " " + p.style : "", c = p.tooltip, c = c ? `title="${c}"` : "";
|
|
1770
|
+
}
|
|
1771
|
+
o.push(`<div class="ddtp-year ${u}" data-year="${d}" ${c}>${d}</div>`);
|
|
1772
|
+
}
|
|
1773
|
+
this.datetimeElement.querySelector(".ddtp-years").innerHTML = o.join(""), this.initMode == m.year && this.afterChangeDatepicker(), (t = this.datetimeElement.querySelectorAll(".ddtp-year")) == null || t.forEach((r) => {
|
|
1774
|
+
r.addEventListener("click", (d) => {
|
|
1775
|
+
const h = d.target;
|
|
1776
|
+
if (h) {
|
|
1777
|
+
const u = h.getAttribute("data-year");
|
|
1778
|
+
if (u) {
|
|
1779
|
+
const c = +u;
|
|
1780
|
+
if (this.isYearDisabled(c))
|
|
1781
|
+
return;
|
|
1782
|
+
if (this.initMode == m.year) {
|
|
1783
|
+
if (this.isYearDisabled(c))
|
|
1784
|
+
return;
|
|
1785
|
+
this.currentDate.setYear(c), this.dateChangeEvent(d);
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
this.currentDate.setYear(c), this.viewMode = this.initMode;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* 월 달력 그리기
|
|
1796
|
+
*/
|
|
1797
|
+
monthDraw(e) {
|
|
1798
|
+
var t;
|
|
1799
|
+
if (e !== !1 && this.initMode == m.month) {
|
|
1800
|
+
this.beforeChangeDatepicker();
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
const i = this.currentDate.format("YYYY");
|
|
1804
|
+
this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${i}`;
|
|
1805
|
+
const l = this.datetimeElement.querySelectorAll(".ddtp-months > .ddtp-month");
|
|
1806
|
+
if (l.length > 0) {
|
|
1807
|
+
if (this.isYearDisabled(+i)) {
|
|
1808
|
+
l.forEach((r) => {
|
|
1809
|
+
r.classList.contains("disabled") || r.classList.add("disabled");
|
|
1810
|
+
});
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
l.forEach((r, d) => {
|
|
1814
|
+
this.isMonthDisabled(+i, d) ? r.classList.contains("disabled") || r.classList.add("disabled") : r.classList.remove("disabled");
|
|
1815
|
+
}), this.initMode == m.month && this.afterChangeDatepicker();
|
|
1816
|
+
return;
|
|
1817
|
+
}
|
|
1818
|
+
this.datetimeElement.querySelector(".ddtp-header-month").textContent = this.currentDate.format("MMMM");
|
|
1819
|
+
const n = Y(this.options.beforeDrawDate), a = n ? this.options.beforeDrawDate : !1, o = [];
|
|
1820
|
+
for (let r = 0; r < 12; r++) {
|
|
1821
|
+
let h = this.isMonthDisabled(+i, r) ? " disabled" : "", u = "";
|
|
1822
|
+
if (n && a) {
|
|
1823
|
+
const c = a({ mode: this._viewMode, date: i + "/" + (r + 1) });
|
|
1824
|
+
h += c.style ? " " + c.style : "", u = c.tooltip, u = u ? `title="${u}"` : "";
|
|
1825
|
+
}
|
|
1826
|
+
o.push(`<div class="ddtp-month ${h}" data-month="${r}" ${u}>${g.getMonthsMessage(r, "abbr")}</div>`);
|
|
1827
|
+
}
|
|
1828
|
+
this.datetimeElement.querySelector(".ddtp-months").innerHTML = o.join(""), this.initMode == m.month && this.afterChangeDatepicker(), (t = this.datetimeElement.querySelectorAll(".ddtp-month")) == null || t.forEach((r) => {
|
|
1829
|
+
r.addEventListener("click", (d) => {
|
|
1830
|
+
const h = d.target;
|
|
1831
|
+
if (h) {
|
|
1832
|
+
const u = h.getAttribute("data-month");
|
|
1833
|
+
if (u) {
|
|
1834
|
+
if (this.isMonthDisabled(this.currentDate.getYear(), +u))
|
|
1835
|
+
return !1;
|
|
1836
|
+
if (this.initMode == m.month) {
|
|
1837
|
+
this.currentDate.setMonth(+u), this.dateChangeEvent(d);
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1840
|
+
this.currentDate.setMonth(+u), this.viewMode = this.initMode, this.dayDraw();
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* 날짜 그리기
|
|
1848
|
+
*/
|
|
1849
|
+
dayDraw(e) {
|
|
1850
|
+
if (e !== !1 && (this.initMode == m.date || this.initMode == m.datetime)) {
|
|
1851
|
+
this.beforeChangeDatepicker();
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
let t = this.currentDate.clone();
|
|
1855
|
+
const i = t.getMonth();
|
|
1856
|
+
t.setDate(1), this.datetimeElement.querySelector(".ddtp-header-year").textContent = t.format("YYYY"), this.datetimeElement.querySelector(".ddtp-header-month").textContent = t.format("MMMM");
|
|
1857
|
+
let l = t.getDay();
|
|
1858
|
+
l = l - this.dayOrder[0], l >= 0 ? t.addDate(-l) : t.addDate(-(7 + l));
|
|
1859
|
+
const n = Y(this.options.beforeDrawDate), a = n ? this.options.beforeDrawDate : !1, o = [];
|
|
1860
|
+
for (let r = 0; r < 42; r++) {
|
|
1861
|
+
let d;
|
|
1862
|
+
r == 0 ? d = t : d = t.clone().addDate(r);
|
|
1863
|
+
const h = d.format(S.date);
|
|
1864
|
+
r % 7 == 0 && o.push((r == 0 ? "" : "</tr>") + "<tr>");
|
|
1865
|
+
let u = this.isDayDisabled(d), c = k[this.dayOrder[r % 7]];
|
|
1866
|
+
const p = d.getMonth();
|
|
1867
|
+
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" : "";
|
|
1868
|
+
let x = "";
|
|
1869
|
+
if (n && a) {
|
|
1870
|
+
const V = a({ mode: this._viewMode, item: d, date: d.format(this.dateFormat) });
|
|
1871
|
+
c += V.style ? " " + V.style : "", c += V.check ? " ddtp-event" : "", x = V.tooltip, x = x ? `title="${x}"` : "";
|
|
1872
|
+
}
|
|
1873
|
+
o.push(`<td class="ddtp-day ${c}" data-day="${d.format("M,D")}" ${x}>`), o.push(`<span>${d.format("d")}</span>`), o.push("</td>");
|
|
1874
|
+
}
|
|
1875
|
+
o.push("</tr>"), this.datetimeElement.querySelector(".ddtp-day-body").innerHTML = o.join(""), (this.initMode == m.date || this.initMode == m.datetime) && this.afterChangeDatepicker();
|
|
1876
|
+
}
|
|
1877
|
+
isDayDisabled(e) {
|
|
1878
|
+
return this.minDate != -1 && this.minDate > e.getTime() || this.maxDate != -1 && this.maxDate < e.getTime();
|
|
1879
|
+
}
|
|
1880
|
+
isYearDisabled(e) {
|
|
1881
|
+
return this.minYear != -1 && this.minYear > e || this.maxYear != -1 && this.maxYear < e;
|
|
1882
|
+
}
|
|
1883
|
+
isMonthDisabled(e, t) {
|
|
1884
|
+
if (this.isYearDisabled(e))
|
|
1885
|
+
return !0;
|
|
1886
|
+
let i = +(e + w(t, 2));
|
|
1887
|
+
return this.minMonth != -1 && this.minMonth > i || this.maxMonth != -1 && this.maxMonth < i;
|
|
1888
|
+
}
|
|
1889
|
+
static setMessage(e) {
|
|
1890
|
+
g.setDefaultMessage(e);
|
|
1891
|
+
}
|
|
1892
|
+
};
|
|
1893
|
+
ie.VERSION = "0.0.13";
|
|
1894
|
+
ie.format = Ne;
|
|
1895
|
+
ie.parser = H;
|
|
1896
|
+
let ft = ie;
|
|
1897
|
+
function mt() {
|
|
1898
|
+
return {
|
|
1899
|
+
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
|
|
1900
|
+
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
class X extends f {
|
|
1904
|
+
constructor(e, t, i) {
|
|
1905
|
+
super(i, e, t), this.mounted(), this.setDefaultOption(), this.setDefaultInfo();
|
|
1906
|
+
}
|
|
1907
|
+
mounted() {
|
|
1908
|
+
let e;
|
|
1909
|
+
this.field.rendererOptions = Object.assign({}, this.field.rendererOptions), typeof this.field.rendererOptions.onSelect < "u" && (e = typeof this.field.rendererOptions.onSelect), y(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) => {
|
|
1910
|
+
e && e(t, i), this.setValue(t), this.valid();
|
|
1911
|
+
}, this.dateObj = new ft(this.element, this.field.rendererOptions, {});
|
|
1912
|
+
}
|
|
1913
|
+
createField() {
|
|
1914
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
1915
|
+
t.innerHTML = `
|
|
1916
|
+
<div class="df-field">
|
|
1917
|
+
<input type="text" name="${e.$xssName}" class="df-form-field df-text df-help-icon" autocomplete="off" readonly/>
|
|
1918
|
+
</div>
|
|
1919
|
+
${f.getDescriptionTemplate(e)}
|
|
1920
|
+
<div class="df-help-message"></div>
|
|
1921
|
+
`, this.element = t.querySelector(`[name="${e.$xssName}"]`);
|
|
1922
|
+
}
|
|
1923
|
+
getValue() {
|
|
1924
|
+
return this.element.value;
|
|
1925
|
+
}
|
|
1926
|
+
setValue(e, t) {
|
|
1927
|
+
if (t !== !1 && this.changeEventCall(this.field, null, this, e) === !1) {
|
|
1928
|
+
this.element.value = this.field.$value;
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
this.field.$value = e, this.element.value = e;
|
|
1932
|
+
}
|
|
1933
|
+
reset() {
|
|
1934
|
+
this.setDefaultInfo(), this.setDisabled(!1), b(this.rowElement);
|
|
1935
|
+
}
|
|
1936
|
+
getElement() {
|
|
1937
|
+
return this.element;
|
|
1938
|
+
}
|
|
1939
|
+
valid() {
|
|
1940
|
+
const e = R(this.getValue(), this.field);
|
|
1941
|
+
return $(this.field, this.rowElement, e), e;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
class pt extends f {
|
|
1945
|
+
constructor(e, t, i) {
|
|
1946
|
+
super(i, e, t), e.renderer ? this.customFunction = e.renderer : this.customFunction = {}, this.mounted();
|
|
1947
|
+
}
|
|
1948
|
+
mounted() {
|
|
1949
|
+
this.customFunction.mounted && this.customFunction.mounted.call(this, this.field, this.rowElement), this.tabContainerElement.querySelectorAll(".df-tab-item").forEach((e) => {
|
|
1950
|
+
e.addEventListener("click", (t) => {
|
|
1951
|
+
this.clickEventHandler(e, t);
|
|
1952
|
+
});
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* tab item click
|
|
1957
|
+
*
|
|
1958
|
+
* @param {Element} tabItem
|
|
1959
|
+
* @param {*} evt
|
|
1960
|
+
*/
|
|
1961
|
+
clickEventHandler(e, t) {
|
|
1962
|
+
this.setActive(e.getAttribute("data-tab-id") ?? "");
|
|
1963
|
+
}
|
|
1964
|
+
setActive(e) {
|
|
1965
|
+
var l, n;
|
|
1966
|
+
const t = this.tabContainerElement.querySelector(`[data-tab-id="${e}"]`);
|
|
1967
|
+
if (!t) return;
|
|
1968
|
+
if (!t.classList.contains("active")) {
|
|
1969
|
+
for (let a of ((l = t == null ? void 0 : t.parentElement) == null ? void 0 : l.children) ?? [])
|
|
1970
|
+
a.classList.remove("active");
|
|
1971
|
+
t.classList.add("active");
|
|
1972
|
+
}
|
|
1973
|
+
const i = this.rowElement.querySelector(`[tab-panel-id="${e}"]`);
|
|
1974
|
+
if (!(i != null && i.classList.contains("active"))) {
|
|
1975
|
+
for (let a of ((n = i == null ? void 0 : i.parentElement) == null ? void 0 : n.children) ?? [])
|
|
1976
|
+
a.classList.remove("active");
|
|
1977
|
+
i == null || i.classList.add("active");
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
static isDataRender() {
|
|
1981
|
+
return !1;
|
|
1982
|
+
}
|
|
1983
|
+
static isChildrenCreate() {
|
|
1984
|
+
return !1;
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* tab template
|
|
1988
|
+
*
|
|
1989
|
+
* @param {FormField} field
|
|
1990
|
+
* @param {FormTemplate} formTemplate
|
|
1991
|
+
* @param {FormOptions} options
|
|
1992
|
+
* @returns {string} template string
|
|
1993
|
+
*/
|
|
1994
|
+
createField() {
|
|
1995
|
+
var a, o;
|
|
1996
|
+
const e = this.field, t = this.daraForm.formTemplate, i = this.daraForm.getOptions(), l = this.rowElement.querySelector(".df-field-container");
|
|
1997
|
+
let n = A(i, e);
|
|
1998
|
+
if (l.innerHTML = `
|
|
1999
|
+
<div class="df-field ">
|
|
2000
|
+
<div class="df-tab-header ${n.tabAlignClass}"></div>
|
|
2001
|
+
</div>
|
|
2002
|
+
<div class="df-tab-body"></div>
|
|
2003
|
+
`, e.children) {
|
|
2004
|
+
let r = !0;
|
|
2005
|
+
const d = this.getForm().getOptions();
|
|
2006
|
+
let h = A(d, e, null, t.isLabelHide(e));
|
|
2007
|
+
for (const u of e.children) {
|
|
2008
|
+
u.$parent = e, t.addRowFieldInfo(u);
|
|
2009
|
+
let c = u.$key, p = `<span class="df-tab-item ${r ? "active" : ""}" data-tab-id="${c}"><a href="javascript:;">${u.label}</a></span>`, x = `<div class="df-tab-panel ${r ? "active" : ""}" tab-panel-id="${c}">${f.getDescriptionTemplate(u)}
|
|
2010
|
+
<div class="df-tab-group"></div>
|
|
2011
|
+
</div>`;
|
|
2012
|
+
const V = z(p), T = z(x);
|
|
2013
|
+
if (r = !1, V && ((a = l.querySelector(".df-tab-header")) == null || a.appendChild(V)), T && ((o = l.querySelector(".df-tab-body")) == null || o.appendChild(T), u.children)) {
|
|
2014
|
+
let W = {
|
|
2015
|
+
style: {
|
|
2016
|
+
width: d.style.width ?? "100%",
|
|
2017
|
+
labelWidth: d.style.labelWidth ?? 3,
|
|
2018
|
+
valueWidth: d.style.valueWidth ?? 9,
|
|
2019
|
+
position: d.style.position ?? "left-right"
|
|
2020
|
+
},
|
|
2021
|
+
useTypeValue: d.useTypeValue,
|
|
2022
|
+
autoCreate: !1,
|
|
2023
|
+
notValidMessage: "This form is not valid.",
|
|
2024
|
+
fields: []
|
|
2025
|
+
};
|
|
2026
|
+
u.$tabForm = new te(document.createElement("div"), W), u.$instance = new u.$renderType(u, T == null ? void 0 : T.querySelector(".df-tab-group"), u.$tabForm), u.$tabForm.formTemplate.childTemplate(u, h);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
this.tabContainerElement = l;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
getValue() {
|
|
2033
|
+
var i;
|
|
2034
|
+
if (this.customFunction.getValue)
|
|
2035
|
+
return this.customFunction.getValue.call(this, this.field, this.rowElement);
|
|
2036
|
+
let e = {}, t = this.getForm().getOptions().useTypeValue;
|
|
2037
|
+
for (const l of this.field.children) {
|
|
2038
|
+
const n = (i = l.$tabForm) == null ? void 0 : i.getValue(!1);
|
|
2039
|
+
if (t)
|
|
2040
|
+
e[l.$validName] = n;
|
|
2041
|
+
else
|
|
2042
|
+
for (let [a, o] of Object.entries(n))
|
|
2043
|
+
e[a] = o;
|
|
2044
|
+
}
|
|
2045
|
+
return e;
|
|
2046
|
+
}
|
|
2047
|
+
setValue(e) {
|
|
2048
|
+
var t;
|
|
2049
|
+
for (const i of this.field.children) {
|
|
2050
|
+
let l = e[i.$validName];
|
|
2051
|
+
l && ((t = i.$tabForm) == null || t.setValue(l));
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
reset() {
|
|
2055
|
+
}
|
|
2056
|
+
getElement() {
|
|
2057
|
+
return this.rowElement;
|
|
2058
|
+
}
|
|
2059
|
+
valid() {
|
|
2060
|
+
var t;
|
|
2061
|
+
if (this.customFunction.valid) {
|
|
2062
|
+
const i = this.customFunction.valid.call(this, this.field, this.rowElement);
|
|
2063
|
+
$(this.field, this.rowElement, i);
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
const e = this.field;
|
|
2067
|
+
for (const i of e.children) {
|
|
2068
|
+
const l = (t = i.$tabForm) == null ? void 0 : t.validForm();
|
|
2069
|
+
if (l && l.length > 0) {
|
|
2070
|
+
const n = l[0];
|
|
2071
|
+
if (n.message)
|
|
2072
|
+
return n.message = "[" + this.field.label + "] " + n.message, n;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
return !0;
|
|
2076
|
+
}
|
|
2077
|
+
focus() {
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
let U = 0;
|
|
2081
|
+
class gt extends f {
|
|
2082
|
+
constructor(e, t, i) {
|
|
2083
|
+
super(i, e, t), this.allAddRowInfo = {}, e.renderer ? this.customFunction = e.renderer : this.customFunction = {};
|
|
2084
|
+
const l = {
|
|
2085
|
+
style: {
|
|
2086
|
+
width: "100%",
|
|
2087
|
+
labelWidth: 3,
|
|
2088
|
+
valueWidth: 9,
|
|
2089
|
+
position: "left-right"
|
|
2090
|
+
},
|
|
2091
|
+
autoCreate: !1,
|
|
2092
|
+
notValidMessage: "This form is not valid.",
|
|
2093
|
+
fields: []
|
|
2094
|
+
};
|
|
2095
|
+
this.gridForm = new te(document.createElement("div"), l), this.mounted(), this.setDefaultOption(), this.setDefaultInfo();
|
|
2096
|
+
}
|
|
2097
|
+
mounted() {
|
|
2098
|
+
var e;
|
|
2099
|
+
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) => {
|
|
2100
|
+
this.addRow();
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2103
|
+
static isDataRender() {
|
|
2104
|
+
return !1;
|
|
2105
|
+
}
|
|
2106
|
+
static isChildrenCreate() {
|
|
2107
|
+
return !1;
|
|
2108
|
+
}
|
|
2109
|
+
createField() {
|
|
2110
|
+
var a, o, r, d;
|
|
2111
|
+
const e = this.field, t = this.rowElement.querySelector(".df-field-container");
|
|
2112
|
+
let i = [], l = [], n = [];
|
|
2113
|
+
if (n.push(""), e.children) {
|
|
2114
|
+
l.push("<colgroup>"), i.push("<tr>"), l.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>");
|
|
2115
|
+
for (const h of e.children)
|
|
2116
|
+
l.push(`<col style="width:${((o = h.style) == null ? void 0 : o.width) ?? "*"}">`), i.push(`<th class="df-grid-header">${h.label}</th>`);
|
|
2117
|
+
l.push("</colgroup>"), i.push("</tr>");
|
|
2118
|
+
}
|
|
2119
|
+
t.innerHTML = `
|
|
2120
|
+
<div class="df-grid-field">
|
|
2121
|
+
${n.join("")}
|
|
2122
|
+
<div class="df-grid-container ${((r = e.style) == null ? void 0 : r.position) ?? ""}" style="height:${((d = e.rendererOptions) == null ? void 0 : d.height) ?? "auto"};">
|
|
2123
|
+
<table class="df-grid">${l.join("")}<thead>${i.join("")}</thead><tbody></tbody></table>
|
|
2124
|
+
</div>
|
|
2125
|
+
</div>
|
|
2126
|
+
`;
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* add row
|
|
2130
|
+
*/
|
|
2131
|
+
addRow(e) {
|
|
2132
|
+
var r, d, h;
|
|
2133
|
+
let t = [];
|
|
2134
|
+
const i = this.daraForm.getOptions(), l = this.gridForm.formTemplate, n = this.field.$xssName;
|
|
2135
|
+
++U;
|
|
2136
|
+
let a = [];
|
|
2137
|
+
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="${U}" class="df-btn df-grid-row-remove"><i class="df-icon df-remove-icon"></i></button>`), t.push("</td>");
|
|
2138
|
+
for (const u of this.field.children) {
|
|
2139
|
+
let c = A(i, u, null, !0), p = he({}, u);
|
|
2140
|
+
a.push(p), p.$orgin = u, p.name = p.name + "_" + U, p.$xssName = n + "_" + Te(p), l.addRowFieldInfo(p), t.push(`<td id="${p.$xssName}"><div class="df-field-container ${p.required ? "required" : ""} " style="${c.valueStyle}"></div></td>`);
|
|
2141
|
+
}
|
|
2142
|
+
t.push("</tr>"), this.allAddRowInfo[U] = a;
|
|
2143
|
+
const o = z(t.join(""));
|
|
2144
|
+
o && ((d = this.rowElement.querySelector("tbody")) == null || d.append(o), (h = o.querySelector(".df-grid-row-remove")) == null || h.addEventListener("click", (u) => {
|
|
2145
|
+
this.removeRow(u);
|
|
2146
|
+
})), e = e ?? {};
|
|
2147
|
+
for (let u of a)
|
|
2148
|
+
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]);
|
|
2149
|
+
}
|
|
2150
|
+
/**
|
|
2151
|
+
* remove row
|
|
2152
|
+
*
|
|
2153
|
+
* @param evt event
|
|
2154
|
+
*/
|
|
2155
|
+
removeRow(e) {
|
|
2156
|
+
var l, n;
|
|
2157
|
+
const i = e.target.closest("tr");
|
|
2158
|
+
if (i) {
|
|
2159
|
+
if (((l = i.parentElement) == null ? void 0 : l.childElementCount) == 1) return;
|
|
2160
|
+
let a = ((n = e.currentTarget) == null ? void 0 : n.getAttribute("data-row-idx")) || "-1";
|
|
2161
|
+
this.removeFieldInfo(a), i.remove();
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
/**
|
|
2165
|
+
*
|
|
2166
|
+
* @param rowIdx row index
|
|
2167
|
+
*/
|
|
2168
|
+
removeFieldInfo(e) {
|
|
2169
|
+
let t = [];
|
|
2170
|
+
if (C(e)) {
|
|
2171
|
+
for (let i in this.allAddRowInfo)
|
|
2172
|
+
t = t.concat(this.allAddRowInfo[i]);
|
|
2173
|
+
this.allAddRowInfo = {};
|
|
2174
|
+
} else if (e) {
|
|
2175
|
+
const i = parseInt(e, 10);
|
|
2176
|
+
t = t.concat(this.allAddRowInfo[i]), delete this.allAddRowInfo[i];
|
|
2177
|
+
}
|
|
2178
|
+
for (let i of t)
|
|
2179
|
+
this.gridForm.getFieldInfoMap().removeFieldInfo(i.name);
|
|
2180
|
+
}
|
|
2181
|
+
allRemoveRow() {
|
|
2182
|
+
var e;
|
|
2183
|
+
(e = this.rowElement.querySelector("tbody")) == null || e.replaceChildren(), this.removeFieldInfo();
|
|
2184
|
+
}
|
|
2185
|
+
getValue() {
|
|
2186
|
+
if (this.customFunction.getValue)
|
|
2187
|
+
return this.customFunction.getValue.call(this, this.field, this.rowElement);
|
|
2188
|
+
let e = [];
|
|
2189
|
+
const t = this.field.children, i = t.length;
|
|
2190
|
+
for (let l in this.allAddRowInfo) {
|
|
2191
|
+
const n = this.allAddRowInfo[l];
|
|
2192
|
+
let a = {};
|
|
2193
|
+
for (let o = 0; o < i; o++) {
|
|
2194
|
+
let r = t[o];
|
|
2195
|
+
a[r.name] = this.gridForm.getFieldValue(n[o].name);
|
|
2196
|
+
}
|
|
2197
|
+
e.push(a);
|
|
2198
|
+
}
|
|
2199
|
+
return e;
|
|
2200
|
+
}
|
|
2201
|
+
setValue(e) {
|
|
2202
|
+
this.field.$value = e;
|
|
2203
|
+
let t = [];
|
|
2204
|
+
L(e) ? t = e : de(e) && t.push(e), this.allRemoveRow();
|
|
2205
|
+
for (let i of t)
|
|
2206
|
+
this.addRow(i);
|
|
2207
|
+
}
|
|
2208
|
+
reset() {
|
|
2209
|
+
this.setDefaultInfo(), b(this.rowElement);
|
|
2210
|
+
}
|
|
2211
|
+
getElement() {
|
|
2212
|
+
return this.customFunction.getElement ? this.customFunction.getElement.call(this, this.field, this.rowElement) : null;
|
|
2213
|
+
}
|
|
2214
|
+
valid() {
|
|
2215
|
+
if (this.customFunction.valid) {
|
|
2216
|
+
const t = this.customFunction.valid.call(this, this.field, this.rowElement);
|
|
2217
|
+
$(this.field, this.rowElement, t);
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
const e = this.gridForm.validForm();
|
|
2221
|
+
if (e.length > 0) {
|
|
2222
|
+
const t = e[0];
|
|
2223
|
+
if (t.message)
|
|
2224
|
+
return t.message = "[" + this.field.label + "] " + t.message, t;
|
|
2225
|
+
}
|
|
2226
|
+
return !0;
|
|
2227
|
+
}
|
|
2228
|
+
focus() {
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
const v = {
|
|
2232
|
+
NAN: "nan",
|
|
2233
|
+
MIN: "minimum",
|
|
2234
|
+
EXCLUSIVE_MIN: "exclusiveMinimum",
|
|
2235
|
+
MAX: "maximum",
|
|
2236
|
+
EXCLUSIVE_MAX: "exclusiveMaximum",
|
|
2237
|
+
MIN_LENGTH: "minLength",
|
|
2238
|
+
MAX_LENGTH: "maxLength",
|
|
2239
|
+
BETWEEN: "between",
|
|
2240
|
+
BETWEEN_EXCLUSIVE_MIN: "betweenExclusiveMin",
|
|
2241
|
+
BETWEEN_EXCLUSIVE_MAX: "betweenExclusiveMax",
|
|
2242
|
+
BETWEEN_EXCLUSIVE_MINMAX: "betweenExclusiveMinMax",
|
|
2243
|
+
REQUIRED: "required"
|
|
2244
|
+
}, vt = "dff", K = {
|
|
2245
|
+
number: Ke,
|
|
2246
|
+
textarea: Ze,
|
|
2247
|
+
dropdown: fe,
|
|
2248
|
+
checkbox: pe,
|
|
2249
|
+
radio: ge,
|
|
2250
|
+
text: Qe,
|
|
2251
|
+
password: Ge,
|
|
2252
|
+
file: et,
|
|
2253
|
+
custom: tt,
|
|
2254
|
+
group: it,
|
|
2255
|
+
hidden: st,
|
|
2256
|
+
button: lt,
|
|
2257
|
+
range: nt,
|
|
2258
|
+
datehour: X,
|
|
2259
|
+
datemonth: X,
|
|
2260
|
+
date: X,
|
|
2261
|
+
datetime: X,
|
|
2262
|
+
tab: pt,
|
|
2263
|
+
grid: gt
|
|
2264
|
+
}, Ae = {
|
|
2265
|
+
horizontal: "horizontal"
|
|
2266
|
+
}, F = {
|
|
2267
|
+
"top-left": ["top", "df-txt-left"],
|
|
2268
|
+
"top-center": ["top", "df-txt-center"],
|
|
2269
|
+
"top-right": ["top", "df-txt-right"],
|
|
2270
|
+
"left-left": ["", "df-txt-left"],
|
|
2271
|
+
"left-center": ["", "df-txt-center"],
|
|
2272
|
+
"left-right": ["", "df-txt-right"],
|
|
2273
|
+
"right-right": ["right", "df-txt-right"],
|
|
2274
|
+
"right-center": ["right", "df-txt-center"],
|
|
2275
|
+
"right-left": ["right", "df-txt-left"],
|
|
2276
|
+
"bottom-left": ["bottom", "df-txt-left"],
|
|
2277
|
+
"bottom-center": ["bottom", "df-txt-center"],
|
|
2278
|
+
"bottom-right": ["bottom", "df-txt-right"]
|
|
2279
|
+
};
|
|
2280
|
+
F.top = F["top-left"];
|
|
2281
|
+
F.right = F["right-right"];
|
|
2282
|
+
F.left = F["left-left"];
|
|
2283
|
+
F.bottom = F["bottom-left"];
|
|
2284
|
+
let Me = {
|
|
2285
|
+
required: "{label} 필수 입력사항입니다.",
|
|
2286
|
+
fileButton: "파일찾기",
|
|
2287
|
+
selection: "선택",
|
|
2288
|
+
string: {
|
|
2289
|
+
minLength: "{minLength} 글자 이상으로 입력하세요.",
|
|
2290
|
+
maxLength: "{maxLength} 글자 이하로 입력하세요.",
|
|
2291
|
+
between: "{minLength} ~ {maxLength} 사이의 글자를 입력하세요."
|
|
2292
|
+
},
|
|
2293
|
+
number: {
|
|
2294
|
+
nan: "숫자만 입력 가능 합니다.",
|
|
2295
|
+
minimum: "{minimum} 값과 같거나 커야 합니다",
|
|
2296
|
+
exclusiveMinimum: "{minimum} 보다 커야 합니다",
|
|
2297
|
+
maximum: "{maximum} 값과 같거나 작아야 합니다",
|
|
2298
|
+
exclusiveMaximum: "{maximum} 보다 작아야 합니다.",
|
|
2299
|
+
between: "{minimum}~{maximum} 사이의 값을 입력하세요.",
|
|
2300
|
+
betweenExclusiveMin: "{minimum} 보다 크고 {maximum} 보다 같거나 작아야 합니다",
|
|
2301
|
+
betweenExclusiveMax: "{minimum} 보다 같거나 크고 {maximum} 보다 작아야 합니다",
|
|
2302
|
+
betweenExclusiveMinMax: "{minimum} 보다 크고 {maximum} 보다 작아야 합니다"
|
|
2303
|
+
},
|
|
2304
|
+
regexp: {
|
|
2305
|
+
mobile: "핸드폰 번호가 유효하지 않습니다.",
|
|
2306
|
+
email: "이메일이 유효하지 않습니다.",
|
|
2307
|
+
url: "URL이 유효하지 않습니다.",
|
|
2308
|
+
alpha: "영문만 입력 가능 합니다.",
|
|
2309
|
+
"alpha-num": "영문과 숫자만 입력 가능 합니다.",
|
|
2310
|
+
number: "숫자만 입력 가능 합니다.",
|
|
2311
|
+
variable: "값이 유효하지 않습니다.",
|
|
2312
|
+
"number-char": "숫자, 문자 각각 하나 이상 포함 되어야 합니다.",
|
|
2313
|
+
"upper-char": "대문자가 하나 이상 포함 되어야 합니다.",
|
|
2314
|
+
"upper-char-special": "대문자,소문자,특수문자 각각 하나 이상 포함 되어야 합니다.",
|
|
2315
|
+
"upper-char-special-number": "대문자,소문자,특수문자,숫자 각각 하나 이상 포함 되어야합니다."
|
|
2316
|
+
}
|
|
2317
|
+
};
|
|
2318
|
+
class yt {
|
|
2319
|
+
constructor() {
|
|
2320
|
+
this.lang = Me;
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* 다국어 메시지 등록
|
|
2324
|
+
*
|
|
2325
|
+
* @public
|
|
2326
|
+
* @param {?Message} [lang] 둥록할 메시지
|
|
2327
|
+
*/
|
|
2328
|
+
set(e) {
|
|
2329
|
+
this.lang = Object.assign({}, Me, e);
|
|
2330
|
+
}
|
|
2331
|
+
/**
|
|
2332
|
+
* 메시지 얻기
|
|
2333
|
+
*
|
|
2334
|
+
* @public
|
|
2335
|
+
* @param {string} messageKey 메시지 키
|
|
2336
|
+
* @returns {*}
|
|
2337
|
+
*/
|
|
2338
|
+
getMessage(e) {
|
|
2339
|
+
return this.lang[e];
|
|
2340
|
+
}
|
|
2341
|
+
/**
|
|
2342
|
+
* ValidResult 값을 메시지로 변경.
|
|
2343
|
+
*
|
|
2344
|
+
* @public
|
|
2345
|
+
* @param {FormField} field
|
|
2346
|
+
* @param {ValidResult} validResult
|
|
2347
|
+
* @returns {string[]}
|
|
2348
|
+
*/
|
|
2349
|
+
validMessage(e, t) {
|
|
2350
|
+
let i = "", l = [];
|
|
2351
|
+
t.regexp && (i = this.lang.regexp[t.regexp], l.push(i)), (t.constraint ?? []).forEach((o) => {
|
|
2352
|
+
o === v.REQUIRED && (i = Fe(this.lang.required, e), l.push(i)), e.renderType == "number" || e.renderType == "range" ? (i = this.lang.number[o], l.push(i)) : (i = this.lang.string[o], l.push(i));
|
|
2353
|
+
});
|
|
2354
|
+
const n = [], a = Object.assign({}, { name: e.name, label: e.label }, e.rule);
|
|
2355
|
+
return l.forEach((o) => {
|
|
2356
|
+
o && n.push(Fe(o, a));
|
|
2357
|
+
}), t.validator && n.push(t.validator.message), n;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
function Fe(s, e) {
|
|
2361
|
+
return s.replace(/\{{1,1}([A-Za-z0-9_.]*)\}{1,1}/g, (t, i) => typeof e[i] < "u" ? e[i] : t);
|
|
2362
|
+
}
|
|
2363
|
+
const I = new yt(), Et = (s) => {
|
|
2364
|
+
let e;
|
|
2365
|
+
return s.renderType && (e = K[s.renderType]), e && (e.isDataRender() === !1 || !y(s.name)) ? e : y(s.name) ? s.children ? K.group : K.hidden : K.text;
|
|
2366
|
+
};
|
|
2367
|
+
class $t {
|
|
2368
|
+
constructor(e, t) {
|
|
2369
|
+
this.fieldIdx = 0, this.allFieldInfo = {}, this.keyNameMap = {}, this.conditionFields = [], this.fieldPrefix = `${vt}_${_e(e)}`, this.form = t;
|
|
2370
|
+
}
|
|
2371
|
+
/**
|
|
2372
|
+
* add Field 정보
|
|
2373
|
+
*
|
|
2374
|
+
* @public
|
|
2375
|
+
* @param {FormField} field 폼필드 정보
|
|
2376
|
+
*/
|
|
2377
|
+
addField(e) {
|
|
2378
|
+
He(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 = Et(e), e.conditional && this.conditionFields.push(e.$key);
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* 필드명으로 필드 정부 구하기
|
|
2382
|
+
*
|
|
2383
|
+
* @public
|
|
2384
|
+
* @param {string} fieldName 필드명
|
|
2385
|
+
* @returns {FormField}
|
|
2386
|
+
*/
|
|
2387
|
+
getFieldName(e) {
|
|
2388
|
+
return this.allFieldInfo[this.keyNameMap[e]];
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* 필드 키로 정보 구하기
|
|
2392
|
+
*
|
|
2393
|
+
* @public
|
|
2394
|
+
* @param {string} fieldKey
|
|
2395
|
+
* @returns {FormField}
|
|
2396
|
+
*/
|
|
2397
|
+
get(e) {
|
|
2398
|
+
return this.allFieldInfo[e];
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* 필드명 있는지 여부 체크.
|
|
2402
|
+
*
|
|
2403
|
+
* @public
|
|
2404
|
+
* @param {string} fieldName 필드명
|
|
2405
|
+
* @returns {boolean}
|
|
2406
|
+
*/
|
|
2407
|
+
hasFieldName(e) {
|
|
2408
|
+
return !!(this.keyNameMap[e] && this.allFieldInfo[this.keyNameMap[e]]);
|
|
2409
|
+
}
|
|
2410
|
+
/**
|
|
2411
|
+
* 모든 필드 정보
|
|
2412
|
+
*
|
|
2413
|
+
* @public
|
|
2414
|
+
* @returns {NumberFieldMap}
|
|
2415
|
+
*/
|
|
2416
|
+
getAllFieldInfo() {
|
|
2417
|
+
return this.allFieldInfo;
|
|
2418
|
+
}
|
|
2419
|
+
/**
|
|
2420
|
+
* 필드 정보 맵에서 지우기
|
|
2421
|
+
*
|
|
2422
|
+
* @public
|
|
2423
|
+
* @param {string} fieldName
|
|
2424
|
+
*/
|
|
2425
|
+
removeFieldInfo(e) {
|
|
2426
|
+
const t = this.keyNameMap[e];
|
|
2427
|
+
y(t) || (this.removeFieldInfoByKey(t), delete this.keyNameMap[e]);
|
|
2428
|
+
}
|
|
2429
|
+
/**
|
|
2430
|
+
* 필드 키로 필드 정보 맵에서 지우기
|
|
2431
|
+
*
|
|
2432
|
+
* @public
|
|
2433
|
+
* @param {string} fieldKey
|
|
2434
|
+
*/
|
|
2435
|
+
removeFieldInfoByKey(e) {
|
|
2436
|
+
const t = this.allFieldInfo[e];
|
|
2437
|
+
t && this.keyNameMap[t.$validName] === e && delete this.keyNameMap[t.$validName], delete this.allFieldInfo[e], this.conditionFields = this.conditionFields.filter((i) => i !== e);
|
|
2438
|
+
}
|
|
2439
|
+
/**
|
|
2440
|
+
* 모든 필드값 구하기
|
|
2441
|
+
*
|
|
2442
|
+
* @public
|
|
2443
|
+
* @param {boolean} validationCheck
|
|
2444
|
+
* @returns {*}
|
|
2445
|
+
*/
|
|
2446
|
+
getAllFieldValue(e, t) {
|
|
2447
|
+
const i = this.form.getOptions().useTypeValue;
|
|
2448
|
+
if (t !== !0) {
|
|
2449
|
+
for (let [l, n] of Object.entries(this.allFieldInfo))
|
|
2450
|
+
e = De(e, n, i);
|
|
2451
|
+
return e;
|
|
2452
|
+
}
|
|
2453
|
+
return new Promise((l, n) => {
|
|
2454
|
+
for (let [a, o] of Object.entries(this.allFieldInfo)) {
|
|
2455
|
+
if (!o.$instance.isEnableView())
|
|
2456
|
+
continue;
|
|
2457
|
+
let r = this.getFieldValidation(o, !0);
|
|
2458
|
+
if (r !== !0) {
|
|
2459
|
+
n(new Error(r.message, { cause: r }));
|
|
2460
|
+
return;
|
|
2461
|
+
}
|
|
2462
|
+
e = De(e, o, i);
|
|
2463
|
+
}
|
|
2464
|
+
l(e);
|
|
2465
|
+
});
|
|
2466
|
+
}
|
|
2467
|
+
getFormDataValue(e, t) {
|
|
2468
|
+
if (t !== !0) {
|
|
2469
|
+
let i = new FormData();
|
|
2470
|
+
for (let [l, n] of Object.entries(e))
|
|
2471
|
+
i.set(l, n);
|
|
2472
|
+
for (let [l, n] of Object.entries(this.allFieldInfo))
|
|
2473
|
+
xe(i, n, n.$instance.getValue());
|
|
2474
|
+
return i;
|
|
2475
|
+
}
|
|
2476
|
+
return new Promise((i, l) => {
|
|
2477
|
+
let n = new FormData();
|
|
2478
|
+
for (let [a, o] of Object.entries(e))
|
|
2479
|
+
n.set(a, o);
|
|
2480
|
+
for (let [a, o] of Object.entries(this.allFieldInfo)) {
|
|
2481
|
+
if (!o.$instance.isEnableView())
|
|
2482
|
+
continue;
|
|
2483
|
+
let r = this.getFieldValidation(o, !0);
|
|
2484
|
+
if (r !== !0) {
|
|
2485
|
+
l(new Error(r.message, { cause: r }));
|
|
2486
|
+
return;
|
|
2487
|
+
}
|
|
2488
|
+
xe(n, o, o.$instance.getValue());
|
|
2489
|
+
}
|
|
2490
|
+
i(n);
|
|
2491
|
+
});
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
*
|
|
2495
|
+
*
|
|
2496
|
+
* @param field
|
|
2497
|
+
* @returns
|
|
2498
|
+
*/
|
|
2499
|
+
isConditionFieldCheck(e) {
|
|
2500
|
+
let t = e;
|
|
2501
|
+
for (; typeof t < "u"; ) {
|
|
2502
|
+
if (!this.isConditionField(t))
|
|
2503
|
+
return !1;
|
|
2504
|
+
t = t.$parent;
|
|
2505
|
+
}
|
|
2506
|
+
return !0;
|
|
2507
|
+
}
|
|
2508
|
+
/**
|
|
2509
|
+
* field 활성 비활성화 여부.
|
|
2510
|
+
*
|
|
2511
|
+
* @param field form field
|
|
2512
|
+
* @returns
|
|
2513
|
+
*/
|
|
2514
|
+
isConditionField(e) {
|
|
2515
|
+
if (!this.conditionFields.includes(e.$key))
|
|
2516
|
+
return !0;
|
|
2517
|
+
let t = !1;
|
|
2518
|
+
if (e.conditional.custom)
|
|
2519
|
+
t = e.conditional.custom.call(null, e);
|
|
2520
|
+
else if (e.conditional.field) {
|
|
2521
|
+
const i = this.getFieldName(e.conditional.field);
|
|
2522
|
+
i && e.conditional.eq == i.$instance.getValue() && (t = !0);
|
|
2523
|
+
}
|
|
2524
|
+
return t;
|
|
2525
|
+
}
|
|
2526
|
+
/**
|
|
2527
|
+
* 컬럼 로우 보이고 안보이기 체크.
|
|
2528
|
+
*
|
|
2529
|
+
* @public
|
|
2530
|
+
*/
|
|
2531
|
+
conditionCheck() {
|
|
2532
|
+
this.conditionFields.forEach((e) => {
|
|
2533
|
+
const t = this.allFieldInfo[e];
|
|
2534
|
+
this.isConditionField(t) ? t.$instance.show() : t.$instance.hide();
|
|
2535
|
+
});
|
|
2536
|
+
}
|
|
2537
|
+
/**
|
|
2538
|
+
* field validation check
|
|
2539
|
+
*
|
|
2540
|
+
* @param fieldInfo FormField
|
|
2541
|
+
* @returns boolean true or ValidResult
|
|
2542
|
+
*/
|
|
2543
|
+
getFieldValidation(e, t) {
|
|
2544
|
+
if (!this.isConditionFieldCheck(e))
|
|
2545
|
+
return !0;
|
|
2546
|
+
const i = e.$instance;
|
|
2547
|
+
let l = i.valid();
|
|
2548
|
+
return l === !0 ? !0 : (t && i.focus(), l = l, y(l.message) && (l.message = I.validMessage(e, l)[0]), l);
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
function De(s, e, t) {
|
|
2552
|
+
if (Ce(e))
|
|
2553
|
+
return s;
|
|
2554
|
+
const i = e.$instance.getValue();
|
|
2555
|
+
if (e.renderType === "file") {
|
|
2556
|
+
const l = i.uploadFile;
|
|
2557
|
+
s[e.$validName] = l, s[e.$validName + "RemoveIds"] = i.removeIds;
|
|
2558
|
+
} else if (t !== !0)
|
|
2559
|
+
if (j(e))
|
|
2560
|
+
for (let [l, n] of Object.entries(i))
|
|
2561
|
+
s[l] = n;
|
|
2562
|
+
else
|
|
2563
|
+
C(e.name) || (s[e.name] = i);
|
|
2564
|
+
else
|
|
2565
|
+
s[e.$validName] = i;
|
|
2566
|
+
return s;
|
|
2567
|
+
}
|
|
2568
|
+
function xe(s, e, t) {
|
|
2569
|
+
if (Ce(e))
|
|
2570
|
+
return s;
|
|
2571
|
+
const i = e.$instance.getValue();
|
|
2572
|
+
if (e.renderType === "file") {
|
|
2573
|
+
const l = i.uploadFile;
|
|
2574
|
+
s.delete(e.$validName);
|
|
2575
|
+
for (let n of l)
|
|
2576
|
+
s.append(e.$validName, n);
|
|
2577
|
+
s.set(e.$validName + "RemoveIds", i.removeIds);
|
|
2578
|
+
} else if (t !== !0)
|
|
2579
|
+
if (j(e))
|
|
2580
|
+
for (let [l, n] of Object.entries(i))
|
|
2581
|
+
s.set(l, n);
|
|
2582
|
+
else
|
|
2583
|
+
C(e.name) || s.set(e.$validName, i);
|
|
2584
|
+
else
|
|
2585
|
+
s.set(e.$validName, i);
|
|
2586
|
+
return s;
|
|
2587
|
+
}
|
|
2588
|
+
class bt {
|
|
2589
|
+
constructor(e, t, i) {
|
|
2590
|
+
this.addRowFields = [], this.daraform = e, this.options = e.getOptions(), this.formElement = t, this.fieldInfoMap = i;
|
|
2591
|
+
}
|
|
2592
|
+
/**
|
|
2593
|
+
* field row 추가.
|
|
2594
|
+
*
|
|
2595
|
+
* @param field
|
|
2596
|
+
*/
|
|
2597
|
+
addRow(e) {
|
|
2598
|
+
this.checkHiddenField(e) || (this.addRowFields = [], this.addRowTemplate(e));
|
|
2599
|
+
}
|
|
2600
|
+
/**
|
|
2601
|
+
* 그룹 템플릿
|
|
2602
|
+
*
|
|
2603
|
+
* @param {FormField} field
|
|
2604
|
+
* @returns {string} row template
|
|
2605
|
+
*/
|
|
2606
|
+
addRowTemplate(e) {
|
|
2607
|
+
let t = this.isLabelHide(e), i = A(this.options, e, null, t);
|
|
2608
|
+
this.addRowFieldInfo(e);
|
|
2609
|
+
const l = z(`
|
|
2610
|
+
<div class="df-row df-form-group ${i.fieldClass}" id="${e.$key}">
|
|
2611
|
+
${t ? "" : `<div class="df-label ${i.labelClass} ${i.labelAlignClass}" title="${e.label ?? ""}" style="${i.labelStyle}">${this.getLabelTemplate(e)}</div>`}
|
|
2612
|
+
|
|
2613
|
+
<div class="df-field-container ${i.valueClass} ${e.required ? "required" : ""}" style="${i.valueStyle}"></div>
|
|
2614
|
+
</div>
|
|
2615
|
+
`);
|
|
2616
|
+
l && (this.createField(e, l), this.formElement.append(l), e.children && this.childTemplate(e, i));
|
|
2617
|
+
}
|
|
2618
|
+
createField(e, t) {
|
|
2619
|
+
e.$instance = new e.$renderType(e, t, this.daraform);
|
|
2620
|
+
}
|
|
2621
|
+
/**
|
|
2622
|
+
* child template
|
|
2623
|
+
*
|
|
2624
|
+
* @param {FormField} field
|
|
2625
|
+
* @param {FieldStyle} parentFieldStyle
|
|
2626
|
+
* @returns {*}
|
|
2627
|
+
*/
|
|
2628
|
+
childTemplate(e, t) {
|
|
2629
|
+
let i = null, l = !0, n = !1;
|
|
2630
|
+
if (!e.$renderType.isChildrenCreate())
|
|
2631
|
+
return;
|
|
2632
|
+
const a = document.createElement("div");
|
|
2633
|
+
a.classList.add("df-row", t.rowStyleClass ?? "");
|
|
2634
|
+
let o = 0;
|
|
2635
|
+
for (const r of e.children) {
|
|
2636
|
+
if (C(r))
|
|
2637
|
+
throw new Error(`parent field :[${e.$validName}], children index ${o}, empty [${r}]`);
|
|
2638
|
+
if (r.$parent = e, ++o, this.checkHiddenField(r))
|
|
2639
|
+
continue;
|
|
2640
|
+
this.addRowFieldInfo(r), l && (i = r);
|
|
2641
|
+
let d = this.isLabelHide(r), h, u = "";
|
|
2642
|
+
d ? (h = A(this.options, r, i, !n), u = n ? `<span class="df-label df-empty ${h.labelClass}" style="${h.labelStyle}"></span>` : "") : (h = A(this.options, r, i, !1), u = `<span class="df-label ${h.labelClass} ${h.labelAlignClass}" title="${r.label ?? ""}" style="${h.labelStyle}">${this.getLabelTemplate(r)}</span>`);
|
|
2643
|
+
const c = z(`<div class="df-form-group ${h.fieldClass}" style="${h.fieldStyle}" id="${r.$key}">
|
|
2644
|
+
${u}
|
|
2645
|
+
<span class="df-field-container ${h.valueClass} ${r.required ? "required" : ""}" style="${h.valueStyle}"></span>
|
|
2646
|
+
</div>`);
|
|
2647
|
+
c && (this.createField(r, c), a.append(c), r.children && this.childTemplate(r, r.children ? h : t)), d || (n = !0), l = !1;
|
|
2648
|
+
}
|
|
2649
|
+
e.$instance.addChildField(a);
|
|
2650
|
+
}
|
|
2651
|
+
/**
|
|
2652
|
+
* label template
|
|
2653
|
+
*
|
|
2654
|
+
* @param {FormField} field form field
|
|
2655
|
+
* @returns {string} template string
|
|
2656
|
+
*/
|
|
2657
|
+
getLabelTemplate(e) {
|
|
2658
|
+
const t = e.required ? '<span class="required"></span>' : "", i = D(e.tooltip) ? "" : `<span class="df-tooltip">?<span class="df-tooltip-text">${e.tooltip}</span></span>`;
|
|
2659
|
+
return `${e.label ?? ""} ${i} ${t}`;
|
|
2660
|
+
}
|
|
2661
|
+
/**
|
|
2662
|
+
* label 숨김 여부
|
|
2663
|
+
*
|
|
2664
|
+
* @param field formfield
|
|
2665
|
+
* @returns
|
|
2666
|
+
*/
|
|
2667
|
+
isLabelHide(e) {
|
|
2668
|
+
var t;
|
|
2669
|
+
return ((t = e.style) == null ? void 0 : t.labelHide) || y(e.label);
|
|
2670
|
+
}
|
|
2671
|
+
checkHiddenField(e) {
|
|
2672
|
+
return je(e) ? (this.fieldInfoMap.addField(e), e.$instance = new e.$renderType(e, null, this.daraform), !0) : !1;
|
|
2673
|
+
}
|
|
2674
|
+
/**
|
|
2675
|
+
* add row file map
|
|
2676
|
+
*
|
|
2677
|
+
* @param {FormField} field
|
|
2678
|
+
*/
|
|
2679
|
+
addRowFieldInfo(e) {
|
|
2680
|
+
if (!D(e.name) && this.fieldInfoMap.hasFieldName(e.name))
|
|
2681
|
+
throw new Error(`Duplicate field name "${e.name}"`);
|
|
2682
|
+
this.fieldInfoMap.addField(e), this.addRowFields.push(e.$key);
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
function wt(s) {
|
|
2686
|
+
return he({}, re, s);
|
|
2687
|
+
}
|
|
2688
|
+
function Mt(s) {
|
|
2689
|
+
re = he({}, re, s);
|
|
2690
|
+
}
|
|
2691
|
+
let re = {
|
|
2692
|
+
style: {
|
|
2693
|
+
width: "100%",
|
|
2694
|
+
labelWidth: 3,
|
|
2695
|
+
valueWidth: 9,
|
|
2696
|
+
position: "left-right"
|
|
2697
|
+
},
|
|
2698
|
+
mode: "new",
|
|
2699
|
+
useTypeValue: !0,
|
|
2700
|
+
autoCreate: !0,
|
|
2701
|
+
notValidMessage: "This form is not valid.",
|
|
2702
|
+
fields: []
|
|
2703
|
+
};
|
|
2704
|
+
const Z = {}, Ve = "data-form-uid";
|
|
2705
|
+
let Ft = 0;
|
|
2706
|
+
const _ = class _ {
|
|
2707
|
+
constructor(e, t, i) {
|
|
2708
|
+
if (this.formValue = {}, this.changeListeners = [], this.changeMode = (l) => {
|
|
2709
|
+
this.options.mode = l, this.formElement.setAttribute("data-df-mode", l);
|
|
2710
|
+
}, this.resetForm = () => {
|
|
2711
|
+
const l = this.fieldInfoMap.getAllFieldInfo();
|
|
2712
|
+
for (const n in l) {
|
|
2713
|
+
const o = l[n].$instance;
|
|
2714
|
+
o && typeof o.reset == "function" && o.reset();
|
|
2715
|
+
}
|
|
2716
|
+
this.formValue = {}, this.conditionCheck();
|
|
2717
|
+
}, this.resetField = (l) => {
|
|
2718
|
+
this.fieldInfoMap.getFieldName(l).$instance.reset(), this.formValue[l] = "", this.conditionCheck();
|
|
2719
|
+
}, this.getFieldValue = (l) => {
|
|
2720
|
+
const n = this.fieldInfoMap.getFieldName(l);
|
|
2721
|
+
return n ? n.$instance.getValue() : null;
|
|
2722
|
+
}, this.getValue = (l) => this.fieldInfoMap.getAllFieldValue(this.formValue, l), this.getFormDataValue = (l) => this.fieldInfoMap.getFormDataValue(this.formValue, l), this.setValue = (l, n) => {
|
|
2723
|
+
n !== !1 && this.resetForm(), Object.keys(l).forEach((a) => {
|
|
2724
|
+
this._setFieldValue(a, l[a]);
|
|
2725
|
+
}), this.conditionCheck();
|
|
2726
|
+
}, this.setFieldValue = (l, n) => {
|
|
2727
|
+
this._setFieldValue(l, n), this.conditionCheck();
|
|
2728
|
+
}, this.setFieldItems = (l, n) => {
|
|
2729
|
+
const a = this.fieldInfoMap.getFieldName(l);
|
|
2730
|
+
if (a)
|
|
2731
|
+
return a.$instance.setValueItems(n);
|
|
2732
|
+
}, this.addField = (l) => {
|
|
2733
|
+
this.options.fields.push(l), this.formTemplate.addRow(l), this.conditionCheck();
|
|
2734
|
+
}, this.removeField = (l) => {
|
|
2735
|
+
const n = this.fieldInfoMap.getFieldName(l);
|
|
2736
|
+
if (!n) return;
|
|
2737
|
+
const a = this.getRemoveFields(n);
|
|
2738
|
+
a.forEach((o) => {
|
|
2739
|
+
this.removeFormValue(o);
|
|
2740
|
+
}), this.removeFieldElement(n), this.removeParentChildField(n), a.forEach((o) => {
|
|
2741
|
+
this.fieldInfoMap.removeFieldInfoByKey(o.$key);
|
|
2742
|
+
}), this.conditionCheck();
|
|
2743
|
+
}, this.isValidForm = () => this.validForm().length < 1, this.validForm = () => {
|
|
2744
|
+
let l = [], n = this.options.autoFocus !== !1, a = !0;
|
|
2745
|
+
const o = this.fieldInfoMap.getAllFieldInfo();
|
|
2746
|
+
for (const r in o) {
|
|
2747
|
+
const d = o[r];
|
|
2748
|
+
let h = this.fieldInfoMap.getFieldValidation(d, n);
|
|
2749
|
+
h !== !0 && (n = !1, Le(d) ? l = l.concat(h) : (a && (this.validTabCheck(d), a = !1), l.push(h)));
|
|
2750
|
+
}
|
|
2751
|
+
return l;
|
|
2752
|
+
}, this.isValidField = (l) => {
|
|
2753
|
+
const n = this.fieldInfoMap.getFieldName(l);
|
|
2754
|
+
if (y(n))
|
|
2755
|
+
throw new Error(`Field name [${l}] not found`);
|
|
2756
|
+
const a = n.$instance;
|
|
2757
|
+
return a ? a.valid() === !0 : !0;
|
|
2758
|
+
}, this.getOptions = () => this.options, this.subscribe = (l) => (this.changeListeners.push(l), () => {
|
|
2759
|
+
this.changeListeners = this.changeListeners.filter((n) => n !== l);
|
|
2760
|
+
}), this.destroy = () => {
|
|
2761
|
+
this.formElement.className = this.orginFormStyleClass, this.formElement.replaceChildren();
|
|
2762
|
+
for (const l in this)
|
|
2763
|
+
Ye(this, l) && (delete this[l], delete Z[this.selector]);
|
|
2764
|
+
}, this.getFields = () => this.options.fields, this.setFields = (l) => {
|
|
2765
|
+
this.options.fields = l, this.createForm(l);
|
|
2766
|
+
}, this.options = wt(t), I.set(i), e)
|
|
2767
|
+
this.orginFormStyleClass = e.className, e.classList.add("daracl-form"), this.selector = `df_${++Ft}`, e.setAttribute("name", this.selector), e.setAttribute(Ve, 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 && (Z[this.selector] = this);
|
|
2768
|
+
else
|
|
2769
|
+
throw new Error(`${e} form selector not found`);
|
|
2770
|
+
}
|
|
2771
|
+
static create(e, t, i) {
|
|
2772
|
+
return new _(e, t, i);
|
|
2773
|
+
}
|
|
2774
|
+
static setMessage(e) {
|
|
2775
|
+
I.set(e);
|
|
2776
|
+
}
|
|
2777
|
+
static setDefaultOptions(e, t) {
|
|
2778
|
+
Mt(e), t && I.set(t);
|
|
2779
|
+
}
|
|
2780
|
+
createForm(e) {
|
|
2781
|
+
this.fieldInfoMap = new $t(this.selector, this), this.formTemplate = new bt(this, this.formElement, this.fieldInfoMap), this.options.autoCreate !== !1 && (e.forEach((t) => {
|
|
2782
|
+
this.formTemplate.addRow(t);
|
|
2783
|
+
}), this.conditionCheck(), this.options.onMounted && this.options.onMounted.call(this));
|
|
2784
|
+
}
|
|
2785
|
+
/**
|
|
2786
|
+
* 필드 element 얻기
|
|
2787
|
+
*
|
|
2788
|
+
* @param {string} fieldName
|
|
2789
|
+
* @returns {*}
|
|
2790
|
+
*/
|
|
2791
|
+
getFieldElement(e) {
|
|
2792
|
+
const t = this.fieldInfoMap.getFieldName(e);
|
|
2793
|
+
return t != null && t.$instance ? t.$instance.getElement() : null;
|
|
2794
|
+
}
|
|
2795
|
+
getField(e) {
|
|
2796
|
+
return this.fieldInfoMap.getFieldName(e);
|
|
2797
|
+
}
|
|
2798
|
+
_setFieldValue(e, t) {
|
|
2799
|
+
this.formValue[e] = t;
|
|
2800
|
+
const i = this.fieldInfoMap.getFieldName(e);
|
|
2801
|
+
i && i.$instance.setValue(t);
|
|
2802
|
+
}
|
|
2803
|
+
/**
|
|
2804
|
+
* 제거할 필드와 같은 fieldInfoMap에 등록된 하위 필드(group 하위 필드, tab 패널) 목록
|
|
2805
|
+
* grid 컬럼, tab 패널 내부 필드는 별도 form에 등록되므로 제외됨.
|
|
2806
|
+
*
|
|
2807
|
+
* @param {FormField} fieldInfo
|
|
2808
|
+
* @param {FormField[]} result
|
|
2809
|
+
* @returns {FormField[]}
|
|
2810
|
+
*/
|
|
2811
|
+
getRemoveFields(e, t = []) {
|
|
2812
|
+
var i;
|
|
2813
|
+
return t.push(e), (i = e.children) == null || i.forEach((l) => {
|
|
2814
|
+
l && this.fieldInfoMap.get(l.$key) === l && this.getRemoveFields(l, t);
|
|
2815
|
+
}), t;
|
|
2816
|
+
}
|
|
2817
|
+
/**
|
|
2818
|
+
* field element 제거
|
|
2819
|
+
*
|
|
2820
|
+
* @param {FormField} fieldInfo
|
|
2821
|
+
*/
|
|
2822
|
+
removeFieldElement(e) {
|
|
2823
|
+
var o, r;
|
|
2824
|
+
const t = e.$parent;
|
|
2825
|
+
if (t && j(t)) {
|
|
2826
|
+
const d = t.$instance.getElement(), h = d.querySelector(`[data-tab-id="${e.$key}"]`), u = h == null ? void 0 : h.classList.contains("active");
|
|
2827
|
+
h == null || h.remove(), (o = d.querySelector(`[tab-panel-id="${e.$key}"]`)) == null || o.remove();
|
|
2828
|
+
const c = d.querySelector(".df-tab-header .df-tab-item");
|
|
2829
|
+
u && c && t.$instance.setActive(c.getAttribute("data-tab-id") ?? "");
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2832
|
+
const i = `[id="${e.$key}"]`;
|
|
2833
|
+
let l = (r = e.$instance) == null ? void 0 : r.getElement();
|
|
2834
|
+
(l instanceof NodeList || l instanceof HTMLCollection) && (l = l[0] ?? null);
|
|
2835
|
+
const n = (l instanceof Element ? l.closest(i) : null) ?? this.formElement.querySelector(i), a = n == null ? void 0 : n.parentElement;
|
|
2836
|
+
n == null || n.remove(), t && (a != null && a.classList.contains("df-row")) && a.childElementCount < 1 && a.remove();
|
|
2837
|
+
}
|
|
2838
|
+
/**
|
|
2839
|
+
* 부모 children(최상위는 options.fields)에서 필드 제거
|
|
2840
|
+
* tab 은 children 기준으로 값/유효성 체크를 하므로 제거해야 함.
|
|
2841
|
+
*
|
|
2842
|
+
* @param {FormField} fieldInfo
|
|
2843
|
+
*/
|
|
2844
|
+
removeParentChildField(e) {
|
|
2845
|
+
const t = e.$parent ? e.$parent.children : this.options.fields, i = t ? t.indexOf(e) : -1;
|
|
2846
|
+
i > -1 && (t == null || t.splice(i, 1));
|
|
2847
|
+
}
|
|
2848
|
+
/**
|
|
2849
|
+
* getValue() 시 formValue에 누적된 field 값 제거
|
|
2850
|
+
*
|
|
2851
|
+
* @param {FormField} fieldInfo
|
|
2852
|
+
*/
|
|
2853
|
+
removeFormValue(e) {
|
|
2854
|
+
const t = [e.name, e.$validName];
|
|
2855
|
+
e.renderType === "file" ? t.push(e.$validName + "RemoveIds") : j(e) && t.push(...Object.keys(e.$instance.getValue() ?? {})), e.$tabForm && t.push(...Object.keys(e.$tabForm.getValue(!1) ?? {})), t.forEach((i) => {
|
|
2856
|
+
D(i) || delete this.formValue[i];
|
|
2857
|
+
});
|
|
2858
|
+
}
|
|
2859
|
+
validTabCheck(e) {
|
|
2860
|
+
e.$parent && (e.$parent.renderType == "tab" && e.$parent.$instance.setActive(e.$key), this.validTabCheck(e.$parent));
|
|
2861
|
+
}
|
|
2862
|
+
conditionCheck() {
|
|
2863
|
+
this.fieldInfoMap.conditionCheck(), this.notifyChange();
|
|
2864
|
+
}
|
|
2865
|
+
notifyChange() {
|
|
2866
|
+
if (this.changeListeners.length < 1) return;
|
|
2867
|
+
const e = { form: this };
|
|
2868
|
+
this.changeListeners.forEach((t) => t(e));
|
|
2869
|
+
}
|
|
2870
|
+
setFieldDisabled(e, t) {
|
|
2871
|
+
this.fieldInfoMap.getFieldName(e).$instance.setDisabled(t);
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* 설명 추가
|
|
2875
|
+
*
|
|
2876
|
+
* @public
|
|
2877
|
+
* @param {string} fieldName
|
|
2878
|
+
* @param {string} desc
|
|
2879
|
+
*/
|
|
2880
|
+
setFieldDescription(e, t) {
|
|
2881
|
+
this.fieldInfoMap.getFieldName(e).$instance.setDescription(t);
|
|
2882
|
+
}
|
|
2883
|
+
static instance(e) {
|
|
2884
|
+
let t;
|
|
2885
|
+
oe(e) ? t = document.querySelector(e) : t = e, t = t;
|
|
2886
|
+
let i = t.getAttribute(Ve);
|
|
2887
|
+
if (y(i) || D(i)) {
|
|
2888
|
+
const l = Object.keys(Z);
|
|
2889
|
+
if (l.length > 1)
|
|
2890
|
+
throw new Error(`selector empty : [${i}]`);
|
|
2891
|
+
return i = l[0], Z[i];
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
getFieldInfoMap() {
|
|
2895
|
+
return this.fieldInfoMap;
|
|
2896
|
+
}
|
|
2897
|
+
};
|
|
2898
|
+
_.VERSION = "0.0.18", _.validator = {
|
|
2899
|
+
string: (e, t) => R(e, t),
|
|
2900
|
+
number: (e, t) => ue(e, t),
|
|
2901
|
+
regexp: (e, t) => {
|
|
2902
|
+
let i = { name: t.name, constraint: [] };
|
|
2903
|
+
return Ie(e, t, i);
|
|
2904
|
+
}
|
|
2905
|
+
};
|
|
2906
|
+
let te = _;
|
|
2907
|
+
export {
|
|
2908
|
+
te as DaraForm
|
|
2909
|
+
};
|
|
2910
|
+
//# sourceMappingURL=index.min.js.map
|