@singularsystems/neo-core 1.0.0-alpha.2 → 1.0.0-alpha.4
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/CHANGELOG.md +15 -0
- package/dist/ApiClient/ApiClientBase.d.ts +5 -5
- package/dist/ApiClient/ApiClientBase.js +13 -13
- package/dist/ApiClient/ReadApiClient.d.ts +16 -16
- package/dist/ApiClient/ReadApiClient.js +24 -24
- package/dist/ApiClient/UpdateableApiClient.d.ts +28 -28
- package/dist/ApiClient/UpdateableApiClient.js +33 -33
- package/dist/AppServices/AppService.d.ts +46 -46
- package/dist/AppServices/AppService.js +25 -25
- package/dist/AppServices/Config/ConfigModel.d.ts +21 -20
- package/dist/AppServices/Config/ConfigModel.js +28 -17
- package/dist/AppServices/Config/ConfigService.d.ts +15 -15
- package/dist/AppServices/Config/ConfigService.js +49 -53
- package/dist/AppServices/Module.d.ts +11 -11
- package/dist/AppServices/Module.js +13 -13
- package/dist/AppServices/NeoContainer.d.ts +22 -22
- package/dist/AppServices/NeoContainer.js +42 -42
- package/dist/AppServices/NeoModule.d.ts +3 -3
- package/dist/AppServices/NeoModule.js +30 -30
- package/dist/AppServices/NeoTypes.d.ts +61 -61
- package/dist/AppServices/NeoTypes.js +42 -42
- package/dist/AppServices/ServiceIdentifier.d.ts +23 -23
- package/dist/AppServices/ServiceIdentifier.js +38 -39
- package/dist/AppServices/index.d.ts +7 -7
- package/dist/AppServices/index.js +7 -7
- package/dist/Components/AnimationHelper.d.ts +69 -69
- package/dist/Components/AnimationHelper.js +182 -182
- package/dist/Components/BootstrapHelpers.d.ts +8 -8
- package/dist/Components/BootstrapHelpers.js +30 -30
- package/dist/Components/BootstrapTypes.d.ts +35 -35
- package/dist/Components/BootstrapTypes.js +1 -1
- package/dist/Components/ButtonOptions.d.ts +63 -61
- package/dist/Components/ButtonOptions.js +1 -1
- package/dist/Components/ContextMenu/ContextMenu.d.ts +16 -16
- package/dist/Components/ContextMenu/ContextMenu.js +1 -1
- package/dist/Components/ContextMenu/MenuUtils.d.ts +16 -16
- package/dist/Components/ContextMenu/MenuUtils.js +34 -34
- package/dist/Components/DatePicker/DatePicker.d.ts +70 -69
- package/dist/Components/DatePicker/DatePicker.js +502 -487
- package/dist/Components/DatePicker/DatePickerOptions.d.ts +43 -34
- package/dist/Components/DatePicker/DatePickerOptions.js +33 -33
- package/dist/Components/ErrorHandler.d.ts +59 -55
- package/dist/Components/ErrorHandler.js +210 -138
- package/dist/Components/FileManager/BoundFileManager.d.ts +18 -18
- package/dist/Components/FileManager/BoundFileManager.js +60 -60
- package/dist/Components/FileManager/FileManager.d.ts +80 -78
- package/dist/Components/FileManager/FileManager.js +277 -257
- package/dist/Components/FileManager/FileUploadBatch.d.ts +37 -37
- package/dist/Components/FileManager/FileUploadBatch.js +83 -82
- package/dist/Components/FileManager/IFileManagerOptions.d.ts +42 -42
- package/dist/Components/FileManager/IFileManagerOptions.js +1 -1
- package/dist/Components/FormOptions.d.ts +34 -34
- package/dist/Components/FormOptions.js +1 -1
- package/dist/Components/ICollapsableOptions.d.ts +11 -11
- package/dist/Components/ICollapsableOptions.js +1 -1
- package/dist/Components/Modal/ModalHelper.d.ts +31 -31
- package/dist/Components/Modal/ModalHelper.js +174 -174
- package/dist/Components/Modal/ModalOptions.d.ts +61 -61
- package/dist/Components/Modal/ModalOptions.js +1 -1
- package/dist/Components/Modal/ModalStore.d.ts +32 -32
- package/dist/Components/Modal/ModalStore.js +82 -82
- package/dist/Components/Modal/ModalUtils.d.ts +61 -61
- package/dist/Components/Modal/ModalUtils.js +109 -109
- package/dist/Components/Notifications/INotificationHelper.d.ts +56 -56
- package/dist/Components/Notifications/INotificationHelper.js +1 -1
- package/dist/Components/Notifications/Notification.d.ts +32 -32
- package/dist/Components/Notifications/Notification.js +26 -27
- package/dist/Components/Notifications/NotificationHelper.d.ts +63 -63
- package/dist/Components/Notifications/NotificationHelper.js +111 -112
- package/dist/Components/Notifications/NotificationStore.d.ts +34 -34
- package/dist/Components/Notifications/NotificationStore.js +78 -79
- package/dist/Components/PositionHelper.d.ts +10 -10
- package/dist/Components/PositionHelper.js +43 -43
- package/dist/Components/TaskRunner/Decorators.d.ts +6 -6
- package/dist/Components/TaskRunner/Decorators.js +24 -24
- package/dist/Components/TaskRunner/ProgressState.d.ts +22 -22
- package/dist/Components/TaskRunner/ProgressState.js +71 -72
- package/dist/Components/TaskRunner/TaskRunner.d.ts +114 -114
- package/dist/Components/TaskRunner/TaskRunner.js +253 -244
- package/dist/Components/TooltipOptions.d.ts +8 -8
- package/dist/Components/TooltipOptions.js +1 -1
- package/dist/Components/index.d.ts +22 -22
- package/dist/Components/index.js +13 -13
- package/dist/ConnectionManager.d.ts +45 -45
- package/dist/ConnectionManager.js +60 -61
- package/dist/Data/ApiDataSource.d.ts +46 -46
- package/dist/Data/ApiDataSource.js +140 -144
- package/dist/Data/AsyncDataSource.d.ts +35 -35
- package/dist/Data/AsyncDataSource.js +79 -80
- package/dist/Data/CacheService.d.ts +40 -40
- package/dist/Data/CacheService.js +63 -64
- package/dist/Data/DataCacheEntry.d.ts +42 -42
- package/dist/Data/DataCacheEntry.js +80 -80
- package/dist/Data/DataView.d.ts +43 -43
- package/dist/Data/DataView.js +173 -172
- package/dist/Data/Deserialiser.d.ts +42 -42
- package/dist/Data/Deserialiser.js +255 -255
- package/dist/Data/Paging/PageManager.d.ts +167 -167
- package/dist/Data/Paging/PageManager.js +323 -323
- package/dist/Data/Paging/PageRequest.d.ts +24 -24
- package/dist/Data/Paging/PageRequest.js +38 -39
- package/dist/Data/Paging/PageResult.d.ts +10 -10
- package/dist/Data/Paging/PageResult.js +14 -14
- package/dist/Data/Serialiser.d.ts +41 -41
- package/dist/Data/Serialiser.js +201 -201
- package/dist/Data/SortOperation.d.ts +8 -8
- package/dist/Data/SortOperation.js +26 -26
- package/dist/Data/StaticDataSource.d.ts +9 -9
- package/dist/Data/StaticDataSource.js +27 -27
- package/dist/Data/WindowedDataView.d.ts +8 -8
- package/dist/Data/WindowedDataView.js +49 -50
- package/dist/Data/index.d.ts +15 -15
- package/dist/Data/index.js +15 -15
- package/dist/Dates/DateUtils.d.ts +47 -47
- package/dist/Dates/DateUtils.js +226 -226
- package/dist/Dates/TimeSpan.d.ts +24 -24
- package/dist/Dates/TimeSpan.js +46 -46
- package/dist/DebounceHelper.d.ts +44 -38
- package/dist/DebounceHelper.js +122 -95
- package/dist/Extensions.d.ts +82 -82
- package/dist/Extensions.js +182 -182
- package/dist/FileUtils.d.ts +6 -6
- package/dist/FileUtils.js +37 -37
- package/dist/Globals.d.ts +19 -19
- package/dist/Globals.js +41 -41
- package/dist/JsonSchema/ClassMetadata.d.ts +25 -25
- package/dist/JsonSchema/ClassMetadata.js +53 -53
- package/dist/JsonSchema/JsonData.d.ts +16 -16
- package/dist/JsonSchema/JsonData.js +97 -97
- package/dist/JsonSchema/JsonSchemaTypes.d.ts +37 -37
- package/dist/JsonSchema/JsonSchemaTypes.js +1 -1
- package/dist/JsonSchema/PropertyMetadata.d.ts +8 -8
- package/dist/JsonSchema/PropertyMetadata.js +8 -8
- package/dist/JsonSchema/TypeCache.d.ts +16 -16
- package/dist/JsonSchema/TypeCache.js +44 -44
- package/dist/JsonSchema/TypeMetadata.d.ts +45 -45
- package/dist/JsonSchema/TypeMetadata.js +170 -170
- package/dist/JsonSchema/index.d.ts +7 -7
- package/dist/JsonSchema/index.js +6 -6
- package/dist/Localisation/ILocalisationService.d.ts +11 -11
- package/dist/Localisation/ILocalisationService.js +1 -1
- package/dist/Localisation/LocalisationService.d.ts +4 -4
- package/dist/Localisation/LocalisationService.js +17 -17
- package/dist/Localisation/index.d.ts +1 -1
- package/dist/Localisation/index.js +1 -1
- package/dist/Misc.d.ts +6 -6
- package/dist/Misc.js +6 -6
- package/dist/Model/BaseModels/AuditValues.d.ts +12 -12
- package/dist/Model/BaseModels/AuditValues.js +46 -48
- package/dist/Model/BaseModels/CriteriaBase.d.ts +18 -16
- package/dist/Model/BaseModels/CriteriaBase.js +45 -34
- package/dist/Model/BaseModels/FileDescriptorBase.d.ts +12 -12
- package/dist/Model/BaseModels/FileDescriptorBase.js +22 -22
- package/dist/Model/BaseModels/ReasonedUserEvent.d.ts +5 -4
- package/dist/Model/BaseModels/ReasonedUserEvent.js +23 -19
- package/dist/Model/BaseModels/UserEvent.d.ts +9 -8
- package/dist/Model/BaseModels/UserEvent.js +36 -32
- package/dist/Model/BindableBase.d.ts +46 -40
- package/dist/Model/BindableBase.js +79 -76
- package/dist/Model/Decorators.d.ts +47 -44
- package/dist/Model/Decorators.js +182 -177
- package/dist/Model/EnumHelper.d.ts +54 -54
- package/dist/Model/EnumHelper.js +104 -100
- package/dist/Model/IAutoRunner.d.ts +5 -5
- package/dist/Model/IAutoRunner.js +1 -1
- package/dist/Model/IModelBase.d.ts +92 -79
- package/dist/Model/IModelBase.js +1 -1
- package/dist/Model/IModelCreatorBase.d.ts +9 -9
- package/dist/Model/IModelCreatorBase.js +1 -1
- package/dist/Model/List.d.ts +79 -77
- package/dist/Model/List.js +208 -198
- package/dist/Model/LookupBase.d.ts +13 -6
- package/dist/Model/LookupBase.js +19 -10
- package/dist/Model/Misc.d.ts +83 -81
- package/dist/Model/Misc.js +59 -59
- package/dist/Model/ModelBase.d.ts +88 -86
- package/dist/Model/ModelBase.js +182 -180
- package/dist/Model/ModelCreatorBase.d.ts +24 -23
- package/dist/Model/ModelCreatorBase.js +92 -92
- package/dist/Model/ModelFieldInfo.d.ts +29 -12
- package/dist/Model/ModelFieldInfo.js +35 -26
- package/dist/Model/ModelGraphTraverser.d.ts +35 -35
- package/dist/Model/ModelGraphTraverser.js +101 -99
- package/dist/Model/NeoModel.d.ts +6 -6
- package/dist/Model/NeoModel.js +13 -13
- package/dist/Model/NeoTypeInfo.d.ts +52 -41
- package/dist/Model/NeoTypeInfo.js +300 -250
- package/dist/Model/ObservableProperty.d.ts +8 -8
- package/dist/Model/ObservableProperty.js +41 -41
- package/dist/Model/ObservableValue.d.ts +9 -9
- package/dist/Model/ObservableValue.js +25 -26
- package/dist/Model/PropertyInfo.d.ts +83 -81
- package/dist/Model/PropertyInfo.js +138 -137
- package/dist/Model/PropertyInstance.d.ts +84 -48
- package/dist/Model/PropertyInstance.js +173 -113
- package/dist/Model/ValueObject.d.ts +3 -3
- package/dist/Model/ValueObject.js +10 -10
- package/dist/Model/index.d.ts +15 -14
- package/dist/Model/index.js +13 -12
- package/dist/NumberUtils.d.ts +63 -49
- package/dist/NumberUtils.js +247 -197
- package/dist/Routing/IMenuItemProvider.d.ts +9 -9
- package/dist/Routing/IMenuItemProvider.js +1 -1
- package/dist/Routing/IMenuRoute.d.ts +18 -18
- package/dist/Routing/IMenuRoute.js +1 -1
- package/dist/Routing/INavigationHelper.d.ts +7 -7
- package/dist/Routing/INavigationHelper.js +1 -1
- package/dist/Routing/IPageLeaveHandler.d.ts +23 -23
- package/dist/Routing/IPageLeaveHandler.js +7 -7
- package/dist/Routing/IRoute.d.ts +27 -27
- package/dist/Routing/IRoute.js +1 -1
- package/dist/Routing/IRouteSecurityService.d.ts +14 -14
- package/dist/Routing/IRouteSecurityService.js +1 -1
- package/dist/Routing/MenuItemProvider.d.ts +17 -17
- package/dist/Routing/MenuItemProvider.js +53 -54
- package/dist/Routing/RouteSecurityService.d.ts +18 -18
- package/dist/Routing/RouteSecurityService.js +35 -36
- package/dist/Routing/index.d.ts +7 -7
- package/dist/Routing/index.js +3 -3
- package/dist/Security/IAuthenticationService.d.ts +41 -36
- package/dist/Security/IAuthenticationService.js +1 -1
- package/dist/Security/IAuthorisationService.d.ts +11 -11
- package/dist/Security/IAuthorisationService.js +1 -1
- package/dist/Security/ILoginErrorHandler.d.ts +4 -4
- package/dist/Security/ILoginErrorHandler.js +1 -1
- package/dist/Security/ISecurityService.d.ts +10 -10
- package/dist/Security/ISecurityService.js +1 -1
- package/dist/Security/IUser.d.ts +10 -10
- package/dist/Security/IUser.js +1 -1
- package/dist/Security/IUserRole.d.ts +6 -6
- package/dist/Security/IUserRole.js +1 -1
- package/dist/Security/LoginErrorHandler.d.ts +15 -15
- package/dist/Security/LoginErrorHandler.js +97 -98
- package/dist/Security/Oidc/OidcAuthService.d.ts +67 -60
- package/dist/Security/Oidc/OidcAuthService.js +216 -189
- package/dist/Security/Oidc/OidcTypes.d.ts +46 -29
- package/dist/Security/Oidc/OidcTypes.js +1 -1
- package/dist/Security/Oidc/OidcUser.d.ts +9 -9
- package/dist/Security/Oidc/OidcUser.js +33 -33
- package/dist/Security/SecurityService.d.ts +12 -12
- package/dist/Security/SecurityService.js +33 -34
- package/dist/Security/SignInResult.d.ts +13 -13
- package/dist/Security/SignInResult.js +8 -8
- package/dist/Security/User.d.ts +12 -12
- package/dist/Security/User.js +24 -24
- package/dist/Security/index.d.ts +10 -10
- package/dist/Security/index.js +5 -5
- package/dist/Settings.d.ts +71 -57
- package/dist/Settings.js +100 -87
- package/dist/SignalR/HubBase.d.ts +70 -70
- package/dist/SignalR/HubBase.js +164 -164
- package/dist/SignalR/HubReceiver.d.ts +11 -11
- package/dist/SignalR/HubReceiver.js +25 -25
- package/dist/SignalR/HubSubscription.d.ts +12 -12
- package/dist/SignalR/HubSubscription.js +14 -14
- package/dist/SignalR/index.d.ts +3 -3
- package/dist/SignalR/index.js +1 -1
- package/dist/StringUtils.d.ts +7 -7
- package/dist/StringUtils.js +24 -24
- package/dist/Utils.d.ts +81 -80
- package/dist/Utils.js +220 -218
- package/dist/Validation/Decorators.d.ts +12 -12
- package/dist/Validation/Decorators.js +52 -52
- package/dist/Validation/DisplayHelper.d.ts +20 -19
- package/dist/Validation/DisplayHelper.js +104 -104
- package/dist/Validation/Misc.d.ts +10 -10
- package/dist/Validation/Misc.js +11 -11
- package/dist/Validation/ModelProxy.d.ts +20 -20
- package/dist/Validation/ModelProxy.js +46 -46
- package/dist/Validation/RuleContext.d.ts +86 -86
- package/dist/Validation/RuleContext.js +130 -130
- package/dist/Validation/Rules.d.ts +70 -70
- package/dist/Validation/Rules.js +177 -177
- package/dist/Validation/ValidationHelpers.d.ts +12 -12
- package/dist/Validation/ValidationHelpers.js +57 -57
- package/dist/Validation/ValidationRules.d.ts +18 -18
- package/dist/Validation/ValidationRules.js +34 -34
- package/dist/Validation/ValidationState.d.ts +42 -42
- package/dist/Validation/ValidationState.js +74 -74
- package/dist/Validation/Validators/IModelValidator.d.ts +28 -24
- package/dist/Validation/Validators/IModelValidator.js +1 -1
- package/dist/Validation/Validators/IPropertyValidator.d.ts +21 -21
- package/dist/Validation/Validators/IPropertyValidator.js +15 -15
- package/dist/Validation/Validators/ModelValidator.d.ts +46 -45
- package/dist/Validation/Validators/ModelValidator.js +143 -137
- package/dist/Validation/Validators/PropertyValidator.d.ts +21 -21
- package/dist/Validation/Validators/PropertyValidator.js +64 -67
- package/dist/Validation/Validators/RuleValidator.d.ts +19 -19
- package/dist/Validation/Validators/RuleValidator.js +51 -55
- package/dist/Validation/index.d.ts +9 -9
- package/dist/Validation/index.js +7 -7
- package/dist/Views/IViewBase.d.ts +5 -5
- package/dist/Views/IViewBase.js +1 -1
- package/dist/index.d.ts +37 -36
- package/dist/index.js +44 -43
- package/package.json +11 -10
|
@@ -1,487 +1,502 @@
|
|
|
1
|
-
import DateUtils from '../../Dates/DateUtils';
|
|
2
|
-
import AnimationHelper from '../AnimationHelper';
|
|
3
|
-
import { YearsInYearView, ProcessedDatePickerOptions } from './DatePickerOptions';
|
|
4
|
-
import PositionHelper from '../PositionHelper';
|
|
5
|
-
import { Utils } from '../../Utils';
|
|
6
|
-
// TODO: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
|
7
|
-
// TODO: Allow input to be shown with inline picker, and specify position.
|
|
8
|
-
var ViewType;
|
|
9
|
-
(function (ViewType) {
|
|
10
|
-
ViewType[ViewType["Days"] = 1] = "Days";
|
|
11
|
-
ViewType[ViewType["Months"] = 2] = "Months";
|
|
12
|
-
ViewType[ViewType["Years"] = 3] = "Years";
|
|
13
|
-
})(ViewType || (ViewType = {}));
|
|
14
|
-
var DatePicker = /** @class */ (function () {
|
|
15
|
-
function DatePicker(container, options) {
|
|
16
|
-
this.container = container;
|
|
17
|
-
this.isReadOnly = false;
|
|
18
|
-
this.inputHasChanged = false;
|
|
19
|
-
this.canAutoSetDate = false;
|
|
20
|
-
this.suspendLayout = false;
|
|
21
|
-
this.currentBindValue = null;
|
|
22
|
-
this.boundDateNoTime = null;
|
|
23
|
-
this.options = ProcessedDatePickerOptions.fromPartial(options || {});
|
|
24
|
-
this.inputFocused = this.inputFocused.bind(this);
|
|
25
|
-
this.inputBlurred = this.inputBlurred.bind(this);
|
|
26
|
-
this.inputChanged = this.inputChanged.bind(this);
|
|
27
|
-
this.inputKeyDown = this.inputKeyDown.bind(this);
|
|
28
|
-
if (!this.options.alwaysShow) {
|
|
29
|
-
this.input = this.container.getElementsByTagName('input')[0];
|
|
30
|
-
this.input.addEventListener("focus", this.inputFocused);
|
|
31
|
-
this.input.addEventListener("mousedown", this.inputFocused);
|
|
32
|
-
this.input.addEventListener("blur", this.inputBlurred);
|
|
33
|
-
this.input.addEventListener("input", this.inputChanged);
|
|
34
|
-
this.input.addEventListener("keydown", this.inputKeyDown);
|
|
35
|
-
if (this.options.timeOnly) {
|
|
36
|
-
this.input.placeholder = "hh:mm" + (this.options.formatString.indexOf("s") > 0 ? ":ss" : "");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
DatePicker.prototype.inputFocused = function (e) {
|
|
41
|
-
if (!this.popup && !this.isReadOnly) {
|
|
42
|
-
this.show();
|
|
43
|
-
}
|
|
44
|
-
if (window.innerWidth <= 576 && !this.options.timeOnly) {
|
|
45
|
-
// Stop keyboard showing on phones.
|
|
46
|
-
this.input.readOnly = true;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
DatePicker.prototype.inputBlurred = function () {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
this.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
this.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
this.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
this.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
this.
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
DatePicker.prototype.
|
|
227
|
-
var
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this.
|
|
257
|
-
this.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
this.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
if (this.currentViewType
|
|
272
|
-
this.
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
DatePicker.prototype.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
this.
|
|
299
|
-
}
|
|
300
|
-
this.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
this.
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
var
|
|
353
|
-
var
|
|
354
|
-
var
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
cell
|
|
361
|
-
this.setupCell(cell,
|
|
362
|
-
}
|
|
363
|
-
this.prevButton.disabled = this.options.minDateNoTime.getFullYear() >= year;
|
|
364
|
-
this.nextButton.disabled = this.options.maxDateNoTime.getFullYear()
|
|
365
|
-
};
|
|
366
|
-
DatePicker.prototype.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
cell.
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
};
|
|
381
|
-
DatePicker.prototype.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
this.currentViewType
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
this.
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
this.
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
this.
|
|
465
|
-
};
|
|
466
|
-
DatePicker.prototype.
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
this.
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
1
|
+
import DateUtils from '../../Dates/DateUtils';
|
|
2
|
+
import AnimationHelper from '../AnimationHelper';
|
|
3
|
+
import { YearsInYearView, ProcessedDatePickerOptions } from './DatePickerOptions';
|
|
4
|
+
import PositionHelper from '../PositionHelper';
|
|
5
|
+
import { Utils } from '../../Utils';
|
|
6
|
+
// TODO: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
|
7
|
+
// TODO: Allow input to be shown with inline picker, and specify position.
|
|
8
|
+
var ViewType;
|
|
9
|
+
(function (ViewType) {
|
|
10
|
+
ViewType[ViewType["Days"] = 1] = "Days";
|
|
11
|
+
ViewType[ViewType["Months"] = 2] = "Months";
|
|
12
|
+
ViewType[ViewType["Years"] = 3] = "Years";
|
|
13
|
+
})(ViewType || (ViewType = {}));
|
|
14
|
+
var DatePicker = /** @class */ (function () {
|
|
15
|
+
function DatePicker(container, options) {
|
|
16
|
+
this.container = container;
|
|
17
|
+
this.isReadOnly = false;
|
|
18
|
+
this.inputHasChanged = false;
|
|
19
|
+
this.canAutoSetDate = false;
|
|
20
|
+
this.suspendLayout = false;
|
|
21
|
+
this.currentBindValue = null;
|
|
22
|
+
this.boundDateNoTime = null;
|
|
23
|
+
this.options = ProcessedDatePickerOptions.fromPartial(options || {});
|
|
24
|
+
this.inputFocused = this.inputFocused.bind(this);
|
|
25
|
+
this.inputBlurred = this.inputBlurred.bind(this);
|
|
26
|
+
this.inputChanged = this.inputChanged.bind(this);
|
|
27
|
+
this.inputKeyDown = this.inputKeyDown.bind(this);
|
|
28
|
+
if (!this.options.alwaysShow) {
|
|
29
|
+
this.input = this.container.getElementsByTagName('input')[0];
|
|
30
|
+
this.input.addEventListener("focus", this.inputFocused);
|
|
31
|
+
this.input.addEventListener("mousedown", this.inputFocused);
|
|
32
|
+
this.input.addEventListener("blur", this.inputBlurred);
|
|
33
|
+
this.input.addEventListener("input", this.inputChanged);
|
|
34
|
+
this.input.addEventListener("keydown", this.inputKeyDown);
|
|
35
|
+
if (this.options.timeOnly) {
|
|
36
|
+
this.input.placeholder = "hh:mm" + (this.options.formatString.indexOf("s") > 0 ? ":ss" : "");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
DatePicker.prototype.inputFocused = function (e) {
|
|
41
|
+
if (!this.popup && !this.isReadOnly) {
|
|
42
|
+
this.show();
|
|
43
|
+
}
|
|
44
|
+
if (window.innerWidth <= 576 && !this.options.timeOnly) {
|
|
45
|
+
// Stop keyboard showing on phones.
|
|
46
|
+
this.input.readOnly = true;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
DatePicker.prototype.inputBlurred = function () {
|
|
50
|
+
this.onInputBlurred(true);
|
|
51
|
+
};
|
|
52
|
+
DatePicker.prototype.onInputBlurred = function (closePopup) {
|
|
53
|
+
if (this.inputHasChanged) {
|
|
54
|
+
if (this.input.value) {
|
|
55
|
+
// if this is time only, use the existing value to preserve the date.
|
|
56
|
+
var refDate = this.options.timeOnly && this.bindProperty.value;
|
|
57
|
+
var parsedDate = DateUtils.tryParse(this.input.value, this.options.formatString, false, refDate || new Date());
|
|
58
|
+
if (parsedDate) {
|
|
59
|
+
this.setBindValue(parsedDate, { preserveTime: false, close: closePopup });
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.setBindValue(this.bindProperty.value, { preserveTime: false, close: closePopup });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.setBindValue(null, { preserveTime: true, close: closePopup });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (this.options.autoClose && closePopup)
|
|
71
|
+
this.removePopup(true);
|
|
72
|
+
}
|
|
73
|
+
this.input.readOnly = this.isReadOnly;
|
|
74
|
+
};
|
|
75
|
+
DatePicker.prototype.inputChanged = function () {
|
|
76
|
+
this.inputHasChanged = true;
|
|
77
|
+
if (!this.options.timeOnly) {
|
|
78
|
+
// Update the displayed date as the user types.
|
|
79
|
+
var parsedDate = DateUtils.tryParse(this.input.value, this.options.formatString, false, this.bindProperty.value);
|
|
80
|
+
if (parsedDate) {
|
|
81
|
+
this.setCurrentViewDate(parsedDate);
|
|
82
|
+
this.populateContentContainer(true);
|
|
83
|
+
}
|
|
84
|
+
if (!this.popup) {
|
|
85
|
+
this.show();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
DatePicker.prototype.inputKeyDown = function (e) {
|
|
90
|
+
// TODO: find better way to check key. Maybe util class with KeyHelper.IsXXXKey(e)
|
|
91
|
+
if (e.key === "Escape") {
|
|
92
|
+
// Revert to previous value
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
this.setBindValue(this.bindProperty.value, { preserveTime: false, close: false });
|
|
95
|
+
}
|
|
96
|
+
else if (e.key === "Enter") {
|
|
97
|
+
var prevValue = this.input.value;
|
|
98
|
+
if (!this.bindProperty.value && !this.input.value) {
|
|
99
|
+
// Set date to today if the current value is null
|
|
100
|
+
this.setBindValue(new Date(), { preserveTime: true, close: false });
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.onInputBlurred(false);
|
|
104
|
+
}
|
|
105
|
+
if (this.input.value !== prevValue) {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.removePopup(true);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
DatePicker.prototype.removePopup = function (animate) {
|
|
114
|
+
if (this.popup) {
|
|
115
|
+
if (animate) {
|
|
116
|
+
AnimationHelper.scale(this.popup, DatePicker.AnimationClassName, 1, 0);
|
|
117
|
+
AnimationHelper.beginRemove(this.container, this.popup);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
this.container.removeChild(this.popup);
|
|
121
|
+
}
|
|
122
|
+
this.currentHeaderLabel = null;
|
|
123
|
+
this.currentContentTable = null;
|
|
124
|
+
this.popup = null;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
DatePicker.prototype.setBindValue = function (dateValue, options) {
|
|
128
|
+
this.inputHasChanged = false;
|
|
129
|
+
var oldValue = this.bindProperty.value;
|
|
130
|
+
if (oldValue && dateValue && options.preserveTime) {
|
|
131
|
+
// preserve the time component of the original date.
|
|
132
|
+
dateValue.setHours(oldValue.getHours(), oldValue.getMinutes(), oldValue.getSeconds(), oldValue.getMilliseconds());
|
|
133
|
+
}
|
|
134
|
+
// Note: this may have the side effect of calling update().
|
|
135
|
+
this.setBindProperty(dateValue, false);
|
|
136
|
+
this.setInputValue();
|
|
137
|
+
if (!this.options.alwaysShow && options.close) {
|
|
138
|
+
this.removePopup(true);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
DatePicker.prototype.setBindProperty = function (dateValue, suspend) {
|
|
142
|
+
var _this = this;
|
|
143
|
+
if (dateValue) {
|
|
144
|
+
dateValue = DateUtils.max(DateUtils.min(dateValue, this.options.maxDate), this.options.minDate);
|
|
145
|
+
}
|
|
146
|
+
if (suspend)
|
|
147
|
+
this.suspendLayout = true;
|
|
148
|
+
this.bindProperty.value = dateValue;
|
|
149
|
+
if (suspend)
|
|
150
|
+
Utils.nextTick(function () { return _this.suspendLayout = false; });
|
|
151
|
+
if (this.options.onDateSelected !== undefined) {
|
|
152
|
+
this.options.onDateSelected(!suspend);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
DatePicker.prototype.setInputValue = function () {
|
|
156
|
+
if (!this.options.alwaysShow) {
|
|
157
|
+
var displayValue = "";
|
|
158
|
+
if (this.bindProperty.value) {
|
|
159
|
+
displayValue = DateUtils.format(this.bindProperty.value, this.options.formatString);
|
|
160
|
+
}
|
|
161
|
+
this.input.value = displayValue;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
DatePicker.prototype.show = function () {
|
|
165
|
+
if (!this.options.timeOnly) {
|
|
166
|
+
this.resetCurrentViewDate();
|
|
167
|
+
this.createComponents();
|
|
168
|
+
this.positionPopup(true);
|
|
169
|
+
AnimationHelper.fade(this.popup, DatePicker.AnimationClassName, true);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
DatePicker.prototype.positionPopup = function (fromBottom) {
|
|
173
|
+
if (this.popup) {
|
|
174
|
+
PositionHelper.checkScreenBounds(this.container, this.popup, fromBottom, this.options.popupAlignRight);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Updates the date picker options. This also updates the input value of the input element. Update should be called by the Vue / React component on each render.
|
|
179
|
+
* @param options New options.
|
|
180
|
+
*/
|
|
181
|
+
DatePicker.prototype.update = function (options, bindProperty, isReadOnly) {
|
|
182
|
+
if (bindProperty && bindProperty !== this.bindProperty) {
|
|
183
|
+
this.bindProperty = bindProperty;
|
|
184
|
+
}
|
|
185
|
+
if (options) {
|
|
186
|
+
this.options = ProcessedDatePickerOptions.fromPartial(options);
|
|
187
|
+
}
|
|
188
|
+
this.isReadOnly = isReadOnly;
|
|
189
|
+
this.today = DateUtils.today();
|
|
190
|
+
if (this.currentBindValue !== (bindProperty === null || bindProperty === void 0 ? void 0 : bindProperty.value)) {
|
|
191
|
+
this.currentBindValue = bindProperty === null || bindProperty === void 0 ? void 0 : bindProperty.value;
|
|
192
|
+
this.resetCurrentViewDate();
|
|
193
|
+
if (this.options.alwaysShow) {
|
|
194
|
+
if (!this.suspendLayout) {
|
|
195
|
+
this.createComponents();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
this.setInputValue();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
DatePicker.prototype.resetCurrentViewDate = function () {
|
|
204
|
+
this.setCurrentViewDate(this.bindProperty.value);
|
|
205
|
+
this.currentViewType = this.options.monthView ? ViewType.Months : (this.options.yearView ? ViewType.Years : ViewType.Days);
|
|
206
|
+
};
|
|
207
|
+
DatePicker.prototype.setCurrentViewDate = function (fromDate) {
|
|
208
|
+
if (fromDate) {
|
|
209
|
+
this.boundDateNoTime = DateUtils.stripTime(fromDate);
|
|
210
|
+
if (this.inputHasChanged) {
|
|
211
|
+
// if the user is typing, show the selected date within the range of min and max date.
|
|
212
|
+
this.boundDateNoTime = DateUtils.max(DateUtils.min(this.boundDateNoTime, this.options.maxDateNoTime), this.options.minDateNoTime);
|
|
213
|
+
}
|
|
214
|
+
this.currentViewDate = new Date(this.boundDateNoTime);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
this.boundDateNoTime = null;
|
|
218
|
+
this.currentViewDate = DateUtils.today();
|
|
219
|
+
this.currentViewDate = DateUtils.max(DateUtils.min(this.currentViewDate, this.options.maxDateNoTime), this.options.minDateNoTime);
|
|
220
|
+
}
|
|
221
|
+
this.currentViewDate.setDate(1);
|
|
222
|
+
if (this.options.yearView) {
|
|
223
|
+
this.currentViewDate.setMonth(0);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
DatePicker.prototype.createComponents = function () {
|
|
227
|
+
var _this = this;
|
|
228
|
+
if (!this.popup) {
|
|
229
|
+
this.popup = this.createAndAppend(this.container, "div", "neo-datepicker-popup");
|
|
230
|
+
if (this.options.alwaysShow) {
|
|
231
|
+
this.popup.classList.add("neo-datepicker-inline");
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
this.popup.addEventListener("mouseenter", function () { return _this.positionPopup(false); });
|
|
235
|
+
this.popup.addEventListener("mouseleave", function () { return _this.positionPopup(true); });
|
|
236
|
+
}
|
|
237
|
+
this.createHeader();
|
|
238
|
+
this.createContentContainer();
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
this.populateContentContainer(true);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
DatePicker.prototype.createHeader = function () {
|
|
245
|
+
var header = this.createAndAppend(this.popup, "div", "neo-datepicker-header");
|
|
246
|
+
this.prevButton = this.createAndAppend(header, "button", "left-button");
|
|
247
|
+
this.prevButton.type = "button";
|
|
248
|
+
this.prevButton.innerText = "<";
|
|
249
|
+
this.prevButton.tabIndex = -1;
|
|
250
|
+
this.prevButton.addEventListener("mousedown", this.previousClick.bind(this));
|
|
251
|
+
this.headerContainer = this.createAndAppend(header, "div", "header-text-container");
|
|
252
|
+
this.headerContainer.addEventListener("mousedown", this.headerClick.bind(this));
|
|
253
|
+
this.headerAnimationHelper = new AnimationHelper(this.headerContainer, DatePicker.AnimationClassName);
|
|
254
|
+
this.nextButton = this.createAndAppend(header, "button", "right-button");
|
|
255
|
+
this.nextButton.type = "button";
|
|
256
|
+
this.nextButton.innerText = ">";
|
|
257
|
+
this.nextButton.tabIndex = -1;
|
|
258
|
+
this.nextButton.addEventListener("mousedown", this.nextClick.bind(this));
|
|
259
|
+
};
|
|
260
|
+
DatePicker.prototype.createHeaderLabel = function () {
|
|
261
|
+
this.currentHeaderLabel = this.createAndAppend(this.headerContainer, "div", "header-text");
|
|
262
|
+
if (this.currentViewType == ViewType.Days) {
|
|
263
|
+
this.currentHeaderLabel.innerText = DateUtils.format(this.currentViewDate, "MMMM yyyy");
|
|
264
|
+
}
|
|
265
|
+
else if (this.currentViewType == ViewType.Months) {
|
|
266
|
+
this.currentHeaderLabel.innerText = DateUtils.format(this.currentViewDate, "yyyy");
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
this.currentHeaderLabel.innerText = this.currentViewDate.getFullYear() + " - " + (this.currentViewDate.getFullYear() + YearsInYearView - 1);
|
|
270
|
+
}
|
|
271
|
+
if (this.currentViewType < ViewType.Years && !(this.prevButton.disabled && this.nextButton.disabled)) {
|
|
272
|
+
this.currentHeaderLabel.className += " selectable";
|
|
273
|
+
}
|
|
274
|
+
this.headerAnimationHelper.addChild(this.currentHeaderLabel, false);
|
|
275
|
+
this.headerAnimationHelper.fade();
|
|
276
|
+
};
|
|
277
|
+
DatePicker.prototype.createContentContainer = function () {
|
|
278
|
+
this.contentContainer = this.createAndAppend(this.popup, "div", "neo-datepicker-content");
|
|
279
|
+
this.contentContainer.addEventListener("mousedown", this.contentClick.bind(this));
|
|
280
|
+
this.contentAnimationHelper = new AnimationHelper(this.contentContainer, DatePicker.AnimationClassName);
|
|
281
|
+
this.populateContentContainer(!!this.options.alwaysShow);
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Populates a new d/m/y view and replaces the old view
|
|
285
|
+
* @param displayImmediately True if the new content must be displayed without animation.
|
|
286
|
+
* @param sameViewType True if the view type is not changing. E.g. scrolling left and right.
|
|
287
|
+
*/
|
|
288
|
+
DatePicker.prototype.populateContentContainer = function (displayImmediately, sameViewType) {
|
|
289
|
+
if (this.currentViewType == ViewType.Days) {
|
|
290
|
+
this.createDaysView();
|
|
291
|
+
}
|
|
292
|
+
else if (this.currentViewType == ViewType.Months) {
|
|
293
|
+
this.createMonthsView();
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
if (!sameViewType)
|
|
297
|
+
this.currentViewDate.setFullYear(this.currentViewDate.getFullYear() - this.options.yearsBeforeInYearView);
|
|
298
|
+
this.createYearsView();
|
|
299
|
+
}
|
|
300
|
+
this.createHeaderLabel();
|
|
301
|
+
this.contentAnimationHelper.addChild(this.currentContentTable, true);
|
|
302
|
+
if (displayImmediately) {
|
|
303
|
+
this.contentAnimationHelper.replace();
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
DatePicker.prototype.createDaysView = function () {
|
|
307
|
+
this.currentContentTable = this.createAndAppend(this.contentContainer, "table", "day-view");
|
|
308
|
+
var tHead = this.createAndAppend(this.currentContentTable, "thead");
|
|
309
|
+
var tBody = this.createAndAppend(this.currentContentTable, "tbody");
|
|
310
|
+
var trHead = this.createAndAppend(tHead, "tr");
|
|
311
|
+
var trBody = this.createAndAppend(tBody, "tr");
|
|
312
|
+
var currentDate = new Date(this.currentViewDate);
|
|
313
|
+
var lastDayOfMonth = DateUtils.monthEnd(currentDate);
|
|
314
|
+
this.prevButton.disabled = this.options.minDateNoTime.getTime() >= currentDate.getTime();
|
|
315
|
+
if (this.canAutoSetDate && this.options.autoChangeDate == "start") {
|
|
316
|
+
this.setBindProperty(currentDate, true);
|
|
317
|
+
}
|
|
318
|
+
this.nextButton.disabled = this.options.maxDateNoTime.getTime() <= lastDayOfMonth.getTime();
|
|
319
|
+
if (this.canAutoSetDate && this.options.autoChangeDate == "end") {
|
|
320
|
+
this.setBindProperty(lastDayOfMonth, true);
|
|
321
|
+
}
|
|
322
|
+
// Start with the first Sunday before the first of the month.
|
|
323
|
+
currentDate.setDate(currentDate.getDate() - currentDate.getDay());
|
|
324
|
+
var first = true;
|
|
325
|
+
while (true) {
|
|
326
|
+
for (var i = 0; i < 7; i++) {
|
|
327
|
+
if (first) {
|
|
328
|
+
var dayHeader = DateUtils.i18n.dayNames[currentDate.getDay()];
|
|
329
|
+
if (!this.options.display3DayLetters)
|
|
330
|
+
dayHeader = dayHeader.substring(0, 2);
|
|
331
|
+
this.createAndAppend(trHead, "th").innerText = dayHeader;
|
|
332
|
+
}
|
|
333
|
+
var cell = this.createAndAppend(trBody, "td");
|
|
334
|
+
var date = currentDate.getDate();
|
|
335
|
+
var month = currentDate.getMonth();
|
|
336
|
+
this.setupCell(cell, date.toString(), currentDate.getFullYear() + "," + month + "," + date, currentDate.getTime() >= this.options.minDateNoTime.getTime() && currentDate.getTime() <= this.options.maxDateNoTime.getTime(), currentDate.getTime() == this.today.getTime(), this.boundDateNoTime != null && currentDate.getTime() == this.boundDateNoTime.getTime());
|
|
337
|
+
if (month != this.currentViewDate.getMonth()) {
|
|
338
|
+
cell.classList.add("outside-month");
|
|
339
|
+
}
|
|
340
|
+
currentDate.setDate(date + 1);
|
|
341
|
+
}
|
|
342
|
+
trBody = this.createAndAppend(tBody, "tr");
|
|
343
|
+
first = false;
|
|
344
|
+
if (currentDate.getMonth() != this.currentViewDate.getMonth())
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
this.canAutoSetDate = false;
|
|
348
|
+
};
|
|
349
|
+
DatePicker.prototype.createMonthsView = function () {
|
|
350
|
+
this.currentContentTable = this.createAndAppend(this.contentContainer, "table", "month-view");
|
|
351
|
+
var tBody = this.createAndAppend(this.currentContentTable, "tbody");
|
|
352
|
+
var trBody;
|
|
353
|
+
var year = this.currentViewDate.getFullYear();
|
|
354
|
+
for (var i = 0; i < 12; i++) {
|
|
355
|
+
var monthStartDate = new Date(year, i, 1).getTime();
|
|
356
|
+
var monthEndDate = new Date(year, i + 1, 1).getTime();
|
|
357
|
+
if (i % 4 == 0) {
|
|
358
|
+
trBody = this.createAndAppend(tBody, "tr");
|
|
359
|
+
}
|
|
360
|
+
var cell = this.createAndAppend(trBody, "td");
|
|
361
|
+
this.setupCell(cell, DateUtils.i18n.monthNames[i], i, monthEndDate > this.options.minDateNoTime.getTime() && monthStartDate <= this.options.maxDateNoTime.getTime(), this.today.getFullYear() == year && this.today.getMonth() == i, this.boundDateNoTime != null && this.boundDateNoTime.getFullYear() == year && this.boundDateNoTime.getMonth() == i);
|
|
362
|
+
}
|
|
363
|
+
this.prevButton.disabled = this.options.minDateNoTime.getFullYear() >= year;
|
|
364
|
+
this.nextButton.disabled = this.options.maxDateNoTime.getFullYear() <= year;
|
|
365
|
+
};
|
|
366
|
+
DatePicker.prototype.createYearsView = function () {
|
|
367
|
+
this.currentContentTable = this.createAndAppend(this.contentContainer, "table", "year-view");
|
|
368
|
+
var tBody = this.createAndAppend(this.currentContentTable, "tbody");
|
|
369
|
+
var trBody;
|
|
370
|
+
var year = this.currentViewDate.getFullYear();
|
|
371
|
+
for (var i = 0; i < YearsInYearView; i++) {
|
|
372
|
+
if (i % 4 == 0) {
|
|
373
|
+
trBody = this.createAndAppend(tBody, "tr");
|
|
374
|
+
}
|
|
375
|
+
var cell = this.createAndAppend(trBody, "td");
|
|
376
|
+
this.setupCell(cell, (year + i).toString(), (year + i).toString(), year + i >= this.options.minDateNoTime.getFullYear() && year + i <= this.options.maxDateNoTime.getFullYear(), this.today.getFullYear() == year + i, this.boundDateNoTime != null && this.boundDateNoTime.getFullYear() == year + i);
|
|
377
|
+
}
|
|
378
|
+
this.prevButton.disabled = this.options.minDateNoTime.getFullYear() >= year;
|
|
379
|
+
this.nextButton.disabled = this.options.maxDateNoTime.getFullYear() < year + YearsInYearView;
|
|
380
|
+
};
|
|
381
|
+
DatePicker.prototype.setupCell = function (cell, innerText, data, selectable, current, isSelected) {
|
|
382
|
+
if (selectable) {
|
|
383
|
+
cell.classList.add("selectable");
|
|
384
|
+
cell.dataset["date"] = data;
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
cell.classList.add("disabled");
|
|
388
|
+
}
|
|
389
|
+
if (current) {
|
|
390
|
+
cell.classList.add("today");
|
|
391
|
+
}
|
|
392
|
+
if (isSelected) {
|
|
393
|
+
cell.classList.add("selected");
|
|
394
|
+
}
|
|
395
|
+
var cellContent = this.createAndAppend(cell, "span");
|
|
396
|
+
cellContent.innerText = innerText;
|
|
397
|
+
};
|
|
398
|
+
DatePicker.prototype.contentClick = function (e) {
|
|
399
|
+
e.preventDefault();
|
|
400
|
+
if (e.target) {
|
|
401
|
+
var element = e.target;
|
|
402
|
+
if (!element.dataset["date"]) {
|
|
403
|
+
element = element.parentElement;
|
|
404
|
+
}
|
|
405
|
+
var dateString = element === null || element === void 0 ? void 0 : element.dataset["date"];
|
|
406
|
+
if (dateString) {
|
|
407
|
+
if (this.currentViewType == ViewType.Days) {
|
|
408
|
+
this.dayClicked(dateString);
|
|
409
|
+
}
|
|
410
|
+
else if (this.currentViewType == ViewType.Months) {
|
|
411
|
+
this.monthClicked(dateString);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
this.yearClicked(dateString);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
DatePicker.prototype.dayClicked = function (datePartsString) {
|
|
420
|
+
var dateParts = datePartsString.split(",");
|
|
421
|
+
this.setBindValue(new Date(parseInt(dateParts[0]), parseInt(dateParts[1]), parseInt(dateParts[2])), { preserveTime: true, close: true });
|
|
422
|
+
};
|
|
423
|
+
DatePicker.prototype.monthClicked = function (monthString) {
|
|
424
|
+
this.currentViewDate.setMonth(parseInt(monthString));
|
|
425
|
+
if (this.options.monthView) {
|
|
426
|
+
this.setBindValue(this.currentViewDate, { preserveTime: true, close: true });
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
this.currentViewType = ViewType.Days;
|
|
430
|
+
this.canAutoSetDate = true;
|
|
431
|
+
this.populateContentContainer(false);
|
|
432
|
+
this.contentAnimationHelper.fadeAndScale(true);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
DatePicker.prototype.yearClicked = function (yearString) {
|
|
436
|
+
this.currentViewDate.setFullYear(parseInt(yearString));
|
|
437
|
+
if (this.options.yearView) {
|
|
438
|
+
this.setBindValue(this.currentViewDate, { preserveTime: true, close: true });
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
this.currentViewType = ViewType.Months;
|
|
442
|
+
this.populateContentContainer(false);
|
|
443
|
+
this.contentAnimationHelper.fadeAndScale(true);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
DatePicker.prototype.headerClick = function (e) {
|
|
447
|
+
e.preventDefault();
|
|
448
|
+
if (this.currentHeaderLabel.classList.contains("selectable")) {
|
|
449
|
+
if (this.currentViewType == ViewType.Days) {
|
|
450
|
+
this.currentViewType = ViewType.Months;
|
|
451
|
+
}
|
|
452
|
+
else if (this.currentViewType == ViewType.Months) {
|
|
453
|
+
this.currentViewType = ViewType.Years;
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
this.populateContentContainer(false);
|
|
459
|
+
this.contentAnimationHelper.fadeAndScale(false);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
DatePicker.prototype.previousClick = function (e) {
|
|
463
|
+
e.preventDefault();
|
|
464
|
+
this.moveCurrent(-1);
|
|
465
|
+
};
|
|
466
|
+
DatePicker.prototype.nextClick = function (e) {
|
|
467
|
+
e.preventDefault();
|
|
468
|
+
this.moveCurrent(1);
|
|
469
|
+
};
|
|
470
|
+
DatePicker.prototype.moveCurrent = function (delta) {
|
|
471
|
+
if (this.currentViewType == ViewType.Days) {
|
|
472
|
+
this.canAutoSetDate = true;
|
|
473
|
+
this.currentViewDate.setMonth(this.currentViewDate.getMonth() + delta, 1);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
this.currentViewDate.setFullYear(this.currentViewDate.getFullYear() + delta * (this.currentViewType == ViewType.Months ? 1 : YearsInYearView));
|
|
477
|
+
}
|
|
478
|
+
this.populateContentContainer(false, true);
|
|
479
|
+
this.contentAnimationHelper.slide(delta, true);
|
|
480
|
+
};
|
|
481
|
+
DatePicker.prototype.createAndAppend = function (parent, elementType, className) {
|
|
482
|
+
if (className === void 0) { className = ""; }
|
|
483
|
+
var newElement = document.createElement(elementType);
|
|
484
|
+
if (className)
|
|
485
|
+
newElement.className = className;
|
|
486
|
+
parent.appendChild(newElement);
|
|
487
|
+
return newElement;
|
|
488
|
+
};
|
|
489
|
+
DatePicker.prototype.destroy = function () {
|
|
490
|
+
if (this.input) {
|
|
491
|
+
this.input.removeEventListener("focus", this.inputFocused);
|
|
492
|
+
this.input.removeEventListener("mousedown", this.inputFocused);
|
|
493
|
+
this.input.removeEventListener("blur", this.inputBlurred);
|
|
494
|
+
this.input.removeEventListener("input", this.inputChanged);
|
|
495
|
+
this.input.removeEventListener("keydown", this.inputKeyDown);
|
|
496
|
+
}
|
|
497
|
+
this.removePopup(false);
|
|
498
|
+
};
|
|
499
|
+
DatePicker.AnimationClassName = "neo-datepicker-animate";
|
|
500
|
+
return DatePicker;
|
|
501
|
+
}());
|
|
502
|
+
export default DatePicker;
|