matcha-components 19.49.0 → 19.50.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.
@@ -1,10 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { ElementRef, Renderer2, Input, Inject, Component, EventEmitter, ContentChild, Output, ContentChildren, HostBinding, HostListener, Directive, forwardRef, NgModule } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
3
5
  import { animation, style, animate, trigger, transition, useAnimation, state, query, stagger, animateChild, sequence, group } from '@angular/animations';
4
6
  import { Subscription, Subject } from 'rxjs';
5
7
  import { debounceTime } from 'rxjs/operators';
6
- import * as i1 from '@angular/common';
7
- import { CommonModule } from '@angular/common';
8
8
  import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
9
9
 
10
10
  class MatchaButtonComponent {
@@ -201,34 +201,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
201
201
  class MatchaButtonItemComponent {
202
202
  constructor(renderer) {
203
203
  this.renderer = renderer;
204
- // Propriedade que indica se o botão está ativo
205
204
  this.active = false;
206
- // Evento emitido quando o botão for clicado
207
205
  this.selected = new EventEmitter();
208
206
  }
209
207
  ngAfterContentInit() {
210
- // Atualiza a cor inicial do botão conforme o estado
211
- this.updateButtonColor();
212
- // Registra o clique no botão interno
213
208
  if (this.innerButton) {
214
- this.renderer.listen(this.innerButton.nativeElement, 'click', () => {
215
- this.onClick();
216
- });
209
+ this.renderer.listen(this.innerButton.nativeElement, 'click', () => this.onClick());
217
210
  }
218
211
  }
219
212
  onClick() {
220
213
  this.selected.emit();
221
214
  }
222
- // Método para definir o estado ativo e atualizar a cor
223
- setActiveState(isActive, activeColor, inactiveColor) {
215
+ setActiveState(isActive, activeColor, inactiveColor, activeType, inactiveType) {
224
216
  this.active = isActive;
225
- this.updateButtonColor(activeColor, inactiveColor);
226
- }
227
- // Atualiza o atributo 'color' do botão interno
228
- updateButtonColor(activeColor = 'blue', inactiveColor = 'grey') {
229
- if (this.innerButton) {
230
- const newColor = this.active ? activeColor : inactiveColor;
231
- this.renderer.setAttribute(this.innerButton.nativeElement, 'color', newColor);
217
+ const color = isActive ? activeColor : inactiveColor;
218
+ const type = isActive ? activeType : inactiveType;
219
+ // Aplica a cor correta ao botão interno
220
+ this.renderer.setAttribute(this.innerButton.nativeElement, 'color', color);
221
+ // Limpa todos os tipos anteriores
222
+ ['basic', 'outline', 'alpha', 'pill'].forEach(attr => {
223
+ this.renderer.setAttribute(this.innerButton.nativeElement, attr, 'false');
224
+ });
225
+ // Aplica o tipo correto ao botão interno se houver algum
226
+ if (type) {
227
+ this.renderer.setAttribute(this.innerButton.nativeElement, type, 'true');
232
228
  }
233
229
  }
234
230
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: MatchaButtonItemComponent, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component }); }
@@ -246,59 +242,79 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
246
242
  args: [MatchaButtonComponent, { static: true, read: ElementRef }]
247
243
  }] } });
248
244
 
