matcha-components 19.52.0 → 19.53.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.
@@ -199,40 +199,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
199
199
  }] } });
200
200
 
201
201
  class MatchaButtonItemComponent {
202
- constructor(renderer) {
203
- this.renderer = renderer;
202
+ constructor(_render) {
203
+ this._render = _render;
204
204
  this.active = false;
205
205
  this.selected = new EventEmitter();
206
206
  }
207
207
  ngAfterContentInit() {
208
- if (this.innerButton) {
209
- this.renderer.listen(this.innerButton.nativeElement, 'click', () => this.onClick());
208
+ if (!this.innerButton) {
209
+ return;
210
+ }
211
+ /* considera <button … active-item> como ativo */
212
+ if (this.innerButton.nativeElement.hasAttribute('active-item')) {
213
+ this.active = true;
210
214
  }
215
+ this._render.listen(this.innerButton.nativeElement, 'click', () => this.onClick());
211
216
  }
212
217
  onClick() {
213
218
  this.selected.emit();
214
219
  }
215
220
  setActiveState(isActive, inactiveColor, inactiveType) {
216
221
  this.active = isActive;
217
- const color = isActive ? '' : inactiveColor;
218
- const type = isActive ? '' : inactiveType;
219
- // Aplica a cor correta ao botão interno
222
+ /* liga/desliga atributo visual */
220
223
  if (isActive) {
221
- this.renderer.setAttribute(this.innerButton.nativeElement, 'active-item', 'true');
224
+ this._render.setAttribute(this.innerButton.nativeElement, 'active-item', 'true');
222
225
  }
223
226
  else {
224
- this.renderer.removeAttribute(this.innerButton.nativeElement, 'active-item');
227
+ this._render.removeAttribute(this.innerButton.nativeElement, 'active-item');
225
228
  }
226
- // inactiveType - pode ser 'basic', 'outline', 'alpha' ou 'pill'
227
- // Se o tipo for 'basic', 'outline', 'alpha' ou 'pill', aplica o tipo correto
228
- // Limpa todos os tipos anteriores
229
- // ['basic', 'outline', 'alpha', 'pill'].forEach(attr => {
230
- // this.renderer.setAttribute(this.innerButton.nativeElement, attr, 'false');
231
- // });
232
- // Aplica o tipo correto ao botão interno se houver algum
233
- // if (type) {
234
- // this.renderer.setAttribute(this.innerButton.nativeElement, type, 'true');
235
- // }
236
229
  }
237
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 }); }
238
231
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.5", type: MatchaButtonItemComponent, isStandalone: false, selector: "matcha-button-item", inputs: { active: "active" }, outputs: { selected: "selected" }, queries: [{ propertyName: "innerButton", first: true, predicate: MatchaButtonComponent, descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<ng-content></ng-content>\n", styles: [""] }); }
@@ -251,39 +244,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
251
244
 
252
245
  class MatchaButtonGroupComponent {
253
246
  constructor() {
247
+ /* entradas originais */
254
248
  this._multiple = false;
255
249
  this._disabled = false;
256
250
  this.inactiveColor = 'disabled';
257
251
  this.inactiveType = 'basic';
258
252
  this._gap = 16;
259
253
  }
260
- get multiple() {
261
- return this._multiple;
262
- }
263
- set multiple(value) {
264
- this._multiple = value === 'false' ? false : Boolean(value);
265
- }
266
- get disabled() {
267
- return this._disabled;
268
- }
269
- set disabled(value) {
270
- this._disabled = value === 'false' ? false : Boolean(value);
271
- }
272
- get isDisabled() {
273
- return this.disabled || null;
274
- }
275
- set gap(value) {
276
- const numericGap = Number(value);
277
- this._gap = isNaN(numericGap) ? 16 : numericGap;
278
- }
279
- get gapClass() {
280
- return `gap-${this._gap}`;
281
- }
254
+ get multiple() { return this._multiple; }
255
+ set multiple(v) { this._multiple = v === 'false' ? false : !!v; }
256
+ get disabled() { return this._disabled; }
257
+ set disabled(v) { this._disabled = v === 'false' ? false : !!v; }
258
+ get isDisabled() { return this.disabled || null; }
259
+ set gap(v) { const n = +v; this._gap = isNaN(n) ? 16 : n; }
260
+ get gapClass() { return `gap-${this._gap}`; }
261
+ /* ────────────────────────────────────── */
282
262
  ngAfterContentInit() {
283
- this.buttonItems.forEach((item, index) => {
284
- const isFirst = index === 0;
285
- // Opcionalmente, primeiro botão pode iniciar ativo por padrão
286
- item.setActiveState(isFirst, this.inactiveColor, this.inactiveType);
263
+ /* se algum veio com [active] / active-item usa-o, senão o primeiro */
264
+ const preset = this.buttonItems.find(i => i.active);
265
+ this.buttonItems.forEach((item, idx) => {
266
+ const isActive = preset ? item === preset : idx === 0;
267
+ item.setActiveState(isActive, this.inactiveColor, this.inactiveType);
287
268
  item.selected.subscribe(() => this.onItemSelected(item));
288
269
  });
289
270
  }
@@ -292,9 +273,7 @@ class MatchaButtonGroupComponent {
292
273
  selectedItem.setActiveState(!selectedItem.active, this.inactiveColor, this.inactiveType);
293
274
  }
294
275
  else {
295
- this.buttonItems.forEach(item => {
296
- item.setActiveState(item === selectedItem, this.inactiveColor, this.inactiveType);
297
- });
276
+ this.buttonItems.forEach(item => item.setActiveState(item === selectedItem, this.inactiveColor, this.inactiveType));
298
277
  }
299
278
  }
300
279
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: MatchaButtonGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }