@wkly/datetime-picker 12.0.0 → 13.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 (60) hide show
  1. package/cdk-overlay/package.json +5 -6
  2. package/cdk-overlay/public-api.d.ts +10 -0
  3. package/cdk-overlay/wkly-datetime-picker-cdk-overlay.d.ts +1 -0
  4. package/config.d.ts +3 -0
  5. package/esm2020/cdk-overlay/public-api.mjs +137 -0
  6. package/{esm2015/cdk-overlay/wkly-datetime-picker-cdk-overlay.js → esm2020/cdk-overlay/wkly-datetime-picker-cdk-overlay.mjs} +1 -1
  7. package/esm2020/config.mjs +100 -0
  8. package/esm2020/field.component.mjs +253 -0
  9. package/esm2020/picker.component.mjs +955 -0
  10. package/esm2020/presentation.mjs +303 -0
  11. package/esm2020/public-api.mjs +31 -0
  12. package/{esm2015/wkly-datetime-picker.js → esm2020/wkly-datetime-picker.mjs} +1 -1
  13. package/fesm2015/wkly-datetime-picker-cdk-overlay.mjs +143 -0
  14. package/fesm2015/wkly-datetime-picker-cdk-overlay.mjs.map +1 -0
  15. package/fesm2015/wkly-datetime-picker.mjs +1624 -0
  16. package/fesm2015/wkly-datetime-picker.mjs.map +1 -0
  17. package/fesm2020/wkly-datetime-picker-cdk-overlay.mjs +143 -0
  18. package/fesm2020/wkly-datetime-picker-cdk-overlay.mjs.map +1 -0
  19. package/fesm2020/wkly-datetime-picker.mjs +1622 -0
  20. package/fesm2020/wkly-datetime-picker.mjs.map +1 -0
  21. package/field.component.d.ts +3 -0
  22. package/package.json +34 -14
  23. package/picker.component.d.ts +3 -0
  24. package/presentation.d.ts +7 -0
  25. package/public-api.d.ts +8 -0
  26. package/wkly-datetime-picker.d.ts +1 -1
  27. package/bundles/wkly-datetime-picker-cdk-overlay.umd.js +0 -675
  28. package/bundles/wkly-datetime-picker-cdk-overlay.umd.js.map +0 -1
  29. package/bundles/wkly-datetime-picker.umd.js +0 -2373
  30. package/bundles/wkly-datetime-picker.umd.js.map +0 -1
  31. package/cdk-overlay/public-api.ngfactory.d.ts +0 -3
  32. package/cdk-overlay/wkly-datetime-picker-cdk-overlay.metadata.json +0 -1
  33. package/esm2015/cdk-overlay/public-api.js +0 -127
  34. package/esm2015/cdk-overlay/public-api.ngfactory.js +0 -19
  35. package/esm2015/cdk-overlay/public-api.ngsummary.json +0 -1
  36. package/esm2015/cdk-overlay/wkly-datetime-picker-cdk-overlay.ngsummary.json +0 -1
  37. package/esm2015/config.js +0 -241
  38. package/esm2015/config.ngsummary.json +0 -1
  39. package/esm2015/field.component.css.shim.ngstyle.js +0 -9
  40. package/esm2015/field.component.js +0 -240
  41. package/esm2015/field.component.ngfactory.js +0 -52
  42. package/esm2015/field.component.ngsummary.json +0 -1
  43. package/esm2015/picker.component.js +0 -929
  44. package/esm2015/picker.component.ngfactory.js +0 -137
  45. package/esm2015/picker.component.ngsummary.json +0 -1
  46. package/esm2015/presentation.js +0 -295
  47. package/esm2015/presentation.ngsummary.json +0 -1
  48. package/esm2015/public-api.js +0 -24
  49. package/esm2015/public-api.ngfactory.js +0 -13
  50. package/esm2015/public-api.ngsummary.json +0 -1
  51. package/esm2015/wkly-datetime-picker.ngsummary.json +0 -1
  52. package/fesm2015/wkly-datetime-picker-cdk-overlay.js +0 -134
  53. package/fesm2015/wkly-datetime-picker-cdk-overlay.js.map +0 -1
  54. package/fesm2015/wkly-datetime-picker.js +0 -1715
  55. package/fesm2015/wkly-datetime-picker.js.map +0 -1
  56. package/field.component.css.shim.ngstyle.d.ts +0 -1
  57. package/field.component.ngfactory.d.ts +0 -1
  58. package/picker.component.ngfactory.d.ts +0 -1
  59. package/public-api.ngfactory.d.ts +0 -3
  60. package/wkly-datetime-picker.metadata.json +0 -1
