mis-crystal-design-system 2.9.9 → 3.0.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.
Files changed (43) hide show
  1. package/bundles/mis-crystal-design-system-timepicker.umd.js +630 -0
  2. package/bundles/mis-crystal-design-system-timepicker.umd.js.map +1 -0
  3. package/bundles/mis-crystal-design-system-timepicker.umd.min.js +16 -0
  4. package/bundles/mis-crystal-design-system-timepicker.umd.min.js.map +1 -0
  5. package/bundles/mis-crystal-design-system-timerangepicker.umd.js +177 -0
  6. package/bundles/mis-crystal-design-system-timerangepicker.umd.js.map +1 -0
  7. package/bundles/mis-crystal-design-system-timerangepicker.umd.min.js +2 -0
  8. package/bundles/mis-crystal-design-system-timerangepicker.umd.min.js.map +1 -0
  9. package/esm2015/timepicker/index.js +2 -0
  10. package/esm2015/timepicker/mis-crystal-design-system-timepicker.js +6 -0
  11. package/esm2015/timepicker/public_api.js +3 -0
  12. package/esm2015/timepicker/time.namespace.js +2 -0
  13. package/esm2015/timepicker/timepicker.component.js +189 -0
  14. package/esm2015/timepicker/timepicker.directive.js +62 -0
  15. package/esm2015/timepicker/timepicker.module.js +20 -0
  16. package/esm2015/timerangepicker/index.js +2 -0
  17. package/esm2015/timerangepicker/mis-crystal-design-system-timerangepicker.js +5 -0
  18. package/esm2015/timerangepicker/public_api.js +3 -0
  19. package/esm2015/timerangepicker/timerange.namespace.js +2 -0
  20. package/esm2015/timerangepicker/timerangepicker.component.js +123 -0
  21. package/esm2015/timerangepicker/timerangepicker.module.js +18 -0
  22. package/fesm2015/mis-crystal-design-system-timepicker.js +272 -0
  23. package/fesm2015/mis-crystal-design-system-timepicker.js.map +1 -0
  24. package/fesm2015/mis-crystal-design-system-timerangepicker.js +147 -0
  25. package/fesm2015/mis-crystal-design-system-timerangepicker.js.map +1 -0
  26. package/package.json +1 -1
  27. package/timepicker/index.d.ts +1 -0
  28. package/timepicker/mis-crystal-design-system-timepicker.d.ts +5 -0
  29. package/timepicker/mis-crystal-design-system-timepicker.metadata.json +1 -0
  30. package/timepicker/package.json +11 -0
  31. package/timepicker/public_api.d.ts +2 -0
  32. package/timepicker/time.namespace.d.ts +4 -0
  33. package/timepicker/timepicker.component.d.ts +38 -0
  34. package/timepicker/timepicker.directive.d.ts +16 -0
  35. package/timepicker/timepicker.module.d.ts +4 -0
  36. package/timerangepicker/index.d.ts +1 -0
  37. package/timerangepicker/mis-crystal-design-system-timerangepicker.d.ts +4 -0
  38. package/timerangepicker/mis-crystal-design-system-timerangepicker.metadata.json +1 -0
  39. package/timerangepicker/package.json +11 -0
  40. package/timerangepicker/public_api.d.ts +2 -0
  41. package/timerangepicker/timerange.namespace.d.ts +9 -0
  42. package/timerangepicker/timerangepicker.component.d.ts +29 -0
  43. package/timerangepicker/timerangepicker.module.d.ts +4 -0
