@tetacom/ng-components 1.6.16 → 1.6.18

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.
package/README.md CHANGED
@@ -1,7 +1,3 @@
1
1
  # components
2
2
 
3
3
  This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Running unit tests
6
-
7
- Run `nx test components` to execute the unit tests.
@@ -46,7 +46,7 @@ export declare class DatePickerComponent extends BasePicker implements OnInit, C
46
46
  constructor(_elementRef: ElementRef, _cdr: ChangeDetectorRef, datePipe: DatePipe, localeService: TetaConfigService);
47
47
  ngOnInit(): void;
48
48
  prepareInput(isFirstRender?: boolean): Promise<void>;
49
- onBlur(): void;
49
+ onBlur(event?: FocusEvent): void;
50
50
  setDate(date: any): void;
51
51
  onChange(date: Date): void;
52
52
  registerOnChange(fn: (date: Date) => any): void;
@@ -54,6 +54,8 @@ export declare class DatePickerComponent extends BasePicker implements OnInit, C
54
54
  writeValue(obj: Date | string | number): void;
55
55
  setDisabledState?(isDisabled: boolean): void;
56
56
  ngOnChanges(changes: SimpleChanges): void;
57
+ changeInput(v: any): void;
58
+ private updateCalendarSelection;
57
59
  static ɵfac: i0.ɵɵFactoryDeclaration<DatePickerComponent, never>;
58
60
  static ɵcmp: i0.ɵɵComponentDeclaration<DatePickerComponent, "teta-date-picker", never, { "date": { "alias": "date"; "required": false; }; "showTime": { "alias": "showTime"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "invalid": { "alias": "invalid"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "align": { "alias": "align"; "required": false; }; "verticalAlign": { "alias": "verticalAlign"; "required": false; }; "viewType": { "alias": "viewType"; "required": false; }; "appendToBody": { "alias": "appendToBody"; "required": false; }; "backdrop": { "alias": "backdrop"; "required": false; }; "allowNull": { "alias": "allowNull"; "required": false; }; "open": { "alias": "open"; "required": false; }; "firstDayOfWeek": { "alias": "firstDayOfWeek"; "required": false; }; "disabledDates": { "alias": "disabledDates"; "required": false; }; "disabledPeriods": { "alias": "disabledPeriods"; "required": false; }; "disabledDays": { "alias": "disabledDays"; "required": false; }; "minYearDate": { "alias": "minYearDate"; "required": false; }; "maxYearDate": { "alias": "maxYearDate"; "required": false; }; }, { "selectDate": "selectDate"; }, never, never, true, never>;
59
61
  }
@@ -2361,6 +2361,271 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
2361
2361
  args: [DOCUMENT]
2362
2362
  }] }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.Renderer2 }] });
2363
2363
 
