@daracl/form 0.0.1

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