@@ -0,0 +1,272 @@
1
+ import { EventEmitter, Directive, TemplateRef, ViewContainerRef, Input, Output, Component, ViewChild, ViewChildren, NgModule } from '@angular/core';
2
+ import * as moment from 'moment-timezone';
3
+ import { tz } from 'moment-timezone';
4
+ import { ConnectionPositionPair, OverlayConfig, Overlay, OverlayModule } from '@angular/cdk/overlay';
5
+ import { TemplatePortal } from '@angular/cdk/portal';
6
+ import { CommonModule } from '@angular/common';
7
+ import { FormsModule } from '@angular/forms';
8
+ import { ToolTipModule } from 'mis-crystal-design-system/tooltip';
9
+
10
+ class TimepickerDirective {
11
+ constructor(templateRef, overlay, viewContainerRef) {
12
+ this.templateRef = templateRef;
13
+ this.overlay = overlay;
14
+ this.viewContainerRef = viewContainerRef;
15
+ this.openStatus = false;
16
+ this.statusEmitter = new EventEmitter();
17
+ }
18
+ set createOverlayOnInput(openStatus) {
19
+ this.openStatus = openStatus;
20
+ if (this.originEl && this.openStatus)
21
+ this.createOverlay(this.originEl);
22
+ }
23
+ ;
24
+ createOverlay(origin) {
25
+ const positions = [
26
+ new ConnectionPositionPair({ originX: "start", originY: "bottom" }, { overlayX: "start", overlayY: "top" }, 0, 4),
27
+ new ConnectionPositionPair({ originX: "end", originY: "bottom" }, { overlayX: "end", overlayY: "top" }, 0, 4)
28
+ ];
29
+ const overlayConfig = new OverlayConfig({
30
+ hasBackdrop: true,
31
+ backdropClass: "cdk-overlay-transparent-backdrop",
32
+ positionStrategy: this.overlay
33
+ .position()
34
+ //connecting the dropdown overlay to the input element
35
+ .flexibleConnectedTo(origin)
36
+ .withPositions([...positions])
37
+ .withPush(true)
38
+ });
39
+ this.overlayRef = this.overlay.create(overlayConfig);
40
+ const dropdownPortal = new TemplatePortal(this.templateRef, this.viewContainerRef);
41
+ this.overlayRef.attach(dropdownPortal);
42
+ this.overlayRef.backdropClick().subscribe(resp => {
43
+ this.openStatus = false;
44
+ this.statusEmitter.emit(false);
45
+ this.overlayRef.detach();
46
+ });
47
+ }
48
+ destroyOverlay() {
49
+ this.overlayRef.detach();
50
+ }
51
+ }
52
+ TimepickerDirective.decorators = [
53
+ { type: Directive, args: [{
54
+ selector: '[libTimepicker]'
55
+ },] }
56
+ ];
57
+ TimepickerDirective.ctorParameters = () => [
58
+ { type: TemplateRef },
59
+ { type: Overlay },
60
+ { type: ViewContainerRef }
61
+ ];
62
+ TimepickerDirective.propDecorators = {
63
+ originEl: [{ type: Input, args: ['originEl',] }],
64
+ statusEmitter: [{ type: Output }],
65
+ createOverlayOnInput: [{ type: Input, args: ['openStatus',] }]
66
+ };
67
+
68
+ class TimePickerComponent {
69
+ constructor() {
70
+ this.openStatus = false;
71
+ this.isHighlighted = 0;
72
+ this.isInvalid = false;
73
+ this.timeIntervals = [];
74
+ this.shouldScroll = false;
75
+ this.userInputFlag = false;
76
+ this.clockFormat = 12;
77
+ this.timezone = "Asia/Kolkata";
78
+ this.height = "max-content";
79
+ this.inputWidth = "100px";
80
+ this.interval = 15;
81
+ this.dateAsEpoch = moment().valueOf();
82
+ this.rangeValidity = true;
83
+ this.timeEmitter = new EventEmitter();
84
+ }
85
+ // gets all the li elements from the dropdown and scrolls to the highlighted element
86
+ set timeIntervalRefs(intervals) {
87
+ intervals.forEach(interval => {
88
+ if (interval.nativeElement.classList[0] === "highlight") {
89
+ const highlighted = interval.nativeElement;
90
+ setTimeout(() => highlighted.scrollIntoView({ behavior: "smooth", block: "center" }));
91
+ }
92
+ });
93
+ }
94
+ ngOnInit() {
95
+ this.timeFormat = this.clockFormat === 12 ? "hh:mm a" : "HH:mm";
96
+ this.populateDropdown();
97
+ this.chosenTime = this.timeIntervals[0];
98
+ this.calculateClosestInterval(this.chosenTime);
99
+ this.emitTime({
100
+ valid: !this.isInvalid,
101
+ time: this.chosenTime
102
+ });
103
+ }
104
+ ngOnChanges() {
105
+ tz.setDefault(this.timezone);
106
+ this.currTime = moment().format();
107
+ if (this.timeFormat) {
108
+ // if the first interval is >= the chosen time
109
+ // then only update the value of chosen time
110
+ // else it remains the same
111
+ const chosenTimeMoment = moment(`${moment(this.dateAsEpoch).format("DD-MM-YYYY")} ${this.chosenTime}`, `'DD-MM-YYYY' ${this.timeFormat}`);
112
+ if (this.firstInterval >= chosenTimeMoment.valueOf() && this.rangeValidity && !this.userInputFlag) {
113
+ this.chosenTime = moment(this.firstInterval).format(this.timeFormat);
114
+ }
115
+ if (!this.userInputFlag)
116
+ this.populateDropdown();
117
+ this.userInputFlag = false;
118
+ this.isInvalid = !this.checkTimeValidity(this.chosenTime.trim());
119
+ this.emitTime({
120
+ valid: !this.isInvalid,
121
+ time: this.chosenTime
122
+ });
123
+ this.calculateClosestInterval(this.chosenTime);
124
+ }
125
+ }
126
+ emitTime(data) {
127
+ this.timeEmitter.emit(data);
128
+ }
129
+ // gets a boolean from overlay event to close the dropdown
130
+ closeDropdown(val) {
131
+ this.openStatus = val;
132
+ }
133
+ // toggle timepicker dropdown
134
+ openDropdown() {
135
+ this.openStatus = true;
136
+ }
137
+ checkTimeValidity(time) {
138
+ const RE12 = /^(([0-9][1-9]|1[0-2]):([0-5][0-9])( )?(am|pm|AM|PM))$/i;
139
+ const RE24 = /^([01][0-9]|2[0-3]):[0-5][0-9]$/;
140
+ const RE = this.clockFormat === 12 ? RE12 : RE24;
141
+ const timeMoment = moment(`${moment(this.dateAsEpoch).format("DD-MM-YYYY")} ${time}`, `'DD-MM-YYYY' ${this.timeFormat}`);
142
+ let flag = false;
143
+ // if the first interval is set to the start of the day
144
+ // then we don't check its validity against the current time
145
+ if (this.firstInterval &&
146
+ moment(this.firstInterval).format(this.timeFormat).valueOf() === moment().startOf("d").format(this.timeFormat).valueOf()) {
147
+ flag = time.match(RE) ? true : false;
148
+ }
149
+ else {
150
+ flag = time.match(RE) && timeMoment.isAfter(moment());
151
+ }
152
+ return flag;
153
+ }
154
+ // update chosen time as soon as the user clicks on an interval
155
+ onTimeSelect(time) {
156
+ this.isInvalid = !this.checkTimeValidity(time.trim());
157
+ if (!this.isInvalid) {
158
+ this.chosenTime = time;
159
+ this.calculateClosestInterval(this.chosenTime);
160
+ }
161
+ this.emitTime({
162
+ valid: !this.isInvalid,
163
+ time: time
164
+ });
165
+ this.openStatus = false;
166
+ if (this.timepickerDirective)
167
+ this.timepickerDirective.destroyOverlay();
168
+ }
169
+ // checks validity of time on input change and calculates the closest interval
170
+ onTimeChange(time) {
171
+ this.isInvalid = !this.checkTimeValidity(time.trim());
172
+ if (!this.isInvalid) {
173
+ this.userInputFlag = true;
174
+ this.calculateClosestInterval(time);
175
+ }
176
+ this.emitTime({
177
+ valid: !this.isInvalid,
178
+ time: time
179
+ });
180
+ }
181
+ calculateClosestInterval(time) {
182
+ const intervalMS = this.interval * 60 * 1000;
183
+ const chosenDate = moment(this.dateAsEpoch).format("DD-MM-YYYY");
184
+ // converting time passed as parameter to moment object and adding date
185
+ const parsedTimeWithDate = moment(`${chosenDate} ${time}`, `DD-MM-YYYY ${this.timeFormat}`);
186
+ // converting moment object to epoch so that calculations for rounding off are easier to do
187
+ const currEpoch = parsedTimeWithDate.valueOf();
188
+ const offset = currEpoch % intervalMS;
189
+ const roundedEpoch = offset >= intervalMS / 2 ? currEpoch + (intervalMS - offset) : currEpoch - offset;
190
+ // finding the index of element that needs to be highlighted
191
+ this.timeIntervals.forEach((interval, index, array) => {
192
+ const intervalObj = moment(`${chosenDate} ${interval}`, `DD-MM-YYYY ${this.timeFormat}`);
193
+ if (intervalObj.valueOf() === roundedEpoch)
194
+ this.isHighlighted = index;
195
+ if (array.length === 1)
196
+ this.isHighlighted = 0;
197
+ });
198
+ }
199
+ // populates the dropdown according to the first interval received
200
+ populateDropdown() {
201
+ this.timeIntervals = [];
202
+ // if picker is used as an individual component
203
+ if (!this.firstInterval) {
204
+ // firstInterval is initialised according to the current time
205
+ // if the date is same as the current date
206
+ if (moment(this.dateAsEpoch).format("DD-MM-YYYY") === moment().format("DD-MM-YYYY")) {
207
+ const offset = this.interval - (moment().minutes() % this.interval);
208
+ this.firstInterval = moment().add(offset, "m").valueOf();
209
+ }
210
+ // else the firstInterval is initialised as start of day
211
+ else {
212
+ this.firstInterval = moment().startOf("d").valueOf();
213
+ }
214
+ }
215
+ const start = moment(this.firstInterval);
216
+ const end = moment().endOf("d");
217
+ while (start.valueOf() < end.valueOf()) {
218
+ this.timeIntervals.push(start.format(this.timeFormat));
219
+ start.add(this.interval, "m");
220
+ }
221
+ // if the start time is equal to the interval just before midnight
222
+ // and the start date = end date
223
+ // push 11:59pm only
224
+ if (this.timeIntervals.length === 0) {
225
+ this.chosenTime = moment().endOf("d").format(this.timeFormat);
226
+ this.timeIntervals.push(moment().endOf("d").format(this.timeFormat));
227
+ }
228
+ }
229
+ }
230
+ TimePickerComponent.decorators = [
231
+ { type: Component, args: [{
232
+ selector: "mis-timepicker",
233
+ template: "<div class=\"timepicker-container\" [ngStyle]=\"{ height: height }\">\n <input\n type=\"text\"\n [(ngModel)]=\"chosenTime\"\n (ngModelChange)=\"onTimeChange(chosenTime)\"\n [ngClass]=\"{ invalid: isInvalid || !rangeValidity }\"\n [ngStyle]=\"{ width: inputWidth }\"\n (click)=\"openDropdown()\"\n misToolTip\n [showToolTip]=\"isInvalid || !rangeValidity\"\n [text]=\"'Invalid Time'\"\n [position]=\"'top'\"\n [showOnHover]=\"false\"\n #input\n cdkOverlayOrigin\n class=\"p\"\n />\n\n <ng-template #dropdownContainer libDropdownScroll libTimepicker [originEl]=\"input\" [openStatus]=\"openStatus\" (statusEmitter)=\"closeDropdown($event)\">\n <div *ngIf=\"openStatus\" class=\"timepicker-dropdown\" [ngStyle]=\"{ width: dropdownWidth || inputWidth }\">\n <ul #dropdown>\n <li #timeInterval (click)=\"onTimeSelect(interval)\" *ngFor=\"let interval of timeIntervals; index as i\" [ngClass]=\"{ highlight: i === isHighlighted }\">\n {{ interval }}\n <div class=\"ic-ui-check-24 selected-icon\" *ngIf=\"interval === chosenTime\"></div>\n </li>\n </ul>\n </div>\n </ng-template>\n</div>\n",
234
+ styles: [".h1{font-size:40px;line-height:48px}.h1,.h2{font-weight:400;letter-spacing:0}.h2{font-size:32px;line-height:40px}.h3{font-size:28px;line-height:36px}.h3,.h4{font-weight:400;letter-spacing:0}.h4{font-size:24px;line-height:32px}.h5-b{font-weight:700;letter-spacing:.25px}.h5,.h5-b{font-size:20px;line-height:28px}.h5{font-weight:400;letter-spacing:.15px}.h6-b{font-weight:700}.h6,.h6-b{font-size:16px;letter-spacing:0;line-height:24px}.h6,.p{font-weight:400}.p{font-size:16px;letter-spacing:0;line-height:180%}.h7-b{font-weight:700;letter-spacing:.25px}.h7,.h7-b{font-size:14px;line-height:20px}.h7{font-weight:400;letter-spacing:.2px}.h8-b{font-weight:700;letter-spacing:.25px}.h8,.h8-b{font-size:12px;line-height:18px}.h8{letter-spacing:.2px}.h8,.h9{font-weight:400}.h9{font-size:10px;letter-spacing:0;line-height:15px}.btn-lg-b{font-weight:700;letter-spacing:.5px}.btn-lg,.btn-lg-b{font-size:16px;line-height:24px}.btn-lg{font-weight:400;letter-spacing:.2px}.btn-sm{font-size:14px;font-weight:400;letter-spacing:.25px;line-height:20px}.btn-link{font-size:16px;line-height:24px}.btn-link,.display-1{font-weight:400;letter-spacing:0}.display-1{font-size:48px;line-height:56px}.display-2{font-size:14px;font-weight:400;letter-spacing:.5px;line-height:20px}*{box-sizing:border-box;font-family:Lato}.timepicker-container{display:inline-block;position:relative}input{text-align:center;border:none;border-bottom:1px solid #e0e0e0;outline:none;height:100%;width:100px;padding:4px 16px}input:hover{background:#f5f7fc}input:active,input:focus{background:#e6ebf7;border-bottom:1px solid #0937b2}.timepicker-dropdown{position:absolute;top:calc(100% + 4px);left:0;max-height:200px;overflow-y:auto;border:1px solid #e0e0e0;box-shadow:0 12px 24px rgba(0,0,0,.12),0 4px 8px rgba(0,0,0,.12);border-radius:4px;padding:8px;background:#fff}.timepicker-dropdown::-webkit-scrollbar{display:none}.timepicker-dropdown ul{margin:0;padding:0}.timepicker-dropdown li{text-align:start;list-style:none;padding:6px 12px;cursor:pointer;font-size:16px;color:#181f33;display:flex;justify-content:space-between;align-items:center}.timepicker-dropdown li:hover{background:#f5f7fc;border-radius:6px}.timepicker-dropdown li .selected-icon{font-weight:900}.highlight{background-color:#f5f7fc;border-radius:6px}.invalid{background:#fae1ea!important;border-bottom:1px solid #b00020!important}"]
235
+ },] }
236
+ ];
237
+ TimePickerComponent.ctorParameters = () => [];
238
+ TimePickerComponent.propDecorators = {
239
+ clockFormat: [{ type: Input }],
240
+ timezone: [{ type: Input }],
241
+ height: [{ type: Input }],
242
+ inputWidth: [{ type: Input }],
243
+ dropdownWidth: [{ type: Input }],
244
+ interval: [{ type: Input }],
245
+ dateAsEpoch: [{ type: Input }],
246
+ firstInterval: [{ type: Input }],
247
+ rangeValidity: [{ type: Input }],
248
+ timeEmitter: [{ type: Output }],
249
+ input: [{ type: ViewChild, args: ["input", { static: true },] }],
250
+ timepickerDirective: [{ type: ViewChild, args: [TimepickerDirective,] }],
251
+ timeIntervalRefs: [{ type: ViewChildren, args: ["timeInterval",] }]
252
+ };
253
+
254
+ class TimePickerModule {
255
+ static forRoot() {
256
+ return { ngModule: TimePickerModule, providers: [] };
257
+ }
258
+ }
259
+ TimePickerModule.decorators = [
260
+ { type: NgModule, args: [{
261
+ declarations: [TimePickerComponent, TimepickerDirective],
262
+ imports: [CommonModule, FormsModule, ToolTipModule, OverlayModule],
263
+ exports: [TimePickerComponent]
264
+ },] }
265
+ ];
266
+
267
+ /**
268
+ * Generated bundle index. Do not edit.
269
+ */
270
+
271
+ export { TimePickerComponent, TimePickerModule, TimepickerDirective as ɵa };
272
+ //# sourceMappingURL=mis-crystal-design-system-timepicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mis-crystal-design-system-timepicker.js","sources":["../../../projects/mis-components/timepicker/timepicker.directive.ts","../../../projects/mis-components/timepicker/timepicker.component.ts","../../../projects/mis-components/timepicker/timepicker.module.ts","../../../projects/mis-components/timepicker/mis-crystal-design-system-timepicker.ts"],"sourcesContent":["import { Directive, Output, TemplateRef } from '@angular/core';\nimport { EventEmitter, Input, ViewContainerRef } from \"@angular/core\";\nimport { ConnectionPositionPair, Overlay, OverlayConfig, OverlayRef } from \"@angular/cdk/overlay\";\nimport { TemplatePortal } from \"@angular/cdk/portal\";\n\n@Directive({\n selector: '[libTimepicker]'\n})\nexport class TimepickerDirective {\n private openStatus: boolean = false;\n @Input('originEl') originEl : any;\n @Output() statusEmitter = new EventEmitter<boolean>(); \n\n @Input('openStatus') set createOverlayOnInput(openStatus){\n this.openStatus = openStatus;\n if(this.originEl && this.openStatus) this.createOverlay(this.originEl);\n }; \n private overlayRef!: OverlayRef;\n constructor(private templateRef: TemplateRef<Element>, private overlay: Overlay, private viewContainerRef: ViewContainerRef) {}\n\n createOverlay(origin: any): void {\n const positions = [\n new ConnectionPositionPair({ originX: \"start\", originY: \"bottom\" }, { overlayX: \"start\", overlayY: \"top\" }, 0, 4),\n new ConnectionPositionPair({ originX: \"end\", originY: \"bottom\" }, { overlayX: \"end\", overlayY: \"top\" }, 0, 4)\n ];\n\n const overlayConfig = new OverlayConfig({\n hasBackdrop: true,\n backdropClass: \"cdk-overlay-transparent-backdrop\",\n positionStrategy: this.overlay\n .position()\n //connecting the dropdown overlay to the input element\n .flexibleConnectedTo(origin)\n .withPositions([...positions])\n .withPush(true)\n });\n\n this.overlayRef = this.overlay.create(overlayConfig);\n const dropdownPortal = new TemplatePortal(this.templateRef, this.viewContainerRef);\n this.overlayRef.attach(dropdownPortal);\n this.overlayRef.backdropClick().subscribe(resp => {\n this.openStatus = false;\n this.statusEmitter.emit(false);\n this.overlayRef.detach();\n });\n }\n\n destroyOverlay(){\n this.overlayRef.detach();\n }\n \n}\n","import { Component, ElementRef, EventEmitter, Input, Output, QueryList, TemplateRef, ViewChild, ViewChildren } from \"@angular/core\";\nimport * as moment from \"moment-timezone\";\nimport { ITime } from \"./time.namespace\";\nimport { TimepickerDirective } from \"./timepicker.directive\";\n\n@Component({\n selector: \"mis-timepicker\",\n templateUrl: \"./timepicker.component.html\",\n styleUrls: [\"./timepicker.component.scss\"]\n})\nexport class TimePickerComponent {\n currTime!: string;\n chosenTime: string;\n openStatus: boolean = false;\n isHighlighted: number = 0;\n isInvalid: boolean = false;\n timeIntervals: string[] = [];\n shouldScroll: boolean = false;\n userInputFlag: boolean = false;\n\n @Input() clockFormat: number = 12;\n timeFormat!: string;\n\n @Input() timezone: string = \"Asia/Kolkata\";\n @Input() height: string = \"max-content\";\n @Input() inputWidth: string = \"100px\";\n @Input() dropdownWidth?: string;\n @Input() interval: number = 15;\n @Input() dateAsEpoch: number = moment().valueOf();\n @Input() firstInterval!: number;\n @Input() rangeValidity: boolean = true;\n\n @Output() timeEmitter = new EventEmitter<ITime>();\n @ViewChild(\"input\", { static: true }) input: ElementRef;\n @ViewChild(TimepickerDirective) timepickerDirective: TimepickerDirective;\n\n // gets all the li elements from the dropdown and scrolls to the highlighted element\n @ViewChildren(\"timeInterval\") set timeIntervalRefs(intervals) {\n intervals.forEach(interval => {\n if (interval.nativeElement.classList[0] === \"highlight\") {\n const highlighted = interval.nativeElement;\n setTimeout(() => highlighted.scrollIntoView({ behavior: \"smooth\", block: \"center\" }));\n }\n });\n }\n\n constructor() {}\n ngOnInit(): void {\n this.timeFormat = this.clockFormat === 12 ? \"hh:mm a\" : \"HH:mm\";\n this.populateDropdown();\n this.chosenTime = this.timeIntervals[0];\n this.calculateClosestInterval(this.chosenTime);\n this.emitTime({\n valid: !this.isInvalid,\n time: this.chosenTime\n });\n }\n\n ngOnChanges(): void {\n moment.tz.setDefault(this.timezone);\n this.currTime = moment().format();\n if (this.timeFormat) {\n // if the first interval is >= the chosen time\n // then only update the value of chosen time\n // else it remains the same\n const chosenTimeMoment = moment(`${moment(this.dateAsEpoch).format(\"DD-MM-YYYY\")} ${this.chosenTime}`, `'DD-MM-YYYY' ${this.timeFormat}`);\n\n if (this.firstInterval >= chosenTimeMoment.valueOf() && this.rangeValidity && !this.userInputFlag) {\n this.chosenTime = moment(this.firstInterval).format(this.timeFormat);\n }\n if (!this.userInputFlag) this.populateDropdown();\n this.userInputFlag = false;\n this.isInvalid = !this.checkTimeValidity(this.chosenTime.trim());\n this.emitTime({\n valid: !this.isInvalid,\n time: this.chosenTime\n });\n this.calculateClosestInterval(this.chosenTime);\n }\n }\n\n emitTime(data: ITime): void {\n this.timeEmitter.emit(data);\n }\n\n // gets a boolean from overlay event to close the dropdown\n closeDropdown(val: boolean) {\n this.openStatus = val;\n }\n\n // toggle timepicker dropdown\n openDropdown(): void {\n this.openStatus = true;\n }\n\n checkTimeValidity(time: string): boolean {\n const RE12 = /^(([0-9][1-9]|1[0-2]):([0-5][0-9])( )?(am|pm|AM|PM))$/i;\n const RE24 = /^([01][0-9]|2[0-3]):[0-5][0-9]$/;\n const RE = this.clockFormat === 12 ? RE12 : RE24;\n\n const timeMoment = moment(`${moment(this.dateAsEpoch).format(\"DD-MM-YYYY\")} ${time}`, `'DD-MM-YYYY' ${this.timeFormat}`);\n let flag: boolean = false;\n\n // if the first interval is set to the start of the day\n // then we don't check its validity against the current time\n if (\n this.firstInterval &&\n moment(this.firstInterval).format(this.timeFormat).valueOf() === moment().startOf(\"d\").format(this.timeFormat).valueOf()\n ) {\n flag = time.match(RE) ? true : false;\n } else {\n flag = time.match(RE) && timeMoment.isAfter(moment());\n }\n\n return flag;\n }\n\n // update chosen time as soon as the user clicks on an interval\n onTimeSelect(time: string): void {\n this.isInvalid = !this.checkTimeValidity(time.trim());\n if (!this.isInvalid) {\n this.chosenTime = time;\n this.calculateClosestInterval(this.chosenTime);\n }\n this.emitTime({\n valid: !this.isInvalid,\n time: time\n });\n this.openStatus = false;\n if (this.timepickerDirective) this.timepickerDirective.destroyOverlay();\n }\n\n // checks validity of time on input change and calculates the closest interval\n onTimeChange(time: string): void {\n this.isInvalid = !this.checkTimeValidity(time.trim());\n if (!this.isInvalid) {\n this.userInputFlag = true;\n this.calculateClosestInterval(time);\n }\n this.emitTime({\n valid: !this.isInvalid,\n time: time\n });\n }\n\n calculateClosestInterval(time: string): void {\n const intervalMS = this.interval * 60 * 1000;\n const chosenDate = moment(this.dateAsEpoch).format(\"DD-MM-YYYY\");\n\n // converting time passed as parameter to moment object and adding date\n const parsedTimeWithDate = moment(`${chosenDate} ${time}`, `DD-MM-YYYY ${this.timeFormat}`);\n\n // converting moment object to epoch so that calculations for rounding off are easier to do\n const currEpoch = parsedTimeWithDate.valueOf();\n\n const offset = currEpoch % intervalMS;\n const roundedEpoch = offset >= intervalMS / 2 ? currEpoch + (intervalMS - offset) : currEpoch - offset;\n\n // finding the index of element that needs to be highlighted\n this.timeIntervals.forEach((interval, index, array) => {\n const intervalObj = moment(`${chosenDate} ${interval}`, `DD-MM-YYYY ${this.timeFormat}`);\n if (intervalObj.valueOf() === roundedEpoch) this.isHighlighted = index;\n if (array.length === 1) this.isHighlighted = 0;\n });\n }\n\n // populates the dropdown according to the first interval received\n populateDropdown(): void {\n this.timeIntervals = [];\n\n // if picker is used as an individual component\n if (!this.firstInterval) {\n // firstInterval is initialised according to the current time\n // if the date is same as the current date\n if (moment(this.dateAsEpoch).format(\"DD-MM-YYYY\") === moment().format(\"DD-MM-YYYY\")) {\n const offset = this.interval - (moment().minutes() % this.interval);\n this.firstInterval = moment().add(offset, \"m\").valueOf();\n }\n\n // else the firstInterval is initialised as start of day\n else {\n this.firstInterval = moment().startOf(\"d\").valueOf();\n }\n }\n\n const start = moment(this.firstInterval);\n const end = moment().endOf(\"d\");\n\n while (start.valueOf() < end.valueOf()) {\n this.timeIntervals.push(start.format(this.timeFormat));\n start.add(this.interval, \"m\");\n }\n\n // if the start time is equal to the interval just before midnight\n // and the start date = end date\n // push 11:59pm only\n if (this.timeIntervals.length === 0) {\n this.chosenTime = moment().endOf(\"d\").format(this.timeFormat);\n this.timeIntervals.push(moment().endOf(\"d\").format(this.timeFormat));\n }\n }\n}\n","import { NgModule, ModuleWithProviders } from \"@angular/core\";\nimport { CommonModule } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { TimePickerComponent } from \"./timepicker.component\";\nimport { ToolTipModule } from \"mis-crystal-design-system/tooltip\";\nimport { OverlayModule } from '@angular/cdk/overlay';\nimport { TimepickerDirective } from './timepicker.directive';\n\n@NgModule({\n declarations: [TimePickerComponent, TimepickerDirective],\n imports: [CommonModule, FormsModule, ToolTipModule, OverlayModule],\n exports: [TimePickerComponent]\n})\nexport class TimePickerModule {\n static forRoot(): ModuleWithProviders<TimePickerModule> {\n return { ngModule: TimePickerModule, providers: [] };\n }\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n\nexport {TimepickerDirective as ɵa} from './timepicker.directive';"],"names":["moment.tz"],"mappings":";;;;;;;;;MAQa,mBAAmB;IAU9B,YAAoB,WAAiC,EAAU,OAAgB,EAAU,gBAAkC;QAAvG,gBAAW,GAAX,WAAW,CAAsB;QAAU,YAAO,GAAP,OAAO,CAAS;QAAU,qBAAgB,GAAhB,gBAAgB,CAAkB;QATnH,eAAU,GAAY,KAAK,CAAC;QAE1B,kBAAa,GAAG,IAAI,YAAY,EAAW,CAAC;KAOyE;IAL/H,IAA0B,oBAAoB,CAAC,UAAU;QACvD,IAAI,CAAC,UAAU,GAAG,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gBACR,YAAY,EAAE,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;gBACxD,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,CAAC;gBAClE,OAAO,EAAE,CAAC,mBAAmB,CAAC;aAC/B;;;ACZD;;;;;;"}
@@ -0,0 +1,147 @@
1
+ import { EventEmitter, Component, ChangeDetectorRef, Input, Output, NgModule } from '@angular/core';
2
+ import * as moment from 'moment-timezone';
3
+ import { tz } from 'moment-timezone';
4
+ import { CommonModule } from '@angular/common';
5
+ import { FormsModule } from '@angular/forms';
6
+ import { TimePickerModule } from 'mis-crystal-design-system/timepicker';
7
+
8
+ class TimeRangePickerComponent {
9
+ constructor(cdr) {
10
+ this.cdr = cdr;
11
+ this.inputWidth = '100px';
12
+ this.height = '46px';
13
+ this.timezone = "Asia/Kolkata";
14
+ this.startDateEpoch = moment().tz(this.timezone).valueOf();
15
+ this.endDateEpoch = moment().tz(this.timezone).valueOf();
16
+ this.clockFormat = 12;
17
+ this.interval = 15;
18
+ this.timeRangeEmitter = new EventEmitter();
19
+ this.firstIntervalForStartPicker = moment().valueOf();
20
+ this.firstIntervalForEndPicker = moment().valueOf();
21
+ this.rangeValidity = true;
22
+ }
23
+ ngOnInit() {
24
+ console.log(this.timezone);
25
+ this.timeFormat = this.clockFormat === 12 ? "hh:mm a" : "HH:mm";
26
+ this.setFirstIntervals();
27
+ }
28
+ ngOnChanges() {
29
+ tz.setDefault(this.timezone);
30
+ }
31
+ // calculate the first interval of the picker
32
+ setFirstIntervals() {
33
+ const startDate = moment(this.startDateEpoch).format("DD-MM-YYYY");
34
+ const endDate = moment(this.endDateEpoch).format("DD-MM-YYYY");
35
+ const minutes = moment().minutes();
36
+ const offset = this.interval - (minutes % this.interval);
37
+ // first interval for the start picker will always be the one closest to the current time
38
+ this.firstIntervalForStartPicker = moment().add(offset, "m").valueOf();
39
+ this.startTime = {
40
+ valid: true,
41
+ time: moment().add(offset, "m").format(this.timeFormat)
42
+ };
43
+ // for the end picker if the startDate and the endDate is same
44
+ // the first interval is set one interval ahead of the first interval for start picker
45
+ // else if the dates are different we set it to the start of the day
46
+ if (startDate === endDate) {
47
+ this.firstIntervalForEndPicker = moment().add(offset, "m").add(this.interval, "m").valueOf();
48
+ }
49
+ else {
50
+ this.firstIntervalForEndPicker = moment().startOf("d").valueOf();
51
+ }
52
+ this.endTime = {
53
+ valid: true,
54
+ time: moment(this.firstIntervalForEndPicker).format(this.timeFormat)
55
+ };
56
+ }
57
+ emitTimeRange(data) {
58
+ this.timeRangeEmitter.emit(data);
59
+ }
60
+ //handlers catch the emitted values and run validation
61
+ startPickerHandler(time) {
62
+ this.startTime = time;
63
+ // if the start time changes and the start date is the same as the end date
64
+ // and the start time >= end time
65
+ // update the first interval of end picker according to the time set in start picker
66
+ const startDate = moment(this.startDateEpoch).format("DD-MM-YYYY");
67
+ const endDate = moment(this.endDateEpoch).format("DD-MM-YYYY");
68
+ if (startDate === endDate) {
69
+ let minutes = moment(this.startTime.time, this.timeFormat).minutes();
70
+ let offset = this.interval - (minutes % this.interval);
71
+ this.firstIntervalForEndPicker = moment(`${startDate} ${this.startTime.time}`, `'DD-MM-YYYY' ${this.timeFormat}`).add(offset, "m").valueOf();
72
+ }
73
+ }
74
+ endPickerHandler(time) {
75
+ this.endTime = time;
76
+ const validity = this.checkTimeValidity(this.startTime.time.trim()) && this.checkTimeValidity(this.endTime.time.trim());
77
+ this.emitTimeRange({
78
+ valid: validity && this.rangeValidity,
79
+ startTime: this.startTime.time,
80
+ endTime: this.endTime.time
81
+ });
82
+ this.rangeValidation();
83
+ }
84
+ checkTimeValidity(time) {
85
+ const RE12 = /^(([0-9][1-9]|1[0-2]):([0-5][0-9])( )?(am|pm|AM|PM))$/i;
86
+ const RE24 = /^([01][0-9]|2[0-3]):[0-5][0-9]$/;
87
+ const RE = this.clockFormat === 12 ? RE12 : RE24;
88
+ const flag = time.match(RE) ? true : false;
89
+ return flag;
90
+ }
91
+ // validates end picker's input according to the start picker's input
92
+ rangeValidation() {
93
+ const startDate = moment(this.startDateEpoch).format("DD-MM-YYYY");
94
+ const endDate = moment(this.endDateEpoch).format("DD-MM-YYYY");
95
+ const validity = this.checkTimeValidity(this.startTime.time.trim()) && this.checkTimeValidity(this.endTime.time.trim());
96
+ if (validity && startDate === endDate) {
97
+ if (this.endTime.time === moment().endOf("d").add(1, "m").format(this.timeFormat)) {
98
+ this.endTime.time = moment().endOf("d").format(this.timeFormat);
99
+ }
100
+ const startMoment = moment(this.startTime.time, this.timeFormat);
101
+ const endMoment = moment(this.endTime.time, this.timeFormat);
102
+ this.rangeValidity = endMoment.diff(startMoment, "m") >= 1 ? true : false;
103
+ this.cdr.detectChanges();
104
+ }
105
+ }
106
+ }
107
+ TimeRangePickerComponent.decorators = [
108
+ { type: Component, args: [{
109
+ selector: "mis-timerangepicker",
110
+ template: "<div class=\"rangepicker-container\">\n <mis-timepicker\n [clockFormat]=\"clockFormat\"\n [interval]=\"interval\"\n [dateAsEpoch]=\"startDateEpoch\"\n [firstInterval]=\"firstIntervalForStartPicker\"\n (timeEmitter)=\"startPickerHandler($event)\"\n [timezone]=\"timezone\"\n [height]=\"height\"\n [inputWidth]=\"'200px'\"\n [dropdownWidth]=\"dropdownWidth\"\n ></mis-timepicker>\n <mis-timepicker\n [clockFormat]=\"clockFormat\"\n [interval]=\"interval\"\n [dateAsEpoch]=\"endDateEpoch\"\n [firstInterval]=\"firstIntervalForEndPicker\"\n (timeEmitter)=\"endPickerHandler($event)\"\n [rangeValidity]=\"rangeValidity\"\n [timezone]=\"timezone\"\n [height]=\"height\"\n [inputWidth]=\"'200px'\"\n [dropdownWidth]=\"dropdownWidth\"\n ></mis-timepicker>\n</div>\n",
111
+ styles: [".rangepicker-container{display:flex;gap:1rem}"]
112
+ },] }
113
+ ];
114
+ TimeRangePickerComponent.ctorParameters = () => [
115
+ { type: ChangeDetectorRef }
116
+ ];
117
+ TimeRangePickerComponent.propDecorators = {
118
+ inputWidth: [{ type: Input }],
119
+ dropdownWidth: [{ type: Input }],
120
+ height: [{ type: Input }],
121
+ timezone: [{ type: Input }],
122
+ startDateEpoch: [{ type: Input }],
123
+ endDateEpoch: [{ type: Input }],
124
+ clockFormat: [{ type: Input }],
125
+ interval: [{ type: Input }],
126
+ timeRangeEmitter: [{ type: Output }]
127
+ };
128
+
129
+ class TimeRangePickerModule {
130
+ static forRoot() {
131
+ return { ngModule: TimeRangePickerModule, providers: [] };
132
+ }
133
+ }
134
+ TimeRangePickerModule.decorators = [
135
+ { type: NgModule, args: [{
136
+ declarations: [TimeRangePickerComponent],
137
+ imports: [CommonModule, FormsModule, TimePickerModule],
138
+ exports: [TimeRangePickerComponent]
139
+ },] }
140
+ ];
141
+
142
+ /**
143
+ * Generated bundle index. Do not edit.
144
+ */
145
+
146
+ export { TimeRangePickerComponent, TimeRangePickerModule };
147
+ //# sourceMappingURL=mis-crystal-design-system-timerangepicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mis-crystal-design-system-timerangepicker.js","sources":["../../../projects/mis-components/timerangepicker/timerangepicker.component.ts","../../../projects/mis-components/timerangepicker/timerangepicker.module.ts","../../../projects/mis-components/timerangepicker/mis-crystal-design-system-timerangepicker.ts"],"sourcesContent":["import { Component, Input, ChangeDetectorRef, Output, EventEmitter } from \"@angular/core\";\nimport * as moment from \"moment-timezone\";\nimport { ITimeRange, ITime } from \"./timerange.namespace\";\n\n@Component({\n selector: \"mis-timerangepicker\",\n templateUrl: \"./timerangepicker.component.html\",\n styleUrls: [\"./timerangepicker.component.scss\"]\n})\nexport class TimeRangePickerComponent {\n @Input() inputWidth :string = '100px';\n @Input() dropdownWidth?: string;\n @Input() height: string = '46px';\n @Input() timezone: string = \"Asia/Kolkata\";\n @Input() startDateEpoch: number = moment().tz(this.timezone).valueOf();\n @Input() endDateEpoch: number = moment().tz(this.timezone).valueOf();\n @Input() clockFormat: number = 12;\n @Input() interval: number = 15;\n @Output() timeRangeEmitter = new EventEmitter<ITimeRange>();\n\n timeFormat!: string;\n firstIntervalForStartPicker: number = moment().valueOf();\n firstIntervalForEndPicker: number = moment().valueOf();\n startTime!: ITime;\n endTime!: ITime;\n rangeValidity: boolean = true;\n\n constructor(private cdr: ChangeDetectorRef) {}\n\n ngOnInit() {\n console.log(this.timezone);\n this.timeFormat = this.clockFormat === 12 ? \"hh:mm a\" : \"HH:mm\";\n this.setFirstIntervals();\n }\n\n ngOnChanges(){\n moment.tz.setDefault(this.timezone);\n }\n\n // calculate the first interval of the picker\n setFirstIntervals(): void {\n const startDate = moment(this.startDateEpoch).format(\"DD-MM-YYYY\");\n const endDate = moment(this.endDateEpoch).format(\"DD-MM-YYYY\");\n const minutes = moment().minutes();\n const offset = this.interval - (minutes % this.interval);\n\n // first interval for the start picker will always be the one closest to the current time\n this.firstIntervalForStartPicker = moment().add(offset, \"m\").valueOf();\n this.startTime = {\n valid: true,\n time: moment().add(offset, \"m\").format(this.timeFormat)\n };\n\n // for the end picker if the startDate and the endDate is same\n // the first interval is set one interval ahead of the first interval for start picker\n // else if the dates are different we set it to the start of the day\n if (startDate === endDate) {\n this.firstIntervalForEndPicker = moment().add(offset, \"m\").add(this.interval, \"m\").valueOf();\n } else {\n this.firstIntervalForEndPicker = moment().startOf(\"d\").valueOf();\n }\n\n this.endTime = {\n valid: true,\n time: moment(this.firstIntervalForEndPicker).format(this.timeFormat)\n }\n }\n\n emitTimeRange(data: ITimeRange): void {\n this.timeRangeEmitter.emit(data);\n }\n\n //handlers catch the emitted values and run validation\n startPickerHandler(time: ITime): void {\n this.startTime = time;\n\n // if the start time changes and the start date is the same as the end date\n // and the start time >= end time\n // update the first interval of end picker according to the time set in start picker\n const startDate = moment(this.startDateEpoch).format(\"DD-MM-YYYY\");\n const endDate = moment(this.endDateEpoch).format(\"DD-MM-YYYY\");\n\n if (startDate === endDate) {\n let minutes = moment(this.startTime.time, this.timeFormat).minutes();\n let offset = this.interval - (minutes % this.interval);\n this.firstIntervalForEndPicker = moment(`${startDate} ${this.startTime.time}`, `'DD-MM-YYYY' ${this.timeFormat}`).add(offset, \"m\").valueOf();\n }\n }\n\n endPickerHandler(time: ITime): void {\n this.endTime = time;\n\n const validity = this.checkTimeValidity(this.startTime.time.trim()) && this.checkTimeValidity(this.endTime.time.trim());\n this.emitTimeRange({\n valid: validity && this.rangeValidity,\n startTime: this.startTime.time,\n endTime: this.endTime.time\n });\n\n this.rangeValidation();\n }\n\n checkTimeValidity(time: string): boolean {\n const RE12 = /^(([0-9][1-9]|1[0-2]):([0-5][0-9])( )?(am|pm|AM|PM))$/i;\n const RE24 = /^([01][0-9]|2[0-3]):[0-5][0-9]$/;\n const RE = this.clockFormat === 12 ? RE12 : RE24;\n const flag = time.match(RE) ? true : false;\n return flag;\n }\n\n // validates end picker's input according to the start picker's input\n rangeValidation() {\n const startDate = moment(this.startDateEpoch).format(\"DD-MM-YYYY\");\n const endDate = moment(this.endDateEpoch).format(\"DD-MM-YYYY\");\n const validity = this.checkTimeValidity(this.startTime.time.trim()) && this.checkTimeValidity(this.endTime.time.trim());\n if (validity && startDate === endDate) {\n if (this.endTime.time === moment().endOf(\"d\").add(1, \"m\").format(this.timeFormat)) {\n this.endTime.time = moment().endOf(\"d\").format(this.timeFormat);\n }\n\n const startMoment = moment(this.startTime.time, this.timeFormat);\n const endMoment = moment(this.endTime.time, this.timeFormat);\n this.rangeValidity = endMoment.diff(startMoment, \"m\") >= 1 ? true : false;\n this.cdr.detectChanges();\n }\n }\n}\n","import { NgModule, ModuleWithProviders } from \"@angular/core\";\nimport { CommonModule } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { TimeRangePickerComponent } from \"./timerangepicker.component\";\nimport { TimePickerModule } from \"mis-crystal-design-system/timepicker\";\n\n@NgModule({\n declarations: [TimeRangePickerComponent],\n imports: [CommonModule, FormsModule, TimePickerModule],\n exports: [TimeRangePickerComponent]\n})\nexport class TimeRangePickerModule {\n static forRoot(): ModuleWithProviders<TimeRangePickerModule> {\n return { ngModule: TimeR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C,aAAa,EAAE,CAAC;SAC1B;KACF;;;YAzHF,SAAS,SAAC;gBACT,QAAQ,EAAE,qBAAqB;gBAC/B,8zBAA+C;;aAEhD;;;YAR0B,iBAAiB;;;yBAUzC,KAAK;4BACL,KAAK;qBACL,KAAK;uBACL,KAAK;6BACL,KAAK;2BACL,KAAK;0BACL,KAAK;uBACL,KAAK;+BACL,MAAM;;;MCPI,qBAAqB;IAChC,OAAO,OAAO;QACZ,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;KAC3D;;;YARF,QAAQ,SAAC;gBACR,YAAY,EAAE,CAAC,wBAAwB,CAAC;gBACxC,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,gBAAgB,CAAC;gBACtD,OAAO,EAAE,CAAC,wBAAwB,CAAC;aACpC;;;ACVD;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mis-crystal-design-system",
3
- "version": "2.9.9",
3
+ "version": "3.0.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "*",
6
6
  "@angular/core": "*",