2364
+ const getPrecision = (a) => {
2365
+ if (!isFinite(a)) {
2366
+ return 0;
2367
+ }
2368
+ let e = 1;
2369
+ let p = 0;
2370
+ while (Math.round(a * e) / e !== a) {
2371
+ e *= 10;
2372
+ p++;
2373
+ }
2374
+ return p;
2375
+ };
2376
+ const formatNumber = (value, decimalLength, chunkDelimiter, decimalDelimiter, chunkLength) => {
2377
+ const abs = Math.abs(value);
2378
+ if (0 < abs && 1 > abs) {
2379
+ const firstDigitIndex = Math.floor(Math.abs(Math.log10(abs)));
2380
+ decimalLength += firstDigitIndex;
2381
+ }
2382
+ const precision = Math.min(getPrecision(value), Math.floor(decimalLength));
2383
+ const result = '\\d(?=(\\d{' + chunkLength + '})+' + (precision > 0 ? '\\D' : '$') + ')';
2384
+ const num = value.toFixed(precision);
2385
+ return (decimalDelimiter ? num.replace('.', decimalDelimiter) : num).replace(new RegExp(result, 'g'), '$&' + chunkDelimiter);
2386
+ };
2387
+ const prependZero = (input, length) => ('0'.repeat(length) + input).slice(-length);
2388
+
2389
+ class DateUtil {
2390
+ /**
2391
+ * Вычесть n-дней
2392
+ */
2393
+ static subtractDays(date, days = 0) {
2394
+ if (date && date instanceof Date) {
2395
+ const dt = new Date(date.getTime());
2396
+ dt.setDate(dt.getDate() - days);
2397
+ return dt;
2398
+ }
2399
+ return null;
2400
+ }
2401
+ /**
2402
+ * Добавить n-дней
2403
+ */
2404
+ static addDays(date, days = 0) {
2405
+ if (date && date instanceof Date) {
2406
+ const dt = new Date(date.getTime());
2407
+ dt.setDate(dt.getDate() + days);
2408
+ return dt;
2409
+ }
2410
+ return null;
2411
+ }
2412
+ /**
2413
+ * Получить дату из строки
2414
+ */
2415
+ static parseString(dat) {
2416
+ if (!dat || dat.length < 1) {
2417
+ return null;
2418
+ }
2419
+ const parts = dat.split(' ');
2420
+ const dtPart = parts[0].split('.');
2421
+ const tPart = parts[1]?.split(':') ?? ['0', '0', '0'];
2422
+ const parsedDate = new Date(parseInt(dtPart[2], 10), parseInt(dtPart[1], 10) - 1, parseInt(dtPart[0], 10), parseInt(tPart[0], 10), parseInt(tPart[1], 10), parseInt(tPart[2], 10));
2423
+ if (isNaN(parsedDate.getTime())) {
2424
+ return null;
2425
+ }
2426
+ return parsedDate;
2427
+ }
2428
+ /**
2429
+ * Привести дату к строке
2430
+ */
2431
+ static toString(dat) {
2432
+ if (!dat || !(dat instanceof Date)) {
2433
+ return '';
2434
+ }
2435
+ const month = dat.getMonth() + 1;
2436
+ return `${prependZero(dat.getDate(), 2)}.${prependZero(month, 2)}.${dat.getFullYear()} ${prependZero(dat.getHours(), 2)}:${prependZero(dat.getMinutes(), 2)}:${prependZero(dat.getSeconds(), 2)}`;
2437
+ }
2438
+ /**
2439
+ * Привести дату к строке без часов и минут
2440
+ */
2441
+ static toShortString(dat) {
2442
+ if (!dat || !(dat instanceof Date)) {
2443
+ return '';
2444
+ }
2445
+ const month = dat.getMonth() + 1;
2446
+ return `${prependZero(dat.getDate(), 2)}.${prependZero(month, 2)}.${dat.getFullYear()}`;
2447
+ }
2448
+ /**
2449
+ * Подготовка даты к отправке на сервер, чтобы небыло смещения часов
2450
+ */
2451
+ static convertUTC2DateLocal(date) {
2452
+ if (date && date instanceof Date) {
2453
+ const timezoneOffsetMs = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTimezoneOffset() * 60000;
2454
+ return new Date(date.getTime() - timezoneOffsetMs);
2455
+ }
2456
+ return null;
2457
+ }
2458
+ /**
2459
+ * Подготовка даты к отправке на сервер, чтобы небыло смещения часов
2460
+ */
2461
+ static convertDateLocal2UTC(date) {
2462
+ if (date && date instanceof Date) {
2463
+ const timezoneOffsetMs = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTimezoneOffset() * 60000;
2464
+ return date == null ? null : new Date(date.getTime() + timezoneOffsetMs);
2465
+ }
2466
+ return null;
2467
+ }
2468
+ static convertDateStringsToDates(input) {
2469
+ const regexIso8601 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;
2470
+ if (typeof input === 'string' && regexIso8601.test(input)) {
2471
+ return DateUtil.convertStringToLocalDate(input);
2472
+ }
2473
+ if (typeof input !== 'object' || !input) {
2474
+ return input;
2475
+ }
2476
+ let res;
2477
+ if (input instanceof Array) {
2478
+ res = [];
2479
+ }
2480
+ else {
2481
+ res = {};
2482
+ }
2483
+ return DateUtil.fillConvertDateStringsToDates(res, input);
2484
+ }
2485
+ static convertDates(input) {
2486
+ if (typeof input !== 'object' || !input) {
2487
+ return input;
2488
+ }
2489
+ if (input instanceof Date) {
2490
+ return DateUtil.convertUTC2DateLocal(input);
2491
+ }
2492
+ let res;
2493
+ if (input instanceof Array) {
2494
+ res = [];
2495
+ }
2496
+ else {
2497
+ res = {};
2498
+ }
2499
+ return DateUtil.fillConvertDates(res, input);
2500
+ }
2501
+ static getMonthDaysCount(date) {
2502
+ return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
2503
+ }
2504
+ // Возвращает список месяцев между двумя датами
2505
+ static getRangeOfMonths(start, end) {
2506
+ if (start > end || !start || !end) {
2507
+ return null;
2508
+ }
2509
+ const resDates = [];
2510
+ let i = 0;
2511
+ let dateTmp = new Date(start.getFullYear(), start.getMonth() + i, 1);
2512
+ while (end >= dateTmp) {
2513
+ resDates.push(dateTmp);
2514
+ i++;
2515
+ dateTmp = new Date(start.getFullYear(), start.getMonth() + i, 1);
2516
+ }
2517
+ return resDates;
2518
+ }
2519
+ static truncateToMonth(date) {
2520
+ const res = new Date(date.getFullYear(), date.getMonth(), 1, 0, 0, 0);
2521
+ return res;
2522
+ }
2523
+ static truncateToDay(date) {
2524
+ const res = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
2525
+ return res;
2526
+ }
2527
+ static truncateToHour(date) {
2528
+ const res = new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), 0, 0);
2529
+ return res;
2530
+ }
2531
+ static toISOString(date) {
2532
+ return new Date(date - new Date().getTimezoneOffset() * 60000).toISOString().slice(0, -5) + 'Z';
2533
+ }
2534
+ static isValidDate(date) {
2535
+ return date instanceof Date && !isNaN(date.getTime());
2536
+ }
2537
+ static millisecondToHumanFormat(milliSeconds, maxValue = 5000, showDays = false) {
2538
+ const negative = milliSeconds < 0;
2539
+ if (negative) {
2540
+ milliSeconds = -milliSeconds;
2541
+ }
2542
+ let d;
2543
+ if (showDays) {
2544
+ d = Math.trunc(milliSeconds / (60000 * 60 * 24));
2545
+ milliSeconds = milliSeconds - 60000 * 60 * 24 * d;
2546
+ }
2547
+ const h = Math.trunc(milliSeconds / (60000 * 60));
2548
+ milliSeconds = milliSeconds - 60000 * 60 * h;
2549
+ const m = Math.trunc(milliSeconds / 60000);
2550
+ milliSeconds = milliSeconds - 60000 * m;
2551
+ const s = Math.trunc(milliSeconds / 1000);
2552
+ milliSeconds = milliSeconds - 1000 * s;
2553
+ const frac = milliSeconds;
2554
+ let result = m ? m + ' м ' : ''; // start with minutes
2555
+ if (maxValue < 60000 * 60) {
2556
+ if (s) {
2557
+ result = result + s + ' с '; // add seconds value
2558
+ }
2559
+ if (s === 0 && !m) {
2560
+ result = result + '0 c';
2561
+ }
2562
+ }
2563
+ if (maxValue < 5000) {
2564
+ result = frac ? result + frac + ' мс ' : result;
2565
+ }
2566
+ if (h) {
2567
+ result = h + ' ч ' + result;
2568
+ }
2569
+ if (d) {
2570
+ result = d + 'д ' + result;
2571
+ }
2572
+ if (negative) {
2573
+ result = '-' + result;
2574
+ }
2575
+ return result.trim();
2576
+ }
2577
+ static fillConvertDates(result, input) {
2578
+ for (const key in input) {
2579
+ if (!input.hasOwnProperty || !input.hasOwnProperty(key)) {
2580
+ continue;
2581
+ }
2582
+ if (input.hasOwnProperty(key)) {
2583
+ let value = input[key];
2584
+ if (value instanceof Date) {
2585
+ if (value !== null && value !== undefined) {
2586
+ value = DateUtil.convertUTC2DateLocal(value);
2587
+ }
2588
+ result[key] = value;
2589
+ }
2590
+ else if (typeof value === 'object') {
2591
+ result[key] = DateUtil.convertDates(value);
2592
+ }
2593
+ else {
2594
+ result[key] = value;
2595
+ }
2596
+ }
2597
+ }
2598
+ return result;
2599
+ }
2600
+ static fillConvertDateStringsToDates(result, input) {
2601
+ const regexIso8601 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z?)?$/i;
2602
+ for (const key in input) {
2603
+ if (!input.hasOwnProperty(key)) {
2604
+ continue;
2605
+ }
2606
+ const value = input[key];
2607
+ if (typeof value === 'string' && regexIso8601.test(value)) {
2608
+ result[key] = DateUtil.convertStringToLocalDate(value);
2609
+ }
2610
+ else if (typeof value === 'object') {
2611
+ result[key] = DateUtil.convertDateStringsToDates(value);
2612
+ }
2613
+ else {
2614
+ result[key] = value;
2615
+ }
2616
+ }
2617
+ return result;
2618
+ }
2619
+ static convertStringToLocalDate(dateString) {
2620
+ const milliseconds = Date.parse(dateString);
2621
+ if (!isNaN(milliseconds)) {
2622
+ const dt = new Date(milliseconds);
2623
+ return DateUtil.convertDateLocal2UTC(dt);
2624
+ }
2625
+ return null;
2626
+ }
2627
+ }
2628
+
2364
2629
  const DATE_PICKER_CONTROL_VALUE_ACCESSOR = {
2365
2630
  provide: NG_VALUE_ACCESSOR,
2366
2631
  useExisting: forwardRef(() => DatePickerComponent),
@@ -2439,7 +2704,10 @@ class DatePickerComponent extends BasePicker {
2439
2704
  }
2440
2705
  this.changePlaceholder(str);
2441
2706
  }