249
- // button-group.component.ts
250
245
  class MatchaButtonGroupComponent {
251
246
  constructor() {
252
247
  this._multiple = false;
253
- // Cores para os estados ativo e inativo
248
+ this._disabled = false;
254
249
  this.activeColor = 'blue';
255
- this.inactiveColor = 'grey';
250
+ this.inactiveColor = 'disabled';
251
+ this.activeType = '';
252
+ this.inactiveType = 'basic';
253
+ this._gap = 16;
256
254
  }
257
255
  get multiple() {
258
256
  return this._multiple;
259
257
  }
260
258
  set multiple(value) {
261
- // Converte string 'false' para boolean false
262
- // Qualquer outro valor string será convertido para true
263
259
  this._multiple = value === 'false' ? false : Boolean(value);
264
260
  }
261
+ get disabled() {
262
+ return this._disabled;
263
+ }
264
+ set disabled(value) {
265
+ this._disabled = value === 'false' ? false : Boolean(value);
266
+ }
267
+ get isDisabled() {
268
+ return this.disabled || null;
269
+ }
270
+ set gap(value) {
271
+ const numericGap = Number(value);
272
+ this._gap = isNaN(numericGap) ? 16 : numericGap;
273
+ }
274
+ get gapClass() {
275
+ return `gap-${this._gap}`;
276
+ }
265
277
  ngAfterContentInit() {
266
- console.log(this.buttonItems, 'estou funcionando');
267
- // Inicializa cada button-item com o estado inativo
268
- this.buttonItems.forEach(item => {
269
- item.setActiveState(false, this.activeColor, this.inactiveColor);
270
- // Inscreve-se para saber quando algum item for selecionado
278
+ this.buttonItems.forEach((item, index) => {
279
+ const isFirst = index === 0;
280
+ // Opcionalmente, primeiro botão pode iniciar ativo por padrão
281
+ item.setActiveState(isFirst, this.activeColor, this.inactiveColor, this.activeType, this.inactiveType);
271
282
  item.selected.subscribe(() => this.onItemSelected(item));
272
283
  });
273
- // Opcional: define o primeiro item como ativo por padrão
274
- if (this.buttonItems.first) {
275
- this.buttonItems.first.setActiveState(true, this.activeColor, this.inactiveColor);
276
- }
277
284
  }
278
285
  onItemSelected(selectedItem) {
279
286
  if (this.multiple) {
280
- // Se múltiplo, inverte o estado do item clicado
281
- selectedItem.setActiveState(!selectedItem.active, this.activeColor, this.inactiveColor);
287
+ selectedItem.setActiveState(!selectedItem.active, this.activeColor, this.inactiveColor, this.activeType, this.inactiveType);
282
288
  }
283
289
  else {
284
- // Se único, desativa todos e ativa somente o item clicado
285
290
  this.buttonItems.forEach(item => {
286
- item.setActiveState(item === selectedItem, this.activeColor, this.inactiveColor);
291
+ item.setActiveState(item === selectedItem, this.activeColor, this.inactiveColor, this.activeType, this.inactiveType);
287
292
  });
288
293
  }
289
294
  }
290
295
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: MatchaButtonGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
291
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.5", type: MatchaButtonGroupComponent, isStandalone: false, selector: "matcha-button-group", inputs: { multiple: "multiple", activeColor: "activeColor", inactiveColor: "inactiveColor" }, queries: [{ propertyName: "buttonItems", predicate: MatchaButtonItemComponent }], ngImport: i0, template: "<div class=\"button-group d-flex flex-wrap gap-16\" role=\"group\"><ng-content></ng-content></div>\n", styles: [""] }); }
296
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.5", type: MatchaButtonGroupComponent, isStandalone: false, selector: "matcha-button-group", inputs: { multiple: "multiple", disabled: "disabled", activeColor: "activeColor", inactiveColor: "inactiveColor", activeType: "activeType", inactiveType: "inactiveType", gap: "gap" }, host: { properties: { "attr.disabled": "this.isDisabled" } }, queries: [{ propertyName: "buttonItems", predicate: MatchaButtonItemComponent }], ngImport: i0, template: "<div class=\"button-group d-flex flex-wrap\" [ngClass]=\"gapClass\" role=\"group\"><ng-content></ng-content></div>\n", styles: [""], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
292
297
  }
293
298
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: MatchaButtonGroupComponent, decorators: [{
294
299
  type: Component,
295
- args: [{ selector: 'matcha-button-group', standalone: false, template: "<div class=\"button-group d-flex flex-wrap gap-16\" role=\"group\"><ng-content></ng-content></div>\n" }]
300
+ args: [{ selector: 'matcha-button-group', standalone: false, template: "<div class=\"button-group d-flex flex-wrap\" [ngClass]=\"gapClass\" role=\"group\"><ng-content></ng-content></div>\n" }]
296
301
  }], propDecorators: { multiple: [{
297
302
  type: Input
303
+ }], disabled: [{
304
+ type: Input
305
+ }], isDisabled: [{
306
+ type: HostBinding,
307
+ args: ['attr.disabled']
298
308
  }], activeColor: [{
299
309
  type: Input
300
310
  }], inactiveColor: [{
301
311
  type: Input
312
+ }], activeType: [{
313
+ type: Input
314
+ }], inactiveType: [{
315
+ type: Input
316
+ }], gap: [{
317
+ type: Input
302
318
  }], buttonItems: [{
303
319
  type: ContentChildren,
304
320
  args: [MatchaButtonItemComponent]
@@ -1742,18 +1758,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
1742
1758
  }] } });