@@ -1,2373 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@wkly/core'), require('@wkly/adapters'), require('@wkly/presentation')) :
3
- typeof define === 'function' && define.amd ? define('@wkly/datetime-picker', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@wkly/core', '@wkly/adapters', '@wkly/presentation'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.wkly = global.wkly || {}, global.wkly["datetime-picker"] = {}), global.ng.core, global.ng.common, global.ng.forms, global.core, global.adapters, global.presentation));
5
- })(this, (function (exports, i0, i1, forms, core, adapters, presentation) { '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 () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n["default"] = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
27
-
28
- /******************************************************************************
29
- Copyright (c) Microsoft Corporation.
30
-
31
- Permission to use, copy, modify, and/or distribute this software for any
32
- purpose with or without fee is hereby granted.
33
-
34
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
35
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
37
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
38
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
39
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
40
- PERFORMANCE OF THIS SOFTWARE.
41
- ***************************************************************************** */
42
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
43
- var extendStatics = function (d, b) {
44
- extendStatics = Object.setPrototypeOf ||
45
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
46
- function (d, b) { for (var p in b)
47
- if (Object.prototype.hasOwnProperty.call(b, p))
48
- d[p] = b[p]; };
49
- return extendStatics(d, b);
50
- };
51
- function __extends(d, b) {
52
- if (typeof b !== "function" && b !== null)
53
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
54
- extendStatics(d, b);
55
- function __() { this.constructor = d; }
56
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
57
- }
58
- var __assign = function () {
59
- __assign = Object.assign || function __assign(t) {
60
- for (var s, i = 1, n = arguments.length; i < n; i++) {
61
- s = arguments[i];
62
- for (var p in s)
63
- if (Object.prototype.hasOwnProperty.call(s, p))
64
- t[p] = s[p];
65
- }
66
- return t;
67
- };
68
- return __assign.apply(this, arguments);
69
- };
70
- function __rest(s, e) {
71
- var t = {};
72
- for (var p in s)
73
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
74
- t[p] = s[p];
75
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
76
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
77
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
78
- t[p[i]] = s[p[i]];
79
- }
80
- return t;
81
- }
82
- function __decorate$1(decorators, target, key, desc) {
83
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
84
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
85
- r = Reflect.decorate(decorators, target, key, desc);
86
- else
87
- for (var i = decorators.length - 1; i >= 0; i--)
88
- if (d = decorators[i])
89
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
90
- return c > 3 && r && Object.defineProperty(target, key, r), r;
91
- }
92
- function __param(paramIndex, decorator) {
93
- return function (target, key) { decorator(target, key, paramIndex); };
94
- }
95
- function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
96
- function accept(f) { if (f !== void 0 && typeof f !== "function")
97
- throw new TypeError("Function expected"); return f; }
98
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
99
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
100
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
101
- var _, done = false;
102
- for (var i = decorators.length - 1; i >= 0; i--) {
103
- var context = {};
104
- for (var p in contextIn)
105
- context[p] = p === "access" ? {} : contextIn[p];
106
- for (var p in contextIn.access)
107
- context.access[p] = contextIn.access[p];
108
- context.addInitializer = function (f) { if (done)
109
- throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
110
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
111
- if (kind === "accessor") {
112
- if (result === void 0)
113
- continue;
114
- if (result === null || typeof result !== "object")
115
- throw new TypeError("Object expected");
116
- if (_ = accept(result.get))
117
- descriptor.get = _;
118
- if (_ = accept(result.set))
119
- descriptor.set = _;
120
- if (_ = accept(result.init))
121
- initializers.unshift(_);
122
- }
123
- else if (_ = accept(result)) {
124
- if (kind === "field")
125
- initializers.unshift(_);
126
- else
127
- descriptor[key] = _;
128
- }
129
- }
130
- if (target)
131
- Object.defineProperty(target, contextIn.name, descriptor);
132
- done = true;
133
- }
134
- ;
135
- function __runInitializers(thisArg, initializers, value) {
136
- var useValue = arguments.length > 2;
137
- for (var i = 0; i < initializers.length; i++) {
138
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
139
- }
140
- return useValue ? value : void 0;
141
- }
142
- ;
143
- function __propKey(x) {
144
- return typeof x === "symbol" ? x : "".concat(x);
145
- }
146
- ;
147
- function __setFunctionName(f, name, prefix) {
148
- if (typeof name === "symbol")
149
- name = name.description ? "[".concat(name.description, "]") : "";
150
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
151
- }
152
- ;
153
- function __metadata$1(metadataKey, metadataValue) {
154
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
155
- return Reflect.metadata(metadataKey, metadataValue);
156
- }
157
- function __awaiter(thisArg, _arguments, P, generator) {
158
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
159
- return new (P || (P = Promise))(function (resolve, reject) {
160
- function fulfilled(value) { try {
161
- step(generator.next(value));
162
- }
163
- catch (e) {
164
- reject(e);
165
- } }
166
- function rejected(value) { try {
167
- step(generator["throw"](value));
168
- }
169
- catch (e) {
170
- reject(e);
171
- } }
172
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
173
- step((generator = generator.apply(thisArg, _arguments || [])).next());
174
- });
175
- }
176
- function __generator(thisArg, body) {
177
- var _ = { label: 0, sent: function () { if (t[0] & 1)
178
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
179
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
180
- function verb(n) { return function (v) { return step([n, v]); }; }
181
- function step(op) {
182
- if (f)
183
- throw new TypeError("Generator is already executing.");
184
- while (g && (g = 0, op[0] && (_ = 0)), _)
185
- try {
186
- 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)
187
- return t;
188
- if (y = 0, t)
189
- op = [op[0] & 2, t.value];
190
- switch (op[0]) {
191
- case 0:
192
- case 1:
193
- t = op;
194
- break;
195
- case 4:
196
- _.label++;
197
- return { value: op[1], done: false };
198
- case 5:
199
- _.label++;
200
- y = op[1];
201
- op = [0];
202
- continue;
203
- case 7:
204
- op = _.ops.pop();
205
- _.trys.pop();
206
- continue;
207
- default:
208
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
209
- _ = 0;
210
- continue;
211
- }
212
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
213
- _.label = op[1];
214
- break;
215
- }
216
- if (op[0] === 6 && _.label < t[1]) {
217
- _.label = t[1];
218
- t = op;
219
- break;
220
- }
221
- if (t && _.label < t[2]) {
222
- _.label = t[2];
223
- _.ops.push(op);
224
- break;
225
- }
226
- if (t[2])
227
- _.ops.pop();
228
- _.trys.pop();
229
- continue;
230
- }
231
- op = body.call(thisArg, _);
232
- }
233
- catch (e) {
234
- op = [6, e];
235
- y = 0;
236
- }
237
- finally {
238
- f = t = 0;
239
- }
240
- if (op[0] & 5)
241
- throw op[1];
242
- return { value: op[0] ? op[1] : void 0, done: true };
243
- }
244
- }
245
- var __createBinding = Object.create ? (function (o, m, k, k2) {
246
- if (k2 === undefined)
247
- k2 = k;
248
- var desc = Object.getOwnPropertyDescriptor(m, k);
249
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
250
- desc = { enumerable: true, get: function () { return m[k]; } };
251
- }
252
- Object.defineProperty(o, k2, desc);
253
- }) : (function (o, m, k, k2) {
254
- if (k2 === undefined)
255
- k2 = k;
256
- o[k2] = m[k];
257
- });
258
- function __exportStar(m, o) {
259
- for (var p in m)
260
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
261
- __createBinding(o, m, p);
262
- }
263
- function __values(o) {
264
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
265
- if (m)
266
- return m.call(o);
267
- if (o && typeof o.length === "number")
268
- return {
269
- next: function () {
270
- if (o && i >= o.length)
271
- o = void 0;
272
- return { value: o && o[i++], done: !o };
273
- }
274
- };
275
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
276
- }
277
- function __read(o, n) {
278
- var m = typeof Symbol === "function" && o[Symbol.iterator];
279
- if (!m)
280
- return o;
281
- var i = m.call(o), r, ar = [], e;
282
- try {
283
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
284
- ar.push(r.value);
285
- }
286
- catch (error) {
287
- e = { error: error };
288
- }
289
- finally {
290
- try {
291
- if (r && !r.done && (m = i["return"]))
292
- m.call(i);
293
- }
294
- finally {
295
- if (e)
296
- throw e.error;
297
- }
298
- }
299
- return ar;
300
- }
301
- /** @deprecated */
302
- function __spread() {
303
- for (var ar = [], i = 0; i < arguments.length; i++)
304
- ar = ar.concat(__read(arguments[i]));
305
- return ar;
306
- }
307
- /** @deprecated */
308
- function __spreadArrays() {
309
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
310
- s += arguments[i].length;
311
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
312
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
313
- r[k] = a[j];
314
- return r;
315
- }
316
- function __spreadArray(to, from, pack) {
317
- if (pack || arguments.length === 2)
318
- for (var i = 0, l = from.length, ar; i < l; i++) {
319
- if (ar || !(i in from)) {
320
- if (!ar)
321
- ar = Array.prototype.slice.call(from, 0, i);
322
- ar[i] = from[i];
323
- }
324
- }
325
- return to.concat(ar || Array.prototype.slice.call(from));
326
- }
327
- function __await(v) {
328
- return this instanceof __await ? (this.v = v, this) : new __await(v);
329
- }
330
- function __asyncGenerator(thisArg, _arguments, generator) {
331
- if (!Symbol.asyncIterator)
332
- throw new TypeError("Symbol.asyncIterator is not defined.");
333
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
334
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
335
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
336
- function verb(n, f) { if (g[n]) {
337
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); };
338
- if (f)
339
- i[n] = f(i[n]);
340
- } }
341
- function resume(n, v) { try {
342
- step(g[n](v));
343
- }
344
- catch (e) {
345
- settle(q[0][3], e);
346
- } }
347
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
348
- function fulfill(value) { resume("next", value); }
349
- function reject(value) { resume("throw", value); }
350
- function settle(f, v) { if (f(v), q.shift(), q.length)
351
- resume(q[0][0], q[0][1]); }
352
- }
353
- function __asyncDelegator(o) {
354
- var i, p;
355
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
356
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
357
- }
358
- function __asyncValues(o) {
359
- if (!Symbol.asyncIterator)
360
- throw new TypeError("Symbol.asyncIterator is not defined.");
361
- var m = o[Symbol.asyncIterator], i;
362
- 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);
363
- 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); }); }; }
364
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
365
- }
366
- function __makeTemplateObject(cooked, raw) {
367
- if (Object.defineProperty) {
368
- Object.defineProperty(cooked, "raw", { value: raw });
369
- }
370
- else {
371
- cooked.raw = raw;
372
- }
373
- return cooked;
374
- }
375
- ;
376
- var __setModuleDefault = Object.create ? (function (o, v) {
377
- Object.defineProperty(o, "default", { enumerable: true, value: v });
378
- }) : function (o, v) {
379
- o["default"] = v;
380
- };
381
- var ownKeys = function (o) {
382
- ownKeys = Object.getOwnPropertyNames || function (o) {
383
- var ar = [];
384
- for (var k in o)
385
- if (Object.prototype.hasOwnProperty.call(o, k))
386
- ar[ar.length] = k;
387
- return ar;
388
- };
389
- return ownKeys(o);
390
- };
391
- function __importStar(mod) {
392
- if (mod && mod.__esModule)
393
- return mod;
394
- var result = {};
395
- if (mod != null)
396
- for (var k = ownKeys(mod), i = 0; i < k.length; i++)
397
- if (k[i] !== "default")
398
- __createBinding(result, mod, k[i]);
399
- __setModuleDefault(result, mod);
400
- return result;
401
- }
402
- function __importDefault(mod) {
403
- return (mod && mod.__esModule) ? mod : { default: mod };
404
- }
405
- function __classPrivateFieldGet(receiver, state, kind, f) {
406
- if (kind === "a" && !f)
407
- throw new TypeError("Private accessor was defined without a getter");
408
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
409
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
410
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
411
- }
412
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
413
- if (kind === "m")
414
- throw new TypeError("Private method is not writable");
415
- if (kind === "a" && !f)
416
- throw new TypeError("Private accessor was defined without a setter");
417
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
418
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
419
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
420
- }
421
- function __classPrivateFieldIn(state, receiver) {
422
- if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
423
- throw new TypeError("Cannot use 'in' operator on non-object");
424
- return typeof state === "function" ? receiver === state : state.has(receiver);
425
- }
426
- function __addDisposableResource(env, value, async) {
427
- if (value !== null && value !== void 0) {
428
- if (typeof value !== "object" && typeof value !== "function")
429
- throw new TypeError("Object expected.");
430
- var dispose, inner;
431
- if (async) {
432
- if (!Symbol.asyncDispose)
433
- throw new TypeError("Symbol.asyncDispose is not defined.");
434
- dispose = value[Symbol.asyncDispose];
435
- }
436
- if (dispose === void 0) {
437
- if (!Symbol.dispose)
438
- throw new TypeError("Symbol.dispose is not defined.");
439
- dispose = value[Symbol.dispose];
440
- if (async)
441
- inner = dispose;
442
- }
443
- if (typeof dispose !== "function")
444
- throw new TypeError("Object not disposable.");
445
- if (inner)
446
- dispose = function () { try {
447
- inner.call(this);
448
- }
449
- catch (e) {
450
- return Promise.reject(e);
451
- } };
452
- env.stack.push({ value: value, dispose: dispose, async: async });
453
- }
454
- else if (async) {
455
- env.stack.push({ async: true });
456
- }
457
- return value;
458
- }
459
- var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
460
- var e = new Error(message);
461
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
462
- };
463
- function __disposeResources(env) {
464
- function fail(e) {
465
- env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
466
- env.hasError = true;
467
- }
468
- var r, s = 0;
469
- function next() {
470
- while (r = env.stack.pop()) {
471
- try {
472
- if (!r.async && s === 1)
473
- return s = 0, env.stack.push(r), Promise.resolve().then(next);
474
- if (r.dispose) {
475
- var result = r.dispose.call(r.value);
476
- if (r.async)
477
- return s |= 2, Promise.resolve(result).then(next, function (e) { fail(e); return next(); });
478
- }
479
- else
480
- s |= 1;
481
- }
482
- catch (e) {
483
- fail(e);
484
- }
485
- }
486
- if (s === 1)
487
- return env.hasError ? Promise.reject(env.error) : Promise.resolve();
488
- if (env.hasError)
489
- throw env.error;
490
- }
491
- return next();
492
- }
493
- function __rewriteRelativeImportExtension(path, preserveJsx) {
494
- if (typeof path === "string" && /^\.\.?\//.test(path)) {
495
- return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
496
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
497
- });
498
- }
499
- return path;
500
- }
501
- var tslib_es6 = {
502
- __extends: __extends,
503
- __assign: __assign,
504
- __rest: __rest,
505
- __decorate: __decorate$1,
506
- __param: __param,
507
- __esDecorate: __esDecorate,
508
- __runInitializers: __runInitializers,
509
- __propKey: __propKey,
510
- __setFunctionName: __setFunctionName,
511
- __metadata: __metadata$1,
512
- __awaiter: __awaiter,
513
- __generator: __generator,
514
- __createBinding: __createBinding,
515
- __exportStar: __exportStar,
516
- __values: __values,
517
- __read: __read,
518
- __spread: __spread,
519
- __spreadArrays: __spreadArrays,
520
- __spreadArray: __spreadArray,
521
- __await: __await,
522
- __asyncGenerator: __asyncGenerator,
523
- __asyncDelegator: __asyncDelegator,
524
- __asyncValues: __asyncValues,
525
- __makeTemplateObject: __makeTemplateObject,
526
- __importStar: __importStar,
527
- __importDefault: __importDefault,
528
- __classPrivateFieldGet: __classPrivateFieldGet,
529
- __classPrivateFieldSet: __classPrivateFieldSet,
530
- __classPrivateFieldIn: __classPrivateFieldIn,
531
- __addDisposableResource: __addDisposableResource,
532
- __disposeResources: __disposeResources,
533
- __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,
534
- };
535
-
536
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
537
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
538
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
539
- r = Reflect.decorate(decorators, target, key, desc);
540
- else
541
- for (var i = decorators.length - 1; i >= 0; i--)
542
- if (d = decorators[i])
543
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
544
- return c > 3 && r && Object.defineProperty(target, key, r), r;
545
- };
546
- var __metadata = (this && this.__metadata) || function (k, v) {
547
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
548
- return Reflect.metadata(k, v);
549
- };
550
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
551
- var WKLY_CLOCK = new i0.InjectionToken("WKLY_CLOCK", {
552
- providedIn: "root",
553
- factory: function () { return ({ now: function () { return new Date(); } }); },
554
- });
555
- var WKLY_CONFIG = new i0.InjectionToken("WKLY_CONFIG", { providedIn: "root", factory: function () { return ({}); } });
556
- var WKLY_LOCALIZATION = new i0.InjectionToken("WKLY_LOCALIZATION", { providedIn: "root", factory: function () { return ({}); } });
557
- var WKLY_TRANSLATIONS = new i0.InjectionToken("WKLY_TRANSLATIONS", { providedIn: "root", factory: function () { return ({}); } });
558
- /** Shared public inputs/outputs inherited by the picker and both trigger directives. */
559
- // Inherited inputs need literal names in published decorator metadata.
560
- var WklyPickerInputs = /** @class */ (function () {
561
- function WklyPickerInputs() {
562
- this[_a] = "datetime";
563
- this[_b] = null;
564
- this[_d] = "";
565
- this[_e] = null;
566
- this[_f] = {
567
- kind: "full-month",
568
- };
569
- this[_g] = "locale";
570
- this[_h] = false;
571
- this[_j] = 1;
572
- this[_k] = 1;
573
- this[_l] = null;
574
- this[_m] = null;
575
- this[_o] = null;
576
- this[_p] = null;
577
- this[_q] = null;
578
- this[_r] = false;
579
- this[_s] = false;
580
- this[_t] = false;
581
- this[_u] = "locale";
582
- this[_v] = null;
583
- this[_w] = 256;
584
- this[_x] = presentation.DEFAULT_OVERSCAN_WEEKS;
585
- this[_y] = null;
586
- this[_z] = null;
587
- this[_0] = null;
588
- this[_1] = true;
589
- this[_2] = [];
590
- this[_3] = null;
591
- this[_4] = new i0.EventEmitter();
592
- this[_5] = new i0.EventEmitter(true);
593
- this[_6] = new i0.EventEmitter();
594
- this[_7] = new i0.EventEmitter();
595
- this[_8] = new i0.EventEmitter(true);
596
- this[_9] = new i0.EventEmitter();
597
- }
598
- return WklyPickerInputs;
599
- }());
600
- _a = presentation.WklyPickerInputsPropertyKeys.Mode, _b = presentation.WklyPickerInputsPropertyKeys.Value, _c = presentation.WklyPickerInputsPropertyKeys.CalendarAdapter, _d = presentation.WklyPickerInputsPropertyKeys.Locale, _e = presentation.WklyPickerInputsPropertyKeys.WeekOffset, _f = presentation.WklyPickerInputsPropertyKeys.ViewportPreset, _g = presentation.WklyPickerInputsPropertyKeys.HourCycle, _h = presentation.WklyPickerInputsPropertyKeys.ShowSeconds, _j = presentation.WklyPickerInputsPropertyKeys.MinuteStep, _k = presentation.WklyPickerInputsPropertyKeys.SecondStep, _l = presentation.WklyPickerInputsPropertyKeys.Min, _m = presentation.WklyPickerInputsPropertyKeys.Max, _o = presentation.WklyPickerInputsPropertyKeys.IsDateDisabled, _p = presentation.WklyPickerInputsPropertyKeys.IsTimeDisabled, _q = presentation.WklyPickerInputsPropertyKeys.RangeValidator, _r = presentation.WklyPickerInputsPropertyKeys.AllowRangeAcrossDisabled, _s = presentation.WklyPickerInputsPropertyKeys.Required, _t = presentation.WklyPickerInputsPropertyKeys.Disabled, _u = presentation.WklyPickerInputsPropertyKeys.WeekLabelMode, _v = presentation.WklyPickerInputsPropertyKeys.WeekLabelFormatter, _w = presentation.WklyPickerInputsPropertyKeys.WeekCacheSize, _x = presentation.WklyPickerInputsPropertyKeys.OverscanWeeks, _y = presentation.WklyPickerInputsPropertyKeys.AriaLabel, _z = presentation.WklyPickerInputsPropertyKeys.AriaDescribedBy, _0 = presentation.WklyPickerInputsPropertyKeys.InitialEpochDay, _1 = presentation.WklyPickerInputsPropertyKeys.CloseOnBackdrop, _2 = presentation.WklyPickerInputsPropertyKeys.Validators, _3 = presentation.WklyPickerInputsPropertyKeys.Translations, _4 = presentation.WklyPickerOutputsPropertyKeys.ValueChange, _5 = presentation.WklyPickerOutputsPropertyKeys.ValidationChange, _6 = presentation.WklyPickerOutputsPropertyKeys.Opened, _7 = presentation.WklyPickerOutputsPropertyKeys.Closed, _8 = presentation.WklyPickerOutputsPropertyKeys.ViewportChange, _9 = presentation.WklyPickerOutputsPropertyKeys.ViewModeChange;
601
- WklyPickerInputs.decorators = [
602
- { type: i0.Directive, args: [{
603
- inputs: [
604
- "mode",
605
- "value",
606
- "calendarAdapter",
607
- "locale",
608
- "weekOffset",
609
- "viewportPreset",
610
- "hourCycle",
611
- "showSeconds",
612
- "minuteStep",
613
- "secondStep",
614
- "min",
615
- "max",
616
- "isDateDisabled",
617
- "isTimeDisabled",
618
- "rangeValidator",
619
- "allowRangeAcrossDisabled",
620
- "required",
621
- "disabled",
622
- "weekLabelMode",
623
- "weekLabelFormatter",
624
- "weekCacheSize",
625
- "overscanWeeks",
626
- "ariaLabel",
627
- "ariaDescribedBy",
628
- "initialEpochDay",
629
- "closeOnBackdrop",
630
- "validators",
631
- "translations",
632
- ],
633
- outputs: [
634
- "valueChange",
635
- "validationChange",
636
- "opened",
637
- "closed",
638
- "viewportChange",
639
- "viewModeChange",
640
- ],
641
- },] }
642
- ];
643
- __decorate([
644
- i0.Input(),
645
- __metadata("design:type", String)
646
- ], WklyPickerInputs.prototype, _a, void 0);
647
- __decorate([
648
- i0.Input(),
649
- __metadata("design:type", Object)
650
- ], WklyPickerInputs.prototype, _b, void 0);
651
- __decorate([
652
- i0.Input(),
653
- __metadata("design:type", Object)
654
- ], WklyPickerInputs.prototype, _c, void 0);
655
- __decorate([
656
- i0.Input(),
657
- __metadata("design:type", String)
658
- ], WklyPickerInputs.prototype, _d, void 0);
659
- __decorate([
660
- i0.Input(),
661
- __metadata("design:type", Object)
662
- ], WklyPickerInputs.prototype, _e, void 0);
663
- __decorate([
664
- i0.Input(),
665
- __metadata("design:type", Object)
666
- ], WklyPickerInputs.prototype, _f, void 0);
667
- __decorate([
668
- i0.Input(),
669
- __metadata("design:type", String)
670
- ], WklyPickerInputs.prototype, _g, void 0);
671
- __decorate([
672
- i0.Input(),
673
- __metadata("design:type", Boolean)
674
- ], WklyPickerInputs.prototype, _h, void 0);
675
- __decorate([
676
- i0.Input(),
677
- __metadata("design:type", Number)
678
- ], WklyPickerInputs.prototype, _j, void 0);
679
- __decorate([
680
- i0.Input(),
681
- __metadata("design:type", Number)
682
- ], WklyPickerInputs.prototype, _k, void 0);
683
- __decorate([
684
- i0.Input(),
685
- __metadata("design:type", Object)
686
- ], WklyPickerInputs.prototype, _l, void 0);
687
- __decorate([
688
- i0.Input(),
689
- __metadata("design:type", Object)
690
- ], WklyPickerInputs.prototype, _m, void 0);
691
- __decorate([
692
- i0.Input(),
693
- __metadata("design:type", Object)
694
- ], WklyPickerInputs.prototype, _o, void 0);
695
- __decorate([
696
- i0.Input(),
697
- __metadata("design:type", Object)
698
- ], WklyPickerInputs.prototype, _p, void 0);
699
- __decorate([
700
- i0.Input(),
701
- __metadata("design:type", Object)
702
- ], WklyPickerInputs.prototype, _q, void 0);
703
- __decorate([
704
- i0.Input(),
705
- __metadata("design:type", Object)
706
- ], WklyPickerInputs.prototype, _r, void 0);
707
- __decorate([
708
- i0.Input(),
709
- __metadata("design:type", Object)
710
- ], WklyPickerInputs.prototype, _s, void 0);
711
- __decorate([
712
- i0.Input(),
713
- __metadata("design:type", Object)
714
- ], WklyPickerInputs.prototype, _t, void 0);
715
- __decorate([
716
- i0.Input(),
717
- __metadata("design:type", String)
718
- ], WklyPickerInputs.prototype, _u, void 0);
719
- __decorate([
720
- i0.Input(),
721
- __metadata("design:type", Object)
722
- ], WklyPickerInputs.prototype, _v, void 0);
723
- __decorate([
724
- i0.Input(),
725
- __metadata("design:type", Object)
726
- ], WklyPickerInputs.prototype, _w, void 0);
727
- __decorate([
728
- i0.Input(),
729
- __metadata("design:type", Object)
730
- ], WklyPickerInputs.prototype, _x, void 0);
731
- __decorate([
732
- i0.Input(),
733
- __metadata("design:type", Object)
734
- ], WklyPickerInputs.prototype, _y, void 0);
735
- __decorate([
736
- i0.Input(),
737
- __metadata("design:type", Object)
738
- ], WklyPickerInputs.prototype, _z, void 0);
739
- __decorate([
740
- i0.Input(),
741
- __metadata("design:type", Object)
742
- ], WklyPickerInputs.prototype, _0, void 0);
743
- __decorate([
744
- i0.Input(),
745
- __metadata("design:type", Object)
746
- ], WklyPickerInputs.prototype, _1, void 0);
747
- __decorate([
748
- i0.Input(),
749
- __metadata("design:type", Array)
750
- ], WklyPickerInputs.prototype, _2, void 0);
751
- __decorate([
752
- i0.Input(),
753
- __metadata("design:type", Object)
754
- ], WklyPickerInputs.prototype, _3, void 0);
755
- __decorate([
756
- i0.Output(),
757
- __metadata("design:type", Object)
758
- ], WklyPickerInputs.prototype, _4, void 0);
759
- __decorate([
760
- i0.Output(),
761
- __metadata("design:type", Object)
762
- ], WklyPickerInputs.prototype, _5, void 0);
763
- __decorate([
764
- i0.Output(),
765
- __metadata("design:type", Object)
766
- ], WklyPickerInputs.prototype, _6, void 0);
767
- __decorate([
768
- i0.Output(),
769
- __metadata("design:type", Object)
770
- ], WklyPickerInputs.prototype, _7, void 0);
771
- __decorate([
772
- i0.Output(),
773
- __metadata("design:type", Object)
774
- ], WklyPickerInputs.prototype, _8, void 0);
775
- __decorate([
776
- i0.Output(),
777
- __metadata("design:type", Object)
778
- ], WklyPickerInputs.prototype, _9, void 0);
779
-
780
- var WklyDateTimePickerComponent = /** @class */ (function (_super) {
781
- __extends(WklyDateTimePickerComponent, _super);
782
- function WklyDateTimePickerComponent(defaultLocale, defaults, clock, strings, defaultTranslations, platform, host, changeDetector) {
783
- var _this = _super.call(this) || this;
784
- _this.defaultLocale = defaultLocale;
785
- _this.defaults = defaults;
786
- _this.clock = clock;
787
- _this.strings = strings;
788
- _this.defaultTranslations = defaultTranslations;
789
- _this.host = host;
790
- _this.changeDetector = changeDetector;
791
- _this.presentation = "inline";
792
- _this.viewMode = "calendar";
793
- _this.endView = "date";
794
- _this.effectiveLocale = "en-US";
795
- _this.effectiveOffset = 0;
796
- _this.effectiveHourCycle = "h24";
797
- _this.direction = "ltr";
798
- _this.rows = [];
799
- _this.weekdays = [];
800
- _this.drafts = [];
801
- _this.errors = [];
802
- _this.today = 0;
803
- _this.focused = 0;
804
- _this.anchorWeek = 0;
805
- _this.firstWeek = 0;
806
- _this.visibleCount = 6;
807
- _this.rowHeight = 76;
808
- _this.scrollHeight = 152076;
809
- _this.paddingTop = 0;
810
- _this.initialized = false;
811
- _this.compact = false;
812
- _this.WklyPickerInputsPropertyKeys = presentation.WklyPickerInputsPropertyKeys;
813
- _this.baseWeek = 0;
814
- _this.firstSupportedDay = 0;
815
- _this.lastSupportedDay = 0;
816
- _this.firstSupportedWeek = 0;
817
- _this.lastSupportedWeek = 0;
818
- _this.initialMonth = "";
819
- _this.clipMonth = false;
820
- _this.browser = false;
821
- _this.destroyed = false;
822
- _this.snapPending = false;
823
- _this.onChange = function () { };
824
- _this.onTouched = function () { };
825
- _this.validatorChanged = function () { };
826
- _this.configErrors = [];
827
- _this.pendingValue = null;
828
- _this.emittedValue = null;
829
- _this.manualDateEndpoint = 0;
830
- _this.browser = i1.isPlatformBrowser(platform);
831
- return _this;
832
- }
833
- WklyDateTimePickerComponent.prototype.ngOnInit = function () {
834
- this.initialize();
835
- };
836
- WklyDateTimePickerComponent.prototype.ngOnChanges = function (changes) {
837
- if (this.initialized) {
838
- if (Object.keys(changes).length === 1 &&
839
- changes[presentation.WklyPickerInputsPropertyKeys.Value] &&
840
- this.emittedValue ===
841
- JSON.stringify(this[presentation.WklyPickerInputsPropertyKeys.Value])) {
842
- this.emittedValue = null;
843
- return;
844
- }
845
- var focus = this.focused;
846
- this.configure();
847
- if (changes[presentation.WklyPickerInputsPropertyKeys.Value] ||
848
- changes[presentation.WklyPickerInputsPropertyKeys.Mode] ||
849
- changes[presentation.WklyPickerInputsPropertyKeys.CalendarAdapter]) {
850
- this.load(this[presentation.WklyPickerInputsPropertyKeys.Value]);
851
- this.position(this.focused, true);
852
- }
853
- else {
854
- this.check();
855
- if (changes[presentation.WklyPickerInputsPropertyKeys.ViewportPreset])
856
- this.position(focus, true);
857
- else
858
- this.scrollToEpochDay(focus);
859
- }
860
- }
861
- };
862
- WklyDateTimePickerComponent.prototype.initialize = function () {
863
- if (this.initialized)
864
- return;
865
- this.configure();
866
- var initialEpochDay = this[presentation.WklyPickerInputsPropertyKeys.InitialEpochDay];
867
- this.today = this.browser
868
- ? Math.floor(this.clock.now().getTime() / 86400000)
869
- : initialEpochDay === null
870
- ? 0
871
- : initialEpochDay;
872
- this.focused =
873
- initialEpochDay === null
874
- ? this.defaults.initialEpochDay === undefined
875
- ? this.today
876
- : this.defaults.initialEpochDay
877
- : initialEpochDay;
878
- this.load(this[presentation.WklyPickerInputsPropertyKeys.Value]);
879
- this.initialized = true;
880
- this.position(this.focused, true);
881
- };
882
- WklyDateTimePickerComponent.prototype.configure = function () {
883
- var e_1, _c;
884
- var _this = this;
885
- this.configErrors = [];
886
- [
887
- presentation.WklyPickerInputsPropertyKeys.ShowSeconds,
888
- presentation.WklyPickerInputsPropertyKeys.AllowRangeAcrossDisabled,
889
- presentation.WklyPickerInputsPropertyKeys.Required,
890
- presentation.WklyPickerInputsPropertyKeys.Disabled,
891
- presentation.WklyPickerInputsPropertyKeys.CloseOnBackdrop,
892
- ].forEach(function (key) { return (_this[key] = presentation.coerceBoolean(_this[key])); });
893
- this.effectiveLocale =
894
- this[presentation.WklyPickerInputsPropertyKeys.Locale] ||
895
- this.defaults.locale ||
896
- this.defaultLocale;
897
- this.direction = /^(ar|he|fa|ur)(-|$)/.test(this.effectiveLocale)
898
- ? "rtl"
899
- : "ltr";
900
- this.adapter =
901
- this[presentation.WklyPickerInputsPropertyKeys.CalendarAdapter] ||
902
- new adapters.WklyGregorianCalendarAdapter(this.effectiveLocale);
903
- try {
904
- var firstDay = void 0;
905
- try {
906
- firstDay = i1.getLocaleFirstDayOfWeek(this.effectiveLocale);
907
- }
908
- catch (_) { }
909
- this.effectiveOffset = adapters.resolveWeekOffset(this.effectiveLocale, this[presentation.WklyPickerInputsPropertyKeys.WeekOffset], this.defaults.weekOffset, firstDay);
910
- core.integer(this[presentation.WklyPickerInputsPropertyKeys.WeekCacheSize]);
911
- core.integer(this[presentation.WklyPickerInputsPropertyKeys.OverscanWeeks]);
912
- if (this[presentation.WklyPickerInputsPropertyKeys.WeekCacheSize] < 0 ||
913
- this[presentation.WklyPickerInputsPropertyKeys.OverscanWeeks] < 0 ||
914
- this[presentation.WklyPickerInputsPropertyKeys.OverscanWeeks] > 50)
915
- throw new RangeError();
916
- if (![
917
- "datetime",
918
- "date",
919
- "time",
920
- "datetime-range",
921
- "date-range",
922
- "time-range",
923
- ].includes(this[presentation.WklyPickerInputsPropertyKeys.Mode]))
924
- throw new RangeError();
925
- var preset = this[presentation.WklyPickerInputsPropertyKeys.ViewportPreset];
926
- if (preset.kind === "weeks") {
927
- core.integer(preset.visibleWeekCount);
928
- if (preset.visibleWeekCount < 1 || preset.visibleWeekCount > 52)
929
- throw new RangeError();
930
- }
931
- if (preset.kind === "full-month-and-around")
932
- try {
933
- for (var _d = __values([
934
- preset.extraWeeksBefore || 0,
935
- preset.extraWeeksAfter || 0,
936
- ]), _e = _d.next(); !_e.done; _e = _d.next()) {
937
- var n = _e.value;
938
- core.integer(n);
939
- if (n < 0 || n > 52)
940
- throw new RangeError();
941
- }
942
- }
943
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
944
- finally {
945
- try {
946
- if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
947
- }
948
- finally { if (e_1) throw e_1.error; }
949
- }
950
- this.generator = core.createWeekGenerator({
951
- weekOffset: this.effectiveOffset,
952
- cacheSize: this[presentation.WklyPickerInputsPropertyKeys.WeekCacheSize],
953
- });
954
- }
955
- catch (_) {
956
- this.configErrors.push(adapters.error("configuration-error", this[presentation.WklyPickerInputsPropertyKeys.WeekOffset]));
957
- this.generator = core.createWeekGenerator();
958
- this.effectiveOffset = 0;
959
- }
960
- this.setSupportedScrollRange();
961
- this.effectiveHourCycle =
962
- this[presentation.WklyPickerInputsPropertyKeys.HourCycle] === "h12"
963
- ? "h12"
964
- : this[presentation.WklyPickerInputsPropertyKeys.HourCycle] === "locale"
965
- ? new Intl.DateTimeFormat(this.effectiveLocale, {
966
- hour: "numeric",
967
- timeZone: "UTC",
968
- }).resolvedOptions().hour12
969
- ? "h12"
970
- : "h24"
971
- : "h24";
972
- this.weekdays = Array.from({ length: 7 }, function (_, i) { return _this.adapter.formatWeekday(_this.effectiveOffset + i, "short"); });
973
- };
974
- WklyDateTimePickerComponent.prototype.setSupportedScrollRange = function () {
975
- var _this = this;
976
- var _c = __read(this.adapter.supportedEpochDayRange, 2), first = _c[0], last = _c[1];
977
- var _d = __read(this.adapter.supportedYearRange, 2), firstYear = _d[0], lastYear = _d[1];
978
- var yearOf = function (day) { return _this.adapter.epochDayToDate(day).year; };
979
- if (yearOf(first) < firstYear) {
980
- var low = first, high = last;
981
- while (low < high) {
982
- var mid = Math.floor((low + high) / 2);
983
- if (yearOf(mid) < firstYear)
984
- low = mid + 1;
985
- else
986
- high = mid;
987
- }
988
- first = low;
989
- }
990
- if (yearOf(last) > lastYear) {
991
- var low = first, high = last;
992
- while (low < high) {
993
- var mid = Math.ceil((low + high) / 2);
994
- if (yearOf(mid) > lastYear)
995
- high = mid - 1;
996
- else
997
- low = mid;
998
- }
999
- last = low;
1000
- }
1001
- if (first > last ||
1002
- yearOf(first) < firstYear ||
1003
- yearOf(first) > lastYear ||
1004
- yearOf(last) < firstYear ||
1005
- yearOf(last) > lastYear)
1006
- throw new RangeError("No supported days within the calendar year range");
1007
- this.firstSupportedDay = first;
1008
- this.lastSupportedDay = last;
1009
- this.firstSupportedWeek = core.absoluteWeekOf(first, this.effectiveOffset);
1010
- this.lastSupportedWeek = core.absoluteWeekOf(last, this.effectiveOffset);
1011
- };
1012
- WklyDateTimePickerComponent.prototype.clampFirstWeek = function (week) {
1013
- // Keep supported weeks inside the viewport; renderRows adds the buffer rows.
1014
- var last = Math.max(this.firstSupportedWeek, this.lastSupportedWeek - this.visibleCount + 1);
1015
- return Math.max(this.firstSupportedWeek, Math.min(last, week));
1016
- };
1017
- WklyDateTimePickerComponent.prototype.ngAfterViewInit = function () {
1018
- var _this = this;
1019
- this.resetScroll();
1020
- if (this.browser && typeof ResizeObserver !== "undefined") {
1021
- this.observer = new ResizeObserver(function () {
1022
- _this.compact = _this.host.nativeElement.clientWidth < 338;
1023
- var row = _this.host.nativeElement.querySelector(".week-row");
1024
- // CSS heights and scrollTop use layout pixels; client rectangles include zoom.
1025
- var height = row ? parseFloat(getComputedStyle(row).height) : 0;
1026
- if (height && height !== _this.rowHeight) {
1027
- _this.rowHeight = height;
1028
- _this.scrollHeight = _this.rowHeight * 2001;
1029
- _this.renderRows();
1030
- _this.resetScroll();
1031
- }
1032
- });
1033
- this.observer.observe(this.host.nativeElement);
1034
- }
1035
- };
1036
- WklyDateTimePickerComponent.prototype.ngOnDestroy = function () {
1037
- this.destroyed = true;
1038
- if (this.observer)
1039
- this.observer.disconnect();
1040
- if (this.scrollEndTimer)
1041
- clearTimeout(this.scrollEndTimer);
1042
- if (this.generator)
1043
- this.generator.clearCache();
1044
- };
1045
- WklyDateTimePickerComponent.prototype.t = function (key) {
1046
- return presentation.resolveWklyTranslation(key, this.effectiveLocale, this[presentation.WklyPickerInputsPropertyKeys.Translations] ||
1047
- this.defaultTranslations, this.strings);
1048
- };
1049
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "isRange", {
1050
- get: function () {
1051
- return this[presentation.WklyPickerInputsPropertyKeys.Mode].endsWith("-range");
1052
- },
1053
- enumerable: false,
1054
- configurable: true
1055
- });
1056
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "hasDate", {
1057
- get: function () {
1058
- return !this[presentation.WklyPickerInputsPropertyKeys.Mode].startsWith("time");
1059
- },
1060
- enumerable: false,
1061
- configurable: true
1062
- });
1063
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "hasTime", {
1064
- get: function () {
1065
- return (this[presentation.WklyPickerInputsPropertyKeys.Mode] !== "date" &&
1066
- this[presentation.WklyPickerInputsPropertyKeys.Mode] !== "date-range");
1067
- },
1068
- enumerable: false,
1069
- configurable: true
1070
- });
1071
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "submitVisible", {
1072
- get: function () {
1073
- return (this.presentation === "transient" &&
1074
- (this[presentation.WklyPickerInputsPropertyKeys.Mode] !== "date" ||
1075
- this.viewMode === "manual"));
1076
- },
1077
- enumerable: false,
1078
- configurable: true
1079
- });
1080
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "title", {
1081
- get: function () {
1082
- try {
1083
- var d = this.adapter.epochDayToDate(Math.max(this.firstSupportedDay, Math.min(this.lastSupportedDay, core.firstEpochDayOf(this.anchorWeek, this.effectiveOffset))));
1084
- return this.adapter.formatMonth(d) + " " + this.adapter.formatYear(d);
1085
- }
1086
- catch (_) {
1087
- return "";
1088
- }
1089
- },
1090
- enumerable: false,
1091
- configurable: true
1092
- });
1093
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "canSubmit", {
1094
- get: function () {
1095
- return (!this[presentation.WklyPickerInputsPropertyKeys.Disabled] &&
1096
- !this.errors.length &&
1097
- this.pendingValue !== null);
1098
- },
1099
- enumerable: false,
1100
- configurable: true
1101
- });
1102
- WklyDateTimePickerComponent.prototype.blank = function (day) {
1103
- var safe = Math.max(this.firstSupportedDay, Math.min(this.lastSupportedDay, day));
1104
- return {
1105
- date: this.adapter.epochDayToDate(safe),
1106
- hour: 0,
1107
- minute: 0,
1108
- second: 0,
1109
- present: false,
1110
- };
1111
- };
1112
- WklyDateTimePickerComponent.prototype.load = function (value) {
1113
- var _this = this;
1114
- this.drafts = [this.blank(this.focused), this.blank(this.focused)];
1115
- var validation = adapters.validateSelection(value, this, this.adapter);
1116
- if (value !== null && !validation.length) {
1117
- var values = typeof value === "string" ? [value] : value;
1118
- values.forEach(function (v, i) {
1119
- var d = adapters.decodeIso(v);
1120
- _this.drafts[i] = {
1121
- date: _this.hasDate
1122
- ? _this.adapter.epochDayToDate(d.epochDay)
1123
- : _this.blank(_this.today).date,
1124
- hour: d.hour,
1125
- minute: d.minute,
1126
- second: d.second,
1127
- present: true,
1128
- };
1129
- if (i === 0 && _this.hasDate)
1130
- _this.focused = d.epochDay;
1131
- });
1132
- }
1133
- if (validation.length) {
1134
- this.pendingValue = null;
1135
- this.report(validation);
1136
- }
1137
- else
1138
- this.check();
1139
- };
1140
- WklyDateTimePickerComponent.prototype.writeValue = function (value) {
1141
- this[presentation.WklyPickerInputsPropertyKeys.Value] = value;
1142
- if (this.initialized) {
1143
- this.load(value);
1144
- this.position(this.focused, true);
1145
- }
1146
- };
1147
- WklyDateTimePickerComponent.prototype.registerOnChange = function (fn) {
1148
- this.onChange = fn;
1149
- };
1150
- WklyDateTimePickerComponent.prototype.registerOnTouched = function (fn) {
1151
- this.onTouched = fn;
1152
- };
1153
- WklyDateTimePickerComponent.prototype.setDisabledState = function (disabled) {
1154
- this[presentation.WklyPickerInputsPropertyKeys.Disabled] = disabled;
1155
- };
1156
- WklyDateTimePickerComponent.prototype.validate = function (_control) {
1157
- return this.errors.length ? { wkly: this.errors } : null;
1158
- };
1159
- WklyDateTimePickerComponent.prototype.registerOnValidatorChange = function (fn) {
1160
- this.validatorChanged = fn;
1161
- };
1162
- WklyDateTimePickerComponent.prototype.touched = function () {
1163
- var _this = this;
1164
- Promise.resolve().then(function () { return _this.onTouched(); });
1165
- };
1166
- WklyDateTimePickerComponent.prototype.report = function (errors) {
1167
- var changed = JSON.stringify(this.errors) !== JSON.stringify(errors);
1168
- this.errors = errors;
1169
- if (changed) {
1170
- this[presentation.WklyPickerOutputsPropertyKeys.ValidationChange].emit(errors);
1171
- this.validatorChanged();
1172
- }
1173
- };
1174
- WklyDateTimePickerComponent.prototype.check = function () {
1175
- var result = presentation.validateDrafts({
1176
- drafts: this.drafts,
1177
- configErrors: this.configErrors,
1178
- adapter: this.adapter,
1179
- selection: this,
1180
- mode: this[presentation.WklyPickerInputsPropertyKeys.Mode],
1181
- isRange: this.isRange,
1182
- hasDate: this.hasDate,
1183
- hasTime: this.hasTime,
1184
- showSeconds: this[presentation.WklyPickerInputsPropertyKeys.ShowSeconds],
1185
- required: this[presentation.WklyPickerInputsPropertyKeys.Required],
1186
- });
1187
- this.pendingValue = result.pendingValue;
1188
- this.report(result.errors);
1189
- };
1190
- WklyDateTimePickerComponent.prototype.trackDraft = function (index) {
1191
- // Endpoint controls keep their identity and focus when draft objects swap.
1192
- return index;
1193
- };
1194
- WklyDateTimePickerComponent.prototype.orderDrafts = function () {
1195
- var _this = this;
1196
- if (!this.isRange || !this.drafts.every(function (draft) { return draft.present; }))
1197
- return;
1198
- if (this.drafts.some(function (draft) { return draft.unsupportedEpochDay !== undefined; }))
1199
- return;
1200
- try {
1201
- var a = this.drafts[0], b = this.drafts[1];
1202
- var key = function (d) { return _this.adapter.dateToEpochDay(d.date) * 86400 +
1203
- (d.hour || 0) * 3600 +
1204
- (d.minute || 0) * 60 +
1205
- (d.second || 0); };
1206
- if (key(a) > key(b))
1207
- this.drafts = [b, a];
1208
- }
1209
- catch (_) {
1210
- // Impossible or incomplete dates remain editable until corrected.
1211
- }
1212
- };
1213
- WklyDateTimePickerComponent.prototype.finish = function () {
1214
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1215
- return;
1216
- this.orderDrafts();
1217
- if (this.viewMode === "manual" && this.hasDate)
1218
- this.positionOnManualDate();
1219
- this.check();
1220
- if (this.presentation === "inline" && this.canSubmit)
1221
- this.commit();
1222
- };
1223
- WklyDateTimePickerComponent.prototype.commit = function () {
1224
- if (!this.canSubmit)
1225
- return;
1226
- var next = this.pendingValue;
1227
- if (JSON.stringify(next) !==
1228
- JSON.stringify(this[presentation.WklyPickerInputsPropertyKeys.Value])) {
1229
- this[presentation.WklyPickerInputsPropertyKeys.Value] = next;
1230
- this.emittedValue = JSON.stringify(next);
1231
- this.onChange(next);
1232
- this[presentation.WklyPickerOutputsPropertyKeys.ValueChange].emit(next);
1233
- }
1234
- this.onTouched();
1235
- };
1236
- WklyDateTimePickerComponent.prototype.submit = function (reason) {
1237
- if (reason === void 0) { reason = "submit"; }
1238
- this.check();
1239
- if (!this.canSubmit)
1240
- return;
1241
- this.commit();
1242
- if (this.presentation === "transient")
1243
- this[presentation.WklyPickerOutputsPropertyKeys.Closed].emit(reason);
1244
- };
1245
- WklyDateTimePickerComponent.prototype.cancel = function (reason) {
1246
- if (reason === void 0) { reason = "close-button"; }
1247
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1248
- return;
1249
- this.load(this[presentation.WklyPickerInputsPropertyKeys.Value]);
1250
- this.onTouched();
1251
- this[presentation.WklyPickerOutputsPropertyKeys.Closed].emit(reason);
1252
- };
1253
- WklyDateTimePickerComponent.prototype.now = function () {
1254
- var _this = this;
1255
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1256
- return;
1257
- var n = this.clock.now();
1258
- var day = Math.floor(n.getTime() / 86400000);
1259
- this.drafts = [0, 1].map(function (index) { return (Object.assign(Object.assign({}, _this.clockDraft(day, n)), { present: index === 0 || _this.isRange })); });
1260
- if (this.hasDate &&
1261
- (day < this.firstSupportedDay || day > this.lastSupportedDay)) {
1262
- this.report([adapters.error("unsupported-adapter-date", day)]);
1263
- return;
1264
- }
1265
- this.focused = day;
1266
- this.position(day, true);
1267
- this.check();
1268
- this.submit("now");
1269
- };
1270
- WklyDateTimePickerComponent.prototype.clockDraft = function (day, now) {
1271
- return Object.assign(Object.assign({}, this.blank(day)), { hour: now.getUTCHours(), minute: Math.floor(now.getUTCMinutes() / this[presentation.WklyPickerInputsPropertyKeys.MinuteStep]) * this[presentation.WklyPickerInputsPropertyKeys.MinuteStep], second: this[presentation.WklyPickerInputsPropertyKeys.ShowSeconds]
1272
- ? Math.floor(now.getUTCSeconds() / this[presentation.WklyPickerInputsPropertyKeys.SecondStep]) * this[presentation.WklyPickerInputsPropertyKeys.SecondStep]
1273
- : 0 });
1274
- };
1275
- WklyDateTimePickerComponent.prototype.initializeManualRange = function () {
1276
- if (!this.isRange ||
1277
- !this.hasDate ||
1278
- this.drafts.every(function (draft) { return draft.present; }))
1279
- return;
1280
- var seed = this.drafts.find(function (draft) { return draft.present; });
1281
- if (!seed) {
1282
- if (this[presentation.WklyPickerInputsPropertyKeys.Value] !== null)
1283
- return;
1284
- var now = this.clock.now();
1285
- var initialEpochDay = this[presentation.WklyPickerInputsPropertyKeys.InitialEpochDay];
1286
- var day = initialEpochDay === null
1287
- ? this.defaults.initialEpochDay === undefined
1288
- ? Math.floor(now.getTime() / 86400000)
1289
- : this.defaults.initialEpochDay
1290
- : initialEpochDay;
1291
- seed = Object.assign(Object.assign({}, this.clockDraft(day, now)), { present: true });
1292
- }
1293
- // Complete missing endpoints without replacing selected or invalid drafts.
1294
- var initial = seed;
1295
- this.drafts = this.drafts.map(function (draft) { return draft.present ? draft : Object.assign(Object.assign({}, initial), { date: Object.assign({}, initial.date) }); });
1296
- this.finish();
1297
- // Positioning renders before validation; refresh completion controls afterward.
1298
- this.changeDetector.markForCheck();
1299
- };
1300
- WklyDateTimePickerComponent.prototype.toggleView = function () {
1301
- var _this = this;
1302
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled] || !this.hasDate)
1303
- return;
1304
- this.viewMode = this.viewMode === "calendar" ? "manual" : "calendar";
1305
- if (this.viewMode === "manual")
1306
- this.initializeManualRange();
1307
- if (this.viewMode === "calendar")
1308
- this.positionOnManualDate();
1309
- this[presentation.WklyPickerOutputsPropertyKeys.ViewModeChange].emit(this.viewMode);
1310
- if (this.viewMode === "calendar")
1311
- setTimeout(function () { return _this.resetScroll(); });
1312
- };
1313
- WklyDateTimePickerComponent.prototype.positionOnManualDate = function () {
1314
- var draft = this.drafts[this.manualDateEndpoint];
1315
- if (!draft || !draft.present)
1316
- return;
1317
- try {
1318
- // A valid day follows the selection. An impossible day keeps its draft
1319
- // fields but still shows the chosen month in the calendar.
1320
- var target = this.adapter.dateToEpochDay(draft.date);
1321
- this.focused = target;
1322
- this.position(target, true);
1323
- }
1324
- catch (_) {
1325
- try {
1326
- var first = this.adapter.dateToEpochDay(Object.assign(Object.assign({}, draft.date), { day: 1 }));
1327
- this.focused = first;
1328
- this.position(first, true);
1329
- }
1330
- catch (_) { }
1331
- }
1332
- };
1333
- WklyDateTimePickerComponent.prototype.months = function (draft) {
1334
- try {
1335
- return this.adapter.getMonths(draft.date.year).map(function (m) { return m.label; });
1336
- }
1337
- catch (_) {
1338
- return [];
1339
- }
1340
- };
1341
- WklyDateTimePickerComponent.prototype.monthCount = function (draft) {
1342
- return this.months(draft).length || 12;
1343
- };
1344
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "inDays", {
1345
- get: function () {
1346
- return presentation.draftDayDifference(this.drafts, this.adapter);
1347
- },
1348
- enumerable: false,
1349
- configurable: true
1350
- });
1351
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "inDaysLabel", {
1352
- get: function () {
1353
- var days = this.inDays;
1354
- return this.t("inDays").replace(/{{\s*days\s*}}/g, days === null
1355
- ? this.t("daysUnavailable")
1356
- : new Intl.NumberFormat(this.effectiveLocale, {
1357
- useGrouping: false,
1358
- }).format(days));
1359
- },
1360
- enumerable: false,
1361
- configurable: true
1362
- });
1363
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "resultingEndDate", {
1364
- get: function () {
1365
- try {
1366
- var draft = this.drafts[1];
1367
- if (draft.unsupportedEpochDay !== undefined ||
1368
- this.adapter.validateDate(draft.date).length)
1369
- return "";
1370
- return [
1371
- this.adapter.formatDay(draft.date),
1372
- this.adapter.formatMonth(draft.date),
1373
- this.adapter.formatYear(draft.date),
1374
- ].join(" ");
1375
- }
1376
- catch (_) {
1377
- return "";
1378
- }
1379
- },
1380
- enumerable: false,
1381
- configurable: true
1382
- });
1383
- WklyDateTimePickerComponent.prototype.toggleEndView = function (view) {
1384
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1385
- return;
1386
- this.endView = view;
1387
- };
1388
- WklyDateTimePickerComponent.prototype.days = function (value) {
1389
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1390
- return;
1391
- this.manualDateEndpoint = 1;
1392
- presentation.setDraftDayDifference(this.drafts, this.adapter, value);
1393
- this.check();
1394
- };
1395
- WklyDateTimePickerComponent.prototype.field = function (index, field, value) {
1396
- var _c;
1397
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1398
- return;
1399
- var draft = this.drafts[index];
1400
- draft.present = true;
1401
- if (field === "day" || field === "year" || field === "month") {
1402
- this.manualDateEndpoint = index;
1403
- delete draft.unsupportedEpochDay;
1404
- var date_1 = Object.assign(Object.assign({}, draft.date), (_c = {}, _c[field] = value, _c));
1405
- if (field === "month") {
1406
- var month = void 0;
1407
- try {
1408
- month = this.adapter
1409
- .getMonths(date_1.year)
1410
- .find(function (m) { return m.month === value; });
1411
- }
1412
- catch (_) { }
1413
- date_1 = Object.assign(Object.assign({}, date_1), { monthCode: month ? month.monthCode : "" });
1414
- }
1415
- if (field === "year" && value !== null) {
1416
- try {
1417
- var months = this.adapter.getMonths(value);
1418
- var month = months.find(function (m) { return m.monthCode === date_1.monthCode; });
1419
- if (month)
1420
- date_1 = Object.assign(Object.assign({}, date_1), { month: month.month });
1421
- }
1422
- catch (_) { }
1423
- }
1424
- draft.date = date_1;
1425
- }
1426
- else if (field === "hour" && this.effectiveHourCycle === "h12")
1427
- draft.hour =
1428
- value === null
1429
- ? null
1430
- : value >= 1 && value <= 12
1431
- ? (value % 12) + ((draft.hour || 0) >= 12 ? 12 : 0)
1432
- : 24 + value;
1433
- else
1434
- draft[field] = value;
1435
- this.check();
1436
- };
1437
- WklyDateTimePickerComponent.prototype.displayHour = function (draft) {
1438
- return draft.hour === null
1439
- ? null
1440
- : this.effectiveHourCycle === "h12"
1441
- ? draft.hour % 12 || 12
1442
- : draft.hour;
1443
- };
1444
- WklyDateTimePickerComponent.prototype.period = function (index, period) {
1445
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1446
- return;
1447
- if (period === "24")
1448
- this.effectiveHourCycle = "h24";
1449
- else {
1450
- this.effectiveHourCycle = "h12";
1451
- this.drafts[index].hour =
1452
- ((this.drafts[index].hour || 0) % 12) + (period === "pm" ? 12 : 0);
1453
- this.drafts[index].present = true;
1454
- this.finish();
1455
- }
1456
- };
1457
- WklyDateTimePickerComponent.prototype.selected = function (day) {
1458
- var _this = this;
1459
- return this.drafts.some(function (d) {
1460
- try {
1461
- return d.present && _this.adapter.dateToEpochDay(d.date) === day;
1462
- }
1463
- catch (_) {
1464
- return false;
1465
- }
1466
- });
1467
- };
1468
- WklyDateTimePickerComponent.prototype.inRange = function (day) {
1469
- if (!this.isRange || !this.drafts.every(function (d) { return d.present; }))
1470
- return false;
1471
- try {
1472
- var a = this.adapter.dateToEpochDay(this.drafts[0].date), b = this.adapter.dateToEpochDay(this.drafts[1].date);
1473
- return day > Math.min(a, b) && day < Math.max(a, b);
1474
- }
1475
- catch (_) {
1476
- return false;
1477
- }
1478
- };
1479
- WklyDateTimePickerComponent.prototype.dayDisabled = function (day) {
1480
- var _a, _b;
1481
- if (day < this.firstSupportedDay || day > this.lastSupportedDay)
1482
- return true;
1483
- try {
1484
- var date = this.adapter.epochDayToDate(day);
1485
- var isDateDisabled = this[presentation.WklyPickerInputsPropertyKeys.IsDateDisabled];
1486
- if (isDateDisabled &&
1487
- isDateDisabled(day, {
1488
- mode: this[presentation.WklyPickerInputsPropertyKeys.Mode],
1489
- endpoint: this.isRange
1490
- ? ((_a = this.drafts[0]) === null || _a === void 0 ? void 0 : _a.present) && !((_b = this.drafts[1]) === null || _b === void 0 ? void 0 : _b.present)
1491
- ? "end"
1492
- : "start"
1493
- : "single",
1494
- calendarDate: date,
1495
- }))
1496
- return true;
1497
- var min = this[presentation.WklyPickerInputsPropertyKeys.Min];
1498
- var max = this[presentation.WklyPickerInputsPropertyKeys.Max];
1499
- if (min && day < adapters.decodeIso(min).epochDay)
1500
- return true;
1501
- if (max && day > adapters.decodeIso(max).epochDay)
1502
- return true;
1503
- return false;
1504
- }
1505
- catch (_) {
1506
- return true;
1507
- }
1508
- };
1509
- WklyDateTimePickerComponent.prototype.select = function (day) {
1510
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled] || this.dayDisabled(day))
1511
- return;
1512
- this.focused = day;
1513
- var index = this.isRange && this.drafts[0].present && !this.drafts[1].present ? 1 : 0;
1514
- if (this.isRange && index === 0)
1515
- this.drafts[1].present = false;
1516
- delete this.drafts[index].unsupportedEpochDay;
1517
- this.drafts[index].date = this.adapter.epochDayToDate(day);
1518
- this.drafts[index].present = true;
1519
- this.orderDrafts();
1520
- this.renderRows();
1521
- this.finish();
1522
- if (this.presentation === "transient" &&
1523
- this[presentation.WklyPickerInputsPropertyKeys.Mode] === "date" &&
1524
- this.viewMode === "calendar")
1525
- this.submit("auto-submit");
1526
- };
1527
- WklyDateTimePickerComponent.prototype.key = function (event, day) {
1528
- var delta = 0;
1529
- if (event.key === "ArrowLeft")
1530
- delta = -1;
1531
- if (event.key === "ArrowRight")
1532
- delta = 1;
1533
- if (event.key === "ArrowUp")
1534
- delta = -7;
1535
- if (event.key === "ArrowDown")
1536
- delta = 7;
1537
- if (event.key === "PageUp")
1538
- delta = -7 * (event.shiftKey ? this.visibleCount : 1);
1539
- if (event.key === "PageDown")
1540
- delta = 7 * (event.shiftKey ? this.visibleCount : 1);
1541
- if (event.key === "Home") {
1542
- event.preventDefault();
1543
- this.scrollToEpochDay(this.today, { focus: true });
1544
- }
1545
- if (delta) {
1546
- event.preventDefault();
1547
- var target = day + delta;
1548
- if (target >= this.firstSupportedDay && target <= this.lastSupportedDay)
1549
- this.scrollToEpochDay(target, { focus: true });
1550
- }
1551
- };
1552
- WklyDateTimePickerComponent.prototype.position = function (day, preset, options) {
1553
- if (preset === void 0) { preset = false; }
1554
- if (options === void 0) { options = {}; }
1555
- day = Math.max(this.firstSupportedDay, Math.min(this.lastSupportedDay, day));
1556
- this.anchorWeek = core.absoluteWeekOf(day, this.effectiveOffset);
1557
- var viewportPreset = this[presentation.WklyPickerInputsPropertyKeys.ViewportPreset];
1558
- this.clipMonth = preset && viewportPreset.kind === "full-month";
1559
- if (preset && viewportPreset.kind !== "weeks") {
1560
- var d = this.adapter.epochDayToDate(day);
1561
- this.initialMonth = d.year + "/" + d.monthCode;
1562
- var _c = __read(presentation.calendarMonthBounds(this.adapter, day), 2), start = _c[0], end = _c[1];
1563
- this.firstWeek = core.absoluteWeekOf(start, this.effectiveOffset);
1564
- this.visibleCount =
1565
- core.absoluteWeekOf(end, this.effectiveOffset) - this.firstWeek + 1;
1566
- if (viewportPreset.kind === "full-month-and-around" &&
1567
- !this.configErrors.length) {
1568
- var before = viewportPreset.extraWeeksBefore || 0, after = viewportPreset.extraWeeksAfter || 0;
1569
- this.firstWeek -= before;
1570
- this.visibleCount += before + after;
1571
- }
1572
- }
1573
- else {
1574
- if (viewportPreset.kind === "weeks")
1575
- this.visibleCount = this.configErrors.length
1576
- ? 6
1577
- : viewportPreset.visibleWeekCount;
1578
- this.firstWeek =
1579
- this.anchorWeek -
1580
- (options.align === "start"
1581
- ? 0
1582
- : options.align === "end"
1583
- ? this.visibleCount - 1
1584
- : Math.floor(this.visibleCount / 2));
1585
- }
1586
- this.firstWeek = this.clampFirstWeek(this.firstWeek);
1587
- this.baseWeek = this.firstWeek - 1000;
1588
- this.renderRows();
1589
- // Apply the new runway before writing scrollTop or locating a focus target.
1590
- this.changeDetector.detectChanges();
1591
- this.resetScroll();
1592
- };
1593
- WklyDateTimePickerComponent.prototype.resetScroll = function () {
1594
- // Round week boundaries to avoid scrollTop truncation under CSS zoom.
1595
- if (this.scroller)
1596
- this.scroller.nativeElement.scrollTop = Math.round(1000 * this.rowHeight);
1597
- };
1598
- WklyDateTimePickerComponent.prototype.scroll = function (event) {
1599
- var element = event.target;
1600
- this.snapPending = true;
1601
- this.scheduleSnap();
1602
- // Quantize displacement around the reset point, equally in both directions.
1603
- var relativeRows = element.scrollTop / this.rowHeight - 1000;
1604
- var index = 1000 + Math.sign(relativeRows) * Math.round(Math.abs(relativeRows));
1605
- var requestedFirst = this.baseWeek + index;
1606
- var first = this.clampFirstWeek(requestedFirst);
1607
- if (requestedFirst !== first) {
1608
- element.scrollTop = Math.round((first - this.baseWeek) * this.rowHeight);
1609
- }
1610
- if (first === this.firstWeek)
1611
- return;
1612
- this.clipMonth = false;
1613
- this.firstWeek = first;
1614
- this.anchorWeek = first + Math.floor(this.visibleCount / 2);
1615
- if (index < 100 || index > 1900) {
1616
- // Preserve signed displacement from this week; modulo turns fractional
1617
- // rounding just below a boundary into almost a full row after rebasing.
1618
- var offset = element.scrollTop - (first - this.baseWeek) * this.rowHeight;
1619
- this.baseWeek = first - 1000;
1620
- element.scrollTop = Math.round(1000 * this.rowHeight + offset);
1621
- }
1622
- this.renderRows();
1623
- };
1624
- WklyDateTimePickerComponent.prototype.scheduleSnap = function () {
1625
- var _this = this;
1626
- if (this.scrollEndTimer)
1627
- clearTimeout(this.scrollEndTimer);
1628
- this.scrollEndTimer = setTimeout(function () { return _this.snapWeek(); }, 200);
1629
- };
1630
- WklyDateTimePickerComponent.prototype.snapWeek = function () {
1631
- if (this.scrollEndTimer)
1632
- clearTimeout(this.scrollEndTimer);
1633
- this.scrollEndTimer = undefined;
1634
- if (!this.snapPending || !this.scroller)
1635
- return;
1636
- this.snapPending = false;
1637
- // Align the current virtual week without rebuilding or rebasing its rows.
1638
- var element = this.scroller.nativeElement;
1639
- var target = Math.round((this.firstWeek - this.baseWeek) * this.rowHeight);
1640
- if (element.scrollTop !== target)
1641
- element.scrollTop = target;
1642
- };
1643
- WklyDateTimePickerComponent.prototype.showFirstWeek = function (week) {
1644
- var first = this.clampFirstWeek(week);
1645
- if (first === this.firstWeek)
1646
- return;
1647
- this.clipMonth = false;
1648
- this.firstWeek = first;
1649
- this.anchorWeek = first + Math.floor(this.visibleCount / 2);
1650
- this.baseWeek = first - 1000;
1651
- this.renderRows();
1652
- this.resetScroll();
1653
- };
1654
- WklyDateTimePickerComponent.prototype.canMoveWeek = function (delta) {
1655
- return this.clampFirstWeek(this.firstWeek + delta) !== this.firstWeek;
1656
- };
1657
- WklyDateTimePickerComponent.prototype.moveWeek = function (delta) {
1658
- if (!this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1659
- this.showFirstWeek(this.firstWeek + delta);
1660
- };
1661
- WklyDateTimePickerComponent.prototype.renderRows = function () {
1662
- var _this = this;
1663
- // Keep the virtual scroll offset here; row data is shared across Angular versions.
1664
- var overscan = Math.max(0, Math.min(50, this[presentation.WklyPickerInputsPropertyKeys.OverscanWeeks] || 0));
1665
- var start = this.firstWeek - overscan;
1666
- this.paddingTop = (start - this.baseWeek) * this.rowHeight;
1667
- this.rows = presentation.createWeekRows({
1668
- generator: this.generator,
1669
- adapter: this.adapter,
1670
- startWeek: start,
1671
- count: this.visibleCount + 2 * overscan,
1672
- firstVisibleWeek: this.firstWeek,
1673
- firstSupportedDay: this.firstSupportedDay,
1674
- lastSupportedDay: this.lastSupportedDay,
1675
- clipMonth: this.clipMonth,
1676
- initialMonth: this.initialMonth,
1677
- weekLabelMode: this[presentation.WklyPickerInputsPropertyKeys.WeekLabelMode],
1678
- weekLabelFormatter: this[presentation.WklyPickerInputsPropertyKeys.WeekLabelFormatter] || null,
1679
- isDayDisabled: function (day) { return _this.dayDisabled(day); },
1680
- });
1681
- this[presentation.WklyPickerOutputsPropertyKeys.ViewportChange].emit({
1682
- firstVisibleAbsoluteWeek: this.firstWeek,
1683
- lastVisibleAbsoluteWeek: this.firstWeek + this.visibleCount - 1,
1684
- anchorAbsoluteWeek: this.anchorWeek,
1685
- });
1686
- };
1687
- // Retain day DOM nodes and keyboard focus when row metadata is regenerated.
1688
- WklyDateTimePickerComponent.prototype.trackCell = function (_i, cell) {
1689
- return cell.epochDay;
1690
- };
1691
- WklyDateTimePickerComponent.prototype.trackRow = function (_i, row) {
1692
- return row.week.absoluteWeek;
1693
- };
1694
- WklyDateTimePickerComponent.prototype.scrollToEpochDay = function (day, options) {
1695
- if (options === void 0) { options = {}; }
1696
- core.integer(day);
1697
- this.adapter.epochDayToDate(day);
1698
- day = Math.max(this.firstSupportedDay, Math.min(this.lastSupportedDay, day));
1699
- // position renders synchronously; publish the tab stop before that render.
1700
- if (options.focus)
1701
- this.focused = day;
1702
- this.position(day, false, options);
1703
- if (options.select)
1704
- this.select(day);
1705
- if (options.focus)
1706
- this.focusDay();
1707
- };
1708
- WklyDateTimePickerComponent.prototype.scrollToAbsoluteWeek = function (week, options) {
1709
- if (options === void 0) { options = {}; }
1710
- // A boundary week can start before the adapter's first supported day.
1711
- var first = core.firstEpochDayOf(week, this.effectiveOffset);
1712
- this.scrollToEpochDay(week === this.firstSupportedWeek
1713
- ? Math.max(first, this.firstSupportedDay)
1714
- : first, options);
1715
- };
1716
- WklyDateTimePickerComponent.prototype.scrollToCalendarDate = function (date, options) {
1717
- if (options === void 0) { options = {}; }
1718
- this.scrollToEpochDay(this.adapter.dateToEpochDay(date), options);
1719
- };
1720
- WklyDateTimePickerComponent.prototype.scrollToValue = function (value, options) {
1721
- if (options === void 0) { options = {}; }
1722
- this.scrollToEpochDay(adapters.decodeIso(value).epochDay, options);
1723
- };
1724
- WklyDateTimePickerComponent.prototype.focusDay = function () {
1725
- var _this = this;
1726
- if (!this.browser)
1727
- return;
1728
- setTimeout(function () {
1729
- var _a;
1730
- if (_this.destroyed)
1731
- return;
1732
- _this.changeDetector.detectChanges();
1733
- var day = _this.host.nativeElement.querySelector('[data-day="' + _this.focused + '"]');
1734
- var fallback = _this.host.nativeElement.querySelector("button:not(:disabled),input:not(:disabled)");
1735
- (_a = (day || fallback)) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
1736
- });
1737
- };
1738
- return WklyDateTimePickerComponent;
1739
- }(WklyPickerInputs));
1740
- WklyDateTimePickerComponent.decorators = [
1741
- { type: i0.Component, args: [{
1742
- selector: "wkly-datetime-picker",
1743
- template: "<section\n class=\"wkly\"\n [attr.dir]=\"direction\"\n [attr.aria-label]=\"\n this[WklyPickerInputsPropertyKeys.AriaLabel] || 'Date and time picker'\n \"\n [attr.aria-describedby]=\"this[WklyPickerInputsPropertyKeys.AriaDescribedBy]\"\n (focusout)=\"touched()\"\n>\n <header class=\"toolbar\">\n <button\n *ngIf=\"hasDate\"\n type=\"button\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [attr.aria-label]=\"t(viewMode === 'calendar' ? 'manual' : 'calendar')\"\n (click)=\"toggleView()\"\n >\n {{ viewMode === \"calendar\" ? \"\u2637\" : \"\u25A6\" }}\n </button>\n <span *ngIf=\"hasDate\" class=\"year-control\">{{ title }}</span>\n <span class=\"spacer\"></span\n ><button\n type=\"button\"\n class=\"now\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n (click)=\"now()\"\n >\n {{ t(\"now\") }}\n </button>\n <button\n *ngIf=\"presentation === 'transient'\"\n type=\"button\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [attr.aria-label]=\"t('close')\"\n (click)=\"cancel()\"\n >\n \u00D7\n </button>\n </header>\n <ng-container *ngIf=\"hasDate && viewMode === 'calendar'\">\n <div\n role=\"grid\"\n [attr.aria-label]=\"\n this[WklyPickerInputsPropertyKeys.AriaLabel] || 'Calendar'\n \"\n [attr.aria-multiselectable]=\"isRange\"\n >\n <div\n role=\"row\"\n class=\"week-head\"\n [class.no-label]=\"\n compact ||\n (this[WklyPickerInputsPropertyKeys.WeekLabelMode] === 'hidden' &&\n !this[WklyPickerInputsPropertyKeys.WeekLabelFormatter])\n \"\n >\n <span\n *ngIf=\"\n !compact &&\n (this[WklyPickerInputsPropertyKeys.WeekLabelMode] !== 'hidden' ||\n this[WklyPickerInputsPropertyKeys.WeekLabelFormatter])\n \"\n role=\"columnheader\"\n aria-label=\"Week\"\n ></span\n ><span *ngFor=\"let day of weekdays\" role=\"columnheader\">{{ day }}</span>\n </div>\n <div\n #scroller\n class=\"week-scroll\"\n [style.height.px]=\"visibleCount * rowHeight\"\n (scroll)=\"scroll($event)\"\n (scrollend)=\"snapWeek()\"\n >\n <div [style.height.px]=\"scrollHeight\" class=\"scroll-space\">\n <div class=\"rows\" [style.top.px]=\"paddingTop\">\n <div\n *ngFor=\"let row of rows; trackBy: trackRow\"\n role=\"row\"\n class=\"week-row\"\n [class.no-label]=\"\n compact ||\n (this[WklyPickerInputsPropertyKeys.WeekLabelMode] ===\n 'hidden' &&\n !this[WklyPickerInputsPropertyKeys.WeekLabelFormatter])\n \"\n >\n <span\n *ngIf=\"\n !compact &&\n (this[WklyPickerInputsPropertyKeys.WeekLabelMode] !==\n 'hidden' ||\n this[WklyPickerInputsPropertyKeys.WeekLabelFormatter])\n \"\n role=\"rowheader\"\n class=\"week-number\"\n >{{ row.label }}</span\n >\n <div\n *ngFor=\"\n let cell of row.cells;\n let dayIndex = index;\n trackBy: trackCell\n \"\n role=\"gridcell\"\n [attr.data-weekday-index]=\"dayIndex\"\n [attr.aria-colindex]=\"\n dayIndex +\n (compact ||\n (this[WklyPickerInputsPropertyKeys.WeekLabelMode] ===\n 'hidden' &&\n !this[WklyPickerInputsPropertyKeys.WeekLabelFormatter])\n ? 1\n : 2)\n \"\n [attr.aria-selected]=\"selected(cell.epochDay)\"\n [attr.aria-disabled]=\"\n cell.disabled || this[WklyPickerInputsPropertyKeys.Disabled]\n \"\n [class.range]=\"inRange(cell.epochDay)\"\n [class.hidden]=\"cell.hidden\"\n [class.odd-month]=\"cell.date && cell.date.month % 2 === 1\"\n >\n <span [class]=\"'annotation annotation--' + dayIndex\">{{\n cell.annotation\n }}</span>\n <button\n type=\"button\"\n class=\"day\"\n [attr.data-day]=\"cell.epochDay\"\n [attr.aria-label]=\"cell.accessible\"\n [attr.aria-current]=\"cell.epochDay === today ? 'date' : null\"\n [attr.aria-disabled]=\"\n cell.disabled || this[WklyPickerInputsPropertyKeys.Disabled]\n \"\n [attr.tabindex]=\"\n !cell.hidden && cell.epochDay === focused ? 0 : -1\n \"\n [class.selected]=\"selected(cell.epochDay)\"\n [class.today]=\"cell.epochDay === today\"\n (focus)=\"focused = cell.epochDay\"\n (click)=\"select(cell.epochDay)\"\n (keydown)=\"key($event, cell.epochDay)\"\n >\n {{ cell.label }}\n </button>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class=\"week-navigation\">\n <button\n type=\"button\"\n [disabled]=\"\n this[WklyPickerInputsPropertyKeys.Disabled] || !canMoveWeek(-1)\n \"\n [attr.aria-label]=\"t('previous')\"\n (click)=\"moveWeek(-1)\"\n >\n \u2191</button\n ><span>{{ title }}</span\n ><button\n type=\"button\"\n [disabled]=\"\n this[WklyPickerInputsPropertyKeys.Disabled] || !canMoveWeek(1)\n \"\n [attr.aria-label]=\"t('next')\"\n (click)=\"moveWeek(1)\"\n >\n \u2193\n </button>\n </div>\n </ng-container>\n <ng-container\n *ngFor=\"let draft of drafts; let i = index; trackBy: trackDraft\"\n >\n <fieldset\n *ngIf=\"(i === 0 || isRange) && (hasTime || viewMode === 'manual')\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [attr.aria-label]=\"isRange ? t(i === 0 ? 'start' : 'end') : null\"\n >\n <legend *ngIf=\"isRange\">\n <ng-container\n *ngIf=\"\n i === 1 && hasDate && viewMode === 'manual';\n else endpointLabel\n \"\n >\n <span class=\"end-view-toggle\">\n <button\n type=\"button\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [attr.aria-pressed]=\"endView === 'date'\"\n (click)=\"toggleEndView('date')\"\n >\n {{ t(\"end\") }}\n </button>\n <button\n type=\"button\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [attr.aria-pressed]=\"endView === 'days'\"\n (click)=\"toggleEndView('days')\"\n >\n {{ inDaysLabel }}\n </button>\n </span>\n </ng-container>\n <ng-template #endpointLabel>{{\n t(i === 0 ? \"start\" : \"end\")\n }}</ng-template>\n </legend>\n <div\n *ngIf=\"\n i === 1 && hasDate && viewMode === 'manual' && endView === 'days'\n \"\n class=\"date-fields in-days-fields\"\n >\n <span class=\"resulting-end-date\" [attr.aria-label]=\"t('endDate')\">{{\n resultingEndDate\n }}</span>\n <wkly-field\n [label]=\"t('days')\"\n [hideLabel]=\"true\"\n [previousLabel]=\"t('daysPrevious')\"\n [nextLabel]=\"t('daysNext')\"\n [locale]=\"effectiveLocale\"\n [value]=\"inDays\"\n [min]=\"-9999\"\n [max]=\"9999\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [invalid]=\"!!errors.length\"\n (valueChange)=\"days($event)\"\n (complete)=\"finish()\"\n ></wkly-field>\n </div>\n <div\n *ngIf=\"\n hasDate && viewMode === 'manual' && (i === 0 || endView === 'date')\n \"\n class=\"date-fields\"\n >\n <wkly-field\n [label]=\"t('day')\"\n [locale]=\"effectiveLocale\"\n [value]=\"draft.date.day\"\n [min]=\"1\"\n [max]=\"31\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [invalid]=\"!!errors.length\"\n (valueChange)=\"field(i, 'day', $event)\"\n (complete)=\"finish()\"\n ></wkly-field>\n <wkly-field\n [label]=\"t('month')\"\n [locale]=\"effectiveLocale\"\n [value]=\"draft.date.month\"\n [min]=\"1\"\n [max]=\"monthCount(draft)\"\n [labels]=\"months(draft)\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [invalid]=\"!!errors.length\"\n (valueChange)=\"field(i, 'month', $event)\"\n (complete)=\"finish()\"\n ></wkly-field>\n <wkly-field\n [label]=\"t('year')\"\n [locale]=\"effectiveLocale\"\n [value]=\"draft.date.year\"\n [min]=\"adapter.supportedYearRange[0]\"\n [max]=\"adapter.supportedYearRange[1]\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [invalid]=\"!!errors.length\"\n (valueChange)=\"field(i, 'year', $event)\"\n (complete)=\"finish()\"\n ></wkly-field>\n </div>\n <div\n *ngIf=\"hasTime\"\n class=\"time-fields\"\n [class.seconds]=\"this[WklyPickerInputsPropertyKeys.ShowSeconds]\"\n >\n <wkly-field\n [label]=\"t('hour')\"\n [locale]=\"effectiveLocale\"\n [value]=\"displayHour(draft)\"\n [min]=\"effectiveHourCycle === 'h12' ? 1 : 0\"\n [max]=\"effectiveHourCycle === 'h12' ? 12 : 23\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [invalid]=\"!!errors.length\"\n (valueChange)=\"field(i, 'hour', $event)\"\n (complete)=\"finish()\"\n ></wkly-field>\n <wkly-field\n [label]=\"t('minute')\"\n [locale]=\"effectiveLocale\"\n [value]=\"draft.minute\"\n [max]=\"59\"\n [step]=\"\n this[WklyPickerInputsPropertyKeys.MinuteStep] > 0 &&\n 60 % this[WklyPickerInputsPropertyKeys.MinuteStep] === 0\n ? this[WklyPickerInputsPropertyKeys.MinuteStep]\n : 1\n \"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [invalid]=\"!!errors.length\"\n (valueChange)=\"field(i, 'minute', $event)\"\n (complete)=\"finish()\"\n ></wkly-field>\n <wkly-field\n *ngIf=\"this[WklyPickerInputsPropertyKeys.ShowSeconds]\"\n [label]=\"t('second')\"\n [locale]=\"effectiveLocale\"\n [value]=\"draft.second\"\n [max]=\"59\"\n [step]=\"\n this[WklyPickerInputsPropertyKeys.SecondStep] > 0 &&\n 60 % this[WklyPickerInputsPropertyKeys.SecondStep] === 0\n ? this[WklyPickerInputsPropertyKeys.SecondStep]\n : 1\n \"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [invalid]=\"!!errors.length\"\n (valueChange)=\"field(i, 'second', $event)\"\n (complete)=\"finish()\"\n ></wkly-field>\n <div class=\"period\">\n <button\n *ngIf=\"\n effectiveHourCycle === 'h12' ||\n this[WklyPickerInputsPropertyKeys.HourCycle] === 'switchable'\n \"\n type=\"button\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [attr.aria-pressed]=\"\n effectiveHourCycle === 'h12' && (draft.hour || 0) < 12\n \"\n (click)=\"period(i, 'am')\"\n >\n {{ t(\"am\") }}</button\n ><button\n type=\"button\"\n [disabled]=\"\n this[WklyPickerInputsPropertyKeys.Disabled] ||\n this[WklyPickerInputsPropertyKeys.HourCycle] !== 'switchable'\n \"\n [attr.aria-pressed]=\"effectiveHourCycle === 'h24'\"\n (click)=\"period(i, '24')\"\n >\n 24</button\n ><button\n *ngIf=\"\n effectiveHourCycle === 'h12' ||\n this[WklyPickerInputsPropertyKeys.HourCycle] === 'switchable'\n \"\n type=\"button\"\n [disabled]=\"this[WklyPickerInputsPropertyKeys.Disabled]\"\n [attr.aria-pressed]=\"\n effectiveHourCycle === 'h12' && (draft.hour || 0) >= 12\n \"\n (click)=\"period(i, 'pm')\"\n >\n {{ t(\"pm\") }}\n </button>\n </div>\n </div>\n </fieldset>\n </ng-container>\n <div class=\"validation\" role=\"status\" aria-live=\"polite\">\n <p *ngFor=\"let err of errors\">! {{ t(err.messageKey) }}</p>\n </div>\n <footer *ngIf=\"submitVisible\">\n <button\n type=\"button\"\n class=\"confirm\"\n [disabled]=\"!canSubmit\"\n (click)=\"submit()\"\n >\n {{ t(\"confirm\") }}\n </button>\n </footer>\n</section>\n",
1744
- providers: [
1745
- {
1746
- provide: forms.NG_VALUE_ACCESSOR,
1747
- useExisting: i0.forwardRef(function () { return WklyDateTimePickerComponent; }),
1748
- multi: true,
1749
- },
1750
- {
1751
- provide: forms.NG_VALIDATORS,
1752
- useExisting: i0.forwardRef(function () { return WklyDateTimePickerComponent; }),
1753
- multi: true,
1754
- },
1755
- ],
1756
- styles: [":host{display:block;width:100%;box-sizing:border-box;--wkly-background-color: #fff;--wkly-background-color-alternate: #fafafa;--wkly-text-color: #192c28;--wkly-muted-color: #52635e;--wkly-border-color: #dce5e1;--wkly-accent-color: #176c55;--wkly-accent-color-alternate: #6ea494;--wkly-accent-text-color: #fff;--wkly-range-color: #e5f1ee;--wkly-error-color: #b42318;--wkly-focus-color: #245bd6;--wkly-size-multiplier: 1;--wkly-size-unit: 3.5em;color:var(--wkly-text-color);font:14px/1.4 system-ui,sans-serif;container-type:inline-size}.wkly{background:var(--wkly-background-color);border:1px solid var(--wkly-border-color);border-radius:14px;overflow:hidden;min-width:0;font-size:calc(14px * clamp(1,var(--wkly-size-multiplier),1.5))}button{font:inherit;color:inherit;min-width:var(--wkly-size-unit);min-height:var(--wkly-size-unit);border:0;background:transparent;border-radius:8px;cursor:pointer}button:hover:not(:disabled):not([aria-disabled=\"true\"]){background:var(--wkly-accent-color-alternate)}button:disabled,button[aria-disabled=true]{opacity:.4;cursor:default}button:focus-visible{outline:2px solid var(--wkly-focus-color);outline-offset:-2px}.toolbar{display:flex;align-items:center;padding:8px;grid-gap:3px;gap:3px;border-bottom:1px solid var(--wkly-border-color)}.spacer{flex:1}.year-control{padding:0 6px;font-weight:650;text-align:start;line-height:1.2}.now{color:var(--wkly-accent-color);font-weight:650}.week-head,.week-row{display:grid;grid-template-columns:28px repeat(7,minmax(0,1fr))}.week-head{font-size:.85em;color:var(--wkly-muted-color);height:34px;align-items:center;text-align:center}.week-row{height:calc(var(--wkly-size-unit) * clamp(1,var(--wkly-size-multiplier),1));align-items:end}.no-label{grid-template-columns:repeat(7,minmax(0,1fr))}.week-scroll{overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;overflow-anchor:none;scrollbar-width:thin;max-height:65vh;touch-action:pan-y}.scroll-space{position:relative}.rows{position:absolute;left:0;right:0}.week-number{font-size:.85em;text-align:center;align-self:end;line-height:var(--wkly-size-unit);color:var(--wkly-muted-color)}[role=gridcell]{position:relative;min-width:0;height:var(--wkly-size-unit);text-align:center}[role=gridcell].odd-month:not(.range):not(.today){background:var(--wkly-background-color-alternate)}.day{width:100%;min-width:0;height:var(--wkly-size-unit);padding:0;border-radius:8px}.annotation{position:absolute;bottom:.25em;white-space:nowrap;font-size:1.25em;font-weight:650;line-height:1;pointer-events:none;z-index:1;color:var(--wkly-muted-color);color:color-mix(in srgb,var(--wkly-muted-color) 50%,transparent);text-shadow:0 0 2px --wkly-background-color,0 0 4px --wkly-background-color}.odd-month .annotation{text-shadow:0 0 2px --wkly-background-color-alternate,0 0 4px --wkly-background-color-alternate}.annotation:empty{display:none}.annotation--0{inset-inline-start:10%;bottom:1.75em}.annotation--1{inset-inline-start:-5%}.annotation--2{inset-inline-start:-20%}.annotation--3{inset-inline-start:-50%;inset-inline-end:-50%}.annotation--4{inset-inline-end:-20%}.annotation--5{inset-inline-end:-5%}.annotation--6{inset-inline-end:10%}.range{background:var(--wkly-range-color)}.day.selected{background:var(--wkly-accent-color);color:var(--wkly-accent-text-color);font-weight:700}.today:after{content:\"\";display:block;width:5px;height:5px;background:currentColor;border-radius:50%;position:absolute;bottom:2px;left:calc(50% - 2px)}.today{font-weight:750;box-shadow:inset 0 0 0 1px var(--wkly-accent-color)}.hidden{visibility:hidden}.week-navigation{display:flex;align-items:center;justify-content:space-between;border-top:1px solid var(--wkly-border-color);font-size:.85em;color:var(--wkly-muted-color)}fieldset{border:0;padding:0 12px;margin:0;min-width:0}legend{padding-top:.85em;font-weight:650;color:var(--wkly-accent-color)}.date-fields{display:grid;grid-template-columns:1fr 2fr 1.4fr;grid-gap:7px;gap:7px;padding:12px 0}.end-view-toggle{display:inline-flex}.end-view-toggle button{min-height:0;min-width:0;padding:0 6px;border-radius:0;line-height:inherit}.end-view-toggle button:first-child{padding-inline-start:0}.end-view-toggle button+button{border-inline-start:1px solid var(--wkly-text-color)}.end-view-toggle button[aria-pressed=false]{color:var(--wkly-muted-color);font-weight:400}.in-days-fields{grid-template-columns:minmax(0,1fr);grid-gap:0;gap:0;text-align:center}.resulting-end-date{font-size:11px;color:var(--wkly-muted-color);height:1.4em;margin-bottom:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.time-fields{display:grid;grid-template-columns:1fr 1fr 52px;grid-gap:8px;gap:8px;padding:14px 0;border-top:1px solid var(--wkly-border-color)}.time-fields.seconds{grid-template-columns:1fr 1fr 1fr 48px}.period{display:flex;flex-direction:column;justify-content:center;grid-gap:2px;gap:2px;padding-top:1.25em}.period button{font-size:.85em}.period [aria-pressed=true]{background:var(--wkly-range-color);box-shadow:inset 0 0 0 1px var(--wkly-accent-color);font-weight:700}.validation{color:var(--wkly-error-color);font-size:.85em}.validation p{margin:.5em .85em}footer{padding:12px;border-top:1px solid var(--wkly-border-color)}.confirm{background:var(--wkly-accent-color);color:var(--wkly-accent-text-color);width:100%;font-weight:650}.confirm:hover:not(:disabled){background:var(--wkly-accent-color-alternate)}@media (forced-colors: active){.day.selected{outline:2px solid Highlight}.range{border-bottom:2px solid Highlight}.today{outline:1px dashed CanvasText}}@media (prefers-reduced-motion: reduce){*{scroll-behavior:auto!important;animation:none!important}}\n"]
1757
- },] }
1758
- ];
1759
- WklyDateTimePickerComponent.ctorParameters = function () { return [
1760
- { type: String, decorators: [{ type: i0.Inject, args: [i0.LOCALE_ID,] }] },
1761
- { type: undefined, decorators: [{ type: i0.Inject, args: [WKLY_CONFIG,] }] },
1762
- { type: undefined, decorators: [{ type: i0.Inject, args: [WKLY_CLOCK,] }] },
1763
- { type: undefined, decorators: [{ type: i0.Inject, args: [WKLY_LOCALIZATION,] }] },
1764
- { type: undefined, decorators: [{ type: i0.Inject, args: [WKLY_TRANSLATIONS,] }] },
1765
- { type: Object, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] },
1766
- { type: i0.ElementRef },
1767
- { type: i0.ChangeDetectorRef }
1768
- ]; };
1769
- WklyDateTimePickerComponent.propDecorators = {
1770
- scroller: [{ type: i0.ViewChild, args: ["scroller",] }]
1771
- };
1772
-
1773
- /** Native-dialog factory. Browser resources are allocated only by open(). */
1774
- var WklyDateTimePickerDialogService = /** @class */ (function () {
1775
- function WklyDateTimePickerDialogService(resolver, injector, app, document, platform) {
1776
- this.resolver = resolver;
1777
- this.injector = injector;
1778
- this.app = app;
1779
- this.document = document;
1780
- this.platform = platform;
1781
- }
1782
- WklyDateTimePickerDialogService.prototype.open = function (trigger, onCancel, backdrop, injector) {
1783
- var _this = this;
1784
- if (backdrop === void 0) { backdrop = true; }
1785
- if (!i1.isPlatformBrowser(this.platform))
1786
- throw new Error("Picker presentations can only open in a browser");
1787
- var dialog = this.document.createElement("dialog");
1788
- dialog.setAttribute("aria-label", "Date and time picker");
1789
- Object.assign(dialog.style, {
1790
- padding: "0",
1791
- border: "0",
1792
- borderRadius: "14px",
1793
- width: "min(390px, 100vw)",
1794
- maxWidth: "100vw",
1795
- maxHeight: "94vh",
1796
- background: "transparent",
1797
- });
1798
- var component = this.resolver
1799
- .resolveComponentFactory(WklyDateTimePickerComponent)
1800
- .create(injector || this.injector);
1801
- component.instance.presentation = "transient";
1802
- dialog.appendChild(component.location.nativeElement);
1803
- this.document.body.appendChild(dialog);
1804
- this.app.attachView(component.hostView);
1805
- var cancel = function (event) {
1806
- event.preventDefault();
1807
- onCancel("escape");
1808
- };
1809
- var click = function (event) {
1810
- if (backdrop && event.target === dialog) {
1811
- var r = dialog.getBoundingClientRect();
1812
- if (event.clientX < r.left ||
1813
- event.clientX > r.right ||
1814
- event.clientY < r.top ||
1815
- event.clientY > r.bottom)
1816
- onCancel("backdrop");
1817
- }
1818
- };
1819
- var keydown = function (event) {
1820
- if (event.key !== "Tab")
1821
- return;
1822
- var controls = Array.from(dialog.querySelectorAll('button:not(:disabled),input:not(:disabled),[tabindex="0"]')).filter(function (el) { return el.tabIndex >= 0 &&
1823
- el.getClientRects().length &&
1824
- getComputedStyle(el).visibility !== "hidden"; });
1825
- var first = controls[0], last = controls[controls.length - 1];
1826
- if (first &&
1827
- (event.shiftKey
1828
- ? _this.document.activeElement === first
1829
- : _this.document.activeElement === last)) {
1830
- event.preventDefault();
1831
- (event.shiftKey ? last : first).focus();
1832
- }
1833
- };
1834
- dialog.addEventListener("cancel", cancel);
1835
- dialog.addEventListener("click", click);
1836
- dialog.addEventListener("keydown", keydown);
1837
- dialog.showModal();
1838
- return {
1839
- component: component,
1840
- destroy: function () {
1841
- dialog.removeEventListener("cancel", cancel);
1842
- dialog.removeEventListener("click", click);
1843
- dialog.removeEventListener("keydown", keydown);
1844
- dialog.close();
1845
- _this.app.detachView(component.hostView);
1846
- component.destroy();
1847
- dialog.remove();
1848
- trigger.focus();
1849
- },
1850
- };
1851
- };
1852
- return WklyDateTimePickerDialogService;
1853
- }());
1854
- WklyDateTimePickerDialogService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function WklyDateTimePickerDialogService_Factory() { return new WklyDateTimePickerDialogService(i0__namespace.ɵɵinject(i0__namespace.ComponentFactoryResolver), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(i0__namespace.ApplicationRef), i0__namespace.ɵɵinject(i1__namespace.DOCUMENT), i0__namespace.ɵɵinject(i0__namespace.PLATFORM_ID)); }, token: WklyDateTimePickerDialogService, providedIn: "root" });
1855
- WklyDateTimePickerDialogService.decorators = [
1856
- { type: i0.Injectable, args: [{ providedIn: "root" },] }
1857
- ];
1858
- WklyDateTimePickerDialogService.ctorParameters = function () { return [
1859
- { type: i0.ComponentFactoryResolver },
1860
- { type: i0.Injector },
1861
- { type: i0.ApplicationRef },
1862
- { type: Document, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] },
1863
- { type: Object, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] }
1864
- ]; };
1865
- /** Shared trigger lifecycle; optional presentation packages extend this class. */
1866
- var WklyTriggerBase = /** @class */ (function (_super) {
1867
- __extends(WklyTriggerBase, _super);
1868
- function WklyTriggerBase(element) {
1869
- var _this = _super.call(this) || this;
1870
- _this.element = element;
1871
- _this.ref = null;
1872
- _this.subscriptions = [];
1873
- _this.errors = [];
1874
- _this.change = function () { };
1875
- _this.touched = function () { };
1876
- _this.validation = function () { };
1877
- return _this;
1878
- }
1879
- WklyTriggerBase.prototype.open = function () {
1880
- var _this = this;
1881
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled] || this.ref)
1882
- return;
1883
- this.ref = this.create();
1884
- var picker = this.ref.component.instance;
1885
- this.copy();
1886
- this.subscriptions = [
1887
- picker[presentation.WklyPickerOutputsPropertyKeys.ValueChange].subscribe(function (value) {
1888
- _this[presentation.WklyPickerInputsPropertyKeys.Value] = value;
1889
- _this.change(value);
1890
- _this[presentation.WklyPickerOutputsPropertyKeys.ValueChange].emit(value);
1891
- _this.display();
1892
- }),
1893
- picker[presentation.WklyPickerOutputsPropertyKeys.ValidationChange].subscribe(function (errors) {
1894
- _this.errors = errors;
1895
- _this[presentation.WklyPickerOutputsPropertyKeys.ValidationChange].emit(errors);
1896
- _this.validation();
1897
- }),
1898
- picker[presentation.WklyPickerOutputsPropertyKeys.Closed].subscribe(function (reason) { return _this.close(reason); }),
1899
- picker[presentation.WklyPickerOutputsPropertyKeys.ViewportChange].subscribe(function (value) { return _this[presentation.WklyPickerOutputsPropertyKeys.ViewportChange].emit(value); }),
1900
- picker[presentation.WklyPickerOutputsPropertyKeys.ViewModeChange].subscribe(function (value) { return _this[presentation.WklyPickerOutputsPropertyKeys.ViewModeChange].emit(value); }),
1901
- ];
1902
- this.ref.component.changeDetectorRef.detectChanges();
1903
- picker.focusDay();
1904
- this[presentation.WklyPickerOutputsPropertyKeys.Opened].emit();
1905
- };
1906
- WklyTriggerBase.prototype.key = function (event) {
1907
- if (event.key === "Enter" ||
1908
- event.key === " " ||
1909
- event.key === "ArrowDown") {
1910
- event.preventDefault();
1911
- this.open();
1912
- }
1913
- };
1914
- WklyTriggerBase.prototype.blur = function () {
1915
- this.touched();
1916
- };
1917
- WklyTriggerBase.prototype.close = function (reason) {
1918
- if (reason === void 0) { reason = "programmatic"; }
1919
- if (!this.ref)
1920
- return;
1921
- var ref = this.ref;
1922
- this.ref = null;
1923
- this.subscriptions.forEach(function (s) { return s.unsubscribe(); });
1924
- this.subscriptions = [];
1925
- ref.destroy();
1926
- this.touched();
1927
- this[presentation.WklyPickerOutputsPropertyKeys.Closed].emit(reason);
1928
- };
1929
- WklyTriggerBase.prototype.ngOnChanges = function () {
1930
- var _b;
1931
- var _this = this;
1932
- [
1933
- presentation.WklyPickerInputsPropertyKeys.ShowSeconds,
1934
- presentation.WklyPickerInputsPropertyKeys.AllowRangeAcrossDisabled,
1935
- presentation.WklyPickerInputsPropertyKeys.Required,
1936
- presentation.WklyPickerInputsPropertyKeys.Disabled,
1937
- presentation.WklyPickerInputsPropertyKeys.CloseOnBackdrop,
1938
- ].forEach(function (key) { return (_this[key] = presentation.coerceBoolean(_this[key])); });
1939
- this.checkValue();
1940
- this.display();
1941
- if (this.ref) {
1942
- this.copy();
1943
- this.ref.component.instance.ngOnChanges((_b = {},
1944
- _b[presentation.WklyPickerInputsPropertyKeys.Value] = true,
1945
- _b));
1946
- this.ref.component.changeDetectorRef.detectChanges();
1947
- }
1948
- };
1949
- WklyTriggerBase.prototype.ngOnDestroy = function () {
1950
- this.close();
1951
- };
1952
- WklyTriggerBase.prototype.copy = function () {
1953
- var e_1, _b;
1954
- if (this.ref)
1955
- try {
1956
- for (var INPUT_NAMES_1 = __values(presentation.INPUT_NAMES), INPUT_NAMES_1_1 = INPUT_NAMES_1.next(); !INPUT_NAMES_1_1.done; INPUT_NAMES_1_1 = INPUT_NAMES_1.next()) {
1957
- var name = INPUT_NAMES_1_1.value;
1958
- this.ref.component.instance[name] = this[name];
1959
- }
1960
- }
1961
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1962
- finally {
1963
- try {
1964
- if (INPUT_NAMES_1_1 && !INPUT_NAMES_1_1.done && (_b = INPUT_NAMES_1.return)) _b.call(INPUT_NAMES_1);
1965
- }
1966
- finally { if (e_1) throw e_1.error; }
1967
- }
1968
- };
1969
- WklyTriggerBase.prototype.display = function () {
1970
- var host = this.element.nativeElement;
1971
- if (host.tagName === "INPUT") {
1972
- host.readOnly = true;
1973
- var value = this[presentation.WklyPickerInputsPropertyKeys.Value];
1974
- host.value =
1975
- value === null
1976
- ? ""
1977
- : typeof value === "string"
1978
- ? value
1979
- : value.join(" — ");
1980
- host.disabled = this[presentation.WklyPickerInputsPropertyKeys.Disabled];
1981
- host.setAttribute("aria-haspopup", "dialog");
1982
- }
1983
- };
1984
- WklyTriggerBase.prototype.checkValue = function () {
1985
- this.errors = adapters.validateSelection(this[presentation.WklyPickerInputsPropertyKeys.Value], this, this[presentation.WklyPickerInputsPropertyKeys.CalendarAdapter] ||
1986
- new adapters.WklyGregorianCalendarAdapter(this[presentation.WklyPickerInputsPropertyKeys.Locale] || "en-US"));
1987
- this[presentation.WklyPickerOutputsPropertyKeys.ValidationChange].emit(this.errors);
1988
- this.validation();
1989
- };
1990
- WklyTriggerBase.prototype.writeValue = function (value) {
1991
- this[presentation.WklyPickerInputsPropertyKeys.Value] = value;
1992
- this.checkValue();
1993
- this.display();
1994
- if (this.ref)
1995
- this.ref.component.instance.writeValue(value);
1996
- };
1997
- WklyTriggerBase.prototype.registerOnChange = function (fn) {
1998
- this.change = fn;
1999
- };
2000
- WklyTriggerBase.prototype.registerOnTouched = function (fn) {
2001
- this.touched = fn;
2002
- };
2003
- WklyTriggerBase.prototype.setDisabledState = function (value) {
2004
- this[presentation.WklyPickerInputsPropertyKeys.Disabled] = value;
2005
- this.display();
2006
- if (this.ref)
2007
- this.ref.component.instance.setDisabledState(value);
2008
- };
2009
- WklyTriggerBase.prototype.validate = function () {
2010
- return this.errors.length ? { wkly: this.errors } : null;
2011
- };
2012
- WklyTriggerBase.prototype.registerOnValidatorChange = function (fn) {
2013
- this.validation = fn;
2014
- };
2015
- WklyTriggerBase.prototype.scrollToEpochDay = function (day, options) {
2016
- var _a;
2017
- this.open();
2018
- (_a = this.ref) === null || _a === void 0 ? void 0 : _a.component.instance.scrollToEpochDay(day, options);
2019
- };
2020
- WklyTriggerBase.prototype.scrollToAbsoluteWeek = function (week, options) {
2021
- var _a;
2022
- this.open();
2023
- (_a = this.ref) === null || _a === void 0 ? void 0 : _a.component.instance.scrollToAbsoluteWeek(week, options);
2024
- };
2025
- WklyTriggerBase.prototype.scrollToCalendarDate = function (date, options) {
2026
- var _a;
2027
- this.open();
2028
- (_a = this.ref) === null || _a === void 0 ? void 0 : _a.component.instance.scrollToCalendarDate(date, options);
2029
- };
2030
- WklyTriggerBase.prototype.scrollToValue = function (value, options) {
2031
- var _a;
2032
- this.open();
2033
- (_a = this.ref) === null || _a === void 0 ? void 0 : _a.component.instance.scrollToValue(value, options);
2034
- };
2035
- return WklyTriggerBase;
2036
- }(WklyPickerInputs));
2037
- WklyTriggerBase.decorators = [
2038
- { type: i0.Directive }
2039
- ];
2040
- WklyTriggerBase.ctorParameters = function () { return [
2041
- { type: i0.ElementRef }
2042
- ]; };
2043
- WklyTriggerBase.propDecorators = {
2044
- open: [{ type: i0.HostListener, args: ["click",] }],
2045
- key: [{ type: i0.HostListener, args: ["keydown", ["$event"],] }],
2046
- blur: [{ type: i0.HostListener, args: ["blur",] }]
2047
- };
2048
- var WklyDateTimePickerDialogDirective = /** @class */ (function (_super) {
2049
- __extends(WklyDateTimePickerDialogDirective, _super);
2050
- function WklyDateTimePickerDialogDirective(element, service, triggerInjector) {
2051
- var _this = _super.call(this, element) || this;
2052
- _this.service = service;
2053
- _this.triggerInjector = triggerInjector;
2054
- return _this;
2055
- }
2056
- WklyDateTimePickerDialogDirective.prototype.create = function () {
2057
- var _this = this;
2058
- return this.service.open(this.element.nativeElement, function (reason) { return _this.close(reason); }, this[presentation.WklyPickerInputsPropertyKeys.CloseOnBackdrop], this.triggerInjector);
2059
- };
2060
- return WklyDateTimePickerDialogDirective;
2061
- }(WklyTriggerBase));
2062
- WklyDateTimePickerDialogDirective.decorators = [
2063
- { type: i0.Directive, args: [{
2064
- selector: "[wklyDateTimePickerDialog]",
2065
- exportAs: "wklyDialog",
2066
- providers: [
2067
- {
2068
- provide: forms.NG_VALUE_ACCESSOR,
2069
- useExisting: i0.forwardRef(function () { return WklyDateTimePickerDialogDirective; }),
2070
- multi: true,
2071
- },
2072
- {
2073
- provide: forms.NG_VALIDATORS,
2074
- useExisting: i0.forwardRef(function () { return WklyDateTimePickerDialogDirective; }),
2075
- multi: true,
2076
- },
2077
- ],
2078
- },] }
2079
- ];
2080
- WklyDateTimePickerDialogDirective.ctorParameters = function () { return [
2081
- { type: i0.ElementRef },
2082
- { type: WklyDateTimePickerDialogService },
2083
- { type: i0.Injector }
2084
- ]; };
2085
-
2086
- var WklyFieldComponent = /** @class */ (function () {
2087
- function WklyFieldComponent() {
2088
- this.value = 0;
2089
- this.label = "";
2090
- this.hideLabel = false;
2091
- this.previousLabel = "";
2092
- this.nextLabel = "";
2093
- this.min = 0;
2094
- this.max = 59;
2095
- this.step = 1;
2096
- this.locale = "en-US";
2097
- this.disabled = false;
2098
- this.invalid = false;
2099
- this.labels = null;
2100
- this.valueChange = new i0.EventEmitter();
2101
- this.complete = new i0.EventEmitter();
2102
- this.before = null;
2103
- this.touchY = 0;
2104
- this.touchSteps = 0;
2105
- this.touchChanged = false;
2106
- this.typed = null;
2107
- this.inputTimer = null;
2108
- this.wheelTimer = null;
2109
- }
2110
- Object.defineProperty(WklyFieldComponent.prototype, "display", {
2111
- get: function () {
2112
- if (this.typed !== null)
2113
- return this.typed;
2114
- return this.value === null
2115
- ? ""
2116
- : this.labels
2117
- ? this.labels[this.value - this.min] || String(this.value)
2118
- : new Intl.NumberFormat(this.locale, {
2119
- useGrouping: false,
2120
- minimumIntegerDigits: this.max < 60 ? 2 : 1,
2121
- }).format(this.value);
2122
- },
2123
- enumerable: false,
2124
- configurable: true
2125
- });
2126
- WklyFieldComponent.prototype.ngOnChanges = function (changes) {
2127
- if (changes.value && this.min < 0 && this.typed !== null) {
2128
- var typedValue = this.typed === "" || this.typed === "-" ? null : Number(this.typed);
2129
- if (this.value !== typedValue) {
2130
- // External date edits replace a pending relative-day preview.
2131
- this.cancelInput();
2132
- this.typed = null;
2133
- }
2134
- }
2135
- };
2136
- WklyFieldComponent.prototype.ngOnDestroy = function () {
2137
- this.cancelInput();
2138
- if (this.wheelTimer !== null)
2139
- clearTimeout(this.wheelTimer);
2140
- };
2141
- WklyFieldComponent.prototype.next = function (delta) {
2142
- var count = Math.floor((this.max - this.min) / this.step) + 1;
2143
- return (this.min +
2144
- core.floorMod(Math.floor(((this.value === null ? this.min : this.value) - this.min) /
2145
- this.step) + delta, count) *
2146
- this.step);
2147
- };
2148
- WklyFieldComponent.prototype.neighbor = function (delta) {
2149
- var n = this.next(delta);
2150
- return this.labels
2151
- ? this.labels[n - this.min] || ""
2152
- : new Intl.NumberFormat(this.locale, { useGrouping: false }).format(n);
2153
- };
2154
- WklyFieldComponent.prototype.stepBy = function (delta) {
2155
- if (this.disabled)
2156
- return;
2157
- this.scrollBy(delta);
2158
- this.complete.emit();
2159
- };
2160
- WklyFieldComponent.prototype.begin = function (event) {
2161
- this.before = this.value;
2162
- event.target.select();
2163
- };
2164
- WklyFieldComponent.prototype.type = function (event) {
2165
- var _this = this;
2166
- if (this.disabled)
2167
- return;
2168
- var input = event.target;
2169
- var raw = input.value;
2170
- var numeric = Array.from(raw).every(function (character) { return adapters.normalizeDigits(character).length === 1; });
2171
- if (this.min < 0 && !this.labels) {
2172
- // Preserve the sign while using the same locale digit normalization.
2173
- var signed = raw
2174
- .replace(/[\u200e\u200f\u061c]/g, "")
2175
- .replace(/\u2212/g, "-");
2176
- var digits = adapters.normalizeDigits(signed);
2177
- this.typed = input.value = (signed.startsWith("-") ? "-" : "") + digits;
2178
- this.value =
2179
- digits === ""
2180
- ? null
2181
- : Math.max(this.min, Math.min(this.max, Number(this.typed)));
2182
- if (this.value !== null && Number(this.typed) !== this.value)
2183
- this.typed = input.value = String(this.value);
2184
- }
2185
- else if (numeric) {
2186
- var normalized = adapters.normalizeDigits(raw);
2187
- this.typed = input.value =
2188
- this.min >= 0 && this.max < 100 ? normalized.slice(-2) : normalized;
2189
- this.value = this.typed === "" ? null : Number(this.typed);
2190
- }
2191
- else if (this.labels) {
2192
- var search_1 = raw.trim().toLocaleLowerCase(this.locale);
2193
- this.typed = raw;
2194
- var matches = this.labels
2195
- .map(function (label, index) { return ({ label: label, index: index }); })
2196
- .filter(function (item) { return item.label.toLocaleLowerCase(_this.locale).includes(search_1); });
2197
- this.value = matches.length === 1 ? this.min + matches[0].index : null;
2198
- }
2199
- else {
2200
- this.typed = input.value = adapters.normalizeDigits(raw);
2201
- this.value = this.typed === "" ? null : Number(this.typed);
2202
- }
2203
- this.valueChange.emit(this.value);
2204
- this.cancelInput();
2205
- if (!numeric && this.labels && this.value !== null)
2206
- this.complete.emit();
2207
- this.inputTimer = setTimeout(function () {
2208
- _this.inputTimer = null;
2209
- _this.typed = null;
2210
- if (!_this.disabled)
2211
- _this.complete.emit();
2212
- }, 1000);
2213
- };
2214
- WklyFieldComponent.prototype.key = function (event) {
2215
- if (event.key === "Escape") {
2216
- event.preventDefault();
2217
- event.stopPropagation();
2218
- this.cancelInput();
2219
- this.typed = null;
2220
- this.value = this.before;
2221
- this.valueChange.emit(this.before);
2222
- event.target.value = this.display;
2223
- event.target.blur();
2224
- }
2225
- if (event.key === "Enter") {
2226
- event.preventDefault();
2227
- event.stopPropagation();
2228
- this.finish();
2229
- }
2230
- var delta = event.key === "ArrowUp"
2231
- ? -1
2232
- : event.key === "ArrowDown"
2233
- ? 1
2234
- : event.key === "PageUp"
2235
- ? -5
2236
- : event.key === "PageDown"
2237
- ? 5
2238
- : 0;
2239
- if (delta) {
2240
- event.preventDefault();
2241
- this.stepBy(delta);
2242
- }
2243
- };
2244
- WklyFieldComponent.prototype.finish = function () {
2245
- this.cancelInput();
2246
- this.typed = null;
2247
- this.complete.emit();
2248
- };
2249
- WklyFieldComponent.prototype.wheel = function (event) {
2250
- var _this = this;
2251
- if (this.disabled || Math.abs(event.deltaY) < 1)
2252
- return;
2253
- event.preventDefault();
2254
- this.scrollBy(event.deltaY > 0 ? 1 : -1);
2255
- if (this.wheelTimer !== null)
2256
- clearTimeout(this.wheelTimer);
2257
- this.wheelTimer = setTimeout(function () {
2258
- _this.wheelTimer = null;
2259
- _this.complete.emit();
2260
- }, 140);
2261
- };
2262
- WklyFieldComponent.prototype.touchStart = function (event) {
2263
- this.touchY = event.touches[0].clientY;
2264
- this.touchSteps = 0;
2265
- this.touchChanged = false;
2266
- };
2267
- WklyFieldComponent.prototype.touchMove = function (event) {
2268
- this.applyTouchY(event.touches[0].clientY);
2269
- };
2270
- WklyFieldComponent.prototype.touchEnd = function (event) {
2271
- this.applyTouchY(event.changedTouches[0].clientY);
2272
- if (this.touchChanged)
2273
- this.complete.emit();
2274
- this.touchChanged = false;
2275
- };
2276
- WklyFieldComponent.prototype.cancelInput = function () {
2277
- if (this.inputTimer !== null)
2278
- clearTimeout(this.inputTimer);
2279
- this.inputTimer = null;
2280
- };
2281
- WklyFieldComponent.prototype.scrollBy = function (delta) {
2282
- if (this.disabled || !delta)
2283
- return;
2284
- this.cancelInput();
2285
- this.typed = null;
2286
- this.value = this.next(delta);
2287
- this.valueChange.emit(this.value);
2288
- };
2289
- WklyFieldComponent.prototype.applyTouchY = function (y) {
2290
- // Count total gesture steps so repeated move events do not duplicate changes.
2291
- if (this.disabled)
2292
- return;
2293
- var delta = this.touchY - y;
2294
- var steps = Math.abs(delta) > 16
2295
- ? Math.sign(delta) * Math.max(1, Math.round(Math.abs(delta) / 40))
2296
- : 0;
2297
- var change = steps - this.touchSteps;
2298
- if (!change)
2299
- return;
2300
- this.scrollBy(change);
2301
- this.touchSteps = steps;
2302
- this.touchChanged = true;
2303
- };
2304
- return WklyFieldComponent;
2305
- }());
2306
- WklyFieldComponent.decorators = [
2307
- { type: i0.Component, args: [{
2308
- selector: "wkly-field",
2309
- template: "<div\n class=\"field\"\n (wheel)=\"wheel($event)\"\n (touchstart)=\"touchStart($event)\"\n (touchmove)=\"touchMove($event)\"\n (touchend)=\"touchEnd($event)\"\n (touchcancel)=\"touchEnd($event)\"\n>\n <span *ngIf=\"!hideLabel\" class=\"label\">{{ label }}</span>\n <button\n type=\"button\"\n [disabled]=\"disabled\"\n [attr.aria-label]=\"previousLabel || label + ': previous'\"\n (click)=\"stepBy(-1)\"\n >\n {{ neighbor(-1) }}\n </button>\n <input\n [attr.aria-label]=\"label\"\n [attr.aria-invalid]=\"invalid\"\n [disabled]=\"disabled\"\n [value]=\"display\"\n [attr.inputmode]=\"labels ? 'text' : min < 0 ? 'text' : 'numeric'\"\n autocomplete=\"off\"\n (focus)=\"begin($event)\"\n (input)=\"type($event)\"\n (blur)=\"finish()\"\n (keydown)=\"key($event)\"\n />\n <button\n type=\"button\"\n [disabled]=\"disabled\"\n [attr.aria-label]=\"nextLabel || label + ': next'\"\n (click)=\"stepBy(1)\"\n >\n {{ neighbor(1) }}\n </button>\n</div>\n",
2310
- styles: [".field{display:flex;flex-direction:column;align-items:stretch;min-width:0;text-align:center;touch-action:pan-x}.label{font-size:11px;color:var(--wkly-muted-color, #54616e);margin-bottom:4px}button,input{font:inherit;box-sizing:border-box;min-height:44px;width:100%;border:0;text-align:center;background:transparent;color:inherit;border-radius:7px}button{color:var(--wkly-muted-color, #54616e);cursor:pointer}input{font-size:18px;font-weight:650;background:var(--wkly-range-color, #e5f1ee);border-block:2px solid var(--wkly-accent-color, #176c55)}input[aria-invalid=true]{border-color:var(--wkly-error-color, #b42318)}:focus-visible{outline:2px solid var(--wkly-focus-color, #124ee0);outline-offset:1px}button:disabled,input:disabled{opacity:.45}button:hover:not(:disabled){background:var(--wkly-range-color, #e5f1ee)}\n"]
2311
- },] }
2312
- ];
2313
- WklyFieldComponent.propDecorators = {
2314
- value: [{ type: i0.Input }],
2315
- label: [{ type: i0.Input }],
2316
- hideLabel: [{ type: i0.Input }],
2317
- previousLabel: [{ type: i0.Input }],
2318
- nextLabel: [{ type: i0.Input }],
2319
- min: [{ type: i0.Input }],
2320
- max: [{ type: i0.Input }],
2321
- step: [{ type: i0.Input }],
2322
- locale: [{ type: i0.Input }],
2323
- disabled: [{ type: i0.Input }],
2324
- invalid: [{ type: i0.Input }],
2325
- labels: [{ type: i0.Input }],
2326
- valueChange: [{ type: i0.Output }],
2327
- complete: [{ type: i0.Output }]
2328
- };
2329
-
2330
- var WklyDateTimePickerModule = /** @class */ (function () {
2331
- function WklyDateTimePickerModule() {
2332
- }
2333
- return WklyDateTimePickerModule;
2334
- }());
2335
- WklyDateTimePickerModule.decorators = [
2336
- { type: i0.NgModule, args: [{
2337
- imports: [i1.CommonModule],
2338
- declarations: [
2339
- WklyDateTimePickerComponent,
2340
- WklyDateTimePickerDialogDirective,
2341
- WklyFieldComponent,
2342
- ],
2343
- entryComponents: [WklyDateTimePickerComponent],
2344
- exports: [WklyDateTimePickerComponent, WklyDateTimePickerDialogDirective],
2345
- },] }
2346
- ];
2347
-
2348
- /**
2349
- * Generated bundle index. Do not edit.
2350
- */
2351
-
2352
- exports.WKLY_CLOCK = WKLY_CLOCK;
2353
- exports.WKLY_CONFIG = WKLY_CONFIG;
2354
- exports.WKLY_LOCALIZATION = WKLY_LOCALIZATION;
2355
- exports.WKLY_TRANSLATIONS = WKLY_TRANSLATIONS;
2356
- exports.WklyDateTimePickerComponent = WklyDateTimePickerComponent;
2357
- exports.WklyDateTimePickerDialogDirective = WklyDateTimePickerDialogDirective;
2358
- exports.WklyDateTimePickerDialogService = WklyDateTimePickerDialogService;
2359
- exports.WklyDateTimePickerModule = WklyDateTimePickerModule;
2360
- exports.WklyFieldComponent = WklyFieldComponent;
2361
- exports.WklyPickerInputs = WklyPickerInputs;
2362
- exports.WklyTriggerBase = WklyTriggerBase;
2363
- Object.keys(presentation).forEach(function (k) {
2364
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
2365
- enumerable: true,
2366
- get: function () { return presentation[k]; }
2367
- });
2368
- });
2369
-
2370
- Object.defineProperty(exports, '__esModule', { value: true });
2371
-
2372
- }));
2373
- //# sourceMappingURL=wkly-datetime-picker.umd.js.map