2442
- onBlur() {
2707
+ onBlur(event) {
2708
+ if (event?.target?.value === DateUtil.toShortString(this.date)) {
2709
+ return;
2710
+ }
2443
2711
  if (this.allowNull && this.inputText.trim() === '') {
2444
2712
  this.setDate(null);
2445
2713
  this.emitValue(null);
@@ -2453,7 +2721,9 @@ class DatePickerComponent extends BasePicker {
2453
2721
  if (this.showTime) {
2454
2722
  date = new Date(date.setHours(hours || 0, mins || 0));
2455
2723
  }
2456
- this.changeSelectedDate(this.getAvailableDate(this.minDate, this.maxDate, date));
2724
+ const availableDate = this.getAvailableDate(this.minDate, this.maxDate, date);
2725
+ this.changeSelectedDate(availableDate);
2726
+ this.selectedDate.next(availableDate);
2457
2727
  }
2458
2728
  else {
2459
2729
  this.setDate(this.date);
@@ -2499,8 +2769,33 @@ class DatePickerComponent extends BasePicker {
2499
2769
  ngOnChanges(changes) {
2500
2770
  this.prepareInput(false);
2501
2771
  }
2772
+ changeInput(v) {
2773
+ this.changePlaceholder(v);
2774
+ this.updateCalendarSelection(v);
2775
+ }
2776
+ updateCalendarSelection(inputValue) {
2777
+ if (!inputValue || inputValue.trim() === '') {
2778
+ if (this.allowNull) {
2779
+ this.selectedDate.next(null);
2780
+ }
2781
+ return;
2782
+ }
2783
+ const val = inputValue.split(',');
2784
+ const { day, year, month } = this.getDateFromStr(val[0]);
2785
+ const { mins, hours } = this.getTimeFromStr(val[1]);
2786
+ if (day && year && month) {
2787
+ let date = new Date(year, month - 1, day);
2788
+ if (this.showTime && hours !== null && mins !== null) {
2789
+ date = new Date(date.setHours(hours, mins));
2790
+ }
2791
+ if (!isNaN(date.getTime())) {
2792
+ const availableDate = this.getAvailableDate(this.minDate, this.maxDate, date);
2793
+ this.selectedDate.next(availableDate);
2794
+ }
2795
+ }
2796
+ }
2502
2797
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: DatePickerComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1$1.DatePipe }, { token: TetaConfigService }], target: i0.ɵɵFactoryTarget.Component }); }
2503
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: DatePickerComponent, isStandalone: true, selector: "teta-date-picker", inputs: { date: "date", showTime: "showTime", minDate: "minDate", maxDate: "maxDate", invalid: "invalid", disabled: "disabled", align: "align", verticalAlign: "verticalAlign", viewType: "viewType", appendToBody: "appendToBody", backdrop: "backdrop", allowNull: "allowNull", open: "open", firstDayOfWeek: "firstDayOfWeek", disabledDates: "disabledDates", disabledPeriods: "disabledPeriods", disabledDays: "disabledDays", minYearDate: "minYearDate", maxYearDate: "maxYearDate" }, outputs: { selectDate: "selectDate" }, host: { properties: { "class.datepicker": "this.classDatepicker", "class.datepicker-time": "this.dateTimeClass", "tabindex": "this.tabindex" } }, providers: [DATE_PICKER_CONTROL_VALUE_ACCESSOR, DatePipe], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "@if ({ selectedDate: selectedDate | async }; as data) {\n <teta-dropdown\n class=\"row row_auto\"\n [appendToBody]=\"appendToBody\"\n [backdrop]=\"backdrop\"\n [open]=\"open\"\n (openChange)=\"openChange($event)\"\n [viewType]=\"viewType\"\n [disabled]=\"disabled\"\n [verticalAlign]=\"verticalAlign\"\n [align]=\"align\"\n [autoCloseIgnore]=\"['esc', 'inside', 'enter']\"\n >\n <div\n tetaDropdownHead\n [class]=\"'datepicker-head font-body-3 gap-8 datepicker_' + viewType\"\n [ngClass]=\"{ 'datepicker-head_invalid': invalid, 'datepicker-head_disabled': disabled }\"\n >\n <teta-input class=\"row row_auto flex\">\n <div [class]=\"'row_auto row datepicker_' + viewType\">\n <div class=\"row row_auto position-relative font-body-3 align-center\">\n <input\n [ngClass]=\"{ 'color-text-90': !disabled }\"\n [disabled]=\"disabled\"\n #input\n style=\"z-index: 1\"\n class=\"row_auto border-0\"\n (keydown)=\"checkEnter($event)\"\n [(ngModel)]=\"inputText\"\n (ngModelChange)=\"changeInput($event)\"\n [maskito]=\"maskitoOptions\"\n />\n @if (data.selectedDate || allowNull) {\n <div\n (click)=\"input.focus()\"\n class=\"position-absolute color-text-10\"\n style=\"cursor: text; user-select: none\"\n >\n {{ placeholder }}\n </div>\n }\n </div>\n <teta-icon [name]=\"'calendar'\" [palette]=\"'text'\"></teta-icon>\n </div>\n </teta-input>\n </div>\n <div tetaDropdownContent (click)=\"$event.preventDefault()\">\n <teta-date-calendar\n [isDateNull]=\"date === null\"\n [open]=\"open\"\n [max]=\"maxDate\"\n [min]=\"minDate\"\n (setDate)=\"changeSelectedDate($event)\"\n [selectedDate]=\"data.selectedDate\"\n [viewType]=\"viewType\"\n [locale]=\"locale | async\"\n ></teta-date-calendar>\n </div>\n </teta-dropdown>\n}\n", styles: [""], dependencies: [{ kind: "component", type: DropdownComponent, selector: "teta-dropdown", exportAs: ["dropdown"] }, { kind: "directive", type: DropdownHeadDirective, selector: "[tetaDropdownHead]" }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: InputComponent, selector: "teta-input", inputs: ["label", "hint", "viewType", "horizontal", "required"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MaskitoModule }, { kind: "directive", type: i4.MaskitoDirective, selector: "[maskito]", inputs: ["maskito", "maskitoElement"] }, { kind: "directive", type: i4.MaskitoCVA, selector: "input[maskito], textarea[maskito]", inputs: ["maskito"] }, { kind: "component", type: IconComponent, selector: "teta-icon", inputs: ["name", "size", "palette", "class"] }, { kind: "directive", type: DropdownContentDirective, selector: "[tetaDropdownContent]" }, { kind: "component", type: DateCalendarComponent, selector: "teta-date-calendar", inputs: ["selectedDate", "open", "locale", "viewType", "min", "isDateNull", "max"], outputs: ["setDate"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2798
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: DatePickerComponent, isStandalone: true, selector: "teta-date-picker", inputs: { date: "date", showTime: "showTime", minDate: "minDate", maxDate: "maxDate", invalid: "invalid", disabled: "disabled", align: "align", verticalAlign: "verticalAlign", viewType: "viewType", appendToBody: "appendToBody", backdrop: "backdrop", allowNull: "allowNull", open: "open", firstDayOfWeek: "firstDayOfWeek", disabledDates: "disabledDates", disabledPeriods: "disabledPeriods", disabledDays: "disabledDays", minYearDate: "minYearDate", maxYearDate: "maxYearDate" }, outputs: { selectDate: "selectDate" }, host: { properties: { "class.datepicker": "this.classDatepicker", "class.datepicker-time": "this.dateTimeClass", "tabindex": "this.tabindex" } }, providers: [DATE_PICKER_CONTROL_VALUE_ACCESSOR, DatePipe], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "@if ({ selectedDate: selectedDate | async }; as data) {\n <teta-dropdown\n class=\"row row_auto\"\n [appendToBody]=\"appendToBody\"\n [backdrop]=\"backdrop\"\n [open]=\"open\"\n (openChange)=\"openChange($event)\"\n [viewType]=\"viewType\"\n [disabled]=\"disabled\"\n [verticalAlign]=\"verticalAlign\"\n [align]=\"align\"\n [autoCloseIgnore]=\"['esc', 'inside', 'enter']\"\n >\n <div\n tetaDropdownHead\n [class]=\"'datepicker-head font-body-3 gap-8 datepicker_' + viewType\"\n [ngClass]=\"{ 'datepicker-head_invalid': invalid, 'datepicker-head_disabled': disabled }\"\n >\n <teta-input class=\"row row_auto flex\">\n <div [class]=\"'row_auto row datepicker_' + viewType\">\n <div class=\"row row_auto position-relative font-body-3 align-center\">\n <input\n [ngClass]=\"{ 'color-text-90': !disabled }\"\n [disabled]=\"disabled\"\n #input\n style=\"z-index: 1\"\n class=\"row_auto border-0\"\n (keydown)=\"checkEnter($event)\"\n [(ngModel)]=\"inputText\"\n (ngModelChange)=\"changeInput($event)\"\n (blur)=\"onBlur($event)\"\n [maskito]=\"maskitoOptions\"\n />\n @if (data.selectedDate || allowNull) {\n <div\n (click)=\"input.focus()\"\n class=\"position-absolute color-text-10\"\n style=\"cursor: text; user-select: none\"\n >\n {{ placeholder }}\n </div>\n }\n </div>\n <teta-icon [name]=\"'calendar'\" [palette]=\"'text'\"></teta-icon>\n </div>\n </teta-input>\n </div>\n <div tetaDropdownContent (click)=\"$event.preventDefault()\">\n <teta-date-calendar\n [isDateNull]=\"data.selectedDate === null\"\n [open]=\"open\"\n [max]=\"maxDate\"\n [min]=\"minDate\"\n (setDate)=\"changeSelectedDate($event)\"\n [selectedDate]=\"data.selectedDate\"\n [viewType]=\"viewType\"\n [locale]=\"locale | async\"\n ></teta-date-calendar>\n </div>\n </teta-dropdown>\n}\n", styles: [""], dependencies: [{ kind: "component", type: DropdownComponent, selector: "teta-dropdown", exportAs: ["dropdown"] }, { kind: "directive", type: DropdownHeadDirective, selector: "[tetaDropdownHead]" }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: InputComponent, selector: "teta-input", inputs: ["label", "hint", "viewType", "horizontal", "required"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MaskitoModule }, { kind: "directive", type: i4.MaskitoDirective, selector: "[maskito]", inputs: ["maskito", "maskitoElement"] }, { kind: "directive", type: i4.MaskitoCVA, selector: "input[maskito], textarea[maskito]", inputs: ["maskito"] }, { kind: "component", type: IconComponent, selector: "teta-icon", inputs: ["name", "size", "palette", "class"] }, { kind: "directive", type: DropdownContentDirective, selector: "[tetaDropdownContent]" }, { kind: "component", type: DateCalendarComponent, selector: "teta-date-calendar", inputs: ["selectedDate", "open", "locale", "viewType", "min", "isDateNull", "max"], outputs: ["setDate"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2504
2799
  }
2505
2800
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: DatePickerComponent, decorators: [{
2506
2801
  type: Component,
@@ -2515,7 +2810,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
2515
2810
  DropdownContentDirective,
2516
2811
  DateCalendarComponent,
2517
2812
  AsyncPipe,
2518
- ], template: "@if ({ selectedDate: selectedDate | async }; as data) {\n <teta-dropdown\n class=\"row row_auto\"\n [appendToBody]=\"appendToBody\"\n [backdrop]=\"backdrop\"\n [open]=\"open\"\n (openChange)=\"openChange($event)\"\n [viewType]=\"viewType\"\n [disabled]=\"disabled\"\n [verticalAlign]=\"verticalAlign\"\n [align]=\"align\"\n [autoCloseIgnore]=\"['esc', 'inside', 'enter']\"\n >\n <div\n tetaDropdownHead\n [class]=\"'datepicker-head font-body-3 gap-8 datepicker_' + viewType\"\n [ngClass]=\"{ 'datepicker-head_invalid': invalid, 'datepicker-head_disabled': disabled }\"\n >\n <teta-input class=\"row row_auto flex\">\n <div [class]=\"'row_auto row datepicker_' + viewType\">\n <div class=\"row row_auto position-relative font-body-3 align-center\">\n <input\n [ngClass]=\"{ 'color-text-90': !disabled }\"\n [disabled]=\"disabled\"\n #input\n style=\"z-index: 1\"\n class=\"row_auto border-0\"\n (keydown)=\"checkEnter($event)\"\n [(ngModel)]=\"inputText\"\n (ngModelChange)=\"changeInput($event)\"\n [maskito]=\"maskitoOptions\"\n />\n @if (data.selectedDate || allowNull) {\n <div\n (click)=\"input.focus()\"\n class=\"position-absolute color-text-10\"\n style=\"cursor: text; user-select: none\"\n >\n {{ placeholder }}\n </div>\n }\n </div>\n <teta-icon [name]=\"'calendar'\" [palette]=\"'text'\"></teta-icon>\n </div>\n </teta-input>\n </div>\n <div tetaDropdownContent (click)=\"$event.preventDefault()\">\n <teta-date-calendar\n [isDateNull]=\"date === null\"\n [open]=\"open\"\n [max]=\"maxDate\"\n [min]=\"minDate\"\n (setDate)=\"changeSelectedDate($event)\"\n [selectedDate]=\"data.selectedDate\"\n [viewType]=\"viewType\"\n [locale]=\"locale | async\"\n ></teta-date-calendar>\n </div>\n </teta-dropdown>\n}\n" }]
2813
+ ], template: "@if ({ selectedDate: selectedDate | async }; as data) {\n <teta-dropdown\n class=\"row row_auto\"\n [appendToBody]=\"appendToBody\"\n [backdrop]=\"backdrop\"\n [open]=\"open\"\n (openChange)=\"openChange($event)\"\n [viewType]=\"viewType\"\n [disabled]=\"disabled\"\n [verticalAlign]=\"verticalAlign\"\n [align]=\"align\"\n [autoCloseIgnore]=\"['esc', 'inside', 'enter']\"\n >\n <div\n tetaDropdownHead\n [class]=\"'datepicker-head font-body-3 gap-8 datepicker_' + viewType\"\n [ngClass]=\"{ 'datepicker-head_invalid': invalid, 'datepicker-head_disabled': disabled }\"\n >\n <teta-input class=\"row row_auto flex\">\n <div [class]=\"'row_auto row datepicker_' + viewType\">\n <div class=\"row row_auto position-relative font-body-3 align-center\">\n <input\n [ngClass]=\"{ 'color-text-90': !disabled }\"\n [disabled]=\"disabled\"\n #input\n style=\"z-index: 1\"\n class=\"row_auto border-0\"\n (keydown)=\"checkEnter($event)\"\n [(ngModel)]=\"inputText\"\n (ngModelChange)=\"changeInput($event)\"\n (blur)=\"onBlur($event)\"\n [maskito]=\"maskitoOptions\"\n />\n @if (data.selectedDate || allowNull) {\n <div\n (click)=\"input.focus()\"\n class=\"position-absolute color-text-10\"\n style=\"cursor: text; user-select: none\"\n >\n {{ placeholder }}\n </div>\n }\n </div>\n <teta-icon [name]=\"'calendar'\" [palette]=\"'text'\"></teta-icon>\n </div>\n </teta-input>\n </div>\n <div tetaDropdownContent (click)=\"$event.preventDefault()\">\n <teta-date-calendar\n [isDateNull]=\"data.selectedDate === null\"\n [open]=\"open\"\n [max]=\"maxDate\"\n [min]=\"minDate\"\n (setDate)=\"changeSelectedDate($event)\"\n [selectedDate]=\"data.selectedDate\"\n [viewType]=\"viewType\"\n [locale]=\"locale | async\"\n ></teta-date-calendar>\n </div>\n </teta-dropdown>\n}\n" }]
2519
2814
  }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1$1.DatePipe }, { type: TetaConfigService }], propDecorators: { date: [{
2520
2815
  type: Input
2521
2816
  }], showTime: [{
@@ -3744,31 +4039,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
3744
4039
  type: Output
3745
4040
  }] } });