1743
1759
 
1744
1760
  class MatchaSpinComponent {
1745
- constructor() {
1746
- this._progress = 0;
1747
- this.color = 'accent';
1748
- this.diameter = 60;
1749
- this.strokeWidth = 5;
1750
- }
1751
1761
  set progress(value) {
1752
1762
  this._progress = Number(value);
1753
1763
  }
1754
1764
  get progress() {
1755
1765
  return this._progress;
1756
1766
  }
1767
+ constructor(_elementRef, _renderer) {
1768
+ this._elementRef = _elementRef;
1769
+ this._renderer = _renderer;
1770
+ this._progress = 0;
1771
+ this.color = 'accent';
1772
+ this.size = null;
1773
+ this.sizeXs = null;
1774
+ this.sizeSm = null;
1775
+ this.sizeMd = null;
1776
+ this.sizeLg = null;
1777
+ this.sizeXl = null;
1778
+ this.strokeWidth = 5;
1779
+ }
1780
+ ngOnInit() {
1781
+ this._renderer.addClass(this._elementRef.nativeElement, 'matcha-spin');
1782
+ this.setSize();
1783
+ }
1784
+ setSize() {
1785
+ const sizes = ['tiny', 'small', 'medium', 'large', 'huge'];
1786
+ sizes.forEach(size => {
1787
+ this._renderer.removeClass(this._elementRef.nativeElement, `matcha-spin-${size}`);
1788
+ });
1789
+ if (this.size) {
1790
+ this._renderer.addClass(this._elementRef.nativeElement, `matcha-spin-${this.size}`);
1791
+ }
1792
+ }
1793
+ get diameter() {
1794
+ const rect = this._elementRef.nativeElement.getBoundingClientRect();
1795
+ return rect.width;
1796
+ }
1757
1797
  get radius() {
1758
1798
  return (this.diameter - this.strokeWidth) / 2;
1759
1799
  }
@@ -1764,16 +1804,40 @@ class MatchaSpinComponent {
1764
1804
  const progress = Math.min(Math.max(Number(this.progress), 0), 100);
1765
1805
  return this.circumference - (progress / 100) * this.circumference;
1766
1806
  }
1767
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: MatchaSpinComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1768
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.5", type: MatchaSpinComponent, isStandalone: false, selector: "matcha-spin", inputs: { progress: "progress", color: "color" }, ngImport: i0, template: "<div\n class=\"matcha-spin\"\n role=\"progressbar\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"100\"\n [attr.aria-valuenow]=\"progress\"\n [style.width.px]=\"diameter\"\n [style.height.px]=\"diameter\"\n>\n <svg [attr.viewBox]=\"'0 0 ' + diameter + ' ' + diameter\">\n\n <circle\n class=\"spin-placeholder\"\n [attr.cx]=\"diameter / 2\"\n [attr.cy]=\"diameter / 2\"\n [attr.r]=\"radius\"\n [attr.stroke-width]=\"strokeWidth\"\n />\n\n <circle\n class=\"spin-progress\"\n [attr.cx]=\"diameter / 2\"\n [attr.cy]=\"diameter / 2\"\n [attr.r]=\"radius\"\n [attr.stroke]=\"color\"\n [attr.stroke-width]=\"strokeWidth\"\n [attr.stroke-dasharray]=\"circumference\"\n [attr.stroke-dashoffset]=\"progress ? dashOffset:null\"\n />\n </svg>\n\n</div>\n\n", styles: [""] }); }
1807
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: MatchaSpinComponent, deps: [{ token: ElementRef }, { token: Renderer2 }], target: i0.ɵɵFactoryTarget.Component }); }
1808
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.5", type: MatchaSpinComponent, isStandalone: false, selector: "matcha-spin", inputs: { progress: "progress", color: "color", size: "size", sizeXs: ["size-xs", "sizeXs"], sizeSm: ["size-sm", "sizeSm"], sizeMd: ["size-md", "sizeMd"], sizeLg: ["size-lg", "sizeLg"], sizeXl: ["size-xl", "sizeXl"] }, ngImport: i0, template: "<div\n class=\"matcha-spin\"\n role=\"progressbar\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"100\"\n [attr.aria-valuenow]=\"progress\"\n>\n <svg [attr.viewBox]=\"'0 0 ' + diameter + ' ' + diameter\">\n <circle\n class=\"spin-placeholder\"\n [attr.cx]=\"diameter / 2\"\n [attr.cy]=\"diameter / 2\"\n [attr.r]=\"radius\"\n [attr.stroke-width]=\"strokeWidth\"\n />\n <circle\n class=\"spin-progress\"\n [attr.cx]=\"diameter / 2\"\n [attr.cy]=\"diameter / 2\"\n [attr.r]=\"radius\"\n [attr.stroke-width]=\"strokeWidth\"\n [attr.stroke]=\"color\"\n [attr.stroke-dasharray]=\"circumference\"\n [attr.stroke-dashoffset]=\"progress ? dashOffset : null\"\n />\n </svg>\n</div>\n", styles: [""] }); }
1769
1809
  }
