@daracl/form 0.0.19 → 0.0.22
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 +51 -18
- package/dist/daracl.form.css +312 -160
- package/dist/daracl.form.min.css +1 -10
- package/dist/daracl.form.min.umd.js +36 -41
- package/dist/daracl.form.min.umd.js.map +1 -1
- package/dist/daracl.form.umd.js +221 -226
- package/dist/daracl.form.umd.js.map +1 -1
- package/dist/defaultOption.d.ts +3 -0
- package/dist/index.cjs +104 -1537
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +58 -1491
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +33 -98
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +471 -1384
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.d.ts +1 -0
- package/dist/util/utils.d.ts +8 -30
- package/package.json +37 -49
- package/style/base/_base.scss +7 -6
- package/style/components/_button.scss +5 -4
- package/style/components/_field-container.scss +4 -3
- package/style/components/_field-group.scss +1 -1
- package/style/components/_file-list.scss +3 -2
- package/style/components/_form-field.scss +13 -4
- package/style/components/_form-group.scss +8 -7
- package/style/components/_grid-field.scss +12 -11
- package/style/components/_icon.scss +2 -1
- package/style/components/_label.scss +10 -9
- package/style/components/_tab.scss +8 -7
- package/style/daracl.form.scss +17 -31
- package/style/themes/_common.scss +0 -18
- package/style/themes/_dark.scss +0 -32
- package/style/themes/_index.scss +0 -14
- package/style/themes/_light.scss +0 -26
- package/style/themes/_mixin.scss +0 -6
package/dist/index.cjs
CHANGED
|
@@ -1,184 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
"&": "&",
|
|
6
|
-
"<": "<",
|
|
7
|
-
">": ">",
|
|
8
|
-
'"': """,
|
|
9
|
-
"'": "'"
|
|
10
|
-
};
|
|
11
|
-
const replaceXss = (inputText) => {
|
|
12
|
-
let returnText = inputText;
|
|
13
|
-
if (returnText) {
|
|
14
|
-
Object.keys(xssFilter).forEach((key) => {
|
|
15
|
-
returnText = returnText.replaceAll(key, xssFilter[key]);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return returnText;
|
|
19
|
-
};
|
|
20
|
-
const hasOwnProp = (obj, key) => {
|
|
21
|
-
return obj.hasOwnProperty(key);
|
|
22
|
-
};
|
|
23
|
-
const isBlank = (value) => {
|
|
24
|
-
if (value === null) return true;
|
|
25
|
-
if (value === "") return true;
|
|
26
|
-
if (typeof value === "undefined") return true;
|
|
27
|
-
if (typeof value === "string" && (value === "" || value.replace(/\s/g, "") === "")) return true;
|
|
28
|
-
return false;
|
|
29
|
-
};
|
|
30
|
-
const isUndefined = (value) => {
|
|
31
|
-
return typeof value === "undefined";
|
|
32
|
-
};
|
|
33
|
-
const isFunction = (value) => {
|
|
34
|
-
return typeof value === "function";
|
|
35
|
-
};
|
|
36
|
-
const isString = (value) => {
|
|
37
|
-
return typeof value === "string";
|
|
38
|
-
};
|
|
3
|
+
const utils = require("@daracl/core/utils");
|
|
4
|
+
const datetimepicker = require("@daracl/datetimepicker");
|
|
39
5
|
const isNumber = (value) => {
|
|
40
|
-
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
value = +value;
|
|
44
|
-
return !isNaN(value);
|
|
45
|
-
};
|
|
46
|
-
const isArray = (value) => {
|
|
47
|
-
return core.isArray(value);
|
|
6
|
+
return !utils.isBlank(value) && utils.isNumeric(+value, true);
|
|
48
7
|
};
|
|
49
|
-
const isEmpty = (value) => isUndefined(value) || value == null;
|
|
50
8
|
const isTabType = (field) => {
|
|
51
|
-
return field
|
|
9
|
+
return (field == null ? void 0 : field.renderType) === "tab";
|
|
52
10
|
};
|
|
53
11
|
const isGridType = (field) => {
|
|
54
|
-
return field
|
|
12
|
+
return (field == null ? void 0 : field.renderType) === "grid";
|
|
55
13
|
};
|
|
56
14
|
const replaceXssField = (field) => {
|
|
57
15
|
field.$xssName = getXssFieldName(field);
|
|
58
|
-
field.label =
|
|
16
|
+
field.label = utils.xss(field.label);
|
|
59
17
|
return field;
|
|
60
18
|
};
|
|
61
19
|
const ignoreValueField = (field) => {
|
|
62
20
|
return isGridType(field.$parent) || isTabType(field.$parent);
|
|
63
21
|
};
|
|
64
22
|
const getXssFieldName = (field) => {
|
|
65
|
-
if (isUndefined(field.$xssName)) {
|
|
23
|
+
if (utils.isUndefined(field.$xssName)) {
|
|
66
24
|
let returnText = field.name;
|
|
67
25
|
if (returnText) {
|
|
68
|
-
|
|
69
|
-
returnText = returnText.replaceAll(key, "_");
|
|
70
|
-
});
|
|
26
|
+
returnText = returnText.replace(/[&<>"']/g, "_");
|
|
71
27
|
}
|
|
72
28
|
return "df_" + returnText;
|
|
73
29
|
}
|
|
74
30
|
return field.$xssName;
|
|
75
31
|
};
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
let tmpChar = str.charCodeAt(i);
|
|
81
|
-
hash = (hash << 5) - hash + tmpChar;
|
|
82
|
-
hash = hash & hash;
|
|
83
|
-
}
|
|
84
|
-
return String(hash).replaceAll(/-/g, "_");
|
|
85
|
-
};
|
|
86
|
-
const isHiddenField = (field) => {
|
|
87
|
-
if (field.renderType === "hidden") {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
return false;
|
|
91
|
-
};
|
|
92
|
-
const templateToElement = (htmlTemplate) => {
|
|
93
|
-
const template = document.createElement("template");
|
|
94
|
-
template.innerHTML = htmlTemplate;
|
|
95
|
-
return template.content.firstElementChild;
|
|
96
|
-
};
|
|
97
|
-
function isPlainObject(obj) {
|
|
98
|
-
if (typeof obj !== "object" || obj === null) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
let proto = obj;
|
|
102
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
103
|
-
proto = Object.getPrototypeOf(proto);
|
|
104
|
-
}
|
|
105
|
-
return Object.getPrototypeOf(obj) === proto;
|
|
106
|
-
}
|
|
107
|
-
function isObject(value) {
|
|
108
|
-
return typeof value === "object" && value !== null && !isArray(value);
|
|
109
|
-
}
|
|
110
|
-
function isDate(value) {
|
|
111
|
-
return value instanceof Date && !isNaN(value.valueOf());
|
|
112
|
-
}
|
|
113
|
-
const merge = (...value) => {
|
|
114
|
-
let reval = value[0];
|
|
115
|
-
if (!isPlainObject(reval) || isEmpty(reval)) {
|
|
116
|
-
return reval;
|
|
117
|
-
}
|
|
118
|
-
let i = 1;
|
|
119
|
-
if (Object.keys(reval).length > 0) {
|
|
120
|
-
i = 0;
|
|
121
|
-
reval = isArray(reval) ? [] : {};
|
|
122
|
-
}
|
|
123
|
-
const argLen = value.length;
|
|
124
|
-
for (; i < argLen; i += 1) {
|
|
125
|
-
cloneDeep(reval, value[i]);
|
|
126
|
-
}
|
|
127
|
-
return reval;
|
|
32
|
+
const isHiddenField = (field) => (field == null ? void 0 : field.renderType) === "hidden";
|
|
33
|
+
const merge = (...values) => {
|
|
34
|
+
if (!utils.isPlainObject(values[0])) return values[0];
|
|
35
|
+
return utils.objectDeepMerge(...values, {});
|
|
128
36
|
};
|
|
129
|
-
function cloneDeep(dst, src) {
|
|
130
|
-
if (isObject(src)) {
|
|
131
|
-
return cloneObjectDeep(dst, src);
|
|
132
|
-
}
|
|
133
|
-
if (isArray(src)) {
|
|
134
|
-
return cloneArrayDeep(dst, src);
|
|
135
|
-
}
|
|
136
|
-
if (isDate(src)) {
|
|
137
|
-
return new src.constructor(src);
|
|
138
|
-
}
|
|
139
|
-
return src;
|
|
140
|
-
}
|
|
141
|
-
function cloneObjectDeep(dst, src) {
|
|
142
|
-
if (isFunction(src)) {
|
|
143
|
-
return src;
|
|
144
|
-
}
|
|
145
|
-
for (const key of Object.keys(src)) {
|
|
146
|
-
const val = src[key];
|
|
147
|
-
if (isUndefined(val)) {
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (val === null) {
|
|
151
|
-
dst[key] = val;
|
|
152
|
-
} else if (isFunction(val)) {
|
|
153
|
-
dst[key] = val;
|
|
154
|
-
} else if (isEmpty(dst[key])) {
|
|
155
|
-
dst[key] = cloneDeep(isArray(val) ? [] : {}, val);
|
|
156
|
-
} else if (!isObject(val)) {
|
|
157
|
-
dst[key] = val;
|
|
158
|
-
} else {
|
|
159
|
-
cloneDeep(dst[key], val);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return dst;
|
|
163
|
-
}
|
|
164
|
-
function cloneArrayDeep(dst, src) {
|
|
165
|
-
const isObj = isPlainObject(dst);
|
|
166
|
-
for (let i = 0; i < src.length; i += 1) {
|
|
167
|
-
const val = src[i];
|
|
168
|
-
let newVal;
|
|
169
|
-
if (val == null) {
|
|
170
|
-
newVal = val;
|
|
171
|
-
} else {
|
|
172
|
-
newVal = cloneDeep(isArray(val) ? [] : {}, val);
|
|
173
|
-
}
|
|
174
|
-
if (isObj) {
|
|
175
|
-
dst[i] = newVal;
|
|
176
|
-
} else {
|
|
177
|
-
dst.push(newVal);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return dst;
|
|
181
|
-
}
|
|
182
37
|
class Render {
|
|
183
38
|
constructor(form, field, rowElement) {
|
|
184
39
|
var _a;
|
|
@@ -190,12 +45,12 @@ class Render {
|
|
|
190
45
|
if (field.tooltip) (_a = rowElement.querySelector(".df-tooltip")) == null ? void 0 : _a.setAttribute("tooltip", field.tooltip);
|
|
191
46
|
}
|
|
192
47
|
setDefaultInfo() {
|
|
193
|
-
if (isUndefined(this.field.defaultValue)) {
|
|
48
|
+
if (utils.isUndefined(this.field.defaultValue)) {
|
|
194
49
|
this.setValue("", false);
|
|
195
50
|
} else {
|
|
196
51
|
this.setValue(this.field.defaultValue, false);
|
|
197
52
|
}
|
|
198
|
-
if (!isUndefined(this.field.placeholder)) {
|
|
53
|
+
if (!utils.isUndefined(this.field.placeholder)) {
|
|
199
54
|
const ele = this.getElement();
|
|
200
55
|
if (ele instanceof Element) {
|
|
201
56
|
ele.setAttribute("placeholder", this.field.placeholder);
|
|
@@ -221,8 +76,8 @@ class Render {
|
|
|
221
76
|
setValueItems(value) {
|
|
222
77
|
}
|
|
223
78
|
static getDescriptionTemplate(field) {
|
|
224
|
-
const classNames = field.descriptionClass ?
|
|
225
|
-
const style = field.descriptionStyle ? 'style="' +
|
|
79
|
+
const classNames = field.descriptionClass ? utils.xss(field.descriptionClass) : "";
|
|
80
|
+
const style = field.descriptionStyle ? 'style="' + utils.xss(field.descriptionStyle) + '"' : "";
|
|
226
81
|
return field.description ? `<div class="df-description ${classNames}" ${style}>${field.description}</div>` : "";
|
|
227
82
|
}
|
|
228
83
|
changeEventCall(field, e, rederInfo, fieldValue) {
|
|
@@ -239,12 +94,12 @@ class Render {
|
|
|
239
94
|
const valueKey = Render.valuesValueKey(field);
|
|
240
95
|
for (let val of field.listItem.list) {
|
|
241
96
|
let changeVal = val[valueKey];
|
|
242
|
-
if (isString(fieldValue)) {
|
|
97
|
+
if (utils.isString(fieldValue)) {
|
|
243
98
|
if (changeVal == fieldValue) {
|
|
244
99
|
valuesItem.push(val);
|
|
245
100
|
break;
|
|
246
101
|
}
|
|
247
|
-
} else if (isArray(fieldValue)) {
|
|
102
|
+
} else if (utils.isArray(fieldValue)) {
|
|
248
103
|
if (fieldValue.includes(changeVal)) {
|
|
249
104
|
valuesItem.push(val);
|
|
250
105
|
}
|
|
@@ -290,9 +145,9 @@ class Render {
|
|
|
290
145
|
} else {
|
|
291
146
|
const fieldEle = this.rowElement.querySelector(".df-field");
|
|
292
147
|
if (fieldEle) {
|
|
293
|
-
const
|
|
148
|
+
const parser = new DOMParser();
|
|
294
149
|
this.field.description = desc;
|
|
295
|
-
const descEle2 =
|
|
150
|
+
const descEle2 = parser.parseFromString(Render.getDescriptionTemplate(this.field), "text/html").querySelector(".df-description");
|
|
296
151
|
if (descEle2) (_a = fieldEle.parentNode) == null ? void 0 : _a.insertBefore(descEle2, fieldEle.nextSibling);
|
|
297
152
|
}
|
|
298
153
|
}
|
|
@@ -374,7 +229,7 @@ const validator = (value, field, result) => {
|
|
|
374
229
|
if (field.different) {
|
|
375
230
|
const diffFieldName = field.different.field;
|
|
376
231
|
const diffField = field.$instance.getForm().getField(diffFieldName);
|
|
377
|
-
if (!
|
|
232
|
+
if (!utils.isNil(diffField) && field.$instance.getValue() == diffField.$instance.getValue()) {
|
|
378
233
|
result.message = field.different.message;
|
|
379
234
|
return result;
|
|
380
235
|
}
|
|
@@ -382,7 +237,7 @@ const validator = (value, field, result) => {
|
|
|
382
237
|
if (field.identical) {
|
|
383
238
|
const diffFieldName = field.identical.field;
|
|
384
239
|
const diffField = field.$instance.getForm().getField(diffFieldName);
|
|
385
|
-
if (!
|
|
240
|
+
if (!utils.isNil(diffField) && field.$instance.getValue() != diffField.$instance.getValue()) {
|
|
386
241
|
result.message = field.identical.message;
|
|
387
242
|
return result;
|
|
388
243
|
}
|
|
@@ -395,7 +250,7 @@ const numberValidator = (value, field) => {
|
|
|
395
250
|
}
|
|
396
251
|
const result = { name: field.name, constraint: [] };
|
|
397
252
|
const numValue = Number(value);
|
|
398
|
-
if (field.required && isBlank(value)) {
|
|
253
|
+
if (field.required && utils.isBlank(value)) {
|
|
399
254
|
result.constraint.push(RULES.REQUIRED);
|
|
400
255
|
return result;
|
|
401
256
|
}
|
|
@@ -471,7 +326,7 @@ const invalidMessage = (field, rowElement, validResult) => {
|
|
|
471
326
|
rowElement.classList.add("invalid");
|
|
472
327
|
}
|
|
473
328
|
if (validResult !== false) {
|
|
474
|
-
const message2 =
|
|
329
|
+
const message2 = Language2.validMessage(field, validResult);
|
|
475
330
|
if (validResult.message) {
|
|
476
331
|
message2.push(validResult.message);
|
|
477
332
|
}
|
|
@@ -567,7 +422,7 @@ const stringValidator = (value, field) => {
|
|
|
567
422
|
return true;
|
|
568
423
|
}
|
|
569
424
|
let result = { name: field.name, constraint: [] };
|
|
570
|
-
if (field.required && isBlank(value)) {
|
|
425
|
+
if (field.required && utils.isBlank(value)) {
|
|
571
426
|
result.constraint.push(RULES.REQUIRED);
|
|
572
427
|
return result;
|
|
573
428
|
}
|
|
@@ -657,7 +512,7 @@ class DropdownRender extends Render {
|
|
|
657
512
|
var _a, _b, _c, _d, _e;
|
|
658
513
|
super(daraForm, field, rowElement);
|
|
659
514
|
let initDefaultValue = "";
|
|
660
|
-
if (!isUndefined(field.defaultValue)) {
|
|
515
|
+
if (!utils.isUndefined(field.defaultValue)) {
|
|
661
516
|
initDefaultValue = field.defaultValue;
|
|
662
517
|
}
|
|
663
518
|
const valueKey = DropdownRender.valuesValueKey(field);
|
|
@@ -678,7 +533,7 @@ class DropdownRender extends Render {
|
|
|
678
533
|
this.defaultSelected = ((_e = (_d = this.field.listItem) == null ? void 0 : _d.list) == null ? void 0 : _e.length) > 0 ? this.field.listItem.list[0][valueKey] || "" : "";
|
|
679
534
|
}
|
|
680
535
|
}
|
|
681
|
-
if (isUndefined(this.defaultSelected)) {
|
|
536
|
+
if (utils.isUndefined(this.defaultSelected)) {
|
|
682
537
|
this.defaultSelected = "";
|
|
683
538
|
}
|
|
684
539
|
this.mounted();
|
|
@@ -709,7 +564,7 @@ class DropdownRender extends Render {
|
|
|
709
564
|
};
|
|
710
565
|
}
|
|
711
566
|
this.element.innerHTML = this.dropdownValuesTemplate(this.field);
|
|
712
|
-
if (!isBlank(this.field.$value)) {
|
|
567
|
+
if (!utils.isBlank(this.field.$value)) {
|
|
713
568
|
const currentValue = this.field.$value;
|
|
714
569
|
this.field.$value = "";
|
|
715
570
|
this.setValue(currentValue);
|
|
@@ -752,11 +607,11 @@ class DropdownRender extends Render {
|
|
|
752
607
|
const valueKey = Render.valuesValueKey(field);
|
|
753
608
|
let template = "";
|
|
754
609
|
if (((_a = field.rendererOptions) == null ? void 0 : _a.disableDefaultOption) !== true) {
|
|
755
|
-
template += `<option value="">${
|
|
610
|
+
template += `<option value="">${Language2.getMessage("selection")}</option>`;
|
|
756
611
|
}
|
|
757
612
|
(_c = (_b = field.listItem) == null ? void 0 : _b.list) == null ? void 0 : _c.forEach((val) => {
|
|
758
613
|
const attr = `${val.selected ? "selected" : ""} ${val.disabled ? "disabled" : ""}`;
|
|
759
|
-
if (isUndefined(val[valueKey]) && val.label) {
|
|
614
|
+
if (utils.isUndefined(val[valueKey]) && val.label) {
|
|
760
615
|
template += `<option value="${val.value || ""}" ${attr}>${val.label}</option>`;
|
|
761
616
|
} else {
|
|
762
617
|
template += `<option value="${val[valueKey]}" ${attr}>${Render.valuesLabelValue(labelKey, val)}</option>`;
|
|
@@ -865,17 +720,14 @@ function resolveFieldStyle(formOptions, field, beforeField, isLabelHide) {
|
|
|
865
720
|
fieldStyle.valueClass = fieldStyle.labelStyle ? "df-col-full" : "";
|
|
866
721
|
}
|
|
867
722
|
}
|
|
868
|
-
fieldStyle.fieldClass =
|
|
869
|
-
fieldStyle.labelClass =
|
|
870
|
-
fieldStyle.valueClass =
|
|
723
|
+
fieldStyle.fieldClass = utils.resolveClassName(fieldStyle.fieldClass).join(" ");
|
|
724
|
+
fieldStyle.labelClass = utils.resolveClassName(fieldStyle.labelClass).join(" ");
|
|
725
|
+
fieldStyle.valueClass = utils.resolveClassName(fieldStyle.valueClass).join(" ");
|
|
871
726
|
return fieldStyle;
|
|
872
727
|
}
|
|
873
728
|
function orientationClassName(orientation) {
|
|
874
729
|
return orientation === "horizontal" ? "df-horizontal" : "df-vertical";
|
|
875
730
|
}
|
|
876
|
-
function spaceReplace(str) {
|
|
877
|
-
return str.replace(/\s+/g, " ").trim();
|
|
878
|
-
}
|
|
879
731
|
class CheckboxRender extends Render {
|
|
880
732
|
constructor(field, rowElement, daraForm) {
|
|
881
733
|
var _a, _b;
|
|
@@ -883,15 +735,15 @@ class CheckboxRender extends Render {
|
|
|
883
735
|
this.defaultCheckValue = [];
|
|
884
736
|
this.defaultCheckValue = [];
|
|
885
737
|
let initDefaultValue = [];
|
|
886
|
-
if (!isUndefined(field.defaultValue)) {
|
|
887
|
-
if (isArray(field.defaultValue)) {
|
|
738
|
+
if (!utils.isUndefined(field.defaultValue)) {
|
|
739
|
+
if (utils.isArray(field.defaultValue)) {
|
|
888
740
|
initDefaultValue = field.defaultValue;
|
|
889
741
|
} else {
|
|
890
742
|
initDefaultValue = [field.defaultValue];
|
|
891
743
|
}
|
|
892
744
|
}
|
|
893
745
|
const valueKey = CheckboxRender.valuesValueKey(field);
|
|
894
|
-
if (isUndefined(this.field.listItem)) {
|
|
746
|
+
if (utils.isUndefined(this.field.listItem)) {
|
|
895
747
|
this.setValueItems([{ label: "", value: "Y" }]);
|
|
896
748
|
}
|
|
897
749
|
let initDefaultValueFlag = false;
|
|
@@ -934,11 +786,11 @@ class CheckboxRender extends Render {
|
|
|
934
786
|
const valueKey = Render.valuesValueKey(field);
|
|
935
787
|
templates.push(` <div class="df-field"><div class="df-field-group">`);
|
|
936
788
|
(_b = (_a = field.listItem) == null ? void 0 : _a.list) == null ? void 0 : _b.forEach((val) => {
|
|
937
|
-
const checkVal = val[valueKey];
|
|
789
|
+
const checkVal = String(val[valueKey] ?? "");
|
|
938
790
|
templates.push(`
|
|
939
791
|
<span class="df-field-item ${orientationClassName(field.listItem.orientation ?? OrientationMap.horizontal)}">
|
|
940
792
|
<label>
|
|
941
|
-
<input type="checkbox" name="${fieldName}" value="${checkVal ?
|
|
793
|
+
<input type="checkbox" name="${fieldName}" value="${checkVal ? utils.xss(checkVal) : ""}" class="df-form-field df-checkbox" ${val.selected ? "checked" : ""} ${val.disabled ? "disabled" : ""} />
|
|
942
794
|
${Render.valuesLabelValue(labelKey, val)}
|
|
943
795
|
</label>
|
|
944
796
|
</span>
|
|
@@ -958,7 +810,7 @@ class CheckboxRender extends Render {
|
|
|
958
810
|
};
|
|
959
811
|
}
|
|
960
812
|
this.createField();
|
|
961
|
-
if (!isBlank(this.field.$value)) {
|
|
813
|
+
if (!utils.isBlank(this.field.$value)) {
|
|
962
814
|
const currentValue = this.field.$value;
|
|
963
815
|
this.field.$value = "";
|
|
964
816
|
this.setValue(currentValue);
|
|
@@ -998,7 +850,7 @@ class CheckboxRender extends Render {
|
|
|
998
850
|
return;
|
|
999
851
|
}
|
|
1000
852
|
let valueArr = [];
|
|
1001
|
-
if (isArray(value)) {
|
|
853
|
+
if (utils.isArray(value)) {
|
|
1002
854
|
valueArr = value;
|
|
1003
855
|
} else {
|
|
1004
856
|
valueArr.push(value);
|
|
@@ -1034,7 +886,7 @@ class CheckboxRender extends Render {
|
|
|
1034
886
|
valid() {
|
|
1035
887
|
const value = this.getValue();
|
|
1036
888
|
let validResult = true;
|
|
1037
|
-
if (this.field.required && isArray(value)) {
|
|
889
|
+
if (this.field.required && utils.isArray(value)) {
|
|
1038
890
|
if (value.length < 1) {
|
|
1039
891
|
validResult = { name: this.field.name, constraint: [] };
|
|
1040
892
|
validResult.constraint.push(RULES.REQUIRED);
|
|
@@ -1050,7 +902,7 @@ class RadioRender extends Render {
|
|
|
1050
902
|
super(daraForm, field, rowElement);
|
|
1051
903
|
this.defaultCheckValue = "";
|
|
1052
904
|
let initDefaultValue = [];
|
|
1053
|
-
if (!isUndefined(field.defaultValue)) {
|
|
905
|
+
if (!utils.isUndefined(field.defaultValue)) {
|
|
1054
906
|
initDefaultValue = field.defaultValue;
|
|
1055
907
|
}
|
|
1056
908
|
const valueKey = RadioRender.valuesValueKey(field);
|
|
@@ -1127,7 +979,7 @@ class RadioRender extends Render {
|
|
|
1127
979
|
};
|
|
1128
980
|
}
|
|
1129
981
|
this.createField();
|
|
1130
|
-
if (!isBlank(this.field.$value)) {
|
|
982
|
+
if (!utils.isBlank(this.field.$value)) {
|
|
1131
983
|
const currentValue = this.field.$value;
|
|
1132
984
|
this.field.$value = "";
|
|
1133
985
|
this.setValue(currentValue);
|
|
@@ -1179,7 +1031,7 @@ class RadioRender extends Render {
|
|
|
1179
1031
|
const value = this.getValue();
|
|
1180
1032
|
let validResult = true;
|
|
1181
1033
|
if (this.field.required) {
|
|
1182
|
-
if (isBlank(value)) {
|
|
1034
|
+
if (utils.isBlank(value)) {
|
|
1183
1035
|
validResult = { name: this.field.name, constraint: [] };
|
|
1184
1036
|
validResult.constraint.push(RULES.REQUIRED);
|
|
1185
1037
|
}
|
|
@@ -1286,7 +1138,7 @@ class FileRender extends Render {
|
|
|
1286
1138
|
<span class="df-file-wrapper">
|
|
1287
1139
|
<label class="df-file-label">
|
|
1288
1140
|
<input type="file" name="${field.$xssName}" class="df-form-field df-file" multiple />
|
|
1289
|
-
${
|
|
1141
|
+
${Language2.getMessage("fileButton")}
|
|
1290
1142
|
</label>
|
|
1291
1143
|
<i class="df-form-icon df-help-icon"></i>
|
|
1292
1144
|
</span>
|
|
@@ -1416,7 +1268,7 @@ class FileRender extends Render {
|
|
|
1416
1268
|
this.setFileList(this.fileList, true);
|
|
1417
1269
|
}
|
|
1418
1270
|
setValue(value) {
|
|
1419
|
-
if (
|
|
1271
|
+
if (utils.isArray(value)) {
|
|
1420
1272
|
this.setValueItems(value);
|
|
1421
1273
|
}
|
|
1422
1274
|
this.element.value = "";
|
|
@@ -1457,7 +1309,7 @@ class CustomRender extends Render {
|
|
|
1457
1309
|
}
|
|
1458
1310
|
createField() {
|
|
1459
1311
|
const field = this.field;
|
|
1460
|
-
const fieldTemplate =
|
|
1312
|
+
const fieldTemplate = utils.isNil(field.template) ? "" : utils.isString(field.template) ? field.template : field.template();
|
|
1461
1313
|
const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
|
|
1462
1314
|
fieldContainerElement.innerHTML = ` <div class="df-field">
|
|
1463
1315
|
${fieldTemplate}
|
|
@@ -1664,1298 +1516,6 @@ class RangeRender extends Render {
|
|
|
1664
1516
|
return validResult;
|
|
1665
1517
|
}
|
|
1666
1518
|
}
|
|
1667
|
-
let localeMessage$1 = {
|
|
1668
|
-
year: "Year",
|
|
1669
|
-
month: "Month",
|
|
1670
|
-
day: "Day",
|
|
1671
|
-
am: "AM",
|
|
1672
|
-
pm: "PM",
|
|
1673
|
-
today: "Today",
|
|
1674
|
-
ok: "Ok",
|
|
1675
|
-
months: {
|
|
1676
|
-
full: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
|
1677
|
-
abbr: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
|
1678
|
-
},
|
|
1679
|
-
weeks: {
|
|
1680
|
-
full: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
|
1681
|
-
abbr: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
|
1682
|
-
}
|
|
1683
|
-
};
|
|
1684
|
-
let Language$2 = class Language {
|
|
1685
|
-
constructor() {
|
|
1686
|
-
this.lang = localeMessage$1;
|
|
1687
|
-
}
|
|
1688
|
-
setDefaultMessage(lang) {
|
|
1689
|
-
localeMessage$1 = Object.assign(localeMessage$1, lang);
|
|
1690
|
-
}
|
|
1691
|
-
/**
|
|
1692
|
-
* 다국어 메시지 등록
|
|
1693
|
-
*
|
|
1694
|
-
* @public
|
|
1695
|
-
* @param {?Message} [lang] 둥록할 메시지
|
|
1696
|
-
*/
|
|
1697
|
-
set(lang) {
|
|
1698
|
-
this.lang = Object.assign({}, localeMessage$1, lang);
|
|
1699
|
-
}
|
|
1700
|
-
/**
|
|
1701
|
-
* 메시지 얻기
|
|
1702
|
-
*
|
|
1703
|
-
* @public
|
|
1704
|
-
* @param {string} messageKey 메시지 키
|
|
1705
|
-
* @returns {*}
|
|
1706
|
-
*/
|
|
1707
|
-
getMessage(messageKey) {
|
|
1708
|
-
return this.lang[messageKey];
|
|
1709
|
-
}
|
|
1710
|
-
getMonthsMessage(idx, mode = "abbr") {
|
|
1711
|
-
return this.lang.months[mode][idx] || "";
|
|
1712
|
-
}
|
|
1713
|
-
getWeeksMessage(idx, mode = "abbr") {
|
|
1714
|
-
return this.lang.weeks[mode][idx] || "";
|
|
1715
|
-
}
|
|
1716
|
-
getMonthsIdx(val, mode = "abbr") {
|
|
1717
|
-
return mode == "full" ? this.lang.months.full.indexOf(val) : this.lang.months.abbr.indexOf(val);
|
|
1718
|
-
}
|
|
1719
|
-
getWeeksIdx(val, mode = "abbr") {
|
|
1720
|
-
return mode == "full" ? this.lang.weeks.full.indexOf(val) : this.lang.weeks.abbr.indexOf(val);
|
|
1721
|
-
}
|
|
1722
|
-
};
|
|
1723
|
-
const Lanauage = new Language$2();
|
|
1724
|
-
const EXPRESSIONS_FORMAT = ["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"];
|
|
1725
|
-
let MAX_CHAR_LENGTH = 0;
|
|
1726
|
-
let DEFAULT_FORMAT = {
|
|
1727
|
-
year: "YYYY",
|
|
1728
|
-
month: "YYYY-MM",
|
|
1729
|
-
date: "YYYY-MM-DD",
|
|
1730
|
-
time: "HH:mm",
|
|
1731
|
-
datetime: "YYYY-MM-DD HH:mm"
|
|
1732
|
-
};
|
|
1733
|
-
const DAY_STYLE_CLASS = ["ddtp-sun", "ddtp-mon", "ddtp-tue", "ddtp-wed", "ddtp-thu", "ddtp-fri", "ddtp-sat"];
|
|
1734
|
-
var DateViewMode = /* @__PURE__ */ ((DateViewMode2) => {
|
|
1735
|
-
DateViewMode2["year"] = "year";
|
|
1736
|
-
DateViewMode2["month"] = "month";
|
|
1737
|
-
DateViewMode2["date"] = "date";
|
|
1738
|
-
DateViewMode2["datetime"] = "datetime";
|
|
1739
|
-
DateViewMode2["time"] = "time";
|
|
1740
|
-
return DateViewMode2;
|
|
1741
|
-
})(DateViewMode || {});
|
|
1742
|
-
EXPRESSIONS_FORMAT.forEach((item) => {
|
|
1743
|
-
MAX_CHAR_LENGTH = Math.max(item.length, MAX_CHAR_LENGTH);
|
|
1744
|
-
});
|
|
1745
|
-
const format = (date, format2) => {
|
|
1746
|
-
format2 = format2 || "YYYY-MM-DD";
|
|
1747
|
-
const len = format2.length;
|
|
1748
|
-
let result = [];
|
|
1749
|
-
for (let i = 0; i < len; ) {
|
|
1750
|
-
let minLen = Math.min(MAX_CHAR_LENGTH, len - i);
|
|
1751
|
-
let j = minLen;
|
|
1752
|
-
for (; j > 0; j--) {
|
|
1753
|
-
const v = format2.substring(i, i + j);
|
|
1754
|
-
if (EXPRESSIONS_FORMAT.includes(v)) {
|
|
1755
|
-
try {
|
|
1756
|
-
result.push(expressionsFunction$1[v](date));
|
|
1757
|
-
} catch (e) {
|
|
1758
|
-
console.log(EXPRESSIONS_FORMAT.includes(v), v, e);
|
|
1759
|
-
}
|
|
1760
|
-
break;
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
if (j < 1) {
|
|
1764
|
-
result.push(format2.substring(i, i + 1));
|
|
1765
|
-
i += 1;
|
|
1766
|
-
} else {
|
|
1767
|
-
i += j;
|
|
1768
|
-
}
|
|
1769
|
-
}
|
|
1770
|
-
return result.join("");
|
|
1771
|
-
};
|
|
1772
|
-
const expressionsFunction$1 = {
|
|
1773
|
-
YY: (date) => {
|
|
1774
|
-
return String(date.getFullYear()).slice(-2);
|
|
1775
|
-
},
|
|
1776
|
-
YYYY: (date) => {
|
|
1777
|
-
return String(date.getFullYear());
|
|
1778
|
-
},
|
|
1779
|
-
M: (date) => {
|
|
1780
|
-
return String(date.getMonth() + 1);
|
|
1781
|
-
},
|
|
1782
|
-
MM: (date) => {
|
|
1783
|
-
return core.leftPad(date.getMonth() + 1, 2);
|
|
1784
|
-
},
|
|
1785
|
-
MMM: (date) => {
|
|
1786
|
-
return Lanauage.getMonthsMessage(date.getMonth());
|
|
1787
|
-
},
|
|
1788
|
-
MMMM: (date) => {
|
|
1789
|
-
return Lanauage.getMonthsMessage(date.getMonth(), "full");
|
|
1790
|
-
},
|
|
1791
|
-
D: (date) => {
|
|
1792
|
-
return String(date.getDate());
|
|
1793
|
-
},
|
|
1794
|
-
DD: (date) => {
|
|
1795
|
-
return core.leftPad(date.getDate(), 2);
|
|
1796
|
-
},
|
|
1797
|
-
d: (date) => {
|
|
1798
|
-
return String(date.getDate());
|
|
1799
|
-
},
|
|
1800
|
-
dd: (date) => {
|
|
1801
|
-
return core.leftPad(date.getDate(), 2);
|
|
1802
|
-
},
|
|
1803
|
-
ddd: (date) => {
|
|
1804
|
-
return Lanauage.getWeeksMessage(date.getDay());
|
|
1805
|
-
},
|
|
1806
|
-
dddd: (date) => {
|
|
1807
|
-
return Lanauage.getWeeksMessage(date.getDay(), "full");
|
|
1808
|
-
},
|
|
1809
|
-
H: (date) => {
|
|
1810
|
-
return String(date.getHours());
|
|
1811
|
-
},
|
|
1812
|
-
HH: (date) => {
|
|
1813
|
-
return core.leftPad(date.getHours(), 2);
|
|
1814
|
-
},
|
|
1815
|
-
h: (date) => {
|
|
1816
|
-
return getH(date);
|
|
1817
|
-
},
|
|
1818
|
-
hh: (date) => {
|
|
1819
|
-
return core.leftPad(getH(date), 2);
|
|
1820
|
-
},
|
|
1821
|
-
a: (date) => {
|
|
1822
|
-
return String(date.getFullYear()).slice(-2);
|
|
1823
|
-
},
|
|
1824
|
-
A: (date) => {
|
|
1825
|
-
return getMeridiem(date);
|
|
1826
|
-
},
|
|
1827
|
-
m: (date) => {
|
|
1828
|
-
return String(date.getMinutes());
|
|
1829
|
-
},
|
|
1830
|
-
mm: (date) => {
|
|
1831
|
-
return core.leftPad(date.getMinutes(), 2);
|
|
1832
|
-
},
|
|
1833
|
-
s: (date) => {
|
|
1834
|
-
return String(date.getSeconds());
|
|
1835
|
-
},
|
|
1836
|
-
ss: (date) => {
|
|
1837
|
-
return core.leftPad(date.getSeconds(), 2);
|
|
1838
|
-
},
|
|
1839
|
-
SSS: (date) => {
|
|
1840
|
-
return core.leftPad(date.getMilliseconds(), 3);
|
|
1841
|
-
}
|
|
1842
|
-
};
|
|
1843
|
-
function getH(date) {
|
|
1844
|
-
let hour = date.getHours();
|
|
1845
|
-
if (hour > 12) {
|
|
1846
|
-
hour -= 12;
|
|
1847
|
-
} else if (hour < 1) {
|
|
1848
|
-
hour = 12;
|
|
1849
|
-
}
|
|
1850
|
-
return hour;
|
|
1851
|
-
}
|
|
1852
|
-
function getMeridiem(date, isUpper, isShort) {
|
|
1853
|
-
const hour = date.getHours();
|
|
1854
|
-
let m = hour < 12 ? "am" : "pm";
|
|
1855
|
-
m = Lanauage.getMessage(m);
|
|
1856
|
-
m = m.toUpperCase();
|
|
1857
|
-
return m;
|
|
1858
|
-
}
|
|
1859
|
-
const parser = (dateStr, format2) => {
|
|
1860
|
-
if (dateStr.length > 1e3) {
|
|
1861
|
-
return null;
|
|
1862
|
-
}
|
|
1863
|
-
format2 = format2 || DEFAULT_FORMAT.date;
|
|
1864
|
-
const dateInfo = {
|
|
1865
|
-
year: (/* @__PURE__ */ new Date()).getFullYear(),
|
|
1866
|
-
month: 0,
|
|
1867
|
-
day: 1,
|
|
1868
|
-
hour: 0,
|
|
1869
|
-
minute: 0,
|
|
1870
|
-
second: 0,
|
|
1871
|
-
millisecond: 0,
|
|
1872
|
-
isPm: false,
|
|
1873
|
-
isH: false,
|
|
1874
|
-
charIdx: 0
|
|
1875
|
-
};
|
|
1876
|
-
const len = format2.length;
|
|
1877
|
-
let startIdx = 0;
|
|
1878
|
-
for (let i = 0; i < len; ) {
|
|
1879
|
-
let minLen = Math.min(MAX_CHAR_LENGTH, len - i);
|
|
1880
|
-
let j = minLen;
|
|
1881
|
-
for (; j > 0; j--) {
|
|
1882
|
-
const v = format2.substring(i, i + j);
|
|
1883
|
-
if (EXPRESSIONS_FORMAT.includes(v)) {
|
|
1884
|
-
const expInfo = expressionsFunction[v];
|
|
1885
|
-
const val = matchFind(dateStr.substring(startIdx), expInfo[0]);
|
|
1886
|
-
expInfo[1](dateInfo, val);
|
|
1887
|
-
startIdx += val.length;
|
|
1888
|
-
break;
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
if (j < 1) {
|
|
1892
|
-
i += 1;
|
|
1893
|
-
startIdx += 1;
|
|
1894
|
-
} else {
|
|
1895
|
-
i += j;
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
if (dateInfo.hour != null && !dateInfo.isH) {
|
|
1899
|
-
if (dateInfo.isPm && +dateInfo.hour !== 12) {
|
|
1900
|
-
dateInfo.hour = +dateInfo.hour + 12;
|
|
1901
|
-
} else if (!dateInfo.isPm && +dateInfo.hour === 12) {
|
|
1902
|
-
dateInfo.hour = 0;
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
let date;
|
|
1906
|
-
date = new Date(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute, dateInfo.second, dateInfo.millisecond);
|
|
1907
|
-
return date;
|
|
1908
|
-
};
|
|
1909
|
-
const matchFind = (val, regexp2) => {
|
|
1910
|
-
const match = regexp2.exec(val);
|
|
1911
|
-
return match == null ? "" : match[0];
|
|
1912
|
-
};
|
|
1913
|
-
const digitsCheck = {
|
|
1914
|
-
twoOptional: /\d\d?/,
|
|
1915
|
-
two: /\d\d/,
|
|
1916
|
-
three: /\d{3}/,
|
|
1917
|
-
four: /\d{4}/
|
|
1918
|
-
};
|
|
1919
|
-
const word = /[^\s]+/;
|
|
1920
|
-
const expressionsFunction = {
|
|
1921
|
-
YY: [
|
|
1922
|
-
digitsCheck["two"],
|
|
1923
|
-
(dateInfo, val) => {
|
|
1924
|
-
dateInfo.year = +(("" + (/* @__PURE__ */ new Date()).getFullYear()).substring(0, 2) + val);
|
|
1925
|
-
return dateInfo;
|
|
1926
|
-
}
|
|
1927
|
-
],
|
|
1928
|
-
YYYY: [
|
|
1929
|
-
digitsCheck["four"],
|
|
1930
|
-
(dateInfo, val) => {
|
|
1931
|
-
dateInfo.year = +val;
|
|
1932
|
-
return dateInfo;
|
|
1933
|
-
}
|
|
1934
|
-
],
|
|
1935
|
-
M: [
|
|
1936
|
-
digitsCheck["twoOptional"],
|
|
1937
|
-
(dateInfo, val) => {
|
|
1938
|
-
dateInfo.month = +val - 1;
|
|
1939
|
-
return dateInfo;
|
|
1940
|
-
}
|
|
1941
|
-
],
|
|
1942
|
-
MM: [
|
|
1943
|
-
digitsCheck["two"],
|
|
1944
|
-
(dateInfo, val) => {
|
|
1945
|
-
dateInfo.month = +val - 1;
|
|
1946
|
-
return dateInfo;
|
|
1947
|
-
}
|
|
1948
|
-
],
|
|
1949
|
-
MMM: [
|
|
1950
|
-
word,
|
|
1951
|
-
(dateInfo, val) => {
|
|
1952
|
-
dateInfo.month = Lanauage.getMonthsIdx(val, "abbr");
|
|
1953
|
-
return dateInfo;
|
|
1954
|
-
}
|
|
1955
|
-
],
|
|
1956
|
-
MMMM: [
|
|
1957
|
-
word,
|
|
1958
|
-
(dateInfo, val) => {
|
|
1959
|
-
dateInfo.month = Lanauage.getMonthsIdx(val, "full");
|
|
1960
|
-
return dateInfo;
|
|
1961
|
-
}
|
|
1962
|
-
],
|
|
1963
|
-
D: [
|
|
1964
|
-
digitsCheck["twoOptional"],
|
|
1965
|
-
(dateInfo, val) => {
|
|
1966
|
-
dateInfo.day = +val;
|
|
1967
|
-
return dateInfo;
|
|
1968
|
-
}
|
|
1969
|
-
],
|
|
1970
|
-
DD: [
|
|
1971
|
-
digitsCheck["two"],
|
|
1972
|
-
(dateInfo, val) => {
|
|
1973
|
-
dateInfo.day = +val;
|
|
1974
|
-
return dateInfo;
|
|
1975
|
-
}
|
|
1976
|
-
],
|
|
1977
|
-
d: [
|
|
1978
|
-
digitsCheck["twoOptional"],
|
|
1979
|
-
(dateInfo, val) => {
|
|
1980
|
-
dateInfo.day = +val;
|
|
1981
|
-
return dateInfo;
|
|
1982
|
-
}
|
|
1983
|
-
],
|
|
1984
|
-
dd: [
|
|
1985
|
-
digitsCheck["two"],
|
|
1986
|
-
(dateInfo, val) => {
|
|
1987
|
-
dateInfo.day = +val;
|
|
1988
|
-
return dateInfo;
|
|
1989
|
-
}
|
|
1990
|
-
],
|
|
1991
|
-
ddd: [
|
|
1992
|
-
word,
|
|
1993
|
-
(dateInfo, val) => {
|
|
1994
|
-
return dateInfo;
|
|
1995
|
-
}
|
|
1996
|
-
],
|
|
1997
|
-
dddd: [
|
|
1998
|
-
word,
|
|
1999
|
-
(dateInfo, val) => {
|
|
2000
|
-
return dateInfo;
|
|
2001
|
-
}
|
|
2002
|
-
],
|
|
2003
|
-
H: [
|
|
2004
|
-
digitsCheck["twoOptional"],
|
|
2005
|
-
(dateInfo, val) => {
|
|
2006
|
-
dateInfo.hour = +val;
|
|
2007
|
-
dateInfo.isH = true;
|
|
2008
|
-
return dateInfo;
|
|
2009
|
-
}
|
|
2010
|
-
],
|
|
2011
|
-
HH: [
|
|
2012
|
-
digitsCheck["two"],
|
|
2013
|
-
(dateInfo, val) => {
|
|
2014
|
-
dateInfo.hour = +val;
|
|
2015
|
-
dateInfo.isH = true;
|
|
2016
|
-
return dateInfo;
|
|
2017
|
-
}
|
|
2018
|
-
],
|
|
2019
|
-
h: [
|
|
2020
|
-
digitsCheck["twoOptional"],
|
|
2021
|
-
(dateInfo, val) => {
|
|
2022
|
-
dateInfo.hour = +val;
|
|
2023
|
-
return dateInfo;
|
|
2024
|
-
}
|
|
2025
|
-
],
|
|
2026
|
-
hh: [
|
|
2027
|
-
digitsCheck["two"],
|
|
2028
|
-
(dateInfo, val) => {
|
|
2029
|
-
dateInfo.hour = +val;
|
|
2030
|
-
return dateInfo;
|
|
2031
|
-
}
|
|
2032
|
-
],
|
|
2033
|
-
a: [
|
|
2034
|
-
word,
|
|
2035
|
-
(dateInfo, val) => {
|
|
2036
|
-
if (Lanauage.getMessage("am") != val.toLowerCase()) {
|
|
2037
|
-
dateInfo.isPm = true;
|
|
2038
|
-
}
|
|
2039
|
-
return dateInfo;
|
|
2040
|
-
}
|
|
2041
|
-
],
|
|
2042
|
-
A: [
|
|
2043
|
-
word,
|
|
2044
|
-
(dateInfo, val) => {
|
|
2045
|
-
if (Lanauage.getMessage("am") != val.toLowerCase()) {
|
|
2046
|
-
dateInfo.isPm = true;
|
|
2047
|
-
}
|
|
2048
|
-
return dateInfo;
|
|
2049
|
-
}
|
|
2050
|
-
],
|
|
2051
|
-
m: [
|
|
2052
|
-
digitsCheck["twoOptional"],
|
|
2053
|
-
(dateInfo, val) => {
|
|
2054
|
-
dateInfo.minute = +val;
|
|
2055
|
-
return dateInfo;
|
|
2056
|
-
}
|
|
2057
|
-
],
|
|
2058
|
-
mm: [
|
|
2059
|
-
digitsCheck["two"],
|
|
2060
|
-
(dateInfo, val) => {
|
|
2061
|
-
dateInfo.minute = +val;
|
|
2062
|
-
return dateInfo;
|
|
2063
|
-
}
|
|
2064
|
-
],
|
|
2065
|
-
s: [
|
|
2066
|
-
digitsCheck["twoOptional"],
|
|
2067
|
-
(dateInfo, val) => {
|
|
2068
|
-
dateInfo.second = +val;
|
|
2069
|
-
return dateInfo;
|
|
2070
|
-
}
|
|
2071
|
-
],
|
|
2072
|
-
ss: [
|
|
2073
|
-
digitsCheck["two"],
|
|
2074
|
-
(dateInfo, val) => {
|
|
2075
|
-
dateInfo.second = +val;
|
|
2076
|
-
return dateInfo;
|
|
2077
|
-
}
|
|
2078
|
-
],
|
|
2079
|
-
SSS: [
|
|
2080
|
-
digitsCheck["three"],
|
|
2081
|
-
(dateInfo, val) => {
|
|
2082
|
-
dateInfo.millisecond = +val;
|
|
2083
|
-
return dateInfo;
|
|
2084
|
-
}
|
|
2085
|
-
]
|
|
2086
|
-
};
|
|
2087
|
-
function closestElement(el, checkElement) {
|
|
2088
|
-
let currentEl = el;
|
|
2089
|
-
while (currentEl) {
|
|
2090
|
-
if (currentEl == checkElement) {
|
|
2091
|
-
return true;
|
|
2092
|
-
}
|
|
2093
|
-
currentEl = currentEl.parentElement;
|
|
2094
|
-
}
|
|
2095
|
-
return false;
|
|
2096
|
-
}
|
|
2097
|
-
class DaraDate {
|
|
2098
|
-
constructor(dt) {
|
|
2099
|
-
this.date = dt;
|
|
2100
|
-
}
|
|
2101
|
-
setYear(num) {
|
|
2102
|
-
this.date.setFullYear(num);
|
|
2103
|
-
return this;
|
|
2104
|
-
}
|
|
2105
|
-
addYear(num) {
|
|
2106
|
-
this.date.setFullYear(this.date.getFullYear() + num);
|
|
2107
|
-
return this;
|
|
2108
|
-
}
|
|
2109
|
-
addMonth(num) {
|
|
2110
|
-
this.date.setMonth(this.date.getMonth() + num);
|
|
2111
|
-
return this;
|
|
2112
|
-
}
|
|
2113
|
-
setMonth(num) {
|
|
2114
|
-
this.date.setMonth(num);
|
|
2115
|
-
return this;
|
|
2116
|
-
}
|
|
2117
|
-
setDate(num) {
|
|
2118
|
-
this.date.setDate(num);
|
|
2119
|
-
return this;
|
|
2120
|
-
}
|
|
2121
|
-
addDate(num) {
|
|
2122
|
-
this.date.setDate(this.date.getDate() + num);
|
|
2123
|
-
return this;
|
|
2124
|
-
}
|
|
2125
|
-
addWeek(num) {
|
|
2126
|
-
this.date.setDate(this.date.getDate() + num * 7);
|
|
2127
|
-
return this;
|
|
2128
|
-
}
|
|
2129
|
-
addHours(num) {
|
|
2130
|
-
this.date.setHours(this.date.getHours() + num);
|
|
2131
|
-
return this;
|
|
2132
|
-
}
|
|
2133
|
-
setHour(num) {
|
|
2134
|
-
this.date.setHours(num);
|
|
2135
|
-
return this;
|
|
2136
|
-
}
|
|
2137
|
-
addMinutes(num) {
|
|
2138
|
-
this.date.setMinutes(this.date.getMinutes() + num);
|
|
2139
|
-
return this;
|
|
2140
|
-
}
|
|
2141
|
-
setMinutes(num) {
|
|
2142
|
-
this.date.setMinutes(num);
|
|
2143
|
-
return this;
|
|
2144
|
-
}
|
|
2145
|
-
addSeconds(num) {
|
|
2146
|
-
this.date.setSeconds(this.date.getSeconds() + num);
|
|
2147
|
-
return this;
|
|
2148
|
-
}
|
|
2149
|
-
addMilliseconds(num) {
|
|
2150
|
-
this.date.setMilliseconds(this.date.getMilliseconds() + num);
|
|
2151
|
-
return this;
|
|
2152
|
-
}
|
|
2153
|
-
compare(date) {
|
|
2154
|
-
if (this.date.valueOf() < date.valueOf()) {
|
|
2155
|
-
return -1;
|
|
2156
|
-
} else if (this.date.valueOf() > date.valueOf()) {
|
|
2157
|
-
return 1;
|
|
2158
|
-
}
|
|
2159
|
-
return 0;
|
|
2160
|
-
}
|
|
2161
|
-
getYear() {
|
|
2162
|
-
return this.date.getFullYear();
|
|
2163
|
-
}
|
|
2164
|
-
getMonth() {
|
|
2165
|
-
return this.date.getMonth() + 1;
|
|
2166
|
-
}
|
|
2167
|
-
getDate() {
|
|
2168
|
-
return this.date.getDate();
|
|
2169
|
-
}
|
|
2170
|
-
getDay() {
|
|
2171
|
-
return this.date.getDay();
|
|
2172
|
-
}
|
|
2173
|
-
getTime() {
|
|
2174
|
-
return this.date.getTime();
|
|
2175
|
-
}
|
|
2176
|
-
format(format$1) {
|
|
2177
|
-
return format(this.date, format$1);
|
|
2178
|
-
}
|
|
2179
|
-
clone() {
|
|
2180
|
-
return new DaraDate(new Date(this.date.valueOf()));
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
let DEFAULT_OPTIONS$1 = {
|
|
2184
|
-
inline: false,
|
|
2185
|
-
// layer or innerhtml
|
|
2186
|
-
weekStartDay: 0,
|
|
2187
|
-
initialDate: "",
|
|
2188
|
-
autoClose: true,
|
|
2189
|
-
isRTL: false,
|
|
2190
|
-
mode: DateViewMode.date,
|
|
2191
|
-
enableTodayBtn: false,
|
|
2192
|
-
showMonthAfterYear: false,
|
|
2193
|
-
isPositionFixed: false,
|
|
2194
|
-
format: "",
|
|
2195
|
-
zIndex: 1e3,
|
|
2196
|
-
minDate: "",
|
|
2197
|
-
maxDate: "",
|
|
2198
|
-
beforeDrawDate: (dt) => {
|
|
2199
|
-
return {
|
|
2200
|
-
check: false,
|
|
2201
|
-
style: "",
|
|
2202
|
-
tooltip: ""
|
|
2203
|
-
};
|
|
2204
|
-
}
|
|
2205
|
-
};
|
|
2206
|
-
function hiddenElement() {
|
|
2207
|
-
var _a;
|
|
2208
|
-
if (document.getElementById("hiddenDaraDatetimeElement") == null) {
|
|
2209
|
-
(_a = document.querySelector("body")) == null ? void 0 : _a.insertAdjacentHTML("beforeend", `<div id="hiddenDaraDatetimeElement" class="daracl-datetime-hidden"></div>`);
|
|
2210
|
-
}
|
|
2211
|
-
return document.getElementById("hiddenDaraDatetimeElement");
|
|
2212
|
-
}
|
|
2213
|
-
let daraDatetimeIdx = 0;
|
|
2214
|
-
const _DateTimePicker = class _DateTimePicker2 {
|
|
2215
|
-
constructor(selector, options, message2) {
|
|
2216
|
-
var _a;
|
|
2217
|
-
this.isInput = false;
|
|
2218
|
-
this.isVisible = false;
|
|
2219
|
-
this.minYear = -1;
|
|
2220
|
-
this.maxYear = -1;
|
|
2221
|
-
this.minMonth = -1;
|
|
2222
|
-
this.maxMonth = -1;
|
|
2223
|
-
this.dayOrder = [0, 1, 2, 3, 4, 5, 6];
|
|
2224
|
-
this._documentClickEvent = (e) => {
|
|
2225
|
-
if (this.isVisible && e.target != this.targetElement && !closestElement(e.target, this.datetimeElement)) {
|
|
2226
|
-
this.hide();
|
|
2227
|
-
}
|
|
2228
|
-
};
|
|
2229
|
-
this.options = Object.assign({}, DEFAULT_OPTIONS$1, options);
|
|
2230
|
-
daraDatetimeIdx += 1;
|
|
2231
|
-
let selectorElement;
|
|
2232
|
-
if (typeof selector === "string") {
|
|
2233
|
-
selectorElement = document.querySelector(selector);
|
|
2234
|
-
} else {
|
|
2235
|
-
selectorElement = selector;
|
|
2236
|
-
}
|
|
2237
|
-
if (!selectorElement) {
|
|
2238
|
-
throw new Error(`${selector} datetimepicker element not found`);
|
|
2239
|
-
}
|
|
2240
|
-
this._viewMode = Object.keys(DateViewMode).includes(this.options.mode) ? this.options.mode : DateViewMode.date;
|
|
2241
|
-
this.initMode = this._viewMode;
|
|
2242
|
-
Lanauage.set(message2);
|
|
2243
|
-
if (this.initMode == DateViewMode.year) {
|
|
2244
|
-
this.dateFormat = this.options.format || DEFAULT_FORMAT.year;
|
|
2245
|
-
} else if (this.initMode == DateViewMode.month) {
|
|
2246
|
-
this.dateFormat = this.options.format || DEFAULT_FORMAT.month;
|
|
2247
|
-
} else if (this.initMode == DateViewMode.time) {
|
|
2248
|
-
this.dateFormat = this.options.format || DEFAULT_FORMAT.time;
|
|
2249
|
-
} else if (this.initMode == DateViewMode.datetime) {
|
|
2250
|
-
this.dateFormat = this.options.format || DEFAULT_FORMAT.datetime;
|
|
2251
|
-
} else {
|
|
2252
|
-
this.dateFormat = this.options.format || DEFAULT_FORMAT.date;
|
|
2253
|
-
}
|
|
2254
|
-
let viewDate;
|
|
2255
|
-
if (this.options.initialDate) {
|
|
2256
|
-
if (typeof this.options.initialDate === "string") {
|
|
2257
|
-
viewDate = new DaraDate(parser(this.options.initialDate, this.dateFormat) || /* @__PURE__ */ new Date());
|
|
2258
|
-
} else {
|
|
2259
|
-
viewDate = new DaraDate(this.options.initialDate);
|
|
2260
|
-
}
|
|
2261
|
-
} else {
|
|
2262
|
-
viewDate = new DaraDate(/* @__PURE__ */ new Date());
|
|
2263
|
-
this.options.initialDate = viewDate.format(this.dateFormat);
|
|
2264
|
-
}
|
|
2265
|
-
this.setWeekDays();
|
|
2266
|
-
this.todayDate = viewDate.format(DEFAULT_FORMAT.date);
|
|
2267
|
-
this.currentDate = viewDate;
|
|
2268
|
-
this.targetElement = selectorElement;
|
|
2269
|
-
this.minDate = this._minDate();
|
|
2270
|
-
this.maxDate = this._maxDate();
|
|
2271
|
-
if (this.options.inline) {
|
|
2272
|
-
this.datetimeElement = selectorElement;
|
|
2273
|
-
this.datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} embed`;
|
|
2274
|
-
} else {
|
|
2275
|
-
this.isInput = true;
|
|
2276
|
-
this.targetElement.setAttribute("value", viewDate.format(this.dateFormat));
|
|
2277
|
-
const datetimeElement = document.createElement("div");
|
|
2278
|
-
datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} layer`;
|
|
2279
|
-
datetimeElement.setAttribute("style", `z-index:${this.options.zIndex};`);
|
|
2280
|
-
(_a = hiddenElement()) == null ? void 0 : _a.appendChild(datetimeElement);
|
|
2281
|
-
this.datetimeElement = datetimeElement;
|
|
2282
|
-
this.initTargetEvent();
|
|
2283
|
-
}
|
|
2284
|
-
this.createDatetimeTemplate();
|
|
2285
|
-
if (this.isTimeMode()) {
|
|
2286
|
-
this.hourInputEle = this.datetimeElement.querySelector(".ddtp-hour");
|
|
2287
|
-
this.minuteInputEle = this.datetimeElement.querySelector(".ddtp-minute");
|
|
2288
|
-
} else {
|
|
2289
|
-
this.hourInputEle = {};
|
|
2290
|
-
this.minuteInputEle = {};
|
|
2291
|
-
}
|
|
2292
|
-
this.changeViewMode(this._viewMode);
|
|
2293
|
-
this.initHeaderEvent();
|
|
2294
|
-
this.initDateEvent();
|
|
2295
|
-
this.initTimeEvent();
|
|
2296
|
-
}
|
|
2297
|
-
setWeekDays() {
|
|
2298
|
-
let weekStartDay = this.options.weekStartDay;
|
|
2299
|
-
if (weekStartDay == 0) return;
|
|
2300
|
-
if (weekStartDay < 0 || weekStartDay > 6) {
|
|
2301
|
-
weekStartDay = 0;
|
|
2302
|
-
}
|
|
2303
|
-
for (let i = 0; i < 7; i++) {
|
|
2304
|
-
let day = weekStartDay + i;
|
|
2305
|
-
this.dayOrder[i] = day < 7 ? day : day - 7;
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
static create(selector, options, message2) {
|
|
2309
|
-
return new _DateTimePicker2(selector, options, message2);
|
|
2310
|
-
}
|
|
2311
|
-
/**
|
|
2312
|
-
* default date format setting
|
|
2313
|
-
* @example
|
|
2314
|
-
```
|
|
2315
|
-
setDefaultFormat({
|
|
2316
|
-
year: "YYYY",
|
|
2317
|
-
month: "YYYY-MM",
|
|
2318
|
-
date: "YYYY-MM-DD",
|
|
2319
|
-
time: "HH:mm",
|
|
2320
|
-
datetime: "YYYY-MM-DD HH:mm",
|
|
2321
|
-
});
|
|
2322
|
-
```
|
|
2323
|
-
* @public
|
|
2324
|
-
* @static
|
|
2325
|
-
* @param {*} dateFormat
|
|
2326
|
-
*/
|
|
2327
|
-
static setDefaultFormat(dateFormat) {
|
|
2328
|
-
Object.assign(DEFAULT_FORMAT, dateFormat);
|
|
2329
|
-
}
|
|
2330
|
-
_minDate() {
|
|
2331
|
-
let minDate = this.options.minDate;
|
|
2332
|
-
if (minDate != "") {
|
|
2333
|
-
if (typeof minDate === "string") {
|
|
2334
|
-
const dt = parser(minDate, this.dateFormat);
|
|
2335
|
-
if (!dt) {
|
|
2336
|
-
return -1;
|
|
2337
|
-
}
|
|
2338
|
-
minDate = dt;
|
|
2339
|
-
}
|
|
2340
|
-
this.minYear = minDate.getFullYear();
|
|
2341
|
-
this.minMonth = +(this.minYear + core.leftPad(minDate.getMonth(), 2));
|
|
2342
|
-
return new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate(), 0, 0).getTime();
|
|
2343
|
-
}
|
|
2344
|
-
return -1;
|
|
2345
|
-
}
|
|
2346
|
-
_maxDate() {
|
|
2347
|
-
let maxDate = this.options.maxDate;
|
|
2348
|
-
if (maxDate != "") {
|
|
2349
|
-
if (typeof maxDate === "string") {
|
|
2350
|
-
const dt = parser(maxDate, this.dateFormat);
|
|
2351
|
-
if (!dt) {
|
|
2352
|
-
return -1;
|
|
2353
|
-
}
|
|
2354
|
-
maxDate = dt;
|
|
2355
|
-
}
|
|
2356
|
-
this.maxYear = maxDate.getFullYear();
|
|
2357
|
-
this.maxMonth = +(this.maxYear + core.leftPad(maxDate.getMonth(), 2));
|
|
2358
|
-
return new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59).getTime();
|
|
2359
|
-
}
|
|
2360
|
-
return -1;
|
|
2361
|
-
}
|
|
2362
|
-
set viewMode(mode) {
|
|
2363
|
-
if (this._viewMode === mode) {
|
|
2364
|
-
return;
|
|
2365
|
-
}
|
|
2366
|
-
this._viewMode = mode;
|
|
2367
|
-
this.changeViewMode(mode);
|
|
2368
|
-
}
|
|
2369
|
-
get viewMode() {
|
|
2370
|
-
return this._viewMode;
|
|
2371
|
-
}
|
|
2372
|
-
/**
|
|
2373
|
-
* 모드 change
|
|
2374
|
-
* @param mode
|
|
2375
|
-
*/
|
|
2376
|
-
changeViewMode(mode) {
|
|
2377
|
-
var _a;
|
|
2378
|
-
(_a = this.datetimeElement.querySelector(".ddtp-datetime")) == null ? void 0 : _a.setAttribute("view-mode", mode);
|
|
2379
|
-
if (mode === "year") {
|
|
2380
|
-
this.yearDraw();
|
|
2381
|
-
} else if (mode === "month") {
|
|
2382
|
-
this.monthDraw();
|
|
2383
|
-
} else {
|
|
2384
|
-
this.dayDraw();
|
|
2385
|
-
}
|
|
2386
|
-
}
|
|
2387
|
-
/**
|
|
2388
|
-
* init header event
|
|
2389
|
-
*
|
|
2390
|
-
* @public
|
|
2391
|
-
*/
|
|
2392
|
-
initHeaderEvent() {
|
|
2393
|
-
var _a, _b, _c, _d;
|
|
2394
|
-
const isRTL = this.options.isRTL;
|
|
2395
|
-
(_a = this.datetimeElement.querySelector(".ddtp-move-btn.prev")) == null ? void 0 : _a.addEventListener("click", (e) => {
|
|
2396
|
-
this.moveDate(isRTL ? "next" : "prev", e);
|
|
2397
|
-
});
|
|
2398
|
-
(_b = this.datetimeElement.querySelector(".ddtp-move-btn.next")) == null ? void 0 : _b.addEventListener("click", (e) => {
|
|
2399
|
-
this.moveDate(isRTL ? "prev" : "next", e);
|
|
2400
|
-
});
|
|
2401
|
-
(_c = this.datetimeElement.querySelector(".ddtp-header-year")) == null ? void 0 : _c.addEventListener("click", (e) => {
|
|
2402
|
-
this.viewMode = DateViewMode.year;
|
|
2403
|
-
});
|
|
2404
|
-
(_d = this.datetimeElement.querySelector(".ddtp-header-month")) == null ? void 0 : _d.addEventListener("click", (e) => {
|
|
2405
|
-
this.viewMode = DateViewMode.month;
|
|
2406
|
-
});
|
|
2407
|
-
}
|
|
2408
|
-
/**
|
|
2409
|
-
* 날짜 달력 이벤트처리.
|
|
2410
|
-
*/
|
|
2411
|
-
initDateEvent() {
|
|
2412
|
-
var _a, _b;
|
|
2413
|
-
(_a = this.datetimeElement.querySelector(".ddtp-day-body")) == null ? void 0 : _a.addEventListener("click", (e) => {
|
|
2414
|
-
var _a2;
|
|
2415
|
-
const targetEle = e.target;
|
|
2416
|
-
if (targetEle.classList.contains("ddtp-day") || targetEle.closest(".ddtp-day")) {
|
|
2417
|
-
const selectDate = targetEle.getAttribute("data-day") || "1";
|
|
2418
|
-
const mmDD = selectDate.split(",");
|
|
2419
|
-
this.currentDate.setMonth(+mmDD[0] - 1);
|
|
2420
|
-
this.currentDate.setDate(+mmDD[1]);
|
|
2421
|
-
if (this.isDayDisabled(this.currentDate)) {
|
|
2422
|
-
return;
|
|
2423
|
-
}
|
|
2424
|
-
(_a2 = this.datetimeElement.querySelector(".select")) == null ? void 0 : _a2.classList.remove("select");
|
|
2425
|
-
targetEle.classList.add("select");
|
|
2426
|
-
if (this.isTimeMode()) {
|
|
2427
|
-
this.currentDate.setHour(+this.hourInputEle.value);
|
|
2428
|
-
this.currentDate.setMinutes(+this.minuteInputEle.value);
|
|
2429
|
-
}
|
|
2430
|
-
this.dateChangeEvent(e);
|
|
2431
|
-
}
|
|
2432
|
-
});
|
|
2433
|
-
(_b = this.datetimeElement.querySelector(".ddtp-today")) == null ? void 0 : _b.addEventListener("click", (e) => {
|
|
2434
|
-
const initDate = new DaraDate(parser(this.todayDate, DEFAULT_FORMAT.date) || /* @__PURE__ */ new Date());
|
|
2435
|
-
this.currentDate.setYear(initDate.getYear());
|
|
2436
|
-
this.currentDate.setMonth(initDate.getMonth() - 1);
|
|
2437
|
-
this.currentDate.setDate(initDate.getDate());
|
|
2438
|
-
this.changeViewMode(this.initMode);
|
|
2439
|
-
});
|
|
2440
|
-
}
|
|
2441
|
-
isTimeMode() {
|
|
2442
|
-
return this._viewMode === DateViewMode.time || this._viewMode === DateViewMode.datetime;
|
|
2443
|
-
}
|
|
2444
|
-
getTimeNumberValue(val) {
|
|
2445
|
-
if (!core.isNumeric(val)) {
|
|
2446
|
-
return 0;
|
|
2447
|
-
}
|
|
2448
|
-
return parseInt(val, 10);
|
|
2449
|
-
}
|
|
2450
|
-
/**
|
|
2451
|
-
* 시간 분 설정 이벤트 처리.
|
|
2452
|
-
*
|
|
2453
|
-
* @public
|
|
2454
|
-
*/
|
|
2455
|
-
initTimeEvent() {
|
|
2456
|
-
var _a;
|
|
2457
|
-
if (!this.isTimeMode()) return;
|
|
2458
|
-
let hh = this.currentDate.format("HH");
|
|
2459
|
-
const datetimeElement = this.datetimeElement;
|
|
2460
|
-
const hourInputEle = datetimeElement.querySelector(".ddtp-hour");
|
|
2461
|
-
const hourRangeEle = datetimeElement.querySelector(".ddtp-hour-range");
|
|
2462
|
-
hourInputEle.value = hh;
|
|
2463
|
-
hourRangeEle.value = hh;
|
|
2464
|
-
hourInputEle.addEventListener("input", (e) => {
|
|
2465
|
-
const targetElement = e.target;
|
|
2466
|
-
let val = this.getTimeNumberValue(targetElement.value);
|
|
2467
|
-
let addVal = core.leftPadClamp(val, 2, "0");
|
|
2468
|
-
if (parseInt(addVal, 10) > 23) {
|
|
2469
|
-
addVal = "23";
|
|
2470
|
-
}
|
|
2471
|
-
hourInputEle.value = addVal;
|
|
2472
|
-
hourRangeEle.value = addVal;
|
|
2473
|
-
});
|
|
2474
|
-
hourRangeEle.addEventListener("input", (e) => {
|
|
2475
|
-
const targetElement = e.target;
|
|
2476
|
-
hourInputEle.value = core.leftPadClamp(targetElement.value, 2, "0");
|
|
2477
|
-
});
|
|
2478
|
-
let mm = this.currentDate.format("mm");
|
|
2479
|
-
const minuteInputEle = datetimeElement.querySelector(".ddtp-minute");
|
|
2480
|
-
const minuteRangeEle = datetimeElement.querySelector(".ddtp-minute-range");
|
|
2481
|
-
minuteInputEle.value = mm;
|
|
2482
|
-
minuteRangeEle.value = mm;
|
|
2483
|
-
minuteInputEle.addEventListener("input", (e) => {
|
|
2484
|
-
const targetElement = e.target;
|
|
2485
|
-
let val = this.getTimeNumberValue(targetElement.value);
|
|
2486
|
-
let addVal = core.leftPadClamp(val, 2, "0");
|
|
2487
|
-
if (parseInt(addVal, 10) > 59) {
|
|
2488
|
-
addVal = "59";
|
|
2489
|
-
}
|
|
2490
|
-
minuteInputEle.value = addVal;
|
|
2491
|
-
minuteRangeEle.value = addVal;
|
|
2492
|
-
});
|
|
2493
|
-
minuteRangeEle.addEventListener("input", (e) => {
|
|
2494
|
-
const targetElement = e.target;
|
|
2495
|
-
minuteInputEle.value = core.leftPadClamp(targetElement.value, 2, "0");
|
|
2496
|
-
});
|
|
2497
|
-
(_a = datetimeElement.querySelector(".time-select")) == null ? void 0 : _a.addEventListener("click", (e) => {
|
|
2498
|
-
this.currentDate.setHour(+hourInputEle.value);
|
|
2499
|
-
this.currentDate.setMinutes(+minuteInputEle.value);
|
|
2500
|
-
this.dateChangeEvent(e);
|
|
2501
|
-
});
|
|
2502
|
-
}
|
|
2503
|
-
/**
|
|
2504
|
-
* 날짜 이동
|
|
2505
|
-
* @param moveMode // 앞뒤 이동 prev, next
|
|
2506
|
-
* @returns
|
|
2507
|
-
*/
|
|
2508
|
-
moveDate(moveMode, e) {
|
|
2509
|
-
if (this._viewMode === DateViewMode.date || this._viewMode === DateViewMode.datetime) {
|
|
2510
|
-
this.currentDate.setDate(1);
|
|
2511
|
-
this.currentDate.addMonth("prev" === moveMode ? -1 : 1);
|
|
2512
|
-
this.dayDraw();
|
|
2513
|
-
return;
|
|
2514
|
-
}
|
|
2515
|
-
if (this._viewMode === DateViewMode.month) {
|
|
2516
|
-
this.currentDate.setDate(1);
|
|
2517
|
-
this.currentDate.addYear("prev" === moveMode ? -1 : 1);
|
|
2518
|
-
this.monthDraw();
|
|
2519
|
-
return;
|
|
2520
|
-
}
|
|
2521
|
-
if (this._viewMode === DateViewMode.year) {
|
|
2522
|
-
this.currentDate.setDate(1);
|
|
2523
|
-
this.currentDate.addYear("prev" === moveMode ? -16 : 16);
|
|
2524
|
-
this.yearDraw();
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
/**
|
|
2528
|
-
* get date value
|
|
2529
|
-
*
|
|
2530
|
-
* @returns
|
|
2531
|
-
*/
|
|
2532
|
-
getDateValue() {
|
|
2533
|
-
return this.currentDate.format(this.dateFormat);
|
|
2534
|
-
}
|
|
2535
|
-
/**
|
|
2536
|
-
* 옵션 셋팅
|
|
2537
|
-
* @static
|
|
2538
|
-
* @param {DateTimePickerOptions} options
|
|
2539
|
-
*/
|
|
2540
|
-
static setOptions(options) {
|
|
2541
|
-
DEFAULT_OPTIONS$1 = Object.assign({}, DEFAULT_OPTIONS$1, options);
|
|
2542
|
-
}
|
|
2543
|
-
/**
|
|
2544
|
-
* 달력 보이기 처리.
|
|
2545
|
-
*
|
|
2546
|
-
* @returns
|
|
2547
|
-
*/
|
|
2548
|
-
show() {
|
|
2549
|
-
if (this.isVisible) {
|
|
2550
|
-
return;
|
|
2551
|
-
}
|
|
2552
|
-
this.isVisible = true;
|
|
2553
|
-
const docSize = getDocSize();
|
|
2554
|
-
this.datetimeElement.classList.remove("hide");
|
|
2555
|
-
this.datetimeElement.classList.add("show");
|
|
2556
|
-
const rect = this.targetElement.getBoundingClientRect();
|
|
2557
|
-
const scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
2558
|
-
const scrollLeft = window.scrollX || document.documentElement.scrollLeft;
|
|
2559
|
-
const elementHeight = this.datetimeElement.offsetHeight;
|
|
2560
|
-
const targetElementHeight = this.targetElement.offsetHeight + 2;
|
|
2561
|
-
let left = rect.left + scrollLeft;
|
|
2562
|
-
let top = 0;
|
|
2563
|
-
if (this.options.isPositionFixed) {
|
|
2564
|
-
top = rect.top + targetElementHeight;
|
|
2565
|
-
left = rect.left;
|
|
2566
|
-
} else {
|
|
2567
|
-
if (rect.top + targetElementHeight + elementHeight > docSize.clientHeight && rect.top >= elementHeight) {
|
|
2568
|
-
top = scrollTop + rect.top - elementHeight - 2;
|
|
2569
|
-
} else {
|
|
2570
|
-
top = scrollTop + rect.top + targetElementHeight;
|
|
2571
|
-
}
|
|
2572
|
-
}
|
|
2573
|
-
this.datetimeElement.setAttribute("style", `${this.options.isPositionFixed ? "position:fixed;" : ""}top:${top}px;left:${left}px;z-index:${this.options.zIndex}`);
|
|
2574
|
-
document.addEventListener("click", this._documentClickEvent);
|
|
2575
|
-
}
|
|
2576
|
-
/**
|
|
2577
|
-
* 달력 숨기기
|
|
2578
|
-
*/
|
|
2579
|
-
hide() {
|
|
2580
|
-
this.isVisible = false;
|
|
2581
|
-
if (this.options.onClose) {
|
|
2582
|
-
if (this.options.onClose() === false) {
|
|
2583
|
-
return;
|
|
2584
|
-
}
|
|
2585
|
-
}
|
|
2586
|
-
this.datetimeElement.classList.remove("show");
|
|
2587
|
-
this.datetimeElement.classList.add("hide");
|
|
2588
|
-
document.removeEventListener("click", this._documentClickEvent);
|
|
2589
|
-
}
|
|
2590
|
-
/**
|
|
2591
|
-
* 타켓 이벤트 처리.
|
|
2592
|
-
*/
|
|
2593
|
-
initTargetEvent() {
|
|
2594
|
-
if (this.targetElement) {
|
|
2595
|
-
this.targetElement.addEventListener("click", (e) => {
|
|
2596
|
-
this.show();
|
|
2597
|
-
});
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
|
-
/**
|
|
2601
|
-
* 날짜 변경후 이벤트
|
|
2602
|
-
*/
|
|
2603
|
-
afterChangeDatepicker() {
|
|
2604
|
-
const formatValue = this.currentDate.format(this.dateFormat);
|
|
2605
|
-
if (this.options.afterChangeDatepicker && core.isFunction(this.options.afterChangeDatepicker)) {
|
|
2606
|
-
this.options.afterChangeDatepicker(formatValue, this.viewMode);
|
|
2607
|
-
}
|
|
2608
|
-
}
|
|
2609
|
-
/**
|
|
2610
|
-
* 날짜 변경 전 이벤트.
|
|
2611
|
-
* @returns void
|
|
2612
|
-
*/
|
|
2613
|
-
beforeChangeDatepicker() {
|
|
2614
|
-
const formatValue = this.currentDate.format(this.dateFormat);
|
|
2615
|
-
if (this.options.beforeChangeDatepicker && core.isFunction(this.options.beforeChangeDatepicker)) {
|
|
2616
|
-
const reval = this.options.beforeChangeDatepicker(formatValue, (result) => {
|
|
2617
|
-
if (result === false) {
|
|
2618
|
-
return;
|
|
2619
|
-
}
|
|
2620
|
-
this.refresh(false);
|
|
2621
|
-
});
|
|
2622
|
-
if (reval === false) {
|
|
2623
|
-
return;
|
|
2624
|
-
}
|
|
2625
|
-
this.refresh(false);
|
|
2626
|
-
return;
|
|
2627
|
-
}
|
|
2628
|
-
this.refresh(false);
|
|
2629
|
-
}
|
|
2630
|
-
dateChangeEvent(e) {
|
|
2631
|
-
const formatValue = this.currentDate.format(this.dateFormat);
|
|
2632
|
-
if (this.options.onSelect) {
|
|
2633
|
-
if (this.options.onSelect(formatValue, this.viewMode, e) === false) {
|
|
2634
|
-
return;
|
|
2635
|
-
}
|
|
2636
|
-
}
|
|
2637
|
-
if (this.isInput) {
|
|
2638
|
-
this.targetElement.setAttribute("value", formatValue);
|
|
2639
|
-
}
|
|
2640
|
-
if (!this.options.inline && this.options.autoClose) {
|
|
2641
|
-
this.hide();
|
|
2642
|
-
}
|
|
2643
|
-
}
|
|
2644
|
-
/**
|
|
2645
|
-
* datepicker template 그리기
|
|
2646
|
-
*/
|
|
2647
|
-
createDatetimeTemplate() {
|
|
2648
|
-
const showMonthAfterYear = this.options.showMonthAfterYear;
|
|
2649
|
-
let datetimeTemplate = `<div class="ddtp-datetime ${this.options.isRTL ? "rtl" : ""}" view-mode="${this._viewMode}">
|
|
2650
|
-
<div class="ddtp-header">
|
|
2651
|
-
<span class="${showMonthAfterYear ? "ddtp-header-year" : "ddtp-header-month"}"></span>
|
|
2652
|
-
<span class="${showMonthAfterYear ? "ddtp-header-month" : "ddtp-header-year"}"></span>
|
|
2653
|
-
|
|
2654
|
-
<span class="ddtp-date-move">
|
|
2655
|
-
<a href="javascript:;" class="ddtp-move-btn prev">
|
|
2656
|
-
<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>
|
|
2657
|
-
</a>
|
|
2658
|
-
<a href="javascript:;" class="ddtp-move-btn next">
|
|
2659
|
-
<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>
|
|
2660
|
-
</a>
|
|
2661
|
-
</span>
|
|
2662
|
-
</div>
|
|
2663
|
-
<div class="ddtp-body">
|
|
2664
|
-
<table class="ddtp-days">
|
|
2665
|
-
<thead class="ddtp-day-header">
|
|
2666
|
-
<tr>
|
|
2667
|
-
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[0]]}">${Lanauage.getWeeksMessage(this.dayOrder[0])}</td>
|
|
2668
|
-
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[1]]}">${Lanauage.getWeeksMessage(this.dayOrder[1])}</td>
|
|
2669
|
-
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[2]]}">${Lanauage.getWeeksMessage(this.dayOrder[2])}</td>
|
|
2670
|
-
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[3]]}">${Lanauage.getWeeksMessage(this.dayOrder[3])}</td>
|
|
2671
|
-
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[4]]}">${Lanauage.getWeeksMessage(this.dayOrder[4])}</td>
|
|
2672
|
-
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[5]]}">${Lanauage.getWeeksMessage(this.dayOrder[5])}</td>
|
|
2673
|
-
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[6]]}">${Lanauage.getWeeksMessage(this.dayOrder[6])}</td>
|
|
2674
|
-
</tr>
|
|
2675
|
-
</thead>
|
|
2676
|
-
<tbody class="ddtp-day-body">
|
|
2677
|
-
</tbody>
|
|
2678
|
-
|
|
2679
|
-
<tfoot class="ddtp-day-footer">
|
|
2680
|
-
<td colspan="7">
|
|
2681
|
-
<div style="width:99%;text-align:center;margin-top: 5px;${this.options.enableTodayBtn ? "" : "display:none;"}"><button type="button" class="ddtp-today">${Lanauage.getMessage("today")}</button></div>
|
|
2682
|
-
<div class="footer-tooltip"></div>
|
|
2683
|
-
</td>
|
|
2684
|
-
</tfoot>
|
|
2685
|
-
</table>
|
|
2686
|
-
|
|
2687
|
-
<div class="ddtp-times">
|
|
2688
|
-
<div class="time-container">
|
|
2689
|
-
<div class="ddtp-time">
|
|
2690
|
-
<span>H: </span><input type="number" class="ddtp-hour" min="0" max="23" maxlength="2">
|
|
2691
|
-
<input type="range" min="0" max="23" class="ddtp-hour-range">
|
|
2692
|
-
</div>
|
|
2693
|
-
<div class="ddtp-time">
|
|
2694
|
-
<span>M: </span><input type="number" class="ddtp-minute" min="0" max="59" size="2" maxlength="2">
|
|
2695
|
-
<input type="range" min="0" max="59" class="ddtp-minute-range">
|
|
2696
|
-
</div>
|
|
2697
|
-
</div>
|
|
2698
|
-
<div class="ddtp-btn">
|
|
2699
|
-
<button type="button" class="time-select">${Lanauage.getMessage("ok")}</button>
|
|
2700
|
-
</div>
|
|
2701
|
-
</div>
|
|
2702
|
-
|
|
2703
|
-
<div class="ddtp-months">
|
|
2704
|
-
</div>
|
|
2705
|
-
|
|
2706
|
-
<div class="ddtp-years">
|
|
2707
|
-
</div>
|
|
2708
|
-
</div>
|
|
2709
|
-
</div>`;
|
|
2710
|
-
this.datetimeElement.innerHTML = datetimeTemplate;
|
|
2711
|
-
}
|
|
2712
|
-
refresh(beforeChangeDatepickerCheck) {
|
|
2713
|
-
if (this._viewMode === DateViewMode.date || this._viewMode === DateViewMode.datetime) {
|
|
2714
|
-
this.dayDraw(beforeChangeDatepickerCheck);
|
|
2715
|
-
return;
|
|
2716
|
-
}
|
|
2717
|
-
if (this._viewMode === DateViewMode.month) {
|
|
2718
|
-
this.monthDraw(beforeChangeDatepickerCheck);
|
|
2719
|
-
return;
|
|
2720
|
-
}
|
|
2721
|
-
if (this._viewMode === DateViewMode.year) {
|
|
2722
|
-
this.yearDraw(beforeChangeDatepickerCheck);
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
/**
|
|
2726
|
-
* 년 달력 그리기
|
|
2727
|
-
*/
|
|
2728
|
-
yearDraw(beforeChangeDatepickerCheck) {
|
|
2729
|
-
var _a;
|
|
2730
|
-
const currentYear = this.currentDate.format("YYYY");
|
|
2731
|
-
if (beforeChangeDatepickerCheck !== false && this.initMode == DateViewMode.year) {
|
|
2732
|
-
this.beforeChangeDatepicker();
|
|
2733
|
-
return;
|
|
2734
|
-
}
|
|
2735
|
-
const startYear = +currentYear - 8;
|
|
2736
|
-
this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${startYear} ~ ${startYear + 15}`;
|
|
2737
|
-
const beforeDrawDateFlag = core.isFunction(this.options.beforeDrawDate);
|
|
2738
|
-
const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
|
|
2739
|
-
const calHTML = [];
|
|
2740
|
-
for (let i = 0; i < 16; i++) {
|
|
2741
|
-
const year = startYear + i;
|
|
2742
|
-
const disabled = this.isYearDisabled(year);
|
|
2743
|
-
let addStylceClass = disabled ? " disabled" : "";
|
|
2744
|
-
let tooltip = "";
|
|
2745
|
-
if (beforeDrawDateFlag && beforeDrawDateFn) {
|
|
2746
|
-
const reval = beforeDrawDateFn({ mode: this._viewMode, date: year });
|
|
2747
|
-
addStylceClass += reval.style ? " " + reval.style : "";
|
|
2748
|
-
tooltip = reval.tooltip;
|
|
2749
|
-
tooltip = tooltip ? `title="${tooltip}"` : "";
|
|
2750
|
-
}
|
|
2751
|
-
calHTML.push(`<div class="ddtp-year ${addStylceClass}" data-year="${year}" ${tooltip}>${year}</div>`);
|
|
2752
|
-
}
|
|
2753
|
-
this.datetimeElement.querySelector(".ddtp-years").innerHTML = calHTML.join("");
|
|
2754
|
-
if (this.initMode == DateViewMode.year) {
|
|
2755
|
-
this.afterChangeDatepicker();
|
|
2756
|
-
}
|
|
2757
|
-
(_a = this.datetimeElement.querySelectorAll(".ddtp-year")) == null ? void 0 : _a.forEach((yearEle) => {
|
|
2758
|
-
yearEle.addEventListener("click", (e) => {
|
|
2759
|
-
const targetEle = e.target;
|
|
2760
|
-
if (targetEle) {
|
|
2761
|
-
const year = targetEle.getAttribute("data-year");
|
|
2762
|
-
if (year) {
|
|
2763
|
-
const numYear = +year;
|
|
2764
|
-
if (this.isYearDisabled(numYear)) {
|
|
2765
|
-
return;
|
|
2766
|
-
}
|
|
2767
|
-
if (this.initMode == DateViewMode.year) {
|
|
2768
|
-
if (this.isYearDisabled(numYear)) {
|
|
2769
|
-
return;
|
|
2770
|
-
}
|
|
2771
|
-
this.currentDate.setYear(numYear);
|
|
2772
|
-
this.dateChangeEvent(e);
|
|
2773
|
-
return;
|
|
2774
|
-
}
|
|
2775
|
-
this.currentDate.setYear(numYear);
|
|
2776
|
-
this.viewMode = this.initMode;
|
|
2777
|
-
}
|
|
2778
|
-
}
|
|
2779
|
-
});
|
|
2780
|
-
});
|
|
2781
|
-
}
|
|
2782
|
-
/**
|
|
2783
|
-
* 월 달력 그리기
|
|
2784
|
-
*/
|
|
2785
|
-
monthDraw(beforeChangeDatepickerCheck) {
|
|
2786
|
-
var _a;
|
|
2787
|
-
if (beforeChangeDatepickerCheck !== false && this.initMode == DateViewMode.month) {
|
|
2788
|
-
this.beforeChangeDatepicker();
|
|
2789
|
-
return;
|
|
2790
|
-
}
|
|
2791
|
-
const year = this.currentDate.format("YYYY");
|
|
2792
|
-
this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${year}`;
|
|
2793
|
-
const monthElements = this.datetimeElement.querySelectorAll(".ddtp-months > .ddtp-month");
|
|
2794
|
-
if (monthElements.length > 0) {
|
|
2795
|
-
if (this.isYearDisabled(+year)) {
|
|
2796
|
-
monthElements.forEach((monthEle) => {
|
|
2797
|
-
if (!monthEle.classList.contains("disabled")) {
|
|
2798
|
-
monthEle.classList.add("disabled");
|
|
2799
|
-
}
|
|
2800
|
-
});
|
|
2801
|
-
return;
|
|
2802
|
-
}
|
|
2803
|
-
monthElements.forEach((monthEle, idx) => {
|
|
2804
|
-
if (this.isMonthDisabled(+year, idx)) {
|
|
2805
|
-
if (!monthEle.classList.contains("disabled")) {
|
|
2806
|
-
monthEle.classList.add("disabled");
|
|
2807
|
-
}
|
|
2808
|
-
} else {
|
|
2809
|
-
monthEle.classList.remove("disabled");
|
|
2810
|
-
}
|
|
2811
|
-
});
|
|
2812
|
-
if (this.initMode == DateViewMode.month) {
|
|
2813
|
-
this.afterChangeDatepicker();
|
|
2814
|
-
}
|
|
2815
|
-
return;
|
|
2816
|
-
}
|
|
2817
|
-
this.datetimeElement.querySelector(".ddtp-header-month").textContent = this.currentDate.format("MMMM");
|
|
2818
|
-
const beforeDrawDateFlag = core.isFunction(this.options.beforeDrawDate);
|
|
2819
|
-
const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
|
|
2820
|
-
const calHTML = [];
|
|
2821
|
-
for (let i = 0; i < 12; i++) {
|
|
2822
|
-
const disabled = this.isMonthDisabled(+year, i);
|
|
2823
|
-
let addStylceClass = disabled ? " disabled" : "";
|
|
2824
|
-
let tooltip = "";
|
|
2825
|
-
if (beforeDrawDateFlag && beforeDrawDateFn) {
|
|
2826
|
-
const reval = beforeDrawDateFn({ mode: this._viewMode, date: year + "/" + (i + 1) });
|
|
2827
|
-
addStylceClass += reval.style ? " " + reval.style : "";
|
|
2828
|
-
tooltip = reval.tooltip;
|
|
2829
|
-
tooltip = tooltip ? `title="${tooltip}"` : "";
|
|
2830
|
-
}
|
|
2831
|
-
calHTML.push(`<div class="ddtp-month ${addStylceClass}" data-month="${i}" ${tooltip}>${Lanauage.getMonthsMessage(i, "abbr")}</div>`);
|
|
2832
|
-
}
|
|
2833
|
-
this.datetimeElement.querySelector(".ddtp-months").innerHTML = calHTML.join("");
|
|
2834
|
-
if (this.initMode == DateViewMode.month) {
|
|
2835
|
-
this.afterChangeDatepicker();
|
|
2836
|
-
}
|
|
2837
|
-
(_a = this.datetimeElement.querySelectorAll(".ddtp-month")) == null ? void 0 : _a.forEach((monthEle) => {
|
|
2838
|
-
monthEle.addEventListener("click", (e) => {
|
|
2839
|
-
const targetEle = e.target;
|
|
2840
|
-
if (targetEle) {
|
|
2841
|
-
const month = targetEle.getAttribute("data-month");
|
|
2842
|
-
if (month) {
|
|
2843
|
-
if (this.isMonthDisabled(this.currentDate.getYear(), +month)) {
|
|
2844
|
-
return false;
|
|
2845
|
-
}
|
|
2846
|
-
if (this.initMode == DateViewMode.month) {
|
|
2847
|
-
this.currentDate.setMonth(+month);
|
|
2848
|
-
this.dateChangeEvent(e);
|
|
2849
|
-
return;
|
|
2850
|
-
}
|
|
2851
|
-
this.currentDate.setMonth(+month);
|
|
2852
|
-
this.viewMode = this.initMode;
|
|
2853
|
-
this.dayDraw();
|
|
2854
|
-
}
|
|
2855
|
-
}
|
|
2856
|
-
});
|
|
2857
|
-
});
|
|
2858
|
-
}
|
|
2859
|
-
/**
|
|
2860
|
-
* 날짜 그리기
|
|
2861
|
-
*/
|
|
2862
|
-
dayDraw(beforeChangeDatepickerCheck) {
|
|
2863
|
-
if (beforeChangeDatepickerCheck !== false && (this.initMode == DateViewMode.date || this.initMode == DateViewMode.datetime)) {
|
|
2864
|
-
this.beforeChangeDatepicker();
|
|
2865
|
-
return;
|
|
2866
|
-
}
|
|
2867
|
-
let monthFirstDate = this.currentDate.clone();
|
|
2868
|
-
const currentMonth = monthFirstDate.getMonth();
|
|
2869
|
-
monthFirstDate.setDate(1);
|
|
2870
|
-
this.datetimeElement.querySelector(".ddtp-header-year").textContent = monthFirstDate.format("YYYY");
|
|
2871
|
-
this.datetimeElement.querySelector(".ddtp-header-month").textContent = monthFirstDate.format("MMMM");
|
|
2872
|
-
let day = monthFirstDate.getDay();
|
|
2873
|
-
day = day - this.dayOrder[0];
|
|
2874
|
-
if (day >= 0) {
|
|
2875
|
-
monthFirstDate.addDate(-day);
|
|
2876
|
-
} else {
|
|
2877
|
-
monthFirstDate.addDate(-(7 + day));
|
|
2878
|
-
}
|
|
2879
|
-
const beforeDrawDateFlag = core.isFunction(this.options.beforeDrawDate);
|
|
2880
|
-
const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
|
|
2881
|
-
const calHTML = [];
|
|
2882
|
-
for (let i = 0; i < 42; i++) {
|
|
2883
|
-
let dateItem;
|
|
2884
|
-
if (i == 0) {
|
|
2885
|
-
dateItem = monthFirstDate;
|
|
2886
|
-
} else {
|
|
2887
|
-
dateItem = monthFirstDate.clone().addDate(i);
|
|
2888
|
-
}
|
|
2889
|
-
const dateItemFormat = dateItem.format(DEFAULT_FORMAT.date);
|
|
2890
|
-
if (i % 7 == 0) {
|
|
2891
|
-
calHTML.push((i == 0 ? "" : "</tr>") + "<tr>");
|
|
2892
|
-
}
|
|
2893
|
-
let disabled = this.isDayDisabled(dateItem);
|
|
2894
|
-
let addStylceClass = DAY_STYLE_CLASS[this.dayOrder[i % 7]];
|
|
2895
|
-
const dateItemMonth = dateItem.getMonth();
|
|
2896
|
-
if (dateItemMonth != currentMonth) {
|
|
2897
|
-
if (dateItemMonth < currentMonth) {
|
|
2898
|
-
addStylceClass += dateItemMonth == 1 ? " new" : " old";
|
|
2899
|
-
} else {
|
|
2900
|
-
addStylceClass += currentMonth == 1 && dateItemMonth == 12 ? " old" : " new";
|
|
2901
|
-
}
|
|
2902
|
-
}
|
|
2903
|
-
addStylceClass += this.todayDate == dateItemFormat ? " ddtp-today" : "";
|
|
2904
|
-
addStylceClass += disabled ? " disabled" : "";
|
|
2905
|
-
let tooltip = "";
|
|
2906
|
-
if (beforeDrawDateFlag && beforeDrawDateFn) {
|
|
2907
|
-
const reval = beforeDrawDateFn({ mode: this._viewMode, item: dateItem, date: dateItem.format(this.dateFormat) });
|
|
2908
|
-
addStylceClass += reval.style ? " " + reval.style : "";
|
|
2909
|
-
addStylceClass += reval.check ? " ddtp-event" : "";
|
|
2910
|
-
tooltip = reval.tooltip;
|
|
2911
|
-
tooltip = tooltip ? `title="${tooltip}"` : "";
|
|
2912
|
-
}
|
|
2913
|
-
calHTML.push(`<td class="ddtp-day ${addStylceClass}" data-day="${dateItem.format("M,D")}" ${tooltip}>`);
|
|
2914
|
-
calHTML.push(`<span>${dateItem.format("d")}</span>`);
|
|
2915
|
-
calHTML.push("</td>");
|
|
2916
|
-
}
|
|
2917
|
-
calHTML.push("</tr>");
|
|
2918
|
-
this.datetimeElement.querySelector(".ddtp-day-body").innerHTML = calHTML.join("");
|
|
2919
|
-
if (this.initMode == DateViewMode.date || this.initMode == DateViewMode.datetime) {
|
|
2920
|
-
this.afterChangeDatepicker();
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2923
|
-
isDayDisabled(dateItem) {
|
|
2924
|
-
if (this.minDate != -1 && this.minDate > dateItem.getTime() || this.maxDate != -1 && this.maxDate < dateItem.getTime()) {
|
|
2925
|
-
return true;
|
|
2926
|
-
}
|
|
2927
|
-
return false;
|
|
2928
|
-
}
|
|
2929
|
-
isYearDisabled(year) {
|
|
2930
|
-
if (this.minYear != -1 && this.minYear > year || this.maxYear != -1 && this.maxYear < year) {
|
|
2931
|
-
return true;
|
|
2932
|
-
}
|
|
2933
|
-
return false;
|
|
2934
|
-
}
|
|
2935
|
-
isMonthDisabled(year, month) {
|
|
2936
|
-
if (this.isYearDisabled(year)) {
|
|
2937
|
-
return true;
|
|
2938
|
-
}
|
|
2939
|
-
let yearMonth = +(year + core.leftPad(month, 2));
|
|
2940
|
-
if (this.minMonth != -1 && this.minMonth > yearMonth || this.maxMonth != -1 && this.maxMonth < yearMonth) {
|
|
2941
|
-
return true;
|
|
2942
|
-
}
|
|
2943
|
-
return false;
|
|
2944
|
-
}
|
|
2945
|
-
static setMessage(message2) {
|
|
2946
|
-
Lanauage.setDefaultMessage(message2);
|
|
2947
|
-
}
|
|
2948
|
-
};
|
|
2949
|
-
_DateTimePicker.VERSION = `${"0.0.13"}`;
|
|
2950
|
-
_DateTimePicker.format = format;
|
|
2951
|
-
_DateTimePicker.parser = parser;
|
|
2952
|
-
let DateTimePicker = _DateTimePicker;
|
|
2953
|
-
function getDocSize() {
|
|
2954
|
-
return {
|
|
2955
|
-
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
|
|
2956
|
-
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
|
|
2957
|
-
};
|
|
2958
|
-
}
|
|
2959
1519
|
class DateRender extends Render {
|
|
2960
1520
|
constructor(field, rowElement, daraForm) {
|
|
2961
1521
|
super(daraForm, field, rowElement);
|
|
@@ -2967,9 +1527,9 @@ class DateRender extends Render {
|
|
|
2967
1527
|
let dateOnSelectEvent;
|
|
2968
1528
|
this.field.rendererOptions = Object.assign({}, this.field.rendererOptions);
|
|
2969
1529
|
if (typeof this.field.rendererOptions.onSelect !== "undefined") {
|
|
2970
|
-
dateOnSelectEvent =
|
|
1530
|
+
dateOnSelectEvent = this.field.rendererOptions.onSelect;
|
|
2971
1531
|
}
|
|
2972
|
-
if (isUndefined(this.field.rendererOptions.mode)) {
|
|
1532
|
+
if (utils.isUndefined(this.field.rendererOptions.mode)) {
|
|
2973
1533
|
if (this.field.renderType == "datemonth" || this.field.renderType == "datehour") {
|
|
2974
1534
|
this.field.rendererOptions.mode = this.field.renderType.replace("date", "");
|
|
2975
1535
|
} else {
|
|
@@ -2977,13 +1537,13 @@ class DateRender extends Render {
|
|
|
2977
1537
|
}
|
|
2978
1538
|
}
|
|
2979
1539
|
this.field.rendererOptions.onSelect = (dt, e) => {
|
|
2980
|
-
if (dateOnSelectEvent) {
|
|
1540
|
+
if (utils.isFunction(dateOnSelectEvent)) {
|
|
2981
1541
|
dateOnSelectEvent(dt, e);
|
|
2982
1542
|
}
|
|
2983
1543
|
this.setValue(dt);
|
|
2984
1544
|
this.valid();
|
|
2985
1545
|
};
|
|
2986
|
-
this.dateObj = new DateTimePicker(this.element, this.field.rendererOptions, {});
|
|
1546
|
+
this.dateObj = new datetimepicker.DateTimePicker(this.element, this.field.rendererOptions, {});
|
|
2987
1547
|
}
|
|
2988
1548
|
createField() {
|
|
2989
1549
|
const field = this.field;
|
|
@@ -3108,8 +1668,8 @@ class TabRender extends Render {
|
|
|
3108
1668
|
let tabBodyTemplate = `<div class="df-tab-panel ${firstFlag ? "active" : ""}" tab-panel-id="${id}">${Render.getDescriptionTemplate(childField)}
|
|
3109
1669
|
<div class="df-tab-group"></div>
|
|
3110
1670
|
</div>`;
|
|
3111
|
-
const tabElement = templateToElement(tabTemplate);
|
|
3112
|
-
const tabBodyElement = templateToElement(tabBodyTemplate);
|
|
1671
|
+
const tabElement = utils.templateToElement(tabTemplate);
|
|
1672
|
+
const tabBodyElement = utils.templateToElement(tabBodyTemplate);
|
|
3113
1673
|
firstFlag = false;
|
|
3114
1674
|
if (tabElement) {
|
|
3115
1675
|
(_a = fieldContainerElement.querySelector(".df-tab-header")) == null ? void 0 : _a.appendChild(tabElement);
|
|
@@ -3167,6 +1727,10 @@ class TabRender extends Render {
|
|
|
3167
1727
|
}
|
|
3168
1728
|
}
|
|
3169
1729
|
reset() {
|
|
1730
|
+
var _a;
|
|
1731
|
+
for (const childField of this.field.children ?? []) {
|
|
1732
|
+
(_a = childField.$tabForm) == null ? void 0 : _a.resetForm();
|
|
1733
|
+
}
|
|
3170
1734
|
}
|
|
3171
1735
|
getElement() {
|
|
3172
1736
|
return this.rowElement;
|
|
@@ -3298,7 +1862,7 @@ class GridRender extends Render {
|
|
|
3298
1862
|
}
|
|
3299
1863
|
rowTemplate.push("</tr>");
|
|
3300
1864
|
this.allAddRowInfo[$$idx] = addColumns;
|
|
3301
|
-
const addRowElement = templateToElement(rowTemplate.join(""));
|
|
1865
|
+
const addRowElement = utils.templateToElement(rowTemplate.join(""));
|
|
3302
1866
|
if (addRowElement) {
|
|
3303
1867
|
(_b = this.rowElement.querySelector("tbody")) == null ? void 0 : _b.append(addRowElement);
|
|
3304
1868
|
(_c = addRowElement.querySelector(".df-grid-row-remove")) == null ? void 0 : _c.addEventListener("click", (evt) => {
|
|
@@ -3308,7 +1872,7 @@ class GridRender extends Render {
|
|
|
3308
1872
|
valueItem = valueItem ?? {};
|
|
3309
1873
|
for (let columnField of addColumns) {
|
|
3310
1874
|
columnField.$instance = new columnField.$renderType(columnField, addRowElement == null ? void 0 : addRowElement.querySelector(`#${columnField.$xssName}`), this.gridForm);
|
|
3311
|
-
if (valueItem
|
|
1875
|
+
if (utils.hasProperty(valueItem, columnField.$orgin.name)) {
|
|
3312
1876
|
columnField.$instance.setValue(valueItem[columnField.$orgin.name]);
|
|
3313
1877
|
}
|
|
3314
1878
|
}
|
|
@@ -3334,8 +1898,7 @@ class GridRender extends Render {
|
|
|
3334
1898
|
*/
|
|
3335
1899
|
removeFieldInfo(rowIdx) {
|
|
3336
1900
|
let removeFieldArrs = [];
|
|
3337
|
-
|
|
3338
|
-
if (isEmpty(rowIdx)) {
|
|
1901
|
+
if (utils.isNil(rowIdx)) {
|
|
3339
1902
|
for (let key in this.allAddRowInfo) {
|
|
3340
1903
|
removeFieldArrs = removeFieldArrs.concat(this.allAddRowInfo[key]);
|
|
3341
1904
|
}
|
|
@@ -3375,10 +1938,10 @@ class GridRender extends Render {
|
|
|
3375
1938
|
setValue(value) {
|
|
3376
1939
|
this.field.$value = value;
|
|
3377
1940
|
let valueArr = [];
|
|
3378
|
-
if (isArray(value)) {
|
|
1941
|
+
if (utils.isArray(value)) {
|
|
3379
1942
|
valueArr = value;
|
|
3380
1943
|
} else {
|
|
3381
|
-
if (isPlainObject(value)) {
|
|
1944
|
+
if (utils.isPlainObject(value)) {
|
|
3382
1945
|
valueArr.push(value);
|
|
3383
1946
|
}
|
|
3384
1947
|
}
|
|
@@ -3507,7 +2070,7 @@ let localeMessage = {
|
|
|
3507
2070
|
"upper-char-special-number": "대문자,소문자,특수문자,숫자 각각 하나 이상 포함 되어야합니다."
|
|
3508
2071
|
}
|
|
3509
2072
|
};
|
|
3510
|
-
let Language$1 = class
|
|
2073
|
+
let Language$1 = class Language {
|
|
3511
2074
|
constructor() {
|
|
3512
2075
|
this.lang = localeMessage;
|
|
3513
2076
|
}
|
|
@@ -3576,16 +2139,16 @@ function message(msgFormat, msgParam) {
|
|
|
3576
2139
|
return typeof msgParam[key] !== "undefined" ? msgParam[key] : match;
|
|
3577
2140
|
});
|
|
3578
2141
|
}
|
|
3579
|
-
const
|
|
2142
|
+
const Language2 = new Language$1();
|
|
3580
2143
|
const getRenderer = (field) => {
|
|
3581
2144
|
let render;
|
|
3582
2145
|
if (field.renderType) {
|
|
3583
2146
|
render = RENDER_TEMPLATE[field.renderType];
|
|
3584
2147
|
}
|
|
3585
|
-
if (render && (render.isDataRender() === false || !isUndefined(field.name))) {
|
|
2148
|
+
if (render && (render.isDataRender() === false || !utils.isUndefined(field.name))) {
|
|
3586
2149
|
return render;
|
|
3587
2150
|
}
|
|
3588
|
-
if (isUndefined(field.name)) {
|
|
2151
|
+
if (utils.isUndefined(field.name)) {
|
|
3589
2152
|
if (field.children) {
|
|
3590
2153
|
return RENDER_TEMPLATE["group"];
|
|
3591
2154
|
} else {
|
|
@@ -3600,7 +2163,7 @@ class FieldInfoMap {
|
|
|
3600
2163
|
this.allFieldInfo = {};
|
|
3601
2164
|
this.keyNameMap = {};
|
|
3602
2165
|
this.conditionFields = [];
|
|
3603
|
-
this.fieldPrefix = `${FIELD_PREFIX}_${getHashCode(selector)}`;
|
|
2166
|
+
this.fieldPrefix = `${FIELD_PREFIX}_${utils.getHashCode(selector)}`;
|
|
3604
2167
|
this.form = form;
|
|
3605
2168
|
}
|
|
3606
2169
|
/**
|
|
@@ -3671,7 +2234,7 @@ class FieldInfoMap {
|
|
|
3671
2234
|
*/
|
|
3672
2235
|
removeFieldInfo(fieldName) {
|
|
3673
2236
|
const fieldKey = this.keyNameMap[fieldName];
|
|
3674
|
-
if (isUndefined(fieldKey)) return;
|
|
2237
|
+
if (utils.isUndefined(fieldKey)) return;
|
|
3675
2238
|
this.removeFieldInfoByKey(fieldKey);
|
|
3676
2239
|
delete this.keyNameMap[fieldName];
|
|
3677
2240
|
}
|
|
@@ -3823,8 +2386,8 @@ class FieldInfoMap {
|
|
|
3823
2386
|
renderInfo.focus();
|
|
3824
2387
|
}
|
|
3825
2388
|
fieldValid = fieldValid;
|
|
3826
|
-
if (isUndefined(fieldValid.message)) {
|
|
3827
|
-
fieldValid.message =
|
|
2389
|
+
if (utils.isUndefined(fieldValid.message)) {
|
|
2390
|
+
fieldValid.message = Language2.validMessage(fieldInfo, fieldValid)[0];
|
|
3828
2391
|
}
|
|
3829
2392
|
return fieldValid;
|
|
3830
2393
|
}
|
|
@@ -3845,7 +2408,7 @@ function addFormValue(formData, fieldInfo, useTypeValue) {
|
|
|
3845
2408
|
formData[key] = value;
|
|
3846
2409
|
}
|
|
3847
2410
|
} else {
|
|
3848
|
-
if (!
|
|
2411
|
+
if (!utils.isNil(fieldInfo.name)) {
|
|
3849
2412
|
formData[fieldInfo.name] = fieldValue;
|
|
3850
2413
|
}
|
|
3851
2414
|
}
|
|
@@ -3874,7 +2437,7 @@ function addFieldFormData(formData, fieldInfo, useTypeValue) {
|
|
|
3874
2437
|
formData.set(key, value);
|
|
3875
2438
|
}
|
|
3876
2439
|
} else {
|
|
3877
|
-
if (!
|
|
2440
|
+
if (!utils.isNil(fieldInfo.name)) {
|
|
3878
2441
|
formData.set(fieldInfo.$validName, fieldValue);
|
|
3879
2442
|
}
|
|
3880
2443
|
}
|
|
@@ -3914,7 +2477,7 @@ class FormTemplate {
|
|
|
3914
2477
|
let labelHideFlag = this.isLabelHide(field);
|
|
3915
2478
|
let fieldStyle = resolveFieldStyle(this.options, field, null, labelHideFlag);
|
|
3916
2479
|
this.addRowFieldInfo(field);
|
|
3917
|
-
const rowElement = templateToElement(`
|
|
2480
|
+
const rowElement = utils.templateToElement(`
|
|
3918
2481
|
<div class="df-row df-form-group ${fieldStyle.fieldClass}" id="${field.$key}">
|
|
3919
2482
|
${labelHideFlag ? "" : `<div class="df-label ${fieldStyle.labelClass} ${fieldStyle.labelAlignClass}" title="${field.label ?? ""}" style="${fieldStyle.labelStyle}">${this.getLabelTemplate(field)}</div>`}
|
|
3920
2483
|
|
|
@@ -3950,7 +2513,7 @@ class FormTemplate {
|
|
|
3950
2513
|
rowElement.classList.add("df-row", parentFieldStyle.rowStyleClass ?? "");
|
|
3951
2514
|
let idx = 0;
|
|
3952
2515
|
for (const childField of field.children) {
|
|
3953
|
-
if (
|
|
2516
|
+
if (utils.isNil(childField)) {
|
|
3954
2517
|
throw new Error(`parent field :[${field.$validName}], children index ${idx}, empty [${childField}]`);
|
|
3955
2518
|
}
|
|
3956
2519
|
childField.$parent = field;
|
|
@@ -3972,7 +2535,7 @@ class FormTemplate {
|
|
|
3972
2535
|
childFieldStyle = resolveFieldStyle(this.options, childField, beforeField, false);
|
|
3973
2536
|
labelTemplate = `<span class="df-label ${childFieldStyle.labelClass} ${childFieldStyle.labelAlignClass}" title="${childField.label ?? ""}" style="${childFieldStyle.labelStyle}">${this.getLabelTemplate(childField)}</span>`;
|
|
3974
2537
|
}
|
|
3975
|
-
const groupElement = templateToElement(`<div class="df-form-group ${childFieldStyle.fieldClass}" style="${childFieldStyle.fieldStyle}" id="${childField.$key}">
|
|
2538
|
+
const groupElement = utils.templateToElement(`<div class="df-form-group ${childFieldStyle.fieldClass}" style="${childFieldStyle.fieldStyle}" id="${childField.$key}">
|
|
3976
2539
|
${labelTemplate}
|
|
3977
2540
|
<span class="df-field-container ${childFieldStyle.valueClass} ${childField.required ? "required" : ""}" style="${childFieldStyle.valueStyle}"></span>
|
|
3978
2541
|
</div>`);
|
|
@@ -3998,7 +2561,7 @@ class FormTemplate {
|
|
|
3998
2561
|
*/
|
|
3999
2562
|
getLabelTemplate(field) {
|
|
4000
2563
|
const requiredTemplate = field.required ? `<span class="required"></span>` : "";
|
|
4001
|
-
const tooltipTemplate = isBlank(field.tooltip) ? "" : `<span class="df-tooltip">?<span class="df-tooltip-text">${field.tooltip}</span></span>`;
|
|
2564
|
+
const tooltipTemplate = utils.isBlank(field.tooltip) ? "" : `<span class="df-tooltip">?<span class="df-tooltip-text">${field.tooltip}</span></span>`;
|
|
4002
2565
|
return `<span class="df-label-text">${field.label ?? ""}</span> ${tooltipTemplate} ${requiredTemplate}`;
|
|
4003
2566
|
}
|
|
4004
2567
|
/**
|
|
@@ -4009,7 +2572,7 @@ class FormTemplate {
|
|
|
4009
2572
|
*/
|
|
4010
2573
|
isLabelHide(field) {
|
|
4011
2574
|
var _a;
|
|
4012
|
-
return ((_a = field.style) == null ? void 0 : _a.labelHide) || isUndefined(field.label);
|
|
2575
|
+
return ((_a = field.style) == null ? void 0 : _a.labelHide) || utils.isUndefined(field.label);
|
|
4013
2576
|
}
|
|
4014
2577
|
checkHiddenField(field) {
|
|
4015
2578
|
if (isHiddenField(field)) {
|
|
@@ -4025,7 +2588,7 @@ class FormTemplate {
|
|
|
4025
2588
|
* @param {FormField} field
|
|
4026
2589
|
*/
|
|
4027
2590
|
addRowFieldInfo(field) {
|
|
4028
|
-
if (!isBlank(field.name) && this.fieldInfoMap.hasFieldName(field.name)) {
|
|
2591
|
+
if (!utils.isBlank(field.name) && this.fieldInfoMap.hasFieldName(field.name)) {
|
|
4029
2592
|
throw new Error(`Duplicate field name "${field.name}"`);
|
|
4030
2593
|
}
|
|
4031
2594
|
this.fieldInfoMap.addField(field);
|
|
@@ -4034,10 +2597,18 @@ class FormTemplate {
|
|
|
4034
2597
|
}
|
|
4035
2598
|
function initFormOptions(options) {
|
|
4036
2599
|
const opts = merge({}, DEFAULT_OPTIONS, options);
|
|
2600
|
+
opts.fields = normalizeFields(opts.fields);
|
|
4037
2601
|
return opts;
|
|
4038
2602
|
}
|
|
4039
2603
|
function setDefaultOptions(options) {
|
|
4040
2604
|
DEFAULT_OPTIONS = merge({}, DEFAULT_OPTIONS, options);
|
|
2605
|
+
DEFAULT_OPTIONS.fields = normalizeFields(DEFAULT_OPTIONS.fields);
|
|
2606
|
+
}
|
|
2607
|
+
function normalizeFields(fields) {
|
|
2608
|
+
return (fields ?? []).filter((field) => field != null).map((field) => {
|
|
2609
|
+
if (Array.isArray(field.children)) field.children = normalizeFields(field.children);
|
|
2610
|
+
return field;
|
|
2611
|
+
});
|
|
4041
2612
|
}
|
|
4042
2613
|
let DEFAULT_OPTIONS = {
|
|
4043
2614
|
style: {
|
|
@@ -4133,6 +2704,7 @@ const _DaraForm = class _DaraForm {
|
|
|
4133
2704
|
}
|
|
4134
2705
|
};
|
|
4135
2706
|
this.addField = (field) => {
|
|
2707
|
+
if (!normalizeFields([field]).length) return;
|
|
4136
2708
|
this.options.fields.push(field);
|
|
4137
2709
|
this.formTemplate.addRow(field);
|
|
4138
2710
|
this.conditionCheck();
|
|
@@ -4180,7 +2752,7 @@ const _DaraForm = class _DaraForm {
|
|
|
4180
2752
|
};
|
|
4181
2753
|
this.isValidField = (fieldName) => {
|
|
4182
2754
|
const fieldInfo = this.fieldInfoMap.getFieldName(fieldName);
|
|
4183
|
-
if (isUndefined(fieldInfo)) {
|
|
2755
|
+
if (utils.isUndefined(fieldInfo)) {
|
|
4184
2756
|
throw new Error(`Field name [${fieldName}] not found`);
|
|
4185
2757
|
}
|
|
4186
2758
|
const renderInfo = fieldInfo.$instance;
|
|
@@ -4201,10 +2773,10 @@ const _DaraForm = class _DaraForm {
|
|
|
4201
2773
|
this.destroy = () => {
|
|
4202
2774
|
this.formElement.className = this.orginFormStyleClass;
|
|
4203
2775
|
this.formElement.replaceChildren();
|
|
2776
|
+
delete allInstance[this.selector];
|
|
4204
2777
|
for (const key in this) {
|
|
4205
|
-
if (
|
|
2778
|
+
if (utils.hasProperty(this, key)) {
|
|
4206
2779
|
delete this[key];
|
|
4207
|
-
delete allInstance[this.selector];
|
|
4208
2780
|
}
|
|
4209
2781
|
}
|
|
4210
2782
|
};
|
|
@@ -4212,11 +2784,13 @@ const _DaraForm = class _DaraForm {
|
|
|
4212
2784
|
return this.options.fields;
|
|
4213
2785
|
};
|
|
4214
2786
|
this.setFields = (fields) => {
|
|
4215
|
-
this.options.fields = fields;
|
|
4216
|
-
this.
|
|
2787
|
+
this.options.fields = normalizeFields(fields);
|
|
2788
|
+
this.formElement.replaceChildren();
|
|
2789
|
+
this.formValue = {};
|
|
2790
|
+
this.createForm(this.options.fields);
|
|
4217
2791
|
};
|
|
4218
2792
|
this.options = initFormOptions(options);
|
|
4219
|
-
|
|
2793
|
+
Language2.set(message2);
|
|
4220
2794
|
if (formElement) {
|
|
4221
2795
|
this.orginFormStyleClass = formElement.className;
|
|
4222
2796
|
formElement.classList.add("daracl-form");
|
|
@@ -4240,12 +2814,12 @@ const _DaraForm = class _DaraForm {
|
|
|
4240
2814
|
return new _DaraForm(formElement, options, message2);
|
|
4241
2815
|
}
|
|
4242
2816
|
static setMessage(message2) {
|
|
4243
|
-
|
|
2817
|
+
Language2.set(message2);
|
|
4244
2818
|
}
|
|
4245
2819
|
static setDefaultOptions(options, message2) {
|
|
4246
2820
|
setDefaultOptions(options);
|
|
4247
2821
|
if (message2) {
|
|
4248
|
-
|
|
2822
|
+
Language2.set(message2);
|
|
4249
2823
|
}
|
|
4250
2824
|
}
|
|
4251
2825
|
createForm(fields) {
|
|
@@ -4364,7 +2938,7 @@ const _DaraForm = class _DaraForm {
|
|
|
4364
2938
|
keys.push(...Object.keys(fieldInfo.$tabForm.getValue(false) ?? {}));
|
|
4365
2939
|
}
|
|
4366
2940
|
keys.forEach((key) => {
|
|
4367
|
-
if (!isBlank(key)) delete this.formValue[key];
|
|
2941
|
+
if (!utils.isBlank(key)) delete this.formValue[key];
|
|
4368
2942
|
});
|
|
4369
2943
|
}
|
|
4370
2944
|
validTabCheck(fieldInfo) {
|
|
@@ -4400,28 +2974,21 @@ const _DaraForm = class _DaraForm {
|
|
|
4400
2974
|
fieldInfo.$instance.setDescription(desc);
|
|
4401
2975
|
}
|
|
4402
2976
|
static instance(ele) {
|
|
4403
|
-
|
|
4404
|
-
if (
|
|
4405
|
-
element = document.querySelector(ele);
|
|
4406
|
-
} else {
|
|
4407
|
-
element = ele;
|
|
4408
|
-
}
|
|
4409
|
-
element = element;
|
|
2977
|
+
const element = utils.isString(ele) ? document.querySelector(ele) : ele;
|
|
2978
|
+
if (!element) return void 0;
|
|
4410
2979
|
let selector = element.getAttribute(SEQ_ATTR_KEY);
|
|
4411
|
-
if (
|
|
2980
|
+
if (utils.isBlank(selector)) {
|
|
4412
2981
|
const keys = Object.keys(allInstance);
|
|
4413
|
-
if (keys.length > 1) {
|
|
4414
|
-
throw new Error(`selector empty : [${selector}]`);
|
|
4415
|
-
}
|
|
2982
|
+
if (keys.length > 1) throw new Error(`selector empty : [${selector}]`);
|
|
4416
2983
|
selector = keys[0];
|
|
4417
|
-
return allInstance[selector];
|
|
4418
2984
|
}
|
|
2985
|
+
return selector ? allInstance[selector] : void 0;
|
|
4419
2986
|
}
|
|
4420
2987
|
getFieldInfoMap() {
|
|
4421
2988
|
return this.fieldInfoMap;
|
|
4422
2989
|
}
|
|
4423
2990
|
};
|
|
4424
|
-
_DaraForm.VERSION = `${"0.0.
|
|
2991
|
+
_DaraForm.VERSION = `${"0.0.22"}`;
|
|
4425
2992
|
_DaraForm.validator = {
|
|
4426
2993
|
string: (value, field) => {
|
|
4427
2994
|
return stringValidator(value, field);
|