3746
4041
 
3747
- const getPrecision = (a) => {
3748
- if (!isFinite(a)) {
3749
- return 0;
3750
- }
3751
- let e = 1;
3752
- let p = 0;
3753
- while (Math.round(a * e) / e !== a) {
3754
- e *= 10;
3755
- p++;
3756
- }
3757
- return p;
3758
- };
3759
- const formatNumber = (value, decimalLength, chunkDelimiter, decimalDelimiter, chunkLength) => {
3760
- const abs = Math.abs(value);
3761
- if (0 < abs && 1 > abs) {
3762
- const firstDigitIndex = Math.floor(Math.abs(Math.log10(abs)));
3763
- decimalLength += firstDigitIndex;
3764
- }
3765
- const precision = Math.min(getPrecision(value), Math.floor(decimalLength));
3766
- const result = '\\d(?=(\\d{' + chunkLength + '})+' + (precision > 0 ? '\\D' : '$') + ')';
3767
- const num = value.toFixed(precision);
3768
- return (decimalDelimiter ? num.replace('.', decimalDelimiter) : num).replace(new RegExp(result, 'g'), '$&' + chunkDelimiter);
3769
- };
3770
- const prependZero = (input, length) => ('0'.repeat(length) + input).slice(-length);
3771
-
3772
4042
  class NumberPipe {
3773
4043
  transform(value, decimalLength = 2, chunkDelimiter = '', decimalDelimiter = '.', chunkLength = 3) {
3774
4044
  if (value === null || value === undefined || value === '') {
@@ -6593,236 +6863,6 @@ var SelectType;
6593
6863
  SelectType[SelectType["mouse"] = 2] = "mouse";
6594
6864
  })(SelectType || (SelectType = {}));
6595
6865
 
6596
- class DateUtil {
6597
- /**
6598
- * Вычесть n-дней
6599
- */
6600
- static subtractDays(date, days = 0) {
6601
- if (date && date instanceof Date) {
6602
- const dt = new Date(date.getTime());
6603
- dt.setDate(dt.getDate() - days);
6604
- return dt;
6605
- }
6606
- return null;
6607
- }
6608
- /**
6609
- * Добавить n-дней
6610
- */
6611
- static addDays(date, days = 0) {
6612
- if (date && date instanceof Date) {
6613
- const dt = new Date(date.getTime());
6614
- dt.setDate(dt.getDate() + days);
6615
- return dt;
6616
- }
6617
- return null;
6618
- }
6619
- /**
6620
- * Получить дату из строки
6621
- */
6622
- static parseString(dat) {
6623
- if (!dat || dat.length < 1) {
6624
- return null;
6625
- }
6626
- const parts = dat.split(' ');
6627
- const dtPart = parts[0].split('.');
6628
- const tPart = parts[1]?.split(':') ?? ['0', '0', '0'];
6629
- const parsedDate = new Date(parseInt(dtPart[2], 10), parseInt(dtPart[1], 10) - 1, parseInt(dtPart[0], 10), parseInt(tPart[0], 10), parseInt(tPart[1], 10), parseInt(tPart[2], 10));
6630
- if (isNaN(parsedDate.getTime())) {
6631
- return null;
6632
- }
6633
- return parsedDate;
6634
- }
6635
- /**
6636
- * Привести дату к строке
6637
- */
6638
- static toString(dat) {
6639
- if (!dat || !(dat instanceof Date)) {
6640
- return '';
6641
- }
6642
- const month = dat.getMonth() + 1;
6643
- return `${prependZero(dat.getDate(), 2)}.${prependZero(month, 2)}.${dat.getFullYear()} ${prependZero(dat.getHours(), 2)}:${prependZero(dat.getMinutes(), 2)}:${prependZero(dat.getSeconds(), 2)}`;
6644
- }
6645
- /**
6646
- * Подготовка даты к отправке на сервер, чтобы небыло смещения часов
6647
- */
6648
- static convertUTC2DateLocal(date) {
6649
- if (date && date instanceof Date) {
6650
- const timezoneOffsetMs = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTimezoneOffset() * 60000;
6651
- return new Date(date.getTime() - timezoneOffsetMs);
6652
- }
6653
- return null;
6654
- }
6655
- /**
6656
- * Подготовка даты к отправке на сервер, чтобы небыло смещения часов
6657
- */
6658
- static convertDateLocal2UTC(date) {
6659
- if (date && date instanceof Date) {
6660
- const timezoneOffsetMs = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTimezoneOffset() * 60000;
6661
- return date == null ? null : new Date(date.getTime() + timezoneOffsetMs);
6662
- }
6663
- return null;
6664
- }
6665
- static convertDateStringsToDates(input) {
6666
- const regexIso8601 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;
6667
- if (typeof input === 'string' && regexIso8601.test(input)) {
6668
- return DateUtil.convertStringToLocalDate(input);
6669
- }
6670
- if (typeof input !== 'object' || !input) {
6671
- return input;
6672
- }
6673
- let res;
6674
- if (input instanceof Array) {
6675
- res = [];
6676
- }
6677
- else {
6678
- res = {};
6679
- }
6680
- return DateUtil.fillConvertDateStringsToDates(res, input);
6681
- }
6682
- static convertDates(input) {
6683
- if (typeof input !== 'object' || !input) {
6684
- return input;
6685
- }
6686
- if (input instanceof Date) {
6687
- return DateUtil.convertUTC2DateLocal(input);
6688
- }
6689
- let res;
6690
- if (input instanceof Array) {
6691
- res = [];
6692
- }
6693
- else {
6694
- res = {};
6695
- }
6696
- return DateUtil.fillConvertDates(res, input);
6697
- }
6698
- static getMonthDaysCount(date) {
6699
- return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
6700
- }
6701
- // Возвращает список месяцев между двумя датами
6702
- static getRangeOfMonths(start, end) {
6703
- if (start > end || !start || !end) {
6704
- return null;
6705
- }
6706
- const resDates = [];
6707
- let i = 0;
6708
- let dateTmp = new Date(start.getFullYear(), start.getMonth() + i, 1);
6709
- while (end >= dateTmp) {
6710
- resDates.push(dateTmp);
6711
- i++;
6712
- dateTmp = new Date(start.getFullYear(), start.getMonth() + i, 1);
6713
- }
6714
- return resDates;
6715
- }
6716
- static truncateToMonth(date) {
6717
- const res = new Date(date.getFullYear(), date.getMonth(), 1, 0, 0, 0);
6718
- return res;
6719
- }
6720
- static truncateToDay(date) {
6721
- const res = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
6722
- return res;
6723
- }
6724
- static truncateToHour(date) {
6725
- const res = new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), 0, 0);
6726
- return res;
6727
- }
6728
- static toISOString(date) {
6729
- return new Date(date - new Date().getTimezoneOffset() * 60000).toISOString().slice(0, -5) + 'Z';
6730
- }
6731
- static isValidDate(date) {
6732
- return date instanceof Date && !isNaN(date.getTime());
6733
- }
6734
- static millisecondToHumanFormat(milliSeconds, maxValue = 5000, showDays = false) {
6735
- const negative = milliSeconds < 0;
6736
- if (negative) {
6737
- milliSeconds = -milliSeconds;
6738
- }
6739
- let d;
6740
- if (showDays) {
6741
- d = Math.trunc(milliSeconds / (60000 * 60 * 24));
6742
- milliSeconds = milliSeconds - 60000 * 60 * 24 * d;
6743
- }
6744
- const h = Math.trunc(milliSeconds / (60000 * 60));
6745
- milliSeconds = milliSeconds - 60000 * 60 * h;
6746
- const m = Math.trunc(milliSeconds / 60000);
6747
- milliSeconds = milliSeconds - 60000 * m;
6748
- const s = Math.trunc(milliSeconds / 1000);
6749
- milliSeconds = milliSeconds - 1000 * s;
6750
- const frac = milliSeconds;
6751
- let result = m ? m + ' м ' : ''; // start with minutes
6752
- if (maxValue < 60000 * 60) {
6753
- if (s) {
6754
- result = result + s + ' с '; // add seconds value
6755
- }
6756
- if (s === 0 && !m) {
6757
- result = result + '0 c';
6758
- }
6759
- }
6760
- if (maxValue < 5000) {
6761
- result = frac ? result + frac + ' мс ' : result;
6762
- }
6763
- if (h) {
6764
- result = h + ' ч ' + result;
6765
- }
6766
- if (d) {
6767
- result = d + 'д ' + result;
6768
- }
6769
- if (negative) {
6770
- result = '-' + result;
6771
- }
6772
- return result.trim();
6773
- }
6774
- static fillConvertDates(result, input) {
6775
- for (const key in input) {
6776
- if (!input.hasOwnProperty || !input.hasOwnProperty(key)) {
6777
- continue;
6778
- }
6779
- if (input.hasOwnProperty(key)) {
6780
- let value = input[key];
6781
- if (value instanceof Date) {
6782
- if (value !== null && value !== undefined) {
6783
- value = DateUtil.convertUTC2DateLocal(value);
6784
- }
6785
- result[key] = value;
6786
- }
6787
- else if (typeof value === 'object') {
6788
- result[key] = DateUtil.convertDates(value);
6789
- }
6790
- else {
6791
- result[key] = value;
6792
- }
6793
- }
6794
- }
6795
- return result;
6796
- }
6797
- static fillConvertDateStringsToDates(result, input) {
6798
- const regexIso8601 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z?)?$/i;
6799
- for (const key in input) {
6800
- if (!input.hasOwnProperty(key)) {
6801
- continue;
6802
- }
6803
- const value = input[key];
6804
- if (typeof value === 'string' && regexIso8601.test(value)) {
6805
- result[key] = DateUtil.convertStringToLocalDate(value);
6806
- }
6807
- else if (typeof value === 'object') {
6808
- result[key] = DateUtil.convertDateStringsToDates(value);
6809
- }
6810
- else {
6811
- result[key] = value;
6812
- }
6813
- }
6814
- return result;
6815
- }
6816
- static convertStringToLocalDate(dateString) {
6817
- const milliseconds = Date.parse(dateString);
6818
- if (!isNaN(milliseconds)) {
6819
- const dt = new Date(milliseconds);
6820
- return DateUtil.convertDateLocal2UTC(dt);
6821
- }
6822
- return null;
6823
- }
6824
- }
6825
-
6826
6866
  class ColumnReorderEvent {
6827
6867
  constructor(source, target) {
6828
6868
  this.source = source;