@daracl/form 0.0.19 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,59 +1,17 @@
1
- import { isArray as isArray$1, leftPad, isNumeric, leftPadClamp, isFunction as isFunction$1 } from "@daracl/core";
2
- const xssFilter = {
3
- "&": "&",
4
- "<": "&lt;",
5
- ">": "&gt;",
6
- '"': "&quot;",
7
- "'": "&#39;"
8
- };
9
- const replaceXss = (inputText) => {
10
- let returnText = inputText;
11
- if (returnText) {
12
- Object.keys(xssFilter).forEach((key) => {
13
- returnText = returnText.replaceAll(key, xssFilter[key]);
14
- });
15
- }
16
- return returnText;
17
- };
18
- const hasOwnProp = (obj, key) => {
19
- return obj.hasOwnProperty(key);
20
- };
21
- const isBlank = (value) => {
22
- if (value === null) return true;
23
- if (value === "") return true;
24
- if (typeof value === "undefined") return true;
25
- if (typeof value === "string" && (value === "" || value.replace(/\s/g, "") === "")) return true;
26
- return false;
27
- };
28
- const isUndefined = (value) => {
29
- return typeof value === "undefined";
30
- };
31
- const isFunction = (value) => {
32
- return typeof value === "function";
33
- };
34
- const isString = (value) => {
35
- return typeof value === "string";
36
- };
1
+ import { xss, isPlainObject, objectDeepMerge, isUndefined, isBlank, isNumeric, isString, isArray, isNil, resolveClassName, isFunction, templateToElement, hasProperty, getHashCode } from "@daracl/core/utils";
2
+ import { DateTimePicker } from "@daracl/datetimepicker";
37
3
  const isNumber = (value) => {
38
- if (isBlank(value)) {
39
- return false;
40
- }
41
- value = +value;
42
- return !isNaN(value);
43
- };
44
- const isArray = (value) => {
45
- return isArray$1(value);
4
+ return !isBlank(value) && isNumeric(+value, true);
46
5
  };
47
- const isEmpty = (value) => isUndefined(value) || value == null;
48
6
  const isTabType = (field) => {
49
- return field && field.renderType === "tab";
7
+ return (field == null ? void 0 : field.renderType) === "tab";
50
8
  };
51
9
  const isGridType = (field) => {
52
- return field && field.renderType === "grid";
10
+ return (field == null ? void 0 : field.renderType) === "grid";
53
11
  };
54
12
  const replaceXssField = (field) => {
55
13
  field.$xssName = getXssFieldName(field);
56
- field.label = replaceXss(field.label);
14
+ field.label = xss(field.label);
57
15
  return field;
58
16
  };
