mis-crystal-design-system 2.9.9 → 3.0.1

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 +643 -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 +211 -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 +202 -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 +157 -0
  21. package/esm2015/timerangepicker/timerangepicker.module.js +18 -0
  22. package/fesm2015/mis-crystal-design-system-timepicker.js +285 -0
  23. package/fesm2015/mis-crystal-design-system-timepicker.js.map +1 -0
  24. package/fesm2015/mis-crystal-design-system-timerangepicker.js +181 -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 +5 -0
  33. package/timepicker/timepicker.component.d.ts +40 -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 +12 -0
  42. package/timerangepicker/timerangepicker.component.d.ts +32 -0
  43. package/timerangepicker/timerangepicker.module.d.ts +4 -0
@@ -0,0 +1,643 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('moment-timezone'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/common'), require('@angular/forms'), require('mis-crystal-design-system/tooltip')) :
3
+ typeof define === 'function' && define.amd ? define('mis-crystal-design-system/timepicker', ['exports', '@angular/core', 'moment-timezone', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/common', '@angular/forms', 'mis-crystal-design-system/tooltip'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['mis-crystal-design-system'] = global['mis-crystal-design-system'] || {}, global['mis-crystal-design-system'].timepicker = {}), global.ng.core, global.moment, global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.common, global.ng.forms, global['mis-crystal-design-system'].tooltip));
5
+ }(this, (function (exports, core, moment, overlay, portal, common, forms, tooltip) { 'use strict';
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () {
17
+ return e[k];
18
+ }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n['default'] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
28
+
29
+ /*! *****************************************************************************
30
+ Copyright (c) Microsoft Corporation.
31
+
32
+ Permission to use, copy, modify, and/or distribute this software for any
33
+ purpose with or without fee is hereby granted.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
37
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41
+ PERFORMANCE OF THIS SOFTWARE.
42
+ ***************************************************************************** */
43
+ /* global Reflect, Promise */
44
+ var extendStatics = function (d, b) {
45
+ extendStatics = Object.setPrototypeOf ||
46
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
47
+ function (d, b) { for (var p in b)
48
+ if (Object.prototype.hasOwnProperty.call(b, p))
49
+ d[p] = b[p]; };
50
+ return extendStatics(d, b);
51
+ };
52
+ function __extends(d, b) {
53
+ if (typeof b !== "function" && b !== null)
54
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
55
+ extendStatics(d, b);
56
+ function __() { this.constructor = d; }
57
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
58
+ }
59
+ var __assign = function () {
60
+ __assign = Object.assign || function __assign(t) {
61
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
62
+ s = arguments[i];
63
+ for (var p in s)
64
+ if (Object.prototype.hasOwnProperty.call(s, p))
65
+ t[p] = s[p];
66
+ }
67
+ return t;
68
+ };
69
+ return __assign.apply(this, arguments);
70
+ };
71
+ function __rest(s, e) {
72
+ var t = {};
73
+ for (var p in s)
74
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
+ t[p] = s[p];
76
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
+ t[p[i]] = s[p[i]];
80
+ }
81
+ return t;
82
+ }
83
+ function __decorate(decorators, target, key, desc) {
84
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
85
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
86
+ r = Reflect.decorate(decorators, target, key, desc);
87
+ else
88
+ for (var i = decorators.length - 1; i >= 0; i--)
89
+ if (d = decorators[i])
90
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
91
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
92
+ }
93
+ function __param(paramIndex, decorator) {
94
+ return function (target, key) { decorator(target, key, paramIndex); };
95
+ }
96
+ function __metadata(metadataKey, metadataValue) {
97
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
98
+ return Reflect.metadata(metadataKey, metadataValue);
99
+ }
100
+ function __awaiter(thisArg, _arguments, P, generator) {
101
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
102
+ return new (P || (P = Promise))(function (resolve, reject) {
103
+ function fulfilled(value) { try {
104
+ step(generator.next(value));
105
+ }
106
+ catch (e) {
107
+ reject(e);
108
+ } }
109
+ function rejected(value) { try {
110
+ step(generator["throw"](value));
111
+ }
112
+ catch (e) {
113
+ reject(e);
114
+ } }
115
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
116
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
117
+ });
118
+ }
119
+ function __generator(thisArg, body) {
120
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
121
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
122
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
123
+ function verb(n) { return function (v) { return step([n, v]); }; }
124
+ function step(op) {
125
+ if (f)
126
+ throw new TypeError("Generator is already executing.");
127
+ while (_)
128
+ try {
129
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
130
+ return t;
131
+ if (y = 0, t)
132
+ op = [op[0] & 2, t.value];
133
+ switch (op[0]) {
134
+ case 0:
135
+ case 1:
136
+ t = op;
137
+ break;
138
+ case 4:
139
+ _.label++;
140
+ return { value: op[1], done: false };
141
+ case 5:
142
+ _.label++;
143
+ y = op[1];
144
+ op = [0];
145
+ continue;
146
+ case 7:
147
+ op = _.ops.pop();
148
+ _.trys.pop();
149
+ continue;
150
+ default:
151
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
+ _ = 0;
153
+ continue;
154
+ }
155
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
156
+ _.label = op[1];
157
+ break;
158
+ }
159
+ if (op[0] === 6 && _.label < t[1]) {
160
+ _.label = t[1];
161
+ t = op;
162
+ break;
163
+ }
164
+ if (t && _.label < t[2]) {
165
+ _.label = t[2];
166
+ _.ops.push(op);
167
+ break;
168
+ }
169
+ if (t[2])
170
+ _.ops.pop();
171
+ _.trys.pop();
172
+ continue;
173
+ }
174
+ op = body.call(thisArg, _);
175
+ }
176
+ catch (e) {
177
+ op = [6, e];
178
+ y = 0;
179
+ }
180
+ finally {
181
+ f = t = 0;
182
+ }
183
+ if (op[0] & 5)
184
+ throw op[1];
185
+ return { value: op[0] ? op[1] : void 0, done: true };
186
+ }
187
+ }
188
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
189
+ if (k2 === undefined)
190
+ k2 = k;
191
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
192
+ }) : (function (o, m, k, k2) {
193
+ if (k2 === undefined)
194
+ k2 = k;
195
+ o[k2] = m[k];
196
+ });
197
+ function __exportStar(m, o) {
198
+ for (var p in m)
199
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
200
+ __createBinding(o, m, p);
201
+ }
202
+ function __values(o) {
203
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
204
+ if (m)
205
+ return m.call(o);
206
+ if (o && typeof o.length === "number")
207
+ return {
208
+ next: function () {
209
+ if (o && i >= o.length)
210
+ o = void 0;
211
+ return { value: o && o[i++], done: !o };
212
+ }
213
+ };
214
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
215
+ }
216
+ function __read(o, n) {
217
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
218
+ if (!m)
219
+ return o;
220
+ var i = m.call(o), r, ar = [], e;
221
+ try {
222
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
223
+ ar.push(r.value);
224
+ }
225
+ catch (error) {
226
+ e = { error: error };
227
+ }
228
+ finally {
229
+ try {
230
+ if (r && !r.done && (m = i["return"]))
231
+ m.call(i);
232
+ }
233
+ finally {
234
+ if (e)
235
+ throw e.error;
236
+ }
237
+ }
238
+ return ar;
239
+ }
240
+ /** @deprecated */
241
+ function __spread() {
242
+ for (var ar = [], i = 0; i < arguments.length; i++)
243
+ ar = ar.concat(__read(arguments[i]));
244
+ return ar;
245
+ }
246
+ /** @deprecated */
247
+ function __spreadArrays() {
248
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
249
+ s += arguments[i].length;
250
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
251
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
252
+ r[k] = a[j];
253
+ return r;
254
+ }
255
+ function __spreadArray(to, from, pack) {
256
+ if (pack || arguments.length === 2)
257
+ for (var i = 0, l = from.length, ar; i < l; i++) {
258
+ if (ar || !(i in from)) {
259
+ if (!ar)
260
+ ar = Array.prototype.slice.call(from, 0, i);
261
+ ar[i] = from[i];
262
+ }
263
+ }
264
+ return to.concat(ar || Array.prototype.slice.call(from));
265
+ }
266
+ function __await(v) {
267
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
268
+ }
269
+ function __asyncGenerator(thisArg, _arguments, generator) {
270
+ if (!Symbol.asyncIterator)
271
+ throw new TypeError("Symbol.asyncIterator is not defined.");
272
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
273
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
274
+ function verb(n) { if (g[n])
275
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
276
+ function resume(n, v) { try {
277
+ step(g[n](v));
278
+ }
279
+ catch (e) {
280
+ settle(q[0][3], e);
281
+ } }
282
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
283
+ function fulfill(value) { resume("next", value); }
284
+ function reject(value) { resume("throw", value); }
285
+ function settle(f, v) { if (f(v), q.shift(), q.length)
286
+ resume(q[0][0], q[0][1]); }
287
+ }
288
+ function __asyncDelegator(o) {
289
+ var i, p;
290
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
291
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
292
+ }
293
+ function __asyncValues(o) {
294
+ if (!Symbol.asyncIterator)
295
+ throw new TypeError("Symbol.asyncIterator is not defined.");
296
+ var m = o[Symbol.asyncIterator], i;
297
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
298
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
299
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
300
+ }
301
+ function __makeTemplateObject(cooked, raw) {
302
+ if (Object.defineProperty) {
303
+ Object.defineProperty(cooked, "raw", { value: raw });
304
+ }
305
+ else {
306
+ cooked.raw = raw;
307
+ }
308
+ return cooked;
309
+ }
310
+ ;
311
+ var __setModuleDefault = Object.create ? (function (o, v) {
312
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
313
+ }) : function (o, v) {
314
+ o["default"] = v;
315
+ };
316
+ function __importStar(mod) {
317
+ if (mod && mod.__esModule)
318
+ return mod;
319
+ var result = {};
320
+ if (mod != null)
321
+ for (var k in mod)
322
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
323
+ __createBinding(result, mod, k);
324
+ __setModuleDefault(result, mod);
325
+ return result;
326
+ }
327
+ function __importDefault(mod) {
328
+ return (mod && mod.__esModule) ? mod : { default: mod };
329
+ }
330
+ function __classPrivateFieldGet(receiver, state, kind, f) {
331
+ if (kind === "a" && !f)
332
+ throw new TypeError("Private accessor was defined without a getter");
333
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
334
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
335
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
336
+ }
337
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
338
+ if (kind === "m")
339
+ throw new TypeError("Private method is not writable");
340
+ if (kind === "a" && !f)
341
+ throw new TypeError("Private accessor was defined without a setter");
342
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
343
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
344
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
345
+ }
346
+
347
+ var TimepickerDirective = /** @class */ (function () {
348
+ function TimepickerDirective(templateRef, overlay, viewContainerRef) {
349
+ this.templateRef = templateRef;
350
+ this.overlay = overlay;
351
+ this.viewContainerRef = viewContainerRef;
352
+ this.openStatus = false;
353
+ this.statusEmitter = new core.EventEmitter();
354
+ }
355
+ Object.defineProperty(TimepickerDirective.prototype, "createOverlayOnInput", {
356
+ set: function (openStatus) {
357
+ this.openStatus = openStatus;
358
+ if (this.originEl && this.openStatus)
359
+ this.createOverlay(this.originEl);
360
+ },
361
+ enumerable: false,
362
+ configurable: true
363
+ });
364
+ ;
365
+ TimepickerDirective.prototype.createOverlay = function (origin) {
366
+ var _this = this;
367
+ var positions = [
368
+ new overlay.ConnectionPositionPair({ originX: "start", originY: "bottom" }, { overlayX: "start", overlayY: "top" }, 0, 4),
369
+ new overlay.ConnectionPositionPair({ originX: "end", originY: "bottom" }, { overlayX: "end", overlayY: "top" }, 0, 4)
370
+ ];
371
+ var overlayConfig = new overlay.OverlayConfig({
372
+ hasBackdrop: true,
373
+ backdropClass: "cdk-overlay-transparent-backdrop",
374
+ positionStrategy: this.overlay
375
+ .position()
376
+ //connecting the dropdown overlay to the input element
377
+ .flexibleConnectedTo(origin)
378
+ .withPositions(__spread(positions))
379
+ .withPush(true)
380
+ });
381
+ this.overlayRef = this.overlay.create(overlayConfig);
382
+ var dropdownPortal = new portal.TemplatePortal(this.templateRef, this.viewContainerRef);
383
+ this.overlayRef.attach(dropdownPortal);
384
+ this.overlayRef.backdropClick().subscribe(function (resp) {
385
+ _this.openStatus = false;
386
+ _this.statusEmitter.emit(false);
387
+ _this.overlayRef.detach();
388
+ });
389
+ };
390
+ TimepickerDirective.prototype.destroyOverlay = function () {
391
+ this.overlayRef.detach();
392
+ };
393
+ return TimepickerDirective;
394
+ }());
395
+ TimepickerDirective.decorators = [
396
+ { type: core.Directive, args: [{
397
+ selector: '[libTimepicker]'
398
+ },] }
399
+ ];
400
+ TimepickerDirective.ctorParameters = function () { return [
401
+ { type: core.TemplateRef },
402
+ { type: overlay.Overlay },
403
+ { type: core.ViewContainerRef }
404
+ ]; };
405
+ TimepickerDirective.propDecorators = {
406
+ originEl: [{ type: core.Input, args: ['originEl',] }],
407
+ statusEmitter: [{ type: core.Output }],
408
+ createOverlayOnInput: [{ type: core.Input, args: ['openStatus',] }]
409
+ };
410
+
411
+ var TimePickerComponent = /** @class */ (function () {
412
+ function TimePickerComponent() {
413
+ this.openStatus = false;
414
+ this.isHighlighted = 0;
415
+ this.isInvalid = false;
416
+ this.timeIntervals = [];
417
+ this.shouldScroll = false;
418
+ this.userInputFlag = false;
419
+ this.clockFormat = 12;
420
+ this.timezone = "Asia/Kolkata";
421
+ this.height = "max-content";
422
+ this.inputWidth = "100px";
423
+ this.interval = 15;
424
+ this.dateAsEpoch = moment__namespace().valueOf();
425
+ this.rangeValidity = true;
426
+ this.timeEmitter = new core.EventEmitter();
427
+ }
428
+ Object.defineProperty(TimePickerComponent.prototype, "timeIntervalRefs", {
429
+ // gets all the li elements from the dropdown and scrolls to the highlighted element
430
+ set: function (intervals) {
431
+ intervals.forEach(function (interval) {
432
+ if (interval.nativeElement.classList[0] === "highlight") {
433
+ var highlighted_1 = interval.nativeElement;
434
+ setTimeout(function () { return highlighted_1.scrollIntoView({ behavior: "smooth", block: "center" }); });
435
+ }
436
+ });
437
+ },
438
+ enumerable: false,
439
+ configurable: true
440
+ });
441
+ TimePickerComponent.prototype.ngOnInit = function () {
442
+ this.timeFormat = this.clockFormat === 12 ? "hh:mm a" : "HH:mm";
443
+ this.populateDropdown();
444
+ this.chosenTime = this.timeIntervals[0];
445
+ this.calculateClosestInterval(this.chosenTime);
446
+ var chosenTimeMoment = this.getMoment(this.chosenTime);
447
+ this.emitTime({
448
+ valid: !this.isInvalid,
449
+ time: this.chosenTime,
450
+ epoch: chosenTimeMoment.valueOf()
451
+ });
452
+ };
453
+ TimePickerComponent.prototype.ngOnChanges = function () {
454
+ moment.tz.setDefault(this.timezone);
455
+ this.currTime = moment__namespace().format();
456
+ if (this.timeFormat) {
457
+ // if the first interval is >= the chosen time
458
+ // then only update the value of chosen time
459
+ // else it remains the same
460
+ var chosenTimeMoment = this.getMoment(this.chosenTime);
461
+ if (this.firstInterval >= chosenTimeMoment.valueOf() && this.rangeValidity && !this.userInputFlag) {
462
+ this.chosenTime = moment__namespace(this.firstInterval).format(this.timeFormat);
463
+ }
464
+ if (!this.userInputFlag)
465
+ this.populateDropdown();
466
+ this.userInputFlag = false;
467
+ this.isInvalid = !this.checkTimeValidity(this.chosenTime.trim());
468
+ this.emitTime({
469
+ valid: !this.isInvalid,
470
+ time: this.chosenTime,
471
+ epoch: chosenTimeMoment.valueOf()
472
+ });
473
+ this.calculateClosestInterval(this.chosenTime);
474
+ }
475
+ };
476
+ TimePickerComponent.prototype.emitTime = function (data) {
477
+ this.timeEmitter.emit(data);
478
+ };
479
+ // function to get moment object when time is given in string
480
+ TimePickerComponent.prototype.getMoment = function (time) {
481
+ return moment__namespace(moment__namespace(this.dateAsEpoch).format("DD-MM-YYYY") + " " + time, "'DD-MM-YYYY' " + this.timeFormat);
482
+ };
483
+ // gets a boolean from overlay event to close the dropdown
484
+ TimePickerComponent.prototype.closeDropdown = function (val) {
485
+ this.openStatus = val;
486
+ };
487
+ // toggle timepicker dropdown
488
+ TimePickerComponent.prototype.openDropdown = function () {
489
+ this.openStatus = true;
490
+ };
491
+ TimePickerComponent.prototype.checkTimeValidity = function (time) {
492
+ var RE12 = /^(([0][1-9]|1[0-2]):([0-5][0-9])( )?(am|pm|AM|PM))$/i;
493
+ var RE24 = /^([01][0-9]|2[0-3]):[0-5][0-9]$/;
494
+ var RE = this.clockFormat === 12 ? RE12 : RE24;
495
+ var timeMoment = this.getMoment(time);
496
+ var flag = false;
497
+ // if the first interval is set to the start of the day
498
+ // then we don't check its validity against the current time
499
+ if (this.firstInterval &&
500
+ moment__namespace(this.firstInterval).format(this.timeFormat).valueOf() === moment__namespace().startOf("d").format(this.timeFormat).valueOf()) {
501
+ flag = time.match(RE) ? true : false;
502
+ }
503
+ else {
504
+ flag = time.match(RE) && timeMoment.isAfter(moment__namespace()) ? true : false;
505
+ }
506
+ return flag;
507
+ };
508
+ // update chosen time as soon as the user clicks on an interval
509
+ TimePickerComponent.prototype.onTimeSelect = function (time) {
510
+ this.isInvalid = !this.checkTimeValidity(time.trim());
511
+ if (!this.isInvalid) {
512
+ this.chosenTime = time;
513
+ this.calculateClosestInterval(this.chosenTime);
514
+ }
515
+ var timeMoment = this.getMoment(time);
516
+ this.emitTime({
517
+ valid: !this.isInvalid,
518
+ time: time,
519
+ epoch: timeMoment.valueOf()
520
+ });
521
+ this.openStatus = false;
522
+ if (this.timepickerDirective)
523
+ this.timepickerDirective.destroyOverlay();
524
+ };
525
+ // checks validity of time on input change and calculates the closest interval
526
+ TimePickerComponent.prototype.onTimeChange = function (time) {
527
+ this.isInvalid = !this.checkTimeValidity(time.trim());
528
+ if (!this.isInvalid) {
529
+ this.userInputFlag = true;
530
+ this.calculateClosestInterval(time);
531
+ }
532
+ var timeMoment = this.getMoment(time);
533
+ this.emitTime({
534
+ valid: !this.isInvalid,
535
+ time: time,
536
+ epoch: timeMoment.valueOf()
537
+ });
538
+ };
539
+ TimePickerComponent.prototype.calculateClosestInterval = function (time) {
540
+ var _this = this;
541
+ var intervalMS = this.interval * 60 * 1000;
542
+ var chosenDate = moment__namespace(this.dateAsEpoch).format("DD-MM-YYYY");
543
+ // converting time passed as parameter to moment object and adding date
544
+ var parsedTimeWithDate = moment__namespace(chosenDate + " " + time, "DD-MM-YYYY " + this.timeFormat);
545
+ // converting moment object to epoch so that calculations for rounding off are easier to do
546
+ var currEpoch = parsedTimeWithDate.valueOf();
547
+ var offset = currEpoch % intervalMS;
548
+ var roundedEpoch = offset >= intervalMS / 2 ? currEpoch + (intervalMS - offset) : currEpoch - offset;
549
+ // finding the index of element that needs to be highlighted
550
+ this.timeIntervals.forEach(function (interval, index, array) {
551
+ var intervalObj = moment__namespace(chosenDate + " " + interval, "DD-MM-YYYY " + _this.timeFormat);
552
+ if (intervalObj.valueOf() === roundedEpoch)
553
+ _this.isHighlighted = index;
554
+ if (array.length === 1)
555
+ _this.isHighlighted = 0;
556
+ });
557
+ };
558
+ // populates the dropdown according to the first interval received
559
+ TimePickerComponent.prototype.populateDropdown = function () {
560
+ this.timeIntervals = [];
561
+ // if picker is used as an individual component
562
+ if (!this.firstInterval) {
563
+ // firstInterval is initialised according to the current time
564
+ // if the date is same as the current date
565
+ if (moment__namespace(this.dateAsEpoch).format("DD-MM-YYYY") === moment__namespace().format("DD-MM-YYYY")) {
566
+ var offset = this.interval - (moment__namespace().minutes() % this.interval);
567
+ this.firstInterval = moment__namespace().add(offset, "m").valueOf();
568
+ }
569
+ // else the firstInterval is initialised as start of day
570
+ else {
571
+ this.firstInterval = moment__namespace().startOf("d").valueOf();
572
+ }
573
+ }
574
+ var dateAsString = moment__namespace(this.dateAsEpoch).format('DD-MM-YYYY');
575
+ var intervalAsString = moment__namespace(this.firstInterval).format(this.timeFormat);
576
+ var start = moment__namespace(dateAsString + " " + intervalAsString, "DD-MM-YYYY " + this.timeFormat);
577
+ var end = moment__namespace("" + dateAsString, 'DD-MM-YYYY').endOf('d');
578
+ while (start.valueOf() < end.valueOf()) {
579
+ this.timeIntervals.push(start.format(this.timeFormat));
580
+ start.add(this.interval, "m");
581
+ }
582
+ // if the start time is equal to the interval just before midnight
583
+ // and the start date = end date
584
+ // push 11:59pm only
585
+ if (this.timeIntervals.length === 0) {
586
+ this.chosenTime = moment__namespace().endOf("d").format(this.timeFormat);
587
+ this.timeIntervals.push(moment__namespace().endOf("d").format(this.timeFormat));
588
+ }
589
+ };
590
+ return TimePickerComponent;
591
+ }());
592
+ TimePickerComponent.decorators = [
593
+ { type: core.Component, args: [{
594
+ selector: "mis-timepicker",
595
+ 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",
596
+ 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}"]
597
+ },] }
598
+ ];
599
+ TimePickerComponent.ctorParameters = function () { return []; };
600
+ TimePickerComponent.propDecorators = {
601
+ clockFormat: [{ type: core.Input }],
602
+ timezone: [{ type: core.Input }],
603
+ height: [{ type: core.Input }],
604
+ inputWidth: [{ type: core.Input }],
605
+ dropdownWidth: [{ type: core.Input }],
606
+ interval: [{ type: core.Input }],
607
+ dateAsEpoch: [{ type: core.Input }],
608
+ firstInterval: [{ type: core.Input }],
609
+ rangeValidity: [{ type: core.Input }],
610
+ timeEmitter: [{ type: core.Output }],
611
+ input: [{ type: core.ViewChild, args: ["input", { static: true },] }],
612
+ timepickerDirective: [{ type: core.ViewChild, args: [TimepickerDirective,] }],
613
+ timeIntervalRefs: [{ type: core.ViewChildren, args: ["timeInterval",] }]
614
+ };
615
+
616
+ var TimePickerModule = /** @class */ (function () {
617
+ function TimePickerModule() {
618
+ }
619
+ TimePickerModule.forRoot = function () {
620
+ return { ngModule: TimePickerModule, providers: [] };
621
+ };
622
+ return TimePickerModule;
623
+ }());
624
+ TimePickerModule.decorators = [
625
+ { type: core.NgModule, args: [{
626
+ declarations: [TimePickerComponent, TimepickerDirective],
627
+ imports: [common.CommonModule, forms.FormsModule, tooltip.ToolTipModule, overlay.OverlayModule],
628
+ exports: [TimePickerComponent]
629
+ },] }
630
+ ];
631
+
632
+ /**
633
+ * Generated bundle index. Do not edit.
634
+ */
635
+
636
+ exports.TimePickerComponent = TimePickerComponent;
637
+ exports.TimePickerModule = TimePickerModule;
638
+ exports.ɵa = TimepickerDirective;
639
+
640
+ Object.defineProperty(exports, '__esModule', { value: true });
641
+
642
+ })));
643
+ //# sourceMappingURL=mis-crystal-design-system-timepicker.umd.js.map