@@ -0,0 +1 @@
1
+ export * from "./public_api";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';
5
+ export { TimepickerDirective as ɵa } from './timepicker.directive';
@@ -0,0 +1 @@
1
+ {"__symbolic":"module","version":4,"metadata":{"TimePickerComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":5,"character":1},"arguments":[{"selector":"mis-timepicker","template":"<div class=\"timepicker-container\" [ngStyle]=\"{ height: height }\">\n <input\n type=\"text\"\n [(ngModel)]=\"chosenTime\"\n (ngModelChange)=\"onTimeChange(chosenTime)\"\n [ngClass]=\"{ invalid: isInvalid || !rangeValidity }\"\n [ngStyle]=\"{ width: inputWidth }\"\n (click)=\"openDropdown()\"\n misToolTip\n [showToolTip]=\"isInvalid || !rangeValidity\"\n [text]=\"'Invalid Time'\"\n [position]=\"'top'\"\n [showOnHover]=\"false\"\n #input\n cdkOverlayOrigin\n class=\"p\"\n />\n\n <ng-template #dropdownContainer libDropdownScroll libTimepicker [originEl]=\"input\" [openStatus]=\"openStatus\" (statusEmitter)=\"closeDropdown($event)\">\n <div *ngIf=\"openStatus\" class=\"timepicker-dropdown\" [ngStyle]=\"{ width: dropdownWidth || inputWidth }\">\n <ul #dropdown>\n <li #timeInterval (click)=\"onTimeSelect(interval)\" *ngFor=\"let interval of timeIntervals; index as i\" [ngClass]=\"{ highlight: i === isHighlighted }\">\n {{ interval }}\n <div class=\"ic-ui-check-24 selected-icon\" *ngIf=\"interval === chosenTime\"></div>\n </li>\n </ul>\n </div>\n </ng-template>\n</div>\n","styles":[".h1{font-size:40px;line-height:48px}.h1,.h2{font-weight:400;letter-spacing:0}.h2{font-size:32px;line-height:40px}.h3{font-size:28px;line-height:36px}.h3,.h4{font-weight:400;letter-spacing:0}.h4{font-size:24px;line-height:32px}.h5-b{font-weight:700;letter-spacing:.25px}.h5,.h5-b{font-size:20px;line-height:28px}.h5{font-weight:400;letter-spacing:.15px}.h6-b{font-weight:700}.h6,.h6-b{font-size:16px;letter-spacing:0;line-height:24px}.h6,.p{font-weight:400}.p{font-size:16px;letter-spacing:0;line-height:180%}.h7-b{font-weight:700;letter-spacing:.25px}.h7,.h7-b{font-size:14px;line-height:20px}.h7{font-weight:400;letter-spacing:.2px}.h8-b{font-weight:700;letter-spacing:.25px}.h8,.h8-b{font-size:12px;line-height:18px}.h8{letter-spacing:.2px}.h8,.h9{font-weight:400}.h9{font-size:10px;letter-spacing:0;line-height:15px}.btn-lg-b{font-weight:700;letter-spacing:.5px}.btn-lg,.btn-lg-b{font-size:16px;line-height:24px}.btn-lg{font-weight:400;letter-spacing:.2px}.btn-sm{font-size:14px;font-weight:400;letter-spacing:.25px;line-height:20px}.btn-link{font-size:16px;line-height:24px}.btn-link,.display-1{font-weight:400;letter-spacing:0}.display-1{font-size:48px;line-height:56px}.display-2{font-size:14px;font-weight:400;letter-spacing:.5px;line-height:20px}*{box-sizing:border-box;font-family:Lato}.timepicker-container{display:inline-block;position:relative}input{text-align:center;border:none;border-bottom:1px solid #e0e0e0;outline:none;height:100%;width:100px;padding:4px 16px}input:hover{background:#f5f7fc}input:active,input:focus{background:#e6ebf7;border-bottom:1px solid #0937b2}.timepicker-dropdown{position:absolute;top:calc(100% + 4px);left:0;max-height:200px;overflow-y:auto;border:1px solid #e0e0e0;box-shadow:0 12px 24px rgba(0,0,0,.12),0 4px 8px rgba(0,0,0,.12);border-radius:4px;padding:8px;background:#fff}.timepicker-dropdown::-webkit-scrollbar{display:none}.timepicker-dropdown ul{margin:0;padding:0}.timepicker-dropdown li{text-align:start;list-style:none;padding:6px 12px;cursor:pointer;font-size:16px;color:#181f33;display:flex;justify-content:space-between;align-items:center}.timepicker-dropdown li:hover{background:#f5f7fc;border-radius:6px}.timepicker-dropdown li .selected-icon{font-weight:900}.highlight{background-color:#f5f7fc;border-radius:6px}.invalid{background:#fae1ea!important;border-bottom:1px solid #b00020!important}"]}]}],"members":{"clockFormat":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":20,"character":3}}]}],"timezone":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":23,"character":3}}]}],"height":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":24,"character":3}}]}],"inputWidth":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":25,"character":3}}]}],"dropdownWidth":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":26,"character":3}}]}],"interval":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":27,"character":3}}]}],"dateAsEpoch":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":28,"character":3}}]}],"firstInterval":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":29,"character":3}}]}],"rangeValidity":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":30,"character":3}}]}],"timeEmitter":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":32,"character":3}}]}],"input":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":33,"character":3},"arguments":["input",{"static":true}]}]}],"timepickerDirective":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":34,"character":3},"arguments":[{"__symbolic":"reference","name":"ɵa"}]}]}],"timeIntervalRefs":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChildren","line":37,"character":3},"arguments":["timeInterval"]}]}],"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"emitTime":[{"__symbolic":"method"}],"closeDropdown":[{"__symbolic":"method"}],"openDropdown":[{"__symbolic":"method"}],"checkTimeValidity":[{"__symbolic":"method"}],"onTimeSelect":[{"__symbolic":"method"}],"onTimeChange":[{"__symbolic":"method"}],"calculateClosestInterval":[{"__symbolic":"method"}],"populateDropdown":[{"__symbolic":"method"}]}},"TimePickerModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":8,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"TimePickerComponent"},{"__symbolic":"reference","name":"ɵa"}],"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":10,"character":12},{"__symbolic":"reference","module":"@angular/forms","name":"FormsModule","line":10,"character":26},{"__symbolic":"reference","module":"mis-crystal-design-system/tooltip","name":"ToolTipModule","line":10,"character":39},{"__symbolic":"reference","module":"@angular/cdk/overlay","name":"OverlayModule","line":10,"character":54}],"exports":[{"__symbolic":"reference","name":"TimePickerComponent"}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":[],"value":{"ngModule":{"__symbolic":"reference","name":"TimePickerModule"},"providers":[]}}}},"ɵa":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":5,"character":1},"arguments":[{"selector":"[libTimepicker]"}]}],"members":{"originEl":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":10,"character":3},"arguments":["originEl"]}]}],"statusEmitter":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":11,"character":3}}]}],"createOverlayOnInput":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":13,"character":3},"arguments":["openStatus"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"TemplateRef","module":"@angular/core","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":18,"character":47,"context":{"typeName":"Element"},"module":"./timepicker.directive"}]},{"__symbolic":"reference","module":"@angular/cdk/overlay","name":"Overlay","line":18,"character":74},{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef","line":18,"character":109}]}],"createOverlay":[{"__symbolic":"method"}],"destroyOverlay":[{"__symbolic":"method"}]}}},"origins":{"TimePickerComponent":"./timepicker.component","TimePickerModule":"./timepicker.module","ɵa":"./timepicker.directive"},"importAs":"mis-crystal-design-system/timepicker"}
@@ -0,0 +1,11 @@
1
+ {
2
+ "main": "../bundles/mis-crystal-design-system-timepicker.umd.js",
3
+ "module": "../fesm2015/mis-crystal-design-system-timepicker.js",
4
+ "es2015": "../fesm2015/mis-crystal-design-system-timepicker.js",
5
+ "esm2015": "../esm2015/timepicker/mis-crystal-design-system-timepicker.js",
6
+ "fesm2015": "../fesm2015/mis-crystal-design-system-timepicker.js",
7
+ "typings": "mis-crystal-design-system-timepicker.d.ts",
8
+ "metadata": "mis-crystal-design-system-timepicker.metadata.json",
9
+ "sideEffects": false,
10
+ "name": "mis-crystal-design-system/timepicker"
11
+ }
@@ -0,0 +1,2 @@
1
+ export { TimePickerComponent } from "./timepicker.component";
2
+ export { TimePickerModule } from "./timepicker.module";
@@ -0,0 +1,4 @@
1
+ export interface ITime {
2
+ valid: boolean;
3
+ time: string;
4
+ }
@@ -0,0 +1,38 @@
1
+ import { ElementRef, EventEmitter } from "@angular/core";
2
+ import { ITime } from "./time.namespace";
3
+ import { TimepickerDirective } from "./timepicker.directive";
4
+ export declare class TimePickerComponent {
5
+ currTime: string;
6
+ chosenTime: string;
7
+ openStatus: boolean;
8
+ isHighlighted: number;
9
+ isInvalid: boolean;
10
+ timeIntervals: string[];
11
+ shouldScroll: boolean;
12
+ userInputFlag: boolean;
13
+ clockFormat: number;
14
+ timeFormat: string;
15
+ timezone: string;
16
+ height: string;
17
+ inputWidth: string;
18
+ dropdownWidth?: string;
19
+ interval: number;
20
+ dateAsEpoch: number;
21
+ firstInterval: number;
22
+ rangeValidity: boolean;
23
+ timeEmitter: EventEmitter<ITime>;
24
+ input: ElementRef;
25
+ timepickerDirective: TimepickerDirective;
26
+ set timeIntervalRefs(intervals: any);
27
+ constructor();
28
+ ngOnInit(): void;
29
+ ngOnChanges(): void;
30
+ emitTime(data: ITime): void;
31
+ closeDropdown(val: boolean): void;
32
+ openDropdown(): void;
33
+ checkTimeValidity(time: string): boolean;
34
+ onTimeSelect(time: string): void;
35
+ onTimeChange(time: string): void;
36
+ calculateClosestInterval(time: string): void;
37
+ populateDropdown(): void;
38
+ }
@@ -0,0 +1,16 @@
1
+ import { TemplateRef } from '@angular/core';
2
+ import { EventEmitter, ViewContainerRef } from "@angular/core";
3
+ import { Overlay } from "@angular/cdk/overlay";
4
+ export declare class TimepickerDirective {
5
+ private templateRef;
6
+ private overlay;
7
+ private viewContainerRef;
8
+ private openStatus;
9
+ originEl: any;
10
+ statusEmitter: EventEmitter<boolean>;
11
+ set createOverlayOnInput(openStatus: any);
12
+ private overlayRef;
13
+ constructor(templateRef: TemplateRef<Element>, overlay: Overlay, viewContainerRef: ViewContainerRef);
14
+ createOverlay(origin: any): void;
15
+ destroyOverlay(): void;
16
+ }
@@ -0,0 +1,4 @@
1
+ import { ModuleWithProviders } from "@angular/core";
2
+ export declare class TimePickerModule {
3
+ static forRoot(): ModuleWithProviders<TimePickerModule>;
4
+ }
@@ -0,0 +1 @@
1
+ export * from "./public_api";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';