matcha-components 19.51.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,32 +199,32 @@ 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
- setActiveState(isActive, activeColor, inactiveColor, activeType, inactiveType) {
220
+ setActiveState(isActive, inactiveColor, inactiveType) {
216
221
  this.active = isActive;
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');
222
+ /* liga/desliga atributo visual */
223
+ if (isActive) {
224
+ this._render.setAttribute(this.innerButton.nativeElement, 'active-item', 'true');
225
+ }
226
+ else {
227
+ this._render.removeAttribute(this.innerButton.nativeElement, 'active-item');
228
228
  }
229
229
  }
230
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 }); }
@@ -244,56 +244,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
244
244
 
245
245
  class MatchaButtonGroupComponent {
246
246
  constructor() {
247
+ /* entradas originais */
247
248
  this._multiple = false;
248
249
  this._disabled = false;
249
- this.activeColor = 'blue';
250
250
  this.inactiveColor = 'disabled';
251
- this.activeType = '';
252
251
  this.inactiveType = 'basic';
253
252
  this._gap = 16;
254
253
  }
255
- get multiple() {
256
- return this._multiple;
257
- }
258
- set multiple(value) {
259
- this._multiple = value === 'false' ? false : Boolean(value);
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
- }
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
+ /* ────────────────────────────────────── */
277
262
  ngAfterContentInit() {
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);
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);
282
268
  item.selected.subscribe(() => this.onItemSelected(item));
283
269
  });
284
270
  }
285
271
  onItemSelected(selectedItem) {
286
272
  if (this.multiple) {
287
- selectedItem.setActiveState(!selectedItem.active, this.activeColor, this.inactiveColor, this.activeType, this.inactiveType);
273
+ selectedItem.setActiveState(!selectedItem.active, this.inactiveColor, this.inactiveType);
288
274
  }
289
275
  else {
290
- this.buttonItems.forEach(item => {
291
- item.setActiveState(item === selectedItem, this.activeColor, this.inactiveColor, this.activeType, this.inactiveType);
292
- });
276
+ this.buttonItems.forEach(item => item.setActiveState(item === selectedItem, this.inactiveColor, this.inactiveType));
293
277
  }
294
278
  }
295
279
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: MatchaButtonGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
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"] }] }); }
280
+ 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", inactiveColor: "inactiveColor", 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"] }] }); }
297
281
  }
298
282
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: MatchaButtonGroupComponent, decorators: [{
299
283
  type: Component,
@@ -305,12 +289,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
305
289
  }], isDisabled: [{
306
290
  type: HostBinding,
307
291
  args: ['attr.disabled']
308
- }], activeColor: [{
309
- type: Input
310
292
  }], inactiveColor: [{
311
293
  type: Input
312
- }], activeType: [{
313
- type: Input
314
294
  }], inactiveType: [{
315
295
  type: Input
316
296
  }], gap: [{