@daracl/form 0.0.4 → 0.0.5
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/193.daracl.form.min.js +7 -0
- package/dist/193.daracl.form.min.js.LICENSE.txt +5 -0
- package/dist/193.daracl.form.min.js.map +1 -0
- package/dist/dara.datetimepicker.js +304 -0
- package/dist/dara.datetimepicker.js.LICENSE.txt +5 -0
- package/dist/dara.datetimepicker.js.map +1 -0
- package/dist/daracl.form.js +52 -26
- package/dist/daracl.form.js.map +1 -1
- package/dist/daracl.form.min.css +2 -2
- package/dist/daracl.form.min.css.map +1 -1
- package/dist/daracl.form.min.js +2 -2
- package/dist/daracl.form.min.js.LICENSE.txt +1 -1
- package/dist/daracl.form.min.js.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.css.map +2 -2
- package/dist/index.js +5 -1
- package/dist/index.js.map +2 -2
- package/dist/util/utils.d.ts +1 -1
- package/dist/vendors-node_modules_daracl_datetimepicker_dist_index_js.daracl.form.js +1477 -0
- package/dist/vendors-node_modules_daracl_datetimepicker_dist_index_js.daracl.form.js.map +1 -0
- package/package.json +11 -8
- package/src/DaraForm.ts +431 -0
- package/src/FieldInfoMap.ts +356 -0
- package/src/FormTemplate.ts +207 -0
- package/src/constants.ts +100 -0
- package/src/event/renderEvents.ts +41 -0
- package/src/index copy.html +591 -0
- package/src/index-grid.html +655 -0
- package/src/index-tab.html +639 -0
- package/src/index.html +483 -0
- package/src/renderer/ButtonRender.ts +51 -0
- package/src/renderer/CheckboxRender.ts +214 -0
- package/src/renderer/CustomRender.ts +100 -0
- package/src/renderer/DateRender.ts +103 -0
- package/src/renderer/DropdownRender.ts +149 -0
- package/src/renderer/FileRender.ts +239 -0
- package/src/renderer/GridRender.ts +289 -0
- package/src/renderer/GroupRender.ts +47 -0
- package/src/renderer/HiddenRender.ts +36 -0
- package/src/renderer/NumberRender.ts +68 -0
- package/src/renderer/PasswordRender.ts +69 -0
- package/src/renderer/RadioRender.ts +191 -0
- package/src/renderer/RangeRender.ts +79 -0
- package/src/renderer/Render.ts +194 -0
- package/src/renderer/TabRender.ts +229 -0
- package/src/renderer/TextAreaRender.ts +72 -0
- package/src/renderer/TextRender.ts +68 -0
- package/src/rule/fileValidator.ts +26 -0
- package/src/rule/numberValidator.ts +96 -0
- package/src/rule/regexpValidator.ts +45 -0
- package/src/rule/stringValidator.ts +64 -0
- package/src/rule/validator.ts +49 -0
- package/src/types/DataMap.d.ts +17 -0
- package/src/types/FormField.d.ts +129 -0
- package/src/types/FormOptions.d.ts +91 -0
- package/src/types/Message.d.ts +40 -0
- package/src/types/ValidResult.d.ts +9 -0
- package/src/util/Lanauage.ts +127 -0
- package/src/util/renderFactory.ts +26 -0
- package/src/util/styleUtils.ts +85 -0
- package/src/util/utils.ts +283 -0
- package/src/util/validUtils.ts +53 -0
- package/style/daracl.form.scss +2 -1
|
@@ -0,0 +1,1477 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @daracl/form v0.0.4
|
|
3
|
+
* Copyright 2023-2024 darainfo and other contributors;
|
|
4
|
+
* Licensed MIT
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
(self["webpackChunkDaracl_form"] = self["webpackChunkDaracl_form"] || []).push([["vendors-node_modules_daracl_datetimepicker_dist_index_js"],{
|
|
8
|
+
|
|
9
|
+
/***/ "./node_modules/@daracl/datetimepicker/dist/index.js":
|
|
10
|
+
/*!***********************************************************!*\
|
|
11
|
+
!*** ./node_modules/@daracl/datetimepicker/dist/index.js ***!
|
|
12
|
+
\***********************************************************/
|
|
13
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14
|
+
|
|
15
|
+
__webpack_require__.r(__webpack_exports__);
|
|
16
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
17
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
18
|
+
/* harmony export */ });
|
|
19
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
20
|
+
var __esm = (fn, res) => function __init() {
|
|
21
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
22
|
+
};
|
|
23
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
24
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/Lanauage.ts
|
|
28
|
+
var localeMessage, Language, Lanauage_default;
|
|
29
|
+
var init_Lanauage = __esm({
|
|
30
|
+
"src/Lanauage.ts"() {
|
|
31
|
+
"use strict";
|
|
32
|
+
localeMessage = {
|
|
33
|
+
year: "Year",
|
|
34
|
+
month: "Month",
|
|
35
|
+
day: "Day",
|
|
36
|
+
am: "AM",
|
|
37
|
+
pm: "PM",
|
|
38
|
+
today: "Today",
|
|
39
|
+
ok: "Ok",
|
|
40
|
+
months: {
|
|
41
|
+
full: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
|
42
|
+
abbr: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
|
43
|
+
},
|
|
44
|
+
weeks: {
|
|
45
|
+
full: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
|
46
|
+
abbr: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Language = class {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.lang = localeMessage;
|
|
52
|
+
}
|
|
53
|
+
setDefaultMessage(lang) {
|
|
54
|
+
localeMessage = Object.assign(localeMessage, lang);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 다국어 메시지 등록
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
* @param {?Message} [lang] 둥록할 메시지
|
|
61
|
+
*/
|
|
62
|
+
set(lang) {
|
|
63
|
+
this.lang = Object.assign({}, localeMessage, lang);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 메시지 얻기
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
* @param {string} messageKey 메시지 키
|
|
70
|
+
* @returns {*}
|
|
71
|
+
*/
|
|
72
|
+
getMessage(messageKey) {
|
|
73
|
+
return this.lang[messageKey];
|
|
74
|
+
}
|
|
75
|
+
getMonthsMessage(idx, mode = "abbr") {
|
|
76
|
+
return this.lang.months[mode][idx] || "";
|
|
77
|
+
}
|
|
78
|
+
getWeeksMessage(idx, mode = "abbr") {
|
|
79
|
+
return this.lang.weeks[mode][idx] || "";
|
|
80
|
+
}
|
|
81
|
+
getMonthsIdx(val, mode = "abbr") {
|
|
82
|
+
return mode == "full" ? this.lang.months.full.indexOf(val) : this.lang.months.abbr.indexOf(val);
|
|
83
|
+
}
|
|
84
|
+
getWeeksIdx(val, mode = "abbr") {
|
|
85
|
+
return mode == "full" ? this.lang.weeks.full.indexOf(val) : this.lang.weeks.abbr.indexOf(val);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
Lanauage_default = new Language();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// src/constants.ts
|
|
93
|
+
var EXPRESSIONS_FORMAT, MAX_CHAR_LENGTH, DEFAULT_FORMAT, DAY_STYLE_CLASS, DateViewMode;
|
|
94
|
+
var init_constants = __esm({
|
|
95
|
+
"src/constants.ts"() {
|
|
96
|
+
"use strict";
|
|
97
|
+
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"];
|
|
98
|
+
MAX_CHAR_LENGTH = 0;
|
|
99
|
+
DEFAULT_FORMAT = {
|
|
100
|
+
year: "YYYY",
|
|
101
|
+
month: "YYYY-MM",
|
|
102
|
+
date: "YYYY-MM-DD",
|
|
103
|
+
time: "HH:mm",
|
|
104
|
+
datetime: "YYYY-MM-DD HH:mm"
|
|
105
|
+
};
|
|
106
|
+
DAY_STYLE_CLASS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
107
|
+
DateViewMode = /* @__PURE__ */ ((DateViewMode2) => {
|
|
108
|
+
DateViewMode2["year"] = "year";
|
|
109
|
+
DateViewMode2["month"] = "month";
|
|
110
|
+
DateViewMode2["date"] = "date";
|
|
111
|
+
DateViewMode2["datetime"] = "datetime";
|
|
112
|
+
DateViewMode2["time"] = "time";
|
|
113
|
+
return DateViewMode2;
|
|
114
|
+
})(DateViewMode || {});
|
|
115
|
+
EXPRESSIONS_FORMAT.forEach((item) => {
|
|
116
|
+
MAX_CHAR_LENGTH = Math.max(item.length, MAX_CHAR_LENGTH);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// src/util/utils.ts
|
|
122
|
+
var xssFilter, utils_default;
|
|
123
|
+
var init_utils = __esm({
|
|
124
|
+
"src/util/utils.ts"() {
|
|
125
|
+
"use strict";
|
|
126
|
+
xssFilter = {
|
|
127
|
+
"&": "&",
|
|
128
|
+
"<": "<",
|
|
129
|
+
">": ">",
|
|
130
|
+
'"': """,
|
|
131
|
+
"'": "'"
|
|
132
|
+
};
|
|
133
|
+
utils_default = {
|
|
134
|
+
replace(str) {
|
|
135
|
+
let returnText = str;
|
|
136
|
+
if (returnText) {
|
|
137
|
+
Object.keys(xssFilter).forEach((key) => {
|
|
138
|
+
returnText = returnText.replaceAll(key, xssFilter[key]);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return returnText;
|
|
142
|
+
},
|
|
143
|
+
unReplace(inputText) {
|
|
144
|
+
let returnText = inputText;
|
|
145
|
+
if (returnText) {
|
|
146
|
+
Object.keys(xssFilter).forEach((key) => {
|
|
147
|
+
returnText = returnText.replaceAll(xssFilter[key], key);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return returnText;
|
|
151
|
+
},
|
|
152
|
+
unFieldName(fieldName) {
|
|
153
|
+
if (fieldName) {
|
|
154
|
+
return this.unReplace(fieldName).replaceAll('"', '\\"');
|
|
155
|
+
}
|
|
156
|
+
return "";
|
|
157
|
+
},
|
|
158
|
+
isBlank(value) {
|
|
159
|
+
if (value === null)
|
|
160
|
+
return true;
|
|
161
|
+
if (value === "")
|
|
162
|
+
return true;
|
|
163
|
+
if (typeof value === "undefined")
|
|
164
|
+
return true;
|
|
165
|
+
if (typeof value === "string" && (value === "" || value.replace(/\s/g, "") === ""))
|
|
166
|
+
return true;
|
|
167
|
+
return false;
|
|
168
|
+
},
|
|
169
|
+
isUndefined(value) {
|
|
170
|
+
return typeof value === "undefined";
|
|
171
|
+
},
|
|
172
|
+
isFunction(value) {
|
|
173
|
+
return typeof value === "function";
|
|
174
|
+
},
|
|
175
|
+
isString(value) {
|
|
176
|
+
return typeof value === "string";
|
|
177
|
+
},
|
|
178
|
+
isNumber(value) {
|
|
179
|
+
if (this.isBlank(value)) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return !isNaN(value);
|
|
183
|
+
},
|
|
184
|
+
isArray(value) {
|
|
185
|
+
return Array.isArray(value);
|
|
186
|
+
},
|
|
187
|
+
getHashCode(str) {
|
|
188
|
+
let hash = 0;
|
|
189
|
+
if (str.length == 0)
|
|
190
|
+
return hash;
|
|
191
|
+
for (let i = 0; i < str.length; i++) {
|
|
192
|
+
let tmpChar = str.charCodeAt(i);
|
|
193
|
+
hash = (hash << 5) - hash + tmpChar;
|
|
194
|
+
hash = hash & hash;
|
|
195
|
+
}
|
|
196
|
+
return hash;
|
|
197
|
+
},
|
|
198
|
+
pad(str, length) {
|
|
199
|
+
str = String(str);
|
|
200
|
+
while (str.length < length) {
|
|
201
|
+
str = "0" + str;
|
|
202
|
+
}
|
|
203
|
+
return str;
|
|
204
|
+
},
|
|
205
|
+
closestElement(el, checkElement) {
|
|
206
|
+
let currentEl = el;
|
|
207
|
+
while (currentEl) {
|
|
208
|
+
if (currentEl == checkElement) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
currentEl = currentEl.parentElement;
|
|
212
|
+
}
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// src/format/index.ts
|
|
220
|
+
function getH(date) {
|
|
221
|
+
let hour = date.getHours();
|
|
222
|
+
if (hour > 12) {
|
|
223
|
+
hour -= 12;
|
|
224
|
+
} else if (hour < 1) {
|
|
225
|
+
hour = 12;
|
|
226
|
+
}
|
|
227
|
+
return hour;
|
|
228
|
+
}
|
|
229
|
+
function getMeridiem(date, isUpper, isShort) {
|
|
230
|
+
const hour = date.getHours();
|
|
231
|
+
let m = hour < 12 ? "am" : "pm";
|
|
232
|
+
m = Lanauage_default.getMessage(m);
|
|
233
|
+
m = isUpper ? m.toUpperCase() : m;
|
|
234
|
+
return m;
|
|
235
|
+
}
|
|
236
|
+
var format_default, expressionsFunction;
|
|
237
|
+
var init_format = __esm({
|
|
238
|
+
"src/format/index.ts"() {
|
|
239
|
+
"use strict";
|
|
240
|
+
init_Lanauage();
|
|
241
|
+
init_constants();
|
|
242
|
+
init_utils();
|
|
243
|
+
format_default = (date, format) => {
|
|
244
|
+
format = format || "YYYY-MM-DD";
|
|
245
|
+
const len = format.length;
|
|
246
|
+
let result = [];
|
|
247
|
+
for (let i = 0; i < len; ) {
|
|
248
|
+
let minLen = Math.min(MAX_CHAR_LENGTH, len - i);
|
|
249
|
+
let j = minLen;
|
|
250
|
+
for (; j > 0; j--) {
|
|
251
|
+
const v = format.substring(i, i + j);
|
|
252
|
+
if (EXPRESSIONS_FORMAT.includes(v)) {
|
|
253
|
+
try {
|
|
254
|
+
result.push(expressionsFunction[v](date));
|
|
255
|
+
} catch (e) {
|
|
256
|
+
console.log(EXPRESSIONS_FORMAT.includes(v), v, e);
|
|
257
|
+
}
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (j < 1) {
|
|
262
|
+
result.push(format.substring(i, i + 1));
|
|
263
|
+
i += 1;
|
|
264
|
+
} else {
|
|
265
|
+
i += j;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return result.join("");
|
|
269
|
+
};
|
|
270
|
+
expressionsFunction = {
|
|
271
|
+
YY: (date) => {
|
|
272
|
+
return String(date.getFullYear()).slice(-2);
|
|
273
|
+
},
|
|
274
|
+
YYYY: (date) => {
|
|
275
|
+
return String(date.getFullYear());
|
|
276
|
+
},
|
|
277
|
+
M: (date) => {
|
|
278
|
+
return String(date.getMonth() + 1);
|
|
279
|
+
},
|
|
280
|
+
MM: (date) => {
|
|
281
|
+
return utils_default.pad(date.getMonth() + 1, 2);
|
|
282
|
+
},
|
|
283
|
+
MMM: (date) => {
|
|
284
|
+
return Lanauage_default.getMonthsMessage(date.getMonth());
|
|
285
|
+
},
|
|
286
|
+
MMMM: (date) => {
|
|
287
|
+
return Lanauage_default.getMonthsMessage(date.getMonth(), "full");
|
|
288
|
+
},
|
|
289
|
+
D: (date) => {
|
|
290
|
+
return String(date.getDate());
|
|
291
|
+
},
|
|
292
|
+
DD: (date) => {
|
|
293
|
+
return utils_default.pad(date.getDate(), 2);
|
|
294
|
+
},
|
|
295
|
+
d: (date) => {
|
|
296
|
+
return String(date.getDate());
|
|
297
|
+
},
|
|
298
|
+
dd: (date) => {
|
|
299
|
+
return utils_default.pad(date.getDate(), 2);
|
|
300
|
+
},
|
|
301
|
+
ddd: (date) => {
|
|
302
|
+
return Lanauage_default.getWeeksMessage(date.getDay());
|
|
303
|
+
},
|
|
304
|
+
dddd: (date) => {
|
|
305
|
+
return Lanauage_default.getWeeksMessage(date.getDay(), "full");
|
|
306
|
+
},
|
|
307
|
+
H: (date) => {
|
|
308
|
+
return String(date.getHours());
|
|
309
|
+
},
|
|
310
|
+
HH: (date) => {
|
|
311
|
+
return utils_default.pad(date.getHours(), 2);
|
|
312
|
+
},
|
|
313
|
+
h: (date) => {
|
|
314
|
+
return getH(date);
|
|
315
|
+
},
|
|
316
|
+
hh: (date) => {
|
|
317
|
+
return utils_default.pad(getH(date), 2);
|
|
318
|
+
},
|
|
319
|
+
a: (date) => {
|
|
320
|
+
return String(date.getFullYear()).slice(-2);
|
|
321
|
+
},
|
|
322
|
+
A: (date) => {
|
|
323
|
+
return getMeridiem(date, true, true);
|
|
324
|
+
},
|
|
325
|
+
m: (date) => {
|
|
326
|
+
return String(date.getMinutes());
|
|
327
|
+
},
|
|
328
|
+
mm: (date) => {
|
|
329
|
+
return utils_default.pad(date.getMinutes(), 2);
|
|
330
|
+
},
|
|
331
|
+
s: (date) => {
|
|
332
|
+
return String(date.getSeconds());
|
|
333
|
+
},
|
|
334
|
+
ss: (date) => {
|
|
335
|
+
return utils_default.pad(date.getSeconds(), 2);
|
|
336
|
+
},
|
|
337
|
+
SSS: (date) => {
|
|
338
|
+
return utils_default.pad(date.getMilliseconds(), 3);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// src/util/parser.ts
|
|
345
|
+
var parser_default, matchFind, digitsCheck, word, expressionsFunction2;
|
|
346
|
+
var init_parser = __esm({
|
|
347
|
+
"src/util/parser.ts"() {
|
|
348
|
+
"use strict";
|
|
349
|
+
init_Lanauage();
|
|
350
|
+
init_constants();
|
|
351
|
+
parser_default = (dateStr, format) => {
|
|
352
|
+
if (dateStr.length > 1e3) {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
format = format || DEFAULT_FORMAT.date;
|
|
356
|
+
const dateInfo = {
|
|
357
|
+
year: (/* @__PURE__ */ new Date()).getFullYear(),
|
|
358
|
+
month: 0,
|
|
359
|
+
day: 1,
|
|
360
|
+
hour: 0,
|
|
361
|
+
minute: 0,
|
|
362
|
+
second: 0,
|
|
363
|
+
millisecond: 0,
|
|
364
|
+
isPm: false,
|
|
365
|
+
isH: false,
|
|
366
|
+
charIdx: 0
|
|
367
|
+
};
|
|
368
|
+
const len = format.length;
|
|
369
|
+
let startIdx = 0;
|
|
370
|
+
for (let i = 0; i < len; ) {
|
|
371
|
+
let minLen = Math.min(MAX_CHAR_LENGTH, len - i);
|
|
372
|
+
let j = minLen;
|
|
373
|
+
for (; j > 0; j--) {
|
|
374
|
+
const v = format.substring(i, i + j);
|
|
375
|
+
if (EXPRESSIONS_FORMAT.includes(v)) {
|
|
376
|
+
const expInfo = expressionsFunction2[v];
|
|
377
|
+
const val = matchFind(dateStr.substring(startIdx), expInfo[0]);
|
|
378
|
+
expInfo[1](dateInfo, val);
|
|
379
|
+
startIdx += val.length;
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
if (j < 1) {
|
|
384
|
+
i += 1;
|
|
385
|
+
startIdx += 1;
|
|
386
|
+
} else {
|
|
387
|
+
i += j;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (dateInfo.hour != null && !dateInfo.isH) {
|
|
391
|
+
if (dateInfo.isPm && +dateInfo.hour !== 12) {
|
|
392
|
+
dateInfo.hour = +dateInfo.hour + 12;
|
|
393
|
+
} else if (!dateInfo.isPm && +dateInfo.hour === 12) {
|
|
394
|
+
dateInfo.hour = 0;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
let date;
|
|
398
|
+
date = new Date(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute, dateInfo.second, dateInfo.millisecond);
|
|
399
|
+
return date;
|
|
400
|
+
};
|
|
401
|
+
matchFind = (val, regexp) => {
|
|
402
|
+
const match = regexp.exec(val);
|
|
403
|
+
return match == null ? "" : match[0];
|
|
404
|
+
};
|
|
405
|
+
digitsCheck = {
|
|
406
|
+
twoOptional: /\d\d?/,
|
|
407
|
+
two: /\d\d/,
|
|
408
|
+
three: /\d{3}/,
|
|
409
|
+
four: /\d{4}/
|
|
410
|
+
};
|
|
411
|
+
word = /[^\s]+/;
|
|
412
|
+
expressionsFunction2 = {
|
|
413
|
+
YY: [
|
|
414
|
+
digitsCheck["two"],
|
|
415
|
+
(dateInfo, val) => {
|
|
416
|
+
dateInfo.year = +(("" + (/* @__PURE__ */ new Date()).getFullYear()).substring(0, 2) + val);
|
|
417
|
+
return dateInfo;
|
|
418
|
+
}
|
|
419
|
+
],
|
|
420
|
+
YYYY: [
|
|
421
|
+
digitsCheck["four"],
|
|
422
|
+
(dateInfo, val) => {
|
|
423
|
+
dateInfo.year = +val;
|
|
424
|
+
return dateInfo;
|
|
425
|
+
}
|
|
426
|
+
],
|
|
427
|
+
M: [
|
|
428
|
+
digitsCheck["twoOptional"],
|
|
429
|
+
(dateInfo, val) => {
|
|
430
|
+
dateInfo.month = +val - 1;
|
|
431
|
+
return dateInfo;
|
|
432
|
+
}
|
|
433
|
+
],
|
|
434
|
+
MM: [
|
|
435
|
+
digitsCheck["two"],
|
|
436
|
+
(dateInfo, val) => {
|
|
437
|
+
dateInfo.month = +val - 1;
|
|
438
|
+
return dateInfo;
|
|
439
|
+
}
|
|
440
|
+
],
|
|
441
|
+
MMM: [
|
|
442
|
+
word,
|
|
443
|
+
(dateInfo, val) => {
|
|
444
|
+
dateInfo.month = Lanauage_default.getMonthsIdx(val, "abbr");
|
|
445
|
+
return dateInfo;
|
|
446
|
+
}
|
|
447
|
+
],
|
|
448
|
+
MMMM: [
|
|
449
|
+
word,
|
|
450
|
+
(dateInfo, val) => {
|
|
451
|
+
dateInfo.month = Lanauage_default.getMonthsIdx(val, "full");
|
|
452
|
+
return dateInfo;
|
|
453
|
+
}
|
|
454
|
+
],
|
|
455
|
+
D: [
|
|
456
|
+
digitsCheck["twoOptional"],
|
|
457
|
+
(dateInfo, val) => {
|
|
458
|
+
dateInfo.day = +val;
|
|
459
|
+
return dateInfo;
|
|
460
|
+
}
|
|
461
|
+
],
|
|
462
|
+
DD: [
|
|
463
|
+
digitsCheck["two"],
|
|
464
|
+
(dateInfo, val) => {
|
|
465
|
+
dateInfo.day = +val;
|
|
466
|
+
return dateInfo;
|
|
467
|
+
}
|
|
468
|
+
],
|
|
469
|
+
d: [
|
|
470
|
+
digitsCheck["twoOptional"],
|
|
471
|
+
(dateInfo, val) => {
|
|
472
|
+
dateInfo.day = +val;
|
|
473
|
+
return dateInfo;
|
|
474
|
+
}
|
|
475
|
+
],
|
|
476
|
+
dd: [
|
|
477
|
+
digitsCheck["two"],
|
|
478
|
+
(dateInfo, val) => {
|
|
479
|
+
dateInfo.day = +val;
|
|
480
|
+
return dateInfo;
|
|
481
|
+
}
|
|
482
|
+
],
|
|
483
|
+
ddd: [
|
|
484
|
+
word,
|
|
485
|
+
(dateInfo, val) => {
|
|
486
|
+
return dateInfo;
|
|
487
|
+
}
|
|
488
|
+
],
|
|
489
|
+
dddd: [
|
|
490
|
+
word,
|
|
491
|
+
(dateInfo, val) => {
|
|
492
|
+
return dateInfo;
|
|
493
|
+
}
|
|
494
|
+
],
|
|
495
|
+
H: [
|
|
496
|
+
digitsCheck["twoOptional"],
|
|
497
|
+
(dateInfo, val) => {
|
|
498
|
+
dateInfo.hour = +val;
|
|
499
|
+
dateInfo.isH = true;
|
|
500
|
+
return dateInfo;
|
|
501
|
+
}
|
|
502
|
+
],
|
|
503
|
+
HH: [
|
|
504
|
+
digitsCheck["two"],
|
|
505
|
+
(dateInfo, val) => {
|
|
506
|
+
dateInfo.hour = +val;
|
|
507
|
+
dateInfo.isH = true;
|
|
508
|
+
return dateInfo;
|
|
509
|
+
}
|
|
510
|
+
],
|
|
511
|
+
h: [
|
|
512
|
+
digitsCheck["twoOptional"],
|
|
513
|
+
(dateInfo, val) => {
|
|
514
|
+
dateInfo.hour = +val;
|
|
515
|
+
return dateInfo;
|
|
516
|
+
}
|
|
517
|
+
],
|
|
518
|
+
hh: [
|
|
519
|
+
digitsCheck["two"],
|
|
520
|
+
(dateInfo, val) => {
|
|
521
|
+
dateInfo.hour = +val;
|
|
522
|
+
return dateInfo;
|
|
523
|
+
}
|
|
524
|
+
],
|
|
525
|
+
a: [
|
|
526
|
+
word,
|
|
527
|
+
(dateInfo, val) => {
|
|
528
|
+
if (Lanauage_default.getMessage("am") != val.toLowerCase()) {
|
|
529
|
+
dateInfo.isPm = true;
|
|
530
|
+
}
|
|
531
|
+
return dateInfo;
|
|
532
|
+
}
|
|
533
|
+
],
|
|
534
|
+
A: [
|
|
535
|
+
word,
|
|
536
|
+
(dateInfo, val) => {
|
|
537
|
+
if (Lanauage_default.getMessage("am") != val.toLowerCase()) {
|
|
538
|
+
dateInfo.isPm = true;
|
|
539
|
+
}
|
|
540
|
+
return dateInfo;
|
|
541
|
+
}
|
|
542
|
+
],
|
|
543
|
+
m: [
|
|
544
|
+
digitsCheck["twoOptional"],
|
|
545
|
+
(dateInfo, val) => {
|
|
546
|
+
dateInfo.minute = +val;
|
|
547
|
+
return dateInfo;
|
|
548
|
+
}
|
|
549
|
+
],
|
|
550
|
+
mm: [
|
|
551
|
+
digitsCheck["two"],
|
|
552
|
+
(dateInfo, val) => {
|
|
553
|
+
dateInfo.minute = +val;
|
|
554
|
+
return dateInfo;
|
|
555
|
+
}
|
|
556
|
+
],
|
|
557
|
+
s: [
|
|
558
|
+
digitsCheck["twoOptional"],
|
|
559
|
+
(dateInfo, val) => {
|
|
560
|
+
dateInfo.second = +val;
|
|
561
|
+
return dateInfo;
|
|
562
|
+
}
|
|
563
|
+
],
|
|
564
|
+
ss: [
|
|
565
|
+
digitsCheck["two"],
|
|
566
|
+
(dateInfo, val) => {
|
|
567
|
+
dateInfo.second = +val;
|
|
568
|
+
return dateInfo;
|
|
569
|
+
}
|
|
570
|
+
],
|
|
571
|
+
SSS: [
|
|
572
|
+
digitsCheck["three"],
|
|
573
|
+
(dateInfo, val) => {
|
|
574
|
+
dateInfo.millisecond = +val;
|
|
575
|
+
return dateInfo;
|
|
576
|
+
}
|
|
577
|
+
]
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
// src/DaraDate.ts
|
|
583
|
+
var DaraDate;
|
|
584
|
+
var init_DaraDate = __esm({
|
|
585
|
+
"src/DaraDate.ts"() {
|
|
586
|
+
"use strict";
|
|
587
|
+
init_format();
|
|
588
|
+
DaraDate = class _DaraDate {
|
|
589
|
+
constructor(dt) {
|
|
590
|
+
this.date = dt;
|
|
591
|
+
}
|
|
592
|
+
setYear(num) {
|
|
593
|
+
this.date.setFullYear(num);
|
|
594
|
+
return this;
|
|
595
|
+
}
|
|
596
|
+
addYear(num) {
|
|
597
|
+
this.date.setFullYear(this.date.getFullYear() + num);
|
|
598
|
+
return this;
|
|
599
|
+
}
|
|
600
|
+
addMonth(num) {
|
|
601
|
+
this.date.setMonth(this.date.getMonth() + num);
|
|
602
|
+
return this;
|
|
603
|
+
}
|
|
604
|
+
setMonth(num) {
|
|
605
|
+
this.date.setMonth(num);
|
|
606
|
+
return this;
|
|
607
|
+
}
|
|
608
|
+
setDate(num) {
|
|
609
|
+
this.date.setDate(num);
|
|
610
|
+
return this;
|
|
611
|
+
}
|
|
612
|
+
addDate(num) {
|
|
613
|
+
this.date.setDate(this.date.getDate() + num);
|
|
614
|
+
return this;
|
|
615
|
+
}
|
|
616
|
+
addWeek(num) {
|
|
617
|
+
this.date.setDate(this.date.getDate() + num * 7);
|
|
618
|
+
return this;
|
|
619
|
+
}
|
|
620
|
+
addHours(num) {
|
|
621
|
+
this.date.setHours(this.date.getHours() + num);
|
|
622
|
+
return this;
|
|
623
|
+
}
|
|
624
|
+
setHour(num) {
|
|
625
|
+
this.date.setHours(num);
|
|
626
|
+
return this;
|
|
627
|
+
}
|
|
628
|
+
addMinutes(num) {
|
|
629
|
+
this.date.setMinutes(this.date.getMinutes() + num);
|
|
630
|
+
return this;
|
|
631
|
+
}
|
|
632
|
+
setMinutes(num) {
|
|
633
|
+
this.date.setMinutes(num);
|
|
634
|
+
return this;
|
|
635
|
+
}
|
|
636
|
+
addSeconds(num) {
|
|
637
|
+
this.date.setSeconds(this.date.getSeconds() + num);
|
|
638
|
+
return this;
|
|
639
|
+
}
|
|
640
|
+
addMilliseconds(num) {
|
|
641
|
+
this.date.setMilliseconds(this.date.getMilliseconds() + num);
|
|
642
|
+
return this;
|
|
643
|
+
}
|
|
644
|
+
compare(date) {
|
|
645
|
+
if (this.date.valueOf() < date.valueOf()) {
|
|
646
|
+
return -1;
|
|
647
|
+
} else if (this.date.valueOf() > date.valueOf()) {
|
|
648
|
+
return 1;
|
|
649
|
+
}
|
|
650
|
+
return 0;
|
|
651
|
+
}
|
|
652
|
+
getYear() {
|
|
653
|
+
return this.date.getFullYear();
|
|
654
|
+
}
|
|
655
|
+
getMonth() {
|
|
656
|
+
return this.date.getMonth() + 1;
|
|
657
|
+
}
|
|
658
|
+
getDate() {
|
|
659
|
+
return this.date.getDate();
|
|
660
|
+
}
|
|
661
|
+
getDay() {
|
|
662
|
+
return this.date.getDay();
|
|
663
|
+
}
|
|
664
|
+
getTime() {
|
|
665
|
+
return this.date.getTime();
|
|
666
|
+
}
|
|
667
|
+
format(format) {
|
|
668
|
+
return format_default(this.date, format);
|
|
669
|
+
}
|
|
670
|
+
clone() {
|
|
671
|
+
return new _DaraDate(new Date(this.date.valueOf()));
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
// src/DateTimePicker.ts
|
|
678
|
+
function hiddenElement() {
|
|
679
|
+
if (document.getElementById("hiddenDaraDatetimeElement") == null) {
|
|
680
|
+
document.querySelector("body")?.insertAdjacentHTML("beforeend", `<div id="hiddenDaraDatetimeElement" class="daracl-datetime-hidden"></div>`);
|
|
681
|
+
}
|
|
682
|
+
return document.getElementById("hiddenDaraDatetimeElement");
|
|
683
|
+
}
|
|
684
|
+
function getDocSize() {
|
|
685
|
+
return {
|
|
686
|
+
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
|
|
687
|
+
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
var DEFAULT_OPTIONS, daraDatetimeIdx, DateTimePicker;
|
|
691
|
+
var init_DateTimePicker = __esm({
|
|
692
|
+
"src/DateTimePicker.ts"() {
|
|
693
|
+
"use strict";
|
|
694
|
+
init_format();
|
|
695
|
+
init_parser();
|
|
696
|
+
init_Lanauage();
|
|
697
|
+
init_utils();
|
|
698
|
+
init_DaraDate();
|
|
699
|
+
init_constants();
|
|
700
|
+
DEFAULT_OPTIONS = {
|
|
701
|
+
inline: false,
|
|
702
|
+
// layer or innerhtml
|
|
703
|
+
weekStartDay: 0,
|
|
704
|
+
initialDate: "",
|
|
705
|
+
autoClose: true,
|
|
706
|
+
isRTL: false,
|
|
707
|
+
mode: "date" /* date */,
|
|
708
|
+
enableTodayBtn: true,
|
|
709
|
+
showMonthAfterYear: false,
|
|
710
|
+
isPositionFixed: false,
|
|
711
|
+
format: "",
|
|
712
|
+
zIndex: 1e3,
|
|
713
|
+
minDate: "",
|
|
714
|
+
maxDate: "",
|
|
715
|
+
beforeDrawDate: (dt) => {
|
|
716
|
+
return {
|
|
717
|
+
check: false,
|
|
718
|
+
style: "",
|
|
719
|
+
tooltip: ""
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
daraDatetimeIdx = 0;
|
|
724
|
+
DateTimePicker = class _DateTimePicker {
|
|
725
|
+
constructor(selector, options, message) {
|
|
726
|
+
this.isInput = false;
|
|
727
|
+
this.isVisible = false;
|
|
728
|
+
this.minYear = -1;
|
|
729
|
+
this.maxYear = -1;
|
|
730
|
+
this.minMonth = -1;
|
|
731
|
+
this.maxMonth = -1;
|
|
732
|
+
// 요일 순서.
|
|
733
|
+
this.dayOrder = [0, 1, 2, 3, 4, 5, 6];
|
|
734
|
+
/**
|
|
735
|
+
* 바탕 클릭시 캘린더 숨김 처리.
|
|
736
|
+
*
|
|
737
|
+
* @param e
|
|
738
|
+
*/
|
|
739
|
+
this._documentClickEvent = (e) => {
|
|
740
|
+
if (this.isVisible && e.target != this.targetElement && !utils_default.closestElement(e.target, this.datetimeElement)) {
|
|
741
|
+
this.hide();
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
this.options = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
745
|
+
daraDatetimeIdx += 1;
|
|
746
|
+
let selectorElement;
|
|
747
|
+
if (typeof selector === "string") {
|
|
748
|
+
selectorElement = document.querySelector(selector);
|
|
749
|
+
} else {
|
|
750
|
+
selectorElement = selector;
|
|
751
|
+
}
|
|
752
|
+
if (!selectorElement) {
|
|
753
|
+
throw new Error(`${selector} datetimepicker element not found`);
|
|
754
|
+
}
|
|
755
|
+
this._viewMode = Object.keys(DateViewMode).includes(this.options.mode) ? this.options.mode : "date" /* date */;
|
|
756
|
+
this.initMode = this._viewMode;
|
|
757
|
+
Lanauage_default.set(message);
|
|
758
|
+
if (this.initMode == "year" /* year */) {
|
|
759
|
+
this.dateFormat = this.options.format || DEFAULT_FORMAT.year;
|
|
760
|
+
} else if (this.initMode == "month" /* month */) {
|
|
761
|
+
this.dateFormat = this.options.format || DEFAULT_FORMAT.month;
|
|
762
|
+
} else if (this.initMode == "time" /* time */) {
|
|
763
|
+
this.dateFormat = this.options.format || DEFAULT_FORMAT.time;
|
|
764
|
+
} else if (this.initMode == "datetime" /* datetime */) {
|
|
765
|
+
this.dateFormat = this.options.format || DEFAULT_FORMAT.datetime;
|
|
766
|
+
} else {
|
|
767
|
+
this.dateFormat = this.options.format || DEFAULT_FORMAT.date;
|
|
768
|
+
}
|
|
769
|
+
let viewDate;
|
|
770
|
+
if (this.options.initialDate) {
|
|
771
|
+
if (typeof this.options.initialDate === "string") {
|
|
772
|
+
viewDate = new DaraDate(parser_default(this.options.initialDate, this.dateFormat) || /* @__PURE__ */ new Date());
|
|
773
|
+
} else {
|
|
774
|
+
viewDate = new DaraDate(this.options.initialDate);
|
|
775
|
+
}
|
|
776
|
+
} else {
|
|
777
|
+
viewDate = new DaraDate(/* @__PURE__ */ new Date());
|
|
778
|
+
this.options.initialDate = viewDate.format(this.dateFormat);
|
|
779
|
+
}
|
|
780
|
+
this.setWeekDays();
|
|
781
|
+
this.todayDate = viewDate.format(DEFAULT_FORMAT.date);
|
|
782
|
+
this.currentDate = viewDate;
|
|
783
|
+
this.targetElement = selectorElement;
|
|
784
|
+
this.minDate = this._minDate();
|
|
785
|
+
this.maxDate = this._maxDate();
|
|
786
|
+
if (this.options.inline) {
|
|
787
|
+
this.datetimeElement = selectorElement;
|
|
788
|
+
this.datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} embed`;
|
|
789
|
+
} else {
|
|
790
|
+
this.isInput = true;
|
|
791
|
+
this.targetElement.setAttribute("value", viewDate.format(this.dateFormat));
|
|
792
|
+
const datetimeElement = document.createElement("div");
|
|
793
|
+
datetimeElement.className = `daracl-datetime-wrapper ddtp-${daraDatetimeIdx} layer`;
|
|
794
|
+
datetimeElement.setAttribute("style", `z-index:${this.options.zIndex};`);
|
|
795
|
+
hiddenElement()?.appendChild(datetimeElement);
|
|
796
|
+
this.datetimeElement = datetimeElement;
|
|
797
|
+
this.initTargetEvent();
|
|
798
|
+
}
|
|
799
|
+
this.createDatetimeTemplate();
|
|
800
|
+
if (this.isTimeMode()) {
|
|
801
|
+
this.hourInputEle = this.datetimeElement.querySelector(".ddtp-hour");
|
|
802
|
+
this.minuteInputEle = this.datetimeElement.querySelector(".ddtp-minute");
|
|
803
|
+
} else {
|
|
804
|
+
this.hourInputEle = {};
|
|
805
|
+
this.minuteInputEle = {};
|
|
806
|
+
}
|
|
807
|
+
this.changeViewMode(this._viewMode);
|
|
808
|
+
this.initHeaderEvent();
|
|
809
|
+
this.initDateEvent();
|
|
810
|
+
this.initTimeEvent();
|
|
811
|
+
}
|
|
812
|
+
static {
|
|
813
|
+
this.VERSION = `${"0.0.4"}`;
|
|
814
|
+
}
|
|
815
|
+
static {
|
|
816
|
+
this.format = format_default;
|
|
817
|
+
}
|
|
818
|
+
static {
|
|
819
|
+
this.parser = parser_default;
|
|
820
|
+
}
|
|
821
|
+
setWeekDays() {
|
|
822
|
+
let weekStartDay = this.options.weekStartDay;
|
|
823
|
+
if (weekStartDay == 0)
|
|
824
|
+
return;
|
|
825
|
+
if (weekStartDay < 0 || weekStartDay > 6) {
|
|
826
|
+
weekStartDay = 0;
|
|
827
|
+
}
|
|
828
|
+
for (let i = 0; i < 7; i++) {
|
|
829
|
+
let day = weekStartDay + i;
|
|
830
|
+
this.dayOrder[i] = day < 7 ? day : day - 7;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
static create(selector, options, message) {
|
|
834
|
+
return new _DateTimePicker(selector, options, message);
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* default date format setting
|
|
838
|
+
* @example
|
|
839
|
+
```
|
|
840
|
+
setDefaultFormat({
|
|
841
|
+
year: "YYYY",
|
|
842
|
+
month: "YYYY-MM",
|
|
843
|
+
date: "YYYY-MM-DD",
|
|
844
|
+
time: "HH:mm",
|
|
845
|
+
datetime: "YYYY-MM-DD HH:mm",
|
|
846
|
+
});
|
|
847
|
+
```
|
|
848
|
+
* @public
|
|
849
|
+
* @static
|
|
850
|
+
* @param {*} dateFormat
|
|
851
|
+
*/
|
|
852
|
+
static setDefaultFormat(dateFormat) {
|
|
853
|
+
Object.assign(DEFAULT_FORMAT, dateFormat);
|
|
854
|
+
}
|
|
855
|
+
_minDate() {
|
|
856
|
+
let minDate = this.options.minDate;
|
|
857
|
+
if (minDate != "") {
|
|
858
|
+
if (typeof minDate === "string") {
|
|
859
|
+
const dt = parser_default(minDate, this.dateFormat);
|
|
860
|
+
if (!dt) {
|
|
861
|
+
return -1;
|
|
862
|
+
}
|
|
863
|
+
minDate = dt;
|
|
864
|
+
}
|
|
865
|
+
this.minYear = minDate.getFullYear();
|
|
866
|
+
this.minMonth = +(this.minYear + utils_default.pad(minDate.getMonth(), 2));
|
|
867
|
+
return new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate(), 0, 0).getTime();
|
|
868
|
+
}
|
|
869
|
+
return -1;
|
|
870
|
+
}
|
|
871
|
+
_maxDate() {
|
|
872
|
+
let maxDate = this.options.maxDate;
|
|
873
|
+
if (maxDate != "") {
|
|
874
|
+
if (typeof maxDate === "string") {
|
|
875
|
+
const dt = parser_default(maxDate, this.dateFormat);
|
|
876
|
+
if (!dt) {
|
|
877
|
+
return -1;
|
|
878
|
+
}
|
|
879
|
+
maxDate = dt;
|
|
880
|
+
}
|
|
881
|
+
this.maxYear = maxDate.getFullYear();
|
|
882
|
+
this.maxMonth = +(this.maxYear + utils_default.pad(maxDate.getMonth(), 2));
|
|
883
|
+
return new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59).getTime();
|
|
884
|
+
}
|
|
885
|
+
return -1;
|
|
886
|
+
}
|
|
887
|
+
set viewMode(mode) {
|
|
888
|
+
if (this._viewMode === mode) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
this._viewMode = mode;
|
|
892
|
+
this.changeViewMode(mode);
|
|
893
|
+
}
|
|
894
|
+
get viewMode() {
|
|
895
|
+
return this._viewMode;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* 모드 change
|
|
899
|
+
* @param mode
|
|
900
|
+
*/
|
|
901
|
+
changeViewMode(mode) {
|
|
902
|
+
this.datetimeElement.querySelector(".ddtp-datetime")?.setAttribute("view-mode", mode);
|
|
903
|
+
if (mode === "year") {
|
|
904
|
+
this.yearDraw();
|
|
905
|
+
} else if (mode === "month") {
|
|
906
|
+
this.monthDraw();
|
|
907
|
+
} else {
|
|
908
|
+
this.dayDraw();
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* init header event
|
|
913
|
+
*
|
|
914
|
+
* @public
|
|
915
|
+
*/
|
|
916
|
+
initHeaderEvent() {
|
|
917
|
+
const isRTL = this.options.isRTL;
|
|
918
|
+
this.datetimeElement.querySelector(".ddtp-move-btn.prev")?.addEventListener("click", (e) => {
|
|
919
|
+
this.moveDate(isRTL ? "next" : "prev", e);
|
|
920
|
+
});
|
|
921
|
+
this.datetimeElement.querySelector(".ddtp-move-btn.next")?.addEventListener("click", (e) => {
|
|
922
|
+
this.moveDate(isRTL ? "prev" : "next", e);
|
|
923
|
+
});
|
|
924
|
+
this.datetimeElement.querySelector(".ddtp-header-year")?.addEventListener("click", (e) => {
|
|
925
|
+
this.viewMode = "year" /* year */;
|
|
926
|
+
});
|
|
927
|
+
this.datetimeElement.querySelector(".ddtp-header-month")?.addEventListener("click", (e) => {
|
|
928
|
+
this.viewMode = "month" /* month */;
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* 날짜 달력 이벤트처리.
|
|
933
|
+
*/
|
|
934
|
+
initDateEvent() {
|
|
935
|
+
this.datetimeElement.querySelector(".ddtp-day-body")?.addEventListener("click", (e) => {
|
|
936
|
+
const targetEle = e.target;
|
|
937
|
+
if (targetEle.classList.contains("ddtp-day") || targetEle.closest(".ddtp-day")) {
|
|
938
|
+
const selectDate = targetEle.getAttribute("data-day") || "1";
|
|
939
|
+
const mmDD = selectDate.split(",");
|
|
940
|
+
this.currentDate.setMonth(+mmDD[0] - 1);
|
|
941
|
+
this.currentDate.setDate(+mmDD[1]);
|
|
942
|
+
if (this.isDayDisabled(this.currentDate)) {
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
this.datetimeElement.querySelector(".select")?.classList.remove("select");
|
|
946
|
+
targetEle.classList.add("select");
|
|
947
|
+
if (this.isTimeMode()) {
|
|
948
|
+
this.currentDate.setHour(+this.hourInputEle.value);
|
|
949
|
+
this.currentDate.setMinutes(+this.minuteInputEle.value);
|
|
950
|
+
}
|
|
951
|
+
this.dateChangeEvent(e);
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
this.datetimeElement.querySelector(".time-today")?.addEventListener("click", (e) => {
|
|
955
|
+
const initDate = new DaraDate(parser_default(this.todayDate, DEFAULT_FORMAT.date) || /* @__PURE__ */ new Date());
|
|
956
|
+
this.currentDate.setYear(initDate.getYear());
|
|
957
|
+
this.currentDate.setMonth(initDate.getMonth() - 1);
|
|
958
|
+
this.currentDate.setDate(initDate.getDate());
|
|
959
|
+
this.changeViewMode(this.initMode);
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
isTimeMode() {
|
|
963
|
+
return this._viewMode === "time" /* time */ || this._viewMode === "datetime" /* datetime */;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* 시간 분 설정 이벤트 처리.
|
|
967
|
+
*
|
|
968
|
+
* @public
|
|
969
|
+
*/
|
|
970
|
+
initTimeEvent() {
|
|
971
|
+
if (!this.isTimeMode())
|
|
972
|
+
return;
|
|
973
|
+
let hh = this.currentDate.format("HH");
|
|
974
|
+
const hourInputEle = this.datetimeElement.querySelector(".ddtp-hour");
|
|
975
|
+
const hourRangeEle = this.datetimeElement.querySelector(".ddtp-hour-range");
|
|
976
|
+
hourInputEle.value = hh;
|
|
977
|
+
hourRangeEle.value = hh;
|
|
978
|
+
hourInputEle.addEventListener("input", (e) => {
|
|
979
|
+
const targetElement = e.target;
|
|
980
|
+
const addVal = utils_default.pad(targetElement.value, 2);
|
|
981
|
+
hourInputEle.value = addVal;
|
|
982
|
+
hourRangeEle.value = addVal;
|
|
983
|
+
});
|
|
984
|
+
hourRangeEle.addEventListener("input", (e) => {
|
|
985
|
+
const targetElement = e.target;
|
|
986
|
+
hourInputEle.value = utils_default.pad(targetElement.value, 2);
|
|
987
|
+
});
|
|
988
|
+
let mm = this.currentDate.format("mm");
|
|
989
|
+
const minuteInputEle = this.datetimeElement.querySelector(".ddtp-minute");
|
|
990
|
+
const minuteRangeEle = this.datetimeElement.querySelector(".ddtp-minute-range");
|
|
991
|
+
minuteInputEle.value = mm;
|
|
992
|
+
minuteRangeEle.value = mm;
|
|
993
|
+
minuteInputEle.addEventListener("input", (e) => {
|
|
994
|
+
const targetElement = e.target;
|
|
995
|
+
const addVal = utils_default.pad(targetElement.value, 2);
|
|
996
|
+
minuteInputEle.value = addVal;
|
|
997
|
+
minuteRangeEle.value = addVal;
|
|
998
|
+
});
|
|
999
|
+
minuteRangeEle.addEventListener("input", (e) => {
|
|
1000
|
+
const targetElement = e.target;
|
|
1001
|
+
minuteInputEle.value = utils_default.pad(targetElement.value, 2);
|
|
1002
|
+
});
|
|
1003
|
+
this.datetimeElement.querySelector(".time-select")?.addEventListener("click", (e) => {
|
|
1004
|
+
this.currentDate.setHour(+hourInputEle.value);
|
|
1005
|
+
this.currentDate.setMinutes(+minuteInputEle.value);
|
|
1006
|
+
this.dateChangeEvent(e);
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* 날짜 이동
|
|
1011
|
+
* @param moveMode // 앞뒤 이동 prev, next
|
|
1012
|
+
* @returns
|
|
1013
|
+
*/
|
|
1014
|
+
moveDate(moveMode, e) {
|
|
1015
|
+
if (this._viewMode === "date" /* date */ || this._viewMode === "datetime" /* datetime */) {
|
|
1016
|
+
this.currentDate.setDate(1);
|
|
1017
|
+
this.currentDate.addMonth("prev" === moveMode ? -1 : 1);
|
|
1018
|
+
this.dayDraw();
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
if (this._viewMode === "month" /* month */) {
|
|
1022
|
+
this.currentDate.setDate(1);
|
|
1023
|
+
this.currentDate.addYear("prev" === moveMode ? -1 : 1);
|
|
1024
|
+
this.monthDraw();
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
if (this._viewMode === "year" /* year */) {
|
|
1028
|
+
this.currentDate.setDate(1);
|
|
1029
|
+
this.currentDate.addYear("prev" === moveMode ? -16 : 16);
|
|
1030
|
+
this.yearDraw();
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* get date value
|
|
1035
|
+
*
|
|
1036
|
+
* @returns
|
|
1037
|
+
*/
|
|
1038
|
+
getDateValue() {
|
|
1039
|
+
return this.currentDate.format(this.dateFormat);
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* 옵션 셋팅
|
|
1043
|
+
* @static
|
|
1044
|
+
* @param {DateTimePickerOptions} options
|
|
1045
|
+
*/
|
|
1046
|
+
static setOptions(options) {
|
|
1047
|
+
DEFAULT_OPTIONS = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* 달력 보이기 처리.
|
|
1051
|
+
*
|
|
1052
|
+
* @returns
|
|
1053
|
+
*/
|
|
1054
|
+
show() {
|
|
1055
|
+
if (this.isVisible) {
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
this.isVisible = true;
|
|
1059
|
+
const docSize = getDocSize();
|
|
1060
|
+
this.datetimeElement.classList.remove("hide");
|
|
1061
|
+
this.datetimeElement.classList.add("show");
|
|
1062
|
+
const rect = this.targetElement.getBoundingClientRect();
|
|
1063
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
1064
|
+
const scrollLeft = window.scrollX || document.documentElement.scrollLeft;
|
|
1065
|
+
const elementHeight = this.datetimeElement.offsetHeight;
|
|
1066
|
+
const targetElementHeight = this.targetElement.offsetHeight + 2;
|
|
1067
|
+
let left = rect.left + scrollLeft;
|
|
1068
|
+
let top = 0;
|
|
1069
|
+
if (this.options.isPositionFixed) {
|
|
1070
|
+
top = rect.top + targetElementHeight;
|
|
1071
|
+
left = rect.left;
|
|
1072
|
+
} else {
|
|
1073
|
+
if (rect.top + targetElementHeight + elementHeight > docSize.clientHeight && rect.top >= elementHeight) {
|
|
1074
|
+
top = scrollTop + rect.top - elementHeight - 2;
|
|
1075
|
+
} else {
|
|
1076
|
+
top = scrollTop + rect.top + targetElementHeight;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
this.datetimeElement.setAttribute("style", `${this.options.isPositionFixed ? "position:fixed;" : ""}top:${top}px;left:${left}px;z-index:${this.options.zIndex}`);
|
|
1080
|
+
document.addEventListener("click", this._documentClickEvent);
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* 달력 숨기기
|
|
1084
|
+
*/
|
|
1085
|
+
hide() {
|
|
1086
|
+
this.isVisible = false;
|
|
1087
|
+
if (this.options.onClose) {
|
|
1088
|
+
if (this.options.onClose() === false) {
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
this.datetimeElement.classList.remove("show");
|
|
1093
|
+
this.datetimeElement.classList.add("hide");
|
|
1094
|
+
document.removeEventListener("click", this._documentClickEvent);
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* 타켓 이벤트 처리.
|
|
1098
|
+
*/
|
|
1099
|
+
initTargetEvent() {
|
|
1100
|
+
if (this.targetElement) {
|
|
1101
|
+
this.targetElement.addEventListener("click", (e) => {
|
|
1102
|
+
this.show();
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* 날짜 변경후 이벤트
|
|
1108
|
+
*/
|
|
1109
|
+
afterChangeDatepicker() {
|
|
1110
|
+
const formatValue = this.currentDate.format(this.dateFormat);
|
|
1111
|
+
if (this.options.afterChangeDatepicker && utils_default.isFunction(this.options.afterChangeDatepicker)) {
|
|
1112
|
+
this.options.afterChangeDatepicker(formatValue, this.viewMode);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* 날짜 변경 전 이벤트.
|
|
1117
|
+
* @returns void
|
|
1118
|
+
*/
|
|
1119
|
+
beforeChangeDatepicker() {
|
|
1120
|
+
const formatValue = this.currentDate.format(this.dateFormat);
|
|
1121
|
+
if (this.options.beforeChangeDatepicker && utils_default.isFunction(this.options.beforeChangeDatepicker)) {
|
|
1122
|
+
const reval = this.options.beforeChangeDatepicker(formatValue, (result) => {
|
|
1123
|
+
if (result === false) {
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
this.refresh(false);
|
|
1127
|
+
});
|
|
1128
|
+
if (reval === false) {
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
this.refresh(false);
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
this.refresh(false);
|
|
1135
|
+
}
|
|
1136
|
+
dateChangeEvent(e) {
|
|
1137
|
+
const formatValue = this.currentDate.format(this.dateFormat);
|
|
1138
|
+
if (this.options.onSelect) {
|
|
1139
|
+
if (this.options.onSelect(formatValue, this.viewMode, e) === false) {
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
if (this.isInput) {
|
|
1144
|
+
this.targetElement.setAttribute("value", formatValue);
|
|
1145
|
+
}
|
|
1146
|
+
if (!this.options.inline && this.options.autoClose) {
|
|
1147
|
+
this.hide();
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* datepicker template 그리기
|
|
1152
|
+
*/
|
|
1153
|
+
createDatetimeTemplate() {
|
|
1154
|
+
const showMonthAfterYear = this.options.showMonthAfterYear;
|
|
1155
|
+
let datetimeTemplate = `<div class="ddtp-datetime ${this.options.isRTL ? "rtl" : ""}" view-mode="${this._viewMode}">
|
|
1156
|
+
<div class="ddtp-header">
|
|
1157
|
+
<span class="${showMonthAfterYear ? "ddtp-header-year" : "ddtp-header-month"}"></span>
|
|
1158
|
+
<span class="${showMonthAfterYear ? "ddtp-header-month" : "ddtp-header-year"}"></span>
|
|
1159
|
+
|
|
1160
|
+
<span class="ddtp-date-move">
|
|
1161
|
+
<a href="javascript:;" class="ddtp-move-btn prev">
|
|
1162
|
+
<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>
|
|
1163
|
+
</a>
|
|
1164
|
+
<a href="javascript:;" class="ddtp-move-btn next">
|
|
1165
|
+
<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>
|
|
1166
|
+
</a>
|
|
1167
|
+
</span>
|
|
1168
|
+
</div>
|
|
1169
|
+
<div class="ddtp-body">
|
|
1170
|
+
<table class="ddtp-days">
|
|
1171
|
+
<thead class="ddtp-day-header">
|
|
1172
|
+
<tr>
|
|
1173
|
+
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[0]]}">${Lanauage_default.getWeeksMessage(this.dayOrder[0])}</td>
|
|
1174
|
+
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[1]]}">${Lanauage_default.getWeeksMessage(this.dayOrder[1])}</td>
|
|
1175
|
+
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[2]]}">${Lanauage_default.getWeeksMessage(this.dayOrder[2])}</td>
|
|
1176
|
+
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[3]]}">${Lanauage_default.getWeeksMessage(this.dayOrder[3])}</td>
|
|
1177
|
+
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[4]]}">${Lanauage_default.getWeeksMessage(this.dayOrder[4])}</td>
|
|
1178
|
+
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[5]]}">${Lanauage_default.getWeeksMessage(this.dayOrder[5])}</td>
|
|
1179
|
+
<td class="ddtp-day-label ${DAY_STYLE_CLASS[this.dayOrder[6]]}">${Lanauage_default.getWeeksMessage(this.dayOrder[6])}</td>
|
|
1180
|
+
</tr>
|
|
1181
|
+
</thead>
|
|
1182
|
+
<tbody class="ddtp-day-body">
|
|
1183
|
+
</tbody>
|
|
1184
|
+
|
|
1185
|
+
<tfoot class="ddtp-day-footer">
|
|
1186
|
+
<td colspan="7">
|
|
1187
|
+
<div style="text-align:center;margin-top: 5px;${this.options.enableTodayBtn ? "" : "display:none;"}"><button type="button" class="time-today">${Lanauage_default.getMessage("today")}</button></div>
|
|
1188
|
+
<div class="footer-tooltip"></div>
|
|
1189
|
+
</td>
|
|
1190
|
+
</tfoot>
|
|
1191
|
+
</table>
|
|
1192
|
+
|
|
1193
|
+
<div class="ddtp-times">
|
|
1194
|
+
<div class="time-container">
|
|
1195
|
+
<div class="ddtp-time">
|
|
1196
|
+
<span>H: </span><input type="number" class="ddtp-hour" min="0" max="23">
|
|
1197
|
+
<input type="range" min="0" max="23" class="ddtp-hour-range">
|
|
1198
|
+
</div>
|
|
1199
|
+
<div class="ddtp-time">
|
|
1200
|
+
<span>M: </span><input type="number" class="ddtp-minute" min="0" max="59">
|
|
1201
|
+
<input type="range" min="0" max="59" class="ddtp-minute-range">
|
|
1202
|
+
</div>
|
|
1203
|
+
</div>
|
|
1204
|
+
<div class="time-btn">
|
|
1205
|
+
<button type="button" class="time-select">${Lanauage_default.getMessage("ok")}</button>
|
|
1206
|
+
</div>
|
|
1207
|
+
</div>
|
|
1208
|
+
|
|
1209
|
+
<div class="ddtp-months">
|
|
1210
|
+
</div>
|
|
1211
|
+
|
|
1212
|
+
<div class="ddtp-years">
|
|
1213
|
+
</div>
|
|
1214
|
+
</div>
|
|
1215
|
+
</div>`;
|
|
1216
|
+
this.datetimeElement.innerHTML = datetimeTemplate;
|
|
1217
|
+
}
|
|
1218
|
+
refresh(beforeChangeDatepickerCheck) {
|
|
1219
|
+
if (this._viewMode === "date" /* date */ || this._viewMode === "datetime" /* datetime */) {
|
|
1220
|
+
this.dayDraw(beforeChangeDatepickerCheck);
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
if (this._viewMode === "month" /* month */) {
|
|
1224
|
+
this.monthDraw(beforeChangeDatepickerCheck);
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
if (this._viewMode === "year" /* year */) {
|
|
1228
|
+
this.yearDraw(beforeChangeDatepickerCheck);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* 년 달력 그리기
|
|
1233
|
+
*/
|
|
1234
|
+
yearDraw(beforeChangeDatepickerCheck) {
|
|
1235
|
+
const currentYear = this.currentDate.format("YYYY");
|
|
1236
|
+
if (beforeChangeDatepickerCheck !== false && this.initMode == "year" /* year */) {
|
|
1237
|
+
this.beforeChangeDatepicker();
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
const startYear = +currentYear - 8;
|
|
1241
|
+
this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${startYear} ~ ${startYear + 15}`;
|
|
1242
|
+
const beforeDrawDateFlag = utils_default.isFunction(this.options.beforeDrawDate);
|
|
1243
|
+
const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
|
|
1244
|
+
const calHTML = [];
|
|
1245
|
+
for (let i = 0; i < 16; i++) {
|
|
1246
|
+
const year = startYear + i;
|
|
1247
|
+
const disabled = this.isYearDisabled(year);
|
|
1248
|
+
let addStylceClass = disabled ? " disabled" : "";
|
|
1249
|
+
let tooltip = "";
|
|
1250
|
+
if (beforeDrawDateFlag && beforeDrawDateFn) {
|
|
1251
|
+
const reval = beforeDrawDateFn({ mode: this._viewMode, date: year });
|
|
1252
|
+
addStylceClass += reval.style ? " " + reval.style : "";
|
|
1253
|
+
tooltip = reval.tooltip;
|
|
1254
|
+
tooltip = tooltip ? `title="${tooltip}"` : "";
|
|
1255
|
+
}
|
|
1256
|
+
calHTML.push(`<div class="ddtp-year ${addStylceClass}" data-year="${year}" ${tooltip}>${year}</div>`);
|
|
1257
|
+
}
|
|
1258
|
+
this.datetimeElement.querySelector(".ddtp-years").innerHTML = calHTML.join("");
|
|
1259
|
+
if (this.initMode == "year" /* year */) {
|
|
1260
|
+
this.afterChangeDatepicker();
|
|
1261
|
+
}
|
|
1262
|
+
this.datetimeElement.querySelectorAll(".ddtp-year")?.forEach((yearEle) => {
|
|
1263
|
+
yearEle.addEventListener("click", (e) => {
|
|
1264
|
+
const targetEle = e.target;
|
|
1265
|
+
if (targetEle) {
|
|
1266
|
+
const year = targetEle.getAttribute("data-year");
|
|
1267
|
+
if (year) {
|
|
1268
|
+
const numYear = +year;
|
|
1269
|
+
if (this.isYearDisabled(numYear)) {
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
if (this.initMode == "year" /* year */) {
|
|
1273
|
+
if (this.isYearDisabled(numYear)) {
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
this.currentDate.setYear(numYear);
|
|
1277
|
+
this.dateChangeEvent(e);
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
this.currentDate.setYear(numYear);
|
|
1281
|
+
this.viewMode = this.initMode;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* 월 달력 그리기
|
|
1289
|
+
*/
|
|
1290
|
+
monthDraw(beforeChangeDatepickerCheck) {
|
|
1291
|
+
if (beforeChangeDatepickerCheck !== false && this.initMode == "month" /* month */) {
|
|
1292
|
+
this.beforeChangeDatepicker();
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
const year = this.currentDate.format("YYYY");
|
|
1296
|
+
this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${year}`;
|
|
1297
|
+
const monthElements = this.datetimeElement.querySelectorAll(".ddtp-months > .ddtp-month");
|
|
1298
|
+
if (monthElements.length > 0) {
|
|
1299
|
+
if (this.isYearDisabled(+year)) {
|
|
1300
|
+
monthElements.forEach((monthEle) => {
|
|
1301
|
+
if (!monthEle.classList.contains("disabled")) {
|
|
1302
|
+
monthEle.classList.add("disabled");
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
monthElements.forEach((monthEle, idx) => {
|
|
1308
|
+
if (this.isMonthDisabled(+year, idx)) {
|
|
1309
|
+
if (!monthEle.classList.contains("disabled")) {
|
|
1310
|
+
monthEle.classList.add("disabled");
|
|
1311
|
+
}
|
|
1312
|
+
} else {
|
|
1313
|
+
monthEle.classList.remove("disabled");
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
if (this.initMode == "month" /* month */) {
|
|
1317
|
+
this.afterChangeDatepicker();
|
|
1318
|
+
}
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
this.datetimeElement.querySelector(".ddtp-header-month").textContent = this.currentDate.format("MMMM");
|
|
1322
|
+
const beforeDrawDateFlag = utils_default.isFunction(this.options.beforeDrawDate);
|
|
1323
|
+
const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
|
|
1324
|
+
const calHTML = [];
|
|
1325
|
+
for (let i = 0; i < 12; i++) {
|
|
1326
|
+
const disabled = this.isMonthDisabled(+year, i);
|
|
1327
|
+
let addStylceClass = disabled ? " disabled" : "";
|
|
1328
|
+
let tooltip = "";
|
|
1329
|
+
if (beforeDrawDateFlag && beforeDrawDateFn) {
|
|
1330
|
+
const reval = beforeDrawDateFn({ mode: this._viewMode, date: year + "/" + (i + 1) });
|
|
1331
|
+
addStylceClass += reval.style ? " " + reval.style : "";
|
|
1332
|
+
tooltip = reval.tooltip;
|
|
1333
|
+
tooltip = tooltip ? `title="${tooltip}"` : "";
|
|
1334
|
+
}
|
|
1335
|
+
calHTML.push(`<div class="ddtp-month ${addStylceClass}" data-month="${i}" ${tooltip}>${Lanauage_default.getMonthsMessage(i, "abbr")}</div>`);
|
|
1336
|
+
}
|
|
1337
|
+
this.datetimeElement.querySelector(".ddtp-months").innerHTML = calHTML.join("");
|
|
1338
|
+
if (this.initMode == "month" /* month */) {
|
|
1339
|
+
this.afterChangeDatepicker();
|
|
1340
|
+
}
|
|
1341
|
+
this.datetimeElement.querySelectorAll(".ddtp-month")?.forEach((monthEle) => {
|
|
1342
|
+
monthEle.addEventListener("click", (e) => {
|
|
1343
|
+
const targetEle = e.target;
|
|
1344
|
+
if (targetEle) {
|
|
1345
|
+
const month = targetEle.getAttribute("data-month");
|
|
1346
|
+
if (month) {
|
|
1347
|
+
if (this.isMonthDisabled(this.currentDate.getYear(), +month)) {
|
|
1348
|
+
return false;
|
|
1349
|
+
}
|
|
1350
|
+
if (this.initMode == "month" /* month */) {
|
|
1351
|
+
this.currentDate.setMonth(+month);
|
|
1352
|
+
this.dateChangeEvent(e);
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
this.currentDate.setMonth(+month);
|
|
1356
|
+
this.viewMode = this.initMode;
|
|
1357
|
+
this.dayDraw();
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* 날짜 그리기
|
|
1365
|
+
*/
|
|
1366
|
+
dayDraw(beforeChangeDatepickerCheck) {
|
|
1367
|
+
if (beforeChangeDatepickerCheck !== false && (this.initMode == "date" /* date */ || this.initMode == "datetime" /* datetime */)) {
|
|
1368
|
+
this.beforeChangeDatepicker();
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
let monthFirstDate = this.currentDate.clone();
|
|
1372
|
+
const currentMonth = monthFirstDate.getMonth();
|
|
1373
|
+
monthFirstDate.setDate(1);
|
|
1374
|
+
this.datetimeElement.querySelector(".ddtp-header-year").textContent = monthFirstDate.format("YYYY");
|
|
1375
|
+
this.datetimeElement.querySelector(".ddtp-header-month").textContent = monthFirstDate.format("MMMM");
|
|
1376
|
+
let day = monthFirstDate.getDay();
|
|
1377
|
+
day = day - this.dayOrder[0];
|
|
1378
|
+
if (day >= 0) {
|
|
1379
|
+
monthFirstDate.addDate(-day);
|
|
1380
|
+
} else {
|
|
1381
|
+
monthFirstDate.addDate(-(7 + day));
|
|
1382
|
+
}
|
|
1383
|
+
const beforeDrawDateFlag = utils_default.isFunction(this.options.beforeDrawDate);
|
|
1384
|
+
const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
|
|
1385
|
+
const calHTML = [];
|
|
1386
|
+
for (let i = 0; i < 42; i++) {
|
|
1387
|
+
let dateItem;
|
|
1388
|
+
if (i == 0) {
|
|
1389
|
+
dateItem = monthFirstDate;
|
|
1390
|
+
} else {
|
|
1391
|
+
dateItem = monthFirstDate.clone().addDate(i);
|
|
1392
|
+
}
|
|
1393
|
+
const dateItemFormat = dateItem.format(DEFAULT_FORMAT.date);
|
|
1394
|
+
if (i % 7 == 0) {
|
|
1395
|
+
calHTML.push((i == 0 ? "" : "</tr>") + "<tr>");
|
|
1396
|
+
}
|
|
1397
|
+
let disabled = this.isDayDisabled(dateItem);
|
|
1398
|
+
let addStylceClass = DAY_STYLE_CLASS[this.dayOrder[i % 7]];
|
|
1399
|
+
const dateItemMonth = dateItem.getMonth();
|
|
1400
|
+
if (dateItemMonth != currentMonth) {
|
|
1401
|
+
if (dateItemMonth < currentMonth) {
|
|
1402
|
+
addStylceClass += dateItemMonth == 1 ? " new" : " old";
|
|
1403
|
+
} else {
|
|
1404
|
+
addStylceClass += currentMonth == 1 && dateItemMonth == 12 ? " old" : " new";
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
addStylceClass += this.todayDate == dateItemFormat ? " today" : "";
|
|
1408
|
+
addStylceClass += disabled ? " disabled" : "";
|
|
1409
|
+
let tooltip = "";
|
|
1410
|
+
if (beforeDrawDateFlag && beforeDrawDateFn) {
|
|
1411
|
+
const reval = beforeDrawDateFn({ mode: this._viewMode, item: dateItem, date: dateItem.format(this.dateFormat) });
|
|
1412
|
+
addStylceClass += reval.style ? " " + reval.style : "";
|
|
1413
|
+
addStylceClass += reval.check ? " event" : "";
|
|
1414
|
+
tooltip = reval.tooltip;
|
|
1415
|
+
tooltip = tooltip ? `title="${tooltip}"` : "";
|
|
1416
|
+
}
|
|
1417
|
+
calHTML.push(`<td class="ddtp-day ${addStylceClass}" data-day="${dateItem.format("M,D")}" ${tooltip}>`);
|
|
1418
|
+
calHTML.push(`<span>${dateItem.format("d")}</span>`);
|
|
1419
|
+
calHTML.push("</td>");
|
|
1420
|
+
}
|
|
1421
|
+
calHTML.push("</tr>");
|
|
1422
|
+
this.datetimeElement.querySelector(".ddtp-day-body").innerHTML = calHTML.join("");
|
|
1423
|
+
if (this.initMode == "date" /* date */ || this.initMode == "datetime" /* datetime */) {
|
|
1424
|
+
this.afterChangeDatepicker();
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
isDayDisabled(dateItem) {
|
|
1428
|
+
if (this.minDate != -1 && this.minDate > dateItem.getTime() || this.maxDate != -1 && this.maxDate < dateItem.getTime()) {
|
|
1429
|
+
return true;
|
|
1430
|
+
}
|
|
1431
|
+
return false;
|
|
1432
|
+
}
|
|
1433
|
+
isYearDisabled(year) {
|
|
1434
|
+
if (this.minYear != -1 && this.minYear > year || this.maxYear != -1 && this.maxYear < year) {
|
|
1435
|
+
return true;
|
|
1436
|
+
}
|
|
1437
|
+
return false;
|
|
1438
|
+
}
|
|
1439
|
+
isMonthDisabled(year, month) {
|
|
1440
|
+
if (this.isYearDisabled(year)) {
|
|
1441
|
+
return true;
|
|
1442
|
+
}
|
|
1443
|
+
let yearMonth = +(year + utils_default.pad(month, 2));
|
|
1444
|
+
if (this.minMonth != -1 && this.minMonth > yearMonth || this.maxMonth != -1 && this.maxMonth < yearMonth) {
|
|
1445
|
+
return true;
|
|
1446
|
+
}
|
|
1447
|
+
return false;
|
|
1448
|
+
}
|
|
1449
|
+
static setMessage(message) {
|
|
1450
|
+
Lanauage_default.setDefaultMessage(message);
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
|
|
1456
|
+
// style/daracl.datetimepicker.scss
|
|
1457
|
+
var init_daracl_datetimepicker = __esm({
|
|
1458
|
+
"style/daracl.datetimepicker.scss"() {
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
|
|
1462
|
+
// src/index.ts
|
|
1463
|
+
var require_src = __commonJS({
|
|
1464
|
+
"src/index.ts"(exports, module) {
|
|
1465
|
+
init_DateTimePicker();
|
|
1466
|
+
init_daracl_datetimepicker();
|
|
1467
|
+
module.exports = DateTimePicker;
|
|
1468
|
+
}
|
|
1469
|
+
});
|
|
1470
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (require_src());
|
|
1471
|
+
//# sourceMappingURL=index.js.map
|
|
1472
|
+
|
|
1473
|
+
|
|
1474
|
+
/***/ })
|
|
1475
|
+
|
|
1476
|
+
}]);
|
|
1477
|
+
//# sourceMappingURL=vendors-node_modules_daracl_datetimepicker_dist_index_js.daracl.form.js.map
|