@daracl/form 0.0.15 → 0.0.16

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
@@ -433,7 +433,7 @@ var numberValidator;
433
433
  var init_numberValidator = __esm({
434
434
  "src/rule/numberValidator.ts"() {
435
435
  "use strict";
436
- init_constants2();
436
+ init_constants();
437
437
  init_validator();
438
438
  init_utils();
439
439
  numberValidator = (value, field) => {
@@ -509,7 +509,7 @@ var invalidMessage, resetRowElementStyleClass;
509
509
  var init_validUtils = __esm({
510
510
  "src/util/validUtils.ts"() {
511
511
  "use strict";
512
- init_Lanauage2();
512
+ init_Lanauage();
513
513
  invalidMessage = (field, rowElement, validResult) => {
514
514
  if (validResult === true) {
515
515
  rowElement.classList.remove("invalid");
@@ -647,7 +647,7 @@ var stringValidator;
647
647
  var init_stringValidator = __esm({
648
648
  "src/rule/stringValidator.ts"() {
649
649
  "use strict";
650
- init_constants2();
650
+ init_constants();
651
651
  init_utils();
652
652
  init_validator();
653
653
  stringValidator = (value, field) => {
@@ -760,11 +760,11 @@ var init_DropdownRender = __esm({
760
760
  "src/renderer/DropdownRender.ts"() {
761
761
  "use strict";
762
762
  init_Render();
763
- init_constants2();
763
+ init_constants();
764
764
  init_validUtils();
765
765
  init_renderEvents();
766
766
  init_utils();
767
- init_Lanauage2();
767
+ init_Lanauage();
768
768
  DropdownRender = class _DropdownRender extends Render {
769
769
  constructor(field, rowElement, daraForm) {
770
770
  super(daraForm, field, rowElement);
@@ -945,7 +945,7 @@ var init_CheckboxRender = __esm({
945
945
  "use strict";
946
946
  init_Render();
947
947
  init_utils();
948
- init_constants2();
948
+ init_constants();
949
949
  init_validUtils();
950
950
  init_renderEvents();
951
951
  CheckboxRender = class _CheckboxRender extends Render {
@@ -1123,7 +1123,7 @@ var init_RadioRender = __esm({
1123
1123
  "src/renderer/RadioRender.ts"() {
1124
1124
  "use strict";
1125
1125
  init_Render();
1126
- init_constants2();
1126
+ init_constants();
1127
1127
  init_validUtils();
1128
1128
  init_renderEvents();
1129
1129
  init_utils();
@@ -1335,7 +1335,7 @@ var fileValidator;
1335
1335
  var init_fileValidator = __esm({
1336
1336
  "src/rule/fileValidator.ts"() {
1337
1337
  "use strict";
1338
- init_constants2();
1338
+ init_constants();
1339
1339
  fileValidator = (element, field, fileList) => {
1340
1340
  const result = { name: field.name, constraint: [] };
1341
1341
  if (field.required && fileList.length < 1) {
@@ -1358,7 +1358,7 @@ var init_FileRender = __esm({
1358
1358
  init_Render();
1359
1359
  init_validUtils();
1360
1360
  init_fileValidator();
1361
- init_Lanauage2();
1361
+ init_Lanauage();
1362
1362
  init_renderEvents();
1363
1363
  init_utils();
1364
1364
  FileRender = class extends Render {
@@ -1831,1435 +1831,8 @@ var init_RangeRender = __esm({
1831
1831
  }
1832
1832
  });
1833
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
- isPositionFixed: false,
2509
- format: "",
2510
- zIndex: 1e3,
2511
- minDate: "",
2512
- maxDate: "",
2513
- beforeDrawDate: (dt) => {
2514
- return {
2515
- check: false,
2516
- style: "",
2517
- tooltip: ""
2518
- };
2519
- }
2520
- };
2521
- daraDatetimeIdx = 0;
2522
- DateTimePicker = class _DateTimePicker {
2523
- constructor(selector, options, message2) {
2524
- this.isInput = false;
2525
- this.isVisible = false;
2526
- this.minYear = -1;
2527
- this.maxYear = -1;
2528
- this.minMonth = -1;
2529
- this.maxMonth = -1;
2530
- this.dayOrder = [0, 1, 2, 3, 4, 5, 6];
2531
- this._documentClickEvent = (e) => {
2532
- if (this.isVisible && e.target != this.targetElement && !utils_default.closestElement(e.target, this.datetimeElement)) {
2533
- this.hide();
2534
- }
2535
- };
2536
- this.options = Object.assign({}, DEFAULT_OPTIONS, options);
2537
- daraDatetimeIdx += 1;
2538
- let selectorElement;
2539
- if (typeof selector === "string") {
2540
- selectorElement = document.querySelector(selector);
2541
- } else {
2542
- selectorElement = selector;
2543
- }
2544
- if (!selectorElement) {
2545
- throw new Error(`${selector} datetimepicker element not found`);
2546
- }
2547
- this._viewMode = Object.keys(DateViewMode).includes(this.options.mode) ? this.options.mode : "date";
2548
- this.initMode = this._viewMode;
2549
- Lanauage_default2.set(message2);
2550
- if (this.initMode == "year") {
2551
- this.dateFormat = this.options.format || DEFAULT_FORMAT.year;
2552
- } else if (this.initMode == "month") {
2553
- this.dateFormat = this.options.format || DEFAULT_FORMAT.month;
2554
- } else if (this.initMode == "time") {
2555
- this.dateFormat = this.options.format || DEFAULT_FORMAT.time;
2556
- } else if (this.initMode == "datetime") {
2557
- this.dateFormat = this.options.format || DEFAULT_FORMAT.datetime;
2558
- } else {
2559
- this.dateFormat = this.options.format || DEFAULT_FORMAT.date;
2560
- }
2561
- let viewDate;
2562
- if (this.options.initialDate) {
2563
- if (typeof this.options.initialDate === "string") {
2564
- viewDate = new DaraDate(parser_default(this.options.initialDate, this.dateFormat) || /* @__PURE__ */ new Date());
2565
- } else {
2566
- viewDate = new DaraDate(this.options.initialDate);
2567
- }
2568
- } else {
2569
- viewDate = new DaraDate(/* @__PURE__ */ new Date());
2570
- this.options.initialDate = viewDate.format(this.dateFormat);
2571
- }
2572
- this.setWeekDays();
2573
- this.todayDate = viewDate.format(DEFAULT_FORMAT.date);
2574
- this.currentDate = viewDate;
2575
- this.targetElement = selectorElement;
2576
- this.minDate = this._minDate();
2577
- this.maxDate = this._maxDate();
2578
- if (this.options.inline) {
2579
- this.datetimeElement = selectorElement;
2580
- this.datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} embed`;
2581
- } else {
2582
- this.isInput = true;
2583
- this.targetElement.setAttribute("value", viewDate.format(this.dateFormat));
2584
- const datetimeElement = document.createElement("div");
2585
- datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} layer`;
2586
- datetimeElement.setAttribute("style", `z-index:${this.options.zIndex};`);
2587
- hiddenElement()?.appendChild(datetimeElement);
2588
- this.datetimeElement = datetimeElement;
2589
- this.initTargetEvent();
2590
- }
2591
- this.createDatetimeTemplate();
2592
- if (this.isTimeMode()) {
2593
- this.hourInputEle = this.datetimeElement.querySelector(".ddtp-hour");
2594
- this.minuteInputEle = this.datetimeElement.querySelector(".ddtp-minute");
2595
- } else {
2596
- this.hourInputEle = {};
2597
- this.minuteInputEle = {};
2598
- }
2599
- this.changeViewMode(this._viewMode);
2600
- this.initHeaderEvent();
2601
- this.initDateEvent();
2602
- this.initTimeEvent();
2603
- }
2604
- static {
2605
- this.VERSION = `${APP_VERSION}`;
2606
- }
2607
- static {
2608
- this.format = format_default;
2609
- }
2610
- static {
2611
- this.parser = parser_default;
2612
- }
2613
- setWeekDays() {
2614
- let weekStartDay = this.options.weekStartDay;
2615
- if (weekStartDay == 0)
2616
- return;
2617
- if (weekStartDay < 0 || weekStartDay > 6) {
2618
- weekStartDay = 0;
2619
- }
2620
- for (let i = 0; i < 7; i++) {
2621
- let day = weekStartDay + i;
2622
- this.dayOrder[i] = day < 7 ? day : day - 7;
2623
- }
2624
- }
2625
- static create(selector, options, message2) {
2626
- return new _DateTimePicker(selector, options, message2);
2627
- }
2628
- /**
2629
- * default date format setting
2630
- * @example
2631
- ```
2632
- setDefaultFormat({
2633
- year: "YYYY",
2634
- month: "YYYY-MM",
2635
- date: "YYYY-MM-DD",
2636
- time: "HH:mm",
2637
- datetime: "YYYY-MM-DD HH:mm",
2638
- });
2639
- ```
2640
- * @public
2641
- * @static
2642
- * @param {*} dateFormat
2643
- */
2644
- static setDefaultFormat(dateFormat) {
2645
- Object.assign(DEFAULT_FORMAT, dateFormat);
2646
- }
2647
- _minDate() {
2648
- let minDate = this.options.minDate;
2649
- if (minDate != "") {
2650
- if (typeof minDate === "string") {
2651
- const dt = parser_default(minDate, this.dateFormat);
2652
- if (!dt) {
2653
- return -1;
2654
- }
2655
- minDate = dt;
2656
- }
2657
- this.minYear = minDate.getFullYear();
2658
- this.minMonth = +(this.minYear + utils_default.pad(minDate.getMonth(), 2));
2659
- return new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate(), 0, 0).getTime();
2660
- }
2661
- return -1;
2662
- }
2663
- _maxDate() {
2664
- let maxDate = this.options.maxDate;
2665
- if (maxDate != "") {
2666
- if (typeof maxDate === "string") {
2667
- const dt = parser_default(maxDate, this.dateFormat);
2668
- if (!dt) {
2669
- return -1;
2670
- }
2671
- maxDate = dt;
2672
- }
2673
- this.maxYear = maxDate.getFullYear();
2674
- this.maxMonth = +(this.maxYear + utils_default.pad(maxDate.getMonth(), 2));
2675
- return new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59).getTime();
2676
- }
2677
- return -1;
2678
- }
2679
- set viewMode(mode) {
2680
- if (this._viewMode === mode) {
2681
- return;
2682
- }
2683
- this._viewMode = mode;
2684
- this.changeViewMode(mode);
2685
- }
2686
- get viewMode() {
2687
- return this._viewMode;
2688
- }
2689
- /**
2690
- * 모드 change
2691
- * @param mode
2692
- */
2693
- changeViewMode(mode) {
2694
- this.datetimeElement.querySelector(".ddtp-datetime")?.setAttribute("view-mode", mode);
2695
- if (mode === "year") {
2696
- this.yearDraw();
2697
- } else if (mode === "month") {
2698
- this.monthDraw();
2699
- } else {
2700
- this.dayDraw();
2701
- }
2702
- }
2703
- /**
2704
- * init header event
2705
- *
2706
- * @public
2707
- */
2708
- initHeaderEvent() {
2709
- const isRTL = this.options.isRTL;
2710
- this.datetimeElement.querySelector(".ddtp-move-btn.prev")?.addEventListener("click", (e) => {
2711
- this.moveDate(isRTL ? "next" : "prev", e);
2712
- });
2713
- this.datetimeElement.querySelector(".ddtp-move-btn.next")?.addEventListener("click", (e) => {
2714
- this.moveDate(isRTL ? "prev" : "next", e);
2715
- });
2716
- this.datetimeElement.querySelector(".ddtp-header-year")?.addEventListener("click", (e) => {
2717
- this.viewMode = "year";
2718
- });
2719
- this.datetimeElement.querySelector(".ddtp-header-month")?.addEventListener("click", (e) => {
2720
- this.viewMode = "month";
2721
- });
2722
- }
2723
- /**
2724
- * 날짜 달력 이벤트처리.
2725
- */
2726
- initDateEvent() {
2727
- this.datetimeElement.querySelector(".ddtp-day-body")?.addEventListener("click", (e) => {
2728
- const targetEle = e.target;
2729
- if (targetEle.classList.contains("ddtp-day") || targetEle.closest(".ddtp-day")) {
2730
- const selectDate = targetEle.getAttribute("data-day") || "1";
2731
- const mmDD = selectDate.split(",");
2732
- this.currentDate.setMonth(+mmDD[0] - 1);
2733
- this.currentDate.setDate(+mmDD[1]);
2734
- if (this.isDayDisabled(this.currentDate)) {
2735
- return;
2736
- }
2737
- this.datetimeElement.querySelector(".select")?.classList.remove("select");
2738
- targetEle.classList.add("select");
2739
- if (this.isTimeMode()) {
2740
- this.currentDate.setHour(+this.hourInputEle.value);
2741
- this.currentDate.setMinutes(+this.minuteInputEle.value);
2742
- }
2743
- this.dateChangeEvent(e);
2744
- }
2745
- });
2746
- this.datetimeElement.querySelector(".time-today")?.addEventListener("click", (e) => {
2747
- const initDate = new DaraDate(parser_default(this.todayDate, DEFAULT_FORMAT.date) || /* @__PURE__ */ new Date());
2748
- this.currentDate.setYear(initDate.getYear());
2749
- this.currentDate.setMonth(initDate.getMonth() - 1);
2750
- this.currentDate.setDate(initDate.getDate());
2751
- this.changeViewMode(this.initMode);
2752
- });
2753
- }
2754
- isTimeMode() {
2755
- return this._viewMode === "time" || this._viewMode === "datetime";
2756
- }
2757
- /**
2758
- * 시간 분 설정 이벤트 처리.
2759
- *
2760
- * @public
2761
- */
2762
- initTimeEvent() {
2763
- if (!this.isTimeMode())
2764
- return;
2765
- let hh = this.currentDate.format("HH");
2766
- const hourInputEle = this.datetimeElement.querySelector(".ddtp-hour");
2767
- const hourRangeEle = this.datetimeElement.querySelector(".ddtp-hour-range");
2768
- hourInputEle.value = hh;
2769
- hourRangeEle.value = hh;
2770
- hourInputEle.addEventListener("input", (e) => {
2771
- const targetElement = e.target;
2772
- const addVal = utils_default.pad(targetElement.value, 2);
2773
- hourInputEle.value = addVal;
2774
- hourRangeEle.value = addVal;
2775
- });
2776
- hourRangeEle.addEventListener("input", (e) => {
2777
- const targetElement = e.target;
2778
- hourInputEle.value = utils_default.pad(targetElement.value, 2);
2779
- });
2780
- let mm = this.currentDate.format("mm");
2781
- const minuteInputEle = this.datetimeElement.querySelector(".ddtp-minute");
2782
- const minuteRangeEle = this.datetimeElement.querySelector(".ddtp-minute-range");
2783
- minuteInputEle.value = mm;
2784
- minuteRangeEle.value = mm;
2785
- minuteInputEle.addEventListener("input", (e) => {
2786
- const targetElement = e.target;
2787
- const addVal = utils_default.pad(targetElement.value, 2);
2788
- minuteInputEle.value = addVal;
2789
- minuteRangeEle.value = addVal;
2790
- });
2791
- minuteRangeEle.addEventListener("input", (e) => {
2792
- const targetElement = e.target;
2793
- minuteInputEle.value = utils_default.pad(targetElement.value, 2);
2794
- });
2795
- this.datetimeElement.querySelector(".time-select")?.addEventListener("click", (e) => {
2796
- this.currentDate.setHour(+hourInputEle.value);
2797
- this.currentDate.setMinutes(+minuteInputEle.value);
2798
- this.dateChangeEvent(e);
2799
- });
2800
- }
2801
- /**
2802
- * 날짜 이동
2803
- * @param moveMode // 앞뒤 이동 prev, next
2804
- * @returns
2805
- */
2806
- moveDate(moveMode, e) {
2807
- if (this._viewMode === "date" || this._viewMode === "datetime") {
2808
- this.currentDate.setDate(1);
2809
- this.currentDate.addMonth("prev" === moveMode ? -1 : 1);
2810
- this.dayDraw();
2811
- return;
2812
- }
2813
- if (this._viewMode === "month") {
2814
- this.currentDate.setDate(1);
2815
- this.currentDate.addYear("prev" === moveMode ? -1 : 1);
2816
- this.monthDraw();
2817
- return;
2818
- }
2819
- if (this._viewMode === "year") {
2820
- this.currentDate.setDate(1);
2821
- this.currentDate.addYear("prev" === moveMode ? -16 : 16);
2822
- this.yearDraw();
2823
- }
2824
- }
2825
- /**
2826
- * get date value
2827
- *
2828
- * @returns
2829
- */
2830
- getDateValue() {
2831
- return this.currentDate.format(this.dateFormat);
2832
- }
2833
- /**
2834
- * 옵션 셋팅
2835
- * @static
2836
- * @param {DateTimePickerOptions} options
2837
- */
2838
- static setOptions(options) {
2839
- DEFAULT_OPTIONS = Object.assign({}, DEFAULT_OPTIONS, options);
2840
- }
2841
- /**
2842
- * 달력 보이기 처리.
2843
- *
2844
- * @returns
2845
- */
2846
- show() {
2847
- if (this.isVisible) {
2848
- return;
2849
- }
2850
- this.isVisible = true;
2851
- const docSize = getDocSize();
2852
- this.datetimeElement.classList.remove("hide");
2853
- this.datetimeElement.classList.add("show");
2854
- const rect = this.targetElement.getBoundingClientRect();
2855
- const scrollTop = window.scrollY || document.documentElement.scrollTop;
2856
- const scrollLeft = window.scrollX || document.documentElement.scrollLeft;
2857
- const elementHeight = this.datetimeElement.offsetHeight;
2858
- const targetElementHeight = this.targetElement.offsetHeight + 2;
2859
- let left = rect.left + scrollLeft;
2860
- let top = 0;
2861
- if (this.options.isPositionFixed) {
2862
- top = rect.top + targetElementHeight;
2863
- left = rect.left;
2864
- } else {
2865
- if (rect.top + targetElementHeight + elementHeight > docSize.clientHeight && rect.top >= elementHeight) {
2866
- top = scrollTop + rect.top - elementHeight - 2;
2867
- } else {
2868
- top = scrollTop + rect.top + targetElementHeight;
2869
- }
2870
- }
2871
- this.datetimeElement.setAttribute("style", `${this.options.isPositionFixed ? "position:fixed;" : ""}top:${top}px;left:${left}px;z-index:${this.options.zIndex}`);
2872
- document.addEventListener("click", this._documentClickEvent);
2873
- }
2874
- /**
2875
- * 달력 숨기기
2876
- */
2877
- hide() {
2878
- this.isVisible = false;
2879
- if (this.options.onClose) {
2880
- if (this.options.onClose() === false) {
2881
- return;
2882
- }
2883
- }
2884
- this.datetimeElement.classList.remove("show");
2885
- this.datetimeElement.classList.add("hide");
2886
- document.removeEventListener("click", this._documentClickEvent);
2887
- }
2888
- /**
2889
- * 타켓 이벤트 처리.
2890
- */
2891
- initTargetEvent() {
2892
- if (this.targetElement) {
2893
- this.targetElement.addEventListener("click", (e) => {
2894
- this.show();
2895
- });
2896
- }
2897
- }
2898
- /**
2899
- * 날짜 변경후 이벤트
2900
- */
2901
- afterChangeDatepicker() {
2902
- const formatValue = this.currentDate.format(this.dateFormat);
2903
- if (this.options.afterChangeDatepicker && utils_default.isFunction(this.options.afterChangeDatepicker)) {
2904
- this.options.afterChangeDatepicker(formatValue, this.viewMode);
2905
- }
2906
- }
2907
- /**
2908
- * 날짜 변경 전 이벤트.
2909
- * @returns void
2910
- */
2911
- beforeChangeDatepicker() {
2912
- const formatValue = this.currentDate.format(this.dateFormat);
2913
- if (this.options.beforeChangeDatepicker && utils_default.isFunction(this.options.beforeChangeDatepicker)) {
2914
- const reval = this.options.beforeChangeDatepicker(formatValue, (result) => {
2915
- if (result === false) {
2916
- return;
2917
- }
2918
- this.refresh(false);
2919
- });
2920
- if (reval === false) {
2921
- return;
2922
- }
2923
- this.refresh(false);
2924
- return;
2925
- }
2926
- this.refresh(false);
2927
- }
2928
- dateChangeEvent(e) {
2929
- const formatValue = this.currentDate.format(this.dateFormat);
2930
- if (this.options.onSelect) {
2931
- if (this.options.onSelect(formatValue, this.viewMode, e) === false) {
2932
- return;
2933
- }
2934
- }
2935
- if (this.isInput) {
2936
- this.targetElement.setAttribute("value", formatValue);
2937
- }
2938
- if (!this.options.inline && this.options.autoClose) {
2939
- this.hide();
2940
- }
2941
- }
2942
- /**
2943
- * datepicker template 그리기
2944
- */
2945
- createDatetimeTemplate() {
2946
- const showMonthAfterYear = this.options.showMonthAfterYear;
2947
- let datetimeTemplate = `<div class="ddtp-datetime ${this.options.isRTL ? "rtl" : ""}" view-mode="${this._viewMode}">
2948
- <div class="ddtp-header">
2949
- <span class="${showMonthAfterYear ? "ddtp-header-year" : "ddtp-header-month"}"></span>
2950
- <span class="${showMonthAfterYear ? "ddtp-header-month" : "ddtp-header-year"}"></span>
2951
-
2952
- <span class="ddtp-date-move">
2953
- <a href="javascript:;" class="ddtp-move-btn prev">
2954
- <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>
2955
- </a>
2956
- <a href="javascript:;" class="ddtp-move-btn next">
2957
- <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>
2958
- </a>
2959
- </span>
2960
- </div>
2961
- <div class="ddtp-body">
2962
- <table class="ddtp-days">
2963
- <thead class="ddtp-day-header">
2964
- <tr>
2965
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[0]]}">${Lanauage_default2.getWeeksMessage(this.dayOrder[0])}</td>
2966
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[1]]}">${Lanauage_default2.getWeeksMessage(this.dayOrder[1])}</td>
2967
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[2]]}">${Lanauage_default2.getWeeksMessage(this.dayOrder[2])}</td>
2968
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[3]]}">${Lanauage_default2.getWeeksMessage(this.dayOrder[3])}</td>
2969
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[4]]}">${Lanauage_default2.getWeeksMessage(this.dayOrder[4])}</td>
2970
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[5]]}">${Lanauage_default2.getWeeksMessage(this.dayOrder[5])}</td>
2971
- <td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[6]]}">${Lanauage_default2.getWeeksMessage(this.dayOrder[6])}</td>
2972
- </tr>
2973
- </thead>
2974
- <tbody class="ddtp-day-body">
2975
- </tbody>
2976
-
2977
- <tfoot class="ddtp-day-footer">
2978
- <td colspan="7">
2979
- <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>
2980
- <div class="footer-tooltip"></div>
2981
- </td>
2982
- </tfoot>
2983
- </table>
2984
-
2985
- <div class="ddtp-times">
2986
- <div class="time-container">
2987
- <div class="ddtp-time">
2988
- <span>H: </span><input type="number" class="ddtp-hour" min="0" max="23">
2989
- <input type="range" min="0" max="23" class="ddtp-hour-range">
2990
- </div>
2991
- <div class="ddtp-time">
2992
- <span>M: </span><input type="number" class="ddtp-minute" min="0" max="59">
2993
- <input type="range" min="0" max="59" class="ddtp-minute-range">
2994
- </div>
2995
- </div>
2996
- <div class="time-btn">
2997
- <button type="button" class="time-select">${Lanauage_default2.getMessage("ok")}</button>
2998
- </div>
2999
- </div>
3000
-
3001
- <div class="ddtp-months">
3002
- </div>
3003
-
3004
- <div class="ddtp-years">
3005
- </div>
3006
- </div>
3007
- </div>`;
3008
- this.datetimeElement.innerHTML = datetimeTemplate;
3009
- }
3010
- refresh(beforeChangeDatepickerCheck) {
3011
- if (this._viewMode === "date" || this._viewMode === "datetime") {
3012
- this.dayDraw(beforeChangeDatepickerCheck);
3013
- return;
3014
- }
3015
- if (this._viewMode === "month") {
3016
- this.monthDraw(beforeChangeDatepickerCheck);
3017
- return;
3018
- }
3019
- if (this._viewMode === "year") {
3020
- this.yearDraw(beforeChangeDatepickerCheck);
3021
- }
3022
- }
3023
- /**
3024
- * 년 달력 그리기
3025
- */
3026
- yearDraw(beforeChangeDatepickerCheck) {
3027
- const currentYear = this.currentDate.format("YYYY");
3028
- if (beforeChangeDatepickerCheck !== false && this.initMode == "year") {
3029
- this.beforeChangeDatepicker();
3030
- return;
3031
- }
3032
- const startYear = +currentYear - 8;
3033
- this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${startYear} ~ ${startYear + 15}`;
3034
- const beforeDrawDateFlag = utils_default.isFunction(this.options.beforeDrawDate);
3035
- const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
3036
- const calHTML = [];
3037
- for (let i = 0; i < 16; i++) {
3038
- const year = startYear + i;
3039
- const disabled = this.isYearDisabled(year);
3040
- let addStylceClass = disabled ? " disabled" : "";
3041
- let tooltip = "";
3042
- if (beforeDrawDateFlag && beforeDrawDateFn) {
3043
- const reval = beforeDrawDateFn({ mode: this._viewMode, date: year });
3044
- addStylceClass += reval.style ? " " + reval.style : "";
3045
- tooltip = reval.tooltip;
3046
- tooltip = tooltip ? `title="${tooltip}"` : "";
3047
- }
3048
- calHTML.push(`<div class="ddtp-year ${addStylceClass}" data-year="${year}" ${tooltip}>${year}</div>`);
3049
- }
3050
- this.datetimeElement.querySelector(".ddtp-years").innerHTML = calHTML.join("");
3051
- if (this.initMode == "year") {
3052
- this.afterChangeDatepicker();
3053
- }
3054
- this.datetimeElement.querySelectorAll(".ddtp-year")?.forEach((yearEle) => {
3055
- yearEle.addEventListener("click", (e) => {
3056
- const targetEle = e.target;
3057
- if (targetEle) {
3058
- const year = targetEle.getAttribute("data-year");
3059
- if (year) {
3060
- const numYear = +year;
3061
- if (this.isYearDisabled(numYear)) {
3062
- return;
3063
- }
3064
- if (this.initMode == "year") {
3065
- if (this.isYearDisabled(numYear)) {
3066
- return;
3067
- }
3068
- this.currentDate.setYear(numYear);
3069
- this.dateChangeEvent(e);
3070
- return;
3071
- }
3072
- this.currentDate.setYear(numYear);
3073
- this.viewMode = this.initMode;
3074
- }
3075
- }
3076
- });
3077
- });
3078
- }
3079
- /**
3080
- * 월 달력 그리기
3081
- */
3082
- monthDraw(beforeChangeDatepickerCheck) {
3083
- if (beforeChangeDatepickerCheck !== false && this.initMode == "month") {
3084
- this.beforeChangeDatepicker();
3085
- return;
3086
- }
3087
- const year = this.currentDate.format("YYYY");
3088
- this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${year}`;
3089
- const monthElements = this.datetimeElement.querySelectorAll(".ddtp-months > .ddtp-month");
3090
- if (monthElements.length > 0) {
3091
- if (this.isYearDisabled(+year)) {
3092
- monthElements.forEach((monthEle) => {
3093
- if (!monthEle.classList.contains("disabled")) {
3094
- monthEle.classList.add("disabled");
3095
- }
3096
- });
3097
- return;
3098
- }
3099
- monthElements.forEach((monthEle, idx) => {
3100
- if (this.isMonthDisabled(+year, idx)) {
3101
- if (!monthEle.classList.contains("disabled")) {
3102
- monthEle.classList.add("disabled");
3103
- }
3104
- } else {
3105
- monthEle.classList.remove("disabled");
3106
- }
3107
- });
3108
- if (this.initMode == "month") {
3109
- this.afterChangeDatepicker();
3110
- }
3111
- return;
3112
- }
3113
- this.datetimeElement.querySelector(".ddtp-header-month").textContent = this.currentDate.format("MMMM");
3114
- const beforeDrawDateFlag = utils_default.isFunction(this.options.beforeDrawDate);
3115
- const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
3116
- const calHTML = [];
3117
- for (let i = 0; i < 12; i++) {
3118
- const disabled = this.isMonthDisabled(+year, i);
3119
- let addStylceClass = disabled ? " disabled" : "";
3120
- let tooltip = "";
3121
- if (beforeDrawDateFlag && beforeDrawDateFn) {
3122
- const reval = beforeDrawDateFn({ mode: this._viewMode, date: year + "/" + (i + 1) });
3123
- addStylceClass += reval.style ? " " + reval.style : "";
3124
- tooltip = reval.tooltip;
3125
- tooltip = tooltip ? `title="${tooltip}"` : "";
3126
- }
3127
- calHTML.push(`<div class="ddtp-month ${addStylceClass}" data-month="${i}" ${tooltip}>${Lanauage_default2.getMonthsMessage(i, "abbr")}</div>`);
3128
- }
3129
- this.datetimeElement.querySelector(".ddtp-months").innerHTML = calHTML.join("");
3130
- if (this.initMode == "month") {
3131
- this.afterChangeDatepicker();
3132
- }
3133
- this.datetimeElement.querySelectorAll(".ddtp-month")?.forEach((monthEle) => {
3134
- monthEle.addEventListener("click", (e) => {
3135
- const targetEle = e.target;
3136
- if (targetEle) {
3137
- const month = targetEle.getAttribute("data-month");
3138
- if (month) {
3139
- if (this.isMonthDisabled(this.currentDate.getYear(), +month)) {
3140
- return false;
3141
- }
3142
- if (this.initMode == "month") {
3143
- this.currentDate.setMonth(+month);
3144
- this.dateChangeEvent(e);
3145
- return;
3146
- }
3147
- this.currentDate.setMonth(+month);
3148
- this.viewMode = this.initMode;
3149
- this.dayDraw();
3150
- }
3151
- }
3152
- });
3153
- });
3154
- }
3155
- /**
3156
- * 날짜 그리기
3157
- */
3158
- dayDraw(beforeChangeDatepickerCheck) {
3159
- if (beforeChangeDatepickerCheck !== false && (this.initMode == "date" || this.initMode == "datetime")) {
3160
- this.beforeChangeDatepicker();
3161
- return;
3162
- }
3163
- let monthFirstDate = this.currentDate.clone();
3164
- const currentMonth = monthFirstDate.getMonth();
3165
- monthFirstDate.setDate(1);
3166
- this.datetimeElement.querySelector(".ddtp-header-year").textContent = monthFirstDate.format("YYYY");
3167
- this.datetimeElement.querySelector(".ddtp-header-month").textContent = monthFirstDate.format("MMMM");
3168
- let day = monthFirstDate.getDay();
3169
- day = day - this.dayOrder[0];
3170
- if (day >= 0) {
3171
- monthFirstDate.addDate(-day);
3172
- } else {
3173
- monthFirstDate.addDate(-(7 + day));
3174
- }
3175
- const beforeDrawDateFlag = utils_default.isFunction(this.options.beforeDrawDate);
3176
- const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
3177
- const calHTML = [];
3178
- for (let i = 0; i < 42; i++) {
3179
- let dateItem;
3180
- if (i == 0) {
3181
- dateItem = monthFirstDate;
3182
- } else {
3183
- dateItem = monthFirstDate.clone().addDate(i);
3184
- }
3185
- const dateItemFormat = dateItem.format(DEFAULT_FORMAT.date);
3186
- if (i % 7 == 0) {
3187
- calHTML.push((i == 0 ? "" : "</tr>") + "<tr>");
3188
- }
3189
- let disabled = this.isDayDisabled(dateItem);
3190
- let addStylceClass = DAY_STYLE_CLASS[this.dayOrder[i % 7]];
3191
- const dateItemMonth = dateItem.getMonth();
3192
- if (dateItemMonth != currentMonth) {
3193
- if (dateItemMonth < currentMonth) {
3194
- addStylceClass += dateItemMonth == 1 ? " new" : " old";
3195
- } else {
3196
- addStylceClass += currentMonth == 1 && dateItemMonth == 12 ? " old" : " new";
3197
- }
3198
- }
3199
- addStylceClass += this.todayDate == dateItemFormat ? " today" : "";
3200
- addStylceClass += disabled ? " disabled" : "";
3201
- let tooltip = "";
3202
- if (beforeDrawDateFlag && beforeDrawDateFn) {
3203
- const reval = beforeDrawDateFn({ mode: this._viewMode, item: dateItem, date: dateItem.format(this.dateFormat) });
3204
- addStylceClass += reval.style ? " " + reval.style : "";
3205
- addStylceClass += reval.check ? " event" : "";
3206
- tooltip = reval.tooltip;
3207
- tooltip = tooltip ? `title="${tooltip}"` : "";
3208
- }
3209
- calHTML.push(`<td class="ddtp-day ${addStylceClass}" data-day="${dateItem.format("M,D")}" ${tooltip}>`);
3210
- calHTML.push(`<span>${dateItem.format("d")}</span>`);
3211
- calHTML.push("</td>");
3212
- }
3213
- calHTML.push("</tr>");
3214
- this.datetimeElement.querySelector(".ddtp-day-body").innerHTML = calHTML.join("");
3215
- if (this.initMode == "date" || this.initMode == "datetime") {
3216
- this.afterChangeDatepicker();
3217
- }
3218
- }
3219
- isDayDisabled(dateItem) {
3220
- if (this.minDate != -1 && this.minDate > dateItem.getTime() || this.maxDate != -1 && this.maxDate < dateItem.getTime()) {
3221
- return true;
3222
- }
3223
- return false;
3224
- }
3225
- isYearDisabled(year) {
3226
- if (this.minYear != -1 && this.minYear > year || this.maxYear != -1 && this.maxYear < year) {
3227
- return true;
3228
- }
3229
- return false;
3230
- }
3231
- isMonthDisabled(year, month) {
3232
- if (this.isYearDisabled(year)) {
3233
- return true;
3234
- }
3235
- let yearMonth = +(year + utils_default.pad(month, 2));
3236
- if (this.minMonth != -1 && this.minMonth > yearMonth || this.maxMonth != -1 && this.maxMonth < yearMonth) {
3237
- return true;
3238
- }
3239
- return false;
3240
- }
3241
- static setMessage(message2) {
3242
- Lanauage_default2.setDefaultMessage(message2);
3243
- }
3244
- };
3245
- }
3246
- });
3247
- init_daracl_datetimepicker = __esm2({
3248
- "style/daracl.datetimepicker.scss"() {
3249
- }
3250
- });
3251
- require_src = __commonJS2({
3252
- "src/index.ts"(exports, module) {
3253
- init_DateTimePicker();
3254
- init_daracl_datetimepicker();
3255
- module.exports = DateTimePicker;
3256
- }
3257
- });
3258
- dist_default = require_src();
3259
- }
3260
- });
3261
-
3262
1834
  // src/renderer/DateRender.ts
1835
+ import DateTimePicker from "@daracl/datetimepicker";
3263
1836
  var DateRender;
3264
1837
  var init_DateRender = __esm({
3265
1838
  "src/renderer/DateRender.ts"() {
@@ -3267,7 +1840,6 @@ var init_DateRender = __esm({
3267
1840
  init_Render();
3268
1841
  init_stringValidator();
3269
1842
  init_validUtils();
3270
- init_dist();
3271
1843
  init_utils();
3272
1844
  DateRender = class extends Render {
3273
1845
  constructor(field, rowElement, daraForm) {
@@ -3296,7 +1868,7 @@ var init_DateRender = __esm({
3296
1868
  this.setValue(dt);
3297
1869
  this.valid();
3298
1870
  };
3299
- this.dateObj = new dist_default(this.element, this.field.customOptions, {});
1871
+ this.dateObj = new DateTimePicker(this.element, this.field.customOptions, {});
3300
1872
  }
3301
1873
  // async loadDate() {
3302
1874
  // const DateTimePicker = await import("@daracl/datetimepicker");
@@ -3351,7 +1923,7 @@ var init_styleUtils = __esm({
3351
1923
  "src/util/styleUtils.ts"() {
3352
1924
  "use strict";
3353
1925
  init_utils();
3354
- init_constants2();
1926
+ init_constants();
3355
1927
  styleUtils_default = {
3356
1928
  /**
3357
1929
  * field style 처리
@@ -3836,7 +2408,7 @@ var init_GridRender = __esm({
3836
2408
 
3837
2409
  // src/constants.ts
3838
2410
  var RULES, FIELD_PREFIX, RENDER_TEMPLATE, FIELD_POSITION_STYLE;
3839
- var init_constants2 = __esm({
2411
+ var init_constants = __esm({
3840
2412
  "src/constants.ts"() {
3841
2413
  "use strict";
3842
2414
  init_NumberRender();
@@ -3920,12 +2492,12 @@ function message(msgFormat, msgParam) {
3920
2492
  return typeof msgParam[key] !== "undefined" ? msgParam[key] : match;
3921
2493
  });
3922
2494
  }
3923
- var localeMessage2, Language2, Lanauage_default;
3924
- var init_Lanauage2 = __esm({
2495
+ var localeMessage, Language, Lanauage_default;
2496
+ var init_Lanauage = __esm({
3925
2497
  "src/util/Lanauage.ts"() {
3926
2498
  "use strict";
3927
- init_constants2();
3928
- localeMessage2 = {
2499
+ init_constants();
2500
+ localeMessage = {
3929
2501
  required: "{label} \uD544\uC218 \uC785\uB825\uC0AC\uD56D\uC785\uB2C8\uB2E4.",
3930
2502
  fileButton: "\uD30C\uC77C\uCC3E\uAE30",
3931
2503
  selection: "\uC120\uD0DD",
@@ -3959,9 +2531,9 @@ var init_Lanauage2 = __esm({
3959
2531
  "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."
3960
2532
  }
3961
2533
  };
3962
- Language2 = class {
2534
+ Language = class {
3963
2535
  constructor() {
3964
- this.lang = localeMessage2;
2536
+ this.lang = localeMessage;
3965
2537
  }
3966
2538
  /**
3967
2539
  * 다국어 메시지 등록
@@ -3970,7 +2542,7 @@ var init_Lanauage2 = __esm({
3970
2542
  * @param {?Message} [lang] 둥록할 메시지
3971
2543
  */
3972
2544
  set(lang) {
3973
- this.lang = Object.assign({}, localeMessage2, lang);
2545
+ this.lang = Object.assign({}, localeMessage, lang);
3974
2546
  }
3975
2547
  /**
3976
2548
  * 메시지 얻기
@@ -4023,7 +2595,7 @@ var init_Lanauage2 = __esm({
4023
2595
  return reMessage;
4024
2596
  }
4025
2597
  };
4026
- Lanauage_default = new Language2();
2598
+ Lanauage_default = new Language();
4027
2599
  }
4028
2600
  });
4029
2601
 
@@ -4032,7 +2604,7 @@ var getRenderer;
4032
2604
  var init_renderFactory = __esm({
4033
2605
  "src/util/renderFactory.ts"() {
4034
2606
  "use strict";
4035
- init_constants2();
2607
+ init_constants();
4036
2608
  init_utils();
4037
2609
  getRenderer = (field) => {
4038
2610
  let render;
@@ -4114,9 +2686,9 @@ var FieldInfoMap;
4114
2686
  var init_FieldInfoMap = __esm({
4115
2687
  "src/FieldInfoMap.ts"() {
4116
2688
  "use strict";
4117
- init_constants2();
2689
+ init_constants();
4118
2690
  init_renderFactory();
4119
- init_Lanauage2();
2691
+ init_Lanauage();
4120
2692
  init_utils();
4121
2693
  FieldInfoMap = class {
4122
2694
  constructor(selector, form) {
@@ -4503,7 +3075,7 @@ var init_DaraForm = __esm({
4503
3075
  "src/DaraForm.ts"() {
4504
3076
  "use strict";
4505
3077
  init_utils();
4506
- init_Lanauage2();
3078
+ init_Lanauage();
4507
3079
  init_stringValidator();
4508
3080
  init_numberValidator();
4509
3081
  init_regexpValidator();
@@ -4847,12 +3419,12 @@ var init_daracl_form = __esm({
4847
3419
  });
4848
3420
 
4849
3421
  // src/index.ts
4850
- var require_src2 = __commonJS({
3422
+ var require_src = __commonJS({
4851
3423
  "src/index.ts"(exports, module) {
4852
3424
  init_DaraForm();
4853
3425
  init_daracl_form();
4854
3426
  module.exports = DaraForm;
4855
3427
  }
4856
3428
  });
4857
- export default require_src2();
3429
+ export default require_src();
4858
3430
  //# sourceMappingURL=index.js.map