myrta-ui 17.1.72 → 17.1.75

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.
@@ -340,7 +340,6 @@ class AlertComponent {
340
340
  return `${AlertIconClasses[this.color]}`;
341
341
  }
342
342
  onCloseClick() {
343
- console.log(1);
344
343
  this.close.emit(null);
345
344
  }
346
345
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AlertComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -4501,44 +4500,68 @@ class PaginatorComponent {
4501
4500
  .fill(1)
4502
4501
  .map((item, index) => ({ index: index + 1, active: index + 1 === this.currentPage }));
4503
4502
  }
4503
+ // TO DO: пока оставлю для тестов
4504
+ // public get getViewItems(): PaginatorItem[] {
4505
+ // return this.getNumbers.filter((item, index) => {
4506
+ // if (this.currentPage === 1 && this.currentPage < this.getItems) {
4507
+ // return item.index === this.currentPage ||
4508
+ // item.index === this.currentPage + 1 ||
4509
+ // item.index === this.currentPage + 2 ||
4510
+ // item.index === this.currentPage + 3 ||
4511
+ // item.index === this.currentPage + 4;
4512
+ // } else if (this.currentPage == 2 && this.currentPage < this.getItems) {
4513
+ // return item.index === this.currentPage - 1 ||
4514
+ // item.index === this.currentPage ||
4515
+ // item.index === this.currentPage + 1 ||
4516
+ // item.index === this.currentPage + 2 ||
4517
+ // item.index === this.currentPage + 3;
4518
+ // } else if (this.currentPage == this.getItems - 1 && this.currentPage < this.getItems) {
4519
+ // return item.index === this.currentPage - 3 ||
4520
+ // item.index === this.currentPage - 2 ||
4521
+ // item.index === this.currentPage - 1 ||
4522
+ // item.index === this.currentPage ||
4523
+ // item.index === this.currentPage + 1;
4524
+ // } else if (this.currentPage > 1 && this.currentPage < this.getItems) {
4525
+ // return item.index === this.currentPage - 2 ||
4526
+ // item.index === this.currentPage - 1 ||
4527
+ // item.index === this.currentPage ||
4528
+ // item.index === this.currentPage + 1 ||
4529
+ // item.index === this.currentPage + 2;
4530
+ // } else {
4531
+ // return item.index === this.currentPage - 4 ||
4532
+ // item.index === this.currentPage - 3 ||
4533
+ // item.index === this.currentPage - 2 ||
4534
+ // item.index === this.currentPage - 1 ||
4535
+ // item.index === this.currentPage;
4536
+ // }
4537
+ // });
4538
+ // }
4539
+ // Упрощенная версия getViewItems()
4504
4540
  get getViewItems() {
4505
- return this.getNumbers.filter((item, index) => {
4506
- if (this.currentPage === 1 && this.currentPage < this.getItems) {
4507
- return item.index === this.currentPage ||
4508
- item.index === this.currentPage + 1 ||
4509
- item.index === this.currentPage + 2 ||
4510
- item.index === this.currentPage + 3 ||
4511
- item.index === this.currentPage + 4;
4512
- }
4513
- else if (this.currentPage == 2 && this.currentPage < this.getItems) {
4514
- return item.index === this.currentPage - 1 ||
4515
- item.index === this.currentPage ||
4516
- item.index === this.currentPage + 1 ||
4517
- item.index === this.currentPage + 2 ||
4518
- item.index === this.currentPage + 3;
4519
- }
4520
- else if (this.currentPage == this.getItems - 1 && this.currentPage < this.getItems) {
4521
- return item.index === this.currentPage - 3 ||
4522
- item.index === this.currentPage - 2 ||
4523
- item.index === this.currentPage - 1 ||
4524
- item.index === this.currentPage ||
4525
- item.index === this.currentPage + 1;
4526
- }
4527
- else if (this.currentPage > 1 && this.currentPage < this.getItems) {
4528
- return item.index === this.currentPage - 2 ||
4529
- item.index === this.currentPage - 1 ||
4530
- item.index === this.currentPage ||
4531
- item.index === this.currentPage + 1 ||
4532
- item.index === this.currentPage + 2;
4533
- }
4534
- else {
4535
- return item.index === this.currentPage - 4 ||
4536
- item.index === this.currentPage - 3 ||
4537
- item.index === this.currentPage - 2 ||
4538
- item.index === this.currentPage - 1 ||
4539
- item.index === this.currentPage;
4540
- }
4541
- });
4541
+ const totalPages = this.getItems;
4542
+ const current = this.currentPage;
4543
+ const delta = 2; // количество страниц по бокам от текущей
4544
+ const range = [];
4545
+ for (let i = Math.max(2, current - delta); i <= Math.min(totalPages - 1, current + delta); i++) {
4546
+ range.push(i);
4547
+ }
4548
+ // Добавляем первую страницу
4549
+ if (current - delta > 1) {
4550
+ range.unshift('...');
4551
+ }
4552
+ range.unshift(1);
4553
+ // Добавляем последнюю страницу
4554
+ if (current + delta < totalPages - 1) {
4555
+ range.push('...');
4556
+ }
4557
+ if (totalPages > 1) {
4558
+ range.push(totalPages);
4559
+ }
4560
+ return range.map((item, index) => ({
4561
+ index: typeof item === 'number' ? item : index,
4562
+ active: item === current,
4563
+ isEllipsis: item === '...'
4564
+ }));
4542
4565
  }