1770
1810
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: MatchaSpinComponent, decorators: [{
1771
1811
  type: Component,
1772
- args: [{ selector: 'matcha-spin', standalone: false, template: "<div\n class=\"matcha-spin\"\n role=\"progressbar\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"100\"\n [attr.aria-valuenow]=\"progress\"\n [style.width.px]=\"diameter\"\n [style.height.px]=\"diameter\"\n>\n <svg [attr.viewBox]=\"'0 0 ' + diameter + ' ' + diameter\">\n\n <circle\n class=\"spin-placeholder\"\n [attr.cx]=\"diameter / 2\"\n [attr.cy]=\"diameter / 2\"\n [attr.r]=\"radius\"\n [attr.stroke-width]=\"strokeWidth\"\n />\n\n <circle\n class=\"spin-progress\"\n [attr.cx]=\"diameter / 2\"\n [attr.cy]=\"diameter / 2\"\n [attr.r]=\"radius\"\n [attr.stroke]=\"color\"\n [attr.stroke-width]=\"strokeWidth\"\n [attr.stroke-dasharray]=\"circumference\"\n [attr.stroke-dashoffset]=\"progress ? dashOffset:null\"\n />\n </svg>\n\n</div>\n\n" }]
1773
- }], propDecorators: { progress: [{
1812
+ args: [{ selector: 'matcha-spin', standalone: false, template: "<div\n class=\"matcha-spin\"\n role=\"progressbar\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"100\"\n [attr.aria-valuenow]=\"progress\"\n>\n <svg [attr.viewBox]=\"'0 0 ' + diameter + ' ' + diameter\">\n <circle\n class=\"spin-placeholder\"\n [attr.cx]=\"diameter / 2\"\n [attr.cy]=\"diameter / 2\"\n [attr.r]=\"radius\"\n [attr.stroke-width]=\"strokeWidth\"\n />\n <circle\n class=\"spin-progress\"\n [attr.cx]=\"diameter / 2\"\n [attr.cy]=\"diameter / 2\"\n [attr.r]=\"radius\"\n [attr.stroke-width]=\"strokeWidth\"\n [attr.stroke]=\"color\"\n [attr.stroke-dasharray]=\"circumference\"\n [attr.stroke-dashoffset]=\"progress ? dashOffset : null\"\n />\n </svg>\n</div>\n" }]
1813
+ }], ctorParameters: () => [{ type: i0.ElementRef, decorators: [{
1814
+ type: Inject,
1815
+ args: [ElementRef]
1816
+ }] }, { type: i0.Renderer2, decorators: [{
1817
+ type: Inject,
1818
+ args: [Renderer2]
1819
+ }] }], propDecorators: { progress: [{
1774
1820
  type: Input
1775
1821
  }], color: [{
1776
1822
  type: Input
1823
+ }], size: [{
1824
+ type: Input,
1825
+ args: ['size']
1826
+ }], sizeXs: [{
1827
+ type: Input,
1828
+ args: ['size-xs']
1829
+ }], sizeSm: [{
1830
+ type: Input,
1831
+ args: ['size-sm']
1832
+ }], sizeMd: [{
1833
+ type: Input,
1834
+ args: ['size-md']
1835
+ }], sizeLg: [{
1836
+ type: Input,
1837
+ args: ['size-lg']
1838
+ }], sizeXl: [{
1839
+ type: Input,
1840
+ args: ['size-xl']
1777
1841
  }] } });
1778
1842
 
1779
1843
  class MatchaHintTextComponent {