@daracl/form 0.0.16 → 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.
Files changed (92) hide show
  1. package/README.md +1 -1
  2. package/dist/DaraForm.d.ts +51 -2
  3. package/dist/FieldInfoMap.d.ts +8 -1
  4. package/dist/FormTemplate.d.ts +2 -2
  5. package/dist/constants.d.ts +5 -1
  6. package/dist/daracl.form.css +688 -0
  7. package/dist/daracl.form.min.css +10 -0
  8. package/dist/daracl.form.min.umd.js +171 -0
  9. package/dist/daracl.form.min.umd.js.map +1 -0
  10. package/dist/daracl.form.umd.js +4477 -0
  11. package/dist/daracl.form.umd.js.map +1 -0
  12. package/dist/defaultOption.d.ts +8 -0
  13. package/dist/event/renderEvents.d.ts +1 -1
  14. package/dist/global.d.ts +6 -0
  15. package/dist/index.cjs +1806 -519
  16. package/dist/index.cjs.map +1 -7
  17. package/dist/index.d.ts +7 -2
  18. package/dist/index.html +193 -348
  19. package/dist/index.js +4090 -3101
  20. package/dist/index.js.map +1 -7
  21. package/dist/index.min.cjs +171 -0
  22. package/dist/index.min.cjs.map +1 -0
  23. package/dist/index.min.js +2910 -0
  24. package/dist/index.min.js.map +1 -0
  25. package/dist/index.umd.d.ts +7 -0
  26. package/dist/renderer/ButtonRender.d.ts +2 -2
  27. package/dist/renderer/CheckboxRender.d.ts +2 -2
  28. package/dist/renderer/CustomRender.d.ts +2 -2
  29. package/dist/renderer/DateRender.d.ts +2 -2
  30. package/dist/renderer/DropdownRender.d.ts +2 -2
  31. package/dist/renderer/FileRender.d.ts +2 -2
  32. package/dist/renderer/GridRender.d.ts +2 -2
  33. package/dist/renderer/GroupRender.d.ts +2 -2
  34. package/dist/renderer/HiddenRender.d.ts +2 -2
  35. package/dist/renderer/NumberRender.d.ts +2 -2
  36. package/dist/renderer/PasswordRender.d.ts +2 -2
  37. package/dist/renderer/RadioRender.d.ts +2 -2
  38. package/dist/renderer/RangeRender.d.ts +2 -2
  39. package/dist/renderer/Render.d.ts +2 -2
  40. package/dist/renderer/TabRender.d.ts +2 -2
  41. package/dist/renderer/TextAreaRender.d.ts +2 -2
  42. package/dist/renderer/TextRender.d.ts +2 -2
  43. package/dist/types/FormField.d.ts +18 -13
  44. package/dist/types/FormOptions.d.ts +1 -1
  45. package/dist/types/style.d.ts +3 -0
  46. package/dist/util/renderFactory.d.ts +1 -1
  47. package/dist/util/styleUtils.d.ts +10 -12
  48. package/dist/util/utils.d.ts +1 -1
  49. package/package.json +129 -140
  50. package/style/abstracts/_index.scss +2 -0
  51. package/style/abstracts/_mixins.scss +22 -0
  52. package/style/abstracts/_variables.scss +1 -0
  53. package/style/base/_base.scss +59 -0
  54. package/style/base/_index.scss +1 -0
  55. package/style/components/_button.scss +16 -0
  56. package/style/components/_field-container.scss +41 -0
  57. package/style/components/_field-group.scss +16 -0
  58. package/style/components/_file-list.scss +33 -0
  59. package/style/components/_form-field.scss +47 -0
  60. package/style/components/_form-group.scss +90 -0
  61. package/style/components/_grid-field.scss +121 -0
  62. package/style/components/_icon.scss +16 -0
  63. package/style/components/_index.scss +11 -0
  64. package/style/components/_label.scss +59 -0
  65. package/style/components/_row.scss +88 -0
  66. package/style/components/_tab.scss +70 -0
  67. package/{dist/index.css → style/daracl.form.css} +19 -66
  68. package/style/daracl.form.css.map +1 -0
  69. package/style/daracl.form.min.css +2 -0
  70. package/style/daracl.form.min.css.map +1 -0
  71. package/style/daracl.form.scss +44 -691
  72. package/style/themes/_common.scss +13 -0
  73. package/style/themes/_dark.scss +20 -0
  74. package/style/themes/_index.scss +14 -0
  75. package/style/themes/_light.scss +20 -0
  76. package/style/themes/_mixin.scss +6 -0
  77. package/dist/commonVender.d.ts +0 -1
  78. package/dist/daracl.form.js +0 -5720
  79. package/dist/daracl.form.js.map +0 -1
  80. package/dist/daracl.form.min.js +0 -7
  81. package/dist/daracl.form.min.js.LICENSE.txt +0 -5
  82. package/dist/daracl.form.min.js.map +0 -1
  83. package/dist/daracl.vender.min.css +0 -5
  84. package/dist/daracl.vender.min.js +0 -2
  85. package/dist/daracl.vender.min.js.LICENSE.txt +0 -3
  86. package/dist/index.css.map +0 -7
  87. package/dist/indexVender.d.ts +0 -6
  88. package/dist/main.css +0 -6
  89. package/dist/main.css.map +0 -1
  90. package/dist/types/DateTimePicker.d.ts +0 -5
  91. package/src/index.ts +0 -5
  92. /package/dist/util/{Lanauage.d.ts → Language.d.ts} +0 -0
