@ncds/ui-admin 1.6.3 → 1.6.4-alpha.0
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/mcp/bin/server.d.ts +1 -0
- package/mcp/bin/server.js +62 -0
- package/mcp/bin/server.mjs +14 -0
- package/mcp/bin/tools/getComponentHtml.d.ts +3 -0
- package/mcp/bin/tools/getComponentHtml.js +30 -0
- package/mcp/bin/tools/getComponentProps.d.ts +3 -0
- package/mcp/bin/tools/getComponentProps.js +16 -0
- package/mcp/bin/tools/listComponents.d.ts +3 -0
- package/mcp/bin/tools/listComponents.js +15 -0
- package/mcp/bin/tools/searchComponent.d.ts +3 -0
- package/mcp/bin/tools/searchComponent.js +20 -0
- package/mcp/bin/tools/validateHtml.d.ts +10 -0
- package/mcp/bin/tools/validateHtml.js +142 -0
- package/mcp/bin/types.d.ts +28 -0
- package/mcp/bin/types.js +5 -0
- package/mcp/bin/utils/dataLoader.d.ts +11 -0
- package/mcp/bin/utils/dataLoader.js +68 -0
- package/mcp/bin/utils/logger.d.ts +18 -0
- package/mcp/bin/utils/logger.js +27 -0
- package/mcp/bin/utils/response.d.ts +23 -0
- package/mcp/bin/utils/response.js +31 -0
- package/mcp/bin/version.d.ts +1 -0
- package/mcp/bin/version.js +4 -0
- package/mcp/data/.gitkeep +0 -0
- package/mcp/data/_meta.json +7 -0
- package/mcp/data/badge-group.json +73 -0
- package/mcp/data/badge.json +86 -0
- package/mcp/data/bread-crumb.json +22 -0
- package/mcp/data/breadcrumb.json +31 -0
- package/mcp/data/button-group.json +65 -0
- package/mcp/data/button.json +114 -0
- package/mcp/data/carousel-arrow.json +59 -0
- package/mcp/data/carousel-number-group.json +57 -0
- package/mcp/data/carousel.json +22 -0
- package/mcp/data/checkbox.json +31 -0
- package/mcp/data/combobox.json +114 -0
- package/mcp/data/date-picker.json +77 -0
- package/mcp/data/divider.json +56 -0
- package/mcp/data/dot.json +55 -0
- package/mcp/data/dropdown.json +81 -0
- package/mcp/data/empty-state.json +34 -0
- package/mcp/data/featured-icon.json +83 -0
- package/mcp/data/file-input.json +76 -0
- package/mcp/data/horizontal-tab.json +71 -0
- package/mcp/data/image-file-input.json +97 -0
- package/mcp/data/input.json +104 -0
- package/mcp/data/modal.json +85 -0
- package/mcp/data/notification.json +116 -0
- package/mcp/data/number-input.json +128 -0
- package/mcp/data/pagination.json +65 -0
- package/mcp/data/password-input.json +47 -0
- package/mcp/data/progress-bar.json +51 -0
- package/mcp/data/progress-circle.json +54 -0
- package/mcp/data/radio.json +31 -0
- package/mcp/data/range-date-picker-with-buttons.json +64 -0
- package/mcp/data/range-date-picker.json +55 -0
- package/mcp/data/select-dropdown.json +32 -0
- package/mcp/data/select.json +64 -0
- package/mcp/data/selectbox.json +129 -0
- package/mcp/data/slider.json +57 -0
- package/mcp/data/spinner.json +54 -0
- package/mcp/data/switch.json +71 -0
- package/mcp/data/tab.json +122 -0
- package/mcp/data/tag.json +66 -0
- package/mcp/data/textarea.json +88 -0
- package/mcp/data/toggle.json +59 -0
- package/mcp/data/tooltip.json +123 -0
- package/mcp/data/vertical-tab.json +64 -0
- package/mcp/templates/.mcp.json.example +8 -0
- package/mcp/templates/README.md +31 -0
- package/package.json +24 -3
- package/dist/cjs/assets/scripts/comboBox.js +0 -280
- package/dist/cjs/assets/scripts/datePicker.js +0 -706
- package/dist/cjs/assets/scripts/featuredIcon.js +0 -95
- package/dist/cjs/assets/scripts/fileInput/FileInput.js +0 -183
- package/dist/cjs/assets/scripts/fileInput/FileInputModel.js +0 -246
- package/dist/cjs/assets/scripts/fileInput/FileInputView.js +0 -455
- package/dist/cjs/assets/scripts/fileInput/const/classNames.js +0 -35
- package/dist/cjs/assets/scripts/fileInput/const/index.js +0 -27
- package/dist/cjs/assets/scripts/fileInput/const/types.js +0 -13
- package/dist/cjs/assets/scripts/fileInput/index.js +0 -44
- package/dist/cjs/assets/scripts/imageFileInput/ImageFileInput.js +0 -187
- package/dist/cjs/assets/scripts/imageFileInput/ImageFileInputModel.js +0 -255
- package/dist/cjs/assets/scripts/imageFileInput/ImageFileInputView.js +0 -354
- package/dist/cjs/assets/scripts/imageFileInput/const/classNames.js +0 -41
- package/dist/cjs/assets/scripts/imageFileInput/const/index.js +0 -27
- package/dist/cjs/assets/scripts/imageFileInput/const/types.js +0 -13
- package/dist/cjs/assets/scripts/imageFileInput/index.js +0 -44
- package/dist/cjs/assets/scripts/index.js +0 -30
- package/dist/cjs/assets/scripts/modal/Modal.js +0 -116
- package/dist/cjs/assets/scripts/modal/ModalActions.js +0 -128
- package/dist/cjs/assets/scripts/modal/ModalContent.js +0 -46
- package/dist/cjs/assets/scripts/modal/ModalHeader.js +0 -115
- package/dist/cjs/assets/scripts/modal/const/classNames.js +0 -41
- package/dist/cjs/assets/scripts/modal/const/index.js +0 -27
- package/dist/cjs/assets/scripts/modal/const/types.js +0 -5
- package/dist/cjs/assets/scripts/modal/index.js +0 -61
- package/dist/cjs/assets/scripts/modal/utils/contentUtils.js +0 -35
- package/dist/cjs/assets/scripts/notification/FloatingNotification.js +0 -180
- package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +0 -120
- package/dist/cjs/assets/scripts/notification/MessageNotification.js +0 -146
- package/dist/cjs/assets/scripts/notification/Notification.js +0 -116
- package/dist/cjs/assets/scripts/notification/const/classNames.js +0 -50
- package/dist/cjs/assets/scripts/notification/const/icons.js +0 -45
- package/dist/cjs/assets/scripts/notification/const/index.js +0 -87
- package/dist/cjs/assets/scripts/notification/const/sizes.js +0 -54
- package/dist/cjs/assets/scripts/notification/const/types.js +0 -14
- package/dist/cjs/assets/scripts/notification/index.js +0 -92
- package/dist/cjs/assets/scripts/notification/utils.js +0 -92
- package/dist/cjs/assets/scripts/progress-bar/ProgressBar.js +0 -272
- package/dist/cjs/assets/scripts/progress-bar/index.js +0 -12
- package/dist/cjs/assets/scripts/selectBox.js +0 -319
- package/dist/cjs/assets/scripts/shared/ButtonCloseX.js +0 -46
- package/dist/cjs/assets/scripts/tab.js +0 -40
- package/dist/cjs/assets/scripts/tag/Tag.js +0 -268
- package/dist/cjs/assets/scripts/tag/const/classNames.js +0 -24
- package/dist/cjs/assets/scripts/tag/const/index.js +0 -38
- package/dist/cjs/assets/scripts/tag/const/sizes.js +0 -13
- package/dist/cjs/assets/scripts/tag/const/types.js +0 -5
- package/dist/cjs/assets/scripts/tag/index.js +0 -44
- package/dist/cjs/assets/scripts/tooltip/Tooltip.js +0 -380
- package/dist/cjs/assets/scripts/tooltip/TooltipLayerManager.js +0 -84
- package/dist/cjs/assets/scripts/tooltip/const/classNames.js +0 -29
- package/dist/cjs/assets/scripts/tooltip/const/constants.js +0 -56
- package/dist/cjs/assets/scripts/tooltip/const/icons.js +0 -15
- package/dist/cjs/assets/scripts/tooltip/const/index.js +0 -123
- package/dist/cjs/assets/scripts/tooltip/const/templates.js +0 -49
- package/dist/cjs/assets/scripts/tooltip/const/types.js +0 -5
- package/dist/cjs/assets/scripts/tooltip/index.js +0 -57
- package/dist/cjs/assets/scripts/tooltip/utils.js +0 -41
- package/dist/cjs/assets/scripts/utils/unifiedBox/DOMRenderer.js +0 -384
- package/dist/cjs/assets/scripts/utils/unifiedBox/DropdownModel.js +0 -368
- package/dist/cjs/assets/scripts/utils/unifiedBox/UnifiedBoxController.js +0 -681
- package/dist/cjs/assets/scripts/utils/unifiedBox/UnifiedBoxManager.js +0 -711
- package/dist/esm/assets/scripts/comboBox.js +0 -275
- package/dist/esm/assets/scripts/datePicker.js +0 -699
- package/dist/esm/assets/scripts/featuredIcon.js +0 -90
- package/dist/esm/assets/scripts/fileInput/FileInput.js +0 -178
- package/dist/esm/assets/scripts/fileInput/FileInputModel.js +0 -241
- package/dist/esm/assets/scripts/fileInput/FileInputView.js +0 -450
- package/dist/esm/assets/scripts/fileInput/const/classNames.js +0 -25
- package/dist/esm/assets/scripts/fileInput/const/index.js +0 -2
- package/dist/esm/assets/scripts/fileInput/const/types.js +0 -7
- package/dist/esm/assets/scripts/fileInput/index.js +0 -9
- package/dist/esm/assets/scripts/imageFileInput/ImageFileInput.js +0 -182
- package/dist/esm/assets/scripts/imageFileInput/ImageFileInputModel.js +0 -250
- package/dist/esm/assets/scripts/imageFileInput/ImageFileInputView.js +0 -349
- package/dist/esm/assets/scripts/imageFileInput/const/classNames.js +0 -30
- package/dist/esm/assets/scripts/imageFileInput/const/index.js +0 -2
- package/dist/esm/assets/scripts/imageFileInput/const/types.js +0 -7
- package/dist/esm/assets/scripts/imageFileInput/index.js +0 -9
- package/dist/esm/assets/scripts/index.js +0 -28
- package/dist/esm/assets/scripts/modal/Modal.js +0 -110
- package/dist/esm/assets/scripts/modal/ModalActions.js +0 -123
- package/dist/esm/assets/scripts/modal/ModalContent.js +0 -41
- package/dist/esm/assets/scripts/modal/ModalHeader.js +0 -110
- package/dist/esm/assets/scripts/modal/const/classNames.js +0 -31
- package/dist/esm/assets/scripts/modal/const/index.js +0 -2
- package/dist/esm/assets/scripts/modal/const/types.js +0 -1
- package/dist/esm/assets/scripts/modal/index.js +0 -15
- package/dist/esm/assets/scripts/modal/utils/contentUtils.js +0 -28
- package/dist/esm/assets/scripts/notification/FloatingNotification.js +0 -176
- package/dist/esm/assets/scripts/notification/FullWidthNotification.js +0 -115
- package/dist/esm/assets/scripts/notification/MessageNotification.js +0 -141
- package/dist/esm/assets/scripts/notification/Notification.js +0 -111
- package/dist/esm/assets/scripts/notification/const/classNames.js +0 -44
- package/dist/esm/assets/scripts/notification/const/icons.js +0 -39
- package/dist/esm/assets/scripts/notification/const/index.js +0 -4
- package/dist/esm/assets/scripts/notification/const/sizes.js +0 -48
- package/dist/esm/assets/scripts/notification/const/types.js +0 -8
- package/dist/esm/assets/scripts/notification/index.js +0 -11
- package/dist/esm/assets/scripts/notification/utils.js +0 -79
- package/dist/esm/assets/scripts/progress-bar/ProgressBar.js +0 -267
- package/dist/esm/assets/scripts/progress-bar/index.js +0 -1
- package/dist/esm/assets/scripts/selectBox.js +0 -314
- package/dist/esm/assets/scripts/shared/ButtonCloseX.js +0 -38
- package/dist/esm/assets/scripts/tab.js +0 -35
- package/dist/esm/assets/scripts/tag/Tag.js +0 -263
- package/dist/esm/assets/scripts/tag/const/classNames.js +0 -16
- package/dist/esm/assets/scripts/tag/const/index.js +0 -3
- package/dist/esm/assets/scripts/tag/const/sizes.js +0 -7
- package/dist/esm/assets/scripts/tag/const/types.js +0 -1
- package/dist/esm/assets/scripts/tag/index.js +0 -9
- package/dist/esm/assets/scripts/tooltip/Tooltip.js +0 -375
- package/dist/esm/assets/scripts/tooltip/TooltipLayerManager.js +0 -79
- package/dist/esm/assets/scripts/tooltip/const/classNames.js +0 -23
- package/dist/esm/assets/scripts/tooltip/const/constants.js +0 -50
- package/dist/esm/assets/scripts/tooltip/const/icons.js +0 -9
- package/dist/esm/assets/scripts/tooltip/const/index.js +0 -4
- package/dist/esm/assets/scripts/tooltip/const/templates.js +0 -42
- package/dist/esm/assets/scripts/tooltip/const/types.js +0 -1
- package/dist/esm/assets/scripts/tooltip/index.js +0 -10
- package/dist/esm/assets/scripts/tooltip/utils.js +0 -35
- package/dist/esm/assets/scripts/utils/unifiedBox/DOMRenderer.js +0 -379
- package/dist/esm/assets/scripts/utils/unifiedBox/DropdownModel.js +0 -363
- package/dist/esm/assets/scripts/utils/unifiedBox/UnifiedBoxController.js +0 -676
- package/dist/esm/assets/scripts/utils/unifiedBox/UnifiedBoxManager.js +0 -706
- package/dist/types/assets/scripts/comboBox.d.ts +0 -91
- package/dist/types/assets/scripts/datePicker.d.ts +0 -87
- package/dist/types/assets/scripts/featuredIcon.d.ts +0 -23
- package/dist/types/assets/scripts/fileInput/FileInput.d.ts +0 -67
- package/dist/types/assets/scripts/fileInput/FileInputModel.d.ts +0 -70
- package/dist/types/assets/scripts/fileInput/FileInputView.d.ts +0 -77
- package/dist/types/assets/scripts/fileInput/const/classNames.d.ts +0 -17
- package/dist/types/assets/scripts/fileInput/const/index.d.ts +0 -3
- package/dist/types/assets/scripts/fileInput/const/types.d.ts +0 -132
- package/dist/types/assets/scripts/fileInput/index.d.ts +0 -4
- package/dist/types/assets/scripts/imageFileInput/ImageFileInput.d.ts +0 -64
- package/dist/types/assets/scripts/imageFileInput/ImageFileInputModel.d.ts +0 -74
- package/dist/types/assets/scripts/imageFileInput/ImageFileInputView.d.ts +0 -80
- package/dist/types/assets/scripts/imageFileInput/const/classNames.d.ts +0 -20
- package/dist/types/assets/scripts/imageFileInput/const/index.d.ts +0 -3
- package/dist/types/assets/scripts/imageFileInput/const/types.d.ts +0 -126
- package/dist/types/assets/scripts/imageFileInput/index.d.ts +0 -4
- package/dist/types/assets/scripts/index.d.ts +0 -33
- package/dist/types/assets/scripts/modal/Modal.d.ts +0 -28
- package/dist/types/assets/scripts/modal/ModalActions.d.ts +0 -19
- package/dist/types/assets/scripts/modal/ModalContent.d.ts +0 -14
- package/dist/types/assets/scripts/modal/ModalHeader.d.ts +0 -16
- package/dist/types/assets/scripts/modal/const/classNames.d.ts +0 -23
- package/dist/types/assets/scripts/modal/const/index.d.ts +0 -3
- package/dist/types/assets/scripts/modal/const/types.d.ts +0 -62
- package/dist/types/assets/scripts/modal/index.d.ts +0 -8
- package/dist/types/assets/scripts/modal/utils/contentUtils.d.ts +0 -11
- package/dist/types/assets/scripts/notification/FloatingNotification.d.ts +0 -25
- package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +0 -22
- package/dist/types/assets/scripts/notification/MessageNotification.d.ts +0 -23
- package/dist/types/assets/scripts/notification/Notification.d.ts +0 -22
- package/dist/types/assets/scripts/notification/const/classNames.d.ts +0 -44
- package/dist/types/assets/scripts/notification/const/icons.d.ts +0 -26
- package/dist/types/assets/scripts/notification/const/index.d.ts +0 -6
- package/dist/types/assets/scripts/notification/const/sizes.d.ts +0 -33
- package/dist/types/assets/scripts/notification/const/types.d.ts +0 -20
- package/dist/types/assets/scripts/notification/index.d.ts +0 -8
- package/dist/types/assets/scripts/notification/utils.d.ts +0 -9
- package/dist/types/assets/scripts/progress-bar/ProgressBar.d.ts +0 -68
- package/dist/types/assets/scripts/progress-bar/index.d.ts +0 -2
- package/dist/types/assets/scripts/selectBox.d.ts +0 -77
- package/dist/types/assets/scripts/shared/ButtonCloseX.d.ts +0 -6
- package/dist/types/assets/scripts/tab.d.ts +0 -8
- package/dist/types/assets/scripts/tag/Tag.d.ts +0 -28
- package/dist/types/assets/scripts/tag/const/classNames.d.ts +0 -12
- package/dist/types/assets/scripts/tag/const/index.d.ts +0 -4
- package/dist/types/assets/scripts/tag/const/sizes.d.ts +0 -8
- package/dist/types/assets/scripts/tag/const/types.d.ts +0 -34
- package/dist/types/assets/scripts/tag/index.d.ts +0 -4
- package/dist/types/assets/scripts/tooltip/Tooltip.d.ts +0 -55
- package/dist/types/assets/scripts/tooltip/TooltipLayerManager.d.ts +0 -22
- package/dist/types/assets/scripts/tooltip/const/classNames.d.ts +0 -18
- package/dist/types/assets/scripts/tooltip/const/constants.d.ts +0 -34
- package/dist/types/assets/scripts/tooltip/const/icons.d.ts +0 -5
- package/dist/types/assets/scripts/tooltip/const/index.d.ts +0 -6
- package/dist/types/assets/scripts/tooltip/const/templates.d.ts +0 -17
- package/dist/types/assets/scripts/tooltip/const/types.d.ts +0 -15
- package/dist/types/assets/scripts/tooltip/index.d.ts +0 -7
- package/dist/types/assets/scripts/tooltip/utils.d.ts +0 -3
- package/dist/types/assets/scripts/utils/unifiedBox/DOMRenderer.d.ts +0 -108
- package/dist/types/assets/scripts/utils/unifiedBox/DropdownModel.d.ts +0 -158
- package/dist/types/assets/scripts/utils/unifiedBox/UnifiedBoxController.d.ts +0 -171
- package/dist/types/assets/scripts/utils/unifiedBox/UnifiedBoxManager.d.ts +0 -99
|
@@ -1,699 +0,0 @@
|
|
|
1
|
-
var __assign = this && this.__assign || function () {
|
|
2
|
-
__assign = Object.assign || function (t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
6
|
-
}
|
|
7
|
-
return t;
|
|
8
|
-
};
|
|
9
|
-
return __assign.apply(this, arguments);
|
|
10
|
-
};
|
|
11
|
-
import { formatDateInput, formatHourInput, formatMinuteInput } from '@ncds/ui-admin/src/utils/date-picker';
|
|
12
|
-
import flatpickr from 'flatpickr';
|
|
13
|
-
import { Korean } from 'flatpickr/dist/l10n/ko';
|
|
14
|
-
import moment from 'moment';
|
|
15
|
-
// Constants
|
|
16
|
-
var CONSTANTS = {
|
|
17
|
-
ICON_SIZES: {
|
|
18
|
-
xs: '14',
|
|
19
|
-
sm: '16'
|
|
20
|
-
},
|
|
21
|
-
CLASS_NAMES: {
|
|
22
|
-
RANGE_WRAPPER: 'ncua-range-date-picker',
|
|
23
|
-
RANGE_WITH_BUTTONS: 'ncua-range-date-picker-with-buttons',
|
|
24
|
-
DATE_PICKER: 'ncua-date-picker',
|
|
25
|
-
DATE_PICKER_INPUT: 'ncua-date-picker__input',
|
|
26
|
-
DATE_PICKER_ICO: 'ncua-date-picker__ico',
|
|
27
|
-
BUTTON_GROUP: 'ncua-button-group',
|
|
28
|
-
BUTTON_GROUP_HAS_BORDER: 'has-border',
|
|
29
|
-
BUTTON: 'ncua-button-group__item',
|
|
30
|
-
HAS_TIME: 'ncua-date-picker--has-time'
|
|
31
|
-
},
|
|
32
|
-
FORMATS: {
|
|
33
|
-
DATE: 'YYYY-MM-DD',
|
|
34
|
-
DATE_TIME: 'YYYY-MM-DD HH:mm'
|
|
35
|
-
},
|
|
36
|
-
ERROR_MESSAGES: {
|
|
37
|
-
FLATPICKR_NOT_LOADED: 'flatpickr 라이브러리가 로드되지 않았습니다.',
|
|
38
|
-
MOMENT_NOT_LOADED: 'moment 라이브러리가 로드되지 않았습니다.'
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
export var DatePicker = /** @class */function () {
|
|
42
|
-
function DatePicker(wrapper, options) {
|
|
43
|
-
var _a, _b;
|
|
44
|
-
this.flatpickrInstances = [];
|
|
45
|
-
this.currentButton = null;
|
|
46
|
-
var buttons = (_a = options.buttons, _a === void 0 ? [] : _a),
|
|
47
|
-
size = options.size,
|
|
48
|
-
autoComplete = (_b = options.autoComplete, _b === void 0 ? 'off' : _b),
|
|
49
|
-
datePickerOptions = options.datePickerOptions,
|
|
50
|
-
onValidationError = options.onValidationError;
|
|
51
|
-
this.validateWrapper(wrapper);
|
|
52
|
-
this.validationDependencies((buttons === null || buttons === void 0 ? void 0 : buttons.length) > 0);
|
|
53
|
-
this.instanceId = DatePicker.instanceCounter++;
|
|
54
|
-
this.contentWrapper = wrapper;
|
|
55
|
-
this.datePickerOptions = datePickerOptions;
|
|
56
|
-
this.buttons = buttons;
|
|
57
|
-
this.size = size;
|
|
58
|
-
this.separator = '~';
|
|
59
|
-
this.autoComplete = autoComplete;
|
|
60
|
-
this.dateFormat = datePickerOptions[0].options.enableTime ? CONSTANTS.FORMATS.DATE_TIME : CONSTANTS.FORMATS.DATE;
|
|
61
|
-
this.onValidationError = onValidationError;
|
|
62
|
-
this.init();
|
|
63
|
-
}
|
|
64
|
-
DatePicker.prototype.validateWrapper = function (wrapper) {
|
|
65
|
-
if (DatePicker.usedWrappers.has(wrapper)) {
|
|
66
|
-
throw new Error("\uC774\uBBF8 \uC0AC\uC6A9 \uC911\uC778 DOM \uC694\uC18C\uC785\uB2C8\uB2E4. " + "\uAC19\uC740 DOM \uC694\uC18C\uC5D0\uB294 \uD558\uB098\uC758 DatePicker \uC778\uC2A4\uD134\uC2A4\uB9CC \uC0DD\uC131\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. " + "\uB2E4\uB978 DOM \uC694\uC18C\uB97C \uC0AC\uC6A9\uD558\uAC70\uB098 \uAE30\uC874 \uC778\uC2A4\uD134\uC2A4\uB97C \uBA3C\uC800 \uC81C\uAC70\uD574\uC8FC\uC138\uC694.");
|
|
67
|
-
}
|
|
68
|
-
DatePicker.usedWrappers.add(wrapper);
|
|
69
|
-
};
|
|
70
|
-
DatePicker.prototype.init = function () {
|
|
71
|
-
this.contentWrapper.innerHTML = '';
|
|
72
|
-
this.initializeWrapper();
|
|
73
|
-
this.initButtonGroup();
|
|
74
|
-
this.initDatePicker();
|
|
75
|
-
};
|
|
76
|
-
DatePicker.prototype.validationDependencies = function (hasButtons) {
|
|
77
|
-
if (typeof flatpickr === 'undefined') {
|
|
78
|
-
throw new Error(CONSTANTS.ERROR_MESSAGES.FLATPICKR_NOT_LOADED);
|
|
79
|
-
}
|
|
80
|
-
if (hasButtons && typeof moment === 'undefined') {
|
|
81
|
-
throw new Error(CONSTANTS.ERROR_MESSAGES.MOMENT_NOT_LOADED);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
DatePicker.prototype.initializeWrapper = function () {
|
|
85
|
-
if (this.datePickerOptions.length < 2) return;
|
|
86
|
-
this.contentWrapper.classList.add(CONSTANTS.CLASS_NAMES.RANGE_WRAPPER);
|
|
87
|
-
};
|
|
88
|
-
DatePicker.prototype.initButtonGroup = function () {
|
|
89
|
-
var _this = this;
|
|
90
|
-
if (this.buttons.length === 0) return;
|
|
91
|
-
if (this.contentWrapper.classList.contains(CONSTANTS.CLASS_NAMES.RANGE_WRAPPER)) {
|
|
92
|
-
this.contentWrapper.classList.replace(CONSTANTS.CLASS_NAMES.RANGE_WRAPPER, CONSTANTS.CLASS_NAMES.RANGE_WITH_BUTTONS);
|
|
93
|
-
}
|
|
94
|
-
this.contentWrapper.classList.add(CONSTANTS.CLASS_NAMES.RANGE_WITH_BUTTONS);
|
|
95
|
-
var createButtonWrapperElement = function () {
|
|
96
|
-
var wrapper = document.createElement('div');
|
|
97
|
-
wrapper.className = "".concat(CONSTANTS.CLASS_NAMES.BUTTON_GROUP, " ").concat(CONSTANTS.CLASS_NAMES.BUTTON_GROUP_HAS_BORDER, " ").concat(CONSTANTS.CLASS_NAMES.BUTTON_GROUP, "--").concat(_this.size);
|
|
98
|
-
return wrapper;
|
|
99
|
-
};
|
|
100
|
-
var appendButtons = function (wrapper) {
|
|
101
|
-
_this.buttons.forEach(function (button) {
|
|
102
|
-
var buttonElement = _this.createButtonElement(button);
|
|
103
|
-
wrapper.appendChild(buttonElement);
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
var wrapper = createButtonWrapperElement();
|
|
107
|
-
appendButtons(wrapper);
|
|
108
|
-
wrapper.addEventListener('click', this.updateDateWithButton.bind(this));
|
|
109
|
-
this.contentWrapper.appendChild(wrapper);
|
|
110
|
-
};
|
|
111
|
-
DatePicker.prototype.createButtonElement = function (button) {
|
|
112
|
-
if (button.isCurrent) {
|
|
113
|
-
this.currentButton = button;
|
|
114
|
-
}
|
|
115
|
-
var buttonElement = document.createElement('button');
|
|
116
|
-
buttonElement.className = "".concat(CONSTANTS.CLASS_NAMES.BUTTON, " ").concat(button.isCurrent ? 'is-current' : '');
|
|
117
|
-
buttonElement.textContent = button.text;
|
|
118
|
-
buttonElement.type = 'button';
|
|
119
|
-
return buttonElement;
|
|
120
|
-
};
|
|
121
|
-
DatePicker.prototype.reRenderButtonGroup = function (buttons) {
|
|
122
|
-
var _this = this;
|
|
123
|
-
var buttonGroup = this.contentWrapper.querySelector(".".concat(CONSTANTS.CLASS_NAMES.BUTTON_GROUP));
|
|
124
|
-
if (!buttonGroup) return;
|
|
125
|
-
buttonGroup.innerHTML = '';
|
|
126
|
-
buttons.forEach(function (button) {
|
|
127
|
-
if (button.isCurrent) {
|
|
128
|
-
_this.currentButton = button;
|
|
129
|
-
}
|
|
130
|
-
buttonGroup.appendChild(_this.createButtonElement(button));
|
|
131
|
-
});
|
|
132
|
-
this.buttons = buttons;
|
|
133
|
-
};
|
|
134
|
-
DatePicker.prototype.initDatePicker = function () {
|
|
135
|
-
var _this = this;
|
|
136
|
-
var datePickerOptions = this.datePickerOptions;
|
|
137
|
-
var createInputWrapperElement = function (size) {
|
|
138
|
-
var wrapper = document.createElement('div');
|
|
139
|
-
wrapper.className = "".concat(CONSTANTS.CLASS_NAMES.DATE_PICKER, " ").concat(CONSTANTS.CLASS_NAMES.DATE_PICKER, "--").concat(size, " ").concat(_this.datePickerOptions.some(function (option) {
|
|
140
|
-
return option.options.enableTime;
|
|
141
|
-
}) ? CONSTANTS.CLASS_NAMES.HAS_TIME : '');
|
|
142
|
-
return wrapper;
|
|
143
|
-
};
|
|
144
|
-
var createInput = function (datePickerOption, index) {
|
|
145
|
-
var _a, _b;
|
|
146
|
-
var defaultPlaceHolder = datePickerOption.options.enableTime ? CONSTANTS.FORMATS.DATE_TIME : CONSTANTS.FORMATS.DATE;
|
|
147
|
-
var input = document.createElement('input');
|
|
148
|
-
input.type = 'text';
|
|
149
|
-
input.placeholder = (_a = datePickerOption.placeholder) !== null && _a !== void 0 ? _a : defaultPlaceHolder;
|
|
150
|
-
input.name = (_b = datePickerOption.attrName) !== null && _b !== void 0 ? _b : '';
|
|
151
|
-
input.id = "datepicker-".concat(_this.instanceId, "-").concat(datePickerOption.element, "-").concat(index);
|
|
152
|
-
input.className = CONSTANTS.CLASS_NAMES.DATE_PICKER_INPUT;
|
|
153
|
-
input.autocomplete = _this.autoComplete;
|
|
154
|
-
return input;
|
|
155
|
-
};
|
|
156
|
-
var createIcon = function (size, elementId, index) {
|
|
157
|
-
var getCalendarIconSvg = function (size) {
|
|
158
|
-
return "\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(size, "\" height=\"").concat(size, "\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n d=\"M14 6.66671H2M10.6667 1.33337V4.00004M5.33333 1.33337V4.00004M5.2 14.6667H10.8C11.9201 14.6667 12.4802 14.6667 12.908 14.4487C13.2843 14.257 13.5903 13.951 13.782 13.5747C14 13.1469 14 12.5868 14 11.4667V5.86671C14 4.7466 14 4.18655 13.782 3.75873C13.5903 3.3824 13.2843 3.07644 12.908 2.88469C12.4802 2.66671 11.9201 2.66671 10.8 2.66671H5.2C4.0799 2.66671 3.51984 2.66671 3.09202 2.88469C2.71569 3.07644 2.40973 3.3824 2.21799 3.75873C2 4.18655 2 4.7466 2 5.86671V11.4667C2 12.5868 2 13.1469 2.21799 13.5747C2.40973 13.951 2.71569 14.257 3.09202 14.4487C3.51984 14.6667 4.0799 14.6667 5.2 14.6667Z\"\n stroke=\"black\"\n stroke-width=\"1.33333\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n ></path>\n </svg>");
|
|
159
|
-
};
|
|
160
|
-
var ico = document.createElement('label');
|
|
161
|
-
ico.htmlFor = "datepicker-".concat(_this.instanceId, "-").concat(elementId, "-").concat(index);
|
|
162
|
-
ico.className = CONSTANTS.CLASS_NAMES.DATE_PICKER_ICO;
|
|
163
|
-
ico.innerHTML = getCalendarIconSvg(CONSTANTS.ICON_SIZES[size]);
|
|
164
|
-
return ico;
|
|
165
|
-
};
|
|
166
|
-
var insertSeparator = function () {
|
|
167
|
-
var span = document.createElement('span');
|
|
168
|
-
span.textContent = _this.separator;
|
|
169
|
-
_this.contentWrapper.insertBefore(span, _this.contentWrapper.querySelectorAll(".".concat(CONSTANTS.CLASS_NAMES.DATE_PICKER))[1]);
|
|
170
|
-
};
|
|
171
|
-
var createDatePickerElement = function (datePickerOption, index) {
|
|
172
|
-
var inputWrapper = createInputWrapperElement(_this.size);
|
|
173
|
-
var input = createInput(datePickerOption, index);
|
|
174
|
-
inputWrapper.appendChild(input);
|
|
175
|
-
inputWrapper.appendChild(createIcon(_this.size, datePickerOption.element, index));
|
|
176
|
-
inputWrapper.addEventListener('click', function () {
|
|
177
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
|
178
|
-
// biome-ignore lint/suspicious/useIterableCallbackReturn: <explanation>
|
|
179
|
-
_this.buttons.forEach(function (button) {
|
|
180
|
-
return button.isCurrent = false;
|
|
181
|
-
});
|
|
182
|
-
_this.currentButton = null;
|
|
183
|
-
_this.reRenderButtonGroup(_this.buttons);
|
|
184
|
-
});
|
|
185
|
-
_this.contentWrapper.appendChild(inputWrapper);
|
|
186
|
-
if (index > 0) {
|
|
187
|
-
insertSeparator();
|
|
188
|
-
}
|
|
189
|
-
return _this.initializeFlatpickr(input, datePickerOption.options, inputWrapper);
|
|
190
|
-
};
|
|
191
|
-
var createFlatpickrInstances = function (datePickerOptions) {
|
|
192
|
-
return datePickerOptions.map(function (datePickerOption, index) {
|
|
193
|
-
return createDatePickerElement(datePickerOption, index);
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
var calcInitDates = function (datePickerOptions) {
|
|
197
|
-
if (_this.buttons.length > 0) {
|
|
198
|
-
var currentButton = _this.buttons.find(function (button) {
|
|
199
|
-
return button.isCurrent;
|
|
200
|
-
});
|
|
201
|
-
if (!currentButton) {
|
|
202
|
-
return datePickerOptions.map(function () {
|
|
203
|
-
return '';
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
return _this.calculateDatesFromButton(currentButton);
|
|
207
|
-
}
|
|
208
|
-
return datePickerOptions.map(function (datePickerOption) {
|
|
209
|
-
var _a;
|
|
210
|
-
if ((_a = datePickerOption.options) === null || _a === void 0 ? void 0 : _a.defaultDate) {
|
|
211
|
-
return moment(datePickerOption.options.defaultDate.toString()).format(_this.dateFormat);
|
|
212
|
-
}
|
|
213
|
-
return '';
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
this.flatpickrInstances = createFlatpickrInstances(this.datePickerOptions);
|
|
217
|
-
var dates = calcInitDates(datePickerOptions);
|
|
218
|
-
this.setMultipleDates(dates);
|
|
219
|
-
};
|
|
220
|
-
DatePicker.prototype.initializeFlatpickr = function (input, options, wrapper) {
|
|
221
|
-
var _this = this;
|
|
222
|
-
var _a;
|
|
223
|
-
// flatpickr locale 설정 확인
|
|
224
|
-
var locale = typeof options.locale === 'string' ? options.locale : 'ko';
|
|
225
|
-
this.setupFlatpickrLocale(locale, options);
|
|
226
|
-
var onInputHandler = this.createInputHandler();
|
|
227
|
-
var onHourInputHandler = this.createHourInputHandler();
|
|
228
|
-
var onMinuteInputHandler = this.createMinuteInputHandler();
|
|
229
|
-
var onMouseDown = this.createMouseDownHandler(wrapper);
|
|
230
|
-
// onBlur 핸들러 추가하여 입력 전 날짜 저장
|
|
231
|
-
var onBlurHandler = this.createBlurHandler();
|
|
232
|
-
document.addEventListener('mousedown', onMouseDown, true);
|
|
233
|
-
return flatpickr(input, __assign(__assign({}, options), {
|
|
234
|
-
allowInput: (_a = options.allowInput) !== null && _a !== void 0 ? _a : true,
|
|
235
|
-
appendTo: wrapper,
|
|
236
|
-
time_24hr: true,
|
|
237
|
-
defaultHour: options.defaultHour || 0,
|
|
238
|
-
defaultMinute: options.defaultMinute || 0,
|
|
239
|
-
locale: locale,
|
|
240
|
-
formatDate: function (date, format, locale) {
|
|
241
|
-
try {
|
|
242
|
-
// 유효한 날짜인지 확인
|
|
243
|
-
if (!date || !(date instanceof Date) || isNaN(date.getTime())) {
|
|
244
|
-
return '';
|
|
245
|
-
}
|
|
246
|
-
// moment로 포맷팅
|
|
247
|
-
var momentDate = moment(date);
|
|
248
|
-
if (!momentDate.isValid()) {
|
|
249
|
-
return '';
|
|
250
|
-
}
|
|
251
|
-
// format을 moment 형식으로 변환
|
|
252
|
-
var momentFormat = _this.convertFlatpickrFormatToMoment(format);
|
|
253
|
-
return momentDate.format(momentFormat);
|
|
254
|
-
} catch (error) {
|
|
255
|
-
// 오류 발생 시 빈 문자열 반환 (232-23 같은 잘못된 날짜 처리)
|
|
256
|
-
return '';
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
onChange: this.createOnChangeHandler(options),
|
|
260
|
-
onReady: this.createOnReadyHandler(onInputHandler, onHourInputHandler, onMinuteInputHandler, onBlurHandler),
|
|
261
|
-
onDestroy: this.createOnDestroyHandler(onInputHandler, onHourInputHandler, onMinuteInputHandler, onMouseDown, onBlurHandler)
|
|
262
|
-
}));
|
|
263
|
-
};
|
|
264
|
-
DatePicker.prototype.createBlurHandler = function () {
|
|
265
|
-
var _this = this;
|
|
266
|
-
return function (e) {
|
|
267
|
-
var target = e.target;
|
|
268
|
-
var inputIndex = _this.findFlatpickrInstanceIndexByInput(target);
|
|
269
|
-
if (inputIndex < 0) return;
|
|
270
|
-
// blur 시점에 현재 selectedDates를 저장 (입력 전 상태)
|
|
271
|
-
var instance = _this.flatpickrInstances[inputIndex];
|
|
272
|
-
if (instance && instance.selectedDates.length > 0) {
|
|
273
|
-
// 이전 날짜를 별도로 저장 (onChange에서 사용)
|
|
274
|
-
instance._previousDateBeforeInput = instance.selectedDates[0];
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
};
|
|
278
|
-
DatePicker.prototype.setupFlatpickrLocale = function (locale, options) {
|
|
279
|
-
var _a;
|
|
280
|
-
if ((_a = flatpickr === null || flatpickr === void 0 ? void 0 : flatpickr.l10ns) === null || _a === void 0 ? void 0 : _a[locale]) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
console.warn("flatpickr locale '".concat(locale, "' is not loaded. Available locales:"), Object.keys((flatpickr === null || flatpickr === void 0 ? void 0 : flatpickr.l10ns) || {}));
|
|
284
|
-
if (locale === 'ko') {
|
|
285
|
-
flatpickr.l10ns.ko = Korean;
|
|
286
|
-
} else {
|
|
287
|
-
options.locale = undefined;
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
DatePicker.prototype.createInputHandler = function () {
|
|
291
|
-
var _this = this;
|
|
292
|
-
return function (e) {
|
|
293
|
-
var target = e.target;
|
|
294
|
-
var input = target.value;
|
|
295
|
-
var instance = _this.findFlatpickrInstanceByInput(target);
|
|
296
|
-
if (!instance) return;
|
|
297
|
-
// 빈 입력 처리
|
|
298
|
-
if (!input || input.trim() === '') {
|
|
299
|
-
_this.clearInputValue(target, instance);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
// 숫자나 하이픈이 없는 경우 처리
|
|
303
|
-
if (!/[0-9]/.test(input)) {
|
|
304
|
-
_this.restorePreviousDate(target, instance);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
var formattedInput = formatDateInput(input);
|
|
308
|
-
// 포맷팅만 수행
|
|
309
|
-
if (formattedInput !== input) {
|
|
310
|
-
target.value = formattedInput;
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
// 완전한 날짜 형식이지만 유효하지 않은 경우 처리
|
|
314
|
-
if (formattedInput && formattedInput.length >= 10) {
|
|
315
|
-
var parsedDate = moment(formattedInput);
|
|
316
|
-
if (!parsedDate.isValid()) {
|
|
317
|
-
_this.restorePreviousDate(target, instance);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
};
|
|
322
|
-
DatePicker.prototype.findFlatpickrInstanceByInput = function (input) {
|
|
323
|
-
var index = this.findFlatpickrInstanceIndexByInput(input);
|
|
324
|
-
return index >= 0 ? this.flatpickrInstances[index] : null;
|
|
325
|
-
};
|
|
326
|
-
DatePicker.prototype.clearInputValue = function (target, instance) {
|
|
327
|
-
target.value = '';
|
|
328
|
-
instance.setDate('', false);
|
|
329
|
-
};
|
|
330
|
-
DatePicker.prototype.restorePreviousDate = function (target, instance) {
|
|
331
|
-
var hasPreviousDate = instance.selectedDates.length > 0;
|
|
332
|
-
if (!hasPreviousDate) {
|
|
333
|
-
this.clearInputValue(target, instance);
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
var previousDate = instance.selectedDates[0];
|
|
337
|
-
var isValidDate = previousDate instanceof Date && !isNaN(previousDate.getTime());
|
|
338
|
-
if (isValidDate) {
|
|
339
|
-
target.value = moment(previousDate).format(this.dateFormat);
|
|
340
|
-
instance.setDate(previousDate, false);
|
|
341
|
-
} else {
|
|
342
|
-
this.clearInputValue(target, instance);
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
DatePicker.prototype.createHourInputHandler = function () {
|
|
346
|
-
return function (e) {
|
|
347
|
-
var target = e.target;
|
|
348
|
-
var input = target.value;
|
|
349
|
-
var formattedInput = formatHourInput(input);
|
|
350
|
-
if (formattedInput === input) return;
|
|
351
|
-
target.value = formattedInput;
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
DatePicker.prototype.createMinuteInputHandler = function () {
|
|
355
|
-
return function (e) {
|
|
356
|
-
var target = e.target;
|
|
357
|
-
var input = target.value;
|
|
358
|
-
var formattedInput = formatMinuteInput(input);
|
|
359
|
-
if (formattedInput === input) return;
|
|
360
|
-
target.value = formattedInput;
|
|
361
|
-
};
|
|
362
|
-
};
|
|
363
|
-
DatePicker.prototype.createMouseDownHandler = function (wrapper) {
|
|
364
|
-
return function (e) {
|
|
365
|
-
var flatpickrCalendar = wrapper.querySelector('.flatpickr-calendar.open');
|
|
366
|
-
if (!flatpickrCalendar) return;
|
|
367
|
-
if (flatpickrCalendar.contains(e.target)) return;
|
|
368
|
-
var timeInputs = flatpickrCalendar.querySelectorAll('.flatpickr-time input');
|
|
369
|
-
timeInputs.forEach(function (input) {
|
|
370
|
-
if (document.activeElement === input) {
|
|
371
|
-
input.blur();
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
};
|
|
376
|
-
DatePicker.prototype.createOnChangeHandler = function (options) {
|
|
377
|
-
var _this = this;
|
|
378
|
-
return function (selectedDates, dateStr, instance) {
|
|
379
|
-
try {
|
|
380
|
-
var inputIndex = _this.findFlatpickrInstanceIndexByInput(instance.input);
|
|
381
|
-
if (inputIndex < 0) return;
|
|
382
|
-
// blur 시 저장한 이전 날짜 사용
|
|
383
|
-
var previousDate = instance._previousDateBeforeInput;
|
|
384
|
-
// selectedDates가 비어있거나 첫 번째 날짜가 유효하지 않은 경우 처리
|
|
385
|
-
if (!selectedDates || selectedDates.length === 0 || !selectedDates[0] || !(selectedDates[0] instanceof Date) || !_this.isValidDate(selectedDates[0])) {
|
|
386
|
-
// 유효하지 않은 날짜는 이전 값으로 복원하거나 빈 값으로 처리
|
|
387
|
-
if (previousDate && _this.isValidDate(previousDate)) {
|
|
388
|
-
// 이전 값이 있으면 이전 값으로 복원
|
|
389
|
-
instance.selectedDates = [previousDate];
|
|
390
|
-
instance.setDate(previousDate, false);
|
|
391
|
-
} else {
|
|
392
|
-
// 이전 값이 없으면 빈 값으로 처리
|
|
393
|
-
instance.selectedDates = [];
|
|
394
|
-
instance.setDate('', false);
|
|
395
|
-
}
|
|
396
|
-
// 원본 onChange는 호출하지 않음
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
// 유효한 날짜인 경우에만 원본 onChange 호출
|
|
400
|
-
_this.invokeOriginalOnChange(options.onChange, selectedDates, dateStr, instance);
|
|
401
|
-
var selectedDate = selectedDates[0];
|
|
402
|
-
// minDate/maxDate 검증
|
|
403
|
-
_this.validateAndRestoreIfNeeded(selectedDate, instance, inputIndex, previousDate);
|
|
404
|
-
// 검증 후 현재 날짜를 이전 날짜로 업데이트
|
|
405
|
-
if (_this.isValidDate(selectedDate)) {
|
|
406
|
-
instance._previousDateBeforeInput = selectedDate;
|
|
407
|
-
_this.flatpickrInstances[inputIndex].selectedDates = [selectedDate];
|
|
408
|
-
}
|
|
409
|
-
} catch (error) {
|
|
410
|
-
// 오류 발생 시 이전 값으로 복원
|
|
411
|
-
var previousDate = instance._previousDateBeforeInput;
|
|
412
|
-
if (previousDate && _this.isValidDate(previousDate)) {
|
|
413
|
-
instance.selectedDates = [previousDate];
|
|
414
|
-
} else {
|
|
415
|
-
instance.selectedDates = [];
|
|
416
|
-
}
|
|
417
|
-
_this.restoreDateToInstance(instance, previousDate);
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
};
|
|
421
|
-
DatePicker.prototype.invokeOriginalOnChange = function (onChange, selectedDates, dateStr, instance) {
|
|
422
|
-
if (!onChange) return;
|
|
423
|
-
if (Array.isArray(onChange)) {
|
|
424
|
-
onChange.forEach(function (hook) {
|
|
425
|
-
void hook(selectedDates, dateStr, instance);
|
|
426
|
-
});
|
|
427
|
-
} else {
|
|
428
|
-
onChange(selectedDates, dateStr, instance);
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
DatePicker.prototype.isValidDate = function (date) {
|
|
432
|
-
return date instanceof Date && !isNaN(date.getTime());
|
|
433
|
-
};
|
|
434
|
-
DatePicker.prototype.validateAndRestoreIfNeeded = function (selectedDate, instance, inputIndex, previousDate) {
|
|
435
|
-
try {
|
|
436
|
-
var isValid = this.validateDate(selectedDate, inputIndex, previousDate);
|
|
437
|
-
if (!isValid) {
|
|
438
|
-
this.restoreDateToInstance(instance, previousDate);
|
|
439
|
-
} else {
|
|
440
|
-
// 유효한 경우에만 업데이트
|
|
441
|
-
instance._previousDateBeforeInput = selectedDate;
|
|
442
|
-
this.flatpickrInstances[inputIndex].selectedDates = [selectedDate];
|
|
443
|
-
}
|
|
444
|
-
} catch (error) {
|
|
445
|
-
// 오류 발생 시 이전 값으로 복원
|
|
446
|
-
this.restoreDateToInstance(instance, previousDate);
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
DatePicker.prototype.findFlatpickrInstanceIndexByInput = function (input) {
|
|
450
|
-
return this.flatpickrInstances.findIndex(function (inst) {
|
|
451
|
-
return inst.input === input;
|
|
452
|
-
});
|
|
453
|
-
};
|
|
454
|
-
DatePicker.prototype.restoreDateToInstance = function (instance, previousDate) {
|
|
455
|
-
try {
|
|
456
|
-
// setDate 호출 전에 날짜 유효성 확인
|
|
457
|
-
if (previousDate && this.isValidDate(previousDate)) {
|
|
458
|
-
// selectedDates 배열을 정리하여 formatting.js에서 오류가 발생하지 않도록 함
|
|
459
|
-
instance.selectedDates = [previousDate];
|
|
460
|
-
instance.setDate(previousDate, false);
|
|
461
|
-
} else {
|
|
462
|
-
// 빈 값으로 설정할 때도 selectedDates를 정리
|
|
463
|
-
instance.selectedDates = [];
|
|
464
|
-
instance.setDate('', false);
|
|
465
|
-
}
|
|
466
|
-
} catch (error) {
|
|
467
|
-
// setDate에서 오류 발생 시 selectedDates를 빈 배열로 설정
|
|
468
|
-
try {
|
|
469
|
-
instance.selectedDates = [];
|
|
470
|
-
instance.setDate('', false);
|
|
471
|
-
} catch (_a) {
|
|
472
|
-
// 최종 실패 시 무시
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
DatePicker.prototype.createOnReadyHandler = function (onInputHandler, onHourInputHandler, onMinuteInputHandler, onBlurHandler) {
|
|
477
|
-
return function (selectedDates, dateStr, instance) {
|
|
478
|
-
var _a;
|
|
479
|
-
var input = instance.input;
|
|
480
|
-
if (!input) return;
|
|
481
|
-
input.addEventListener('input', onInputHandler);
|
|
482
|
-
input.addEventListener('blur', onBlurHandler);
|
|
483
|
-
var timeInputWrapper = (_a = input.parentElement) === null || _a === void 0 ? void 0 : _a.querySelector('.flatpickr-time');
|
|
484
|
-
if (!timeInputWrapper) return;
|
|
485
|
-
var hourInput = timeInputWrapper.querySelector('.flatpickr-hour');
|
|
486
|
-
var minuteInput = timeInputWrapper.querySelector('.flatpickr-minute');
|
|
487
|
-
if (!hourInput || !minuteInput) return;
|
|
488
|
-
hourInput.addEventListener('input', onHourInputHandler);
|
|
489
|
-
minuteInput.addEventListener('input', onMinuteInputHandler);
|
|
490
|
-
};
|
|
491
|
-
};
|
|
492
|
-
DatePicker.prototype.createOnDestroyHandler = function (onInputHandler, onHourInputHandler, onMinuteInputHandler, onMouseDown, onBlurHandler) {
|
|
493
|
-
return function (selectedDates, dateStr, instance) {
|
|
494
|
-
var _a;
|
|
495
|
-
var input = instance.input;
|
|
496
|
-
if (!input) return;
|
|
497
|
-
input.removeEventListener('input', onInputHandler);
|
|
498
|
-
input.removeEventListener('blur', onBlurHandler);
|
|
499
|
-
// hourInput과 minuteInput에서 이벤트 리스너 제거 (input이 아님)
|
|
500
|
-
var timeInputWrapper = (_a = input.parentElement) === null || _a === void 0 ? void 0 : _a.querySelector('.flatpickr-time');
|
|
501
|
-
if (timeInputWrapper) {
|
|
502
|
-
var hourInput = timeInputWrapper.querySelector('.flatpickr-hour');
|
|
503
|
-
var minuteInput = timeInputWrapper.querySelector('.flatpickr-minute');
|
|
504
|
-
if (hourInput) {
|
|
505
|
-
hourInput.removeEventListener('input', onHourInputHandler);
|
|
506
|
-
}
|
|
507
|
-
if (minuteInput) {
|
|
508
|
-
minuteInput.removeEventListener('input', onMinuteInputHandler);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
document.removeEventListener('mousedown', onMouseDown, true);
|
|
512
|
-
};
|
|
513
|
-
};
|
|
514
|
-
DatePicker.prototype.convertDateOption = function (dateOption) {
|
|
515
|
-
if (!dateOption) return undefined;
|
|
516
|
-
if (typeof dateOption === 'string' || dateOption instanceof Date) {
|
|
517
|
-
return dateOption;
|
|
518
|
-
}
|
|
519
|
-
if (typeof dateOption === 'number') {
|
|
520
|
-
return new Date(dateOption);
|
|
521
|
-
}
|
|
522
|
-
if (Array.isArray(dateOption) && dateOption.length > 0) {
|
|
523
|
-
return dateOption[0] instanceof Date ? dateOption[0] : new Date(dateOption[0]);
|
|
524
|
-
}
|
|
525
|
-
return undefined;
|
|
526
|
-
};
|
|
527
|
-
DatePicker.prototype.validateDate = function (date, index, previousDate) {
|
|
528
|
-
var _a;
|
|
529
|
-
var option = this.datePickerOptions[index];
|
|
530
|
-
if (!option) return true;
|
|
531
|
-
var minDate = (_a = option.options, _a.minDate),
|
|
532
|
-
maxDate = _a.maxDate;
|
|
533
|
-
if (!minDate && !maxDate) return true;
|
|
534
|
-
var inputDate = moment(date);
|
|
535
|
-
if (!inputDate.isValid()) return true;
|
|
536
|
-
var violations = this.checkDateViolations(inputDate, minDate, maxDate);
|
|
537
|
-
if (violations.length === 0) return true;
|
|
538
|
-
if (this.onValidationError) {
|
|
539
|
-
var error = {
|
|
540
|
-
index: index,
|
|
541
|
-
date: date,
|
|
542
|
-
minDate: this.convertDateOption(minDate),
|
|
543
|
-
maxDate: this.convertDateOption(maxDate),
|
|
544
|
-
violations: violations,
|
|
545
|
-
previousDate: previousDate
|
|
546
|
-
};
|
|
547
|
-
this.onValidationError(error);
|
|
548
|
-
}
|
|
549
|
-
return false;
|
|
550
|
-
};
|
|
551
|
-
DatePicker.prototype.checkDateViolations = function (inputDate, minDate, maxDate) {
|
|
552
|
-
var violations = [];
|
|
553
|
-
if (minDate) {
|
|
554
|
-
var min = moment(minDate);
|
|
555
|
-
if (min.isValid() && inputDate.isBefore(min, 'day')) {
|
|
556
|
-
violations.push('minDate');
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
if (maxDate) {
|
|
560
|
-
var max = moment(maxDate);
|
|
561
|
-
if (max.isValid() && inputDate.isAfter(max, 'day')) {
|
|
562
|
-
violations.push('maxDate');
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
return violations;
|
|
566
|
-
};
|
|
567
|
-
DatePicker.prototype.setDate = function (dates) {
|
|
568
|
-
var _this = this;
|
|
569
|
-
var startDate = dates[0],
|
|
570
|
-
endDate = dates[1];
|
|
571
|
-
var datesToSet = this.datePickerOptions.map(function (option, index) {
|
|
572
|
-
var date = index === 0 ? startDate : endDate;
|
|
573
|
-
return _this.formatDateForOption(date, option, index);
|
|
574
|
-
});
|
|
575
|
-
var period = this.calculatePeriod(datesToSet);
|
|
576
|
-
this.updateButtonsByPeriod(period);
|
|
577
|
-
this.setMultipleDates(datesToSet);
|
|
578
|
-
};
|
|
579
|
-
DatePicker.prototype.formatDateForOption = function (date, option, index) {
|
|
580
|
-
var _a, _b;
|
|
581
|
-
if (!date || date === '0000-00-00') return '';
|
|
582
|
-
var hasTime = (_a = option.options) === null || _a === void 0 ? void 0 : _a.enableTime;
|
|
583
|
-
var flatpickrFormat = ((_b = option.options) === null || _b === void 0 ? void 0 : _b.dateFormat) || (hasTime ? 'Y-m-d H:i' : 'Y-m-d');
|
|
584
|
-
var momentFormat = this.convertFlatpickrFormatToMoment(flatpickrFormat);
|
|
585
|
-
var momentDate = this.parseDateWithMultipleFormats(date, hasTime, momentFormat);
|
|
586
|
-
if (!momentDate || !momentDate.isValid()) return '';
|
|
587
|
-
var isValid = this.validateDate(momentDate.toDate(), index);
|
|
588
|
-
if (!isValid) return '';
|
|
589
|
-
return this.formatMomentDate(momentDate, date, hasTime, index, momentFormat);
|
|
590
|
-
};
|
|
591
|
-
DatePicker.prototype.parseDateWithMultipleFormats = function (date, hasTime, momentFormat) {
|
|
592
|
-
// hasTime이 true인 경우 (시간 포함 여부와 무관하게 moment로 파싱)
|
|
593
|
-
if (hasTime) {
|
|
594
|
-
var momentDate_1 = moment(date);
|
|
595
|
-
return momentDate_1.isValid() ? momentDate_1 : null;
|
|
596
|
-
}
|
|
597
|
-
// hasTime이 false인 경우 - 여러 형식으로 시도
|
|
598
|
-
var momentDate = moment(date);
|
|
599
|
-
if (momentDate.isValid()) {
|
|
600
|
-
return momentDate;
|
|
601
|
-
}
|
|
602
|
-
momentDate = moment(date, momentFormat, true);
|
|
603
|
-
if (momentDate.isValid()) {
|
|
604
|
-
return momentDate;
|
|
605
|
-
}
|
|
606
|
-
momentDate = moment(date, [momentFormat, 'YYYY-MM-DD', 'YYYY/MM/DD', 'MM/DD/YYYY'], true);
|
|
607
|
-
return momentDate.isValid() ? momentDate : null;
|
|
608
|
-
};
|
|
609
|
-
DatePicker.prototype.formatMomentDate = function (momentDate, originalDate, hasTime, index, momentFormat) {
|
|
610
|
-
// hasTime이 true이고 원본 날짜에 시간이 없는 경우
|
|
611
|
-
if (hasTime && !originalDate.includes(':')) {
|
|
612
|
-
return index === 0 ? momentDate.startOf('day').format(momentFormat) : momentDate.endOf('day').format(momentFormat);
|
|
613
|
-
}
|
|
614
|
-
return momentDate.format(momentFormat);
|
|
615
|
-
};
|
|
616
|
-
DatePicker.prototype.calculatePeriod = function (datesToSet) {
|
|
617
|
-
if (!datesToSet[0] || !datesToSet[1]) return null;
|
|
618
|
-
return moment(datesToSet[1]).diff(moment(datesToSet[0]), 'days');
|
|
619
|
-
};
|
|
620
|
-
DatePicker.prototype.updateDateWithButton = function (e) {
|
|
621
|
-
var _this = this;
|
|
622
|
-
var target = e.target;
|
|
623
|
-
if (!target.classList.contains(CONSTANTS.CLASS_NAMES.BUTTON)) return;
|
|
624
|
-
var clickedButton = this.buttons.find(function (button) {
|
|
625
|
-
return button.text === target.textContent;
|
|
626
|
-
});
|
|
627
|
-
if (!clickedButton || clickedButton === this.currentButton) return;
|
|
628
|
-
var updateButtonState = function () {
|
|
629
|
-
return _this.buttons.map(function (button) {
|
|
630
|
-
return __assign(__assign({}, button), {
|
|
631
|
-
isCurrent: button.text === (clickedButton === null || clickedButton === void 0 ? void 0 : clickedButton.text)
|
|
632
|
-
});
|
|
633
|
-
});
|
|
634
|
-
};
|
|
635
|
-
this.currentButton = clickedButton;
|
|
636
|
-
this.reRenderButtonGroup(updateButtonState());
|
|
637
|
-
this.setMultipleDates(this.calculateDatesFromButton(clickedButton));
|
|
638
|
-
};
|
|
639
|
-
DatePicker.prototype.setMultipleDates = function (dates) {
|
|
640
|
-
var _this = this;
|
|
641
|
-
dates.forEach(function (date, index) {
|
|
642
|
-
var _a, _b;
|
|
643
|
-
var shouldTriggerChange = index === dates.length - 1;
|
|
644
|
-
(_a = _this.flatpickrInstances[index]) === null || _a === void 0 ? void 0 : _a.setDate(date, shouldTriggerChange);
|
|
645
|
-
(_b = _this.flatpickrInstances[index]) === null || _b === void 0 ? void 0 : _b.redraw();
|
|
646
|
-
});
|
|
647
|
-
};
|
|
648
|
-
DatePicker.prototype.updateButtonsByPeriod = function (period) {
|
|
649
|
-
var newButtons = this.buttons.map(function (button) {
|
|
650
|
-
return __assign(__assign({}, button), {
|
|
651
|
-
isCurrent: period !== null && button.period === period
|
|
652
|
-
});
|
|
653
|
-
});
|
|
654
|
-
this.reRenderButtonGroup(newButtons);
|
|
655
|
-
};
|
|
656
|
-
DatePicker.prototype.calculateDatesFromButton = function (button) {
|
|
657
|
-
var _this = this;
|
|
658
|
-
var period = button.period,
|
|
659
|
-
unit = button.unit;
|
|
660
|
-
return this.datePickerOptions.map(function (option, index) {
|
|
661
|
-
var _a;
|
|
662
|
-
var hasTime = (_a = option.options) === null || _a === void 0 ? void 0 : _a.enableTime;
|
|
663
|
-
if (index === 0) {
|
|
664
|
-
var startMoment = period ? moment().subtract(period, unit) : moment();
|
|
665
|
-
return hasTime ? startMoment.startOf('day').format(_this.dateFormat) : startMoment.format(_this.dateFormat);
|
|
666
|
-
}
|
|
667
|
-
return hasTime ? moment().endOf('day').format(_this.dateFormat) : moment().format(_this.dateFormat);
|
|
668
|
-
});
|
|
669
|
-
};
|
|
670
|
-
// flatpickr 형식을 moment 형식으로 변환하는 헬퍼 메서드
|
|
671
|
-
DatePicker.prototype.convertFlatpickrFormatToMoment = function (flatpickrFormat) {
|
|
672
|
-
var map = {
|
|
673
|
-
Y: 'YYYY',
|
|
674
|
-
y: 'YY',
|
|
675
|
-
m: 'MM',
|
|
676
|
-
d: 'DD',
|
|
677
|
-
H: 'HH',
|
|
678
|
-
i: 'mm',
|
|
679
|
-
S: 'ss'
|
|
680
|
-
};
|
|
681
|
-
return flatpickrFormat.replace(/[YymdHiS]/g, function (matched) {
|
|
682
|
-
return map[matched] || matched;
|
|
683
|
-
});
|
|
684
|
-
};
|
|
685
|
-
DatePicker.prototype.getDates = function () {
|
|
686
|
-
var _this = this;
|
|
687
|
-
return this.flatpickrInstances.map(function (instance) {
|
|
688
|
-
var selectedDates = instance.selectedDates;
|
|
689
|
-
if (selectedDates.length > 0) {
|
|
690
|
-
return moment(selectedDates[0]).format(_this.dateFormat);
|
|
691
|
-
}
|
|
692
|
-
return '';
|
|
693
|
-
});
|
|
694
|
-
};
|
|
695
|
-
DatePicker.instanceCounter = 0;
|
|
696
|
-
DatePicker.usedWrappers = new Set(); // 사용된 wrapper 요소 추적용
|
|
697
|
-
return DatePicker;
|
|
698
|
-
}();
|
|
699
|
-
window.DatePicker = DatePicker;
|