@wkly/datetime-picker 12.1.0 → 13.1.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 +960 -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 +1629 -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 +1627 -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 -2378
  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 -934
  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 -1720
  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,2378 +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
- var hourCycle = this[presentation.WklyPickerInputsPropertyKeys.HourCycle];
962
- // Host value/configuration feedback must retain the user's switchable format.
963
- if (hourCycle !== "switchable" || this.configuredHourCycle !== hourCycle) {
964
- this.effectiveHourCycle =
965
- hourCycle === "h12"
966
- ? "h12"
967
- : hourCycle === "locale"
968
- ? new Intl.DateTimeFormat(this.effectiveLocale, {
969
- hour: "numeric",
970
- timeZone: "UTC",
971
- }).resolvedOptions().hour12
972
- ? "h12"
973
- : "h24"
974
- : "h24";
975
- }
976
- this.configuredHourCycle = hourCycle;
977
- this.weekdays = Array.from({ length: 7 }, function (_, i) { return _this.adapter.formatWeekday(_this.effectiveOffset + i, "short"); });
978
- };
979
- WklyDateTimePickerComponent.prototype.setSupportedScrollRange = function () {
980
- var _this = this;
981
- var _c = __read(this.adapter.supportedEpochDayRange, 2), first = _c[0], last = _c[1];
982
- var _d = __read(this.adapter.supportedYearRange, 2), firstYear = _d[0], lastYear = _d[1];
983
- var yearOf = function (day) { return _this.adapter.epochDayToDate(day).year; };
984
- if (yearOf(first) < firstYear) {
985
- var low = first, high = last;
986
- while (low < high) {
987
- var mid = Math.floor((low + high) / 2);
988
- if (yearOf(mid) < firstYear)
989
- low = mid + 1;
990
- else
991
- high = mid;
992
- }
993
- first = low;
994
- }
995
- if (yearOf(last) > lastYear) {
996
- var low = first, high = last;
997
- while (low < high) {
998
- var mid = Math.ceil((low + high) / 2);
999
- if (yearOf(mid) > lastYear)
1000
- high = mid - 1;
1001
- else
1002
- low = mid;
1003
- }
1004
- last = low;
1005
- }
1006
- if (first > last ||
1007
- yearOf(first) < firstYear ||
1008
- yearOf(first) > lastYear ||
1009
- yearOf(last) < firstYear ||
1010
- yearOf(last) > lastYear)
1011
- throw new RangeError("No supported days within the calendar year range");
1012
- this.firstSupportedDay = first;
1013
- this.lastSupportedDay = last;
1014
- this.firstSupportedWeek = core.absoluteWeekOf(first, this.effectiveOffset);
1015
- this.lastSupportedWeek = core.absoluteWeekOf(last, this.effectiveOffset);
1016
- };
1017
- WklyDateTimePickerComponent.prototype.clampFirstWeek = function (week) {
1018
- // Keep supported weeks inside the viewport; renderRows adds the buffer rows.
1019
- var last = Math.max(this.firstSupportedWeek, this.lastSupportedWeek - this.visibleCount + 1);
1020
- return Math.max(this.firstSupportedWeek, Math.min(last, week));
1021
- };
1022
- WklyDateTimePickerComponent.prototype.ngAfterViewInit = function () {
1023
- var _this = this;
1024
- this.resetScroll();
1025
- if (this.browser && typeof ResizeObserver !== "undefined") {
1026
- this.observer = new ResizeObserver(function () {
1027
- _this.compact = _this.host.nativeElement.clientWidth < 338;
1028
- var row = _this.host.nativeElement.querySelector(".week-row");
1029
- // CSS heights and scrollTop use layout pixels; client rectangles include zoom.
1030
- var height = row ? parseFloat(getComputedStyle(row).height) : 0;
1031
- if (height && height !== _this.rowHeight) {
1032
- _this.rowHeight = height;
1033
- _this.scrollHeight = _this.rowHeight * 2001;
1034
- _this.renderRows();
1035
- _this.resetScroll();
1036
- }
1037
- });
1038
- this.observer.observe(this.host.nativeElement);
1039
- }
1040
- };
1041
- WklyDateTimePickerComponent.prototype.ngOnDestroy = function () {
1042
- this.destroyed = true;
1043
- if (this.observer)
1044
- this.observer.disconnect();
1045
- if (this.scrollEndTimer)
1046
- clearTimeout(this.scrollEndTimer);
1047
- if (this.generator)
1048
- this.generator.clearCache();
1049
- };
1050
- WklyDateTimePickerComponent.prototype.t = function (key) {
1051
- return presentation.resolveWklyTranslation(key, this.effectiveLocale, this[presentation.WklyPickerInputsPropertyKeys.Translations] ||
1052
- this.defaultTranslations, this.strings);
1053
- };
1054
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "isRange", {
1055
- get: function () {
1056
- return this[presentation.WklyPickerInputsPropertyKeys.Mode].endsWith("-range");
1057
- },
1058
- enumerable: false,
1059
- configurable: true
1060
- });
1061
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "hasDate", {
1062
- get: function () {
1063
- return !this[presentation.WklyPickerInputsPropertyKeys.Mode].startsWith("time");
1064
- },
1065
- enumerable: false,
1066
- configurable: true
1067
- });
1068
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "hasTime", {
1069
- get: function () {
1070
- return (this[presentation.WklyPickerInputsPropertyKeys.Mode] !== "date" &&
1071
- this[presentation.WklyPickerInputsPropertyKeys.Mode] !== "date-range");
1072
- },
1073
- enumerable: false,
1074
- configurable: true
1075
- });
1076
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "submitVisible", {
1077
- get: function () {
1078
- return (this.presentation === "transient" &&
1079
- (this[presentation.WklyPickerInputsPropertyKeys.Mode] !== "date" ||
1080
- this.viewMode === "manual"));
1081
- },
1082
- enumerable: false,
1083
- configurable: true
1084
- });
1085
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "title", {
1086
- get: function () {
1087
- try {
1088
- var d = this.adapter.epochDayToDate(Math.max(this.firstSupportedDay, Math.min(this.lastSupportedDay, core.firstEpochDayOf(this.anchorWeek, this.effectiveOffset))));
1089
- return this.adapter.formatMonth(d) + " " + this.adapter.formatYear(d);
1090
- }
1091
- catch (_) {
1092
- return "";
1093
- }
1094
- },
1095
- enumerable: false,
1096
- configurable: true
1097
- });
1098
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "canSubmit", {
1099
- get: function () {
1100
- return (!this[presentation.WklyPickerInputsPropertyKeys.Disabled] &&
1101
- !this.errors.length &&
1102
- this.pendingValue !== null);
1103
- },
1104
- enumerable: false,
1105
- configurable: true
1106
- });
1107
- WklyDateTimePickerComponent.prototype.blank = function (day) {
1108
- var safe = Math.max(this.firstSupportedDay, Math.min(this.lastSupportedDay, day));
1109
- return {
1110
- date: this.adapter.epochDayToDate(safe),
1111
- hour: 0,
1112
- minute: 0,
1113
- second: 0,
1114
- present: false,
1115
- };
1116
- };
1117
- WklyDateTimePickerComponent.prototype.load = function (value) {
1118
- var _this = this;
1119
- this.drafts = [this.blank(this.focused), this.blank(this.focused)];
1120
- var validation = adapters.validateSelection(value, this, this.adapter);
1121
- if (value !== null && !validation.length) {
1122
- var values = typeof value === "string" ? [value] : value;
1123
- values.forEach(function (v, i) {
1124
- var d = adapters.decodeIso(v);
1125
- _this.drafts[i] = {
1126
- date: _this.hasDate
1127
- ? _this.adapter.epochDayToDate(d.epochDay)
1128
- : _this.blank(_this.today).date,
1129
- hour: d.hour,
1130
- minute: d.minute,
1131
- second: d.second,
1132
- present: true,
1133
- };
1134
- if (i === 0 && _this.hasDate)
1135
- _this.focused = d.epochDay;
1136
- });
1137
- }
1138
- if (validation.length) {
1139
- this.pendingValue = null;
1140
- this.report(validation);
1141
- }
1142
- else
1143
- this.check();
1144
- };
1145
- WklyDateTimePickerComponent.prototype.writeValue = function (value) {
1146
- this[presentation.WklyPickerInputsPropertyKeys.Value] = value;
1147
- if (this.initialized) {
1148
- this.load(value);
1149
- this.position(this.focused, true);
1150
- }
1151
- };
1152
- WklyDateTimePickerComponent.prototype.registerOnChange = function (fn) {
1153
- this.onChange = fn;
1154
- };
1155
- WklyDateTimePickerComponent.prototype.registerOnTouched = function (fn) {
1156
- this.onTouched = fn;
1157
- };
1158
- WklyDateTimePickerComponent.prototype.setDisabledState = function (disabled) {
1159
- this[presentation.WklyPickerInputsPropertyKeys.Disabled] = disabled;
1160
- };
1161
- WklyDateTimePickerComponent.prototype.validate = function (_control) {
1162
- return this.errors.length ? { wkly: this.errors } : null;
1163
- };
1164
- WklyDateTimePickerComponent.prototype.registerOnValidatorChange = function (fn) {
1165
- this.validatorChanged = fn;
1166
- };
1167
- WklyDateTimePickerComponent.prototype.touched = function () {
1168
- var _this = this;
1169
- Promise.resolve().then(function () { return _this.onTouched(); });
1170
- };
1171
- WklyDateTimePickerComponent.prototype.report = function (errors) {
1172
- var changed = JSON.stringify(this.errors) !== JSON.stringify(errors);
1173
- this.errors = errors;
1174
- if (changed) {
1175
- this[presentation.WklyPickerOutputsPropertyKeys.ValidationChange].emit(errors);
1176
- this.validatorChanged();
1177
- }
1178
- };
1179
- WklyDateTimePickerComponent.prototype.check = function () {
1180
- var result = presentation.validateDrafts({
1181
- drafts: this.drafts,
1182
- configErrors: this.configErrors,
1183
- adapter: this.adapter,
1184
- selection: this,
1185
- mode: this[presentation.WklyPickerInputsPropertyKeys.Mode],
1186
- isRange: this.isRange,
1187
- hasDate: this.hasDate,
1188
- hasTime: this.hasTime,
1189
- showSeconds: this[presentation.WklyPickerInputsPropertyKeys.ShowSeconds],
1190
- required: this[presentation.WklyPickerInputsPropertyKeys.Required],
1191
- });
1192
- this.pendingValue = result.pendingValue;
1193
- this.report(result.errors);
1194
- };
1195
- WklyDateTimePickerComponent.prototype.trackDraft = function (index) {
1196
- // Endpoint controls keep their identity and focus when draft objects swap.
1197
- return index;
1198
- };
1199
- WklyDateTimePickerComponent.prototype.orderDrafts = function () {
1200
- var _this = this;
1201
- if (!this.isRange || !this.drafts.every(function (draft) { return draft.present; }))
1202
- return;
1203
- if (this.drafts.some(function (draft) { return draft.unsupportedEpochDay !== undefined; }))
1204
- return;
1205
- try {
1206
- var a = this.drafts[0], b = this.drafts[1];
1207
- var key = function (d) { return _this.adapter.dateToEpochDay(d.date) * 86400 +
1208
- (d.hour || 0) * 3600 +
1209
- (d.minute || 0) * 60 +
1210
- (d.second || 0); };
1211
- if (key(a) > key(b))
1212
- this.drafts = [b, a];
1213
- }
1214
- catch (_) {
1215
- // Impossible or incomplete dates remain editable until corrected.
1216
- }
1217
- };
1218
- WklyDateTimePickerComponent.prototype.finish = function () {
1219
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1220
- return;
1221
- this.orderDrafts();
1222
- if (this.viewMode === "manual" && this.hasDate)
1223
- this.positionOnManualDate();
1224
- this.check();
1225
- if (this.presentation === "inline" && this.canSubmit)
1226
- this.commit();
1227
- };
1228
- WklyDateTimePickerComponent.prototype.commit = function () {
1229
- if (!this.canSubmit)
1230
- return;
1231
- var next = this.pendingValue;
1232
- if (JSON.stringify(next) !==
1233
- JSON.stringify(this[presentation.WklyPickerInputsPropertyKeys.Value])) {
1234
- this[presentation.WklyPickerInputsPropertyKeys.Value] = next;
1235
- this.emittedValue = JSON.stringify(next);
1236
- this.onChange(next);
1237
- this[presentation.WklyPickerOutputsPropertyKeys.ValueChange].emit(next);
1238
- }
1239
- this.onTouched();
1240
- };
1241
- WklyDateTimePickerComponent.prototype.submit = function (reason) {
1242
- if (reason === void 0) { reason = "submit"; }
1243
- this.check();
1244
- if (!this.canSubmit)
1245
- return;
1246
- this.commit();
1247
- if (this.presentation === "transient")
1248
- this[presentation.WklyPickerOutputsPropertyKeys.Closed].emit(reason);
1249
- };
1250
- WklyDateTimePickerComponent.prototype.cancel = function (reason) {
1251
- if (reason === void 0) { reason = "close-button"; }
1252
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1253
- return;
1254
- this.load(this[presentation.WklyPickerInputsPropertyKeys.Value]);
1255
- this.onTouched();
1256
- this[presentation.WklyPickerOutputsPropertyKeys.Closed].emit(reason);
1257
- };
1258
- WklyDateTimePickerComponent.prototype.now = function () {
1259
- var _this = this;
1260
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1261
- return;
1262
- var n = this.clock.now();
1263
- var day = Math.floor(n.getTime() / 86400000);
1264
- this.drafts = [0, 1].map(function (index) { return (Object.assign(Object.assign({}, _this.clockDraft(day, n)), { present: index === 0 || _this.isRange })); });
1265
- if (this.hasDate &&
1266
- (day < this.firstSupportedDay || day > this.lastSupportedDay)) {
1267
- this.report([adapters.error("unsupported-adapter-date", day)]);
1268
- return;
1269
- }
1270
- this.focused = day;
1271
- this.position(day, true);
1272
- this.check();
1273
- this.submit("now");
1274
- };
1275
- WklyDateTimePickerComponent.prototype.clockDraft = function (day, now) {
1276
- 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]
1277
- ? Math.floor(now.getUTCSeconds() / this[presentation.WklyPickerInputsPropertyKeys.SecondStep]) * this[presentation.WklyPickerInputsPropertyKeys.SecondStep]
1278
- : 0 });
1279
- };
1280
- WklyDateTimePickerComponent.prototype.initializeManualRange = function () {
1281
- if (!this.isRange ||
1282
- !this.hasDate ||
1283
- this.drafts.every(function (draft) { return draft.present; }))
1284
- return;
1285
- var seed = this.drafts.find(function (draft) { return draft.present; });
1286
- if (!seed) {
1287
- if (this[presentation.WklyPickerInputsPropertyKeys.Value] !== null)
1288
- return;
1289
- var now = this.clock.now();
1290
- var initialEpochDay = this[presentation.WklyPickerInputsPropertyKeys.InitialEpochDay];
1291
- var day = initialEpochDay === null
1292
- ? this.defaults.initialEpochDay === undefined
1293
- ? Math.floor(now.getTime() / 86400000)
1294
- : this.defaults.initialEpochDay
1295
- : initialEpochDay;
1296
- seed = Object.assign(Object.assign({}, this.clockDraft(day, now)), { present: true });
1297
- }
1298
- // Complete missing endpoints without replacing selected or invalid drafts.
1299
- var initial = seed;
1300
- this.drafts = this.drafts.map(function (draft) { return draft.present ? draft : Object.assign(Object.assign({}, initial), { date: Object.assign({}, initial.date) }); });
1301
- this.finish();
1302
- // Positioning renders before validation; refresh completion controls afterward.
1303
- this.changeDetector.markForCheck();
1304
- };
1305
- WklyDateTimePickerComponent.prototype.toggleView = function () {
1306
- var _this = this;
1307
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled] || !this.hasDate)
1308
- return;
1309
- this.viewMode = this.viewMode === "calendar" ? "manual" : "calendar";
1310
- if (this.viewMode === "manual")
1311
- this.initializeManualRange();
1312
- if (this.viewMode === "calendar")
1313
- this.positionOnManualDate();
1314
- this[presentation.WklyPickerOutputsPropertyKeys.ViewModeChange].emit(this.viewMode);
1315
- if (this.viewMode === "calendar")
1316
- setTimeout(function () { return _this.resetScroll(); });
1317
- };
1318
- WklyDateTimePickerComponent.prototype.positionOnManualDate = function () {
1319
- var draft = this.drafts[this.manualDateEndpoint];
1320
- if (!draft || !draft.present)
1321
- return;
1322
- try {
1323
- // A valid day follows the selection. An impossible day keeps its draft
1324
- // fields but still shows the chosen month in the calendar.
1325
- var target = this.adapter.dateToEpochDay(draft.date);
1326
- this.focused = target;
1327
- this.position(target, true);
1328
- }
1329
- catch (_) {
1330
- try {
1331
- var first = this.adapter.dateToEpochDay(Object.assign(Object.assign({}, draft.date), { day: 1 }));
1332
- this.focused = first;
1333
- this.position(first, true);
1334
- }
1335
- catch (_) { }
1336
- }
1337
- };
1338
- WklyDateTimePickerComponent.prototype.months = function (draft) {
1339
- try {
1340
- return this.adapter.getMonths(draft.date.year).map(function (m) { return m.label; });
1341
- }
1342
- catch (_) {
1343
- return [];
1344
- }
1345
- };
1346
- WklyDateTimePickerComponent.prototype.monthCount = function (draft) {
1347
- return this.months(draft).length || 12;
1348
- };
1349
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "inDays", {
1350
- get: function () {
1351
- return presentation.draftDayDifference(this.drafts, this.adapter);
1352
- },
1353
- enumerable: false,
1354
- configurable: true
1355
- });
1356
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "inDaysLabel", {
1357
- get: function () {
1358
- var days = this.inDays;
1359
- return this.t("inDays").replace(/{{\s*days\s*}}/g, days === null
1360
- ? this.t("daysUnavailable")
1361
- : new Intl.NumberFormat(this.effectiveLocale, {
1362
- useGrouping: false,
1363
- }).format(days));
1364
- },
1365
- enumerable: false,
1366
- configurable: true
1367
- });
1368
- Object.defineProperty(WklyDateTimePickerComponent.prototype, "resultingEndDate", {
1369
- get: function () {
1370
- try {
1371
- var draft = this.drafts[1];
1372
- if (draft.unsupportedEpochDay !== undefined ||
1373
- this.adapter.validateDate(draft.date).length)
1374
- return "";
1375
- return [
1376
- this.adapter.formatDay(draft.date),
1377
- this.adapter.formatMonth(draft.date),
1378
- this.adapter.formatYear(draft.date),
1379
- ].join(" ");
1380
- }
1381
- catch (_) {
1382
- return "";
1383
- }
1384
- },
1385
- enumerable: false,
1386
- configurable: true
1387
- });
1388
- WklyDateTimePickerComponent.prototype.toggleEndView = function (view) {
1389
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1390
- return;
1391
- this.endView = view;
1392
- };
1393
- WklyDateTimePickerComponent.prototype.days = function (value) {
1394
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1395
- return;
1396
- this.manualDateEndpoint = 1;
1397
- presentation.setDraftDayDifference(this.drafts, this.adapter, value);
1398
- this.check();
1399
- };
1400
- WklyDateTimePickerComponent.prototype.field = function (index, field, value) {
1401
- var _c;
1402
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1403
- return;
1404
- var draft = this.drafts[index];
1405
- draft.present = true;
1406
- if (field === "day" || field === "year" || field === "month") {
1407
- this.manualDateEndpoint = index;
1408
- delete draft.unsupportedEpochDay;
1409
- var date_1 = Object.assign(Object.assign({}, draft.date), (_c = {}, _c[field] = value, _c));
1410
- if (field === "month") {
1411
- var month = void 0;
1412
- try {
1413
- month = this.adapter
1414
- .getMonths(date_1.year)
1415
- .find(function (m) { return m.month === value; });
1416
- }
1417
- catch (_) { }
1418
- date_1 = Object.assign(Object.assign({}, date_1), { monthCode: month ? month.monthCode : "" });
1419
- }
1420
- if (field === "year" && value !== null) {
1421
- try {
1422
- var months = this.adapter.getMonths(value);
1423
- var month = months.find(function (m) { return m.monthCode === date_1.monthCode; });
1424
- if (month)
1425
- date_1 = Object.assign(Object.assign({}, date_1), { month: month.month });
1426
- }
1427
- catch (_) { }
1428
- }
1429
- draft.date = date_1;
1430
- }
1431
- else if (field === "hour" && this.effectiveHourCycle === "h12")
1432
- draft.hour =
1433
- value === null
1434
- ? null
1435
- : value >= 1 && value <= 12
1436
- ? (value % 12) + ((draft.hour || 0) >= 12 ? 12 : 0)
1437
- : 24 + value;
1438
- else
1439
- draft[field] = value;
1440
- this.check();
1441
- };
1442
- WklyDateTimePickerComponent.prototype.displayHour = function (draft) {
1443
- return draft.hour === null
1444
- ? null
1445
- : this.effectiveHourCycle === "h12"
1446
- ? draft.hour % 12 || 12
1447
- : draft.hour;
1448
- };
1449
- WklyDateTimePickerComponent.prototype.period = function (index, period) {
1450
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1451
- return;
1452
- if (period === "24")
1453
- this.effectiveHourCycle = "h24";
1454
- else {
1455
- this.effectiveHourCycle = "h12";
1456
- this.drafts[index].hour =
1457
- ((this.drafts[index].hour || 0) % 12) + (period === "pm" ? 12 : 0);
1458
- this.drafts[index].present = true;
1459
- this.finish();
1460
- }
1461
- };
1462
- WklyDateTimePickerComponent.prototype.selected = function (day) {
1463
- var _this = this;
1464
- return this.drafts.some(function (d) {
1465
- try {
1466
- return d.present && _this.adapter.dateToEpochDay(d.date) === day;
1467
- }
1468
- catch (_) {
1469
- return false;
1470
- }
1471
- });
1472
- };
1473
- WklyDateTimePickerComponent.prototype.inRange = function (day) {
1474
- if (!this.isRange || !this.drafts.every(function (d) { return d.present; }))
1475
- return false;
1476
- try {
1477
- var a = this.adapter.dateToEpochDay(this.drafts[0].date), b = this.adapter.dateToEpochDay(this.drafts[1].date);
1478
- return day > Math.min(a, b) && day < Math.max(a, b);
1479
- }
1480
- catch (_) {
1481
- return false;
1482
- }
1483
- };
1484
- WklyDateTimePickerComponent.prototype.dayDisabled = function (day) {
1485
- var _a, _b;
1486
- if (day < this.firstSupportedDay || day > this.lastSupportedDay)
1487
- return true;
1488
- try {
1489
- var date = this.adapter.epochDayToDate(day);
1490
- var isDateDisabled = this[presentation.WklyPickerInputsPropertyKeys.IsDateDisabled];
1491
- if (isDateDisabled &&
1492
- isDateDisabled(day, {
1493
- mode: this[presentation.WklyPickerInputsPropertyKeys.Mode],
1494
- endpoint: this.isRange
1495
- ? ((_a = this.drafts[0]) === null || _a === void 0 ? void 0 : _a.present) && !((_b = this.drafts[1]) === null || _b === void 0 ? void 0 : _b.present)
1496
- ? "end"
1497
- : "start"
1498
- : "single",
1499
- calendarDate: date,
1500
- }))
1501
- return true;
1502
- var min = this[presentation.WklyPickerInputsPropertyKeys.Min];
1503
- var max = this[presentation.WklyPickerInputsPropertyKeys.Max];
1504
- if (min && day < adapters.decodeIso(min).epochDay)
1505
- return true;
1506
- if (max && day > adapters.decodeIso(max).epochDay)
1507
- return true;
1508
- return false;
1509
- }
1510
- catch (_) {
1511
- return true;
1512
- }
1513
- };
1514
- WklyDateTimePickerComponent.prototype.select = function (day) {
1515
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled] || this.dayDisabled(day))
1516
- return;
1517
- this.focused = day;
1518
- var index = this.isRange && this.drafts[0].present && !this.drafts[1].present ? 1 : 0;
1519
- if (this.isRange && index === 0)
1520
- this.drafts[1].present = false;
1521
- delete this.drafts[index].unsupportedEpochDay;
1522
- this.drafts[index].date = this.adapter.epochDayToDate(day);
1523
- this.drafts[index].present = true;
1524
- this.orderDrafts();
1525
- this.renderRows();
1526
- this.finish();
1527
- if (this.presentation === "transient" &&
1528
- this[presentation.WklyPickerInputsPropertyKeys.Mode] === "date" &&
1529
- this.viewMode === "calendar")
1530
- this.submit("auto-submit");
1531
- };
1532
- WklyDateTimePickerComponent.prototype.key = function (event, day) {
1533
- var delta = 0;
1534
- if (event.key === "ArrowLeft")
1535
- delta = -1;
1536
- if (event.key === "ArrowRight")
1537
- delta = 1;
1538
- if (event.key === "ArrowUp")
1539
- delta = -7;
1540
- if (event.key === "ArrowDown")
1541
- delta = 7;
1542
- if (event.key === "PageUp")
1543
- delta = -7 * (event.shiftKey ? this.visibleCount : 1);
1544
- if (event.key === "PageDown")
1545
- delta = 7 * (event.shiftKey ? this.visibleCount : 1);
1546
- if (event.key === "Home") {
1547
- event.preventDefault();
1548
- this.scrollToEpochDay(this.today, { focus: true });
1549
- }
1550
- if (delta) {
1551
- event.preventDefault();
1552
- var target = day + delta;
1553
- if (target >= this.firstSupportedDay && target <= this.lastSupportedDay)
1554
- this.scrollToEpochDay(target, { focus: true });
1555
- }
1556
- };
1557
- WklyDateTimePickerComponent.prototype.position = function (day, preset, options) {
1558
- if (preset === void 0) { preset = false; }
1559
- if (options === void 0) { options = {}; }
1560
- day = Math.max(this.firstSupportedDay, Math.min(this.lastSupportedDay, day));
1561
- this.anchorWeek = core.absoluteWeekOf(day, this.effectiveOffset);
1562
- var viewportPreset = this[presentation.WklyPickerInputsPropertyKeys.ViewportPreset];
1563
- this.clipMonth = preset && viewportPreset.kind === "full-month";
1564
- if (preset && viewportPreset.kind !== "weeks") {
1565
- var d = this.adapter.epochDayToDate(day);
1566
- this.initialMonth = d.year + "/" + d.monthCode;
1567
- var _c = __read(presentation.calendarMonthBounds(this.adapter, day), 2), start = _c[0], end = _c[1];
1568
- this.firstWeek = core.absoluteWeekOf(start, this.effectiveOffset);
1569
- this.visibleCount =
1570
- core.absoluteWeekOf(end, this.effectiveOffset) - this.firstWeek + 1;
1571
- if (viewportPreset.kind === "full-month-and-around" &&
1572
- !this.configErrors.length) {
1573
- var before = viewportPreset.extraWeeksBefore || 0, after = viewportPreset.extraWeeksAfter || 0;
1574
- this.firstWeek -= before;
1575
- this.visibleCount += before + after;
1576
- }
1577
- }
1578
- else {
1579
- if (viewportPreset.kind === "weeks")
1580
- this.visibleCount = this.configErrors.length
1581
- ? 6
1582
- : viewportPreset.visibleWeekCount;
1583
- this.firstWeek =
1584
- this.anchorWeek -
1585
- (options.align === "start"
1586
- ? 0
1587
- : options.align === "end"
1588
- ? this.visibleCount - 1
1589
- : Math.floor(this.visibleCount / 2));
1590
- }
1591
- this.firstWeek = this.clampFirstWeek(this.firstWeek);
1592
- this.baseWeek = this.firstWeek - 1000;
1593
- this.renderRows();
1594
- // Apply the new runway before writing scrollTop or locating a focus target.
1595
- this.changeDetector.detectChanges();
1596
- this.resetScroll();
1597
- };
1598
- WklyDateTimePickerComponent.prototype.resetScroll = function () {
1599
- // Round week boundaries to avoid scrollTop truncation under CSS zoom.
1600
- if (this.scroller)
1601
- this.scroller.nativeElement.scrollTop = Math.round(1000 * this.rowHeight);
1602
- };
1603
- WklyDateTimePickerComponent.prototype.scroll = function (event) {
1604
- var element = event.target;
1605
- this.snapPending = true;
1606
- this.scheduleSnap();
1607
- // Quantize displacement around the reset point, equally in both directions.
1608
- var relativeRows = element.scrollTop / this.rowHeight - 1000;
1609
- var index = 1000 + Math.sign(relativeRows) * Math.round(Math.abs(relativeRows));
1610
- var requestedFirst = this.baseWeek + index;
1611
- var first = this.clampFirstWeek(requestedFirst);
1612
- if (requestedFirst !== first) {
1613
- element.scrollTop = Math.round((first - this.baseWeek) * this.rowHeight);
1614
- }
1615
- if (first === this.firstWeek)
1616
- return;
1617
- this.clipMonth = false;
1618
- this.firstWeek = first;
1619
- this.anchorWeek = first + Math.floor(this.visibleCount / 2);
1620
- if (index < 100 || index > 1900) {
1621
- // Preserve signed displacement from this week; modulo turns fractional
1622
- // rounding just below a boundary into almost a full row after rebasing.
1623
- var offset = element.scrollTop - (first - this.baseWeek) * this.rowHeight;
1624
- this.baseWeek = first - 1000;
1625
- element.scrollTop = Math.round(1000 * this.rowHeight + offset);
1626
- }
1627
- this.renderRows();
1628
- };
1629
- WklyDateTimePickerComponent.prototype.scheduleSnap = function () {
1630
- var _this = this;
1631
- if (this.scrollEndTimer)
1632
- clearTimeout(this.scrollEndTimer);
1633
- this.scrollEndTimer = setTimeout(function () { return _this.snapWeek(); }, 200);
1634
- };
1635
- WklyDateTimePickerComponent.prototype.snapWeek = function () {
1636
- if (this.scrollEndTimer)
1637
- clearTimeout(this.scrollEndTimer);
1638
- this.scrollEndTimer = undefined;
1639
- if (!this.snapPending || !this.scroller)
1640
- return;
1641
- this.snapPending = false;
1642
- // Align the current virtual week without rebuilding or rebasing its rows.
1643
- var element = this.scroller.nativeElement;
1644
- var target = Math.round((this.firstWeek - this.baseWeek) * this.rowHeight);
1645
- if (element.scrollTop !== target)
1646
- element.scrollTop = target;
1647
- };
1648
- WklyDateTimePickerComponent.prototype.showFirstWeek = function (week) {
1649
- var first = this.clampFirstWeek(week);
1650
- if (first === this.firstWeek)
1651
- return;
1652
- this.clipMonth = false;
1653
- this.firstWeek = first;
1654
- this.anchorWeek = first + Math.floor(this.visibleCount / 2);
1655
- this.baseWeek = first - 1000;
1656
- this.renderRows();
1657
- this.resetScroll();
1658
- };
1659
- WklyDateTimePickerComponent.prototype.canMoveWeek = function (delta) {
1660
- return this.clampFirstWeek(this.firstWeek + delta) !== this.firstWeek;
1661
- };
1662
- WklyDateTimePickerComponent.prototype.moveWeek = function (delta) {
1663
- if (!this[presentation.WklyPickerInputsPropertyKeys.Disabled])
1664
- this.showFirstWeek(this.firstWeek + delta);
1665
- };
1666
- WklyDateTimePickerComponent.prototype.renderRows = function () {
1667
- var _this = this;
1668
- // Keep the virtual scroll offset here; row data is shared across Angular versions.
1669
- var overscan = Math.max(0, Math.min(50, this[presentation.WklyPickerInputsPropertyKeys.OverscanWeeks] || 0));
1670
- var start = this.firstWeek - overscan;
1671
- this.paddingTop = (start - this.baseWeek) * this.rowHeight;
1672
- this.rows = presentation.createWeekRows({
1673
- generator: this.generator,
1674
- adapter: this.adapter,
1675
- startWeek: start,
1676
- count: this.visibleCount + 2 * overscan,
1677
- firstVisibleWeek: this.firstWeek,
1678
- firstSupportedDay: this.firstSupportedDay,
1679
- lastSupportedDay: this.lastSupportedDay,
1680
- clipMonth: this.clipMonth,
1681
- initialMonth: this.initialMonth,
1682
- weekLabelMode: this[presentation.WklyPickerInputsPropertyKeys.WeekLabelMode],
1683
- weekLabelFormatter: this[presentation.WklyPickerInputsPropertyKeys.WeekLabelFormatter] || null,
1684
- isDayDisabled: function (day) { return _this.dayDisabled(day); },
1685
- });
1686
- this[presentation.WklyPickerOutputsPropertyKeys.ViewportChange].emit({
1687
- firstVisibleAbsoluteWeek: this.firstWeek,
1688
- lastVisibleAbsoluteWeek: this.firstWeek + this.visibleCount - 1,
1689
- anchorAbsoluteWeek: this.anchorWeek,
1690
- });
1691
- };
1692
- // Retain day DOM nodes and keyboard focus when row metadata is regenerated.
1693
- WklyDateTimePickerComponent.prototype.trackCell = function (_i, cell) {
1694
- return cell.epochDay;
1695
- };
1696
- WklyDateTimePickerComponent.prototype.trackRow = function (_i, row) {
1697
- return row.week.absoluteWeek;
1698
- };
1699
- WklyDateTimePickerComponent.prototype.scrollToEpochDay = function (day, options) {
1700
- if (options === void 0) { options = {}; }
1701
- core.integer(day);
1702
- this.adapter.epochDayToDate(day);
1703
- day = Math.max(this.firstSupportedDay, Math.min(this.lastSupportedDay, day));
1704
- // position renders synchronously; publish the tab stop before that render.
1705
- if (options.focus)
1706
- this.focused = day;
1707
- this.position(day, false, options);
1708
- if (options.select)
1709
- this.select(day);
1710
- if (options.focus)
1711
- this.focusDay();
1712
- };
1713
- WklyDateTimePickerComponent.prototype.scrollToAbsoluteWeek = function (week, options) {
1714
- if (options === void 0) { options = {}; }
1715
- // A boundary week can start before the adapter's first supported day.
1716
- var first = core.firstEpochDayOf(week, this.effectiveOffset);
1717
- this.scrollToEpochDay(week === this.firstSupportedWeek
1718
- ? Math.max(first, this.firstSupportedDay)
1719
- : first, options);
1720
- };
1721
- WklyDateTimePickerComponent.prototype.scrollToCalendarDate = function (date, options) {
1722
- if (options === void 0) { options = {}; }
1723
- this.scrollToEpochDay(this.adapter.dateToEpochDay(date), options);
1724
- };
1725
- WklyDateTimePickerComponent.prototype.scrollToValue = function (value, options) {
1726
- if (options === void 0) { options = {}; }
1727
- this.scrollToEpochDay(adapters.decodeIso(value).epochDay, options);
1728
- };
1729
- WklyDateTimePickerComponent.prototype.focusDay = function () {
1730
- var _this = this;
1731
- if (!this.browser)
1732
- return;
1733
- setTimeout(function () {
1734
- var _a;
1735
- if (_this.destroyed)
1736
- return;
1737
- _this.changeDetector.detectChanges();
1738
- var day = _this.host.nativeElement.querySelector('[data-day="' + _this.focused + '"]');
1739
- var fallback = _this.host.nativeElement.querySelector("button:not(:disabled),input:not(:disabled)");
1740
- (_a = (day || fallback)) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
1741
- });
1742
- };
1743
- return WklyDateTimePickerComponent;
1744
- }(WklyPickerInputs));
1745
- WklyDateTimePickerComponent.decorators = [
1746
- { type: i0.Component, args: [{
1747
- selector: "wkly-datetime-picker",
1748
- 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",
1749
- providers: [
1750
- {
1751
- provide: forms.NG_VALUE_ACCESSOR,
1752
- useExisting: i0.forwardRef(function () { return WklyDateTimePickerComponent; }),
1753
- multi: true,
1754
- },
1755
- {
1756
- provide: forms.NG_VALIDATORS,
1757
- useExisting: i0.forwardRef(function () { return WklyDateTimePickerComponent; }),
1758
- multi: true,
1759
- },
1760
- ],
1761
- 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}@media (hover: hover) and (pointer: fine){button:hover:not(:disabled):not([aria-disabled=\"true\"]):not(.selected){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}@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"]
1762
- },] }
1763
- ];
1764
- WklyDateTimePickerComponent.ctorParameters = function () { return [
1765
- { type: String, decorators: [{ type: i0.Inject, args: [i0.LOCALE_ID,] }] },
1766
- { type: undefined, decorators: [{ type: i0.Inject, args: [WKLY_CONFIG,] }] },
1767
- { type: undefined, decorators: [{ type: i0.Inject, args: [WKLY_CLOCK,] }] },
1768
- { type: undefined, decorators: [{ type: i0.Inject, args: [WKLY_LOCALIZATION,] }] },
1769
- { type: undefined, decorators: [{ type: i0.Inject, args: [WKLY_TRANSLATIONS,] }] },
1770
- { type: Object, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] },
1771
- { type: i0.ElementRef },
1772
- { type: i0.ChangeDetectorRef }
1773
- ]; };
1774
- WklyDateTimePickerComponent.propDecorators = {
1775
- scroller: [{ type: i0.ViewChild, args: ["scroller",] }]
1776
- };
1777
-
1778
- /** Native-dialog factory. Browser resources are allocated only by open(). */
1779
- var WklyDateTimePickerDialogService = /** @class */ (function () {
1780
- function WklyDateTimePickerDialogService(resolver, injector, app, document, platform) {
1781
- this.resolver = resolver;
1782
- this.injector = injector;
1783
- this.app = app;
1784
- this.document = document;
1785
- this.platform = platform;
1786
- }
1787
- WklyDateTimePickerDialogService.prototype.open = function (trigger, onCancel, backdrop, injector) {
1788
- var _this = this;
1789
- if (backdrop === void 0) { backdrop = true; }
1790
- if (!i1.isPlatformBrowser(this.platform))
1791
- throw new Error("Picker presentations can only open in a browser");
1792
- var dialog = this.document.createElement("dialog");
1793
- dialog.setAttribute("aria-label", "Date and time picker");
1794
- Object.assign(dialog.style, {
1795
- padding: "0",
1796
- border: "0",
1797
- borderRadius: "14px",
1798
- width: "min(390px, 100vw)",
1799
- maxWidth: "100vw",
1800
- maxHeight: "94vh",
1801
- background: "transparent",
1802
- });
1803
- var component = this.resolver
1804
- .resolveComponentFactory(WklyDateTimePickerComponent)
1805
- .create(injector || this.injector);
1806
- component.instance.presentation = "transient";
1807
- dialog.appendChild(component.location.nativeElement);
1808
- this.document.body.appendChild(dialog);
1809
- this.app.attachView(component.hostView);
1810
- var cancel = function (event) {
1811
- event.preventDefault();
1812
- onCancel("escape");
1813
- };
1814
- var click = function (event) {
1815
- if (backdrop && event.target === dialog) {
1816
- var r = dialog.getBoundingClientRect();
1817
- if (event.clientX < r.left ||
1818
- event.clientX > r.right ||
1819
- event.clientY < r.top ||
1820
- event.clientY > r.bottom)
1821
- onCancel("backdrop");
1822
- }
1823
- };
1824
- var keydown = function (event) {
1825
- if (event.key !== "Tab")
1826
- return;
1827
- var controls = Array.from(dialog.querySelectorAll('button:not(:disabled),input:not(:disabled),[tabindex="0"]')).filter(function (el) { return el.tabIndex >= 0 &&
1828
- el.getClientRects().length &&
1829
- getComputedStyle(el).visibility !== "hidden"; });
1830
- var first = controls[0], last = controls[controls.length - 1];
1831
- if (first &&
1832
- (event.shiftKey
1833
- ? _this.document.activeElement === first
1834
- : _this.document.activeElement === last)) {
1835
- event.preventDefault();
1836
- (event.shiftKey ? last : first).focus();
1837
- }
1838
- };
1839
- dialog.addEventListener("cancel", cancel);
1840
- dialog.addEventListener("click", click);
1841
- dialog.addEventListener("keydown", keydown);
1842
- dialog.showModal();
1843
- return {
1844
- component: component,
1845
- destroy: function () {
1846
- dialog.removeEventListener("cancel", cancel);
1847
- dialog.removeEventListener("click", click);
1848
- dialog.removeEventListener("keydown", keydown);
1849
- dialog.close();
1850
- _this.app.detachView(component.hostView);
1851
- component.destroy();
1852
- dialog.remove();
1853
- trigger.focus();
1854
- },
1855
- };
1856
- };
1857
- return WklyDateTimePickerDialogService;
1858
- }());
1859
- 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" });
1860
- WklyDateTimePickerDialogService.decorators = [
1861
- { type: i0.Injectable, args: [{ providedIn: "root" },] }
1862
- ];
1863
- WklyDateTimePickerDialogService.ctorParameters = function () { return [
1864
- { type: i0.ComponentFactoryResolver },
1865
- { type: i0.Injector },
1866
- { type: i0.ApplicationRef },
1867
- { type: Document, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] },
1868
- { type: Object, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] }
1869
- ]; };
1870
- /** Shared trigger lifecycle; optional presentation packages extend this class. */
1871
- var WklyTriggerBase = /** @class */ (function (_super) {
1872
- __extends(WklyTriggerBase, _super);
1873
- function WklyTriggerBase(element) {
1874
- var _this = _super.call(this) || this;
1875
- _this.element = element;
1876
- _this.ref = null;
1877
- _this.subscriptions = [];
1878
- _this.errors = [];
1879
- _this.change = function () { };
1880
- _this.touched = function () { };
1881
- _this.validation = function () { };
1882
- return _this;
1883
- }
1884
- WklyTriggerBase.prototype.open = function () {
1885
- var _this = this;
1886
- if (this[presentation.WklyPickerInputsPropertyKeys.Disabled] || this.ref)
1887
- return;
1888
- this.ref = this.create();
1889
- var picker = this.ref.component.instance;
1890
- this.copy();
1891
- this.subscriptions = [
1892
- picker[presentation.WklyPickerOutputsPropertyKeys.ValueChange].subscribe(function (value) {
1893
- _this[presentation.WklyPickerInputsPropertyKeys.Value] = value;
1894
- _this.change(value);
1895
- _this[presentation.WklyPickerOutputsPropertyKeys.ValueChange].emit(value);
1896
- _this.display();
1897
- }),
1898
- picker[presentation.WklyPickerOutputsPropertyKeys.ValidationChange].subscribe(function (errors) {
1899
- _this.errors = errors;
1900
- _this[presentation.WklyPickerOutputsPropertyKeys.ValidationChange].emit(errors);
1901
- _this.validation();
1902
- }),
1903
- picker[presentation.WklyPickerOutputsPropertyKeys.Closed].subscribe(function (reason) { return _this.close(reason); }),
1904
- picker[presentation.WklyPickerOutputsPropertyKeys.ViewportChange].subscribe(function (value) { return _this[presentation.WklyPickerOutputsPropertyKeys.ViewportChange].emit(value); }),
1905
- picker[presentation.WklyPickerOutputsPropertyKeys.ViewModeChange].subscribe(function (value) { return _this[presentation.WklyPickerOutputsPropertyKeys.ViewModeChange].emit(value); }),
1906
- ];
1907
- this.ref.component.changeDetectorRef.detectChanges();
1908
- picker.focusDay();
1909
- this[presentation.WklyPickerOutputsPropertyKeys.Opened].emit();
1910
- };
1911
- WklyTriggerBase.prototype.key = function (event) {
1912
- if (event.key === "Enter" ||
1913
- event.key === " " ||
1914
- event.key === "ArrowDown") {
1915
- event.preventDefault();
1916
- this.open();
1917
- }
1918
- };
1919
- WklyTriggerBase.prototype.blur = function () {
1920
- this.touched();
1921
- };
1922
- WklyTriggerBase.prototype.close = function (reason) {
1923
- if (reason === void 0) { reason = "programmatic"; }
1924
- if (!this.ref)
1925
- return;
1926
- var ref = this.ref;
1927
- this.ref = null;
1928
- this.subscriptions.forEach(function (s) { return s.unsubscribe(); });
1929
- this.subscriptions = [];
1930
- ref.destroy();
1931
- this.touched();
1932
- this[presentation.WklyPickerOutputsPropertyKeys.Closed].emit(reason);
1933
- };
1934
- WklyTriggerBase.prototype.ngOnChanges = function () {
1935
- var _b;
1936
- var _this = this;
1937
- [
1938
- presentation.WklyPickerInputsPropertyKeys.ShowSeconds,
1939
- presentation.WklyPickerInputsPropertyKeys.AllowRangeAcrossDisabled,
1940
- presentation.WklyPickerInputsPropertyKeys.Required,
1941
- presentation.WklyPickerInputsPropertyKeys.Disabled,
1942
- presentation.WklyPickerInputsPropertyKeys.CloseOnBackdrop,
1943
- ].forEach(function (key) { return (_this[key] = presentation.coerceBoolean(_this[key])); });
1944
- this.checkValue();
1945
- this.display();
1946
- if (this.ref) {
1947
- this.copy();
1948
- this.ref.component.instance.ngOnChanges((_b = {},
1949
- _b[presentation.WklyPickerInputsPropertyKeys.Value] = true,
1950
- _b));
1951
- this.ref.component.changeDetectorRef.detectChanges();
1952
- }
1953
- };
1954
- WklyTriggerBase.prototype.ngOnDestroy = function () {
1955
- this.close();
1956
- };
1957
- WklyTriggerBase.prototype.copy = function () {
1958
- var e_1, _b;
1959
- if (this.ref)
1960
- try {
1961
- 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()) {
1962
- var name = INPUT_NAMES_1_1.value;
1963
- this.ref.component.instance[name] = this[name];
1964
- }
1965
- }
1966
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1967
- finally {
1968
- try {
1969
- if (INPUT_NAMES_1_1 && !INPUT_NAMES_1_1.done && (_b = INPUT_NAMES_1.return)) _b.call(INPUT_NAMES_1);
1970
- }
1971
- finally { if (e_1) throw e_1.error; }
1972
- }
1973
- };
1974
- WklyTriggerBase.prototype.display = function () {
1975
- var host = this.element.nativeElement;
1976
- if (host.tagName === "INPUT") {
1977
- host.readOnly = true;
1978
- var value = this[presentation.WklyPickerInputsPropertyKeys.Value];
1979
- host.value =
1980
- value === null
1981
- ? ""
1982
- : typeof value === "string"
1983
- ? value
1984
- : value.join(" — ");
1985
- host.disabled = this[presentation.WklyPickerInputsPropertyKeys.Disabled];
1986
- host.setAttribute("aria-haspopup", "dialog");
1987
- }
1988
- };
1989
- WklyTriggerBase.prototype.checkValue = function () {
1990
- this.errors = adapters.validateSelection(this[presentation.WklyPickerInputsPropertyKeys.Value], this, this[presentation.WklyPickerInputsPropertyKeys.CalendarAdapter] ||
1991
- new adapters.WklyGregorianCalendarAdapter(this[presentation.WklyPickerInputsPropertyKeys.Locale] || "en-US"));
1992
- this[presentation.WklyPickerOutputsPropertyKeys.ValidationChange].emit(this.errors);
1993
- this.validation();
1994
- };
1995
- WklyTriggerBase.prototype.writeValue = function (value) {
1996
- this[presentation.WklyPickerInputsPropertyKeys.Value] = value;
1997
- this.checkValue();
1998
- this.display();
1999
- if (this.ref)
2000
- this.ref.component.instance.writeValue(value);
2001
- };
2002
- WklyTriggerBase.prototype.registerOnChange = function (fn) {
2003
- this.change = fn;
2004
- };
2005
- WklyTriggerBase.prototype.registerOnTouched = function (fn) {
2006
- this.touched = fn;
2007
- };
2008
- WklyTriggerBase.prototype.setDisabledState = function (value) {
2009
- this[presentation.WklyPickerInputsPropertyKeys.Disabled] = value;
2010
- this.display();
2011
- if (this.ref)
2012
- this.ref.component.instance.setDisabledState(value);
2013
- };
2014
- WklyTriggerBase.prototype.validate = function () {
2015
- return this.errors.length ? { wkly: this.errors } : null;
2016
- };
2017
- WklyTriggerBase.prototype.registerOnValidatorChange = function (fn) {
2018
- this.validation = fn;
2019
- };
2020
- WklyTriggerBase.prototype.scrollToEpochDay = function (day, options) {
2021
- var _a;
2022
- this.open();
2023
- (_a = this.ref) === null || _a === void 0 ? void 0 : _a.component.instance.scrollToEpochDay(day, options);
2024
- };
2025
- WklyTriggerBase.prototype.scrollToAbsoluteWeek = function (week, options) {
2026
- var _a;
2027
- this.open();
2028
- (_a = this.ref) === null || _a === void 0 ? void 0 : _a.component.instance.scrollToAbsoluteWeek(week, options);
2029
- };
2030
- WklyTriggerBase.prototype.scrollToCalendarDate = function (date, options) {
2031
- var _a;
2032
- this.open();
2033
- (_a = this.ref) === null || _a === void 0 ? void 0 : _a.component.instance.scrollToCalendarDate(date, options);
2034
- };
2035
- WklyTriggerBase.prototype.scrollToValue = function (value, options) {
2036
- var _a;
2037
- this.open();
2038
- (_a = this.ref) === null || _a === void 0 ? void 0 : _a.component.instance.scrollToValue(value, options);
2039
- };
2040
- return WklyTriggerBase;
2041
- }(WklyPickerInputs));
2042
- WklyTriggerBase.decorators = [
2043
- { type: i0.Directive }
2044
- ];
2045
- WklyTriggerBase.ctorParameters = function () { return [
2046
- { type: i0.ElementRef }
2047
- ]; };
2048
- WklyTriggerBase.propDecorators = {
2049
- open: [{ type: i0.HostListener, args: ["click",] }],
2050
- key: [{ type: i0.HostListener, args: ["keydown", ["$event"],] }],
2051
- blur: [{ type: i0.HostListener, args: ["blur",] }]
2052
- };
2053
- var WklyDateTimePickerDialogDirective = /** @class */ (function (_super) {
2054
- __extends(WklyDateTimePickerDialogDirective, _super);
2055
- function WklyDateTimePickerDialogDirective(element, service, triggerInjector) {
2056
- var _this = _super.call(this, element) || this;
2057
- _this.service = service;
2058
- _this.triggerInjector = triggerInjector;
2059
- return _this;
2060
- }
2061
- WklyDateTimePickerDialogDirective.prototype.create = function () {
2062
- var _this = this;
2063
- return this.service.open(this.element.nativeElement, function (reason) { return _this.close(reason); }, this[presentation.WklyPickerInputsPropertyKeys.CloseOnBackdrop], this.triggerInjector);
2064
- };
2065
- return WklyDateTimePickerDialogDirective;
2066
- }(WklyTriggerBase));
2067
- WklyDateTimePickerDialogDirective.decorators = [
2068
- { type: i0.Directive, args: [{
2069
- selector: "[wklyDateTimePickerDialog]",
2070
- exportAs: "wklyDialog",
2071
- providers: [
2072
- {
2073
- provide: forms.NG_VALUE_ACCESSOR,
2074
- useExisting: i0.forwardRef(function () { return WklyDateTimePickerDialogDirective; }),
2075
- multi: true,
2076
- },
2077
- {
2078
- provide: forms.NG_VALIDATORS,
2079
- useExisting: i0.forwardRef(function () { return WklyDateTimePickerDialogDirective; }),
2080
- multi: true,
2081
- },
2082
- ],
2083
- },] }
2084
- ];
2085
- WklyDateTimePickerDialogDirective.ctorParameters = function () { return [
2086
- { type: i0.ElementRef },
2087
- { type: WklyDateTimePickerDialogService },
2088
- { type: i0.Injector }
2089
- ]; };
2090
-
2091
- var WklyFieldComponent = /** @class */ (function () {
2092
- function WklyFieldComponent() {
2093
- this.value = 0;
2094
- this.label = "";
2095
- this.hideLabel = false;
2096
- this.previousLabel = "";
2097
- this.nextLabel = "";
2098
- this.min = 0;
2099
- this.max = 59;
2100
- this.step = 1;
2101
- this.locale = "en-US";
2102
- this.disabled = false;
2103
- this.invalid = false;
2104
- this.labels = null;
2105
- this.valueChange = new i0.EventEmitter();
2106
- this.complete = new i0.EventEmitter();
2107
- this.before = null;
2108
- this.touchY = 0;
2109
- this.touchSteps = 0;
2110
- this.touchChanged = false;
2111
- this.typed = null;
2112
- this.inputTimer = null;
2113
- this.wheelTimer = null;
2114
- }
2115
- Object.defineProperty(WklyFieldComponent.prototype, "display", {
2116
- get: function () {
2117
- if (this.typed !== null)
2118
- return this.typed;
2119
- return this.value === null
2120
- ? ""
2121
- : this.labels
2122
- ? this.labels[this.value - this.min] || String(this.value)
2123
- : new Intl.NumberFormat(this.locale, {
2124
- useGrouping: false,
2125
- minimumIntegerDigits: this.max < 60 ? 2 : 1,
2126
- }).format(this.value);
2127
- },
2128
- enumerable: false,
2129
- configurable: true
2130
- });
2131
- WklyFieldComponent.prototype.ngOnChanges = function (changes) {
2132
- if (changes.value && this.min < 0 && this.typed !== null) {
2133
- var typedValue = this.typed === "" || this.typed === "-" ? null : Number(this.typed);
2134
- if (this.value !== typedValue) {
2135
- // External date edits replace a pending relative-day preview.
2136
- this.cancelInput();
2137
- this.typed = null;
2138
- }
2139
- }
2140
- };
2141
- WklyFieldComponent.prototype.ngOnDestroy = function () {
2142
- this.cancelInput();
2143
- if (this.wheelTimer !== null)
2144
- clearTimeout(this.wheelTimer);
2145
- };
2146
- WklyFieldComponent.prototype.next = function (delta) {
2147
- var count = Math.floor((this.max - this.min) / this.step) + 1;
2148
- return (this.min +
2149
- core.floorMod(Math.floor(((this.value === null ? this.min : this.value) - this.min) /
2150
- this.step) + delta, count) *
2151
- this.step);
2152
- };
2153
- WklyFieldComponent.prototype.neighbor = function (delta) {
2154
- var n = this.next(delta);
2155
- return this.labels
2156
- ? this.labels[n - this.min] || ""
2157
- : new Intl.NumberFormat(this.locale, { useGrouping: false }).format(n);
2158
- };
2159
- WklyFieldComponent.prototype.stepBy = function (delta) {
2160
- if (this.disabled)
2161
- return;
2162
- this.scrollBy(delta);
2163
- this.complete.emit();
2164
- };
2165
- WklyFieldComponent.prototype.begin = function (event) {
2166
- this.before = this.value;
2167
- event.target.select();
2168
- };
2169
- WklyFieldComponent.prototype.type = function (event) {
2170
- var _this = this;
2171
- if (this.disabled)
2172
- return;
2173
- var input = event.target;
2174
- var raw = input.value;
2175
- var numeric = Array.from(raw).every(function (character) { return adapters.normalizeDigits(character).length === 1; });
2176
- if (this.min < 0 && !this.labels) {
2177
- // Preserve the sign while using the same locale digit normalization.
2178
- var signed = raw
2179
- .replace(/[\u200e\u200f\u061c]/g, "")
2180
- .replace(/\u2212/g, "-");
2181
- var digits = adapters.normalizeDigits(signed);
2182
- this.typed = input.value = (signed.startsWith("-") ? "-" : "") + digits;
2183
- this.value =
2184
- digits === ""
2185
- ? null
2186
- : Math.max(this.min, Math.min(this.max, Number(this.typed)));
2187
- if (this.value !== null && Number(this.typed) !== this.value)
2188
- this.typed = input.value = String(this.value);
2189
- }
2190
- else if (numeric) {
2191
- var normalized = adapters.normalizeDigits(raw);
2192
- this.typed = input.value =
2193
- this.min >= 0 && this.max < 100 ? normalized.slice(-2) : normalized;
2194
- this.value = this.typed === "" ? null : Number(this.typed);
2195
- }
2196
- else if (this.labels) {
2197
- var search_1 = raw.trim().toLocaleLowerCase(this.locale);
2198
- this.typed = raw;
2199
- var matches = this.labels
2200
- .map(function (label, index) { return ({ label: label, index: index }); })
2201
- .filter(function (item) { return item.label.toLocaleLowerCase(_this.locale).includes(search_1); });
2202
- this.value = matches.length === 1 ? this.min + matches[0].index : null;
2203
- }
2204
- else {
2205
- this.typed = input.value = adapters.normalizeDigits(raw);
2206
- this.value = this.typed === "" ? null : Number(this.typed);
2207
- }
2208
- this.valueChange.emit(this.value);
2209
- this.cancelInput();
2210
- if (!numeric && this.labels && this.value !== null)
2211
- this.complete.emit();
2212
- this.inputTimer = setTimeout(function () {
2213
- _this.inputTimer = null;
2214
- _this.typed = null;
2215
- if (!_this.disabled)
2216
- _this.complete.emit();
2217
- }, 1000);
2218
- };
2219
- WklyFieldComponent.prototype.key = function (event) {
2220
- if (event.key === "Escape") {
2221
- event.preventDefault();
2222
- event.stopPropagation();
2223
- this.cancelInput();
2224
- this.typed = null;
2225
- this.value = this.before;
2226
- this.valueChange.emit(this.before);
2227
- event.target.value = this.display;
2228
- event.target.blur();
2229
- }
2230
- if (event.key === "Enter") {
2231
- event.preventDefault();
2232
- event.stopPropagation();
2233
- this.finish();
2234
- }
2235
- var delta = event.key === "ArrowUp"
2236
- ? -1
2237
- : event.key === "ArrowDown"
2238
- ? 1
2239
- : event.key === "PageUp"
2240
- ? -5
2241
- : event.key === "PageDown"
2242
- ? 5
2243
- : 0;
2244
- if (delta) {
2245
- event.preventDefault();
2246
- this.stepBy(delta);
2247
- }
2248
- };
2249
- WklyFieldComponent.prototype.finish = function () {
2250
- this.cancelInput();
2251
- this.typed = null;
2252
- this.complete.emit();
2253
- };
2254
- WklyFieldComponent.prototype.wheel = function (event) {
2255
- var _this = this;
2256
- if (this.disabled || Math.abs(event.deltaY) < 1)
2257
- return;
2258
- event.preventDefault();
2259
- this.scrollBy(event.deltaY > 0 ? 1 : -1);
2260
- if (this.wheelTimer !== null)
2261
- clearTimeout(this.wheelTimer);
2262
- this.wheelTimer = setTimeout(function () {
2263
- _this.wheelTimer = null;
2264
- _this.complete.emit();
2265
- }, 140);
2266
- };
2267
- WklyFieldComponent.prototype.touchStart = function (event) {
2268
- this.touchY = event.touches[0].clientY;
2269
- this.touchSteps = 0;
2270
- this.touchChanged = false;
2271
- };
2272
- WklyFieldComponent.prototype.touchMove = function (event) {
2273
- this.applyTouchY(event.touches[0].clientY);
2274
- };
2275
- WklyFieldComponent.prototype.touchEnd = function (event) {
2276
- this.applyTouchY(event.changedTouches[0].clientY);
2277
- if (this.touchChanged)
2278
- this.complete.emit();
2279
- this.touchChanged = false;
2280
- };
2281
- WklyFieldComponent.prototype.cancelInput = function () {
2282
- if (this.inputTimer !== null)
2283
- clearTimeout(this.inputTimer);
2284
- this.inputTimer = null;
2285
- };
2286
- WklyFieldComponent.prototype.scrollBy = function (delta) {
2287
- if (this.disabled || !delta)
2288
- return;
2289
- this.cancelInput();
2290
- this.typed = null;
2291
- this.value = this.next(delta);
2292
- this.valueChange.emit(this.value);
2293
- };
2294
- WklyFieldComponent.prototype.applyTouchY = function (y) {
2295
- // Count total gesture steps so repeated move events do not duplicate changes.
2296
- if (this.disabled)
2297
- return;
2298
- var delta = this.touchY - y;
2299
- var steps = Math.abs(delta) > 16
2300
- ? Math.sign(delta) * Math.max(1, Math.round(Math.abs(delta) / 40))
2301
- : 0;
2302
- var change = steps - this.touchSteps;
2303
- if (!change)
2304
- return;
2305
- this.scrollBy(change);
2306
- this.touchSteps = steps;
2307
- this.touchChanged = true;
2308
- };
2309
- return WklyFieldComponent;
2310
- }());
2311
- WklyFieldComponent.decorators = [
2312
- { type: i0.Component, args: [{
2313
- selector: "wkly-field",
2314
- 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",
2315
- 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}@media (hover: hover) and (pointer: fine){button:hover:not(:disabled){background:var(--wkly-range-color, #e5f1ee)}}\n"]
2316
- },] }
2317
- ];
2318
- WklyFieldComponent.propDecorators = {
2319
- value: [{ type: i0.Input }],
2320
- label: [{ type: i0.Input }],
2321
- hideLabel: [{ type: i0.Input }],
2322
- previousLabel: [{ type: i0.Input }],
2323
- nextLabel: [{ type: i0.Input }],
2324
- min: [{ type: i0.Input }],
2325
- max: [{ type: i0.Input }],
2326
- step: [{ type: i0.Input }],
2327
- locale: [{ type: i0.Input }],
2328
- disabled: [{ type: i0.Input }],
2329
- invalid: [{ type: i0.Input }],
2330
- labels: [{ type: i0.Input }],
2331
- valueChange: [{ type: i0.Output }],
2332
- complete: [{ type: i0.Output }]
2333
- };
2334
-
2335
- var WklyDateTimePickerModule = /** @class */ (function () {
2336
- function WklyDateTimePickerModule() {
2337
- }
2338
- return WklyDateTimePickerModule;
2339
- }());
2340
- WklyDateTimePickerModule.decorators = [
2341
- { type: i0.NgModule, args: [{
2342
- imports: [i1.CommonModule],
2343
- declarations: [
2344
- WklyDateTimePickerComponent,
2345
- WklyDateTimePickerDialogDirective,
2346
- WklyFieldComponent,
2347
- ],
2348
- entryComponents: [WklyDateTimePickerComponent],
2349
- exports: [WklyDateTimePickerComponent, WklyDateTimePickerDialogDirective],
2350
- },] }
2351
- ];
2352
-
2353
- /**
2354
- * Generated bundle index. Do not edit.
2355
- */
2356
-
2357
- exports.WKLY_CLOCK = WKLY_CLOCK;
2358
- exports.WKLY_CONFIG = WKLY_CONFIG;
2359
- exports.WKLY_LOCALIZATION = WKLY_LOCALIZATION;
2360
- exports.WKLY_TRANSLATIONS = WKLY_TRANSLATIONS;
2361
- exports.WklyDateTimePickerComponent = WklyDateTimePickerComponent;
2362
- exports.WklyDateTimePickerDialogDirective = WklyDateTimePickerDialogDirective;
2363
- exports.WklyDateTimePickerDialogService = WklyDateTimePickerDialogService;
2364
- exports.WklyDateTimePickerModule = WklyDateTimePickerModule;
2365
- exports.WklyFieldComponent = WklyFieldComponent;
2366
- exports.WklyPickerInputs = WklyPickerInputs;
2367
- exports.WklyTriggerBase = WklyTriggerBase;
2368
- Object.keys(presentation).forEach(function (k) {
2369
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
2370
- enumerable: true,
2371
- get: function () { return presentation[k]; }
2372
- });
2373
- });
2374
-
2375
- Object.defineProperty(exports, '__esModule', { value: true });
2376
-
2377
- }));
2378
- //# sourceMappingURL=wkly-datetime-picker.umd.js.map