ngx-tethys 18.2.10 → 18.2.13

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 (63) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/date-picker/abstract-picker.component.d.ts +6 -1
  3. package/date-picker/base-picker.component.d.ts +1 -1
  4. package/date-picker/lib/calendar/calendar-footer.component.d.ts +2 -1
  5. package/date-picker/lib/calendar/calendar-table.component.d.ts +4 -3
  6. package/date-picker/lib/popups/date-popup.component.d.ts +2 -1
  7. package/date-picker/lib/popups/inner-popup.component.d.ts +2 -1
  8. package/date-picker/picker.component.d.ts +2 -1
  9. package/date-picker/picker.util.d.ts +5 -5
  10. package/esm2022/cascader/cascader.component.mjs +2 -2
  11. package/esm2022/date-picker/abstract-picker.component.mjs +16 -28
  12. package/esm2022/date-picker/base-picker.component.mjs +17 -13
  13. package/esm2022/date-picker/date-picker.component.mjs +3 -3
  14. package/esm2022/date-picker/lib/calendar/calendar-footer.component.mjs +7 -5
  15. package/esm2022/date-picker/lib/calendar/calendar-table.component.mjs +6 -4
  16. package/esm2022/date-picker/lib/date/date-table.component.mjs +2 -2
  17. package/esm2022/date-picker/lib/popups/date-popup.component.mjs +29 -45
  18. package/esm2022/date-picker/lib/popups/inner-popup.component.mjs +7 -5
  19. package/esm2022/date-picker/month-picker.component.mjs +3 -3
  20. package/esm2022/date-picker/picker.component.mjs +9 -4
  21. package/esm2022/date-picker/picker.util.mjs +21 -15
  22. package/esm2022/date-picker/quarter-picker.component.mjs +3 -3
  23. package/esm2022/date-picker/range-picker.component.mjs +3 -3
  24. package/esm2022/date-picker/week-picker.component.mjs +3 -3
  25. package/esm2022/date-picker/year-picker.component.mjs +3 -3
  26. package/esm2022/i18n/i18n.service.mjs +3 -6
  27. package/esm2022/i18n/locale.mjs +17 -2
  28. package/esm2022/message/message-container.component.mjs +3 -3
  29. package/esm2022/notify/notify-container.component.mjs +3 -3
  30. package/esm2022/select/custom-select/custom-select.component.mjs +2 -2
  31. package/esm2022/time-picker/inner/inner-time-picker.component.mjs +13 -11
  32. package/esm2022/time-picker/inner/inner-time-picker.store.mjs +16 -16
  33. package/esm2022/time-picker/time-picker.utils.mjs +14 -14
  34. package/esm2022/util/date/tiny-date.mjs +23 -11
  35. package/esm2022/util/helpers/helpers.mjs +13 -1
  36. package/esm2022/version.mjs +2 -2
  37. package/fesm2022/ngx-tethys-cascader.mjs +1 -1
  38. package/fesm2022/ngx-tethys-cascader.mjs.map +1 -1
  39. package/fesm2022/ngx-tethys-date-picker.mjs +114 -121
  40. package/fesm2022/ngx-tethys-date-picker.mjs.map +1 -1
  41. package/fesm2022/ngx-tethys-i18n.mjs +17 -5
  42. package/fesm2022/ngx-tethys-i18n.mjs.map +1 -1
  43. package/fesm2022/ngx-tethys-message.mjs +2 -2
  44. package/fesm2022/ngx-tethys-message.mjs.map +1 -1
  45. package/fesm2022/ngx-tethys-notify.mjs +2 -2
  46. package/fesm2022/ngx-tethys-notify.mjs.map +1 -1
  47. package/fesm2022/ngx-tethys-select.mjs +1 -1
  48. package/fesm2022/ngx-tethys-select.mjs.map +1 -1
  49. package/fesm2022/ngx-tethys-time-picker.mjs +40 -38
  50. package/fesm2022/ngx-tethys-time-picker.mjs.map +1 -1
  51. package/fesm2022/ngx-tethys-util.mjs +422 -398
  52. package/fesm2022/ngx-tethys-util.mjs.map +1 -1
  53. package/fesm2022/ngx-tethys.mjs +1 -1
  54. package/fesm2022/ngx-tethys.mjs.map +1 -1
  55. package/i18n/locale.d.ts +7 -1
  56. package/package.json +2 -1
  57. package/schematics/version.d.ts +1 -1
  58. package/schematics/version.js +1 -1
  59. package/table/styles/table.scss +9 -1
  60. package/time-picker/inner/inner-time-picker.component.d.ts +3 -1
  61. package/time-picker/inner/inner-time-picker.store.d.ts +5 -5
  62. package/time-picker/time-picker.utils.d.ts +5 -5
  63. package/util/helpers/helpers.d.ts +1 -0
@@ -1,10 +1,11 @@
1
1
  import * as dateFns from 'date-fns';
2
2
  import { setHours, setMinutes, setSeconds } from 'date-fns';
3
3
  import * as dateFnsLocales from 'date-fns/locale';
4
- import { ThyLocaleType } from 'ngx-tethys/i18n';
4
+ import { ThyLocaleType, getDefaultLocaleId } from 'ngx-tethys/i18n';
5
5
  import { TZDate } from '@date-fns/tz';
6
- import { TemplateRef, ElementRef, isDevMode } from '@angular/core';
6
+ import { fromZonedTime } from 'date-fns-tz';
7
7
  import { _isNumberValue, coerceCssPixelValue as coerceCssPixelValue$1 } from '@angular/cdk/coercion';
