@pumpkin-tech/pumpkin-tech-ng 0.1.1 → 0.1.2

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,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, Input, HostBinding, Injectable, NgModule, EventEmitter, forwardRef, ElementRef, Component, ChangeDetectionStrategy, ViewChild, ContentChild, Output, Inject, InjectionToken, Optional, Pipe, HostListener, inject } from '@angular/core';
2
+ import { Directive, Input, HostBinding, Injectable, NgModule, EventEmitter, forwardRef, ElementRef, Component, ChangeDetectionStrategy, ViewChild, ContentChild, Output, HostListener, Inject, InjectionToken, Optional, Pipe, inject } from '@angular/core';
3
3
  import * as i1 from '@angular/cdk/layout';
4
4
  import * as i2$4 from 'rxjs';
5
5
  import { Subject, BehaviorSubject, delay, tap, map, filter, of } from 'rxjs';
@@ -1370,6 +1370,228 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
1370
1370
  type: Input
1371
1371
  }] } });
1372
1372
 
1373
+ // projects/pumpkin-tech-ng/src/lib/components/badge/badge.component.ts
1374
+ class BadgeComponent {
1375
+ /** Texto do badge (ou use <ng-content>) */
1376
+ label = '';
1377
+ /** mat-icon opcional */
1378
+ icon;
1379
+ /** Tooltip opcional */
1380
+ tooltip;
1381
+ /** Acessibilidade */
1382
+ ariaLabel;
1383
+ /** Clique habilitado */
1384
+ clickable = false;
1385
+ disabled = false;
1386
+ /** Forma/estilo */
1387
+ pill = true;
1388
+ uppercase = false;
1389
+ size = 'md';
1390
+ variant = 'filled';
1391
+ /** Cor: preset (success, warning, …) ou qualquer CSS color (#hex, rgb, etc.) */
1392
+ color = 'neutral';
1393
+ badgeClick = new EventEmitter();
1394
+ badgeKey = new EventEmitter();
1395
+ /** papel ARIA: se clicável, vira “button” */
1396
+ get role() { return this.clickable ? 'button' : 'status'; }
1397
+ get tab() { return this.clickable && !this.disabled ? 0 : -1; }
1398
+ onClick(ev) { if (!this.disabled && this.clickable)
1399
+ this.badgeClick.emit(ev); }
1400
+ onKey(ev) {
1401
+ if (this.disabled || !this.clickable)
1402
+ return;
1403
+ if (ev.key === 'Enter' || ev.key === ' ') {
1404
+ ev.preventDefault();
1405
+ this.badgeKey.emit(ev);
1406
+ this.badgeClick.emit(new MouseEvent('click'));
1407
+ }
1408
+ }
1409
+ // ===== Cores / variantes =====
1410
+ get cssVars() {
1411
+ const base = this.resolveBaseColor(this.color);
1412
+ const [r, g, b] = this.toRgb(base);
1413
+ const fgOn = this.contrastOn(base);
1414
+ switch (this.variant) {
1415
+ case 'filled':
1416
+ return { bg: base, fg: fgOn, bd: base };
1417
+ case 'outline':
1418
+ return { bg: 'transparent', fg: base, bd: base };
1419
+ case 'soft':
1420
+ return { bg: `rgba(${r},${g},${b},.15)`, fg: base, bd: `rgba(${r},${g},${b},.35)` };
1421
+ default:
1422
+ return { bg: base, fg: fgOn, bd: base };
1423
+ }
1424
+ }
1425
+ resolveBaseColor(c) {
1426
+ const PRESETS = {
1427
+ success: '#22c55e', warning: '#f59e0b', error: '#ef4444', info: '#3b82f6',
1428
+ neutral: '#64748b', purple: '#7c3aed',
1429
+ primary: 'var(--mdc-theme-primary, #3f51b5)',
1430
+ accent: 'var(--mdc-theme-secondary, #ff4081)',
1431
+ warn: '#f44336'
1432
+ };
1433
+ return PRESETS[c] ?? c;
1434
+ }
1435
+ toRgb(color) {
1436
+ const ctx = document?.createElement?.('canvas')?.getContext?.('2d');
1437
+ if (!ctx)
1438
+ return [100, 100, 100];
1439
+ ctx.fillStyle = color;
1440
+ const computed = ctx.fillStyle; // normaliza
1441
+ // #rrggbb
1442
+ const m = computed.match(/^#?([0-9a-f]{6})$/i);
1443
+ if (m) {
1444
+ const n = parseInt(m[1], 16);
1445
+ return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
1446
+ }
1447
+ // rgb(a)
1448
+ const m2 = computed.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);
1449
+ if (m2)
1450
+ return [+m2[1], +m2[2], +m2[3]];
1451
+ return [100, 100, 100];
1452
+ }
1453
+ contrastOn(color) {
1454
+ const [r, g, b] = this.toRgb(color);
1455
+ // luminância simples
1456
+ const lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
1457
+ return lum > 0.55 ? '#111' : '#fff';
1458
+ }
1459
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BadgeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1460
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: BadgeComponent, isStandalone: true, selector: "ptech-badge", inputs: { label: "label", icon: "icon", tooltip: "tooltip", ariaLabel: "ariaLabel", clickable: "clickable", disabled: "disabled", pill: "pill", uppercase: "uppercase", size: "size", variant: "variant", color: "color" }, outputs: { badgeClick: "badgeClick", badgeKey: "badgeKey" }, host: { listeners: { "click": "onClick($event)", "keydown": "onKey($event)" }, properties: { "attr.role": "this.role", "attr.tabindex": "this.tab" } }, ngImport: i0, template: `
1461
+ <span
1462
+ class="ptech-badge"
1463
+ [class.clickable]="clickable && !disabled"
1464
+ [class.pill]="pill"
1465
+ [class.sm]="size==='sm'"
1466
+ [class.lg]="size==='lg'"
1467
+ [class.uppercase]="uppercase"
1468
+ [class.disabled]="disabled"
1469
+ [matTooltip]="tooltip || null"
1470
+ [matTooltipDisabled]="!tooltip"
1471
+ [attr.aria-label]="ariaLabel || label"
1472
+ [attr.aria-disabled]="disabled"
1473
+ [ngStyle]="{
1474
+ '--bg': cssVars.bg,
1475
+ '--fg': cssVars.fg,
1476
+ '--bd': cssVars.bd
1477
+ }"
1478
+ >
1479
+ <mat-icon *ngIf="icon" class="icon">{{ icon }}</mat-icon>
1480
+ <ng-content></ng-content>
1481
+ <span *ngIf="label">{{ label }}</span>
1482
+ </span>
1483
+ `, isInline: true, styles: [".ptech-badge{--bg: transparent;--fg: currentColor;--bd: currentColor;display:inline-flex;align-items:center;gap:6px;max-width:100%;line-height:1;font-weight:600;border-radius:8px;padding:.35rem .6rem;border:1px solid var(--bd);background:var(--bg);color:var(--fg);-webkit-user-select:none;user-select:none;font-size:12px}.ptech-badge .icon{font-size:16px;height:16px;width:16px}.ptech-badge.pill{border-radius:999px}.ptech-badge.sm{padding:.25rem .5rem;font-size:11px}.ptech-badge.lg{padding:.45rem .75rem;font-size:13px}.ptech-badge.uppercase{text-transform:uppercase}.ptech-badge.clickable{cursor:pointer}.ptech-badge.disabled{opacity:.5;pointer-events:none}\n"], dependencies: [{ kind: "ngmodule", type: CoreMaterialModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: i3$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i7.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1484
+ }
1485
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BadgeComponent, decorators: [{
1486
+ type: Component,
1487
+ args: [{ selector: 'ptech-badge', standalone: true, imports: [CoreMaterialModule], template: `
1488
+ <span
1489
+ class="ptech-badge"
1490
+ [class.clickable]="clickable && !disabled"
1491
+ [class.pill]="pill"
1492
+ [class.sm]="size==='sm'"
1493
+ [class.lg]="size==='lg'"
1494
+ [class.uppercase]="uppercase"
1495
+ [class.disabled]="disabled"
1496
+ [matTooltip]="tooltip || null"
1497
+ [matTooltipDisabled]="!tooltip"
1498
+ [attr.aria-label]="ariaLabel || label"
1499
+ [attr.aria-disabled]="disabled"
1500
+ [ngStyle]="{
1501
+ '--bg': cssVars.bg,
1502
+ '--fg': cssVars.fg,
1503
+ '--bd': cssVars.bd
1504
+ }"
1505
+ >
1506
+ <mat-icon *ngIf="icon" class="icon">{{ icon }}</mat-icon>
1507
+ <ng-content></ng-content>
1508
+ <span *ngIf="label">{{ label }}</span>
1509
+ </span>
1510
+ `, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".ptech-badge{--bg: transparent;--fg: currentColor;--bd: currentColor;display:inline-flex;align-items:center;gap:6px;max-width:100%;line-height:1;font-weight:600;border-radius:8px;padding:.35rem .6rem;border:1px solid var(--bd);background:var(--bg);color:var(--fg);-webkit-user-select:none;user-select:none;font-size:12px}.ptech-badge .icon{font-size:16px;height:16px;width:16px}.ptech-badge.pill{border-radius:999px}.ptech-badge.sm{padding:.25rem .5rem;font-size:11px}.ptech-badge.lg{padding:.45rem .75rem;font-size:13px}.ptech-badge.uppercase{text-transform:uppercase}.ptech-badge.clickable{cursor:pointer}.ptech-badge.disabled{opacity:.5;pointer-events:none}\n"] }]
1511
+ }], propDecorators: { label: [{
1512
+ type: Input
1513
+ }], icon: [{
1514
+ type: Input
1515
+ }], tooltip: [{
1516
+ type: Input
1517
+ }], ariaLabel: [{
1518
+ type: Input
1519
+ }], clickable: [{
1520
+ type: Input
1521
+ }], disabled: [{
1522
+ type: Input
1523
+ }], pill: [{
1524
+ type: Input
1525
+ }], uppercase: [{
1526
+ type: Input
1527
+ }], size: [{
1528
+ type: Input
1529
+ }], variant: [{
1530
+ type: Input
1531
+ }], color: [{
1532
+ type: Input
1533
+ }], badgeClick: [{
1534
+ type: Output
1535
+ }], badgeKey: [{
1536
+ type: Output
1537
+ }], role: [{
1538
+ type: HostBinding,
1539
+ args: ['attr.role']
1540
+ }], tab: [{
1541
+ type: HostBinding,
1542
+ args: ['attr.tabindex']
1543
+ }], onClick: [{
1544
+ type: HostListener,
1545
+ args: ['click', ['$event']]
1546
+ }], onKey: [{
1547
+ type: HostListener,
1548
+ args: ['keydown', ['$event']]
1549
+ }] } });
1550
+
1551
+ // projects/pumpkin-tech-ng/src/lib/components/badge/badge-stack.component.ts
1552
+ class BadgeStackComponent {
1553
+ direction = 'column';
1554
+ gap = 8;
1555
+ wrap = false;
1556
+ align = 'start';
1557
+ disp = 'flex';
1558
+ get fwrap() { return this.wrap ? 'wrap' : 'nowrap'; }
1559
+ get dir() { return this.direction; }
1560
+ get g() { return `${this.gap}px`; }
1561
+ get ai() {
1562
+ return this.align === 'center' ? 'center' : this.align === 'end' ? 'flex-end' : 'flex-start';
1563
+ }
1564
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BadgeStackComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1565
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: BadgeStackComponent, isStandalone: true, selector: "ptech-badge-stack", inputs: { direction: "direction", gap: "gap", wrap: "wrap", align: "align" }, host: { properties: { "style.display": "this.disp", "style.flex-wrap": "this.fwrap", "style.flex-direction": "this.dir", "style.gap": "this.g", "style.align-items": "this.ai" } }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, styles: [""] });
1566
+ }
1567
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BadgeStackComponent, decorators: [{
1568
+ type: Component,
1569
+ args: [{ selector: 'ptech-badge-stack', standalone: true, template: `<ng-content></ng-content>` }]
1570
+ }], propDecorators: { direction: [{
1571
+ type: Input
1572
+ }], gap: [{
1573
+ type: Input
1574
+ }], wrap: [{
1575
+ type: Input
1576
+ }], align: [{
1577
+ type: Input
1578
+ }], disp: [{
1579
+ type: HostBinding,
1580
+ args: ['style.display']
1581
+ }], fwrap: [{
1582
+ type: HostBinding,
1583
+ args: ['style.flex-wrap']
1584
+ }], dir: [{
1585
+ type: HostBinding,
1586
+ args: ['style.flex-direction']
1587
+ }], g: [{
1588
+ type: HostBinding,
1589
+ args: ['style.gap']
1590
+ }], ai: [{
1591
+ type: HostBinding,
1592
+ args: ['style.align-items']
1593
+ }] } });
1594
+
1373
1595
  class IconComponent {
1374
1596
  color = '';
1375
1597
  icon = '';
@@ -4408,6 +4630,8 @@ class PumpkinTechModule {
4408
4630
  ActionDialogComponent,
4409
4631
  ActionResultDialogComponent,
4410
4632
  ButtonComponent,
4633
+ BadgeComponent,
4634
+ BadgeStackComponent,
4411
4635
  BreadcrumbComponent,
4412
4636
  TitleComponent,
4413
4637
  ActionRowComponent,
@@ -4438,6 +4662,8 @@ class PumpkinTechModule {
4438
4662
  ActionDialogComponent,
4439
4663
  ActionResultDialogComponent,
4440
4664
  ButtonComponent,
4665
+ BadgeComponent,
4666
+ BadgeStackComponent,
4441
4667
  BreadcrumbComponent,
4442
4668
  TitleComponent,
4443
4669
  ActionRowComponent,
@@ -4476,6 +4702,7 @@ class PumpkinTechModule {
4476
4702
  ActionDialogComponent,
4477
4703
  ActionResultDialogComponent,
4478
4704
  ButtonComponent,
4705
+ BadgeComponent,
4479
4706
  BreadcrumbComponent,
4480
4707
  TitleComponent,
4481
4708
  HeaderComponent,
@@ -4512,6 +4739,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
4512
4739
  ActionDialogComponent,
4513
4740
  ActionResultDialogComponent,
4514
4741
  ButtonComponent,
4742
+ BadgeComponent,
4743
+ BadgeStackComponent,
4515
4744
  BreadcrumbComponent,
4516
4745
  TitleComponent,
4517
4746
  ActionRowComponent,
@@ -4544,6 +4773,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
4544
4773
  ActionDialogComponent,
4545
4774
  ActionResultDialogComponent,
4546
4775
  ButtonComponent,
4776
+ BadgeComponent,
4777
+ BadgeStackComponent,
4547
4778
  BreadcrumbComponent,
4548
4779
  TitleComponent,
4549
4780
  ActionRowComponent,
@@ -5934,5 +6165,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
5934
6165
  * Generated bundle index. Do not edit.
5935
6166
  */
5936
6167
 
5937
- export { ActionDialogComponent, ActionResultDialogComponent, ActionRowComponent, AlertComponent, ArrayUtil, BREADCRUMB_PREFIX$, BreadcrumbComponent, BreadcrumbService, ButtonComponent, CheckBoxComponent, ClickCatcherDirective, ConfirmationDialogComponent, CoreMaterialModule, CurrencyBrlPipe, CurrencyPreferenceService, CurrencyUtil, DateAgoPipe, DateMaskDirective, DateUtil, DefaultConsoleMessageService, DefaultMessageService, DialogService, DirectivesModule, DocumentUtil, DynamicTabDirective, FakeDataService, FooterComponent, ForDirective, GetFirstStringBeforeSpacePipe, HeaderComponent, IconComponent, InfoDetailComponent, InfoDetailDialogComponent, InputComponent, InputCurrencyComponent, InputDateComponent, InputDateRangeComponent, InputTimeComponent, LineBreakAfterPeriodPipe, LineBreakAfterPipe, LoadingOverlayComponent, LoadingService, LowerCaseDirective, MESSAGE_SERVICE, MY_DATE_FORMATS, MemoryFormatPipe, ModuleChangeService, NavComponent, NavService, NumberUtil, ObjectUtil, PhoneBrazilPipe, PhoneMaskBrazilDirective, PhoneMaskSpainDirective, PhoneSpainPipe, PipesModule, ProfileMenuComponent, ProgressBarComponent, ProgressBarMultipleComponent, PtechColDirective, PtechGridDirective, PumpkinTechModule, QuantityItemsComponent, RadioGroupEntityComponent, RadioGroupEnumComponent, RedDirective, SelectEntityComponent, SelectEnumComponent, SlideToggleComponent, SnackbarMessageService, SpaceDropDirective, StringUtil, TextareaComponent, TimeDurationPipe, TitleComponent, UpperCaseDirective, UptimeFormatPipe, UuidUtil };
6168
+ export { ActionDialogComponent, ActionResultDialogComponent, ActionRowComponent, AlertComponent, ArrayUtil, BREADCRUMB_PREFIX$, BadgeComponent, BadgeStackComponent, BreadcrumbComponent, BreadcrumbService, ButtonComponent, CheckBoxComponent, ClickCatcherDirective, ConfirmationDialogComponent, CoreMaterialModule, CurrencyBrlPipe, CurrencyPreferenceService, CurrencyUtil, DateAgoPipe, DateMaskDirective, DateUtil, DefaultConsoleMessageService, DefaultMessageService, DialogService, DirectivesModule, DocumentUtil, DynamicTabDirective, FakeDataService, FooterComponent, ForDirective, GetFirstStringBeforeSpacePipe, HeaderComponent, IconComponent, InfoDetailComponent, InfoDetailDialogComponent, InputComponent, InputCurrencyComponent, InputDateComponent, InputDateRangeComponent, InputTimeComponent, LineBreakAfterPeriodPipe, LineBreakAfterPipe, LoadingOverlayComponent, LoadingService, LowerCaseDirective, MESSAGE_SERVICE, MY_DATE_FORMATS, MemoryFormatPipe, ModuleChangeService, NavComponent, NavService, NumberUtil, ObjectUtil, PhoneBrazilPipe, PhoneMaskBrazilDirective, PhoneMaskSpainDirective, PhoneSpainPipe, PipesModule, ProfileMenuComponent, ProgressBarComponent, ProgressBarMultipleComponent, PtechColDirective, PtechGridDirective, PumpkinTechModule, QuantityItemsComponent, RadioGroupEntityComponent, RadioGroupEnumComponent, RedDirective, SelectEntityComponent, SelectEnumComponent, SlideToggleComponent, SnackbarMessageService, SpaceDropDirective, StringUtil, TextareaComponent, TimeDurationPipe, TitleComponent, UpperCaseDirective, UptimeFormatPipe, UuidUtil };
5938
6169
  //# sourceMappingURL=pumpkin-tech-pumpkin-tech-ng.mjs.map