@@ -0,0 +1,4477 @@
1
+ (function(factory) {
2
+ typeof define === "function" && define.amd ? define(factory) : factory();
3
+ })(function() {
4
+ "use strict";
5
+ function isArray$1(value) {
6
+ return Array.isArray(value);
7
+ }
8
+ function isNil(value) {
9
+ return value === null || value === void 0;
10
+ }
11
+ function isString$1(value) {
12
+ return typeof value === "string" || value instanceof String;
13
+ }
14
+ function isEmpty$1(value) {
15
+ if (isNil(value)) {
16
+ return true;
17
+ }
18
+ if (isString$1(value)) {
19
+ return value.trim() === "";
20
+ }
21
+ if (Array.isArray(value)) {
22
+ return value.length === 0;
23
+ }
24
+ if (typeof value === "object") {
25
+ return Object.keys(value).length === 0;
26
+ }
27
+ return false;
28
+ }
29
+ function isFunction$1(value) {
30
+ return typeof value === "function" || value instanceof Function;
31
+ }
32
+ function isNumeric(value, typeIgnore = false) {
33
+ if (typeIgnore === true) return !Number.isNaN(value);
34
+ return (typeof value === "number" || isString$1(value) && value.trim() !== "" && !isNaN(parseFloat(value))) && isFinite(Number(value));
35
+ }
36
+ function leftPad(str, len, ch = "0") {
37
+ return pad(str, len, ch, "l");
38
+ }
39
+ function leftPadClamp(str, len, ch = "0") {
40
+ return pad(str, len, ch, "l", true);
41
+ }
42
+ function pad(orginStr, size, ch, type = "l", clamp = false) {
43
+ let str = "";
44
+ if (isEmpty$1(orginStr)) {
45
+ str = "";
46
+ } else {
47
+ str = isString$1(orginStr) ? orginStr : `${orginStr}`;
48
+ }
49
+ const strLength = str.length;
50
+ if (strLength > size) {
51
+ return clamp ? str.slice(0, size) : str;
52
+ }
53
+ const len = size - strLength;
54
+ if (len < 1) return str;
55
+ const padStr = ch.repeat(len);
56
+ return type === "l" ? padStr + str : str + padStr;
57
+ }
58
+ const xssFilter = {
59
+ "&": "&amp;",
60
+ "<": "&lt;",
61
+ ">": "&gt;",
62
+ '"': "&quot;",
63
+ "'": "&#39;"
64
+ };
65
+ const replaceXss = (inputText) => {
66
+ let returnText = inputText;
67
+ if (returnText) {
68
+ Object.keys(xssFilter).forEach((key) => {
69
+ returnText = returnText.replaceAll(key, xssFilter[key]);
70
+ });
71
+ }
72
+ return returnText;
73
+ };
74
+ const hasOwnProp = (obj, key) => {
75
+ return obj.hasOwnProperty(key);
76
+ };
77
+ const isBlank = (value) => {
78
+ if (value === null) return true;
79
+ if (value === "") return true;
80
+ if (typeof value === "undefined") return true;
81
+ if (typeof value === "string" && (value === "" || value.replace(/\s/g, "") === "")) return true;
82
+ return false;
83
+ };
84
+ const isUndefined = (value) => {
85
+ return typeof value === "undefined";
86
+ };
87
+ const isFunction = (value) => {
88
+ return typeof value === "function";
89
+ };
90
+ const isString = (value) => {
91
+ return typeof value === "string";
92
+ };
93
+ const isNumber = (value) => {
94
+ if (isBlank(value)) {
95
+ return false;
96
+ }
97
+ value = +value;
98
+ return !isNaN(value);
99
+ };
100
+ const isArray = (value) => {
101
+ return isArray$1(value);
102
+ };
103
+ const isEmpty = (value) => isUndefined(value) || value == null;
104
+ const isTabType = (field) => {
105
+ return field && field.renderType === "tab";
106
+ };
107
+ const isGridType = (field) => {
108
+ return field && field.renderType === "grid";
109
+ };
110
+ const replaceXssField = (field) => {
111
+ field.$xssName = getXssFieldName(field);
112
+ field.label = replaceXss(field.label);
113
+ return field;
114
+ };
115
+ const ignoreValueField = (field) => {
116
+ return isGridType(field.$parent) || isTabType(field.$parent);
117
+ };
118
+ const getXssFieldName = (field) => {
119
+ if (isUndefined(field.$xssName)) {
120
+ let returnText = field.name;
121
+ if (returnText) {
122
+ Object.keys(xssFilter).forEach((key) => {
123
+ returnText = returnText.replaceAll(key, "_");
124
+ });
125
+ }
126
+ return "df_" + returnText;
127
+ }
128
+ return field.$xssName;
129
+ };
130
+ const getHashCode = (str) => {
131
+ let hash = 0;
132
+ if (str.length == 0) return hash;
133
+ for (let i = 0; i < str.length; i++) {
134
+ let tmpChar = str.charCodeAt(i);
135
+ hash = (hash << 5) - hash + tmpChar;
136
+ hash = hash & hash;
137
+ }
138
+ return String(hash).replaceAll(/-/g, "_");
139
+ };
140
+ const isHiddenField = (field) => {
141
+ if (field.renderType === "hidden") {
142
+ return true;
143
+ }
144
+ return false;
145
+ };
146
+ const templateToElement = (htmlTemplate) => {
147
+ const template = document.createElement("template");
148
+ template.innerHTML = htmlTemplate;
149
+ return template.content.firstElementChild;
150
+ };
151
+ function isPlainObject(obj) {
152
+ if (typeof obj !== "object" || obj === null) {
153
+ return false;
154
+ }
155
+ let proto = obj;
156
+ while (Object.getPrototypeOf(proto) !== null) {
157
+ proto = Object.getPrototypeOf(proto);
158
+ }
159
+ return Object.getPrototypeOf(obj) === proto;
160
+ }
161
+ function isObject(value) {
162
+ return typeof value === "object" && value !== null && !isArray(value);
163
+ }
164
+ function isDate(value) {
165
+ return value instanceof Date && !isNaN(value.valueOf());
166
+ }
167
+ const merge = (...value) => {
168
+ let reval = value[0];
169
+ if (!isPlainObject(reval) || isEmpty(reval)) {
170
+ return reval;
171
+ }
172
+ let i = 1;
173
+ if (Object.keys(reval).length > 0) {
174
+ i = 0;
175
+ reval = isArray(reval) ? [] : {};
176
+ }
177
+ const argLen = value.length;
178
+ for (; i < argLen; i += 1) {
179
+ cloneDeep(reval, value[i]);
180
+ }
181
+ return reval;
182
+ };
183
+ function cloneDeep(dst, src) {
184
+ if (isObject(src)) {
185
+ return cloneObjectDeep(dst, src);
186
+ }
187
+ if (isArray(src)) {
188
+ return cloneArrayDeep(dst, src);
189
+ }
190
+ if (isDate(src)) {
191
+ return new src.constructor(src);
192
+ }
193
+ return src;
194
+ }
195
+ function cloneObjectDeep(dst, src) {
196
+ if (isFunction(src)) {
197
+ return src;
198
+ }
199
+ for (const key of Object.keys(src)) {
200
+ const val = src[key];
201
+ if (isUndefined(val)) {
202
+ continue;
203
+ }
204
+ if (val === null) {
205
+ dst[key] = val;
206
+ } else if (isFunction(val)) {
207
+ dst[key] = val;
208
+ } else if (isEmpty(dst[key])) {
209
+ dst[key] = cloneDeep(isArray(val) ? [] : {}, val);
210
+ } else if (!isObject(val)) {
211
+ dst[key] = val;
212
+ } else {
213
+ cloneDeep(dst[key], val);
214
+ }
215
+ }
216
+ return dst;
217
+ }
218
+ function cloneArrayDeep(dst, src) {
219
+ const isObj = isPlainObject(dst);
220
+ for (let i = 0; i < src.length; i += 1) {
221
+ const val = src[i];
222
+ let newVal;
223
+ if (val == null) {
224
+ newVal = val;
225
+ } else {
226
+ newVal = cloneDeep(isArray(val) ? [] : {}, val);
227
+ }
228
+ if (isObj) {
229
+ dst[i] = newVal;
230
+ } else {
231
+ dst.push(newVal);
232
+ }
233
+ }
234
+ return dst;
235
+ }
236
+ class Render {
237
+ constructor(form, field, rowElement) {
238
+ var _a;
239
+ this.enableView = true;
240
+ this.daraForm = form;
241
+ this.field = field;
242
+ this.rowElement = rowElement;
243
+ this.createField();
244
+ if (field.tooltip) (_a = rowElement.querySelector(".df-tooltip")) == null ? void 0 : _a.setAttribute("tooltip", field.tooltip);
245
+ }
246
+ setDefaultInfo() {
247
+ if (isUndefined(this.field.defaultValue)) {
248
+ this.setValue("", false);
249
+ } else {
250
+ this.setValue(this.field.defaultValue, false);
251
+ }
252
+ if (!isUndefined(this.field.placeholder)) {
253
+ const ele = this.getElement();
254
+ if (ele instanceof Element) {
255
+ ele.setAttribute("placeholder", this.field.placeholder);
256
+ }
257
+ }
258
+ }
259
+ setDefaultOption() {
260
+ this.setDisabled(this.field.disabled ?? false);
261
+ }
262
+ addChildField(element) {
263
+ var _a;
264
+ (_a = this.rowElement.querySelector(".df-field-container")) == null ? void 0 : _a.append(element);
265
+ }
266
+ static isDataRender() {
267
+ return true;
268
+ }
269
+ static isChildrenCreate() {
270
+ return true;
271
+ }
272
+ getForm() {
273
+ return this.daraForm;
274
+ }
275
+ setValueItems(value) {
276
+ }
277
+ static getDescriptionTemplate(field) {
278
+ const classNames = field.descriptionClass ? replaceXss(field.descriptionClass) : "";
279
+ const style = field.descriptionStyle ? 'style="' + replaceXss(field.descriptionStyle) + '"' : "";
280
+ return field.description ? `<div class="df-description ${classNames}" ${style}>${field.description}</div>` : "";
281
+ }
282
+ changeEventCall(field, e, rederInfo, fieldValue) {
283
+ var _a;
284
+ if (field.onChange) {
285
+ let changeInfo = {
286
+ field,
287
+ evt: e,
288
+ oldValue: field.$value,
289
+ value: fieldValue
290
+ };
291
+ if ((_a = field.listItem) == null ? void 0 : _a.list) {
292
+ let valuesItem = [];
293
+ const valueKey = Render.valuesValueKey(field);
294
+ for (let val of field.listItem.list) {
295
+ let changeVal = val[valueKey];
296
+ if (isString(fieldValue)) {
297
+ if (changeVal == fieldValue) {
298
+ valuesItem.push(val);
299
+ break;
300
+ }
301
+ } else if (isArray(fieldValue)) {
302
+ if (fieldValue.includes(changeVal)) {
303
+ valuesItem.push(val);
304
+ }
305
+ }
306
+ }
307
+ changeInfo.valueItems = valuesItem;
308
+ }
309
+ if (changeInfo.oldValue != changeInfo.value && field.onChange.call(null, changeInfo) === false) {
310
+ rederInfo.setValue(field.$value, false);
311
+ return false;
312
+ }
313
+ field.$value = changeInfo.value;
314
+ }
315
+ this.daraForm.conditionCheck();
316
+ }
317
+ focus() {
318
+ this.getElement().focus();
319
+ }
320
+ isEnableView() {
321
+ return this.enableView;
322
+ }
323
+ show() {
324
+ this.enableView = true;
325
+ this.rowElement.classList.remove("df-hidden");
326
+ }
327
+ hide() {
328
+ this.enableView = false;
329
+ if (!this.rowElement.classList.contains("df-hidden")) {
330
+ this.rowElement.classList.add("df-hidden");
331
+ }
332
+ }
333
+ /**
334
+ * 설명 추가
335
+ *
336
+ * @public
337
+ * @param {string} desc
338
+ */
339
+ setDescription(desc) {
340
+ var _a;
341
+ const descEle = this.rowElement.querySelector(".df-description");
342
+ if (descEle) {
343
+ descEle.textContent = desc;
344
+ } else {
345
+ const fieldEle = this.rowElement.querySelector(".df-field");
346
+ if (fieldEle) {
347
+ const parser2 = new DOMParser();
348
+ this.field.description = desc;
349
+ const descEle2 = parser2.parseFromString(Render.getDescriptionTemplate(this.field), "text/html").querySelector(".df-description");
350
+ if (descEle2) (_a = fieldEle.parentNode) == null ? void 0 : _a.insertBefore(descEle2, fieldEle.nextSibling);
351
+ }
352
+ }
353
+ }
354
+ setActive(id) {
355
+ }
356
+ setDisabled(flag) {
357
+ const ele = this.getElement();
358
+ if (ele instanceof HTMLElement) {
359
+ if (flag === false) {
360
+ this.getElement().removeAttribute("disabled");
361
+ } else {
362
+ this.getElement().setAttribute("disabled", true);
363
+ }
364
+ }
365
+ }
366
+ commonValidator() {
367
+ }
368
+ static valuesValueKey(field) {
369
+ var _a;
370
+ return ((_a = field.listItem) == null ? void 0 : _a.valueField) ? field.listItem.valueField : "value";
371
+ }
372
+ static valuesLabelKey(field) {
373
+ var _a;
374
+ return ((_a = field.listItem) == null ? void 0 : _a.labelField) ? field.listItem.labelField : "label";
375
+ }
376
+ static valuesLabelValue(label, val) {
377
+ let replaceFlag = false;
378
+ const resultValue = label.replace(/\{\{([A-Za-z0-9_.]*)\}\}/g, (match, key) => {
379
+ replaceFlag = true;
380
+ return val[key] || "";
381
+ });
382
+ if (replaceFlag) {
383
+ return resultValue;
384
+ }
385
+ return val[label] || "";
386
+ }
387
+ }
388
+ const regexp = {
389
+ mobile: /^\d{3}-\d{3,4}-\d{4}$/,
390
+ email: /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
391
+ 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*)?$/,
392
+ number: /\d$/,
393
+ alpha: /^[a-zA-Z]+$/,
394
+ "alpha-num": /^[a-zA-Z0-9]+$/,
395
+ variable: /^[a-zA-Z0-9_$][a-zA-Z0-9_$]*$/,
396
+ "number-char": /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]/,
397
+ "upper-char": /^(?=.*?[A-Z])(?=.*?[a-z])/,
398
+ "upper-char-special": /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$%^&*-])/,
399
+ "upper-char-special-number": /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]/
400
+ };
401
+ const regexpValidator = (value, field, result) => {
402
+ if (!field.$instance.isEnableView()) {
403
+ return { name: field.name, constraint: [] };
404
+ }
405
+ if (typeof result === "undefined") {
406
+ result = { name: field.name, constraint: [] };
407
+ }
408
+ const regexpType = field.regexpType;
409
+ if (regexpType) {
410
+ if (!regexp[regexpType].test(value)) {
411
+ result.regexp = regexpType;
412
+ return result;
413
+ }
414
+ }
415
+ return result;
416
+ };
417
+ const validator = (value, field, result) => {
418
+ if (field.validator) {
419
+ result.validator = field.validator(field, value);
420
+ if (typeof result.validator === "object") {
421
+ return result;
422
+ }
423
+ }
424
+ result = regexpValidator(value, field, result);
425
+ if (result.regexp) {
426
+ return result;
427
+ }
428
+ if (field.different) {
429
+ const diffFieldName = field.different.field;
430
+ const diffField = field.$instance.getForm().getField(diffFieldName);
431
+ if (!isEmpty(diffField) && field.$instance.getValue() == diffField.$instance.getValue()) {
432
+ result.message = field.different.message;
433
+ return result;
434
+ }
435
+ }
436
+ if (field.identical) {
437
+ const diffFieldName = field.identical.field;
438
+ const diffField = field.$instance.getForm().getField(diffFieldName);
439
+ if (!isEmpty(diffField) && field.$instance.getValue() != diffField.$instance.getValue()) {
440
+ result.message = field.identical.message;
441
+ return result;
442
+ }
443
+ }
444
+ return true;
445
+ };
446
+ const numberValidator = (value, field) => {
447
+ if (!field.$instance.isEnableView()) {
448
+ return true;
449
+ }
450
+ const result = { name: field.name, constraint: [] };
451
+ const numValue = Number(value);
452
+ if (field.required && isBlank(value)) {
453
+ result.constraint.push(RULES.REQUIRED);
454
+ return result;
455
+ }
456
+ if (!isNumber(value)) {
457
+ result.constraint.push(RULES.NAN);
458
+ return result;
459
+ }
460
+ if (validator(value, field, result) !== true) {
461
+ return result;
462
+ }
463
+ const rule = field.rule;
464
+ if (rule) {
465
+ const isMinimum = isNumber(rule.minimum), isMaximum = isNumber(rule.maximum);
466
+ let minRule = false, minExclusive = false, maxRule = false, maxExclusive = false;
467
+ if (isMinimum) {
468
+ if (rule.exclusiveMinimum && numValue <= rule.minimum) {
469
+ minExclusive = true;
470
+ } else if (numValue < rule.minimum) {
471
+ minRule = true;
472
+ }
473
+ }
474
+ if (isMaximum) {
475
+ if (rule.exclusiveMaximum && numValue >= rule.maximum) {
476
+ maxExclusive = true;
477
+ } else if (numValue > rule.maximum) {
478
+ maxRule = true;
479
+ }
480
+ }
481
+ if (isMinimum && isMaximum && (minRule || minExclusive || maxRule || maxExclusive)) {
482
+ if (rule.exclusiveMinimum && rule.exclusiveMaximum && (minExclusive || maxExclusive)) {
483
+ result.constraint.push(RULES.BETWEEN_EXCLUSIVE_MINMAX);
484
+ } else if (minExclusive) {
485
+ result.constraint.push(RULES.BETWEEN_EXCLUSIVE_MIN);
486
+ } else if (maxExclusive) {
487
+ result.constraint.push(RULES.BETWEEN_EXCLUSIVE_MAX);
488
+ } else {
489
+ result.constraint.push(RULES.BETWEEN);
490
+ }
491
+ } else {
492
+ if (minExclusive) {
493
+ result.constraint.push(RULES.EXCLUSIVE_MIN);
494
+ }
495
+ if (maxExclusive) {
496
+ result.constraint.push(RULES.EXCLUSIVE_MAX);
497
+ }
498
+ if (minRule) {
499
+ result.constraint.push(RULES.MIN);
500
+ }
501
+ if (maxRule) {
502
+ result.constraint.push(RULES.MAX);
503
+ }
504
+ }
505
+ }
506
+ if (result.constraint.length > 0) {
507
+ return result;
508
+ }
509
+ return true;
510
+ };
511
+ const invalidMessage = (field, rowElement, validResult) => {
512
+ if (validResult === true) {
513
+ rowElement.classList.remove("invalid");
514
+ if (!rowElement.classList.contains("valid")) {
515
+ rowElement.classList.add("valid");
516
+ }
517
+ const helpMessageElement = rowElement.querySelector(".df-help-message");
518
+ if (helpMessageElement) {
519
+ helpMessageElement.innerHTML = "";
520
+ }
521
+ return;
522
+ }
523
+ rowElement.classList.remove("valid");
524
+ if (!rowElement.classList.contains("invalid")) {
525
+ rowElement.classList.add("invalid");
526
+ }
527
+ if (validResult !== false) {
528
+ const message2 = Language$1.validMessage(field, validResult);
529
+ if (validResult.message) {
530
+ message2.push(validResult.message);
531
+ }
532
+ const helpMessageElement = rowElement.querySelector(".df-help-message");
533
+ if (helpMessageElement && message2.length > 0) {
534
+ const msgHtml = [];
535
+ message2.forEach((item) => {
536
+ msgHtml.push(`<div>${item}</div>`);
537
+ });
538
+ helpMessageElement.innerHTML = msgHtml.join("");
539
+ }
540
+ }
541
+ };
542
+ const resetRowElementStyleClass = (rowElement) => {
543
+ rowElement.classList.remove("invalid");
544
+ rowElement.classList.remove("valid");
545
+ };
546
+ const inputEvent = (field, element, renderInfo) => {
547
+ element.addEventListener("input", (e) => {
548
+ customChangeEventCall(field, e, renderInfo, renderInfo.getValue());
549
+ renderInfo.valid();
550
+ });
551
+ };
552
+ const numberInputEvent = (field, element, renderInfo) => {
553
+ element.addEventListener("keyup", (e) => {
554
+ const val = e.target.value;
555
+ if (!isNumber(val)) {
556
+ element.value = val.replace(/[^0-9\.\-\+]/g, "");
557
+ e.preventDefault();
558
+ }
559
+ customChangeEventCall(field, e, renderInfo, renderInfo.getValue());
560
+ renderInfo.valid();
561
+ });
562
+ };
563
+ const dropdownChangeEvent = (field, element, renderInfo) => {
564
+ element.addEventListener("change", (e) => {
565
+ customChangeEventCall(field, e, renderInfo, renderInfo.getValue());
566
+ renderInfo.valid();
567
+ });
568
+ };
569
+ const customChangeEventCall = (field, e, renderInfo, value) => {
570
+ renderInfo.changeEventCall(field, e, renderInfo, value);
571
+ };
572
+ class NumberRender extends Render {
573
+ constructor(field, rowElement, daraForm) {
574
+ super(daraForm, field, rowElement);
575
+ this.mounted();
576
+ this.setDefaultOption();
577
+ this.setDefaultInfo();
578
+ }
579
+ mounted() {
580
+ numberInputEvent(this.field, this.element, this);
581
+ }
582
+ createField() {
583
+ const field = this.field;
584
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
585
+ fieldContainerElement.innerHTML = `
586
+ <div class="df-field">
587
+ <input type="text" name="${field.$xssName}" class="df-form-field df-number df-help-icon" />
588
+ </div>
589
+ ${Render.getDescriptionTemplate(field)}
590
+ <div class="df-help-message"></div>
591
+ `;
592
+ this.element = fieldContainerElement.querySelector(`[name="${field.$xssName}"]`);
593
+ }
594
+ getValue() {
595
+ return this.element.value;
596
+ }
597
+ setValue(value, changeCheckFlag) {
598
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
599
+ this.element.value = this.field.$value;
600
+ return;
601
+ }
602
+ this.field.$value = value;
603
+ this.element.value = value;
604
+ }
605
+ reset() {
606
+ this.setDefaultInfo();
607
+ this.setDisabled(false);
608
+ resetRowElementStyleClass(this.rowElement);
609
+ }
610
+ getElement() {
611
+ return this.element;
612
+ }
613
+ valid() {
614
+ const validResult = numberValidator(this.getValue(), this.field);
615
+ invalidMessage(this.field, this.rowElement, validResult);
616
+ return validResult;
617
+ }
618
+ }
619
+ const stringValidator = (value, field) => {
620
+ if (!field.$instance.isEnableView()) {
621
+ return true;
622
+ }
623
+ let result = { name: field.name, constraint: [] };
624
+ if (field.required && isBlank(value)) {
625
+ result.constraint.push(RULES.REQUIRED);
626
+ return result;
627
+ }
628
+ const validResult = validator(value, field, result);
629
+ if (validResult !== true) {
630
+ return validResult;
631
+ }
632
+ const rule = field.rule;
633
+ if (rule) {
634
+ const valueLength = value.length;
635
+ const isMinNumber = isNumber(rule.minLength), isMaxNumber = isNumber(rule.maxLength);
636
+ let minRule = false, maxRule = false;
637
+ if (isMinNumber && valueLength < rule.minLength) {
638
+ minRule = true;
639
+ }
640
+ if (isMaxNumber && valueLength > rule.maxLength) {
641
+ maxRule = true;
642
+ }
643
+ if (isMinNumber && isMaxNumber && (minRule || maxRule)) {
644
+ result.constraint.push(RULES.BETWEEN);
645
+ } else {
646
+ if (minRule) {
647
+ result.constraint.push(RULES.MIN_LENGTH);
648
+ }
649
+ if (maxRule) {
650
+ result.constraint.push(RULES.MAX_LENGTH);
651
+ }
652
+ }
653
+ if (result.constraint.length > 0) {
654
+ return result;
655
+ }
656
+ }
657
+ return true;
658
+ };
659
+ class TextAreaRender extends Render {
660
+ constructor(field, rowElement, daraForm) {
661
+ super(daraForm, field, rowElement);
662
+ this.mounted();
663
+ this.setDefaultOption();
664
+ this.setDefaultInfo();
665
+ }
666
+ mounted() {
667
+ inputEvent(this.field, this.element, this);
668
+ }
669
+ createField() {
670
+ var _a;
671
+ const field = this.field;
672
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
673
+ let rows = (_a = field.rendererOptions) == null ? void 0 : _a.rows;
674
+ rows = +rows > 0 ? rows : 3;
675
+ fieldContainerElement.innerHTML = `
676
+ <div class="df-field">
677
+ <textarea name="${field.$xssName}" rows="${rows}" class="df-form-field df-textarea df-help-icon"></textarea>
678
+ </div>
679
+ ${Render.getDescriptionTemplate(field)}
680
+ <div class="df-help-message"></div>
681
+ `;
682
+ this.element = fieldContainerElement.querySelector(`[name="${field.$xssName}"]`);
683
+ }
684
+ getValue() {
685
+ return this.element.value;
686
+ }
687
+ setValue(value, changeCheckFlag) {
688
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
689
+ this.element.value = this.field.$value;
690
+ return;
691
+ }
692
+ this.field.$value = value;
693
+ this.element.value = value;
694
+ }
695
+ reset() {
696
+ this.setDefaultInfo();
697
+ this.setDisabled(false);
698
+ resetRowElementStyleClass(this.rowElement);
699
+ }
700
+ getElement() {
701
+ return this.element;
702
+ }
703
+ valid() {
704
+ const validResult = stringValidator(this.getValue(), this.field);
705
+ invalidMessage(this.field, this.rowElement, validResult);
706
+ return validResult;
707
+ }
708
+ }
709
+ class DropdownRender extends Render {
710
+ constructor(field, rowElement, daraForm) {
711
+ var _a, _b, _c, _d, _e;
712
+ super(daraForm, field, rowElement);
713
+ let initDefaultValue = "";
714
+ if (!isUndefined(field.defaultValue)) {
715
+ initDefaultValue = field.defaultValue;
716
+ }
717
+ const valueKey = DropdownRender.valuesValueKey(field);
718
+ let initDefaultValueFlag = false;
719
+ (_b = (_a = this.field.listItem) == null ? void 0 : _a.list) == null ? void 0 : _b.forEach((item) => {
720
+ let itemValue = item[valueKey];
721
+ if (item.selected) {
722
+ this.defaultSelected = itemValue;
723
+ }
724
+ if (itemValue == initDefaultValue) {
725
+ initDefaultValueFlag = true;
726
+ }
727
+ });
728
+ if (initDefaultValueFlag) {
729
+ this.defaultSelected = initDefaultValue;
730
+ } else if (!this.defaultSelected) {
731
+ if (((_c = field.rendererOptions) == null ? void 0 : _c.disableDefaultOption) === true) {
732
+ this.defaultSelected = ((_e = (_d = this.field.listItem) == null ? void 0 : _d.list) == null ? void 0 : _e.length) > 0 ? this.field.listItem.list[0][valueKey] || "" : "";
733
+ }
734
+ }
735
+ if (isUndefined(this.defaultSelected)) {
736
+ this.defaultSelected = "";
737
+ }
738
+ this.mounted();
739
+ this.setDefaultOption();
740
+ this.setValue(this.defaultSelected, false);
741
+ }
742
+ mounted() {
743
+ dropdownChangeEvent(this.field, this.element, this);
744
+ }
745
+ createField() {
746
+ const field = this.field;
747
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
748
+ let template = ` <div class="df-field"><select name="${field.$xssName}" class="df-form-field df-dropdown">
749
+ ${this.dropdownValuesTemplate(field)}
750
+ </select> <i class="df-help-icon"></i></div>
751
+ ${Render.getDescriptionTemplate(field)}
752
+ <div class="df-help-message"></div>
753
+ `;
754
+ fieldContainerElement.innerHTML = template;
755
+ this.element = fieldContainerElement.querySelector(`[name="${field.$xssName}"]`);
756
+ }
757
+ setValueItems(items) {
758
+ if (this.field.listItem) {
759
+ this.field.listItem.list = items;
760
+ } else {
761
+ this.field.listItem = {
762
+ list: items
763
+ };
764
+ }
765
+ this.element.innerHTML = this.dropdownValuesTemplate(this.field);
766
+ if (!isBlank(this.field.$value)) {
767
+ const currentValue = this.field.$value;
768
+ this.field.$value = "";
769
+ this.setValue(currentValue);
770
+ }
771
+ }
772
+ getValue() {
773
+ return this.element.value;
774
+ }
775
+ setValue(value, changeCheckFlag) {
776
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
777
+ this.element.value = this.field.$value;
778
+ return;
779
+ }
780
+ this.field.$value = value;
781
+ this.element.value = value;
782
+ }
783
+ reset() {
784
+ this.setValue(this.defaultSelected, false);
785
+ this.setDisabled(false);
786
+ resetRowElementStyleClass(this.rowElement);
787
+ }
788
+ getElement() {
789
+ return this.element;
790
+ }
791
+ valid() {
792
+ const value = this.getValue();
793
+ let validResult = true;
794
+ if (this.field.required) {
795
+ if (value.length < 1) {
796
+ validResult = { name: this.field.name, constraint: [] };
797
+ validResult.constraint.push(RULES.REQUIRED);
798
+ }
799
+ }
800
+ invalidMessage(this.field, this.rowElement, validResult);
801
+ return validResult;
802
+ }
803
+ dropdownValuesTemplate(field) {
804
+ var _a, _b, _c;
805
+ const labelKey = Render.valuesLabelKey(field);
806
+ const valueKey = Render.valuesValueKey(field);
807
+ let template = "";
808
+ if (((_a = field.rendererOptions) == null ? void 0 : _a.disableDefaultOption) !== true) {
809
+ template += `<option value="">${Language$1.getMessage("selection")}</option>`;
810
+ }
811
+ (_c = (_b = field.listItem) == null ? void 0 : _b.list) == null ? void 0 : _c.forEach((val) => {
812
+ const attr = `${val.selected ? "selected" : ""} ${val.disabled ? "disabled" : ""}`;
813
+ if (isUndefined(val[valueKey]) && val.label) {
814
+ template += `<option value="${val.value || ""}" ${attr}>${val.label}</option>`;
815
+ } else {
816
+ template += `<option value="${val[valueKey]}" ${attr}>${Render.valuesLabelValue(labelKey, val)}</option>`;
817
+ }
818
+ });
819
+ return template;
820
+ }
821
+ }
822
+ class TextRender extends Render {
823
+ constructor(field, rowElement, daraForm) {
824
+ super(daraForm, field, rowElement);
825
+ this.mounted();
826
+ this.setDefaultOption();
827
+ this.setDefaultInfo();
828
+ }
829
+ mounted() {
830
+ inputEvent(this.field, this.element, this);
831
+ }
832
+ createField() {
833
+ const field = this.field;
834
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
835
+ fieldContainerElement.innerHTML = `
836
+ <div class="df-field">
837
+ <input type="text" name="${field.$xssName}" class="df-form-field df-text df-help-icon" />
838
+ </div>
839
+ ${Render.getDescriptionTemplate(field)}
840
+ <div class="df-help-message"></div>
841
+ `;
842
+ this.element = fieldContainerElement.querySelector(`[name="${field.$xssName}"]`);
843
+ }
844
+ getValue() {
845
+ return this.element.value;
846
+ }
847
+ setValue(value, changeCheckFlag) {
848
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
849
+ this.element.value = this.field.$value;
850
+ return;
851
+ }
852
+ this.field.$value = value;
853
+ this.element.value = value;
854
+ }
855
+ reset() {
856
+ this.setDefaultInfo();
857
+ this.setDisabled(false);
858
+ resetRowElementStyleClass(this.rowElement);
859
+ }
860
+ getElement() {
861
+ return this.element;
862
+ }
863
+ valid() {
864
+ const validResult = stringValidator(this.getValue(), this.field);
865
+ invalidMessage(this.field, this.rowElement, validResult);
866
+ return validResult;
867
+ }
868
+ }
869
+ function resolveFieldStyle(formOptions, field, beforeField, isLabelHide) {
870
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
871
+ const fieldStyle = {
872
+ rowStyleClass: orientationClassName(field.orientation),
873
+ fieldClass: "",
874
+ fieldStyle: "",
875
+ labelClass: "",
876
+ labelStyle: "",
877
+ labelAlignClass: "",
878
+ valueClass: "",
879
+ valueStyle: "",
880
+ tabAlignClass: ""
881
+ };
882
+ const defaultLabelWidth = ((_a = beforeField == null ? void 0 : beforeField.style) == null ? void 0 : _a.labelWidth) ?? formOptions.style.labelWidth ?? "3";
883
+ let defaultValueWidth = ((_b = beforeField == null ? void 0 : beforeField.style) == null ? void 0 : _b.valueWidth) ?? formOptions.style.valueWidth ?? "9";
884
+ const position = ((_c = beforeField == null ? void 0 : beforeField.style) == null ? void 0 : _c.position) ?? formOptions.style.position;
885
+ const width = (_d = field.style) == null ? void 0 : _d.width;
886
+ const positionArr = FIELD_POSITION_STYLE[(_e = field.style) == null ? void 0 : _e.position] ?? FIELD_POSITION_STYLE[position] ?? FIELD_POSITION_STYLE.top;
887
+ fieldStyle.fieldClass = `${positionArr[0] ? "df-" + positionArr[0] : ""} ${((_f = field.style) == null ? void 0 : _f.customClass) || ""}`;
888
+ if (width) {
889
+ if (isNumber(width)) {
890
+ fieldStyle.fieldClass += isNumber(width) ? ` df-col-xs-${width}` : "";
891
+ } else {
892
+ fieldStyle.fieldStyle = isNumber(width) ? "" : `width:${width};`;
893
+ }
894
+ }
895
+ fieldStyle.tabAlignClass = "df-tab-al-" + (["right", "center"].includes((_g = field.style) == null ? void 0 : _g.tabAlign) ? field.style.tabAlign : "left");
896
+ const labelWidth = ((_h = field.style) == null ? void 0 : _h.labelWidth) || defaultLabelWidth;
897
+ fieldStyle.labelAlignClass = positionArr[1];
898
+ if (!isLabelHide && labelWidth && !["top", "bottom"].includes(positionArr[0])) {
899
+ if (isNumber(labelWidth)) {
900
+ const labelWidthValue = +labelWidth;
901
+ defaultValueWidth = 12 - labelWidthValue;
902
+ fieldStyle.labelClass = `df-col-xs-${labelWidthValue}`;
903
+ fieldStyle.valueClass = fieldStyle.labelStyle ? "df-col-full" : `df-col-xs-${defaultValueWidth}`;
904
+ } else {
905
+ fieldStyle.labelStyle = `width:${labelWidth};`;
906
+ }
907
+ }
908
+ const valueWidth = ((_i = field.style) == null ? void 0 : _i.valueWidth) || defaultValueWidth;
909
+ if (isLabelHide && !["left", "right"].includes(positionArr[0])) {
910
+ fieldStyle.valueClass = "df-col-full";
911
+ } else {
912
+ if (valueWidth && !["top", "bottom"].includes(positionArr[0])) {
913
+ if (isNumber(valueWidth)) {
914
+ fieldStyle.valueClass = fieldStyle.labelStyle ? "df-col-full" : `df-col-xs-${valueWidth}`;
915
+ } else {
916
+ fieldStyle.valueStyle = `width:${valueWidth};`;
917
+ }
918
+ } else {
919
+ fieldStyle.valueClass = fieldStyle.labelStyle ? "df-col-full" : "";
920
+ }
921
+ }
922
+ fieldStyle.fieldClass = spaceReplace(fieldStyle.fieldClass);
923
+ fieldStyle.labelClass = spaceReplace(fieldStyle.labelClass);
924
+ fieldStyle.valueClass = spaceReplace(fieldStyle.valueClass);
925
+ return fieldStyle;
926
+ }
927
+ function orientationClassName(orientation) {
928
+ return orientation === "horizontal" ? "df-horizontal" : "df-vertical";
929
+ }
930
+ function spaceReplace(str) {
931
+ return str.replace(/\s+/g, " ").trim();
932
+ }
933
+ class CheckboxRender extends Render {
934
+ constructor(field, rowElement, daraForm) {
935
+ var _a, _b;
936
+ super(daraForm, field, rowElement);
937
+ this.defaultCheckValue = [];
938
+ this.defaultCheckValue = [];
939
+ let initDefaultValue = [];
940
+ if (!isUndefined(field.defaultValue)) {
941
+ if (isArray(field.defaultValue)) {
942
+ initDefaultValue = field.defaultValue;
943
+ } else {
944
+ initDefaultValue = [field.defaultValue];
945
+ }
946
+ }
947
+ const valueKey = CheckboxRender.valuesValueKey(field);
948
+ if (isUndefined(this.field.listItem)) {
949
+ this.setValueItems([{ label: "", value: "Y" }]);
950
+ }
951
+ let initDefaultValueFlag = false;
952
+ (_b = (_a = this.field.listItem) == null ? void 0 : _a.list) == null ? void 0 : _b.forEach((item) => {
953
+ let itemValue = item[valueKey];
954
+ if (item.selected) {
955
+ this.defaultCheckValue.push(itemValue ? itemValue : true);
956
+ }
957
+ if (initDefaultValue.includes(itemValue)) {
958
+ initDefaultValueFlag = true;
959
+ }
960
+ });
961
+ this.defaultCheckValue = initDefaultValueFlag ? initDefaultValue : this.defaultCheckValue;
962
+ this.mounted();
963
+ this.setDefaultOption();
964
+ this.setValue(this.defaultCheckValue, false);
965
+ }
966
+ mounted() {
967
+ this.initEvent();
968
+ }
969
+ initEvent() {
970
+ const checkboxes = this.rowElement.querySelectorAll(this.getSelector());
971
+ checkboxes.forEach((ele) => {
972
+ ele.addEventListener("change", (e) => {
973
+ customChangeEventCall(this.field, e, this, this.getValue());
974
+ this.valid();
975
+ });
976
+ });
977
+ }
978
+ getSelector() {
979
+ return `input[type="checkbox"][name="${this.field.$xssName}"]`;
980
+ }
981
+ createField() {
982
+ var _a, _b;
983
+ const field = this.field;
984
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
985
+ const templates = [];
986
+ const fieldName = field.$xssName;
987
+ const labelKey = Render.valuesLabelKey(field);
988
+ const valueKey = Render.valuesValueKey(field);
989
+ templates.push(` <div class="df-field"><div class="df-field-group">`);
990
+ (_b = (_a = field.listItem) == null ? void 0 : _a.list) == null ? void 0 : _b.forEach((val) => {
991
+ const checkVal = val[valueKey];
992
+ templates.push(`
993
+ <span class="df-field-item ${orientationClassName(field.listItem.orientation ?? OrientationMap.horizontal)}">
994
+ <label>
995
+ <input type="checkbox" name="${fieldName}" value="${checkVal ? replaceXss(checkVal) : ""}" class="df-form-field df-checkbox" ${val.selected ? "checked" : ""} ${val.disabled ? "disabled" : ""} />
996
+ ${Render.valuesLabelValue(labelKey, val)}
997
+ </label>
998
+ </span>
999
+ `);
1000
+ });
1001
+ templates.push(`<i class="df-form-icon df-help-icon"></i></div></div> ${Render.getDescriptionTemplate(field)}<div class="df-help-message"></div>`);
1002
+ fieldContainerElement.innerHTML = templates.join("");
1003
+ }
1004
+ setValueItems(items) {
1005
+ const containerEle = this.rowElement.querySelector(".df-field-container");
1006
+ if (containerEle) {
1007
+ if (this.field.listItem) {
1008
+ this.field.listItem.list = items;
1009
+ } else {
1010
+ this.field.listItem = {
1011
+ list: items
1012
+ };
1013
+ }
1014
+ this.createField();
1015
+ if (!isBlank(this.field.$value)) {
1016
+ const currentValue = this.field.$value;
1017
+ this.field.$value = "";
1018
+ this.setValue(currentValue);
1019
+ }
1020
+ }
1021
+ }
1022
+ getValue() {
1023
+ const checkboxes = this.rowElement.querySelectorAll(this.getSelector());
1024
+ if (checkboxes.length > 1) {
1025
+ const checkValue = [];
1026
+ checkboxes.forEach((ele) => {
1027
+ const checkEle = ele;
1028
+ if (checkEle.checked) {
1029
+ checkValue.push(checkEle.value);
1030
+ }
1031
+ });
1032
+ return checkValue;
1033
+ } else {
1034
+ const checkElement = this.rowElement.querySelector(`[name="${this.field.$xssName}"]`);
1035
+ if (checkElement == null ? void 0 : checkElement.checked) {
1036
+ return checkElement.value ? checkElement.value : true;
1037
+ }
1038
+ return checkElement.value ? "" : false;
1039
+ }
1040
+ }
1041
+ setValue(value, changeCheckFlag) {
1042
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
1043
+ value = this.field.$value;
1044
+ }
1045
+ this.field.$value = value;
1046
+ if (value === true) {
1047
+ this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked = true;
1048
+ return;
1049
+ }
1050
+ if (value === false) {
1051
+ this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked = false;
1052
+ return;
1053
+ }
1054
+ let valueArr = [];
1055
+ if (isArray(value)) {
1056
+ valueArr = value;
1057
+ } else {
1058
+ valueArr.push(value);
1059
+ }
1060
+ const checkboxes = this.rowElement.querySelectorAll(this.getSelector());
1061
+ checkboxes.forEach((ele) => {
1062
+ ele.checked = false;
1063
+ });
1064
+ valueArr.forEach((val) => {
1065
+ const ele = this.rowElement.querySelector(`[name="${this.field.$xssName}"][value="${val}"]`);
1066
+ if (ele) ele.checked = true;
1067
+ });
1068
+ }
1069
+ reset() {
1070
+ var _a, _b;
1071
+ if (((_b = (_a = this.field.listItem) == null ? void 0 : _a.list) == null ? void 0 : _b.length) == 1 && this.defaultCheckValue.length == 1) {
1072
+ this.setValue(true, false);
1073
+ } else {
1074
+ this.setValue(this.defaultCheckValue, false);
1075
+ }
1076
+ this.setDisabled(false);
1077
+ resetRowElementStyleClass(this.rowElement);
1078
+ }
1079
+ getElement() {
1080
+ return this.rowElement.querySelectorAll(`[name="${this.field.$xssName}"]`);
1081
+ }
1082
+ focus() {
1083
+ const elements = this.getElement();
1084
+ if (elements && elements.length > 0) {
1085
+ this.getElement()[0].focus();
1086
+ }
1087
+ }
1088
+ valid() {
1089
+ const value = this.getValue();
1090
+ let validResult = true;
1091
+ if (this.field.required && isArray(value)) {
1092
+ if (value.length < 1) {
1093
+ validResult = { name: this.field.name, constraint: [] };
1094
+ validResult.constraint.push(RULES.REQUIRED);
1095
+ }
1096
+ }
1097
+ invalidMessage(this.field, this.rowElement, validResult);
1098
+ return validResult;
1099
+ }
1100
+ }
1101
+ class RadioRender extends Render {
1102
+ constructor(field, rowElement, daraForm) {
1103
+ var _a, _b, _c, _d, _e;
1104
+ super(daraForm, field, rowElement);
1105
+ this.defaultCheckValue = "";
1106
+ let initDefaultValue = [];
1107
+ if (!isUndefined(field.defaultValue)) {
1108
+ initDefaultValue = field.defaultValue;
1109
+ }
1110
+ const valueKey = RadioRender.valuesValueKey(field);
1111
+ let initDefaultValueFlag = false;
1112
+ (_b = (_a = this.field.listItem) == null ? void 0 : _a.list) == null ? void 0 : _b.forEach((item) => {
1113
+ let itemValue = item[valueKey];
1114
+ if (item.selected) {
1115
+ this.defaultCheckValue = itemValue;
1116
+ }
1117
+ if (initDefaultValue == itemValue) {
1118
+ initDefaultValueFlag = true;
1119
+ }
1120
+ });
1121
+ if (initDefaultValueFlag) {
1122
+ this.defaultCheckValue = initDefaultValue;
1123
+ } else if (!this.defaultCheckValue) {
1124
+ this.defaultCheckValue = ((_d = (_c = this.field.listItem) == null ? void 0 : _c.list) == null ? void 0 : _d.length) > 0 ? (_e = this.field.listItem) == null ? void 0 : _e.list[0][valueKey] : "";
1125
+ }
1126
+ this.mounted();
1127
+ this.setDefaultOption();
1128
+ this.setValue(this.defaultCheckValue, false);
1129
+ }
1130
+ mounted() {
1131
+ this.initEvent();
1132
+ }
1133
+ initEvent() {
1134
+ const checkboxes = this.rowElement.querySelectorAll(this.getSelector());
1135
+ checkboxes.forEach((ele) => {
1136
+ ele.addEventListener("change", (e) => {
1137
+ customChangeEventCall(this.field, e, this, this.getValue());
1138
+ this.valid();
1139
+ });
1140
+ });
1141
+ }
1142
+ getSelector() {
1143
+ return `input[type="radio"][name="${this.field.$xssName}"]`;
1144
+ }
1145
+ createField() {
1146
+ var _a, _b;
1147
+ const field = this.field;
1148
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
1149
+ const templates = [];
1150
+ const fieldName = field.$xssName;
1151
+ const labelKey = Render.valuesLabelKey(field);
1152
+ const valueKey = Render.valuesValueKey(field);
1153
+ templates.push(`<div class="df-field"><div class="df-field-group">`);
1154
+ (_b = (_a = field.listItem) == null ? void 0 : _a.list) == null ? void 0 : _b.forEach((val) => {
1155
+ const radioVal = val[valueKey];
1156
+ templates.push(
1157
+ `<span class="df-field-item ${orientationClassName(field.orientation ?? OrientationMap.horizontal)}">
1158
+ <label>
1159
+ <input type="radio" name="${fieldName}" value="${radioVal}" class="df-form-field df-radio" ${val.selected ? "checked" : ""} ${val.disabled ? "disabled" : ""}/>
1160
+ ${Render.valuesLabelValue(labelKey, val)}
1161
+ </label>
1162
+ </span>
1163
+ `
1164
+ );
1165
+ });
1166
+ templates.push(`<i class="df-form-icon df-help-icon"></i></div></div>
1167
+ ${Render.getDescriptionTemplate(field)}
1168
+ <div class="df-help-message"></div>
1169
+ `);
1170
+ fieldContainerElement.innerHTML = templates.join("");
1171
+ this.initEvent();
1172
+ }
1173
+ setValueItems(items) {
1174
+ const containerEle = this.rowElement.querySelector(".df-field-container");
1175
+ if (containerEle) {
1176
+ if (this.field.listItem) {
1177
+ this.field.listItem.list = items;
1178
+ } else {
1179
+ this.field.listItem = {
1180
+ list: items
1181
+ };
1182
+ }
1183
+ this.createField();
1184
+ if (!isBlank(this.field.$value)) {
1185
+ const currentValue = this.field.$value;
1186
+ this.field.$value = "";
1187
+ this.setValue(currentValue);
1188
+ }
1189
+ }
1190
+ }
1191
+ getValue() {
1192
+ var _a;
1193
+ return (_a = this.rowElement.querySelector(`[name="${this.field.$xssName}"]:checked`)) == null ? void 0 : _a.value;
1194
+ }
1195
+ setValue(value, changeCheckFlag) {
1196
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
1197
+ value = this.field.$value;
1198
+ }
1199
+ this.field.$value = value;
1200
+ if (value === true) {
1201
+ this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked = true;
1202
+ return;
1203
+ }
1204
+ if (value === false) {
1205
+ this.rowElement.querySelector(`[name="${this.field.$xssName}"]`).checked = false;
1206
+ return;
1207
+ }
1208
+ const elements = this.rowElement.querySelectorAll(this.getSelector());
1209
+ elements.forEach((ele) => {
1210
+ let radioEle = ele;
1211
+ if (radioEle.value == value) {
1212
+ radioEle.checked = true;
1213
+ } else {
1214
+ radioEle.checked = false;
1215
+ }
1216
+ });
1217
+ }
1218
+ reset() {
1219
+ this.setValue(this.defaultCheckValue, false);
1220
+ this.setDisabled(false);
1221
+ resetRowElementStyleClass(this.rowElement);
1222
+ }
1223
+ getElement() {
1224
+ return this.rowElement.querySelectorAll(this.getSelector());
1225
+ }
1226
+ focus() {
1227
+ const elements = this.getElement();
1228
+ if (elements && elements.length > 0) {
1229
+ this.getElement()[0].focus();
1230
+ }
1231
+ }
1232
+ valid() {
1233
+ const value = this.getValue();
1234
+ let validResult = true;
1235
+ if (this.field.required) {
1236
+ if (isBlank(value)) {
1237
+ validResult = { name: this.field.name, constraint: [] };
1238
+ validResult.constraint.push(RULES.REQUIRED);
1239
+ }
1240
+ }
1241
+ invalidMessage(this.field, this.rowElement, validResult);
1242
+ return validResult;
1243
+ }
1244
+ }
1245
+ class PasswordRender extends Render {
1246
+ constructor(field, rowElement, daraForm) {
1247
+ super(daraForm, field, rowElement);
1248
+ this.mounted();
1249
+ this.setDefaultOption();
1250
+ this.setDefaultInfo();
1251
+ }
1252
+ mounted() {
1253
+ inputEvent(this.field, this.element, this);
1254
+ }
1255
+ createField() {
1256
+ const field = this.field;
1257
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
1258
+ fieldContainerElement.innerHTML = `
1259
+ <div class="df-field">
1260
+ <input type="password" name="${field.$xssName}" class="df-form-field df-password df-help-icon" autocomplete="off" />
1261
+ </div>
1262
+ ${Render.getDescriptionTemplate(field)}
1263
+ <div class="df-help-message"></div>
1264
+ `;
1265
+ this.element = fieldContainerElement.querySelector(`[name="${field.$xssName}"]`);
1266
+ }
1267
+ getValue() {
1268
+ return this.element.value;
1269
+ }
1270
+ setValue(value, changeCheckFlag) {
1271
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
1272
+ this.element.value = this.field.$value;
1273
+ return;
1274
+ }
1275
+ this.field.$value = value;
1276
+ this.element.value = value;
1277
+ }
1278
+ reset() {
1279
+ this.setDefaultInfo();
1280
+ this.setDisabled(false);
1281
+ resetRowElementStyleClass(this.rowElement);
1282
+ }
1283
+ getElement() {
1284
+ return this.element;
1285
+ }
1286
+ valid() {
1287
+ const validResult = stringValidator(this.getValue(), this.field);
1288
+ invalidMessage(this.field, this.rowElement, validResult);
1289
+ return validResult;
1290
+ }
1291
+ }
1292
+ const fileValidator = (element, field, fileList) => {
1293
+ const result = { name: field.name, constraint: [] };
1294
+ if (field.required && fileList.length < 1) {
1295
+ result.constraint.push(RULES.REQUIRED);
1296
+ return result;
1297
+ }
1298
+ if (result.constraint.length > 0) {
1299
+ return result;
1300
+ }
1301
+ return true;
1302
+ };
1303
+ class FileRender extends Render {
1304
+ constructor(field, rowElement, daraForm) {
1305
+ var _a;
1306
+ super(daraForm, field, rowElement);
1307
+ this.removeIds = [];
1308
+ this.uploadFiles = {};
1309
+ this.fileList = [];
1310
+ this.fileSeq = 0;
1311
+ this.element = rowElement.querySelector(`[name="${field.$xssName}"]`);
1312
+ this.fileList = ((_a = field.listItem) == null ? void 0 : _a.list) || [];
1313
+ this.mounted();
1314
+ this.setDefaultOption();
1315
+ }
1316
+ mounted() {
1317
+ this.element.addEventListener("change", (e) => {
1318
+ var _a;
1319
+ const files = (_a = e.target) == null ? void 0 : _a.files;
1320
+ if (files) {
1321
+ let fileList = [];
1322
+ for (let item of files) {
1323
+ fileList.push(item);
1324
+ }
1325
+ this.addFiles(fileList);
1326
+ }
1327
+ customChangeEventCall(this.field, e, this, this.fileList);
1328
+ this.valid();
1329
+ });
1330
+ this.fileList.forEach((file) => {
1331
+ file.$seq = this.fileSeq += 1;
1332
+ });
1333
+ this.setFileList(this.fileList);
1334
+ }
1335
+ createField() {
1336
+ const field = this.field;
1337
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
1338
+ fieldContainerElement.innerHTML = `
1339
+ <div class="df-field">
1340
+ <span class="df-file-wrapper">
1341
+ <label class="df-file-label">
1342
+ <input type="file" name="${field.$xssName}" class="df-form-field df-file" multiple />
1343
+ ${Language$1.getMessage("fileButton")}
1344
+ </label>
1345
+ <i class="df-form-icon df-help-icon"></i>
1346
+ </span>
1347
+ </div>
1348
+ ${Render.getDescriptionTemplate(field)}
1349
+ <div class="df-file-list"></div>
1350
+ <div class="df-help-message"></div>
1351
+ `;
1352
+ this.element = fieldContainerElement.querySelector(`[name="${field.$xssName}"]`);
1353
+ }
1354
+ addFiles(files) {
1355
+ let addFlag = false;
1356
+ const newFiles = [];
1357
+ for (let item of files) {
1358
+ const fileCheckList = this.fileList.filter((fileItem) => fileItem.fileName == item.name && fileItem.fileSize == item.size && fileItem.lastModified == item.lastModified);
1359
+ if (fileCheckList.length > 0) continue;
1360
+ this.fileSeq += 1;
1361
+ this.uploadFiles[this.fileSeq] = item;
1362
+ let newFileInfo = {
1363
+ fileName: item.name,
1364
+ $seq: this.fileSeq,
1365
+ fileSize: item.size,
1366
+ lastModified: item.lastModified
1367
+ };
1368
+ newFiles.push(newFileInfo);
1369
+ addFlag = true;
1370
+ }
1371
+ if (addFlag) {
1372
+ this.setFileList(newFiles);
1373
+ this.fileList.push(...newFiles);
1374
+ }
1375
+ }
1376
+ setFileList(fileList, initFlag) {
1377
+ const fileListElement = this.rowElement.querySelector(".df-file-list");
1378
+ if (fileListElement) {
1379
+ if (initFlag === true) {
1380
+ fileListElement.innerHTML = "";
1381
+ }
1382
+ const fileTemplateHtml = [];
1383
+ fileList.forEach((file) => {
1384
+ fileTemplateHtml.push(`
1385
+ <div class="df-file-item" data-seq="${file.$seq}">
1386
+ ${file.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>
1387
+ <span class="df-file-name">${file.fileName}</span >
1388
+ </div>`);
1389
+ });
1390
+ fileListElement.insertAdjacentHTML("beforeend", fileTemplateHtml.join(""));
1391
+ fileList.forEach((item) => {
1392
+ this.removeFileEvent(item, fileListElement);
1393
+ this.downloadFileEvent(item, fileListElement);
1394
+ });
1395
+ }
1396
+ }
1397
+ /**
1398
+ * 파일 다운로드 이벤트 처리.
1399
+ *
1400
+ * @param item
1401
+ * @param fileListElement
1402
+ */
1403
+ downloadFileEvent(item, fileListElement) {
1404
+ const ele = fileListElement.querySelector(`[data-seq="${item.$seq}"] .df-file-download`);
1405
+ if (ele) {
1406
+ ele.addEventListener("click", (evt) => {
1407
+ const fileItemElement = evt.target.closest(".df-file-item");
1408
+ if (fileItemElement) {
1409
+ const attrSeq = fileItemElement.getAttribute("data-seq");
1410
+ if (attrSeq) {
1411
+ const seq = parseInt(attrSeq, 10);
1412
+ const idx = this.fileList.findIndex((v) => v.$seq === seq);
1413
+ const item2 = this.fileList[idx];
1414
+ if (item2["url"]) {
1415
+ location.href = item2["url"];
1416
+ return;
1417
+ }
1418
+ if (this.field.fileDownload) {
1419
+ this.field.fileDownload.call(null, { file: item2, field: this.field });
1420
+ return;
1421
+ }
1422
+ }
1423
+ }
1424
+ });
1425
+ }
1426
+ }
1427
+ /**
1428
+ * 파일 삭제 처리.
1429
+ *
1430
+ * @param item
1431
+ * @param fileListElement
1432
+ */
1433
+ removeFileEvent(item, fileListElement) {
1434
+ const ele = fileListElement.querySelector(`[data-seq="${item.$seq}"] .df-file-remove`);
1435
+ if (ele) {
1436
+ ele.addEventListener("click", (evt) => {
1437
+ const fileItemElement = evt.target.closest(".df-file-item");
1438
+ if (fileItemElement) {
1439
+ const attrSeq = fileItemElement.getAttribute("data-seq");
1440
+ if (attrSeq) {
1441
+ const seq = parseInt(attrSeq, 10);
1442
+ const removeIdx = this.fileList.findIndex((v) => v.$seq === seq);
1443
+ const removeItem = this.fileList[removeIdx];
1444
+ this.fileList.splice(removeIdx, 1);
1445
+ delete this.uploadFiles[seq];
1446
+ fileItemElement.remove();
1447
+ if (removeItem.fileId) {
1448
+ this.removeIds.push(removeItem.fileId);
1449
+ }
1450
+ }
1451
+ }
1452
+ this.valid();
1453
+ });
1454
+ }
1455
+ }
1456
+ getValue() {
1457
+ return {
1458
+ uploadFile: Object.values(this.uploadFiles),
1459
+ removeIds: this.removeIds
1460
+ };
1461
+ }
1462
+ setValueItems(value) {
1463
+ this.fileList = [];
1464
+ this.uploadFiles = [];
1465
+ this.removeIds = [];
1466
+ for (let file of value) {
1467
+ file.$seq = this.fileSeq += 1;
1468
+ this.fileList.push(file);
1469
+ }
1470
+ this.setFileList(this.fileList, true);
1471
+ }
1472
+ setValue(value) {
1473
+ if (isArray$1(value)) {
1474
+ this.setValueItems(value);
1475
+ }
1476
+ this.element.value = "";
1477
+ }
1478
+ reset() {
1479
+ this.setValue("");
1480
+ this.setValueItems([]);
1481
+ resetRowElementStyleClass(this.rowElement);
1482
+ }
1483
+ getElement() {
1484
+ return this.element;
1485
+ }
1486
+ valid() {
1487
+ const validResult = fileValidator(this.element, this.field, this.fileList);
1488
+ invalidMessage(this.field, this.rowElement, validResult);
1489
+ return validResult;
1490
+ }
1491
+ }
1492
+ class CustomRender extends Render {
1493
+ constructor(field, rowElement, daraForm) {
1494
+ super(daraForm, field, rowElement);
1495
+ if (field.renderer) {
1496
+ this.customFunction = field.renderer;
1497
+ this.mounted();
1498
+ this.setDefaultOption();
1499
+ this.setDefaultInfo();
1500
+ } else {
1501
+ this.customFunction = {};
1502
+ }
1503
+ }
1504
+ mounted() {
1505
+ if (this.customFunction.mounted) {
1506
+ this.customFunction.mounted.call(this, this.field, this.rowElement);
1507
+ }
1508
+ }
1509
+ static isDataRender() {
1510
+ return false;
1511
+ }
1512
+ createField() {
1513
+ const field = this.field;
1514
+ const fieldTemplate = isEmpty(field.template) ? "" : isString(field.template) ? field.template : field.template();
1515
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
1516
+ fieldContainerElement.innerHTML = ` <div class="df-field">
1517
+ ${fieldTemplate}
1518
+ </div>
1519
+ ${Render.getDescriptionTemplate(field)}
1520
+ <div class="df-help-message"></div>`;
1521
+ }
1522
+ getValue() {
1523
+ if (this.customFunction.getValue) {
1524
+ return this.customFunction.getValue.call(this, this.field, this.rowElement);
1525
+ }
1526
+ return "";
1527
+ }
1528
+ setValue(value, changeCheckFlag) {
1529
+ if (this.customFunction.setValue) {
1530
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
1531
+ value = this.field.$value;
1532
+ }
1533
+ this.customFunction.setValue.call(this, value, this.field, this.rowElement);
1534
+ }
1535
+ this.field.$value = value;
1536
+ }
1537
+ reset() {
1538
+ this.setDefaultInfo();
1539
+ resetRowElementStyleClass(this.rowElement);
1540
+ }
1541
+ getElement() {
1542
+ if (this.customFunction.getElement) {
1543
+ return this.customFunction.getElement.call(this, this.field, this.rowElement);
1544
+ }
1545
+ return null;
1546
+ }
1547
+ valid() {
1548
+ if (this.customFunction.valid) {
1549
+ const validResult2 = this.customFunction.valid.call(this, this.field, this.rowElement);
1550
+ invalidMessage(this.field, this.rowElement, validResult2);
1551
+ return;
1552
+ }
1553
+ const validResult = stringValidator(this.getValue(), this.field);
1554
+ invalidMessage(this.field, this.rowElement, validResult);
1555
+ return validResult;
1556
+ }
1557
+ /**
1558
+ * focus
1559
+ */
1560
+ focus() {
1561
+ if (this.customFunction.focus) {
1562
+ this.customFunction.focus.call(this, this.field, this.rowElement);
1563
+ }
1564
+ }
1565
+ }
1566
+ class GroupRender extends Render {
1567
+ constructor(field, rowElement, daraForm) {
1568
+ super(daraForm, field, rowElement);
1569
+ }
1570
+ mounted() {
1571
+ }
1572
+ static isDataRender() {
1573
+ return false;
1574
+ }
1575
+ createField() {
1576
+ return "";
1577
+ }
1578
+ getValue() {
1579
+ return null;
1580
+ }
1581
+ setValue(value) {
1582
+ }
1583
+ reset() {
1584
+ }
1585
+ getElement() {
1586
+ return this.rowElement;
1587
+ }
1588
+ valid() {
1589
+ return true;
1590
+ }
1591
+ addChildField(element) {
1592
+ let addContainer = this.rowElement.querySelector(".df-field-container");
1593
+ if (addContainer) {
1594
+ addContainer.append(element);
1595
+ } else {
1596
+ this.rowElement.append(element);
1597
+ }
1598
+ }
1599
+ focus() {
1600
+ }
1601
+ }
1602
+ class HiddenRender extends Render {
1603
+ constructor(field, rowElement, daraForm) {
1604
+ super(daraForm, field, rowElement);
1605
+ this.field.$value = field.defaultValue;
1606
+ }
1607
+ mounted() {
1608
+ }
1609
+ createField() {
1610
+ return ``;
1611
+ }
1612
+ getValue() {
1613
+ return this.field.$value;
1614
+ }
1615
+ setValue(value) {
1616
+ this.field.$value = value;
1617
+ }
1618
+ reset() {
1619
+ this.setValue(this.field.defaultValue);
1620
+ }
1621
+ getElement() {
1622
+ return;
1623
+ }
1624
+ valid() {
1625
+ return true;
1626
+ }
1627
+ }
1628
+ class ButtonRender extends Render {
1629
+ constructor(field, rowElement, daraForm) {
1630
+ super(daraForm, field, rowElement);
1631
+ this.mounted();
1632
+ this.setDefaultOption();
1633
+ }
1634
+ mounted() {
1635
+ var _a;
1636
+ (_a = this.rowElement.querySelector(`#${this.field.$key}`)) == null ? void 0 : _a.addEventListener("click", (evt) => {
1637
+ if (this.field.onClick) {
1638
+ this.field.onClick.call(null, this.field);
1639
+ }
1640
+ });
1641
+ }
1642
+ static isDataRender() {
1643
+ return false;
1644
+ }
1645
+ createField() {
1646
+ const field = this.field;
1647
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
1648
+ fieldContainerElement.innerHTML = `
1649
+ <button type="button" id="${field.$key}" class="df-btn">${field.label}</button> ${Render.getDescriptionTemplate(field)}
1650
+ `;
1651
+ }
1652
+ getValue() {
1653
+ return "";
1654
+ }
1655
+ setValue(value) {
1656
+ }
1657
+ reset() {
1658
+ this.setDisabled(false);
1659
+ }
1660
+ getElement() {
1661
+ return null;
1662
+ }
1663
+ valid() {
1664
+ return true;
1665
+ }
1666
+ }
1667
+ class RangeRender extends Render {
1668
+ constructor(field, rowElement, daraForm) {
1669
+ super(daraForm, field, rowElement);
1670
+ this.rangeNumElement = rowElement.querySelector(".df-range-num");
1671
+ this.mounted();
1672
+ this.setDefaultOption();
1673
+ this.setDefaultInfo();
1674
+ }
1675
+ mounted() {
1676
+ this.element.addEventListener("input", (e) => {
1677
+ this.rangeNumElement.innerHTML = e.target.value;
1678
+ this.element.setAttribute("title", e.target.value);
1679
+ customChangeEventCall(this.field, e, this, this.getValue());
1680
+ this.valid();
1681
+ });
1682
+ }
1683
+ createField() {
1684
+ const field = this.field;
1685
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
1686
+ fieldContainerElement.innerHTML = `
1687
+ <div class="df-field">
1688
+ <span class="df-range-num">${field.defaultValue ? field.defaultValue : 0}</span>
1689
+ <input type="range" name="${field.$xssName}" class="df-form-field df-range df-help-icon" min="${field.rule.minimum}" max="${field.rule.maximum}"/>
1690
+ </div>
1691
+ ${Render.getDescriptionTemplate(field)}
1692
+ <div class="df-help-message"></div>
1693
+ `;
1694
+ this.element = fieldContainerElement.querySelector(`[name="${field.$xssName}"]`);
1695
+ }
1696
+ getValue() {
1697
+ return this.element.value;
1698
+ }
1699
+ setValue(value, changeCheckFlag) {
1700
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
1701
+ this.element.value = this.field.$value;
1702
+ return;
1703
+ }
1704
+ this.field.$value = value;
1705
+ this.element.value = value;
1706
+ }
1707
+ reset() {
1708
+ this.setDefaultInfo();
1709
+ this.setDisabled(false);
1710
+ resetRowElementStyleClass(this.rowElement);
1711
+ }
1712
+ getElement() {
1713
+ return this.element;
1714
+ }
1715
+ valid() {
1716
+ const validResult = numberValidator(this.getValue(), this.field);
1717
+ invalidMessage(this.field, this.rowElement, validResult);
1718
+ return validResult;
1719
+ }
1720
+ }
1721
+ let localeMessage$1 = {
1722
+ year: "Year",
1723
+ month: "Month",
1724
+ day: "Day",
1725
+ am: "AM",
1726
+ pm: "PM",
1727
+ today: "Today",
1728
+ ok: "Ok",
1729
+ months: {
1730
+ full: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
1731
+ abbr: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
1732
+ },
1733
+ weeks: {
1734
+ full: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
1735
+ abbr: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
1736
+ }
1737
+ };
1738
+ let Language$2 = class Language {
1739
+ constructor() {
1740
+ this.lang = localeMessage$1;
1741
+ }
1742
+ setDefaultMessage(lang) {
1743
+ localeMessage$1 = Object.assign(localeMessage$1, lang);
1744
+ }
1745
+ /**
1746
+ * 다국어 메시지 등록
1747
+ *
1748
+ * @public
1749
+ * @param {?Message} [lang] 둥록할 메시지
1750
+ */
1751
+ set(lang) {
1752
+ this.lang = Object.assign({}, localeMessage$1, lang);
1753
+ }
1754
+ /**
1755
+ * 메시지 얻기
1756
+ *
1757
+ * @public
1758
+ * @param {string} messageKey 메시지 키
1759
+ * @returns {*}
1760
+ */
1761
+ getMessage(messageKey) {
1762
+ return this.lang[messageKey];
1763
+ }
1764
+ getMonthsMessage(idx, mode = "abbr") {
1765
+ return this.lang.months[mode][idx] || "";
1766
+ }
1767
+ getWeeksMessage(idx, mode = "abbr") {
1768
+ return this.lang.weeks[mode][idx] || "";
1769
+ }
1770
+ getMonthsIdx(val, mode = "abbr") {
1771
+ return mode == "full" ? this.lang.months.full.indexOf(val) : this.lang.months.abbr.indexOf(val);
1772
+ }
1773
+ getWeeksIdx(val, mode = "abbr") {
1774
+ return mode == "full" ? this.lang.weeks.full.indexOf(val) : this.lang.weeks.abbr.indexOf(val);
1775
+ }
1776
+ };
1777
+ const Lanauage = new Language$2();
1778
+ 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"];
1779
+ let MAX_CHAR_LENGTH = 0;
1780
+ let DEFAULT_FORMAT = {
1781
+ year: "YYYY",
1782
+ month: "YYYY-MM",
1783
+ date: "YYYY-MM-DD",
1784
+ time: "HH:mm",
1785
+ datetime: "YYYY-MM-DD HH:mm"
1786
+ };
1787
+ const DAY_STYLE_CLASS = ["ddtp-sun", "ddtp-mon", "ddtp-tue", "ddtp-wed", "ddtp-thu", "ddtp-fri", "ddtp-sat"];
1788
+ var DateViewMode = /* @__PURE__ */ ((DateViewMode2) => {
1789
+ DateViewMode2["year"] = "year";
1790
+ DateViewMode2["month"] = "month";
1791
+ DateViewMode2["date"] = "date";
1792
+ DateViewMode2["datetime"] = "datetime";
1793
+ DateViewMode2["time"] = "time";
1794
+ return DateViewMode2;
1795
+ })(DateViewMode || {});
1796
+ EXPRESSIONS_FORMAT.forEach((item) => {
1797
+ MAX_CHAR_LENGTH = Math.max(item.length, MAX_CHAR_LENGTH);
1798
+ });
1799
+ const format = (date, format2) => {
1800
+ format2 = format2 || "YYYY-MM-DD";
1801
+ const len = format2.length;
1802
+ let result = [];
1803
+ for (let i = 0; i < len; ) {
1804
+ let minLen = Math.min(MAX_CHAR_LENGTH, len - i);
1805
+ let j = minLen;
1806
+ for (; j > 0; j--) {
1807
+ const v = format2.substring(i, i + j);
1808
+ if (EXPRESSIONS_FORMAT.includes(v)) {
1809
+ try {
1810
+ result.push(expressionsFunction$1[v](date));
1811
+ } catch (e) {
1812
+ console.log(EXPRESSIONS_FORMAT.includes(v), v, e);
1813
+ }
1814
+ break;
1815
+ }
1816
+ }
1817
+ if (j < 1) {
1818
+ result.push(format2.substring(i, i + 1));
1819
+ i += 1;
1820
+ } else {
1821
+ i += j;
1822
+ }
1823
+ }
1824
+ return result.join("");
1825
+ };
1826
+ const expressionsFunction$1 = {
1827
+ YY: (date) => {
1828
+ return String(date.getFullYear()).slice(-2);
1829
+ },
1830
+ YYYY: (date) => {
1831
+ return String(date.getFullYear());
1832
+ },
1833
+ M: (date) => {
1834
+ return String(date.getMonth() + 1);
1835
+ },
1836
+ MM: (date) => {
1837
+ return leftPad(date.getMonth() + 1, 2);
1838
+ },
1839
+ MMM: (date) => {
1840
+ return Lanauage.getMonthsMessage(date.getMonth());
1841
+ },
1842
+ MMMM: (date) => {
1843
+ return Lanauage.getMonthsMessage(date.getMonth(), "full");
1844
+ },
1845
+ D: (date) => {
1846
+ return String(date.getDate());
1847
+ },
1848
+ DD: (date) => {
1849
+ return leftPad(date.getDate(), 2);
1850
+ },
1851
+ d: (date) => {
1852
+ return String(date.getDate());
1853
+ },
1854
+ dd: (date) => {
1855
+ return leftPad(date.getDate(), 2);
1856
+ },
1857
+ ddd: (date) => {
1858
+ return Lanauage.getWeeksMessage(date.getDay());
1859
+ },
1860
+ dddd: (date) => {
1861
+ return Lanauage.getWeeksMessage(date.getDay(), "full");
1862
+ },
1863
+ H: (date) => {
1864
+ return String(date.getHours());
1865
+ },
1866
+ HH: (date) => {
1867
+ return leftPad(date.getHours(), 2);
1868
+ },
1869
+ h: (date) => {
1870
+ return getH(date);
1871
+ },
1872
+ hh: (date) => {
1873
+ return leftPad(getH(date), 2);
1874
+ },
1875
+ a: (date) => {
1876
+ return String(date.getFullYear()).slice(-2);
1877
+ },
1878
+ A: (date) => {
1879
+ return getMeridiem(date);
1880
+ },
1881
+ m: (date) => {
1882
+ return String(date.getMinutes());
1883
+ },
1884
+ mm: (date) => {
1885
+ return leftPad(date.getMinutes(), 2);
1886
+ },
1887
+ s: (date) => {
1888
+ return String(date.getSeconds());
1889
+ },
1890
+ ss: (date) => {
1891
+ return leftPad(date.getSeconds(), 2);
1892
+ },
1893
+ SSS: (date) => {
1894
+ return leftPad(date.getMilliseconds(), 3);
1895
+ }
1896
+ };
1897
+ function getH(date) {
1898
+ let hour = date.getHours();
1899
+ if (hour > 12) {
1900
+ hour -= 12;
1901
+ } else if (hour < 1) {
1902
+ hour = 12;
1903
+ }
1904
+ return hour;
1905
+ }
1906
+ function getMeridiem(date, isUpper, isShort) {
1907
+ const hour = date.getHours();
1908
+ let m = hour < 12 ? "am" : "pm";
1909
+ m = Lanauage.getMessage(m);
1910
+ m = m.toUpperCase();
1911
+ return m;
1912
+ }
1913
+ const parser = (dateStr, format2) => {
1914
+ if (dateStr.length > 1e3) {
1915
+ return null;
1916
+ }
1917
+ format2 = format2 || DEFAULT_FORMAT.date;
1918
+ const dateInfo = {
1919
+ year: (/* @__PURE__ */ new Date()).getFullYear(),
1920
+ month: 0,
1921
+ day: 1,
1922
+ hour: 0,
1923
+ minute: 0,
1924
+ second: 0,
1925
+ millisecond: 0,
1926
+ isPm: false,
1927
+ isH: false,
1928
+ charIdx: 0
1929
+ };
1930
+ const len = format2.length;
1931
+ let startIdx = 0;
1932
+ for (let i = 0; i < len; ) {
1933
+ let minLen = Math.min(MAX_CHAR_LENGTH, len - i);
1934
+ let j = minLen;
1935
+ for (; j > 0; j--) {
1936
+ const v = format2.substring(i, i + j);
1937
+ if (EXPRESSIONS_FORMAT.includes(v)) {
1938
+ const expInfo = expressionsFunction[v];
1939
+ const val = matchFind(dateStr.substring(startIdx), expInfo[0]);
1940
+ expInfo[1](dateInfo, val);
1941
+ startIdx += val.length;
1942
+ break;
1943
+ }
1944
+ }
1945
+ if (j < 1) {
1946
+ i += 1;
1947
+ startIdx += 1;
1948
+ } else {
1949
+ i += j;
1950
+ }
1951
+ }
1952
+ if (dateInfo.hour != null && !dateInfo.isH) {
1953
+ if (dateInfo.isPm && +dateInfo.hour !== 12) {
1954
+ dateInfo.hour = +dateInfo.hour + 12;
1955
+ } else if (!dateInfo.isPm && +dateInfo.hour === 12) {
1956
+ dateInfo.hour = 0;
1957
+ }
1958
+ }
1959
+ let date;
1960
+ date = new Date(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute, dateInfo.second, dateInfo.millisecond);
1961
+ return date;
1962
+ };
1963
+ const matchFind = (val, regexp2) => {
1964
+ const match = regexp2.exec(val);
1965
+ return match == null ? "" : match[0];
1966
+ };
1967
+ const digitsCheck = {
1968
+ twoOptional: /\d\d?/,
1969
+ two: /\d\d/,
1970
+ three: /\d{3}/,
1971
+ four: /\d{4}/
1972
+ };
1973
+ const word = /[^\s]+/;
1974
+ const expressionsFunction = {
1975
+ YY: [
1976
+ digitsCheck["two"],
1977
+ (dateInfo, val) => {
1978
+ dateInfo.year = +(("" + (/* @__PURE__ */ new Date()).getFullYear()).substring(0, 2) + val);
1979
+ return dateInfo;
1980
+ }
1981
+ ],
1982
+ YYYY: [
1983
+ digitsCheck["four"],
1984
+ (dateInfo, val) => {
1985
+ dateInfo.year = +val;
1986
+ return dateInfo;
1987
+ }
1988
+ ],
1989
+ M: [
1990
+ digitsCheck["twoOptional"],
1991
+ (dateInfo, val) => {
1992
+ dateInfo.month = +val - 1;
1993
+ return dateInfo;
1994
+ }
1995
+ ],
1996
+ MM: [
1997
+ digitsCheck["two"],
1998
+ (dateInfo, val) => {
1999
+ dateInfo.month = +val - 1;
2000
+ return dateInfo;
2001
+ }
2002
+ ],
2003
+ MMM: [
2004
+ word,
2005
+ (dateInfo, val) => {
2006
+ dateInfo.month = Lanauage.getMonthsIdx(val, "abbr");
2007
+ return dateInfo;
2008
+ }
2009
+ ],
2010
+ MMMM: [
2011
+ word,
2012
+ (dateInfo, val) => {
2013
+ dateInfo.month = Lanauage.getMonthsIdx(val, "full");
2014
+ return dateInfo;
2015
+ }
2016
+ ],
2017
+ D: [
2018
+ digitsCheck["twoOptional"],
2019
+ (dateInfo, val) => {
2020
+ dateInfo.day = +val;
2021
+ return dateInfo;
2022
+ }
2023
+ ],
2024
+ DD: [
2025
+ digitsCheck["two"],
2026
+ (dateInfo, val) => {
2027
+ dateInfo.day = +val;
2028
+ return dateInfo;
2029
+ }
2030
+ ],
2031
+ d: [
2032
+ digitsCheck["twoOptional"],
2033
+ (dateInfo, val) => {
2034
+ dateInfo.day = +val;
2035
+ return dateInfo;
2036
+ }
2037
+ ],
2038
+ dd: [
2039
+ digitsCheck["two"],
2040
+ (dateInfo, val) => {
2041
+ dateInfo.day = +val;
2042
+ return dateInfo;
2043
+ }
2044
+ ],
2045
+ ddd: [
2046
+ word,
2047
+ (dateInfo, val) => {
2048
+ return dateInfo;
2049
+ }
2050
+ ],
2051
+ dddd: [
2052
+ word,
2053
+ (dateInfo, val) => {
2054
+ return dateInfo;
2055
+ }
2056
+ ],
2057
+ H: [
2058
+ digitsCheck["twoOptional"],
2059
+ (dateInfo, val) => {
2060
+ dateInfo.hour = +val;
2061
+ dateInfo.isH = true;
2062
+ return dateInfo;
2063
+ }
2064
+ ],
2065
+ HH: [
2066
+ digitsCheck["two"],
2067
+ (dateInfo, val) => {
2068
+ dateInfo.hour = +val;
2069
+ dateInfo.isH = true;
2070
+ return dateInfo;
2071
+ }
2072
+ ],
2073
+ h: [
2074
+ digitsCheck["twoOptional"],
2075
+ (dateInfo, val) => {
2076
+ dateInfo.hour = +val;
2077
+ return dateInfo;
2078
+ }
2079
+ ],
2080
+ hh: [
2081
+ digitsCheck["two"],
2082
+ (dateInfo, val) => {
2083
+ dateInfo.hour = +val;
2084
+ return dateInfo;
2085
+ }
2086
+ ],
2087
+ a: [
2088
+ word,
2089
+ (dateInfo, val) => {
2090
+ if (Lanauage.getMessage("am") != val.toLowerCase()) {
2091
+ dateInfo.isPm = true;
2092
+ }
2093
+ return dateInfo;
2094
+ }
2095
+ ],
2096
+ A: [
2097
+ word,
2098
+ (dateInfo, val) => {
2099
+ if (Lanauage.getMessage("am") != val.toLowerCase()) {
2100
+ dateInfo.isPm = true;
2101
+ }
2102
+ return dateInfo;
2103
+ }
2104
+ ],
2105
+ m: [
2106
+ digitsCheck["twoOptional"],
2107
+ (dateInfo, val) => {
2108
+ dateInfo.minute = +val;
2109
+ return dateInfo;
2110
+ }
2111
+ ],
2112
+ mm: [
2113
+ digitsCheck["two"],
2114
+ (dateInfo, val) => {
2115
+ dateInfo.minute = +val;
2116
+ return dateInfo;
2117
+ }
2118
+ ],
2119
+ s: [
2120
+ digitsCheck["twoOptional"],
2121
+ (dateInfo, val) => {
2122
+ dateInfo.second = +val;
2123
+ return dateInfo;
2124
+ }
2125
+ ],
2126
+ ss: [
2127
+ digitsCheck["two"],
2128
+ (dateInfo, val) => {
2129
+ dateInfo.second = +val;
2130
+ return dateInfo;
2131
+ }
2132
+ ],
2133
+ SSS: [
2134
+ digitsCheck["three"],
2135
+ (dateInfo, val) => {
2136
+ dateInfo.millisecond = +val;
2137
+ return dateInfo;
2138
+ }
2139
+ ]
2140
+ };
2141
+ function closestElement(el, checkElement) {
2142
+ let currentEl = el;
2143
+ while (currentEl) {
2144
+ if (currentEl == checkElement) {
2145
+ return true;
2146
+ }
2147
+ currentEl = currentEl.parentElement;
2148
+ }
2149
+ return false;
2150
+ }
2151
+ class DaraDate {
2152
+ constructor(dt) {
2153
+ this.date = dt;
2154
+ }
2155
+ setYear(num) {
2156
+ this.date.setFullYear(num);
2157
+ return this;
2158
+ }
2159
+ addYear(num) {
2160
+ this.date.setFullYear(this.date.getFullYear() + num);
2161
+ return this;
2162
+ }
2163
+ addMonth(num) {
2164
+ this.date.setMonth(this.date.getMonth() + num);
2165
+ return this;
2166
+ }
2167
+ setMonth(num) {
2168
+ this.date.setMonth(num);
2169
+ return this;
2170
+ }
2171
+ setDate(num) {
2172
+ this.date.setDate(num);
2173
+ return this;
2174
+ }
2175
+ addDate(num) {
2176
+ this.date.setDate(this.date.getDate() + num);
2177
+ return this;
2178
+ }
2179
+ addWeek(num) {
2180
+ this.date.setDate(this.date.getDate() + num * 7);
2181
+ return this;
2182
+ }
2183
+ addHours(num) {
2184
+ this.date.setHours(this.date.getHours() + num);
2185
+ return this;
2186
+ }
2187
+ setHour(num) {
2188
+ this.date.setHours(num);
2189
+ return this;
2190
+ }
2191
+ addMinutes(num) {
2192
+ this.date.setMinutes(this.date.getMinutes() + num);
2193
+ return this;
2194
+ }
2195
+ setMinutes(num) {
2196
+ this.date.setMinutes(num);
2197
+ return this;
2198
+ }
2199
+ addSeconds(num) {
2200
+ this.date.setSeconds(this.date.getSeconds() + num);
2201
+ return this;
2202
+ }
2203
+ addMilliseconds(num) {
2204
+ this.date.setMilliseconds(this.date.getMilliseconds() + num);
2205
+ return this;
2206
+ }
2207
+ compare(date) {
2208
+ if (this.date.valueOf() < date.valueOf()) {
2209
+ return -1;
2210
+ } else if (this.date.valueOf() > date.valueOf()) {
2211
+ return 1;
2212
+ }
2213
+ return 0;
2214
+ }
2215
+ getYear() {
2216
+ return this.date.getFullYear();
2217
+ }
2218
+ getMonth() {
2219
+ return this.date.getMonth() + 1;
2220
+ }
2221
+ getDate() {
2222
+ return this.date.getDate();
2223
+ }
2224
+ getDay() {
2225
+ return this.date.getDay();
2226
+ }
2227
+ getTime() {
2228
+ return this.date.getTime();
2229
+ }
2230
+ format(format$1) {
2231
+ return format(this.date, format$1);
2232
+ }
2233
+ clone() {
2234
+ return new DaraDate(new Date(this.date.valueOf()));
2235
+ }
2236
+ }
2237
+ let DEFAULT_OPTIONS$1 = {
2238
+ inline: false,
2239
+ // layer or innerhtml
2240
+ weekStartDay: 0,
2241
+ initialDate: "",
2242
+ autoClose: true,
2243
+ isRTL: false,
2244
+ mode: DateViewMode.date,
2245
+ enableTodayBtn: false,
2246
+ showMonthAfterYear: false,
2247
+ isPositionFixed: false,
2248
+ format: "",
2249
+ zIndex: 1e3,
2250
+ minDate: "",
2251
+ maxDate: "",
2252
+ beforeDrawDate: (dt) => {
2253
+ return {
2254
+ check: false,
2255
+ style: "",
2256
+ tooltip: ""
2257
+ };
2258
+ }
2259
+ };
2260
+ function hiddenElement() {
2261
+ var _a;
2262
+ if (document.getElementById("hiddenDaraDatetimeElement") == null) {
2263
+ (_a = document.querySelector("body")) == null ? void 0 : _a.insertAdjacentHTML("beforeend", `<div id="hiddenDaraDatetimeElement" class="daracl-datetime-hidden"></div>`);
2264
+ }
2265
+ return document.getElementById("hiddenDaraDatetimeElement");
2266
+ }
2267
+ let daraDatetimeIdx = 0;
2268
+ const _DateTimePicker = class _DateTimePicker2 {
2269
+ constructor(selector, options, message2) {
2270
+ var _a;
2271
+ this.isInput = false;
2272
+ this.isVisible = false;
2273
+ this.minYear = -1;
2274
+ this.maxYear = -1;
2275
+ this.minMonth = -1;
2276
+ this.maxMonth = -1;
2277
+ this.dayOrder = [0, 1, 2, 3, 4, 5, 6];
2278
+ this._documentClickEvent = (e) => {
2279
+ if (this.isVisible && e.target != this.targetElement && !closestElement(e.target, this.datetimeElement)) {
2280
+ this.hide();
2281
+ }
2282
+ };
2283
+ this.options = Object.assign({}, DEFAULT_OPTIONS$1, options);
2284
+ daraDatetimeIdx += 1;
2285
+ let selectorElement;
2286
+ if (typeof selector === "string") {
2287
+ selectorElement = document.querySelector(selector);
2288
+ } else {
2289
+ selectorElement = selector;
2290
+ }
2291
+ if (!selectorElement) {
2292
+ throw new Error(`${selector} datetimepicker element not found`);
2293
+ }
2294
+ this._viewMode = Object.keys(DateViewMode).includes(this.options.mode) ? this.options.mode : DateViewMode.date;
2295
+ this.initMode = this._viewMode;
2296
+ Lanauage.set(message2);
2297
+ if (this.initMode == DateViewMode.year) {
2298
+ this.dateFormat = this.options.format || DEFAULT_FORMAT.year;
2299
+ } else if (this.initMode == DateViewMode.month) {
2300
+ this.dateFormat = this.options.format || DEFAULT_FORMAT.month;
2301
+ } else if (this.initMode == DateViewMode.time) {
2302
+ this.dateFormat = this.options.format || DEFAULT_FORMAT.time;
2303
+ } else if (this.initMode == DateViewMode.datetime) {
2304
+ this.dateFormat = this.options.format || DEFAULT_FORMAT.datetime;
2305
+ } else {
2306
+ this.dateFormat = this.options.format || DEFAULT_FORMAT.date;
2307
+ }
2308
+ let viewDate;
2309
+ if (this.options.initialDate) {
2310
+ if (typeof this.options.initialDate === "string") {
2311
+ viewDate = new DaraDate(parser(this.options.initialDate, this.dateFormat) || /* @__PURE__ */ new Date());
2312
+ } else {
2313
+ viewDate = new DaraDate(this.options.initialDate);
2314
+ }
2315
+ } else {
2316
+ viewDate = new DaraDate(/* @__PURE__ */ new Date());
2317
+ this.options.initialDate = viewDate.format(this.dateFormat);
2318
+ }
2319
+ this.setWeekDays();
2320
+ this.todayDate = viewDate.format(DEFAULT_FORMAT.date);
2321
+ this.currentDate = viewDate;
2322
+ this.targetElement = selectorElement;
2323
+ this.minDate = this._minDate();
2324
+ this.maxDate = this._maxDate();
2325
+ if (this.options.inline) {
2326
+ this.datetimeElement = selectorElement;
2327
+ this.datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} embed`;
2328
+ } else {
2329
+ this.isInput = true;
2330
+ this.targetElement.setAttribute("value", viewDate.format(this.dateFormat));
2331
+ const datetimeElement = document.createElement("div");
2332
+ datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} layer`;
2333
+ datetimeElement.setAttribute("style", `z-index:${this.options.zIndex};`);
2334
+ (_a = hiddenElement()) == null ? void 0 : _a.appendChild(datetimeElement);
2335
+ this.datetimeElement = datetimeElement;
2336
+ this.initTargetEvent();
2337
+ }
2338
+ this.createDatetimeTemplate();
2339
+ if (this.isTimeMode()) {
2340
+ this.hourInputEle = this.datetimeElement.querySelector(".ddtp-hour");
2341
+ this.minuteInputEle = this.datetimeElement.querySelector(".ddtp-minute");
2342
+ } else {
2343
+ this.hourInputEle = {};
2344
+ this.minuteInputEle = {};
2345
+ }
2346
+ this.changeViewMode(this._viewMode);
2347
+ this.initHeaderEvent();
2348
+ this.initDateEvent();
2349
+ this.initTimeEvent();
2350
+ }
2351
+ setWeekDays() {
2352
+ let weekStartDay = this.options.weekStartDay;
2353
+ if (weekStartDay == 0) return;
2354
+ if (weekStartDay < 0 || weekStartDay > 6) {
2355
+ weekStartDay = 0;
2356
+ }
2357
+ for (let i = 0; i < 7; i++) {
2358
+ let day = weekStartDay + i;
2359
+ this.dayOrder[i] = day < 7 ? day : day - 7;
2360
+ }
2361
+ }
2362
+ static create(selector, options, message2) {
2363
+ return new _DateTimePicker2(selector, options, message2);
2364
+ }
2365
+ /**
2366
+ * default date format setting
2367
+ * @example
2368
+ ```
2369
+ setDefaultFormat({
2370
+ year: "YYYY",
2371
+ month: "YYYY-MM",
2372
+ date: "YYYY-MM-DD",
2373
+ time: "HH:mm",
2374
+ datetime: "YYYY-MM-DD HH:mm",
2375
+ });
2376
+ ```
2377
+ * @public
2378
+ * @static
2379
+ * @param {*} dateFormat
2380
+ */
2381
+ static setDefaultFormat(dateFormat) {
2382
+ Object.assign(DEFAULT_FORMAT, dateFormat);
2383
+ }
2384
+ _minDate() {
2385
+ let minDate = this.options.minDate;
2386
+ if (minDate != "") {
2387
+ if (typeof minDate === "string") {
2388
+ const dt = parser(minDate, this.dateFormat);
2389
+ if (!dt) {
2390
+ return -1;
2391
+ }
2392
+ minDate = dt;
2393
+ }
2394
+ this.minYear = minDate.getFullYear();
2395
+ this.minMonth = +(this.minYear + leftPad(minDate.getMonth(), 2));
2396
+ return new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate(), 0, 0).getTime();
2397
+ }
2398
+ return -1;
2399
+ }
2400
+ _maxDate() {
2401
+ let maxDate = this.options.maxDate;
2402
+ if (maxDate != "") {
2403
+ if (typeof maxDate === "string") {
2404
+ const dt = parser(maxDate, this.dateFormat);
2405
+ if (!dt) {
2406
+ return -1;
2407
+ }
2408
+ maxDate = dt;
2409
+ }
2410
+ this.maxYear = maxDate.getFullYear();
2411
+ this.maxMonth = +(this.maxYear + leftPad(maxDate.getMonth(), 2));
2412
+ return new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59).getTime();
2413
+ }
2414
+ return -1;
2415
+ }
2416
+ set viewMode(mode) {
2417
+ if (this._viewMode === mode) {
2418
+ return;
2419
+ }
2420
+ this._viewMode = mode;
2421
+ this.changeViewMode(mode);
2422
+ }
2423
+ get viewMode() {
2424
+ return this._viewMode;
2425
+ }
2426
+ /**
2427
+ * 모드 change
2428
+ * @param mode
2429
+ */
2430
+ changeViewMode(mode) {
2431
+ var _a;
2432
+ (_a = this.datetimeElement.querySelector(".ddtp-datetime")) == null ? void 0 : _a.setAttribute("view-mode", mode);
2433
+ if (mode === "year") {
2434
+ this.yearDraw();
2435
+ } else if (mode === "month") {
2436
+ this.monthDraw();
2437
+ } else {
2438
+ this.dayDraw();
2439
+ }
2440
+ }
2441
+ /**
2442
+ * init header event
2443
+ *
2444
+ * @public
2445
+ */
2446
+ initHeaderEvent() {
2447
+ var _a, _b, _c, _d;
2448
+ const isRTL = this.options.isRTL;
2449
+ (_a = this.datetimeElement.querySelector(".ddtp-move-btn.prev")) == null ? void 0 : _a.addEventListener("click", (e) => {
2450
+ this.moveDate(isRTL ? "next" : "prev", e);
2451
+ });
2452
+ (_b = this.datetimeElement.querySelector(".ddtp-move-btn.next")) == null ? void 0 : _b.addEventListener("click", (e) => {
2453
+ this.moveDate(isRTL ? "prev" : "next", e);
2454
+ });
2455
+ (_c = this.datetimeElement.querySelector(".ddtp-header-year")) == null ? void 0 : _c.addEventListener("click", (e) => {
2456
+ this.viewMode = DateViewMode.year;
2457
+ });
2458
+ (_d = this.datetimeElement.querySelector(".ddtp-header-month")) == null ? void 0 : _d.addEventListener("click", (e) => {
2459
+ this.viewMode = DateViewMode.month;
2460
+ });
2461
+ }
2462
+ /**
2463
+ * 날짜 달력 이벤트처리.
2464
+ */
2465
+ initDateEvent() {
2466
+ var _a, _b;
2467
+ (_a = this.datetimeElement.querySelector(".ddtp-day-body")) == null ? void 0 : _a.addEventListener("click", (e) => {
2468
+ var _a2;
2469
+ const targetEle = e.target;
2470
+ if (targetEle.classList.contains("ddtp-day") || targetEle.closest(".ddtp-day")) {
2471
+ const selectDate = targetEle.getAttribute("data-day") || "1";
2472
+ const mmDD = selectDate.split(",");
2473
+ this.currentDate.setMonth(+mmDD[0] - 1);
2474
+ this.currentDate.setDate(+mmDD[1]);
2475
+ if (this.isDayDisabled(this.currentDate)) {
2476
+ return;
2477
+ }
2478
+ (_a2 = this.datetimeElement.querySelector(".select")) == null ? void 0 : _a2.classList.remove("select");
2479
+ targetEle.classList.add("select");
2480
+ if (this.isTimeMode()) {
2481
+ this.currentDate.setHour(+this.hourInputEle.value);
2482
+ this.currentDate.setMinutes(+this.minuteInputEle.value);
2483
+ }
2484
+ this.dateChangeEvent(e);
2485
+ }
2486
+ });
2487
+ (_b = this.datetimeElement.querySelector(".ddtp-today")) == null ? void 0 : _b.addEventListener("click", (e) => {
2488
+ const initDate = new DaraDate(parser(this.todayDate, DEFAULT_FORMAT.date) || /* @__PURE__ */ new Date());
2489
+ this.currentDate.setYear(initDate.getYear());
2490
+ this.currentDate.setMonth(initDate.getMonth() - 1);
2491
+ this.currentDate.setDate(initDate.getDate());
2492
+ this.changeViewMode(this.initMode);
2493
+ });
2494
+ }
2495
+ isTimeMode() {
2496
+ return this._viewMode === DateViewMode.time || this._viewMode === DateViewMode.datetime;
2497
+ }
2498
+ getTimeNumberValue(val) {
2499
+ if (!isNumeric(val)) {
2500
+ return 0;
2501
+ }
2502
+ return parseInt(val, 10);
2503
+ }
2504
+ /**
2505
+ * 시간 분 설정 이벤트 처리.
2506
+ *
2507
+ * @public
2508
+ */
2509
+ initTimeEvent() {
2510
+ var _a;
2511
+ if (!this.isTimeMode()) return;
2512
+ let hh = this.currentDate.format("HH");
2513
+ const datetimeElement = this.datetimeElement;
2514
+ const hourInputEle = datetimeElement.querySelector(".ddtp-hour");
2515
+ const hourRangeEle = datetimeElement.querySelector(".ddtp-hour-range");
2516
+ hourInputEle.value = hh;
2517
+ hourRangeEle.value = hh;
2518
+ hourInputEle.addEventListener("input", (e) => {
2519
+ const targetElement = e.target;
2520
+ let val = this.getTimeNumberValue(targetElement.value);
2521
+ let addVal = leftPadClamp(val, 2, "0");
2522
+ if (parseInt(addVal, 10) > 23) {
2523
+ addVal = "23";
2524
+ }
2525
+ hourInputEle.value = addVal;
2526
+ hourRangeEle.value = addVal;
2527
+ });
2528
+ hourRangeEle.addEventListener("input", (e) => {
2529
+ const targetElement = e.target;
2530
+ hourInputEle.value = leftPadClamp(targetElement.value, 2, "0");
2531
+ });
2532
+ let mm = this.currentDate.format("mm");
2533
+ const minuteInputEle = datetimeElement.querySelector(".ddtp-minute");
2534
+ const minuteRangeEle = datetimeElement.querySelector(".ddtp-minute-range");
2535
+ minuteInputEle.value = mm;
2536
+ minuteRangeEle.value = mm;
2537
+ minuteInputEle.addEventListener("input", (e) => {
2538
+ const targetElement = e.target;
2539
+ let val = this.getTimeNumberValue(targetElement.value);
2540
+ let addVal = leftPadClamp(val, 2, "0");
2541
+ if (parseInt(addVal, 10) > 59) {
2542
+ addVal = "59";
2543
+ }
2544
+ minuteInputEle.value = addVal;
2545
+ minuteRangeEle.value = addVal;
2546
+ });
2547
+ minuteRangeEle.addEventListener("input", (e) => {
2548
+ const targetElement = e.target;
2549
+ minuteInputEle.value = leftPadClamp(targetElement.value, 2, "0");
2550
+ });
2551
+ (_a = datetimeElement.querySelector(".time-select")) == null ? void 0 : _a.addEventListener("click", (e) => {
2552
+ this.currentDate.setHour(+hourInputEle.value);
2553
+ this.currentDate.setMinutes(+minuteInputEle.value);
2554
+ this.dateChangeEvent(e);
2555
+ });
2556
+ }
2557
+ /**
2558
+ * 날짜 이동
2559
+ * @param moveMode // 앞뒤 이동 prev, next
2560
+ * @returns
2561
+ */
2562
+ moveDate(moveMode, e) {
2563
+ if (this._viewMode === DateViewMode.date || this._viewMode === DateViewMode.datetime) {
2564
+ this.currentDate.setDate(1);
2565
+ this.currentDate.addMonth("prev" === moveMode ? -1 : 1);
2566
+ this.dayDraw();
2567
+ return;
2568
+ }
2569
+ if (this._viewMode === DateViewMode.month) {
2570
+ this.currentDate.setDate(1);
2571
+ this.currentDate.addYear("prev" === moveMode ? -1 : 1);
2572
+ this.monthDraw();
2573
+ return;
2574
+ }
2575
+ if (this._viewMode === DateViewMode.year) {
2576
+ this.currentDate.setDate(1);
2577
+ this.currentDate.addYear("prev" === moveMode ? -16 : 16);
2578
+ this.yearDraw();
2579
+ }
2580
+ }
2581
+ /**
2582
+ * get date value
2583
+ *
2584
+ * @returns
2585
+ */
2586
+ getDateValue() {
2587
+ return this.currentDate.format(this.dateFormat);
2588
+ }
2589
+ /**
2590
+ * 옵션 셋팅
2591
+ * @static
2592
+ * @param {DateTimePickerOptions} options
2593
+ */
2594
+ static setOptions(options) {
2595
+ DEFAULT_OPTIONS$1 = Object.assign({}, DEFAULT_OPTIONS$1, options);
2596
+ }
2597
+ /**
2598
+ * 달력 보이기 처리.
2599
+ *
2600
+ * @returns
2601
+ */
2602
+ show() {
2603
+ if (this.isVisible) {
2604
+ return;
2605
+ }
2606
+ this.isVisible = true;
2607
+ const docSize = getDocSize();
2608
+ this.datetimeElement.classList.remove("hide");
2609
+ this.datetimeElement.classList.add("show");
2610
+ const rect = this.targetElement.getBoundingClientRect();
2611
+ const scrollTop = window.scrollY || document.documentElement.scrollTop;
2612
+ const scrollLeft = window.scrollX || document.documentElement.scrollLeft;
2613
+ const elementHeight = this.datetimeElement.offsetHeight;
2614
+ const targetElementHeight = this.targetElement.offsetHeight + 2;
2615
+ let left = rect.left + scrollLeft;
2616
+ let top = 0;
2617
+ if (this.options.isPositionFixed) {
2618
+ top = rect.top + targetElementHeight;
2619
+ left = rect.left;
2620
+ } else {
2621
+ if (rect.top + targetElementHeight + elementHeight > docSize.clientHeight && rect.top >= elementHeight) {
2622
+ top = scrollTop + rect.top - elementHeight - 2;
2623
+ } else {
2624
+ top = scrollTop + rect.top + targetElementHeight;
2625
+ }
2626
+ }
2627
+ this.datetimeElement.setAttribute("style", `${this.options.isPositionFixed ? "position:fixed;" : ""}top:${top}px;left:${left}px;z-index:${this.options.zIndex}`);
2628
+ document.addEventListener("click", this._documentClickEvent);
2629
+ }
2630
+ /**
2631
+ * 달력 숨기기
2632
+ */
2633
+ hide() {
2634
+ this.isVisible = false;
2635
+ if (this.options.onClose) {
2636
+ if (this.options.onClose() === false) {
2637
+ return;
2638
+ }
2639
+ }
2640
+ this.datetimeElement.classList.remove("show");
2641
+ this.datetimeElement.classList.add("hide");
2642
+ document.removeEventListener("click", this._documentClickEvent);
2643
+ }
2644
+ /**
2645
+ * 타켓 이벤트 처리.
2646
+ */
2647
+ initTargetEvent() {
2648
+ if (this.targetElement) {
2649
+ this.targetElement.addEventListener("click", (e) => {
2650
+ this.show();
2651
+ });
2652
+ }
2653
+ }
2654
+ /**
2655
+ * 날짜 변경후 이벤트
2656
+ */
2657
+ afterChangeDatepicker() {
2658
+ const formatValue = this.currentDate.format(this.dateFormat);
2659
+ if (this.options.afterChangeDatepicker && isFunction$1(this.options.afterChangeDatepicker)) {
2660
+ this.options.afterChangeDatepicker(formatValue, this.viewMode);
2661
+ }
2662
+ }
2663
+ /**
2664
+ * 날짜 변경 전 이벤트.
2665
+ * @returns void
2666
+ */
2667
+ beforeChangeDatepicker() {
2668
+ const formatValue = this.currentDate.format(this.dateFormat);
2669
+ if (this.options.beforeChangeDatepicker && isFunction$1(this.options.beforeChangeDatepicker)) {
2670
+ const reval = this.options.beforeChangeDatepicker(formatValue, (result) => {
2671
+ if (result === false) {
2672
+ return;
2673
+ }
2674
+ this.refresh(false);
2675
+ });
2676
+ if (reval === false) {
2677
+ return;
2678
+ }
2679
+ this.refresh(false);
2680
+ return;
2681
+ }
2682
+ this.refresh(false);
2683
+ }
2684
+ dateChangeEvent(e) {
2685
+ const formatValue = this.currentDate.format(this.dateFormat);
2686
+ if (this.options.onSelect) {
2687
+ if (this.options.onSelect(formatValue, this.viewMode, e) === false) {
2688
+ return;
2689
+ }
2690
+ }
2691
+ if (this.isInput) {
2692
+ this.targetElement.setAttribute("value", formatValue);
2693
+ }
2694
+ if (!this.options.inline && this.options.autoClose) {
2695
+ this.hide();
2696
+ }
2697
+ }
2698
+ /**
2699
+ * datepicker template 그리기
2700
+ */
2701
+ createDatetimeTemplate() {
2702
+ const showMonthAfterYear = this.options.showMonthAfterYear;
2703
+ let datetimeTemplate = `<div class="ddtp-datetime ${this.options.isRTL ? "rtl" : ""}" view-mode="${this._viewMode}">
2704
+ <div class="ddtp-header">
2705
+ <span class="${showMonthAfterYear ? "ddtp-header-year" : "ddtp-header-month"}"></span>
2706
+ <span class="${showMonthAfterYear ? "ddtp-header-month" : "ddtp-header-year"}"></span>
2707
+
2708
+ <span class="ddtp-date-move">
2709
+ <a href="javascript:;" class="ddtp-move-btn prev">
2710
+ <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>
2711
+ </a>
2712
+ <a href="javascript:;" class="ddtp-move-btn next">
2713
+ <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>
2714
+ </a>
2715
+ </span>
2716
+ </div>
2717
+ <div class="ddtp-body">
2718
+ <table class="ddtp-days">
2719
+ <thead class="ddtp-day-header">
2720
+ <tr>
2721
+ <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[0]]}">${Lanauage.getWeeksMessage(this.dayOrder[0])}</td>
2722
+ <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[1]]}">${Lanauage.getWeeksMessage(this.dayOrder[1])}</td>
2723
+ <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[2]]}">${Lanauage.getWeeksMessage(this.dayOrder[2])}</td>
2724
+ <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[3]]}">${Lanauage.getWeeksMessage(this.dayOrder[3])}</td>
2725
+ <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[4]]}">${Lanauage.getWeeksMessage(this.dayOrder[4])}</td>
2726
+ <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[5]]}">${Lanauage.getWeeksMessage(this.dayOrder[5])}</td>
2727
+ <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[6]]}">${Lanauage.getWeeksMessage(this.dayOrder[6])}</td>
2728
+ </tr>
2729
+ </thead>
2730
+ <tbody class="ddtp-day-body">
2731
+ </tbody>
2732
+
2733
+ <tfoot class="ddtp-day-footer">
2734
+ <td colspan="7">
2735
+ <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>
2736
+ <div class="footer-tooltip"></div>
2737
+ </td>
2738
+ </tfoot>
2739
+ </table>
2740
+
2741
+ <div class="ddtp-times">
2742
+ <div class="time-container">
2743
+ <div class="ddtp-time">
2744
+ <span>H: </span><input type="number" class="ddtp-hour" min="0" max="23" maxlength="2">
2745
+ <input type="range" min="0" max="23" class="ddtp-hour-range">
2746
+ </div>
2747
+ <div class="ddtp-time">
2748
+ <span>M: </span><input type="number" class="ddtp-minute" min="0" max="59" size="2" maxlength="2">
2749
+ <input type="range" min="0" max="59" class="ddtp-minute-range">
2750
+ </div>
2751
+ </div>
2752
+ <div class="ddtp-btn">
2753
+ <button type="button" class="time-select">${Lanauage.getMessage("ok")}</button>
2754
+ </div>
2755
+ </div>
2756
+
2757
+ <div class="ddtp-months">
2758
+ </div>
2759
+
2760
+ <div class="ddtp-years">
2761
+ </div>
2762
+ </div>
2763
+ </div>`;
2764
+ this.datetimeElement.innerHTML = datetimeTemplate;
2765
+ }
2766
+ refresh(beforeChangeDatepickerCheck) {
2767
+ if (this._viewMode === DateViewMode.date || this._viewMode === DateViewMode.datetime) {
2768
+ this.dayDraw(beforeChangeDatepickerCheck);
2769
+ return;
2770
+ }
2771
+ if (this._viewMode === DateViewMode.month) {
2772
+ this.monthDraw(beforeChangeDatepickerCheck);
2773
+ return;
2774
+ }
2775
+ if (this._viewMode === DateViewMode.year) {
2776
+ this.yearDraw(beforeChangeDatepickerCheck);
2777
+ }
2778
+ }
2779
+ /**
2780
+ * 년 달력 그리기
2781
+ */
2782
+ yearDraw(beforeChangeDatepickerCheck) {
2783
+ var _a;
2784
+ const currentYear = this.currentDate.format("YYYY");
2785
+ if (beforeChangeDatepickerCheck !== false && this.initMode == DateViewMode.year) {
2786
+ this.beforeChangeDatepicker();
2787
+ return;
2788
+ }
2789
+ const startYear = +currentYear - 8;
2790
+ this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${startYear} ~ ${startYear + 15}`;
2791
+ const beforeDrawDateFlag = isFunction$1(this.options.beforeDrawDate);
2792
+ const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
2793
+ const calHTML = [];
2794
+ for (let i = 0; i < 16; i++) {
2795
+ const year = startYear + i;
2796
+ const disabled = this.isYearDisabled(year);
2797
+ let addStylceClass = disabled ? " disabled" : "";
2798
+ let tooltip = "";
2799
+ if (beforeDrawDateFlag && beforeDrawDateFn) {
2800
+ const reval = beforeDrawDateFn({ mode: this._viewMode, date: year });
2801
+ addStylceClass += reval.style ? " " + reval.style : "";
2802
+ tooltip = reval.tooltip;
2803
+ tooltip = tooltip ? `title="${tooltip}"` : "";
2804
+ }
2805
+ calHTML.push(`<div class="ddtp-year ${addStylceClass}" data-year="${year}" ${tooltip}>${year}</div>`);
2806
+ }
2807
+ this.datetimeElement.querySelector(".ddtp-years").innerHTML = calHTML.join("");
2808
+ if (this.initMode == DateViewMode.year) {
2809
+ this.afterChangeDatepicker();
2810
+ }
2811
+ (_a = this.datetimeElement.querySelectorAll(".ddtp-year")) == null ? void 0 : _a.forEach((yearEle) => {
2812
+ yearEle.addEventListener("click", (e) => {
2813
+ const targetEle = e.target;
2814
+ if (targetEle) {
2815
+ const year = targetEle.getAttribute("data-year");
2816
+ if (year) {
2817
+ const numYear = +year;
2818
+ if (this.isYearDisabled(numYear)) {
2819
+ return;
2820
+ }
2821
+ if (this.initMode == DateViewMode.year) {
2822
+ if (this.isYearDisabled(numYear)) {
2823
+ return;
2824
+ }
2825
+ this.currentDate.setYear(numYear);
2826
+ this.dateChangeEvent(e);
2827
+ return;
2828
+ }
2829
+ this.currentDate.setYear(numYear);
2830
+ this.viewMode = this.initMode;
2831
+ }
2832
+ }
2833
+ });
2834
+ });
2835
+ }
2836
+ /**
2837
+ * 월 달력 그리기
2838
+ */
2839
+ monthDraw(beforeChangeDatepickerCheck) {
2840
+ var _a;
2841
+ if (beforeChangeDatepickerCheck !== false && this.initMode == DateViewMode.month) {
2842
+ this.beforeChangeDatepicker();
2843
+ return;
2844
+ }
2845
+ const year = this.currentDate.format("YYYY");
2846
+ this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${year}`;
2847
+ const monthElements = this.datetimeElement.querySelectorAll(".ddtp-months > .ddtp-month");
2848
+ if (monthElements.length > 0) {
2849
+ if (this.isYearDisabled(+year)) {
2850
+ monthElements.forEach((monthEle) => {
2851
+ if (!monthEle.classList.contains("disabled")) {
2852
+ monthEle.classList.add("disabled");
2853
+ }
2854
+ });
2855
+ return;
2856
+ }
2857
+ monthElements.forEach((monthEle, idx) => {
2858
+ if (this.isMonthDisabled(+year, idx)) {
2859
+ if (!monthEle.classList.contains("disabled")) {
2860
+ monthEle.classList.add("disabled");
2861
+ }
2862
+ } else {
2863
+ monthEle.classList.remove("disabled");
2864
+ }
2865
+ });
2866
+ if (this.initMode == DateViewMode.month) {
2867
+ this.afterChangeDatepicker();
2868
+ }
2869
+ return;
2870
+ }
2871
+ this.datetimeElement.querySelector(".ddtp-header-month").textContent = this.currentDate.format("MMMM");
2872
+ const beforeDrawDateFlag = isFunction$1(this.options.beforeDrawDate);
2873
+ const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
2874
+ const calHTML = [];
2875
+ for (let i = 0; i < 12; i++) {
2876
+ const disabled = this.isMonthDisabled(+year, i);
2877
+ let addStylceClass = disabled ? " disabled" : "";
2878
+ let tooltip = "";
2879
+ if (beforeDrawDateFlag && beforeDrawDateFn) {
2880
+ const reval = beforeDrawDateFn({ mode: this._viewMode, date: year + "/" + (i + 1) });
2881
+ addStylceClass += reval.style ? " " + reval.style : "";
2882
+ tooltip = reval.tooltip;
2883
+ tooltip = tooltip ? `title="${tooltip}"` : "";
2884
+ }
2885
+ calHTML.push(`<div class="ddtp-month ${addStylceClass}" data-month="${i}" ${tooltip}>${Lanauage.getMonthsMessage(i, "abbr")}</div>`);
2886
+ }
2887
+ this.datetimeElement.querySelector(".ddtp-months").innerHTML = calHTML.join("");
2888
+ if (this.initMode == DateViewMode.month) {
2889
+ this.afterChangeDatepicker();
2890
+ }
2891
+ (_a = this.datetimeElement.querySelectorAll(".ddtp-month")) == null ? void 0 : _a.forEach((monthEle) => {
2892
+ monthEle.addEventListener("click", (e) => {
2893
+ const targetEle = e.target;
2894
+ if (targetEle) {
2895
+ const month = targetEle.getAttribute("data-month");
2896
+ if (month) {
2897
+ if (this.isMonthDisabled(this.currentDate.getYear(), +month)) {
2898
+ return false;
2899
+ }
2900
+ if (this.initMode == DateViewMode.month) {
2901
+ this.currentDate.setMonth(+month);
2902
+ this.dateChangeEvent(e);
2903
+ return;
2904
+ }
2905
+ this.currentDate.setMonth(+month);
2906
+ this.viewMode = this.initMode;
2907
+ this.dayDraw();
2908
+ }
2909
+ }
2910
+ });
2911
+ });
2912
+ }
2913
+ /**
2914
+ * 날짜 그리기
2915
+ */
2916
+ dayDraw(beforeChangeDatepickerCheck) {
2917
+ if (beforeChangeDatepickerCheck !== false && (this.initMode == DateViewMode.date || this.initMode == DateViewMode.datetime)) {
2918
+ this.beforeChangeDatepicker();
2919
+ return;
2920
+ }
2921
+ let monthFirstDate = this.currentDate.clone();
2922
+ const currentMonth = monthFirstDate.getMonth();
2923
+ monthFirstDate.setDate(1);
2924
+ this.datetimeElement.querySelector(".ddtp-header-year").textContent = monthFirstDate.format("YYYY");
2925
+ this.datetimeElement.querySelector(".ddtp-header-month").textContent = monthFirstDate.format("MMMM");
2926
+ let day = monthFirstDate.getDay();
2927
+ day = day - this.dayOrder[0];
2928
+ if (day >= 0) {
2929
+ monthFirstDate.addDate(-day);
2930
+ } else {
2931
+ monthFirstDate.addDate(-(7 + day));
2932
+ }
2933
+ const beforeDrawDateFlag = isFunction$1(this.options.beforeDrawDate);
2934
+ const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
2935
+ const calHTML = [];
2936
+ for (let i = 0; i < 42; i++) {
2937
+ let dateItem;
2938
+ if (i == 0) {
2939
+ dateItem = monthFirstDate;
2940
+ } else {
2941
+ dateItem = monthFirstDate.clone().addDate(i);
2942
+ }
2943
+ const dateItemFormat = dateItem.format(DEFAULT_FORMAT.date);
2944
+ if (i % 7 == 0) {
2945
+ calHTML.push((i == 0 ? "" : "</tr>") + "<tr>");
2946
+ }
2947
+ let disabled = this.isDayDisabled(dateItem);
2948
+ let addStylceClass = DAY_STYLE_CLASS[this.dayOrder[i % 7]];
2949
+ const dateItemMonth = dateItem.getMonth();
2950
+ if (dateItemMonth != currentMonth) {
2951
+ if (dateItemMonth < currentMonth) {
2952
+ addStylceClass += dateItemMonth == 1 ? " new" : " old";
2953
+ } else {
2954
+ addStylceClass += currentMonth == 1 && dateItemMonth == 12 ? " old" : " new";
2955
+ }
2956
+ }
2957
+ addStylceClass += this.todayDate == dateItemFormat ? " ddtp-today" : "";
2958
+ addStylceClass += disabled ? " disabled" : "";
2959
+ let tooltip = "";
2960
+ if (beforeDrawDateFlag && beforeDrawDateFn) {
2961
+ const reval = beforeDrawDateFn({ mode: this._viewMode, item: dateItem, date: dateItem.format(this.dateFormat) });
2962
+ addStylceClass += reval.style ? " " + reval.style : "";
2963
+ addStylceClass += reval.check ? " ddtp-event" : "";
2964
+ tooltip = reval.tooltip;
2965
+ tooltip = tooltip ? `title="${tooltip}"` : "";
2966
+ }
2967
+ calHTML.push(`<td class="ddtp-day ${addStylceClass}" data-day="${dateItem.format("M,D")}" ${tooltip}>`);
2968
+ calHTML.push(`<span>${dateItem.format("d")}</span>`);
2969
+ calHTML.push("</td>");
2970
+ }
2971
+ calHTML.push("</tr>");
2972
+ this.datetimeElement.querySelector(".ddtp-day-body").innerHTML = calHTML.join("");
2973
+ if (this.initMode == DateViewMode.date || this.initMode == DateViewMode.datetime) {
2974
+ this.afterChangeDatepicker();
2975
+ }
2976
+ }
2977
+ isDayDisabled(dateItem) {
2978
+ if (this.minDate != -1 && this.minDate > dateItem.getTime() || this.maxDate != -1 && this.maxDate < dateItem.getTime()) {
2979
+ return true;
2980
+ }
2981
+ return false;
2982
+ }
2983
+ isYearDisabled(year) {
2984
+ if (this.minYear != -1 && this.minYear > year || this.maxYear != -1 && this.maxYear < year) {
2985
+ return true;
2986
+ }
2987
+ return false;
2988
+ }
2989
+ isMonthDisabled(year, month) {
2990
+ if (this.isYearDisabled(year)) {
2991
+ return true;
2992
+ }
2993
+ let yearMonth = +(year + leftPad(month, 2));
2994
+ if (this.minMonth != -1 && this.minMonth > yearMonth || this.maxMonth != -1 && this.maxMonth < yearMonth) {
2995
+ return true;
2996
+ }
2997
+ return false;
2998
+ }
2999
+ static setMessage(message2) {
3000
+ Lanauage.setDefaultMessage(message2);
3001
+ }
3002
+ };
3003
+ _DateTimePicker.VERSION = `${"0.0.13"}`;
3004
+ _DateTimePicker.format = format;
3005
+ _DateTimePicker.parser = parser;
3006
+ let DateTimePicker = _DateTimePicker;
3007
+ function getDocSize() {
3008
+ return {
3009
+ clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
3010
+ clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
3011
+ };
3012
+ }
3013
+ class DateRender extends Render {
3014
+ constructor(field, rowElement, daraForm) {
3015
+ super(daraForm, field, rowElement);
3016
+ this.mounted();
3017
+ this.setDefaultOption();
3018
+ this.setDefaultInfo();
3019
+ }
3020
+ mounted() {
3021
+ let dateOnSelectEvent;
3022
+ this.field.rendererOptions = Object.assign({}, this.field.rendererOptions);
3023
+ if (typeof this.field.rendererOptions.onSelect !== "undefined") {
3024
+ dateOnSelectEvent = typeof this.field.rendererOptions.onSelect;
3025
+ }
3026
+ if (isUndefined(this.field.rendererOptions.mode)) {
3027
+ if (this.field.renderType == "datemonth" || this.field.renderType == "datehour") {
3028
+ this.field.rendererOptions.mode = this.field.renderType.replace("date", "");
3029
+ } else {
3030
+ this.field.rendererOptions.mode = this.field.renderType;
3031
+ }
3032
+ }
3033
+ this.field.rendererOptions.onSelect = (dt, e) => {
3034
+ if (dateOnSelectEvent) {
3035
+ dateOnSelectEvent(dt, e);
3036
+ }
3037
+ this.setValue(dt);
3038
+ this.valid();
3039
+ };
3040
+ this.dateObj = new DateTimePicker(this.element, this.field.rendererOptions, {});
3041
+ }
3042
+ createField() {
3043
+ const field = this.field;
3044
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
3045
+ fieldContainerElement.innerHTML = `
3046
+ <div class="df-field">
3047
+ <input type="text" name="${field.$xssName}" class="df-form-field df-text df-help-icon" autocomplete="off" readonly/>
3048
+ </div>
3049
+ ${Render.getDescriptionTemplate(field)}
3050
+ <div class="df-help-message"></div>
3051
+ `;
3052
+ this.element = fieldContainerElement.querySelector(`[name="${field.$xssName}"]`);
3053
+ }
3054
+ getValue() {
3055
+ return this.element.value;
3056
+ }
3057
+ setValue(value, changeCheckFlag) {
3058
+ if (changeCheckFlag !== false && this.changeEventCall(this.field, null, this, value) === false) {
3059
+ this.element.value = this.field.$value;
3060
+ return;
3061
+ }
3062
+ this.field.$value = value;
3063
+ this.element.value = value;
3064
+ }
3065
+ reset() {
3066
+ this.setDefaultInfo();
3067
+ this.setDisabled(false);
3068
+ resetRowElementStyleClass(this.rowElement);
3069
+ }
3070
+ getElement() {
3071
+ return this.element;
3072
+ }
3073
+ valid() {
3074
+ const validResult = stringValidator(this.getValue(), this.field);
3075
+ invalidMessage(this.field, this.rowElement, validResult);
3076
+ return validResult;
3077
+ }
3078
+ }
3079
+ class TabRender extends Render {
3080
+ constructor(field, rowElement, daraForm) {
3081
+ super(daraForm, field, rowElement);
3082
+ if (field.renderer) {
3083
+ this.customFunction = field.renderer;
3084
+ } else {
3085
+ this.customFunction = {};
3086
+ }
3087
+ this.mounted();
3088
+ }
3089
+ mounted() {
3090
+ if (this.customFunction.mounted) {
3091
+ this.customFunction.mounted.call(this, this.field, this.rowElement);
3092
+ }
3093
+ this.tabContainerElement.querySelectorAll(".df-tab-item").forEach((tabItem) => {
3094
+ tabItem.addEventListener("click", (e) => {
3095
+ this.clickEventHandler(tabItem, e);
3096
+ });
3097
+ });
3098
+ }
3099
+ /**
3100
+ * tab item click
3101
+ *
3102
+ * @param {Element} tabItem
3103
+ * @param {*} evt
3104
+ */
3105
+ clickEventHandler(tabItem, evt) {
3106
+ this.setActive(tabItem.getAttribute("data-tab-id") ?? "");
3107
+ }
3108
+ setActive(tabId) {
3109
+ var _a, _b;
3110
+ const tabItem = this.tabContainerElement.querySelector(`[data-tab-id="${tabId}"]`);
3111
+ if (!tabItem) return;
3112
+ if (!tabItem.classList.contains("active")) {
3113
+ for (let item of ((_a = tabItem == null ? void 0 : tabItem.parentElement) == null ? void 0 : _a.children) ?? []) {
3114
+ item.classList.remove("active");
3115
+ }
3116
+ tabItem.classList.add("active");
3117
+ }
3118
+ const tabPanel = this.rowElement.querySelector(`[tab-panel-id="${tabId}"]`);
3119
+ if (!(tabPanel == null ? void 0 : tabPanel.classList.contains("active"))) {
3120
+ for (let item of ((_b = tabPanel == null ? void 0 : tabPanel.parentElement) == null ? void 0 : _b.children) ?? []) {
3121
+ item.classList.remove("active");
3122
+ }
3123
+ tabPanel == null ? void 0 : tabPanel.classList.add("active");
3124
+ }
3125
+ }
3126
+ static isDataRender() {
3127
+ return false;
3128
+ }
3129
+ static isChildrenCreate() {
3130
+ return false;
3131
+ }
3132
+ /**
3133
+ * tab template
3134
+ *
3135
+ * @param {FormField} field
3136
+ * @param {FormTemplate} formTemplate
3137
+ * @param {FormOptions} options
3138
+ * @returns {string} template string
3139
+ */
3140
+ createField() {
3141
+ var _a, _b;
3142
+ const field = this.field;
3143
+ const formTemplate = this.daraForm.formTemplate;
3144
+ const options = this.daraForm.getOptions();
3145
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
3146
+ let fieldStyle = resolveFieldStyle(options, field);
3147
+ fieldContainerElement.innerHTML = `
3148
+ <div class="df-field ">
3149
+ <div class="df-tab-header ${fieldStyle.tabAlignClass}"></div>
3150
+ </div>
3151
+ <div class="df-tab-body"></div>
3152
+ `;
3153
+ if (field.children) {
3154
+ let firstFlag = true;
3155
+ const formOptions = this.getForm().getOptions();
3156
+ let fieldStyle2 = resolveFieldStyle(formOptions, field, null, formTemplate.isLabelHide(field));
3157
+ for (const childField of field.children) {
3158
+ childField.$parent = field;
3159
+ formTemplate.addRowFieldInfo(childField);
3160
+ let id = childField.$key;
3161
+ let tabTemplate = `<span class="df-tab-item ${firstFlag ? "active" : ""}" data-tab-id="${id}"><a href="javascript:;">${childField.label}</a></span>`;
3162
+ let tabBodyTemplate = `<div class="df-tab-panel ${firstFlag ? "active" : ""}" tab-panel-id="${id}">${Render.getDescriptionTemplate(childField)}
3163
+ <div class="df-tab-group"></div>
3164
+ </div>`;
3165
+ const tabElement = templateToElement(tabTemplate);
3166
+ const tabBodyElement = templateToElement(tabBodyTemplate);
3167
+ firstFlag = false;
3168
+ if (tabElement) {
3169
+ (_a = fieldContainerElement.querySelector(".df-tab-header")) == null ? void 0 : _a.appendChild(tabElement);
3170
+ }
3171
+ if (tabBodyElement) {
3172
+ (_b = fieldContainerElement.querySelector(".df-tab-body")) == null ? void 0 : _b.appendChild(tabBodyElement);
3173
+ if (childField.children) {
3174
+ let tabFormOptions = {
3175
+ style: {
3176
+ width: formOptions.style.width ?? "100%",
3177
+ labelWidth: formOptions.style.labelWidth ?? 3,
3178
+ valueWidth: formOptions.style.valueWidth ?? 9,
3179
+ position: formOptions.style.position ?? "left-right"
3180
+ },
3181
+ useTypeValue: formOptions.useTypeValue,
3182
+ autoCreate: false,
3183
+ notValidMessage: "This form is not valid.",
3184
+ fields: []
3185
+ };
3186
+ childField.$tabForm = new DaraForm(document.createElement("div"), tabFormOptions);
3187
+ childField.$instance = new childField.$renderType(childField, tabBodyElement == null ? void 0 : tabBodyElement.querySelector(".df-tab-group"), childField.$tabForm);
3188
+ childField.$tabForm.formTemplate.childTemplate(childField, fieldStyle2);
3189
+ }
3190
+ }
3191
+ }
3192
+ this.tabContainerElement = fieldContainerElement;
3193
+ }
3194
+ }
3195
+ getValue() {
3196
+ var _a;
3197
+ if (this.customFunction.getValue) {
3198
+ return this.customFunction.getValue.call(this, this.field, this.rowElement);
3199
+ }
3200
+ let allTabValue = {};
3201
+ let useTypeValue = this.getForm().getOptions().useTypeValue;
3202
+ for (const childField of this.field.children) {
3203
+ const childFieldValue = (_a = childField.$tabForm) == null ? void 0 : _a.getValue(false);
3204
+ if (useTypeValue) {
3205
+ allTabValue[childField.$validName] = childFieldValue;
3206
+ } else {
3207
+ for (let [key, value] of Object.entries(childFieldValue)) {
3208
+ allTabValue[key] = value;
3209
+ }
3210
+ }
3211
+ }
3212
+ return allTabValue;
3213
+ }
3214
+ setValue(value) {
3215
+ var _a;
3216
+ for (const childField of this.field.children) {
3217
+ let tabChildValue = value[childField.$validName];
3218
+ if (tabChildValue) {
3219
+ (_a = childField.$tabForm) == null ? void 0 : _a.setValue(tabChildValue);
3220
+ }
3221
+ }
3222
+ }
3223
+ reset() {
3224
+ }
3225
+ getElement() {
3226
+ return this.rowElement;
3227
+ }
3228
+ valid() {
3229
+ var _a;
3230
+ if (this.customFunction.valid) {
3231
+ const validResult = this.customFunction.valid.call(this, this.field, this.rowElement);
3232
+ invalidMessage(this.field, this.rowElement, validResult);
3233
+ return;
3234
+ }
3235
+ const field = this.field;
3236
+ for (const childField of field.children) {
3237
+ const validResult = (_a = childField.$tabForm) == null ? void 0 : _a.validForm();
3238
+ if (validResult && validResult.length > 0) {
3239
+ const firstItem = validResult[0];
3240
+ if (firstItem.message) {
3241
+ firstItem.message = "[" + this.field.label + "] " + firstItem.message;
3242
+ return firstItem;
3243
+ }
3244
+ }
3245
+ }
3246
+ return true;
3247
+ }
3248
+ focus() {
3249
+ }
3250
+ }
3251
+ let $$idx = 0;
3252
+ class GridRender extends Render {
3253
+ constructor(field, rowElement, daraForm) {
3254
+ super(daraForm, field, rowElement);
3255
+ this.allAddRowInfo = {};
3256
+ if (field.renderer) {
3257
+ this.customFunction = field.renderer;
3258
+ } else {
3259
+ this.customFunction = {};
3260
+ }
3261
+ const gridFormOptions = {
3262
+ style: {
3263
+ width: "100%",
3264
+ labelWidth: 3,
3265
+ valueWidth: 9,
3266
+ position: "left-right"
3267
+ },
3268
+ autoCreate: false,
3269
+ notValidMessage: "This form is not valid.",
3270
+ fields: []
3271
+ };
3272
+ this.gridForm = new DaraForm(document.createElement("div"), gridFormOptions);
3273
+ this.mounted();
3274
+ this.setDefaultOption();
3275
+ this.setDefaultInfo();
3276
+ }
3277
+ mounted() {
3278
+ var _a;
3279
+ this.addRow();
3280
+ if (this.customFunction.mounted) {
3281
+ this.customFunction.mounted.call(this, this.field, this.rowElement);
3282
+ }
3283
+ (_a = this.rowElement.querySelector(".df-grid-add-row-btn")) == null ? void 0 : _a.addEventListener("click", (evt) => {
3284
+ this.addRow();
3285
+ });
3286
+ }
3287
+ static isDataRender() {
3288
+ return false;
3289
+ }
3290
+ static isChildrenCreate() {
3291
+ return false;
3292
+ }
3293
+ createField() {
3294
+ var _a, _b, _c, _d;
3295
+ const field = this.field;
3296
+ const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
3297
+ let theadTemplate = [];
3298
+ let colgroupTemplate = [];
3299
+ let addBtnTemplate = [];
3300
+ addBtnTemplate.push("");
3301
+ if (field.children) {
3302
+ colgroupTemplate.push("<colgroup>");
3303
+ theadTemplate.push("<tr>");
3304
+ colgroupTemplate.push(`<col style="width:38px">`);
3305
+ theadTemplate.push("<th>");
3306
+ if (((_a = field.rendererOptions) == null ? void 0 : _a.disableAddButton) !== true) {
3307
+ theadTemplate.push(`<button type="button" class="df-btn df-grid-add-row-btn" title="Add"><i class="df-icon df-add-icon"></i></button>`);
3308
+ }
3309
+ theadTemplate.push("</th>");
3310
+ for (const childField of field.children) {
3311
+ colgroupTemplate.push(`<col style="width:${((_b = childField.style) == null ? void 0 : _b.width) ?? "*"}">`);
3312
+ theadTemplate.push(`<th class="df-grid-header">${childField.label}</th>`);
3313
+ }
3314
+ colgroupTemplate.push("</colgroup>");
3315
+ theadTemplate.push("</tr>");
3316
+ }
3317
+ fieldContainerElement.innerHTML = `
3318
+ <div class="df-grid-field">
3319
+ ${addBtnTemplate.join("")}
3320
+ <div class="df-grid-container ${((_c = field.style) == null ? void 0 : _c.position) ?? ""}" style="height:${((_d = field.rendererOptions) == null ? void 0 : _d.height) ?? "auto"};">
3321
+ <table class="df-grid">${colgroupTemplate.join("")}<thead>${theadTemplate.join("")}</thead><tbody></tbody></table>
3322
+ </div>
3323
+ </div>
3324
+ `;
3325
+ }
3326
+ /**
3327
+ * add row
3328
+ */
3329
+ addRow(valueItem) {
3330
+ var _a, _b, _c;
3331
+ let rowTemplate = [];
3332
+ const options = this.daraForm.getOptions();
3333
+ const formTemplate = this.gridForm.formTemplate;
3334
+ const parentName = this.field.$xssName;
3335
+ ++$$idx;
3336
+ let addColumns = [];
3337
+ rowTemplate.push(`<tr class="df-grid-row">`);
3338
+ rowTemplate.push("<td>");
3339
+ if (((_a = this.field.rendererOptions) == null ? void 0 : _a.disableRemoveButton) !== true) {
3340
+ rowTemplate.push(`<button type="button" data-row-idx="${$$idx}" class="df-btn df-grid-row-remove"><i class="df-icon df-remove-icon"></i></button>`);
3341
+ }
3342
+ rowTemplate.push("</td>");
3343
+ for (const childField of this.field.children) {
3344
+ let fieldStyle = resolveFieldStyle(options, childField, null, true);
3345
+ let columnField = merge({}, childField);
3346
+ addColumns.push(columnField);
3347
+ columnField.$orgin = childField;
3348
+ columnField.name = columnField.name + "_" + $$idx;
3349
+ columnField.$xssName = parentName + "_" + getXssFieldName(columnField);
3350
+ formTemplate.addRowFieldInfo(columnField);
3351
+ rowTemplate.push(`<td id="${columnField.$xssName}"><div class="df-field-container ${columnField.required ? "required" : ""} " style="${fieldStyle.valueStyle}"></div></td>`);
3352
+ }
3353
+ rowTemplate.push("</tr>");
3354
+ this.allAddRowInfo[$$idx] = addColumns;
3355
+ const addRowElement = templateToElement(rowTemplate.join(""));
3356
+ if (addRowElement) {
3357
+ (_b = this.rowElement.querySelector("tbody")) == null ? void 0 : _b.append(addRowElement);
3358
+ (_c = addRowElement.querySelector(".df-grid-row-remove")) == null ? void 0 : _c.addEventListener("click", (evt) => {
3359
+ this.removeRow(evt);
3360
+ });
3361
+ }
3362
+ valueItem = valueItem ?? {};
3363
+ for (let columnField of addColumns) {
3364
+ columnField.$instance = new columnField.$renderType(columnField, addRowElement == null ? void 0 : addRowElement.querySelector(`#${columnField.$xssName}`), this.gridForm);
3365
+ if (valueItem[columnField.$orgin.name]) {
3366
+ columnField.$instance.setValue(valueItem[columnField.$orgin.name]);
3367
+ }
3368
+ }
3369
+ }
3370
+ /**
3371
+ * remove row
3372
+ *
3373
+ * @param evt event
3374
+ */
3375
+ removeRow(evt) {
3376
+ var _a, _b;
3377
+ const target = evt.target;
3378
+ const rowElement = target.closest("tr");
3379
+ if (rowElement) {
3380
+ if (((_a = rowElement.parentElement) == null ? void 0 : _a.childElementCount) == 1) return;
3381
+ let rowIdx = ((_b = evt.currentTarget) == null ? void 0 : _b.getAttribute("data-row-idx")) || "-1";
3382
+ this.removeFieldInfo(rowIdx);
3383
+ rowElement.remove();
3384
+ }
3385
+ }
3386
+ /**
3387
+ *
3388
+ * @param rowIdx row index
3389
+ */
3390
+ removeFieldInfo(rowIdx) {
3391
+ let removeFieldArrs = [];
3392
+ if (isEmpty(rowIdx)) {
3393
+ for (let key in this.allAddRowInfo) {
3394
+ removeFieldArrs = removeFieldArrs.concat(this.allAddRowInfo[key]);
3395
+ }
3396
+ this.allAddRowInfo = {};
3397
+ } else if (rowIdx) {
3398
+ const rowIdxNum = parseInt(rowIdx, 10);
3399
+ removeFieldArrs = removeFieldArrs.concat(this.allAddRowInfo[rowIdxNum]);
3400
+ delete this.allAddRowInfo[rowIdxNum];
3401
+ }
3402
+ for (let columnField of removeFieldArrs) {
3403
+ this.gridForm.getFieldInfoMap().removeFieldInfo(columnField.name);
3404
+ }
3405
+ }
3406
+ allRemoveRow() {
3407
+ var _a;
3408
+ (_a = this.rowElement.querySelector("tbody")) == null ? void 0 : _a.replaceChildren();
3409
+ this.removeFieldInfo();
3410
+ }
3411
+ getValue() {
3412
+ if (this.customFunction.getValue) {
3413
+ return this.customFunction.getValue.call(this, this.field, this.rowElement);
3414
+ }
3415
+ let result = [];
3416
+ const children = this.field.children;
3417
+ const childrenLength = children.length;
3418
+ for (let idx in this.allAddRowInfo) {
3419
+ const rowColumns = this.allAddRowInfo[idx];
3420
+ let rowInfo = {};
3421
+ for (let childIdx = 0; childIdx < childrenLength; childIdx++) {
3422
+ let childField = children[childIdx];
3423
+ rowInfo[childField.name] = this.gridForm.getFieldValue(rowColumns[childIdx].name);
3424
+ }
3425
+ result.push(rowInfo);
3426
+ }
3427
+ return result;
3428
+ }
3429
+ setValue(value) {
3430
+ this.field.$value = value;
3431
+ let valueArr = [];
3432
+ if (isArray(value)) {
3433
+ valueArr = value;
3434
+ } else {
3435
+ if (isPlainObject(value)) {
3436
+ valueArr.push(value);
3437
+ }
3438
+ }
3439
+ this.allRemoveRow();
3440
+ for (let valueItem of valueArr) {
3441
+ this.addRow(valueItem);
3442
+ }
3443
+ }
3444
+ reset() {
3445
+ this.setDefaultInfo();
3446
+ resetRowElementStyleClass(this.rowElement);
3447
+ }
3448
+ getElement() {
3449
+ if (this.customFunction.getElement) {
3450
+ return this.customFunction.getElement.call(this, this.field, this.rowElement);
3451
+ }
3452
+ return null;
3453
+ }
3454
+ valid() {
3455
+ if (this.customFunction.valid) {
3456
+ const validResult2 = this.customFunction.valid.call(this, this.field, this.rowElement);
3457
+ invalidMessage(this.field, this.rowElement, validResult2);
3458
+ return;
3459
+ }
3460
+ const validResult = this.gridForm.validForm();
3461
+ if (validResult.length > 0) {
3462
+ const firstItem = validResult[0];
3463
+ if (firstItem.message) {
3464
+ firstItem.message = "[" + this.field.label + "] " + firstItem.message;
3465
+ return firstItem;
3466
+ }
3467
+ }
3468
+ return true;
3469
+ }
3470
+ focus() {
3471
+ }
3472
+ }
3473
+ const RULES = {
3474
+ NAN: "nan",
3475
+ MIN: "minimum",
3476
+ EXCLUSIVE_MIN: "exclusiveMinimum",
3477
+ MAX: "maximum",
3478
+ EXCLUSIVE_MAX: "exclusiveMaximum",
3479
+ MIN_LENGTH: "minLength",
3480
+ MAX_LENGTH: "maxLength",
3481
+ BETWEEN: "between",
3482
+ BETWEEN_EXCLUSIVE_MIN: "betweenExclusiveMin",
3483
+ BETWEEN_EXCLUSIVE_MAX: "betweenExclusiveMax",
3484
+ BETWEEN_EXCLUSIVE_MINMAX: "betweenExclusiveMinMax",
3485
+ REQUIRED: "required"
3486
+ };
3487
+ const FIELD_PREFIX = "dff";
3488
+ const RENDER_TEMPLATE = {
3489
+ number: NumberRender,
3490
+ textarea: TextAreaRender,
3491
+ dropdown: DropdownRender,
3492
+ checkbox: CheckboxRender,
3493
+ radio: RadioRender,
3494
+ text: TextRender,
3495
+ password: PasswordRender,
3496
+ file: FileRender,
3497
+ custom: CustomRender,
3498
+ group: GroupRender,
3499
+ hidden: HiddenRender,
3500
+ button: ButtonRender,
3501
+ range: RangeRender,
3502
+ datehour: DateRender,
3503
+ datemonth: DateRender,
3504
+ date: DateRender,
3505
+ datetime: DateRender,
3506
+ tab: TabRender,
3507
+ grid: GridRender
3508
+ };
3509
+ const OrientationMap = {
3510
+ horizontal: "horizontal"
3511
+ };
3512
+ const FIELD_POSITION_STYLE = {
3513
+ "top-left": ["top", "df-txt-left"],
3514
+ "top-center": ["top", "df-txt-center"],
3515
+ "top-right": ["top", "df-txt-right"],
3516
+ "left-left": ["", "df-txt-left"],
3517
+ "left-center": ["", "df-txt-center"],
3518
+ "left-right": ["", "df-txt-right"],
3519
+ "right-right": ["right", "df-txt-right"],
3520
+ "right-center": ["right", "df-txt-center"],
3521
+ "right-left": ["right", "df-txt-left"],
3522
+ "bottom-left": ["bottom", "df-txt-left"],
3523
+ "bottom-center": ["bottom", "df-txt-center"],
3524
+ "bottom-right": ["bottom", "df-txt-right"]
3525
+ };
3526
+ FIELD_POSITION_STYLE["top"] = FIELD_POSITION_STYLE["top-left"];
3527
+ FIELD_POSITION_STYLE["right"] = FIELD_POSITION_STYLE["right-right"];
3528
+ FIELD_POSITION_STYLE["left"] = FIELD_POSITION_STYLE["left-left"];
3529
+ FIELD_POSITION_STYLE["bottom"] = FIELD_POSITION_STYLE["bottom-left"];
3530
+ let localeMessage = {
3531
+ required: "{label} 필수 입력사항입니다.",
3532
+ fileButton: "파일찾기",
3533
+ selection: "선택",
3534
+ string: {
3535
+ minLength: "{minLength} 글자 이상으로 입력하세요.",
3536
+ maxLength: "{maxLength} 글자 이하로 입력하세요.",
3537
+ between: "{minLength} ~ {maxLength} 사이의 글자를 입력하세요."
3538
+ },
3539
+ number: {
3540
+ nan: "숫자만 입력 가능 합니다.",
3541
+ minimum: "{minimum} 값과 같거나 커야 합니다",
3542
+ exclusiveMinimum: "{minimum} 보다 커야 합니다",
3543
+ maximum: "{maximum} 값과 같거나 작아야 합니다",
3544
+ exclusiveMaximum: "{maximum} 보다 작아야 합니다.",
3545
+ between: "{minimum}~{maximum} 사이의 값을 입력하세요.",
3546
+ betweenExclusiveMin: "{minimum} 보다 크고 {maximum} 보다 같거나 작아야 합니다",
3547
+ betweenExclusiveMax: "{minimum} 보다 같거나 크고 {maximum} 보다 작아야 합니다",
3548
+ betweenExclusiveMinMax: "{minimum} 보다 크고 {maximum} 보다 작아야 합니다"
3549
+ },
3550
+ regexp: {
3551
+ mobile: "핸드폰 번호가 유효하지 않습니다.",
3552
+ email: "이메일이 유효하지 않습니다.",
3553
+ url: "URL이 유효하지 않습니다.",
3554
+ alpha: "영문만 입력 가능 합니다.",
3555
+ "alpha-num": "영문과 숫자만 입력 가능 합니다.",
3556
+ number: "숫자만 입력 가능 합니다.",
3557
+ variable: "값이 유효하지 않습니다.",
3558
+ "number-char": "숫자, 문자 각각 하나 이상 포함 되어야 합니다.",
3559
+ "upper-char": "대문자가 하나 이상 포함 되어야 합니다.",
3560
+ "upper-char-special": "대문자,소문자,특수문자 각각 하나 이상 포함 되어야 합니다.",
3561
+ "upper-char-special-number": "대문자,소문자,특수문자,숫자 각각 하나 이상 포함 되어야합니다."
3562
+ }
3563
+ };
3564
+ class Language {
3565
+ constructor() {
3566
+ this.lang = localeMessage;
3567
+ }
3568
+ /**
3569
+ * 다국어 메시지 등록
3570
+ *
3571
+ * @public
3572
+ * @param {?Message} [lang] 둥록할 메시지
3573
+ */
3574
+ set(lang) {
3575
+ this.lang = Object.assign({}, localeMessage, lang);
3576
+ }
3577
+ /**
3578
+ * 메시지 얻기
3579
+ *
3580
+ * @public
3581
+ * @param {string} messageKey 메시지 키
3582
+ * @returns {*}
3583
+ */
3584
+ getMessage(messageKey) {
3585
+ return this.lang[messageKey];
3586
+ }
3587
+ /**
3588
+ * ValidResult 값을 메시지로 변경.
3589
+ *
3590
+ * @public
3591
+ * @param {FormField} field
3592
+ * @param {ValidResult} validResult
3593
+ * @returns {string[]}
3594
+ */
3595
+ validMessage(field, validResult) {
3596
+ let messageFormat = "";
3597
+ let messageFormats = [];
3598
+ if (validResult.regexp) {
3599
+ messageFormat = this.lang.regexp[validResult.regexp];
3600
+ messageFormats.push(messageFormat);
3601
+ }
3602
+ (validResult.constraint ?? []).forEach((constraint) => {
3603
+ if (constraint === RULES.REQUIRED) {
3604
+ messageFormat = message(this.lang.required, field);
3605
+ messageFormats.push(messageFormat);
3606
+ }
3607
+ if (field.renderType == "number" || field.renderType == "range") {
3608
+ messageFormat = this.lang.number[constraint];
3609
+ messageFormats.push(messageFormat);
3610
+ } else {
3611
+ messageFormat = this.lang.string[constraint];
3612
+ messageFormats.push(messageFormat);
3613
+ }
3614
+ });
3615
+ const reMessage = [];
3616
+ const msgParam = Object.assign({}, { name: field.name, label: field.label }, field.rule);
3617
+ messageFormats.forEach((msgFormat) => {
3618
+ if (msgFormat) {
3619
+ reMessage.push(message(msgFormat, msgParam));
3620
+ }
3621
+ });
3622
+ if (validResult.validator) {
3623
+ reMessage.push(validResult.validator.message);
3624
+ }
3625
+ return reMessage;
3626
+ }
3627
+ }
3628
+ function message(msgFormat, msgParam) {
3629
+ return msgFormat.replace(/\{{1,1}([A-Za-z0-9_.]*)\}{1,1}/g, (match, key) => {
3630
+ return typeof msgParam[key] !== "undefined" ? msgParam[key] : match;
3631
+ });
3632
+ }
3633
+ const Language$1 = new Language();
3634
+ const getRenderer = (field) => {
3635
+ let render;
3636
+ if (field.renderType) {
3637
+ render = RENDER_TEMPLATE[field.renderType];
3638
+ }
3639
+ if (render && (render.isDataRender() === false || !isUndefined(field.name))) {
3640
+ return render;
3641
+ }
3642
+ if (isUndefined(field.name)) {
3643
+ if (field.children) {
3644
+ return RENDER_TEMPLATE["group"];
3645
+ } else {
3646
+ return RENDER_TEMPLATE["hidden"];
3647
+ }
3648
+ }
3649
+ return RENDER_TEMPLATE["text"];
3650
+ };
3651
+ class FieldInfoMap {
3652
+ constructor(selector, form) {
3653
+ this.fieldIdx = 0;
3654
+ this.allFieldInfo = {};
3655
+ this.keyNameMap = {};
3656
+ this.conditionFields = [];
3657
+ this.fieldPrefix = `${FIELD_PREFIX}_${getHashCode(selector)}`;
3658
+ this.form = form;
3659
+ }
3660
+ /**
3661
+ * add Field 정보
3662
+ *
3663
+ * @public
3664
+ * @param {FormField} field 폼필드 정보
3665
+ */
3666
+ addField(field) {
3667
+ replaceXssField(field);
3668
+ this.fieldIdx += 1;
3669
+ field.$key = `${this.fieldPrefix}_${this.fieldIdx}`;
3670
+ field.$validName = field.name ?? field.label;
3671
+ this.keyNameMap[field.$validName] = field.$key;
3672
+ this.allFieldInfo[field.$key] = field;
3673
+ field.$renderType = getRenderer(field);
3674
+ if (field.conditional) {
3675
+ this.conditionFields.push(field.$key);
3676
+ }
3677
+ }
3678
+ /**
3679
+ * 필드명으로 필드 정부 구하기
3680
+ *
3681
+ * @public
3682
+ * @param {string} fieldName 필드명
3683
+ * @returns {FormField}
3684
+ */
3685
+ getFieldName(fieldName) {
3686
+ return this.allFieldInfo[this.keyNameMap[fieldName]];
3687
+ }
3688
+ /**
3689
+ * 필드 키로 정보 구하기
3690
+ *
3691
+ * @public
3692
+ * @param {string} fieldKey
3693
+ * @returns {FormField}
3694
+ */
3695
+ get(fieldKey) {
3696
+ return this.allFieldInfo[fieldKey];
3697
+ }
3698
+ /**
3699
+ * 필드명 있는지 여부 체크.
3700
+ *
3701
+ * @public
3702
+ * @param {string} fieldName 필드명
3703
+ * @returns {boolean}
3704
+ */
3705
+ hasFieldName(fieldName) {
3706
+ if (this.keyNameMap[fieldName] && this.allFieldInfo[this.keyNameMap[fieldName]]) {
3707
+ return true;
3708
+ }
3709
+ return false;
3710
+ }
3711
+ /**
3712
+ * 모든 필드 정보
3713
+ *
3714
+ * @public
3715
+ * @returns {NumberFieldMap}
3716
+ */
3717
+ getAllFieldInfo() {
3718
+ return this.allFieldInfo;
3719
+ }
3720
+ /**
3721
+ * 필드 정보 맵에서 지우기
3722
+ *
3723
+ * @public
3724
+ * @param {string} fieldName
3725
+ */
3726
+ removeFieldInfo(fieldName) {
3727
+ const fieldKey = this.keyNameMap[fieldName];
3728
+ if (isUndefined(fieldKey)) return;
3729
+ this.removeFieldInfoByKey(fieldKey);
3730
+ delete this.keyNameMap[fieldName];
3731
+ }
3732
+ /**
3733
+ * 필드 키로 필드 정보 맵에서 지우기
3734
+ *
3735
+ * @public
3736
+ * @param {string} fieldKey
3737
+ */
3738
+ removeFieldInfoByKey(fieldKey) {
3739
+ const fieldInfo = this.allFieldInfo[fieldKey];
3740
+ if (fieldInfo && this.keyNameMap[fieldInfo.$validName] === fieldKey) {
3741
+ delete this.keyNameMap[fieldInfo.$validName];
3742
+ }
3743
+ delete this.allFieldInfo[fieldKey];
3744
+ this.conditionFields = this.conditionFields.filter((key) => key !== fieldKey);
3745
+ }
3746
+ /**
3747
+ * 모든 필드값 구하기
3748
+ *
3749
+ * @public
3750
+ * @param {boolean} validationCheck
3751
+ * @returns {*}
3752
+ */
3753
+ getAllFieldValue(formValue, validationCheck) {
3754
+ const useTypeValue = this.form.getOptions().useTypeValue;
3755
+ if (validationCheck !== true) {
3756
+ for (let [key, fieldInfo] of Object.entries(this.allFieldInfo)) {
3757
+ formValue = addFormValue(formValue, fieldInfo, useTypeValue);
3758
+ }
3759
+ return formValue;
3760
+ }
3761
+ return new Promise((resolve, reject) => {
3762
+ for (let [key, fieldInfo] of Object.entries(this.allFieldInfo)) {
3763
+ if (!fieldInfo.$instance.isEnableView()) {
3764
+ continue;
3765
+ }
3766
+ let fieldValid = this.getFieldValidation(fieldInfo, true);
3767
+ if (fieldValid !== true) {
3768
+ reject(new Error(fieldValid.message, { cause: fieldValid }));
3769
+ return;
3770
+ }
3771
+ formValue = addFormValue(formValue, fieldInfo, useTypeValue);
3772
+ }
3773
+ resolve(formValue);
3774
+ });
3775
+ }
3776
+ getFormDataValue(formValue, validationCheck) {
3777
+ if (validationCheck !== true) {
3778
+ let reval = new FormData();
3779
+ for (let [key, value] of Object.entries(formValue)) {
3780
+ reval.set(key, value);
3781
+ }
3782
+ for (let [key, fieldInfo] of Object.entries(this.allFieldInfo)) {
3783
+ addFieldFormData(reval, fieldInfo, fieldInfo.$instance.getValue());
3784
+ }
3785
+ return reval;
3786
+ }
3787
+ return new Promise((resolve, reject) => {
3788
+ let reval = new FormData();
3789
+ for (let [key, value] of Object.entries(formValue)) {
3790
+ reval.set(key, value);
3791
+ }
3792
+ for (let [key, fieldInfo] of Object.entries(this.allFieldInfo)) {
3793
+ if (!fieldInfo.$instance.isEnableView()) {
3794
+ continue;
3795
+ }
3796
+ let fieldValid = this.getFieldValidation(fieldInfo, true);
3797
+ if (fieldValid !== true) {
3798
+ reject(new Error(fieldValid.message, { cause: fieldValid }));
3799
+ return;
3800
+ }
3801
+ addFieldFormData(reval, fieldInfo, fieldInfo.$instance.getValue());
3802
+ }
3803
+ resolve(reval);
3804
+ });
3805
+ }
3806
+ /**
3807
+ *
3808
+ *
3809
+ * @param field
3810
+ * @returns
3811
+ */
3812
+ isConditionFieldCheck(field) {
3813
+ let parent = field;
3814
+ while (typeof parent !== "undefined") {
3815
+ if (!this.isConditionField(parent)) {
3816
+ return false;
3817
+ }
3818
+ parent = parent.$parent;
3819
+ }
3820
+ return true;
3821
+ }
3822
+ /**
3823
+ * field 활성 비활성화 여부.
3824
+ *
3825
+ * @param field form field
3826
+ * @returns
3827
+ */
3828
+ isConditionField(field) {
3829
+ if (!this.conditionFields.includes(field.$key)) {
3830
+ return true;
3831
+ }
3832
+ let condFlag = false;
3833
+ if (field.conditional.custom) {
3834
+ condFlag = field.conditional.custom.call(null, field);
3835
+ } else {
3836
+ if (field.conditional.field) {
3837
+ const condField = this.getFieldName(field.conditional.field);
3838
+ if (condField) {
3839
+ if (field.conditional.eq == condField.$instance.getValue()) {
3840
+ condFlag = true;
3841
+ }
3842
+ }
3843
+ }
3844
+ }
3845
+ return condFlag;
3846
+ }
3847
+ /**
3848
+ * 컬럼 로우 보이고 안보이기 체크.
3849
+ *
3850
+ * @public
3851
+ */
3852
+ conditionCheck() {
3853
+ this.conditionFields.forEach((fieldKey) => {
3854
+ const fieldInfo = this.allFieldInfo[fieldKey];
3855
+ let condFlag = this.isConditionField(fieldInfo);
3856
+ if (condFlag) {
3857
+ fieldInfo.$instance.show();
3858
+ } else {
3859
+ fieldInfo.$instance.hide();
3860
+ }
3861
+ });
3862
+ }
3863
+ /**
3864
+ * field validation check
3865
+ *
3866
+ * @param fieldInfo FormField
3867
+ * @returns boolean true or ValidResult
3868
+ */
3869
+ getFieldValidation(fieldInfo, focusFlag) {
3870
+ if (!this.isConditionFieldCheck(fieldInfo)) {
3871
+ return true;
3872
+ }
3873
+ const renderInfo = fieldInfo.$instance;
3874
+ let fieldValid = renderInfo.valid();
3875
+ if (fieldValid === true) return true;
3876
+ if (focusFlag) {
3877
+ renderInfo.focus();
3878
+ }
3879
+ fieldValid = fieldValid;
3880
+ if (isUndefined(fieldValid.message)) {
3881
+ fieldValid.message = Language$1.validMessage(fieldInfo, fieldValid)[0];
3882
+ }
3883
+ return fieldValid;
3884
+ }
3885
+ }
3886
+ function addFormValue(formData, fieldInfo, useTypeValue) {
3887
+ if (ignoreValueField(fieldInfo)) {
3888
+ return formData;
3889
+ }
3890
+ const fieldValue = fieldInfo.$instance.getValue();
3891
+ if (fieldInfo.renderType === "file") {
3892
+ const uploadFiles = fieldValue["uploadFile"];
3893
+ formData[fieldInfo.$validName] = uploadFiles;
3894
+ formData[fieldInfo.$validName + "RemoveIds"] = fieldValue["removeIds"];
3895
+ } else {
3896
+ if (useTypeValue !== true) {
3897
+ if (isTabType(fieldInfo)) {
3898
+ for (let [key, value] of Object.entries(fieldValue)) {
3899
+ formData[key] = value;
3900
+ }
3901
+ } else {
3902
+ if (!isEmpty(fieldInfo.name)) {
3903
+ formData[fieldInfo.name] = fieldValue;
3904
+ }
3905
+ }
3906
+ } else {
3907
+ formData[fieldInfo.$validName] = fieldValue;
3908
+ }
3909
+ }
3910
+ return formData;
3911
+ }
3912
+ function addFieldFormData(formData, fieldInfo, useTypeValue) {
3913
+ if (ignoreValueField(fieldInfo)) {
3914
+ return formData;
3915
+ }
3916
+ const fieldValue = fieldInfo.$instance.getValue();
3917
+ if (fieldInfo.renderType === "file") {
3918
+ const uploadFiles = fieldValue["uploadFile"];
3919
+ formData.delete(fieldInfo.$validName);
3920
+ for (let uploadFile of uploadFiles) {
3921
+ formData.append(fieldInfo.$validName, uploadFile);
3922
+ }
3923
+ formData.set(fieldInfo.$validName + "RemoveIds", fieldValue["removeIds"]);
3924
+ } else {
3925
+ if (useTypeValue !== true) {
3926
+ if (isTabType(fieldInfo)) {
3927
+ for (let [key, value] of Object.entries(fieldValue)) {
3928
+ formData.set(key, value);
3929
+ }
3930
+ } else {
3931
+ if (!isEmpty(fieldInfo.name)) {
3932
+ formData.set(fieldInfo.$validName, fieldValue);
3933
+ }
3934
+ }
3935
+ } else {
3936
+ formData.set(fieldInfo.$validName, fieldValue);
3937
+ }
3938
+ }
3939
+ return formData;
3940
+ }
3941
+ class FormTemplate {
3942
+ constructor(daraform, formElement, fieldInfoMap) {
3943
+ this.addRowFields = [];
3944
+ this.daraform = daraform;
3945
+ this.options = daraform.getOptions();
3946
+ this.formElement = formElement;
3947
+ this.fieldInfoMap = fieldInfoMap;
3948
+ }
3949
+ /**
3950
+ * field row 추가.
3951
+ *
3952
+ * @param field
3953
+ */
3954
+ addRow(field) {
3955
+ if (this.checkHiddenField(field)) {
3956
+ return;
3957
+ }
3958
+ this.addRowFields = [];
3959
+ this.addRowTemplate(field);
3960
+ }
3961
+ /**
3962
+ * 그룹 템플릿
3963
+ *
3964
+ * @param {FormField} field
3965
+ * @returns {string} row template
3966
+ */
3967
+ addRowTemplate(field) {
3968
+ let labelHideFlag = this.isLabelHide(field);
3969
+ let fieldStyle = resolveFieldStyle(this.options, field, null, labelHideFlag);
3970
+ this.addRowFieldInfo(field);
3971
+ const rowElement = templateToElement(`
3972
+ <div class="df-row df-form-group ${fieldStyle.fieldClass}" id="${field.$key}">
3973
+ ${labelHideFlag ? "" : `<div class="df-label ${fieldStyle.labelClass} ${fieldStyle.labelAlignClass}" title="${field.label ?? ""}" style="${fieldStyle.labelStyle}">${this.getLabelTemplate(field)}</div>`}
3974
+
3975
+ <div class="df-field-container ${fieldStyle.valueClass} ${field.required ? "required" : ""}" style="${fieldStyle.valueStyle}"></div>
3976
+ </div>
3977
+ `);
3978
+ if (rowElement) {
3979
+ this.createField(field, rowElement);
3980
+ this.formElement.append(rowElement);
3981
+ if (field.children) {
3982
+ this.childTemplate(field, fieldStyle);
3983
+ }
3984
+ }
3985
+ }
3986
+ createField(field, element) {
3987
+ field.$instance = new field.$renderType(field, element, this.daraform);
3988
+ }
3989
+ /**
3990
+ * child template
3991
+ *
3992
+ * @param {FormField} field
3993
+ * @param {FieldStyle} parentFieldStyle
3994
+ * @returns {*}
3995
+ */
3996
+ childTemplate(field, parentFieldStyle) {
3997
+ let beforeField = null;
3998
+ let firstFlag = true;
3999
+ let isEmptyLabel = false;
4000
+ if (!field.$renderType.isChildrenCreate()) {
4001
+ return;
4002
+ }
4003
+ const rowElement = document.createElement("div");
4004
+ rowElement.classList.add("df-row", parentFieldStyle.rowStyleClass ?? "");
4005
+ let idx = 0;
4006
+ for (const childField of field.children) {
4007
+ if (isEmpty(childField)) {
4008
+ throw new Error(`parent field :[${field.$validName}], children index ${idx}, empty [${childField}]`);
4009
+ }
4010
+ childField.$parent = field;
4011
+ ++idx;
4012
+ if (this.checkHiddenField(childField)) {
4013
+ continue;
4014
+ }
4015
+ this.addRowFieldInfo(childField);
4016
+ if (firstFlag) {
4017
+ beforeField = childField;
4018
+ }
4019
+ let labelHideFlag = this.isLabelHide(childField);
4020
+ let childFieldStyle;
4021
+ let labelTemplate = "";
4022
+ if (labelHideFlag) {
4023
+ childFieldStyle = resolveFieldStyle(this.options, childField, beforeField, !isEmptyLabel);
4024
+ labelTemplate = isEmptyLabel ? `<span class="df-label df-empty ${childFieldStyle.labelClass}" style="${childFieldStyle.labelStyle}"></span>` : "";
4025
+ } else {
4026
+ childFieldStyle = resolveFieldStyle(this.options, childField, beforeField, false);
4027
+ labelTemplate = `<span class="df-label ${childFieldStyle.labelClass} ${childFieldStyle.labelAlignClass}" title="${childField.label ?? ""}" style="${childFieldStyle.labelStyle}">${this.getLabelTemplate(childField)}</span>`;
4028
+ }
4029
+ const groupElement = templateToElement(`<div class="df-form-group ${childFieldStyle.fieldClass}" style="${childFieldStyle.fieldStyle}" id="${childField.$key}">
4030
+ ${labelTemplate}
4031
+ <span class="df-field-container ${childFieldStyle.valueClass} ${childField.required ? "required" : ""}" style="${childFieldStyle.valueStyle}"></span>
4032
+ </div>`);
4033
+ if (groupElement) {
4034
+ this.createField(childField, groupElement);
4035
+ rowElement.append(groupElement);
4036
+ if (childField.children) {
4037
+ this.childTemplate(childField, childField.children ? childFieldStyle : parentFieldStyle);
4038
+ }
4039
+ }
4040
+ if (!labelHideFlag) {
4041
+ isEmptyLabel = true;
4042
+ }
4043
+ firstFlag = false;
4044
+ }
4045
+ field.$instance.addChildField(rowElement);
4046
+ }
4047
+ /**
4048
+ * label template
4049
+ *
4050
+ * @param {FormField} field form field
4051
+ * @returns {string} template string
4052
+ */
4053
+ getLabelTemplate(field) {
4054
+ const requiredTemplate = field.required ? `<span class="required"></span>` : "";
4055
+ const tooltipTemplate = isBlank(field.tooltip) ? "" : `<span class="df-tooltip">?<span class="df-tooltip-text">${field.tooltip}</span></span>`;
4056
+ return `${field.label ?? ""} ${tooltipTemplate} ${requiredTemplate}`;
4057
+ }
4058
+ /**
4059
+ * label 숨김 여부
4060
+ *
4061
+ * @param field formfield
4062
+ * @returns
4063
+ */
4064
+ isLabelHide(field) {
4065
+ var _a;
4066
+ return ((_a = field.style) == null ? void 0 : _a.labelHide) || isUndefined(field.label);
4067
+ }
4068
+ checkHiddenField(field) {
4069
+ if (isHiddenField(field)) {
4070
+ this.fieldInfoMap.addField(field);
4071
+ field.$instance = new field.$renderType(field, null, this.daraform);
4072
+ return true;
4073
+ }
4074
+ return false;
4075
+ }
4076
+ /**
4077
+ * add row file map
4078
+ *
4079
+ * @param {FormField} field
4080
+ */
4081
+ addRowFieldInfo(field) {
4082
+ if (!isBlank(field.name) && this.fieldInfoMap.hasFieldName(field.name)) {
4083
+ throw new Error(`Duplicate field name "${field.name}"`);
4084
+ }
4085
+ this.fieldInfoMap.addField(field);
4086
+ this.addRowFields.push(field.$key);
4087
+ }
4088
+ }
4089
+ function initFormOptions(options) {
4090
+ const opts = merge({}, DEFAULT_OPTIONS, options);
4091
+ return opts;
4092
+ }
4093
+ function setDefaultOptions(options) {
4094
+ DEFAULT_OPTIONS = merge({}, DEFAULT_OPTIONS, options);
4095
+ }
4096
+ let DEFAULT_OPTIONS = {
4097
+ style: {
4098
+ width: "100%",
4099
+ labelWidth: 3,
4100
+ valueWidth: 9,
4101
+ position: "left-right"
4102
+ },
4103
+ mode: "new",
4104
+ useTypeValue: true,
4105
+ autoCreate: true,
4106
+ notValidMessage: "This form is not valid.",
4107
+ fields: []
4108
+ };
4109
+ const allInstance = {};
4110
+ const SEQ_ATTR_KEY = "data-form-uid";
4111
+ let DARA_FORM_SEQ = 0;
4112
+ const _DaraForm = class _DaraForm {
4113
+ constructor(formElement, options, message2) {
4114
+ this.formValue = {};
4115
+ this.changeListeners = [];
4116
+ this.changeMode = (mode) => {
4117
+ this.options.mode = mode;
4118
+ this.formElement.setAttribute("data-df-mode", mode);
4119
+ };
4120
+ this.resetForm = () => {
4121
+ const fieldMap = this.fieldInfoMap.getAllFieldInfo();
4122
+ for (const seq in fieldMap) {
4123
+ const fieldInfo = fieldMap[seq];
4124
+ const renderInfo = fieldInfo.$instance;
4125
+ if (renderInfo && typeof renderInfo.reset === "function") {
4126
+ renderInfo.reset();
4127
+ }
4128
+ }
4129
+ this.formValue = {};
4130
+ this.conditionCheck();
4131
+ };
4132
+ this.resetField = (fieldName) => {
4133
+ this.fieldInfoMap.getFieldName(fieldName).$instance.reset();
4134
+ this.formValue[fieldName] = "";
4135
+ this.conditionCheck();
4136
+ };
4137
+ this.getFieldValue = (fieldName) => {
4138
+ const field = this.fieldInfoMap.getFieldName(fieldName);
4139
+ if (field) {
4140
+ return field.$instance.getValue();
4141
+ }
4142
+ return null;
4143
+ };
4144
+ this.getValue = (isValid) => {
4145
+ return this.fieldInfoMap.getAllFieldValue(this.formValue, isValid);
4146
+ };
4147
+ this.getFormDataValue = (isValid) => {
4148
+ return this.fieldInfoMap.getFormDataValue(this.formValue, isValid);
4149
+ };
4150
+ this.setValue = (values, dataClear) => {
4151
+ if (dataClear !== false) {
4152
+ this.resetForm();
4153
+ }
4154
+ Object.keys(values).forEach((fieldName) => {
4155
+ this._setFieldValue(fieldName, values[fieldName]);
4156
+ });
4157
+ this.conditionCheck();
4158
+ };
4159
+ this.setFieldValue = (fieldName, value) => {
4160
+ this._setFieldValue(fieldName, value);
4161
+ this.conditionCheck();
4162
+ };
4163
+ this.setFieldItems = (fieldName, values) => {
4164
+ const field = this.fieldInfoMap.getFieldName(fieldName);
4165
+ if (field) {
4166
+ return field.$instance.setValueItems(values);
4167
+ }
4168
+ };
4169
+ this.addField = (field) => {
4170
+ this.options.fields.push(field);
4171
+ this.formTemplate.addRow(field);
4172
+ this.conditionCheck();
4173
+ };
4174
+ this.removeField = (fieldName) => {
4175
+ const fieldInfo = this.fieldInfoMap.getFieldName(fieldName);
4176
+ if (!fieldInfo) return;
4177
+ const removeFields = this.getRemoveFields(fieldInfo);
4178
+ removeFields.forEach((removeField) => {
4179
+ this.removeFormValue(removeField);
4180
+ });
4181
+ this.removeFieldElement(fieldInfo);
4182
+ this.removeParentChildField(fieldInfo);
4183
+ removeFields.forEach((removeField) => {
4184
+ this.fieldInfoMap.removeFieldInfoByKey(removeField.$key);
4185
+ });
4186
+ this.conditionCheck();
4187
+ };
4188
+ this.isValidForm = () => {
4189
+ const result = this.validForm();
4190
+ return result.length < 1;
4191
+ };
4192
+ this.validForm = () => {
4193
+ let validResult = [];
4194
+ let autoFocusFlag = this.options.autoFocus !== false;
4195
+ let firstFlag = true;
4196
+ const fieldMap = this.fieldInfoMap.getAllFieldInfo();
4197
+ for (const fieldKey in fieldMap) {
4198
+ const fieldInfo = fieldMap[fieldKey];
4199
+ let fieldValid = this.fieldInfoMap.getFieldValidation(fieldInfo, autoFocusFlag);
4200
+ if (fieldValid !== true) {
4201
+ autoFocusFlag = false;
4202
+ if (isGridType(fieldInfo)) {
4203
+ validResult = validResult.concat(fieldValid);
4204
+ } else {
4205
+ if (firstFlag) {
4206
+ this.validTabCheck(fieldInfo);
4207
+ firstFlag = false;
4208
+ }
4209
+ validResult.push(fieldValid);
4210
+ }
4211
+ }
4212
+ }
4213
+ return validResult;
4214
+ };
4215
+ this.isValidField = (fieldName) => {
4216
+ const fieldInfo = this.fieldInfoMap.getFieldName(fieldName);
4217
+ if (isUndefined(fieldInfo)) {
4218
+ throw new Error(`Field name [${fieldName}] not found`);
4219
+ }
4220
+ const renderInfo = fieldInfo.$instance;
4221
+ if (renderInfo) {
4222
+ return renderInfo.valid() === true;
4223
+ }
4224
+ return true;
4225
+ };
4226
+ this.getOptions = () => {
4227
+ return this.options;
4228
+ };
4229
+ this.subscribe = (listener) => {
4230
+ this.changeListeners.push(listener);
4231
+ return () => {
4232
+ this.changeListeners = this.changeListeners.filter((l) => l !== listener);
4233
+ };
4234
+ };
4235
+ this.destroy = () => {
4236
+ this.formElement.className = this.orginFormStyleClass;
4237
+ this.formElement.replaceChildren();
4238
+ for (const key in this) {
4239
+ if (hasOwnProp(this, key)) {
4240
+ delete this[key];
4241
+ delete allInstance[this.selector];
4242
+ }
4243
+ }
4244
+ };
4245
+ this.getFields = () => {
4246
+ return this.options.fields;
4247
+ };
4248
+ this.setFields = (fields) => {
4249
+ this.options.fields = fields;
4250
+ this.createForm(fields);
4251
+ };
4252
+ this.options = initFormOptions(options);
4253
+ Language$1.set(message2);
4254
+ if (formElement) {
4255
+ this.orginFormStyleClass = formElement.className;
4256
+ formElement.classList.add("daracl-form");
4257
+ this.selector = `df_${++DARA_FORM_SEQ}`;
4258
+ formElement.setAttribute("name", this.selector);
4259
+ formElement.setAttribute(SEQ_ATTR_KEY, this.selector);
4260
+ if (this.options.style.width) {
4261
+ formElement.setAttribute("style", `width:${this.options.style.width};`);
4262
+ }
4263
+ this.formElement = formElement;
4264
+ this.changeMode(this.options.mode ?? "new");
4265
+ this.createForm(this.options.fields);
4266
+ if (this.options.autoCreate !== false) {
4267
+ allInstance[this.selector] = this;
4268
+ }
4269
+ } else {
4270
+ throw new Error(`${formElement} form selector not found`);
4271
+ }
4272
+ }
4273
+ static create(formElement, options, message2) {
4274
+ return new _DaraForm(formElement, options, message2);
4275
+ }
4276
+ static setMessage(message2) {
4277
+ Language$1.set(message2);
4278
+ }
4279
+ static setDefaultOptions(options, message2) {
4280
+ setDefaultOptions(options);
4281
+ if (message2) {
4282
+ Language$1.set(message2);
4283
+ }
4284
+ }
4285
+ createForm(fields) {
4286
+ this.fieldInfoMap = new FieldInfoMap(this.selector, this);
4287
+ this.formTemplate = new FormTemplate(this, this.formElement, this.fieldInfoMap);
4288
+ if (this.options.autoCreate === false) {
4289
+ return;
4290
+ }
4291
+ fields.forEach((field) => {
4292
+ this.formTemplate.addRow(field);
4293
+ });
4294
+ this.conditionCheck();
4295
+ if (this.options.onMounted) {
4296
+ this.options.onMounted.call(this);
4297
+ }
4298
+ }
4299
+ /**
4300
+ * 필드 element 얻기
4301
+ *
4302
+ * @param {string} fieldName
4303
+ * @returns {*}
4304
+ */
4305
+ getFieldElement(fieldName) {
4306
+ const field = this.fieldInfoMap.getFieldName(fieldName);
4307
+ if (field == null ? void 0 : field.$instance) {
4308
+ return field.$instance.getElement();
4309
+ }
4310
+ return null;
4311
+ }
4312
+ getField(fieldName) {
4313
+ return this.fieldInfoMap.getFieldName(fieldName);
4314
+ }
4315
+ _setFieldValue(fieldName, value) {
4316
+ this.formValue[fieldName] = value;
4317
+ const fieldInfo = this.fieldInfoMap.getFieldName(fieldName);
4318
+ if (fieldInfo) {
4319
+ fieldInfo.$instance.setValue(value);
4320
+ }
4321
+ }
4322
+ /**
4323
+ * 제거할 필드와 같은 fieldInfoMap에 등록된 하위 필드(group 하위 필드, tab 패널) 목록
4324
+ * grid 컬럼, tab 패널 내부 필드는 별도 form에 등록되므로 제외됨.
4325
+ *
4326
+ * @param {FormField} fieldInfo
4327
+ * @param {FormField[]} result
4328
+ * @returns {FormField[]}
4329
+ */
4330
+ getRemoveFields(fieldInfo, result = []) {
4331
+ var _a;
4332
+ result.push(fieldInfo);
4333
+ (_a = fieldInfo.children) == null ? void 0 : _a.forEach((childField) => {
4334
+ if (childField && this.fieldInfoMap.get(childField.$key) === childField) {
4335
+ this.getRemoveFields(childField, result);
4336
+ }
4337
+ });
4338
+ return result;
4339
+ }
4340
+ /**
4341
+ * field element 제거
4342
+ *
4343
+ * @param {FormField} fieldInfo
4344
+ */
4345
+ removeFieldElement(fieldInfo) {
4346
+ var _a, _b;
4347
+ const parentField = fieldInfo.$parent;
4348
+ if (parentField && isTabType(parentField)) {
4349
+ const tabElement = parentField.$instance.getElement();
4350
+ const tabItem = tabElement.querySelector(`[data-tab-id="${fieldInfo.$key}"]`);
4351
+ const activeFlag = tabItem == null ? void 0 : tabItem.classList.contains("active");
4352
+ tabItem == null ? void 0 : tabItem.remove();
4353
+ (_a = tabElement.querySelector(`[tab-panel-id="${fieldInfo.$key}"]`)) == null ? void 0 : _a.remove();
4354
+ const firstTabItem = tabElement.querySelector(".df-tab-header .df-tab-item");
4355
+ if (activeFlag && firstTabItem) {
4356
+ parentField.$instance.setActive(firstTabItem.getAttribute("data-tab-id") ?? "");
4357
+ }
4358
+ return;
4359
+ }
4360
+ const rowSelector = `[id="${fieldInfo.$key}"]`;
4361
+ let element = (_b = fieldInfo.$instance) == null ? void 0 : _b.getElement();
4362
+ if (element instanceof NodeList || element instanceof HTMLCollection) {
4363
+ element = element[0] ?? null;
4364
+ }
4365
+ const rowElement = (element instanceof Element ? element.closest(rowSelector) : null) ?? this.formElement.querySelector(rowSelector);
4366
+ const containerElement = rowElement == null ? void 0 : rowElement.parentElement;
4367
+ rowElement == null ? void 0 : rowElement.remove();
4368
+ if (parentField && (containerElement == null ? void 0 : containerElement.classList.contains("df-row")) && containerElement.childElementCount < 1) {
4369
+ containerElement.remove();
4370
+ }
4371
+ }
4372
+ /**
4373
+ * 부모 children(최상위는 options.fields)에서 필드 제거
4374
+ * tab 은 children 기준으로 값/유효성 체크를 하므로 제거해야 함.
4375
+ *
4376
+ * @param {FormField} fieldInfo
4377
+ */
4378
+ removeParentChildField(fieldInfo) {
4379
+ const fields = fieldInfo.$parent ? fieldInfo.$parent.children : this.options.fields;
4380
+ const idx = fields ? fields.indexOf(fieldInfo) : -1;
4381
+ if (idx > -1) {
4382
+ fields == null ? void 0 : fields.splice(idx, 1);
4383
+ }
4384
+ }
4385
+ /**
4386
+ * getValue() 시 formValue에 누적된 field 값 제거
4387
+ *
4388
+ * @param {FormField} fieldInfo
4389
+ */
4390
+ removeFormValue(fieldInfo) {
4391
+ const keys = [fieldInfo.name, fieldInfo.$validName];
4392
+ if (fieldInfo.renderType === "file") {
4393
+ keys.push(fieldInfo.$validName + "RemoveIds");
4394
+ } else if (isTabType(fieldInfo)) {
4395
+ keys.push(...Object.keys(fieldInfo.$instance.getValue() ?? {}));
4396
+ }
4397
+ if (fieldInfo.$tabForm) {
4398
+ keys.push(...Object.keys(fieldInfo.$tabForm.getValue(false) ?? {}));
4399
+ }
4400
+ keys.forEach((key) => {
4401
+ if (!isBlank(key)) delete this.formValue[key];
4402
+ });
4403
+ }
4404
+ validTabCheck(fieldInfo) {
4405
+ if (fieldInfo.$parent) {
4406
+ if (fieldInfo.$parent.renderType == "tab") {
4407
+ fieldInfo.$parent.$instance.setActive(fieldInfo.$key);
4408
+ }
4409
+ this.validTabCheck(fieldInfo.$parent);
4410
+ }
4411
+ }
4412
+ conditionCheck() {
4413
+ this.fieldInfoMap.conditionCheck();
4414
+ this.notifyChange();
4415
+ }
4416
+ notifyChange() {
4417
+ if (this.changeListeners.length < 1) return;
4418
+ const event = { form: this };
4419
+ this.changeListeners.forEach((listener) => listener(event));
4420
+ }
4421
+ setFieldDisabled(fieldName, flag) {
4422
+ const fieldInfo = this.fieldInfoMap.getFieldName(fieldName);
4423
+ fieldInfo.$instance.setDisabled(flag);
4424
+ }
4425
+ /**
4426
+ * 설명 추가
4427
+ *
4428
+ * @public
4429
+ * @param {string} fieldName
4430
+ * @param {string} desc
4431
+ */
4432
+ setFieldDescription(fieldName, desc) {
4433
+ const fieldInfo = this.fieldInfoMap.getFieldName(fieldName);
4434
+ fieldInfo.$instance.setDescription(desc);
4435
+ }
4436
+ static instance(ele) {
4437
+ let element;
4438
+ if (isString(ele)) {
4439
+ element = document.querySelector(ele);
4440
+ } else {
4441
+ element = ele;
4442
+ }
4443
+ element = element;
4444
+ let selector = element.getAttribute(SEQ_ATTR_KEY);
4445
+ if (isUndefined(selector) || isBlank(selector)) {
4446
+ const keys = Object.keys(allInstance);
4447
+ if (keys.length > 1) {
4448
+ throw new Error(`selector empty : [${selector}]`);
4449
+ }
4450
+ selector = keys[0];
4451
+ return allInstance[selector];
4452
+ }
4453
+ }
4454
+ getFieldInfoMap() {
4455
+ return this.fieldInfoMap;
4456
+ }
4457
+ };
4458
+ _DaraForm.VERSION = `${"0.0.18"}`;
4459
+ _DaraForm.validator = {
4460
+ string: (value, field) => {
4461
+ return stringValidator(value, field);
4462
+ },
4463
+ number: (value, field) => {
4464
+ return numberValidator(value, field);
4465
+ },
4466
+ regexp: (value, field) => {
4467
+ let result = { name: field.name, constraint: [] };
4468
+ return regexpValidator(value, field, result);
4469
+ }
4470
+ };
4471
+ let DaraForm = _DaraForm;
4472
+ if (typeof window !== "undefined") {
4473
+ window.Daracl = window.Daracl || {};
4474
+ window.Daracl.form = DaraForm;
4475
+ }
4476
+ });
4477
+ //# sourceMappingURL=daracl.form.umd.js.map