@wkly/datetime-picker 11.0.0 → 13.0.0

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