59
17
  const ignoreValueField = (field) => {
@@ -63,120 +21,17 @@ const getXssFieldName = (field) => {
63
21
  if (isUndefined(field.$xssName)) {
64
22
  let returnText = field.name;
65
23
  if (returnText) {
66
- Object.keys(xssFilter).forEach((key) => {
67
- returnText = returnText.replaceAll(key, "_");
68
- });
24
+ returnText = returnText.replace(/[&<>"']/g, "_");
69
25
  }
70
26
  return "df_" + returnText;
71
27
  }
72
28
  return field.$xssName;
73
29
  };
74
- const getHashCode = (str) => {
75
- let hash = 0;
76
- if (str.length == 0) return hash;
77
- for (let i = 0; i < str.length; i++) {
78
- let tmpChar = str.charCodeAt(i);
79
- hash = (hash << 5) - hash + tmpChar;
80
- hash = hash & hash;
81
- }
82
- return String(hash).replaceAll(/-/g, "_");
83
- };
84
- const isHiddenField = (field) => {
85
- if (field.renderType === "hidden") {
86
- return true;
87
- }
88
- return false;
89
- };
90
- const templateToElement = (htmlTemplate) => {
91
- const template = document.createElement("template");
92
- template.innerHTML = htmlTemplate;
93
- return template.content.firstElementChild;
94
- };
95
- function isPlainObject(obj) {
96
- if (typeof obj !== "object" || obj === null) {
97
- return false;
98
- }
99
- let proto = obj;
100
- while (Object.getPrototypeOf(proto) !== null) {
101
- proto = Object.getPrototypeOf(proto);
102
- }
103
- return Object.getPrototypeOf(obj) === proto;
104
- }
105
- function isObject(value) {
106
- return typeof value === "object" && value !== null && !isArray(value);
107
- }
108
- function isDate(value) {
109
- return value instanceof Date && !isNaN(value.valueOf());
110
- }
111
- const merge = (...value) => {
112
- let reval = value[0];
113
- if (!isPlainObject(reval) || isEmpty(reval)) {
114
- return reval;
115
- }
116
- let i = 1;
117
- if (Object.keys(reval).length > 0) {
118
- i = 0;
119
- reval = isArray(reval) ? [] : {};
120
- }
121
- const argLen = value.length;
122
- for (; i < argLen; i += 1) {
123
- cloneDeep(reval, value[i]);
124
- }
125
- return reval;
30
+ const isHiddenField = (field) => (field == null ? void 0 : field.renderType) === "hidden";
31
+ const merge = (...values) => {
32
+ if (!isPlainObject(values[0])) return values[0];
33
+ return objectDeepMerge(...values, {});
126
34
  };
127
- function cloneDeep(dst, src) {
128
- if (isObject(src)) {
129
- return cloneObjectDeep(dst, src);
130
- }
131
- if (isArray(src)) {
132
- return cloneArrayDeep(dst, src);
133
- }
134
- if (isDate(src)) {
135
- return new src.constructor(src);
136
- }
137
- return src;
138
- }
139
- function cloneObjectDeep(dst, src) {
140
- if (isFunction(src)) {
141
- return src;
142
- }
143
- for (const key of Object.keys(src)) {
144
- const val = src[key];
145
- if (isUndefined(val)) {
146
- continue;
147
- }
148
- if (val === null) {
149
- dst[key] = val;
150
- } else if (isFunction(val)) {
151
- dst[key] = val;
152
- } else if (isEmpty(dst[key])) {
153
- dst[key] = cloneDeep(isArray(val) ? [] : {}, val);
154
- } else if (!isObject(val)) {
155
- dst[key] = val;
156
- } else {
157
- cloneDeep(dst[key], val);
158
- }
159
- }
160
- return dst;
161
- }
162
- function cloneArrayDeep(dst, src) {
163
- const isObj = isPlainObject(dst);
164
- for (let i = 0; i < src.length; i += 1) {
165
- const val = src[i];
166
- let newVal;
167
- if (val == null) {
168
- newVal = val;
169
- } else {
170
- newVal = cloneDeep(isArray(val) ? [] : {}, val);
171
- }
172
- if (isObj) {
173
- dst[i] = newVal;
174
- } else {
175
- dst.push(newVal);
176
- }
177
- }
178
- return dst;
179
- }
180
35
  class Render {
181
36
  constructor(form, field, rowElement) {
182
37
  var _a;
@@ -219,8 +74,8 @@ class Render {
219
74
  setValueItems(value) {
220
75
  }
221
76
  static getDescriptionTemplate(field) {
222
- const classNames = field.descriptionClass ? replaceXss(field.descriptionClass) : "";
223
- const style = field.descriptionStyle ? 'style="' + replaceXss(field.descriptionStyle) + '"' : "";
77
+ const classNames = field.descriptionClass ? xss(field.descriptionClass) : "";
78
+ const style = field.descriptionStyle ? 'style="' + xss(field.descriptionStyle) + '"' : "";
224
79
  return field.description ? `<div class="df-description ${classNames}" ${style}>${field.description}</div>` : "";
225
80
  }
226
81
  changeEventCall(field, e, rederInfo, fieldValue) {
@@ -288,9 +143,9 @@ class Render {
288
143
  } else {
289
144
  const fieldEle = this.rowElement.querySelector(".df-field");
290
145
  if (fieldEle) {
291
- const parser2 = new DOMParser();
146
+ const parser = new DOMParser();
292
147
  this.field.description = desc;
293
- const descEle2 = parser2.parseFromString(Render.getDescriptionTemplate(this.field), "text/html").querySelector(".df-description");
148
+ const descEle2 = parser.parseFromString(Render.getDescriptionTemplate(this.field), "text/html").querySelector(".df-description");
294
149
  if (descEle2) (_a = fieldEle.parentNode) == null ? void 0 : _a.insertBefore(descEle2, fieldEle.nextSibling);
295
150
  }
296
151
  }
@@ -372,7 +227,7 @@ const validator = (value, field, result) => {
372
227
  if (field.different) {
373
228
  const diffFieldName = field.different.field;
374
229
  const diffField = field.$instance.getForm().getField(diffFieldName);
375
- if (!isEmpty(diffField) && field.$instance.getValue() == diffField.$instance.getValue()) {
230
+ if (!isNil(diffField) && field.$instance.getValue() == diffField.$instance.getValue()) {
376
231
  result.message = field.different.message;
377
232
  return result;
378
233
  }
@@ -380,7 +235,7 @@ const validator = (value, field, result) => {
380
235
  if (field.identical) {
381
236
  const diffFieldName = field.identical.field;
382
237
  const diffField = field.$instance.getForm().getField(diffFieldName);
383
- if (!isEmpty(diffField) && field.$instance.getValue() != diffField.$instance.getValue()) {
238
+ if (!isNil(diffField) && field.$instance.getValue() != diffField.$instance.getValue()) {
384
239
  result.message = field.identical.message;
385
240
  return result;
386
241
  }
@@ -863,17 +718,14 @@ function resolveFieldStyle(formOptions, field, beforeField, isLabelHide) {
863
718
  fieldStyle.valueClass = fieldStyle.labelStyle ? "df-col-full" : "";
864
719
  }
865
720
  }
866
- fieldStyle.fieldClass = spaceReplace(fieldStyle.fieldClass);
867
- fieldStyle.labelClass = spaceReplace(fieldStyle.labelClass);
868
- fieldStyle.valueClass = spaceReplace(fieldStyle.valueClass);
721
+ fieldStyle.fieldClass = resolveClassName(fieldStyle.fieldClass).join(" ");
722
+ fieldStyle.labelClass = resolveClassName(fieldStyle.labelClass).join(" ");
723
+ fieldStyle.valueClass = resolveClassName(fieldStyle.valueClass).join(" ");
869
724
  return fieldStyle;
870
725
  }
871
726
  function orientationClassName(orientation) {
872
727
  return orientation === "horizontal" ? "df-horizontal" : "df-vertical";
873
728
  }
874
- function spaceReplace(str) {
875
- return str.replace(/\s+/g, " ").trim();
876
- }
877
729
  class CheckboxRender extends Render {
878
730
  constructor(field, rowElement, daraForm) {
879
731
  var _a, _b;
@@ -932,11 +784,11 @@ class CheckboxRender extends Render {
932
784
  const valueKey = Render.valuesValueKey(field);
933
785
  templates.push(` <div class="df-field"><div class="df-field-group">`);
934
786
  (_b = (_a = field.listItem) == null ? void 0 : _a.list) == null ? void 0 : _b.forEach((val) => {
935
- const checkVal = val[valueKey];
787
+ const checkVal = String(val[valueKey] ?? "");
936
788
  templates.push(`
937
789
  <span class="df-field-item ${orientationClassName(field.listItem.orientation ?? OrientationMap.horizontal)}">
938
790
  <label>
939
- <input type="checkbox" name="${fieldName}" value="${checkVal ? replaceXss(checkVal) : ""}" class="df-form-field df-checkbox" ${val.selected ? "checked" : ""} ${val.disabled ? "disabled" : ""} />
791
+ <input type="checkbox" name="${fieldName}" value="${checkVal ? xss(checkVal) : ""}" class="df-form-field df-checkbox" ${val.selected ? "checked" : ""} ${val.disabled ? "disabled" : ""} />
940
792
  ${Render.valuesLabelValue(labelKey, val)}
941
793
  </label>
942
794
  </span>
@@ -1414,7 +1266,7 @@ class FileRender extends Render {
1414
1266
  this.setFileList(this.fileList, true);
1415
1267
  }
1416
1268
  setValue(value) {
1417
- if (isArray$1(value)) {
1269
+ if (isArray(value)) {
1418
1270
  this.setValueItems(value);
1419
1271
  }
1420
1272
  this.element.value = "";
@@ -1455,7 +1307,7 @@ class CustomRender extends Render {
1455
1307
  }
1456
1308
  createField() {
1457
1309
  const field = this.field;
1458
- const fieldTemplate = isEmpty(field.template) ? "" : isString(field.template) ? field.template : field.template();
1310
+ const fieldTemplate = isNil(field.template) ? "" : isString(field.template) ? field.template : field.template();
1459
1311
  const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
1460
1312
  fieldContainerElement.innerHTML = ` <div class="df-field">
1461
1313
  ${fieldTemplate}
@@ -1662,1298 +1514,6 @@ class RangeRender extends Render {
1662
1514
  return validResult;
1663
1515
  }
1664
1516
  }
1665
- let localeMessage$1 = {
1666
- year: "Year",
1667
- month: "Month",
1668
- day: "Day",
1669
- am: "AM",
1670
- pm: "PM",
1671
- today: "Today",
1672
- ok: "Ok",
1673
- months: {
1674
- full: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
1675
- abbr: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
1676
- },
1677
- weeks: {
1678
- full: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
1679
- abbr: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
1680
- }
1681
- };
1682
- let Language$2 = class Language {
1683
- constructor() {
1684
- this.lang = localeMessage$1;
1685
- }
1686
- setDefaultMessage(lang) {
1687
- localeMessage$1 = Object.assign(localeMessage$1, lang);
1688
- }
1689
- /**
1690
- * 다국어 메시지 등록
1691
- *
1692
- * @public
1693
- * @param {?Message} [lang] 둥록할 메시지
1694
- */
1695
- set(lang) {
1696
- this.lang = Object.assign({}, localeMessage$1, lang);
1697
- }
1698
- /**
1699
- * 메시지 얻기
1700
- *
1701
- * @public
1702
- * @param {string} messageKey 메시지 키
1703
- * @returns {*}
1704
- */
1705
- getMessage(messageKey) {
1706
- return this.lang[messageKey];
1707
- }
1708
- getMonthsMessage(idx, mode = "abbr") {
1709
- return this.lang.months[mode][idx] || "";
1710
- }
1711
- getWeeksMessage(idx, mode = "abbr") {
1712
- return this.lang.weeks[mode][idx] || "";
1713
- }
1714
- getMonthsIdx(val, mode = "abbr") {
1715
- return mode == "full" ? this.lang.months.full.indexOf(val) : this.lang.months.abbr.indexOf(val);
1716
- }
1717
- getWeeksIdx(val, mode = "abbr") {
1718
- return mode == "full" ? this.lang.weeks.full.indexOf(val) : this.lang.weeks.abbr.indexOf(val);
1719
- }
1720
- };
1721
- const Lanauage = new Language$2();
1722
- const EXPRESSIONS_FORMAT = ["YY", "YYYY", "MMMM", "MMM", "MM", "M", "dddd", "ddd", "dd", "d", "DD", "D", "S", "HH", "H", "hh", "h", "mm", "m", "ss", "s", "SSS", "zzzz", "zzz", "zz", "z", "a", "A"];
1723
- let MAX_CHAR_LENGTH = 0;
1724
- let DEFAULT_FORMAT = {
1725
- year: "YYYY",
1726
- month: "YYYY-MM",
1727
- date: "YYYY-MM-DD",
1728
- time: "HH:mm",
1729
- datetime: "YYYY-MM-DD HH:mm"
1730
- };
1731
- const DAY_STYLE_CLASS = ["ddtp-sun", "ddtp-mon", "ddtp-tue", "ddtp-wed", "ddtp-thu", "ddtp-fri", "ddtp-sat"];
1732
- var DateViewMode = /* @__PURE__ */ ((DateViewMode2) => {
1733
- DateViewMode2["year"] = "year";
1734
- DateViewMode2["month"] = "month";
1735
- DateViewMode2["date"] = "date";
1736
- DateViewMode2["datetime"] = "datetime";
1737
- DateViewMode2["time"] = "time";
1738
- return DateViewMode2;
1739
- })(DateViewMode || {});
1740
- EXPRESSIONS_FORMAT.forEach((item) => {
1741
- MAX_CHAR_LENGTH = Math.max(item.length, MAX_CHAR_LENGTH);
1742
- });
1743
- const format = (date, format2) => {
1744
- format2 = format2 || "YYYY-MM-DD";
1745
- const len = format2.length;
1746
- let result = [];
1747
- for (let i = 0; i < len; ) {
1748
- let minLen = Math.min(MAX_CHAR_LENGTH, len - i);
1749
- let j = minLen;
1750
- for (; j > 0; j--) {
1751
- const v = format2.substring(i, i + j);
1752
- if (EXPRESSIONS_FORMAT.includes(v)) {
1753
- try {
1754
- result.push(expressionsFunction$1[v](date));
1755
- } catch (e) {
1756
- console.log(EXPRESSIONS_FORMAT.includes(v), v, e);
1757
- }
1758
- break;
1759
- }
1760
- }
1761
- if (j < 1) {
1762
- result.push(format2.substring(i, i + 1));
1763
- i += 1;
1764
- } else {
1765
- i += j;
1766
- }
1767
- }
1768
- return result.join("");
1769
- };
1770
- const expressionsFunction$1 = {
1771
- YY: (date) => {
1772
- return String(date.getFullYear()).slice(-2);
1773
- },
1774
- YYYY: (date) => {
1775
- return String(date.getFullYear());
1776
- },
1777
- M: (date) => {
1778
- return String(date.getMonth() + 1);
1779
- },
1780
- MM: (date) => {
1781
- return leftPad(date.getMonth() + 1, 2);
1782
- },
1783
- MMM: (date) => {
1784
- return Lanauage.getMonthsMessage(date.getMonth());
1785
- },
1786
- MMMM: (date) => {
1787
- return Lanauage.getMonthsMessage(date.getMonth(), "full");
1788
- },
1789
- D: (date) => {
1790
- return String(date.getDate());
1791
- },
1792
- DD: (date) => {
1793
- return leftPad(date.getDate(), 2);
1794
- },
1795
- d: (date) => {
1796
- return String(date.getDate());
1797
- },
1798
- dd: (date) => {
1799
- return leftPad(date.getDate(), 2);
1800
- },
1801
- ddd: (date) => {
1802
- return Lanauage.getWeeksMessage(date.getDay());
1803
- },
1804
- dddd: (date) => {
1805
- return Lanauage.getWeeksMessage(date.getDay(), "full");
1806
- },
1807
- H: (date) => {
1808
- return String(date.getHours());
1809
- },
1810
- HH: (date) => {
1811
- return leftPad(date.getHours(), 2);
1812
- },
1813
- h: (date) => {
1814
- return getH(date);
1815
- },
1816
- hh: (date) => {
1817
- return leftPad(getH(date), 2);
1818
- },
1819
- a: (date) => {
1820
- return String(date.getFullYear()).slice(-2);
1821
- },
1822
- A: (date) => {
1823
- return getMeridiem(date);
1824
- },
1825
- m: (date) => {
1826
- return String(date.getMinutes());
1827
- },
1828
- mm: (date) => {
1829
- return leftPad(date.getMinutes(), 2);
1830
- },
1831
- s: (date) => {
1832
- return String(date.getSeconds());
1833
- },
1834
- ss: (date) => {
1835
- return leftPad(date.getSeconds(), 2);
1836
- },
1837
- SSS: (date) => {
1838
- return leftPad(date.getMilliseconds(), 3);
1839
- }
1840
- };
1841
- function getH(date) {
1842
- let hour = date.getHours();
1843
- if (hour > 12) {
1844
- hour -= 12;
1845
- } else if (hour < 1) {
1846
- hour = 12;
1847
- }
1848
- return hour;
1849
- }
1850
- function getMeridiem(date, isUpper, isShort) {
1851
- const hour = date.getHours();
1852
- let m = hour < 12 ? "am" : "pm";
1853
- m = Lanauage.getMessage(m);
1854
- m = m.toUpperCase();
1855
- return m;
1856
- }
1857
- const parser = (dateStr, format2) => {
1858
- if (dateStr.length > 1e3) {
1859
- return null;
1860
- }
1861
- format2 = format2 || DEFAULT_FORMAT.date;
1862
- const dateInfo = {
1863
- year: (/* @__PURE__ */ new Date()).getFullYear(),
1864
- month: 0,
1865
- day: 1,
1866
- hour: 0,
1867
- minute: 0,
1868
- second: 0,
1869
- millisecond: 0,
1870
- isPm: false,
1871
- isH: false,
1872
- charIdx: 0
1873
- };
1874
- const len = format2.length;
1875
- let startIdx = 0;
1876
- for (let i = 0; i < len; ) {
1877
- let minLen = Math.min(MAX_CHAR_LENGTH, len - i);
1878
- let j = minLen;
1879
- for (; j > 0; j--) {
1880
- const v = format2.substring(i, i + j);
1881
- if (EXPRESSIONS_FORMAT.includes(v)) {
1882
- const expInfo = expressionsFunction[v];
1883
- const val = matchFind(dateStr.substring(startIdx), expInfo[0]);
1884
- expInfo[1](dateInfo, val);
1885
- startIdx += val.length;
1886
- break;
1887
- }
1888
- }
1889
- if (j < 1) {
1890
- i += 1;
1891
- startIdx += 1;
1892
- } else {
1893
- i += j;
1894
- }
1895
- }
1896
- if (dateInfo.hour != null && !dateInfo.isH) {
1897
- if (dateInfo.isPm && +dateInfo.hour !== 12) {
1898
- dateInfo.hour = +dateInfo.hour + 12;
1899
- } else if (!dateInfo.isPm && +dateInfo.hour === 12) {
1900
- dateInfo.hour = 0;
1901
- }
1902
- }
1903
- let date;
1904
- date = new Date(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute, dateInfo.second, dateInfo.millisecond);
1905
- return date;
1906
- };
1907
- const matchFind = (val, regexp2) => {
1908
- const match = regexp2.exec(val);
1909
- return match == null ? "" : match[0];
1910
- };
1911
- const digitsCheck = {
1912
- twoOptional: /\d\d?/,
1913
- two: /\d\d/,
1914
- three: /\d{3}/,
1915
- four: /\d{4}/
1916
- };
1917
- const word = /[^\s]+/;
1918
- const expressionsFunction = {
1919
- YY: [
1920
- digitsCheck["two"],
1921
- (dateInfo, val) => {
1922
- dateInfo.year = +(("" + (/* @__PURE__ */ new Date()).getFullYear()).substring(0, 2) + val);
1923
- return dateInfo;
1924
- }
1925
- ],
1926
- YYYY: [
1927
- digitsCheck["four"],
1928
- (dateInfo, val) => {
1929
- dateInfo.year = +val;
1930
- return dateInfo;
1931
- }
1932
- ],
1933
- M: [
1934
- digitsCheck["twoOptional"],
1935
- (dateInfo, val) => {
1936
- dateInfo.month = +val - 1;
1937
- return dateInfo;
1938
- }
1939
- ],
1940
- MM: [
1941
- digitsCheck["two"],
1942
- (dateInfo, val) => {
1943
- dateInfo.month = +val - 1;
1944
- return dateInfo;
1945
- }
1946
- ],
1947
- MMM: [
1948
- word,
1949
- (dateInfo, val) => {
1950
- dateInfo.month = Lanauage.getMonthsIdx(val, "abbr");
1951
- return dateInfo;
1952
- }
1953
- ],
1954
- MMMM: [
1955
- word,
1956
- (dateInfo, val) => {
1957
- dateInfo.month = Lanauage.getMonthsIdx(val, "full");
1958
- return dateInfo;
1959
- }
1960
- ],
1961
- D: [
1962
- digitsCheck["twoOptional"],
1963
- (dateInfo, val) => {
1964
- dateInfo.day = +val;
1965
- return dateInfo;
1966
- }
1967
- ],
1968
- DD: [
1969
- digitsCheck["two"],
1970
- (dateInfo, val) => {
1971
- dateInfo.day = +val;
1972
- return dateInfo;
1973
- }
1974
- ],
1975
- d: [
1976
- digitsCheck["twoOptional"],
1977
- (dateInfo, val) => {
1978
- dateInfo.day = +val;
1979
- return dateInfo;
1980
- }
1981
- ],
1982
- dd: [
1983
- digitsCheck["two"],
1984
- (dateInfo, val) => {
1985
- dateInfo.day = +val;
1986
- return dateInfo;
1987
- }
1988
- ],
1989
- ddd: [
1990
- word,
1991
- (dateInfo, val) => {
1992
- return dateInfo;
1993
- }
1994
- ],
1995
- dddd: [
1996
- word,
1997
- (dateInfo, val) => {
1998
- return dateInfo;
1999
- }
2000
- ],
2001
- H: [
2002
- digitsCheck["twoOptional"],
2003
- (dateInfo, val) => {
2004
- dateInfo.hour = +val;
2005
- dateInfo.isH = true;
2006
- return dateInfo;
2007
- }
2008
- ],
2009
- HH: [
2010
- digitsCheck["two"],
2011
- (dateInfo, val) => {
2012
- dateInfo.hour = +val;
2013
- dateInfo.isH = true;
2014
- return dateInfo;
2015
- }
2016
- ],
2017
- h: [
2018
- digitsCheck["twoOptional"],
2019
- (dateInfo, val) => {
2020
- dateInfo.hour = +val;
2021
- return dateInfo;
2022
- }
2023
- ],
2024
- hh: [
2025
- digitsCheck["two"],
2026
- (dateInfo, val) => {
2027
- dateInfo.hour = +val;
2028
- return dateInfo;
2029
- }
2030
- ],
2031
- a: [
2032
- word,
2033
- (dateInfo, val) => {
2034
- if (Lanauage.getMessage("am") != val.toLowerCase()) {
2035
- dateInfo.isPm = true;
2036
- }
2037
- return dateInfo;
2038
- }
2039
- ],
2040
- A: [
2041
- word,
2042
- (dateInfo, val) => {
2043
- if (Lanauage.getMessage("am") != val.toLowerCase()) {
2044
- dateInfo.isPm = true;
2045
- }
2046
- return dateInfo;
2047
- }
2048
- ],
2049
- m: [
2050
- digitsCheck["twoOptional"],
2051
- (dateInfo, val) => {
2052
- dateInfo.minute = +val;
2053
- return dateInfo;
2054
- }
2055
- ],
2056
- mm: [
2057
- digitsCheck["two"],
2058
- (dateInfo, val) => {
2059
- dateInfo.minute = +val;
2060
- return dateInfo;
2061
- }
2062
- ],
2063
- s: [
2064
- digitsCheck["twoOptional"],
2065
- (dateInfo, val) => {
2066
- dateInfo.second = +val;
2067
- return dateInfo;
2068
- }
2069
- ],
2070
- ss: [
2071
- digitsCheck["two"],
2072
- (dateInfo, val) => {
2073
- dateInfo.second = +val;
2074
- return dateInfo;
2075
- }
2076
- ],
2077
- SSS: [
2078
- digitsCheck["three"],
2079
- (dateInfo, val) => {
2080
- dateInfo.millisecond = +val;
2081
- return dateInfo;
2082
- }
2083
- ]
2084
- };
2085
- function closestElement(el, checkElement) {
2086
- let currentEl = el;
2087
- while (currentEl) {
2088
- if (currentEl == checkElement) {
2089
- return true;
2090
- }
2091
- currentEl = currentEl.parentElement;
2092
- }
2093
- return false;
2094
- }
2095
- class DaraDate {
2096
- constructor(dt) {
2097
- this.date = dt;
2098
- }
2099
- setYear(num) {
2100
- this.date.setFullYear(num);
2101
- return this;
2102
- }
2103
- addYear(num) {
2104
- this.date.setFullYear(this.date.getFullYear() + num);
2105
- return this;
2106
- }
2107
- addMonth(num) {
2108
- this.date.setMonth(this.date.getMonth() + num);
2109
- return this;
2110
- }
2111
- setMonth(num) {
2112
- this.date.setMonth(num);
2113
- return this;
2114
- }
2115
- setDate(num) {
2116
- this.date.setDate(num);
2117
- return this;
2118
- }
2119
- addDate(num) {
2120
- this.date.setDate(this.date.getDate() + num);
2121
- return this;
2122
- }
2123
- addWeek(num) {
2124
- this.date.setDate(this.date.getDate() + num * 7);
2125
- return this;
2126
- }
2127
- addHours(num) {
2128
- this.date.setHours(this.date.getHours() + num);
2129
- return this;
2130
- }
2131
- setHour(num) {
2132
- this.date.setHours(num);
2133
- return this;
2134
- }
2135
- addMinutes(num) {
2136
- this.date.setMinutes(this.date.getMinutes() + num);
2137
- return this;
2138
- }
2139
- setMinutes(num) {
2140
- this.date.setMinutes(num);
2141
- return this;
2142
- }
2143
- addSeconds(num) {
2144
- this.date.setSeconds(this.date.getSeconds() + num);
2145
- return this;
2146
- }
2147
- addMilliseconds(num) {
2148
- this.date.setMilliseconds(this.date.getMilliseconds() + num);
2149
- return this;
2150
- }
2151
- compare(date) {
2152
- if (this.date.valueOf() < date.valueOf()) {
2153
- return -1;
2154
- } else if (this.date.valueOf() > date.valueOf()) {
2155
- return 1;
2156
- }
2157
- return 0;
2158
- }
2159
- getYear() {
2160
- return this.date.getFullYear();
2161
- }
2162
- getMonth() {
2163
- return this.date.getMonth() + 1;
2164
- }
2165
- getDate() {
2166
- return this.date.getDate();
2167
- }
2168
- getDay() {
2169
- return this.date.getDay();
2170
- }
2171
- getTime() {
2172
- return this.date.getTime();
2173
- }
2174
- format(format$1) {
2175
- return format(this.date, format$1);
2176
- }
2177
- clone() {
2178
- return new DaraDate(new Date(this.date.valueOf()));
2179
- }
2180
- }
2181
- let DEFAULT_OPTIONS$1 = {
2182
- inline: false,
2183
- // layer or innerhtml
2184
- weekStartDay: 0,
2185
- initialDate: "",
2186
- autoClose: true,
2187
- isRTL: false,
2188
- mode: DateViewMode.date,
2189
- enableTodayBtn: false,
2190
- showMonthAfterYear: false,
2191
- isPositionFixed: false,
2192
- format: "",
2193
- zIndex: 1e3,
2194
- minDate: "",
2195
- maxDate: "",
2196
- beforeDrawDate: (dt) => {
2197
- return {
2198
- check: false,
2199
- style: "",
2200
- tooltip: ""
2201
- };
2202
- }
2203
- };
2204
- function hiddenElement() {
2205
- var _a;
2206
- if (document.getElementById("hiddenDaraDatetimeElement") == null) {
2207
- (_a = document.querySelector("body")) == null ? void 0 : _a.insertAdjacentHTML("beforeend", `<div id="hiddenDaraDatetimeElement" class="daracl-datetime-hidden"></div>`);
2208
- }
2209
- return document.getElementById("hiddenDaraDatetimeElement");
2210
- }
2211
- let daraDatetimeIdx = 0;
2212
- const _DateTimePicker = class _DateTimePicker2 {
2213
- constructor(selector, options, message2) {
2214
- var _a;
2215
- this.isInput = false;
2216
- this.isVisible = false;
2217
- this.minYear = -1;
2218
- this.maxYear = -1;
2219
- this.minMonth = -1;
2220
- this.maxMonth = -1;
2221
- this.dayOrder = [0, 1, 2, 3, 4, 5, 6];
2222
- this._documentClickEvent = (e) => {
2223
- if (this.isVisible && e.target != this.targetElement && !closestElement(e.target, this.datetimeElement)) {
2224
- this.hide();
2225
- }
2226
- };
2227
- this.options = Object.assign({}, DEFAULT_OPTIONS$1, options);
2228
- daraDatetimeIdx += 1;
2229
- let selectorElement;
2230
- if (typeof selector === "string") {
2231
- selectorElement = document.querySelector(selector);
2232
- } else {
2233
- selectorElement = selector;
2234
- }
2235
- if (!selectorElement) {
2236
- throw new Error(`${selector} datetimepicker element not found`);
2237
- }
2238
- this._viewMode = Object.keys(DateViewMode).includes(this.options.mode) ? this.options.mode : DateViewMode.date;
2239
- this.initMode = this._viewMode;
2240
- Lanauage.set(message2);
2241
- if (this.initMode == DateViewMode.year) {
2242
- this.dateFormat = this.options.format || DEFAULT_FORMAT.year;
2243
- } else if (this.initMode == DateViewMode.month) {
2244
- this.dateFormat = this.options.format || DEFAULT_FORMAT.month;
2245
- } else if (this.initMode == DateViewMode.time) {
2246
- this.dateFormat = this.options.format || DEFAULT_FORMAT.time;
2247
- } else if (this.initMode == DateViewMode.datetime) {
2248
- this.dateFormat = this.options.format || DEFAULT_FORMAT.datetime;
2249
- } else {
2250
- this.dateFormat = this.options.format || DEFAULT_FORMAT.date;
2251
- }
2252
- let viewDate;
2253
- if (this.options.initialDate) {
2254
- if (typeof this.options.initialDate === "string") {
2255
- viewDate = new DaraDate(parser(this.options.initialDate, this.dateFormat) || /* @__PURE__ */ new Date());
2256
- } else {
2257
- viewDate = new DaraDate(this.options.initialDate);
2258
- }
2259
- } else {
2260
- viewDate = new DaraDate(/* @__PURE__ */ new Date());
2261
- this.options.initialDate = viewDate.format(this.dateFormat);
2262
- }
2263
- this.setWeekDays();
2264
- this.todayDate = viewDate.format(DEFAULT_FORMAT.date);
2265
- this.currentDate = viewDate;
2266
- this.targetElement = selectorElement;
2267
- this.minDate = this._minDate();
2268
- this.maxDate = this._maxDate();
2269
- if (this.options.inline) {
2270
- this.datetimeElement = selectorElement;
2271
- this.datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} embed`;
2272
- } else {
2273
- this.isInput = true;
2274
- this.targetElement.setAttribute("value", viewDate.format(this.dateFormat));
2275
- const datetimeElement = document.createElement("div");
2276
- datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} layer`;
2277
- datetimeElement.setAttribute("style", `z-index:${this.options.zIndex};`);
2278
- (_a = hiddenElement()) == null ? void 0 : _a.appendChild(datetimeElement);
2279
- this.datetimeElement = datetimeElement;
2280
- this.initTargetEvent();
2281
- }
2282
- this.createDatetimeTemplate();
2283
- if (this.isTimeMode()) {
2284
- this.hourInputEle = this.datetimeElement.querySelector(".ddtp-hour");
2285
- this.minuteInputEle = this.datetimeElement.querySelector(".ddtp-minute");
2286
- } else {
2287
- this.hourInputEle = {};
2288
- this.minuteInputEle = {};
2289
- }
2290
- this.changeViewMode(this._viewMode);
2291
- this.initHeaderEvent();
2292
- this.initDateEvent();
2293
- this.initTimeEvent();
2294
- }
2295
- setWeekDays() {
2296
- let weekStartDay = this.options.weekStartDay;
2297
- if (weekStartDay == 0) return;
2298
- if (weekStartDay < 0 || weekStartDay > 6) {
2299
- weekStartDay = 0;
2300
- }
2301
- for (let i = 0; i < 7; i++) {
2302
- let day = weekStartDay + i;
2303
- this.dayOrder[i] = day < 7 ? day : day - 7;
2304
- }
2305
- }
2306
- static create(selector, options, message2) {
2307
- return new _DateTimePicker2(selector, options, message2);
2308
- }
2309
- /**
2310
- * default date format setting
2311
- * @example
2312
- ```
2313
- setDefaultFormat({
2314
- year: "YYYY",
2315
- month: "YYYY-MM",
2316
- date: "YYYY-MM-DD",
2317
- time: "HH:mm",
2318
- datetime: "YYYY-MM-DD HH:mm",
2319
- });
2320
- ```
2321
- * @public
2322
- * @static
2323
- * @param {*} dateFormat
2324
- */
2325
- static setDefaultFormat(dateFormat) {
2326
- Object.assign(DEFAULT_FORMAT, dateFormat);
2327
- }
2328
- _minDate() {
2329
- let minDate = this.options.minDate;
2330
- if (minDate != "") {
2331
- if (typeof minDate === "string") {
2332
- const dt = parser(minDate, this.dateFormat);
2333
- if (!dt) {
2334
- return -1;
2335
- }
2336
- minDate = dt;
2337
- }
2338
- this.minYear = minDate.getFullYear();
2339
- this.minMonth = +(this.minYear + leftPad(minDate.getMonth(), 2));
2340
- return new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate(), 0, 0).getTime();
2341
- }
2342
- return -1;
2343
- }
2344
- _maxDate() {
2345
- let maxDate = this.options.maxDate;
2346
- if (maxDate != "") {
2347
- if (typeof maxDate === "string") {
2348
- const dt = parser(maxDate, this.dateFormat);
2349
- if (!dt) {
2350
- return -1;
2351
- }
2352
- maxDate = dt;
2353
- }
2354
- this.maxYear = maxDate.getFullYear();
2355
- this.maxMonth = +(this.maxYear + leftPad(maxDate.getMonth(), 2));
2356
- return new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59).getTime();
2357
- }
2358
- return -1;
2359
- }
2360
- set viewMode(mode) {
2361
- if (this._viewMode === mode) {
2362
- return;
2363
- }
2364
- this._viewMode = mode;
2365
- this.changeViewMode(mode);
2366
- }
2367
- get viewMode() {
2368
- return this._viewMode;
2369
- }
2370
- /**
2371
- * 모드 change
2372
- * @param mode
2373
- */
2374
- changeViewMode(mode) {
2375
- var _a;
2376
- (_a = this.datetimeElement.querySelector(".ddtp-datetime")) == null ? void 0 : _a.setAttribute("view-mode", mode);
2377
- if (mode === "year") {
2378
- this.yearDraw();
2379
- } else if (mode === "month") {
2380
- this.monthDraw();
2381
- } else {
2382
- this.dayDraw();
2383
- }
2384
- }
2385
- /**
2386
- * init header event
2387
- *
2388
- * @public
2389
- */
2390
- initHeaderEvent() {
2391
- var _a, _b, _c, _d;
2392
- const isRTL = this.options.isRTL;
2393
- (_a = this.datetimeElement.querySelector(".ddtp-move-btn.prev")) == null ? void 0 : _a.addEventListener("click", (e) => {
2394
- this.moveDate(isRTL ? "next" : "prev", e);
2395
- });
2396
- (_b = this.datetimeElement.querySelector(".ddtp-move-btn.next")) == null ? void 0 : _b.addEventListener("click", (e) => {
2397
- this.moveDate(isRTL ? "prev" : "next", e);
2398
- });
2399
- (_c = this.datetimeElement.querySelector(".ddtp-header-year")) == null ? void 0 : _c.addEventListener("click", (e) => {
2400
- this.viewMode = DateViewMode.year;
2401
- });
2402
- (_d = this.datetimeElement.querySelector(".ddtp-header-month")) == null ? void 0 : _d.addEventListener("click", (e) => {
2403
- this.viewMode = DateViewMode.month;
2404
- });
2405
- }
2406
- /**
2407
- * 날짜 달력 이벤트처리.
2408
- */
2409
- initDateEvent() {
2410
- var _a, _b;
2411
- (_a = this.datetimeElement.querySelector(".ddtp-day-body")) == null ? void 0 : _a.addEventListener("click", (e) => {
2412
- var _a2;
2413
- const targetEle = e.target;
2414
- if (targetEle.classList.contains("ddtp-day") || targetEle.closest(".ddtp-day")) {
2415
- const selectDate = targetEle.getAttribute("data-day") || "1";
2416
- const mmDD = selectDate.split(",");
2417
- this.currentDate.setMonth(+mmDD[0] - 1);
2418
- this.currentDate.setDate(+mmDD[1]);
2419
- if (this.isDayDisabled(this.currentDate)) {
2420
- return;
2421
- }
2422
- (_a2 = this.datetimeElement.querySelector(".select")) == null ? void 0 : _a2.classList.remove("select");
2423
- targetEle.classList.add("select");
2424
- if (this.isTimeMode()) {
2425
- this.currentDate.setHour(+this.hourInputEle.value);
2426
- this.currentDate.setMinutes(+this.minuteInputEle.value);
2427
- }
2428
- this.dateChangeEvent(e);
2429
- }
2430
- });
2431
- (_b = this.datetimeElement.querySelector(".ddtp-today")) == null ? void 0 : _b.addEventListener("click", (e) => {
2432
- const initDate = new DaraDate(parser(this.todayDate, DEFAULT_FORMAT.date) || /* @__PURE__ */ new Date());
2433
- this.currentDate.setYear(initDate.getYear());
2434
- this.currentDate.setMonth(initDate.getMonth() - 1);
2435
- this.currentDate.setDate(initDate.getDate());
2436
- this.changeViewMode(this.initMode);
2437
- });
2438
- }
2439
- isTimeMode() {
2440
- return this._viewMode === DateViewMode.time || this._viewMode === DateViewMode.datetime;
2441
- }
2442
- getTimeNumberValue(val) {
2443
- if (!isNumeric(val)) {
2444
- return 0;
2445
- }
2446
- return parseInt(val, 10);
2447
- }
2448
- /**
2449
- * 시간 분 설정 이벤트 처리.
2450
- *
2451
- * @public
2452
- */
2453
- initTimeEvent() {
2454
- var _a;
2455
- if (!this.isTimeMode()) return;
2456
- let hh = this.currentDate.format("HH");
2457
- const datetimeElement = this.datetimeElement;
2458
- const hourInputEle = datetimeElement.querySelector(".ddtp-hour");
2459
- const hourRangeEle = datetimeElement.querySelector(".ddtp-hour-range");
2460
- hourInputEle.value = hh;
2461
- hourRangeEle.value = hh;
2462
- hourInputEle.addEventListener("input", (e) => {
2463
- const targetElement = e.target;
2464
- let val = this.getTimeNumberValue(targetElement.value);
2465
- let addVal = leftPadClamp(val, 2, "0");
2466
- if (parseInt(addVal, 10) > 23) {
2467
- addVal = "23";
2468
- }
2469
- hourInputEle.value = addVal;
2470
- hourRangeEle.value = addVal;
2471
- });
2472
- hourRangeEle.addEventListener("input", (e) => {
2473
- const targetElement = e.target;
2474
- hourInputEle.value = leftPadClamp(targetElement.value, 2, "0");
2475
- });
2476
- let mm = this.currentDate.format("mm");
2477
- const minuteInputEle = datetimeElement.querySelector(".ddtp-minute");
2478
- const minuteRangeEle = datetimeElement.querySelector(".ddtp-minute-range");
2479
- minuteInputEle.value = mm;
2480
- minuteRangeEle.value = mm;
2481
- minuteInputEle.addEventListener("input", (e) => {
2482
- const targetElement = e.target;
2483
- let val = this.getTimeNumberValue(targetElement.value);
2484
- let addVal = leftPadClamp(val, 2, "0");
2485
- if (parseInt(addVal, 10) > 59) {
2486
- addVal = "59";
2487
- }
2488
- minuteInputEle.value = addVal;
2489
- minuteRangeEle.value = addVal;
2490
- });
2491
- minuteRangeEle.addEventListener("input", (e) => {
2492
- const targetElement = e.target;
2493
- minuteInputEle.value = leftPadClamp(targetElement.value, 2, "0");
2494
- });
2495
- (_a = datetimeElement.querySelector(".time-select")) == null ? void 0 : _a.addEventListener("click", (e) => {
2496
- this.currentDate.setHour(+hourInputEle.value);
2497
- this.currentDate.setMinutes(+minuteInputEle.value);
2498
- this.dateChangeEvent(e);
2499
- });
2500
- }
2501
- /**
2502
- * 날짜 이동
2503
- * @param moveMode // 앞뒤 이동 prev, next
2504
- * @returns
2505
- */
2506
- moveDate(moveMode, e) {
2507
- if (this._viewMode === DateViewMode.date || this._viewMode === DateViewMode.datetime) {
2508
- this.currentDate.setDate(1);
2509
- this.currentDate.addMonth("prev" === moveMode ? -1 : 1);
2510
- this.dayDraw();
2511
- return;
2512
- }
2513
- if (this._viewMode === DateViewMode.month) {
2514
- this.currentDate.setDate(1);
2515
- this.currentDate.addYear("prev" === moveMode ? -1 : 1);
2516
- this.monthDraw();
2517
- return;
2518
- }
2519
- if (this._viewMode === DateViewMode.year) {
2520
- this.currentDate.setDate(1);
2521
- this.currentDate.addYear("prev" === moveMode ? -16 : 16);
2522
- this.yearDraw();
2523
- }
2524
- }
2525
- /**
2526
- * get date value
2527
- *
2528
- * @returns
2529
- */
2530
- getDateValue() {
2531
- return this.currentDate.format(this.dateFormat);
2532
- }
2533
- /**
2534
- * 옵션 셋팅
2535
- * @static
2536
- * @param {DateTimePickerOptions} options
2537
- */
2538
- static setOptions(options) {
2539
- DEFAULT_OPTIONS$1 = Object.assign({}, DEFAULT_OPTIONS$1, options);
2540
- }
2541
- /**
2542
- * 달력 보이기 처리.
2543
- *
2544
- * @returns
2545
- */
2546
- show() {
2547
- if (this.isVisible) {
2548
- return;
2549
- }
2550
- this.isVisible = true;
2551
- const docSize = getDocSize();
2552
- this.datetimeElement.classList.remove("hide");
2553
- this.datetimeElement.classList.add("show");
2554
- const rect = this.targetElement.getBoundingClientRect();
2555
- const scrollTop = window.scrollY || document.documentElement.scrollTop;
2556
- const scrollLeft = window.scrollX || document.documentElement.scrollLeft;
2557
- const elementHeight = this.datetimeElement.offsetHeight;
2558
- const targetElementHeight = this.targetElement.offsetHeight + 2;
2559
- let left = rect.left + scrollLeft;
2560
- let top = 0;
2561
- if (this.options.isPositionFixed) {
2562
- top = rect.top + targetElementHeight;
2563
- left = rect.left;
2564
- } else {
2565
- if (rect.top + targetElementHeight + elementHeight > docSize.clientHeight && rect.top >= elementHeight) {
2566
- top = scrollTop + rect.top - elementHeight - 2;
2567
- } else {
2568
- top = scrollTop + rect.top + targetElementHeight;
2569
- }
2570
- }
2571
- this.datetimeElement.setAttribute("style", `${this.options.isPositionFixed ? "position:fixed;" : ""}top:${top}px;left:${left}px;z-index:${this.options.zIndex}`);
2572
- document.addEventListener("click", this._documentClickEvent);
2573
- }
2574
- /**
2575
- * 달력 숨기기
2576
- */
2577
- hide() {
2578
- this.isVisible = false;
2579
- if (this.options.onClose) {
2580
- if (this.options.onClose() === false) {
2581
- return;
2582
- }
2583
- }
2584
- this.datetimeElement.classList.remove("show");
2585
- this.datetimeElement.classList.add("hide");
2586
- document.removeEventListener("click", this._documentClickEvent);
2587
- }
2588
- /**
2589
- * 타켓 이벤트 처리.
2590
- */
2591
- initTargetEvent() {
2592
- if (this.targetElement) {
2593
- this.targetElement.addEventListener("click", (e) => {
2594
- this.show();
2595
- });
2596
- }
2597
- }
2598
- /**
2599
- * 날짜 변경후 이벤트
2600
- */
2601
- afterChangeDatepicker() {
2602
- const formatValue = this.currentDate.format(this.dateFormat);
2603
- if (this.options.afterChangeDatepicker && isFunction$1(this.options.afterChangeDatepicker)) {
2604
- this.options.afterChangeDatepicker(formatValue, this.viewMode);
2605
- }
2606
- }
2607
- /**
2608
- * 날짜 변경 전 이벤트.
2609
- * @returns void
2610
- */
2611
- beforeChangeDatepicker() {
2612
- const formatValue = this.currentDate.format(this.dateFormat);
2613
- if (this.options.beforeChangeDatepicker && isFunction$1(this.options.beforeChangeDatepicker)) {
2614
- const reval = this.options.beforeChangeDatepicker(formatValue, (result) => {
2615
- if (result === false) {
2616
- return;
2617
- }
2618
- this.refresh(false);
2619
- });
2620
- if (reval === false) {
2621
- return;
2622
- }
2623
- this.refresh(false);
2624
- return;
2625
- }
2626
- this.refresh(false);
2627
- }
2628
- dateChangeEvent(e) {
2629
- const formatValue = this.currentDate.format(this.dateFormat);
2630
- if (this.options.onSelect) {
2631
- if (this.options.onSelect(formatValue, this.viewMode, e) === false) {
2632
- return;
2633
- }
2634
- }
2635
- if (this.isInput) {
2636
- this.targetElement.setAttribute("value", formatValue);
2637
- }
2638
- if (!this.options.inline && this.options.autoClose) {
2639
- this.hide();
2640
- }
2641
- }
2642
- /**
2643
- * datepicker template 그리기
2644
- */
2645
- createDatetimeTemplate() {
2646
- const showMonthAfterYear = this.options.showMonthAfterYear;
2647
- let datetimeTemplate = `<div class="ddtp-datetime ${this.options.isRTL ? "rtl" : ""}" view-mode="${this._viewMode}">
2648
- <div class="ddtp-header">
2649
- <span class="${showMonthAfterYear ? "ddtp-header-year" : "ddtp-header-month"}"></span>
2650
- <span class="${showMonthAfterYear ? "ddtp-header-month" : "ddtp-header-year"}"></span>
2651
-
2652
- <span class="ddtp-date-move">
2653
- <a href="javascript:;" class="ddtp-move-btn prev">
2654
- <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>
2655
- </a>
2656
- <a href="javascript:;" class="ddtp-move-btn next">
2657
- <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>
2658
- </a>
2659
- </span>
2660
- </div>
2661
- <div class="ddtp-body">
2662
- <table class="ddtp-days">
2663
- <thead class="ddtp-day-header">
2664
- <tr>
2665
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[0]]}">${Lanauage.getWeeksMessage(this.dayOrder[0])}</td>
2666
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[1]]}">${Lanauage.getWeeksMessage(this.dayOrder[1])}</td>
2667
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[2]]}">${Lanauage.getWeeksMessage(this.dayOrder[2])}</td>
2668
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[3]]}">${Lanauage.getWeeksMessage(this.dayOrder[3])}</td>
2669
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[4]]}">${Lanauage.getWeeksMessage(this.dayOrder[4])}</td>
2670
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[5]]}">${Lanauage.getWeeksMessage(this.dayOrder[5])}</td>
2671
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[6]]}">${Lanauage.getWeeksMessage(this.dayOrder[6])}</td>
2672
- </tr>
2673
- </thead>
2674
- <tbody class="ddtp-day-body">
2675
- </tbody>
2676
-
2677
- <tfoot class="ddtp-day-footer">
2678
- <td colspan="7">
2679
- <div style="width:99%;text-align:center;margin-top: 5px;${this.options.enableTodayBtn ? "" : "display:none;"}"><button type="button" class="ddtp-today">${Lanauage.getMessage("today")}</button></div>
2680
- <div class="footer-tooltip"></div>
2681
- </td>
2682
- </tfoot>
2683
- </table>
2684
-
2685
- <div class="ddtp-times">
2686
- <div class="time-container">
2687
- <div class="ddtp-time">
2688
- <span>H: </span><input type="number" class="ddtp-hour" min="0" max="23" maxlength="2">
2689
- <input type="range" min="0" max="23" class="ddtp-hour-range">
2690
- </div>
2691
- <div class="ddtp-time">
2692
- <span>M: </span><input type="number" class="ddtp-minute" min="0" max="59" size="2" maxlength="2">
2693
- <input type="range" min="0" max="59" class="ddtp-minute-range">
2694
- </div>
2695
- </div>
2696
- <div class="ddtp-btn">
2697
- <button type="button" class="time-select">${Lanauage.getMessage("ok")}</button>
2698
- </div>
2699
- </div>
2700
-
2701
- <div class="ddtp-months">
2702
- </div>
2703
-
2704
- <div class="ddtp-years">
2705
- </div>
2706
- </div>
2707
- </div>`;
2708
- this.datetimeElement.innerHTML = datetimeTemplate;
2709
- }
2710
- refresh(beforeChangeDatepickerCheck) {
2711
- if (this._viewMode === DateViewMode.date || this._viewMode === DateViewMode.datetime) {
2712
- this.dayDraw(beforeChangeDatepickerCheck);
2713
- return;
2714
- }
2715
- if (this._viewMode === DateViewMode.month) {
2716
- this.monthDraw(beforeChangeDatepickerCheck);
2717
- return;
2718
- }
2719
- if (this._viewMode === DateViewMode.year) {
2720
- this.yearDraw(beforeChangeDatepickerCheck);
2721
- }
2722
- }
2723
- /**
2724
- * 년 달력 그리기
2725
- */
2726
- yearDraw(beforeChangeDatepickerCheck) {
2727
- var _a;
2728
- const currentYear = this.currentDate.format("YYYY");
2729
- if (beforeChangeDatepickerCheck !== false && this.initMode == DateViewMode.year) {
2730
- this.beforeChangeDatepicker();
2731
- return;
2732
- }
2733
- const startYear = +currentYear - 8;
2734
- this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${startYear} ~ ${startYear + 15}`;
2735
- const beforeDrawDateFlag = isFunction$1(this.options.beforeDrawDate);
2736
- const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
2737
- const calHTML = [];
2738
- for (let i = 0; i < 16; i++) {
2739
- const year = startYear + i;
2740
- const disabled = this.isYearDisabled(year);
2741
- let addStylceClass = disabled ? " disabled" : "";
2742
- let tooltip = "";
2743
- if (beforeDrawDateFlag && beforeDrawDateFn) {
2744
- const reval = beforeDrawDateFn({ mode: this._viewMode, date: year });
2745
- addStylceClass += reval.style ? " " + reval.style : "";
2746
- tooltip = reval.tooltip;
2747
- tooltip = tooltip ? `title="${tooltip}"` : "";
2748
- }
2749
- calHTML.push(`<div class="ddtp-year ${addStylceClass}" data-year="${year}" ${tooltip}>${year}</div>`);
2750
- }
2751
- this.datetimeElement.querySelector(".ddtp-years").innerHTML = calHTML.join("");
2752
- if (this.initMode == DateViewMode.year) {
2753
- this.afterChangeDatepicker();
2754
- }
2755
- (_a = this.datetimeElement.querySelectorAll(".ddtp-year")) == null ? void 0 : _a.forEach((yearEle) => {
2756
- yearEle.addEventListener("click", (e) => {
2757
- const targetEle = e.target;
2758
- if (targetEle) {
2759
- const year = targetEle.getAttribute("data-year");
2760
- if (year) {
2761
- const numYear = +year;
2762
- if (this.isYearDisabled(numYear)) {
2763
- return;
2764
- }
2765
- if (this.initMode == DateViewMode.year) {
2766
- if (this.isYearDisabled(numYear)) {
2767
- return;
2768
- }
2769
- this.currentDate.setYear(numYear);
2770
- this.dateChangeEvent(e);
2771
- return;
2772
- }
2773
- this.currentDate.setYear(numYear);
2774
- this.viewMode = this.initMode;
2775
- }
2776
- }
2777
- });
2778
- });
2779
- }
2780
- /**
2781
- * 월 달력 그리기
2782
- */
2783
- monthDraw(beforeChangeDatepickerCheck) {
2784
- var _a;
2785
- if (beforeChangeDatepickerCheck !== false && this.initMode == DateViewMode.month) {
2786
- this.beforeChangeDatepicker();
2787
- return;
2788
- }
2789
- const year = this.currentDate.format("YYYY");
2790
- this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${year}`;
2791
- const monthElements = this.datetimeElement.querySelectorAll(".ddtp-months > .ddtp-month");
2792
- if (monthElements.length > 0) {
2793
- if (this.isYearDisabled(+year)) {
2794
- monthElements.forEach((monthEle) => {
2795
- if (!monthEle.classList.contains("disabled")) {
2796
- monthEle.classList.add("disabled");
2797
- }
2798
- });
2799
- return;
2800
- }
2801
- monthElements.forEach((monthEle, idx) => {
2802
- if (this.isMonthDisabled(+year, idx)) {
2803
- if (!monthEle.classList.contains("disabled")) {
2804
- monthEle.classList.add("disabled");
2805
- }
2806
- } else {
2807
- monthEle.classList.remove("disabled");
2808
- }
2809
- });
2810
- if (this.initMode == DateViewMode.month) {
2811
- this.afterChangeDatepicker();
2812
- }
2813
- return;
2814
- }
2815
- this.datetimeElement.querySelector(".ddtp-header-month").textContent = this.currentDate.format("MMMM");
2816
- const beforeDrawDateFlag = isFunction$1(this.options.beforeDrawDate);
2817
- const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
2818
- const calHTML = [];
2819
- for (let i = 0; i < 12; i++) {
2820
- const disabled = this.isMonthDisabled(+year, i);
2821
- let addStylceClass = disabled ? " disabled" : "";
2822
- let tooltip = "";
2823
- if (beforeDrawDateFlag && beforeDrawDateFn) {
2824
- const reval = beforeDrawDateFn({ mode: this._viewMode, date: year + "/" + (i + 1) });
2825
- addStylceClass += reval.style ? " " + reval.style : "";
2826
- tooltip = reval.tooltip;
2827
- tooltip = tooltip ? `title="${tooltip}"` : "";
2828
- }
2829
- calHTML.push(`<div class="ddtp-month ${addStylceClass}" data-month="${i}" ${tooltip}>${Lanauage.getMonthsMessage(i, "abbr")}</div>`);
2830
- }
2831
- this.datetimeElement.querySelector(".ddtp-months").innerHTML = calHTML.join("");
2832
- if (this.initMode == DateViewMode.month) {
2833
- this.afterChangeDatepicker();
2834
- }
2835
- (_a = this.datetimeElement.querySelectorAll(".ddtp-month")) == null ? void 0 : _a.forEach((monthEle) => {
2836
- monthEle.addEventListener("click", (e) => {
2837
- const targetEle = e.target;
2838
- if (targetEle) {
2839
- const month = targetEle.getAttribute("data-month");
2840
- if (month) {
2841
- if (this.isMonthDisabled(this.currentDate.getYear(), +month)) {
2842
- return false;
2843
- }
2844
- if (this.initMode == DateViewMode.month) {
2845
- this.currentDate.setMonth(+month);
2846
- this.dateChangeEvent(e);
2847
- return;
2848
- }
2849
- this.currentDate.setMonth(+month);
2850
- this.viewMode = this.initMode;
2851
- this.dayDraw();
2852
- }
2853
- }
2854
- });
2855
- });
2856
- }
2857
- /**
2858
- * 날짜 그리기
2859
- */
2860
- dayDraw(beforeChangeDatepickerCheck) {
2861
- if (beforeChangeDatepickerCheck !== false && (this.initMode == DateViewMode.date || this.initMode == DateViewMode.datetime)) {
2862
- this.beforeChangeDatepicker();
2863
- return;
2864
- }
2865
- let monthFirstDate = this.currentDate.clone();
2866
- const currentMonth = monthFirstDate.getMonth();
2867
- monthFirstDate.setDate(1);
2868
- this.datetimeElement.querySelector(".ddtp-header-year").textContent = monthFirstDate.format("YYYY");
2869
- this.datetimeElement.querySelector(".ddtp-header-month").textContent = monthFirstDate.format("MMMM");
2870
- let day = monthFirstDate.getDay();
2871
- day = day - this.dayOrder[0];
2872
- if (day >= 0) {
2873
- monthFirstDate.addDate(-day);
2874
- } else {
2875
- monthFirstDate.addDate(-(7 + day));
2876
- }
2877
- const beforeDrawDateFlag = isFunction$1(this.options.beforeDrawDate);
2878
- const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
2879
- const calHTML = [];
2880
- for (let i = 0; i < 42; i++) {
2881
- let dateItem;
2882
- if (i == 0) {
2883
- dateItem = monthFirstDate;
2884
- } else {
2885
- dateItem = monthFirstDate.clone().addDate(i);
2886
- }
2887
- const dateItemFormat = dateItem.format(DEFAULT_FORMAT.date);
2888
- if (i % 7 == 0) {
2889
- calHTML.push((i == 0 ? "" : "</tr>") + "<tr>");
2890
- }
2891
- let disabled = this.isDayDisabled(dateItem);
2892
- let addStylceClass = DAY_STYLE_CLASS[this.dayOrder[i % 7]];
2893
- const dateItemMonth = dateItem.getMonth();
2894
- if (dateItemMonth != currentMonth) {
2895
- if (dateItemMonth < currentMonth) {
2896
- addStylceClass += dateItemMonth == 1 ? " new" : " old";
2897
- } else {
2898
- addStylceClass += currentMonth == 1 && dateItemMonth == 12 ? " old" : " new";
2899
- }
2900
- }
2901
- addStylceClass += this.todayDate == dateItemFormat ? " ddtp-today" : "";
2902
- addStylceClass += disabled ? " disabled" : "";
2903
- let tooltip = "";
2904
- if (beforeDrawDateFlag && beforeDrawDateFn) {
2905
- const reval = beforeDrawDateFn({ mode: this._viewMode, item: dateItem, date: dateItem.format(this.dateFormat) });
2906
- addStylceClass += reval.style ? " " + reval.style : "";
2907
- addStylceClass += reval.check ? " ddtp-event" : "";
2908
- tooltip = reval.tooltip;
2909
- tooltip = tooltip ? `title="${tooltip}"` : "";
2910
- }
2911
- calHTML.push(`<td class="ddtp-day ${addStylceClass}" data-day="${dateItem.format("M,D")}" ${tooltip}>`);
2912
- calHTML.push(`<span>${dateItem.format("d")}</span>`);
2913
- calHTML.push("</td>");
2914
- }
2915
- calHTML.push("</tr>");
2916
- this.datetimeElement.querySelector(".ddtp-day-body").innerHTML = calHTML.join("");
2917
- if (this.initMode == DateViewMode.date || this.initMode == DateViewMode.datetime) {
2918
- this.afterChangeDatepicker();
2919
- }
2920
- }
2921
- isDayDisabled(dateItem) {
2922
- if (this.minDate != -1 && this.minDate > dateItem.getTime() || this.maxDate != -1 && this.maxDate < dateItem.getTime()) {
2923
- return true;
2924
- }
2925
- return false;
2926
- }
2927
- isYearDisabled(year) {
2928
- if (this.minYear != -1 && this.minYear > year || this.maxYear != -1 && this.maxYear < year) {
2929
- return true;
2930
- }
2931
- return false;
2932
- }
2933
- isMonthDisabled(year, month) {
2934
- if (this.isYearDisabled(year)) {
2935
- return true;
2936
- }
2937
- let yearMonth = +(year + leftPad(month, 2));
2938
- if (this.minMonth != -1 && this.minMonth > yearMonth || this.maxMonth != -1 && this.maxMonth < yearMonth) {
2939
- return true;
2940
- }
2941
- return false;
2942
- }
2943
- static setMessage(message2) {
2944
- Lanauage.setDefaultMessage(message2);
2945
- }
2946
- };
2947
- _DateTimePicker.VERSION = `${"0.0.13"}`;
2948
- _DateTimePicker.format = format;
2949
- _DateTimePicker.parser = parser;
2950
- let DateTimePicker = _DateTimePicker;
2951
- function getDocSize() {
2952
- return {
2953
- clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
2954
- clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
2955
- };
2956
- }
2957
1517
  class DateRender extends Render {
2958
1518
  constructor(field, rowElement, daraForm) {
2959
1519
  super(daraForm, field, rowElement);
@@ -2965,7 +1525,7 @@ class DateRender extends Render {
2965
1525
  let dateOnSelectEvent;
2966
1526
  this.field.rendererOptions = Object.assign({}, this.field.rendererOptions);
2967
1527
  if (typeof this.field.rendererOptions.onSelect !== "undefined") {
2968
- dateOnSelectEvent = typeof this.field.rendererOptions.onSelect;
1528
+ dateOnSelectEvent = this.field.rendererOptions.onSelect;
2969
1529
  }
2970
1530
  if (isUndefined(this.field.rendererOptions.mode)) {
2971
1531
  if (this.field.renderType == "datemonth" || this.field.renderType == "datehour") {
@@ -2975,7 +1535,7 @@ class DateRender extends Render {
2975
1535
  }
2976
1536
  }
2977
1537
  this.field.rendererOptions.onSelect = (dt, e) => {
2978
- if (dateOnSelectEvent) {
1538
+ if (isFunction(dateOnSelectEvent)) {
2979
1539
  dateOnSelectEvent(dt, e);
2980
1540
  }
2981
1541
  this.setValue(dt);
@@ -3165,6 +1725,10 @@ class TabRender extends Render {
3165
1725
  }
3166
1726
  }
3167
1727
  reset() {
1728
+ var _a;
1729
+ for (const childField of this.field.children ?? []) {
1730
+ (_a = childField.$tabForm) == null ? void 0 : _a.resetForm();
1731
+ }
3168
1732
  }
3169
1733
  getElement() {
3170
1734
  return this.rowElement;
@@ -3306,7 +1870,7 @@ class GridRender extends Render {
3306
1870
  valueItem = valueItem ?? {};
3307
1871
  for (let columnField of addColumns) {
3308
1872
  columnField.$instance = new columnField.$renderType(columnField, addRowElement == null ? void 0 : addRowElement.querySelector(`#${columnField.$xssName}`), this.gridForm);
3309
- if (valueItem[columnField.$orgin.name]) {
1873
+ if (hasProperty(valueItem, columnField.$orgin.name)) {
3310
1874
  columnField.$instance.setValue(valueItem[columnField.$orgin.name]);
3311
1875
  }
3312
1876
  }
@@ -3332,8 +1896,7 @@ class GridRender extends Render {
3332
1896
  */
3333
1897
  removeFieldInfo(rowIdx) {
3334
1898
  let removeFieldArrs = [];
3335
- console.log("rowIdx : ", rowIdx);
3336
- if (isEmpty(rowIdx)) {
1899
+ if (isNil(rowIdx)) {
3337
1900
  for (let key in this.allAddRowInfo) {
3338
1901
  removeFieldArrs = removeFieldArrs.concat(this.allAddRowInfo[key]);
3339
1902
  }
@@ -3505,7 +2068,7 @@ let localeMessage = {
3505
2068
  "upper-char-special-number": "대문자,소문자,특수문자,숫자 각각 하나 이상 포함 되어야합니다."
3506
2069
  }
3507
2070
  };
3508
- class Language2 {
2071
+ class Language {
3509
2072
  constructor() {
3510
2073
  this.lang = localeMessage;
3511
2074
  }
@@ -3574,7 +2137,7 @@ function message(msgFormat, msgParam) {
3574
2137
  return typeof msgParam[key] !== "undefined" ? msgParam[key] : match;
3575
2138
  });
3576
2139
  }
3577
- const Language$1 = new Language2();
2140
+ const Language$1 = new Language();
3578
2141
  const getRenderer = (field) => {
3579
2142
  let render;
3580
2143
  if (field.renderType) {
@@ -3843,7 +2406,7 @@ function addFormValue(formData, fieldInfo, useTypeValue) {
3843
2406
  formData[key] = value;
3844
2407
  }
3845
2408
  } else {
3846
- if (!isEmpty(fieldInfo.name)) {
2409
+ if (!isNil(fieldInfo.name)) {
3847
2410
  formData[fieldInfo.name] = fieldValue;
3848
2411
  }
3849
2412
  }
@@ -3872,7 +2435,7 @@ function addFieldFormData(formData, fieldInfo, useTypeValue) {
3872
2435
  formData.set(key, value);
3873
2436
  }
3874
2437
  } else {
3875
- if (!isEmpty(fieldInfo.name)) {
2438
+ if (!isNil(fieldInfo.name)) {
3876
2439
  formData.set(fieldInfo.$validName, fieldValue);
3877
2440
  }
3878
2441
  }
@@ -3948,7 +2511,7 @@ class FormTemplate {
3948
2511
  rowElement.classList.add("df-row", parentFieldStyle.rowStyleClass ?? "");
3949
2512
  let idx = 0;
3950
2513
  for (const childField of field.children) {
3951
- if (isEmpty(childField)) {
2514
+ if (isNil(childField)) {
3952
2515
  throw new Error(`parent field :[${field.$validName}], children index ${idx}, empty [${childField}]`);
3953
2516
  }
3954
2517
  childField.$parent = field;
@@ -4032,10 +2595,18 @@ class FormTemplate {
4032
2595
  }
4033
2596
  function initFormOptions(options) {
4034
2597
  const opts = merge({}, DEFAULT_OPTIONS, options);
2598
+ opts.fields = normalizeFields(opts.fields);
4035
2599
  return opts;
4036
2600
  }
4037
2601
  function setDefaultOptions(options) {
4038
2602
  DEFAULT_OPTIONS = merge({}, DEFAULT_OPTIONS, options);
2603
+ DEFAULT_OPTIONS.fields = normalizeFields(DEFAULT_OPTIONS.fields);
2604
+ }
2605
+ function normalizeFields(fields) {
2606
+ return (fields ?? []).filter((field) => field != null).map((field) => {
2607
+ if (Array.isArray(field.children)) field.children = normalizeFields(field.children);
2608
+ return field;
2609
+ });
4039
2610
  }
4040
2611
  let DEFAULT_OPTIONS = {
4041
2612
  style: {
@@ -4131,6 +2702,7 @@ const _DaraForm = class _DaraForm {
4131
2702
  }
4132
2703
  };
4133
2704
  this.addField = (field) => {
2705
+ if (!normalizeFields([field]).length) return;
4134
2706
  this.options.fields.push(field);
4135
2707
  this.formTemplate.addRow(field);
4136
2708
  this.conditionCheck();
@@ -4199,10 +2771,10 @@ const _DaraForm = class _DaraForm {
4199
2771
  this.destroy = () => {
4200
2772
  this.formElement.className = this.orginFormStyleClass;
4201
2773
  this.formElement.replaceChildren();
2774
+ delete allInstance[this.selector];
4202
2775
  for (const key in this) {
4203
- if (hasOwnProp(this, key)) {
2776
+ if (hasProperty(this, key)) {
4204
2777
  delete this[key];
4205
- delete allInstance[this.selector];
4206
2778
  }
4207
2779
  }
4208
2780
  };
@@ -4210,8 +2782,10 @@ const _DaraForm = class _DaraForm {
4210
2782
  return this.options.fields;
4211
2783
  };
4212
2784
  this.setFields = (fields) => {
4213
- this.options.fields = fields;
4214
- this.createForm(fields);
2785
+ this.options.fields = normalizeFields(fields);
2786
+ this.formElement.replaceChildren();
2787
+ this.formValue = {};
2788
+ this.createForm(this.options.fields);
4215
2789
  };
4216
2790
  this.options = initFormOptions(options);
4217
2791
  Language$1.set(message2);
@@ -4398,28 +2972,21 @@ const _DaraForm = class _DaraForm {
4398
2972
  fieldInfo.$instance.setDescription(desc);
4399
2973
  }
4400
2974
  static instance(ele) {
4401
- let element;
4402
- if (isString(ele)) {
4403
- element = document.querySelector(ele);
4404
- } else {
4405
- element = ele;
4406
- }
4407
- element = element;
2975
+ const element = isString(ele) ? document.querySelector(ele) : ele;
2976
+ if (!element) return void 0;
4408
2977
  let selector = element.getAttribute(SEQ_ATTR_KEY);
4409
- if (isUndefined(selector) || isBlank(selector)) {
2978
+ if (isBlank(selector)) {
4410
2979
  const keys = Object.keys(allInstance);
4411
- if (keys.length > 1) {
4412
- throw new Error(`selector empty : [${selector}]`);
4413
- }
2980
+ if (keys.length > 1) throw new Error(`selector empty : [${selector}]`);
4414
2981
  selector = keys[0];
4415
- return allInstance[selector];
4416
2982
  }
2983
+ return selector ? allInstance[selector] : void 0;
4417
2984
  }
4418
2985
  getFieldInfoMap() {
4419
2986
  return this.fieldInfoMap;
4420
2987
  }
4421
2988
  };
4422
- _DaraForm.VERSION = `${"0.0.19"}`;
2989
+ _DaraForm.VERSION = `${"0.0.22"}`;
4423
2990
  _DaraForm.validator = {
4424
2991
  string: (value, field) => {
4425
2992
  return stringValidator(value, field);