8
+ import { TemplateRef, ElementRef, isDevMode } from '@angular/core';
8
9
  import * as keycodes$1 from '@angular/cdk/keycodes';
9
10
  export * from '@angular/cdk/keycodes';
10
11
 
@@ -123,81 +124,437 @@ const getDateFnsLocale = (locale) => {
123
124
  }
124
125
  };
125
126
 
126
- function sortRangeValue(rangeValue) {
127
- if (Array.isArray(rangeValue)) {
128
- const [start, end] = rangeValue;
129
- return start && end && start.isAfterSecond(end) ? [end, start] : [start, end];
130
- }
131
- return rangeValue;
127
+ function isUndefined(value) {
128
+ return value === undefined;
132
129
  }
133
- const DEFAULT_TIMEZONE = 'Asia/Shanghai';
134
- class TinyDate {
135
- static { this.dateFnsLocale = getDateFnsLocale(ThyLocaleType.zhHans); }
136
- static { this.defaultTimeZone = DEFAULT_TIMEZONE; }
137
- constructor(date, zone) {
138
- this.useTimeZone = zone || TinyDate.defaultTimeZone;
139
- if (date) {
140
- if (date instanceof Date) {
141
- this.nativeDate = TinyDate.utcToZonedTime(date, this.useTimeZone);
142
- }
143
- else if (typeof date === 'string' || typeof date === 'number') {
144
- this.nativeDate = new TZDate(date, this.useTimeZone);
145
- }
146
- else if (typeof ngDevMode === 'undefined' || ngDevMode) {
147
- throw new Error(`The input date type is not supported expect Date | string | number | { date: number; with_time: 0 | 1}, actual ${JSON.stringify(date)}`);
148
- }
149
- }
150
- else {
151
- this.nativeDate = new TZDate(Date.now(), this.useTimeZone);
152
- }
130
+ function isNull(value) {
131
+ return value === null;
132
+ }
133
+ function isUndefinedOrNull(value) {
134
+ return isUndefined(value) || isNull(value);
135
+ }
136
+ function isArray(value) {
137
+ return value && baseGetTag(value) === '[object Array]';
138
+ }
139
+ function isEmpty(value) {
140
+ return !(isArray(value) && value.length > 0);
141
+ }
142
+ function isString(value) {
143
+ return typeof value == 'string' || (!isArray(value) && isObjectLike(value) && baseGetTag(value) === '[object String]');
144
+ }
145
+ function isObjectLike(value) {
146
+ return value !== null && typeof value === 'object';
147
+ }
148
+ function baseGetTag(value) {
149
+ const objectProto = Object.prototype;
150
+ const hasOwnProperty = objectProto.hasOwnProperty;
151
+ const toString = objectProto.toString;
152
+ const symToStringTag = typeof Symbol !== 'undefined' ? Symbol.toStringTag : undefined;
153
+ if (value == null) {
154
+ return value === undefined ? '[object Undefined]' : '[object Null]';
153
155
  }
154
- static setDefaultLocale(locale) {
155
- TinyDate.locale = locale;
156
- TinyDate.dateFnsLocale = getDateFnsLocale(locale);
157
- return setDefaultOptions({ locale: TinyDate.dateFnsLocale });
156
+ if (!(symToStringTag && symToStringTag in Object(value))) {
157
+ return toString.call(value);
158
158
  }
159
- static getDefaultLocale() {
160
- return { locale: TinyDate.locale, dateFnsLocale: TinyDate.dateFnsLocale };
159
+ const isOwn = hasOwnProperty.call(value, symToStringTag);
160
+ const tag = value[symToStringTag];
161
+ let unmasked = false;
162
+ try {
163
+ value[symToStringTag] = undefined;
164
+ unmasked = true;
161
165
  }
162
- static setDefaultTimeZone(zone) {
163
- TinyDate.defaultTimeZone = zone ?? DEFAULT_TIMEZONE;
166
+ catch (e) { }
167
+ const result = toString.call(value);
168
+ if (unmasked) {
169
+ if (isOwn) {
170
+ value[symToStringTag] = tag;
171
+ }
172
+ else {
173
+ delete value[symToStringTag];
174
+ }
164
175
  }
165
- static getDefaultTimeZone() {
166
- return TinyDate.defaultTimeZone;
176
+ return result;
177
+ }
178
+ function isNumber(value) {
179
+ return typeof value === 'number' || (isObjectLike(value) && baseGetTag(value) === '[object Number]');
180
+ }
181
+ function isObject(value) {
182
+ // Avoid a V8 JIT bug in Chrome 19-20.
183
+ // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
184
+ const type = typeof value;
185
+ return !!value && (type === 'object' || type === 'function');
186
+ }
187
+ function isFunction(value) {
188
+ const type = typeof value;
189
+ return !!value && type === 'function';
190
+ }
191
+ function isDate(value) {
192
+ const type = typeof value;
193
+ return !!value && type === 'object' && !!value.getTime;
194
+ }
195
+ function coerceArray(value) {
196
+ return Array.isArray(value) ? value : [value];
197
+ }
198
+ function get(object, path, defaultValue) {
199
+ const paths = path.split('.');
200
+ let result = object[paths.shift()];
201
+ while (result && paths.length) {
202
+ result = result[paths.shift()];
167
203
  }
168
- static utcToZonedTime(value, timeZone) {
169
- return TZDate.tz(timeZone || TinyDate.defaultTimeZone, value);
204
+ return result === undefined ? defaultValue : result;
205
+ }
206
+ function set(object, path, value) {
207
+ if (object == null) {
208
+ return object;
170
209
  }
171
- static createDateInTimeZone(year, month, day, hours, minutes, seconds, timeZone) {
172
- return new TZDate(year, month, day, hours, minutes, seconds, timeZone || TinyDate.defaultTimeZone);
210
+ const paths = path.split('.');
211
+ let index = -1;
212
+ const length = paths.length;
213
+ const lastIndex = length - 1;
214
+ let nested = object;
215
+ while (nested !== null && ++index < length) {
216
+ const key = paths[index];
217
+ if (isObject(nested)) {
218
+ if (index === lastIndex) {
219
+ nested[key] = value;
220
+ nested = nested[key];
221
+ break;
222
+ }
223
+ else {
224
+ if (nested[key] == null) {
225
+ nested[key] = {};
226
+ }
227
+ }
228
+ }
229
+ nested = nested[key];
173
230
  }
174
- static fromUnixTime(unixTime, timeZone) {
175
- return new TinyDate(fromUnixTime(unixTime), timeZone || TinyDate.defaultTimeZone);
231
+ return object;
232
+ }
233
+ function isBoolean(value) {
234
+ return value === true || value === false || (isObjectLike(value) && baseGetTag(value) === '[object Boolean]');
235
+ }
236
+ function isClass(value) {
237
+ return isFunction(value) && /^\s*class\s+/.test(value.toString());
238
+ }
239
+ function htmlElementIsEmpty(element) {
240
+ if (element && element.childNodes) {
241
+ const nodes = element.childNodes;
242
+ for (let i = 0; i < nodes.length; i++) {
243
+ const node = nodes[i];
244
+ if (node.nodeType === Node.ELEMENT_NODE && node.outerHTML.toString().trim().length !== 0) {
245
+ return false;
246
+ }
247
+ else if (node.nodeType === Node.TEXT_NODE && node.textContent.toString().trim().length !== 0) {
248
+ return false;
249
+ }
250
+ else if (node.nodeType !== Node.COMMENT_NODE) {
251
+ return false;
252
+ }
253
+ }
176
254
  }
177
- // get
178
- getTime() {
179
- return this.nativeDate.getTime();
255
+ return true;
256
+ }
257
+ function hexToRgb(hexValue, alpha) {
258
+ const rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
259
+ const hex = hexValue.replace(rgx, (m, r, g, b) => r + r + g + g + b + b);
260
+ const rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
261
+ if (!rgb)
262
+ return;
263
+ const resultR = parseInt(rgb[1], 16);
264
+ const resultG = parseInt(rgb[2], 16);
265
+ const resultB = parseInt(rgb[3], 16);
266
+ if (!isUndefinedOrNull(alpha)) {
267
+ return `rgba(${resultR}, ${resultG}, ${resultB}, ${alpha})`;
180
268
  }
181
- getDate() {
182
- return this.nativeDate.getDate();
269
+ else {
270
+ return `rgb(${resultR}, ${resultG}, ${resultB})`;
183
271
  }
184
- getYear() {
185
- return this.nativeDate.getFullYear();
272
+ }
273
+ function dateToUnixTimestamp(date) {
274
+ if (isNumber(date)) {
275
+ if (date.toString().length === 10) {
276
+ return date;
277
+ }
278
+ else {
279
+ return parseInt((date / 1000).toFixed(0), 10);
280
+ }
186
281
  }
187
- getQuarter() {
188
- return getQuarter(this.nativeDate);
282
+ else {
283
+ return parseInt((date.getTime() / 1000).toFixed(0), 10);
189
284
  }
190
- getMonth() {
191
- return this.nativeDate.getMonth();
285
+ }
286
+ function clamp(value, min = 0, max = 100) {
287
+ return Math.max(min, Math.min(max, value));
288
+ }
289
+ function keyBy(array, key) {
290
+ const result = {};
291
+ array.forEach(item => {
292
+ const keyValue = item[key];
293
+ result[keyValue] = item;
294
+ });
295
+ return result;
296
+ }
297
+ function indexKeyBy(array, key) {
298
+ const result = {};
299
+ array.forEach((item, index) => {
300
+ const keyValue = item[key];
301
+ result[keyValue] = index;
302
+ });
303
+ return result;
304
+ }
305
+ function upperFirst(string) {
306
+ return string.slice(0, 1).toUpperCase() + string.slice(1);
307
+ }
308
+ function camelCase(values) {
309
+ if (isArray(values)) {
310
+ return values.reduce((result, word, index) => {
311
+ word = word.toLowerCase();
312
+ return result + (index ? upperFirst(word) : word);
313
+ }, '');
192
314
  }
193
- getFullYear() {
194
- return this.nativeDate.getFullYear();
315
+ else {
316
+ return;
195
317
  }
196
- getWeek(options = { weekStartsOn: 1 }) {
197
- return getWeek(this.nativeDate, options);
318
+ }
319
+ function generateRandomStr() {
320
+ return Math.random().toString(36).substring(2);
321
+ }
322
+ function isTemplateRef(value) {
323
+ return value instanceof TemplateRef;
324
+ }
325
+ function isHTMLElement(value) {
326
+ return value instanceof HTMLElement;
327
+ }
328
+ function isElementRef(value) {
329
+ return value instanceof ElementRef;
330
+ }
331
+ /**
332
+ * fix angular cdk's coerceBooleanProperty will transform 0 to true
333
+ */
334
+ function coerceBooleanProperty(value) {
335
+ if (value === '' || (value && value !== 'false')) {
336
+ return true;
198
337
  }
199
- getDay() {
200
- return this.nativeDate.getDay();
338
+ else {
339
+ return false;
340
+ }
341
+ }
342
+ /**
343
+ * @deprecated Please use Angular cdk's coerceNumberProperty instead
344
+ */
345
+ function coerceNumberValue(value, fallbackValue = 0) {
346
+ return _isNumberValue(value) ? Number(value) : fallbackValue;
347
+ }
348
+ /**
349
+ * @deprecated Please use Angular cdk's coerceCssPixelValue instead
350
+ */
351
+ function coerceCssPixelValue(value) {
352
+ value = _isNumberValue(value) ? Number(value) : value;
353
+ return coerceCssPixelValue$1(value);
354
+ }
355
+ function valueFunctionProp(prop, ...args) {
356
+ return typeof prop === 'function' ? prop(...args) : prop;
357
+ }
358
+ function shallowEqual(objA, objB) {
359
+ if (objA === objB) {
360
+ return true;
361
+ }
362
+ if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
363
+ return false;
364
+ }
365
+ const keysA = Object.keys(objA);
366
+ const keysB = Object.keys(objB);
367
+ if (keysA.length !== keysB.length) {
368
+ return false;
369
+ }
370
+ const bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
371
+ for (let idx = 0; idx < keysA.length; idx++) {
372
+ const key = keysA[idx];
373
+ if (!bHasOwnProperty(key)) {
374
+ return false;
375
+ }
376
+ if (objA[key] !== objB[key]) {
377
+ return false;
378
+ }
379
+ }
380
+ return true;
381
+ }
382
+ function concatArray(items, originalItems = []) {
383
+ let _originalItems = [];
384
+ if (!originalItems) {
385
+ _originalItems = [];
386
+ }
387
+ else {
388
+ _originalItems = coerceArray(originalItems);
389
+ }
390
+ if (items) {
391
+ if (isArray(items)) {
392
+ return [..._originalItems, ...items];
393
+ }
394
+ else {
395
+ return [..._originalItems, items];
396
+ }
397
+ }
398
+ else {
399
+ return _originalItems;
400
+ }
401
+ }
402
+ function humanizeBytes(bytes, noSpace = false, fractionDigits = 1) {
403
+ if (bytes === 0) {
404
+ return '0 Byte';
405
+ }
406
+ const k = 1024;
407
+ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
408
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
409
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(fractionDigits)) + (noSpace ? '' : ' ') + sizes[i];
410
+ }
411
+ function isFloat(value) {
412
+ if (!value) {
413
+ return false;
414
+ }
415
+ return /^[-+]?([0-9]+([.][0-9]*)?|[.][0-9]+)([Ee][-+]?[0-9]+)?$/.test(value);
416
+ }
417
+ function hasTimeInStringDate(dateString) {
418
+ const standardFormat = /\d{4}[-/]\d{1,2}[-/]\d{1,2}\s+\d{1,2}:\d{1,2}/;
419
+ const chineseFormat = /\d{4}年\d{1,2}月\d{1,2}日?\s+\d{1,2}[时:]\d{1,2}[分]?/;
420
+ const reverseEnglishFormat = /\d{1,2}\s+[A-Za-z]{3,}\s+\d{4}\s+\d{1,2}:\d{1,2}/;
421
+ const englishFormat = /[A-Za-z]{3,}\s+\d{1,2},?\s+\d{4}\s+\d{1,2}:\d{1,2}/;
422
+ const isoFormat = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
423
+ return (standardFormat.test(dateString) ||
424
+ chineseFormat.test(dateString) ||
425
+ reverseEnglishFormat.test(dateString) ||
426
+ englishFormat.test(dateString) ||
427
+ isoFormat.test(dateString));
428
+ }
429
+
430
+ var index = /*#__PURE__*/Object.freeze({
431
+ __proto__: null,
432
+ camelCase: camelCase,
433
+ clamp: clamp,
434
+ coerceArray: coerceArray,
435
+ coerceBooleanProperty: coerceBooleanProperty,
436
+ coerceCssPixelValue: coerceCssPixelValue,
437
+ coerceNumberValue: coerceNumberValue,
438
+ concatArray: concatArray,
439
+ dateToUnixTimestamp: dateToUnixTimestamp,
440
+ generateRandomStr: generateRandomStr,
441
+ get: get,
442
+ hasTimeInStringDate: hasTimeInStringDate,
443
+ hexToRgb: hexToRgb,
444
+ htmlElementIsEmpty: htmlElementIsEmpty,
445
+ humanizeBytes: humanizeBytes,
446
+ indexKeyBy: indexKeyBy,
447
+ isArray: isArray,
448
+ isBoolean: isBoolean,
449
+ isClass: isClass,
450
+ isDate: isDate,
451
+ isElementRef: isElementRef,
452
+ isEmpty: isEmpty,
453
+ isFloat: isFloat,
454
+ isFunction: isFunction,
455
+ isHTMLElement: isHTMLElement,
456
+ isNull: isNull,
457
+ isNumber: isNumber,
458
+ isObject: isObject,
459
+ isString: isString,
460
+ isTemplateRef: isTemplateRef,
461
+ isUndefined: isUndefined,
462
+ isUndefinedOrNull: isUndefinedOrNull,
463
+ keyBy: keyBy,
464
+ set: set,
465
+ shallowEqual: shallowEqual,
466
+ valueFunctionProp: valueFunctionProp
467
+ });
468
+
469
+ function sortRangeValue(rangeValue) {
470
+ if (Array.isArray(rangeValue)) {
471
+ const [start, end] = rangeValue;
472
+ return start && end && start.isAfterSecond(end) ? [end, start] : [start, end];
473
+ }
474
+ return rangeValue;
475
+ }
476
+ const DEFAULT_TIMEZONE = 'Asia/Shanghai';
477
+ class TinyDate {
478
+ static { this.locale = getDefaultLocaleId(); }
479
+ static { this.dateFnsLocale = getDateFnsLocale(TinyDate.locale); }
480
+ static { this.defaultTimeZone = DEFAULT_TIMEZONE; }
481
+ constructor(date, zone) {
482
+ setDefaultOptions({ locale: TinyDate.dateFnsLocale });
483
+ this.useTimeZone = zone || TinyDate.defaultTimeZone;
484
+ if (date) {
485
+ if (date instanceof Date) {
486
+ this.nativeDate = TinyDate.utcToZonedTime(date, this.useTimeZone);
487
+ }
488
+ else if (typeof date === 'string') {
489
+ if (hasTimeInStringDate(date)) {
490
+ // If the string contains time, you need to convert the time to UTC time before passing it to TZDate
491
+ const originTime = new Date(date);
492
+ const zoneTime = TZDate.tz(this.useTimeZone, originTime);
493
+ const utcDate = fromZonedTime(zoneTime, this.useTimeZone).toISOString();
494
+ this.nativeDate = new TZDate(utcDate, this.useTimeZone);
495
+ }
496
+ else {
497
+ this.nativeDate = new TZDate(date, this.useTimeZone);
498
+ }
499
+ }
500
+ else if (typeof date === 'number') {
501
+ this.nativeDate = new TZDate(date, this.useTimeZone);
502
+ }
503
+ else if (typeof ngDevMode === 'undefined' || ngDevMode) {
504
+ throw new Error(`The input date type is not supported expect Date | string | number | { date: number; with_time: 0 | 1}, actual ${JSON.stringify(date)}`);
505
+ }
506
+ }
507
+ else {
508
+ this.nativeDate = new TZDate(Date.now(), this.useTimeZone);
509
+ }
510
+ }
511
+ static setDefaultLocale(locale) {
512
+ TinyDate.locale = locale;
513
+ TinyDate.dateFnsLocale = getDateFnsLocale(locale);
514
+ return setDefaultOptions({ locale: TinyDate.dateFnsLocale });
515
+ }
516
+ static getDefaultLocale() {
517
+ return { locale: TinyDate.locale, dateFnsLocale: TinyDate.dateFnsLocale };
518
+ }
519
+ static setDefaultTimeZone(zone) {
520
+ TinyDate.defaultTimeZone = zone ?? DEFAULT_TIMEZONE;
521
+ }
522
+ static getDefaultTimeZone() {
523
+ return TinyDate.defaultTimeZone;
524
+ }
525
+ static utcToZonedTime(value, timeZone) {
526
+ return TZDate.tz(timeZone || TinyDate.defaultTimeZone, value);
527
+ }
528
+ static createDateInTimeZone(year, month, day, hours, minutes, seconds, timeZone) {
529
+ return new TZDate(year, month, day, hours, minutes, seconds, timeZone || TinyDate.defaultTimeZone);
530
+ }
531
+ static fromUnixTime(unixTime, timeZone) {
532
+ return new TinyDate(fromUnixTime(unixTime), timeZone || TinyDate.defaultTimeZone);
533
+ }
534
+ // get
535
+ getTime() {
536
+ return this.nativeDate.getTime();
537
+ }
538
+ getDate() {
539
+ return this.nativeDate.getDate();
540
+ }
541
+ getYear() {
542
+ return this.nativeDate.getFullYear();
543
+ }
544
+ getQuarter() {
545
+ return getQuarter(this.nativeDate);
546
+ }
547
+ getMonth() {
548
+ return this.nativeDate.getMonth();
549
+ }
550
+ getFullYear() {
551
+ return this.nativeDate.getFullYear();
552
+ }
553
+ getWeek(options = { weekStartsOn: 1 }) {
554
+ return getWeek(this.nativeDate, options);
555
+ }
556
+ getDay() {
557
+ return this.nativeDate.getDay();
201
558
  }
202
559
  getHours() {
203
560
  return this.nativeDate.getHours();
@@ -219,14 +576,10 @@ class TinyDate {
219
576
  }
220
577
  // set
221
578
  setDate(amount) {
222
- const date = new Date(this.nativeDate);
223
- date.setDate(amount);
224
- return new TinyDate(date, this.useTimeZone);
579
+ return new TinyDate(this.nativeDate.setDate(amount), this.useTimeZone);
225
580
  }
226
581
  setHms(hour, minute, second) {
227
- const date = new Date(this.nativeDate);
228
- date.setHours(hour, minute, second);
229
- return new TinyDate(date, this.useTimeZone);
582
+ return new TinyDate(this.nativeDate?.setHours(hour, minute, second), this.useTimeZone);
230
583
  }
231
584
  setYear(year) {
232
585
  return new TinyDate(setYear(this.nativeDate, year), this.useTimeZone);
@@ -430,7 +783,7 @@ class TinyDate {
430
783
  return new TinyDate(startOfWeek(startOfMonth(this.nativeDate), options), this.useTimeZone);
431
784
  }
432
785
  clone() {
433
- return new TinyDate(new Date(this.nativeDate), this.useTimeZone);
786
+ return new TinyDate(this.nativeDate, this.useTimeZone);
434
787
  }
435
788
  getUnixTime() {
436
789
  return getUnixTime(this.nativeDate);
@@ -494,335 +847,6 @@ class TinyDate {
494
847
  }
495
848
  }
496
849
 
497
- function isUndefined(value) {
498
- return value === undefined;
499
- }
500
- function isNull(value) {
501
- return value === null;
502
- }
503
- function isUndefinedOrNull(value) {
504
- return isUndefined(value) || isNull(value);
505
- }
506
- function isArray(value) {
507
- return value && baseGetTag(value) === '[object Array]';
508
- }
509
- function isEmpty(value) {
510
- return !(isArray(value) && value.length > 0);
511
- }
512
- function isString(value) {
513
- return typeof value == 'string' || (!isArray(value) && isObjectLike(value) && baseGetTag(value) === '[object String]');
514
- }
515
- function isObjectLike(value) {
516
- return value !== null && typeof value === 'object';
517
- }
518
- function baseGetTag(value) {
519
- const objectProto = Object.prototype;
520
- const hasOwnProperty = objectProto.hasOwnProperty;
521
- const toString = objectProto.toString;
522
- const symToStringTag = typeof Symbol !== 'undefined' ? Symbol.toStringTag : undefined;
523
- if (value == null) {
524
- return value === undefined ? '[object Undefined]' : '[object Null]';
525
- }
526
- if (!(symToStringTag && symToStringTag in Object(value))) {
527
- return toString.call(value);
528
- }
529
- const isOwn = hasOwnProperty.call(value, symToStringTag);
530
- const tag = value[symToStringTag];
531
- let unmasked = false;
532
- try {
533
- value[symToStringTag] = undefined;
534
- unmasked = true;
535
- }
536
- catch (e) { }
537
- const result = toString.call(value);
538
- if (unmasked) {
539
- if (isOwn) {
540
- value[symToStringTag] = tag;
541
- }
542
- else {
543
- delete value[symToStringTag];
544
- }
545
- }
546
- return result;
547
- }
548
- function isNumber(value) {
549
- return typeof value === 'number' || (isObjectLike(value) && baseGetTag(value) === '[object Number]');
550
- }
551
- function isObject(value) {
552
- // Avoid a V8 JIT bug in Chrome 19-20.
553
- // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
554
- const type = typeof value;
555
- return !!value && (type === 'object' || type === 'function');
556
- }
557
- function isFunction(value) {
558
- const type = typeof value;
559
- return !!value && type === 'function';
560
- }
561
- function isDate(value) {
562
- const type = typeof value;
563
- return !!value && type === 'object' && !!value.getTime;
564
- }
565
- function coerceArray(value) {
566
- return Array.isArray(value) ? value : [value];
567
- }
568
- function get(object, path, defaultValue) {
569
- const paths = path.split('.');
570
- let result = object[paths.shift()];
571
- while (result && paths.length) {
572
- result = result[paths.shift()];
573
- }
574
- return result === undefined ? defaultValue : result;
575
- }
576
- function set(object, path, value) {
577
- if (object == null) {
578
- return object;
579
- }
580
- const paths = path.split('.');
581
- let index = -1;
582
- const length = paths.length;
583
- const lastIndex = length - 1;
584
- let nested = object;
585
- while (nested !== null && ++index < length) {
586
- const key = paths[index];
587
- if (isObject(nested)) {
588
- if (index === lastIndex) {
589
- nested[key] = value;
590
- nested = nested[key];
591
- break;
592
- }
593
- else {
594
- if (nested[key] == null) {
595
- nested[key] = {};
596
- }
597
- }
598
- }
599
- nested = nested[key];
600
- }
601
- return object;
602
- }
603
- function isBoolean(value) {
604
- return value === true || value === false || (isObjectLike(value) && baseGetTag(value) === '[object Boolean]');
605
- }
606
- function isClass(value) {
607
- return isFunction(value) && /^\s*class\s+/.test(value.toString());
608
- }
609
- function htmlElementIsEmpty(element) {
610
- if (element && element.childNodes) {
611
- const nodes = element.childNodes;
612
- for (let i = 0; i < nodes.length; i++) {
613
- const node = nodes[i];
614
- if (node.nodeType === Node.ELEMENT_NODE && node.outerHTML.toString().trim().length !== 0) {
615
- return false;
616
- }
617
- else if (node.nodeType === Node.TEXT_NODE && node.textContent.toString().trim().length !== 0) {
618
- return false;
619
- }
620
- else if (node.nodeType !== Node.COMMENT_NODE) {
621
- return false;
622
- }
623
- }
624
- }
625
- return true;
626
- }
627
- function hexToRgb(hexValue, alpha) {
628
- const rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
629
- const hex = hexValue.replace(rgx, (m, r, g, b) => r + r + g + g + b + b);
630
- const rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
631
- if (!rgb)
632
- return;
633
- const resultR = parseInt(rgb[1], 16);
634
- const resultG = parseInt(rgb[2], 16);
635
- const resultB = parseInt(rgb[3], 16);
636
- if (!isUndefinedOrNull(alpha)) {
637
- return `rgba(${resultR}, ${resultG}, ${resultB}, ${alpha})`;
638
- }
639
- else {
640
- return `rgb(${resultR}, ${resultG}, ${resultB})`;
641
- }
642
- }
643
- function dateToUnixTimestamp(date) {
644
- if (isNumber(date)) {
645
- if (date.toString().length === 10) {
646
- return date;
647
- }
648
- else {
649
- return parseInt((date / 1000).toFixed(0), 10);
650
- }
651
- }
652
- else {
653
- return parseInt((date.getTime() / 1000).toFixed(0), 10);
654
- }
655
- }
656
- function clamp(value, min = 0, max = 100) {
657
- return Math.max(min, Math.min(max, value));
658
- }
659
- function keyBy(array, key) {
660
- const result = {};
661
- array.forEach(item => {
662
- const keyValue = item[key];
663
- result[keyValue] = item;
664
- });
665
- return result;
666
- }
667
- function indexKeyBy(array, key) {
668
- const result = {};
669
- array.forEach((item, index) => {
670
- const keyValue = item[key];
671
- result[keyValue] = index;
672
- });
673
- return result;
674
- }
675
- function upperFirst(string) {
676
- return string.slice(0, 1).toUpperCase() + string.slice(1);
677
- }
678
- function camelCase(values) {
679
- if (isArray(values)) {
680
- return values.reduce((result, word, index) => {
681
- word = word.toLowerCase();
682
- return result + (index ? upperFirst(word) : word);
683
- }, '');
684
- }
685
- else {
686
- return;
687
- }
688
- }
689
- function generateRandomStr() {
690
- return Math.random().toString(36).substring(2);
691
- }
692
- function isTemplateRef(value) {
693
- return value instanceof TemplateRef;
694
- }
695
- function isHTMLElement(value) {
696
- return value instanceof HTMLElement;
697
- }
698
- function isElementRef(value) {
699
- return value instanceof ElementRef;
700
- }
701
- /**
702
- * fix angular cdk's coerceBooleanProperty will transform 0 to true
703
- */
704
- function coerceBooleanProperty(value) {
705
- if (value === '' || (value && value !== 'false')) {
706
- return true;
707
- }
708
- else {
709
- return false;
710
- }
711
- }
712
- /**
713
- * @deprecated Please use Angular cdk's coerceNumberProperty instead
714
- */
715
- function coerceNumberValue(value, fallbackValue = 0) {
716
- return _isNumberValue(value) ? Number(value) : fallbackValue;
717
- }
718
- /**
719
- * @deprecated Please use Angular cdk's coerceCssPixelValue instead
720
- */
721
- function coerceCssPixelValue(value) {
722
- value = _isNumberValue(value) ? Number(value) : value;
723
- return coerceCssPixelValue$1(value);
724
- }
725
- function valueFunctionProp(prop, ...args) {
726
- return typeof prop === 'function' ? prop(...args) : prop;
727
- }
728
- function shallowEqual(objA, objB) {
729
- if (objA === objB) {
730
- return true;
731
- }
732
- if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
733
- return false;
734
- }
735
- const keysA = Object.keys(objA);
736
- const keysB = Object.keys(objB);
737
- if (keysA.length !== keysB.length) {
738
- return false;
739
- }
740
- const bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
741
- for (let idx = 0; idx < keysA.length; idx++) {
742
- const key = keysA[idx];
743
- if (!bHasOwnProperty(key)) {
744
- return false;
745
- }
746
- if (objA[key] !== objB[key]) {
747
- return false;
748
- }
749
- }
750
- return true;
751
- }
752
- function concatArray(items, originalItems = []) {
753
- let _originalItems = [];
754
- if (!originalItems) {
755
- _originalItems = [];
756
- }
757
- else {
758
- _originalItems = coerceArray(originalItems);
759
- }
760
- if (items) {
761
- if (isArray(items)) {
762
- return [..._originalItems, ...items];
763
- }
764
- else {
765
- return [..._originalItems, items];
766
- }
767
- }
768
- else {
769
- return _originalItems;
770
- }
771
- }
772
- function humanizeBytes(bytes, noSpace = false, fractionDigits = 1) {
773
- if (bytes === 0) {
774
- return '0 Byte';
775
- }
776
- const k = 1024;
777
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
778
- const i = Math.floor(Math.log(bytes) / Math.log(k));
779
- return parseFloat((bytes / Math.pow(k, i)).toFixed(fractionDigits)) + (noSpace ? '' : ' ') + sizes[i];
780
- }
781
- function isFloat(value) {
782
- if (!value) {
783
- return false;
784
- }
785
- return /^[-+]?([0-9]+([.][0-9]*)?|[.][0-9]+)([Ee][-+]?[0-9]+)?$/.test(value);
786
- }
787
-
788
- var index = /*#__PURE__*/Object.freeze({
789
- __proto__: null,
790
- camelCase: camelCase,
791
- clamp: clamp,
792
- coerceArray: coerceArray,
793
- coerceBooleanProperty: coerceBooleanProperty,
794
- coerceCssPixelValue: coerceCssPixelValue,
795
- coerceNumberValue: coerceNumberValue,
796
- concatArray: concatArray,
797
- dateToUnixTimestamp: dateToUnixTimestamp,
798
- generateRandomStr: generateRandomStr,
799
- get: get,
800
- hexToRgb: hexToRgb,
801
- htmlElementIsEmpty: htmlElementIsEmpty,
802
- humanizeBytes: humanizeBytes,
803
- indexKeyBy: indexKeyBy,
804
- isArray: isArray,
805
- isBoolean: isBoolean,
806
- isClass: isClass,
807
- isDate: isDate,
808
- isElementRef: isElementRef,
809
- isEmpty: isEmpty,
810
- isFloat: isFloat,
811
- isFunction: isFunction,
812
- isHTMLElement: isHTMLElement,
813
- isNull: isNull,
814
- isNumber: isNumber,
815
- isObject: isObject,
816
- isString: isString,
817
- isTemplateRef: isTemplateRef,
818
- isUndefined: isUndefined,
819
- isUndefinedOrNull: isUndefinedOrNull,
820
- keyBy: keyBy,
821
- set: set,
822
- shallowEqual: shallowEqual,
823
- valueFunctionProp: valueFunctionProp
824
- });
825
-
826
850
  const proto = Element.prototype;
827
851
  const vendor = proto.matches ||
828
852
  proto['matchesSelector'] ||
@@ -1341,5 +1365,5 @@ function setWarnDeprecation(enabled) {
1341
1365
  * Generated bundle index. Do not edit.
1342
1366
  */
1343
1367
 
1344
- export { DEFAULT_TIMEZONE, PREFIX, Producer, TinyDate, addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, assertIconOnly, buildReferencesKeyBy, camelCase, clamp, coerceArray, coerceBooleanProperty, coerceCssPixelValue, coerceNumberValue, concatArray, createWarnDeprecation, dateToUnixTimestamp, differenceInCalendarDays, differenceInCalendarMonths, differenceInCalendarQuarters, differenceInCalendarYears, differenceInDays, differenceInHours, differenceInMinutes, differenceInMonths, differenceInSeconds, differenceInWeeks, differenceInYears, dom, eachDayOfInterval, eachHourOfInterval, eachMonthOfInterval, eachWeekOfInterval, eachYearOfInterval, elementMatchClosest, endOfDay, endOfHour, endOfISOWeek, endOfMinute, endOfMonth, endOfQuarter, endOfWeek, endOfYear, fallbackMatches, format, formatDistance, fromUnixTime, generateRandomStr, get, getClientSize, getContainerRect, getDate, getDateFnsLocale, getDay, getDaysInMonth, getElementOffset, getFitContentPosition, getHTMLElementBySelector, getHours, getMinutes, getMonth, getOffset, getQuarter, getSeconds, getStyleAsText, getTime, getUnixTime, getWeek, getWindow, getYear, hasLaterChange, index as helpers, hexToRgb, htmlElementIsEmpty, humanizeBytes, indexKeyBy, isAfter, isArray, isBoolean, isClass, isDate, isDocument, isElement, isElementRef, isEmpty, isFloat, isFunction, isHTMLElement, isInputOrTextarea, isNull, isNumber, isObject, isSameDay, isSameHour, isSameMinute, isSameMonth, isSameQuarter, isSameSecond, isSameYear, isString, isTemplateRef, isToday, isTomorrow, isTouchEvent, isUndefined, isUndefinedOrNull, isValid, isWeekend, isWindow, keyBy, keycodes, log, match, mergeReferences, produce, references, set, setDate, setDay, setDefaultOptions, setMonth, setQuarter, setWarnDeprecation, setYear, shallowEqual, sortRangeValue, startOfDay, startOfHour, startOfISOWeek, startOfMinute, startOfMonth, startOfQuarter, startOfWeek, startOfYear, subBusinessDays, subDays, subHours, subMilliseconds, subMinutes, subMonths, subQuarters, subSeconds, subWeeks, subYears, valueFunctionProp, warn, warnDeprecation };
1368
+ export { DEFAULT_TIMEZONE, PREFIX, Producer, TinyDate, addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, assertIconOnly, buildReferencesKeyBy, camelCase, clamp, coerceArray, coerceBooleanProperty, coerceCssPixelValue, coerceNumberValue, concatArray, createWarnDeprecation, dateToUnixTimestamp, differenceInCalendarDays, differenceInCalendarMonths, differenceInCalendarQuarters, differenceInCalendarYears, differenceInDays, differenceInHours, differenceInMinutes, differenceInMonths, differenceInSeconds, differenceInWeeks, differenceInYears, dom, eachDayOfInterval, eachHourOfInterval, eachMonthOfInterval, eachWeekOfInterval, eachYearOfInterval, elementMatchClosest, endOfDay, endOfHour, endOfISOWeek, endOfMinute, endOfMonth, endOfQuarter, endOfWeek, endOfYear, fallbackMatches, format, formatDistance, fromUnixTime, generateRandomStr, get, getClientSize, getContainerRect, getDate, getDateFnsLocale, getDay, getDaysInMonth, getElementOffset, getFitContentPosition, getHTMLElementBySelector, getHours, getMinutes, getMonth, getOffset, getQuarter, getSeconds, getStyleAsText, getTime, getUnixTime, getWeek, getWindow, getYear, hasLaterChange, hasTimeInStringDate, index as helpers, hexToRgb, htmlElementIsEmpty, humanizeBytes, indexKeyBy, isAfter, isArray, isBoolean, isClass, isDate, isDocument, isElement, isElementRef, isEmpty, isFloat, isFunction, isHTMLElement, isInputOrTextarea, isNull, isNumber, isObject, isSameDay, isSameHour, isSameMinute, isSameMonth, isSameQuarter, isSameSecond, isSameYear, isString, isTemplateRef, isToday, isTomorrow, isTouchEvent, isUndefined, isUndefinedOrNull, isValid, isWeekend, isWindow, keyBy, keycodes, log, match, mergeReferences, produce, references, set, setDate, setDay, setDefaultOptions, setMonth, setQuarter, setWarnDeprecation, setYear, shallowEqual, sortRangeValue, startOfDay, startOfHour, startOfISOWeek, startOfMinute, startOfMonth, startOfQuarter, startOfWeek, startOfYear, subBusinessDays, subDays, subHours, subMilliseconds, subMinutes, subMonths, subQuarters, subSeconds, subWeeks, subYears, valueFunctionProp, warn, warnDeprecation };
1345
1369
  //# sourceMappingURL=ngx-tethys-util.mjs.map