4543
4566
  get getFirstNumberCurrentPage() {
4544
4567
  if (this.total === 0) {
@@ -4565,6 +4588,7 @@ class PaginatorComponent {
4565
4588
  });
4566
4589
  }
4567
4590
  onChangePageSize(value) {
4591
+ console.log(value);
4568
4592
  this.currentPage = 1;
4569
4593
  this.dataStateChanged.emit({
4570
4594
  currentPage: this.currentPage,
@@ -5949,109 +5973,70 @@ var InputTextareaSizesEnum;
5949
5973
  class AutosizeDirective {
5950
5974
  elem;
5951
5975
  renderer;
5952
- ngZone;
5953
5976
  overflow = 'hidden';
5954
5977
  rows = 1;
5955
- set autosize(value) {
5956
- this._autosize = value;
5957
- if (!value) {
5958
- this.overflow = 'auto';
5959
- this.setHeight('auto');
5960
- }
5961
- }
5962
- get autosize() {
5963
- return this._autosize;
5964
- }
5965
- _autosize = true;
5966
- observer = null;
5967
- resizeTimeout;
5968
- lastHeight = 0;
5969
- constructor(elem, renderer, ngZone) {
5978
+ autosize = true;
5979
+ isInitialized = false;
5980
+ constructor(elem, renderer) {
5970
5981
  this.elem = elem;
5971
5982
  this.renderer = renderer;
5972
- this.ngZone = ngZone;
5973
5983
  }
5974
5984
  ngAfterViewInit() {
5975
- this.setupAutoResize();
5976
- // Первоначальный расчет
5977
- setTimeout(() => this.resize(), 0);
5978
- }
5979
- ngOnDestroy() {
5980
- this.cleanup();
5981
- }
5982
- setupAutoResize() {
5983
- if (!this.autosize)
5984
- return;
5985
- const textarea = this.elem.nativeElement;
5986
- // Используем MutationObserver вместо ngDoCheck
5987
- this.ngZone.runOutsideAngular(() => {
5988
- this.observer = new MutationObserver(() => {
5989
- this.scheduleResize();
5990
- });
5991
- this.observer.observe(textarea, {
5992
- characterData: true,
5993
- childList: true,
5994
- subtree: true
5995
- });
5996
- });
5997
- // Также следим за resize окна
5998
- this.renderer.listen('window', 'resize', () => this.scheduleResize());
5999
- }
6000
- scheduleResize() {
6001
- if (!this.autosize)
6002
- return;
6003
- // Debounce для оптимизации
6004
- clearTimeout(this.resizeTimeout);
6005
- this.resizeTimeout = setTimeout(() => {
6006
- this.ngZone.run(() => this.resize());
6007
- }, 50); // Задержка 50мс
5985
+ this.isInitialized = true;
5986
+ setTimeout(() => this.resize(), 0); // Инициализация после рендера
6008
5987
  }
6009
5988
  onInput() {
6010
- this.scheduleResize();
5989
+ if (this.autosize && this.isInitialized) {
5990
+ this.resize();
5991
+ }
6011
5992
  }
6012
5993
  resize() {
6013
5994
  if (!this.autosize) {
6014
5995
  this.overflow = 'auto';
5996
+ this.setHeight('auto');
6015
5997
  return;
6016
5998
  }
6017
5999
  const textarea = this.elem.nativeElement;
6018
- // Временно отключаем transition для предотвращения скачков
6000
+ // Сохраняем текущее значение и стили
6001
+ const originalValue = textarea.value;
6019
6002
  const originalTransition = textarea.style.transition;
6003
+ const originalOverflow = textarea.style.overflow;
6004
+ // Временно убираем transition для мгновенного расчета
6020
6005
  this.renderer.setStyle(textarea, 'transition', 'none');
6006
+ this.renderer.setStyle(textarea, 'overflow', 'hidden');
6007
+ // Сбрасываем высоту для корректного расчета
6008
+ this.renderer.setStyle(textarea, 'height', 'auto');
6021
6009
  // Рассчитываем новую высоту
6022
6010
  const borderHeight = textarea.offsetHeight - textarea.clientHeight;
6023
- this.setHeight('auto');
6024
6011
  const scrollHeight = textarea.scrollHeight;
6025
- const newHeight = scrollHeight + borderHeight;
6026
- // Изменяем высоту только если она действительно изменилась
6027
- if (Math.abs(newHeight - this.lastHeight) > 2) { // Порог 2px
6028
- this.setHeight(`${newHeight}px`);
6029
- this.lastHeight = newHeight;
6030
- }
6031
- // Восстанавливаем transition
6012
+ const newHeight = Math.max(textarea.clientHeight, // минимальная высота
6013
+ scrollHeight + borderHeight);
6014
+ // Устанавливаем новую высоту
6015
+ this.renderer.setStyle(textarea, 'height', `${newHeight}px`);
6016
+ // Восстанавливаем стили
6032
6017
  setTimeout(() => {
6033
6018
  this.renderer.setStyle(textarea, 'transition', originalTransition);
6019
+ this.renderer.setStyle(textarea, 'overflow', originalOverflow);
6034
6020
  }, 0);
6035
6021
  }
6036
6022
  setHeight(value) {
6037
6023
  this.renderer.setStyle(this.elem.nativeElement, 'height', value);
6038
6024
  }
6039
- cleanup() {
6040
- if (this.observer) {
6041
- this.observer.disconnect();
6042
- this.observer = null;
6043
- }
6044
- clearTimeout(this.resizeTimeout);
6045
- }
6046
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AutosizeDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
6047
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: AutosizeDirective, selector: "[mrxAutosize]", inputs: { rows: "rows", autosize: "autosize" }, host: { listeners: { "input": "onInput()" }, properties: { "style.overflow": "this.overflow", "rows": "this.rows" } }, ngImport: i0 });
6025
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AutosizeDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
6026
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: AutosizeDirective, selector: "[mrxAutosize]", inputs: { rows: "rows", autosize: "autosize" }, host: { listeners: { "input": "onInput()", "paste": "onInput()", "cut": "onInput()", "change": "onInput()" }, properties: { "style.overflow": "this.overflow", "rows": "this.rows" } }, ngImport: i0 });
6048
6027
  }
6049
6028
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AutosizeDirective, decorators: [{
6050
6029
  type: Directive,
6051
6030
  args: [{
6052
- selector: '[mrxAutosize]'
6031
+ selector: '[mrxAutosize]',
6032
+ host: {
6033
+ '(input)': 'onInput()',
6034
+ '(paste)': 'onInput()',
6035
+ '(cut)': 'onInput()',
6036
+ '(change)': 'onInput()'
6037
+ }
6053
6038
  }]
6054
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }], propDecorators: { overflow: [{
6039
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { overflow: [{
6055
6040
  type: HostBinding,
6056
6041
  args: ['style.overflow']
6057
6042
  }], rows: [{
@@ -6061,9 +6046,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
6061
6046
  args: ['rows']
6062
6047
  }], autosize: [{
6063
6048
  type: Input
6064
- }], onInput: [{
6065
- type: HostListener,
6066
- args: ['input']
6067
6049
  }] } });
6068
6050
 
6069
6051
  class InputTextareaComponent {