@pumpkin-tech/pumpkin-tech-ng 0.2.71 → 0.2.72

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.
package/README.md CHANGED
@@ -74,3 +74,20 @@ Angular CLI does not come with an end-to-end testing framework by default. You c
74
74
  ## Additional Resources
75
75
 
76
76
  For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
77
+
78
+ ### Estrelas (`ptech-stars`) — 0.2.72
79
+
80
+ Componente standalone `PtechStarsComponent`, também exportado pelo `PumpkinTechModule`.
81
+
82
+ ```html
83
+ <!-- Nota 8.7/10 = 4.35 de cinco estrelas, com preenchimento parcial -->
84
+ <ptech-stars [value]="8.7" [max]="10"></ptech-stars>
85
+ <!-- Edição com ControlValueAccessor, clique ou teclado -->
86
+ <ptech-stars [(ngModel)]="rating" [max]="10" [readonly]="false" [step]="0.1"></ptech-stars>
87
+ ```
88
+
89
+ Inputs: `value` (number|null), `max` (5), `stars` (5), `readonly` (true),
90
+ `disabled`, `showValue` (true), `label` (Nota), `emptyLabel` (Sem nota), `step` (0.5).
91
+ Também oferece `valueChange`. `null` mostra Sem nota; zero representa nota zero.
92
+ Setas ajustam a nota; Home/End selecionam os extremos. O valor é limitado à escala.
93
+ Cores/tamanho: `--ptech-stars-color`, `--ptech-stars-empty-color`, `--ptech-stars-size`.
@@ -11130,6 +11130,112 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
11130
11130
  args: ['helpDialog']
11131
11131
  }] } });
11132
11132
 
11133
+ /** Five stars by default. `max` defines the numeric scale (e.g. 10 for TMDB). */
11134
+ class PtechStarsComponent {
11135
+ cdr;
11136
+ value = null;
11137
+ max = 5;
11138
+ stars = 5;
11139
+ step = .5;
11140
+ readonly = true;
11141
+ disabled = false;
11142
+ showValue = true;
11143
+ label = 'Nota';
11144
+ emptyLabel = 'Sem nota';
11145
+ valueChange = new EventEmitter();
11146
+ change = () => { };
11147
+ touch = () => { };
11148
+ constructor(cdr) {
11149
+ this.cdr = cdr;
11150
+ }
11151
+ get scale() { return Number.isFinite(this.max) && this.max > 0 ? this.max : 5; }
11152
+ get count() { return Number.isFinite(this.stars) ? Math.max(1, Math.min(20, Math.floor(this.stars))) : 5; }
11153
+ get starIndexes() { return Array.from({ length: this.count }, (_, i) => i); }
11154
+ get normalizedValue() { return Math.max(0, Math.min(this.scale, Number(this.value) || 0)); }
11155
+ get accessibleLabel() { return `${this.label}: ${this.value == null ? this.emptyLabel : this.normalizedValue + ' de ' + this.scale}`; }
11156
+ fill(index) { return Math.max(0, Math.min(100, (this.normalizedValue / this.scale * this.count - index) * 100)); }
11157
+ writeValue(value) { this.value = value; this.cdr.markForCheck(); }
11158
+ registerOnChange(fn) { this.change = fn; }
11159
+ registerOnTouched(fn) { this.touch = fn; }
11160
+ setDisabledState(disabled) { this.disabled = disabled; this.cdr.markForCheck(); }
11161
+ select(value) {
11162
+ if (this.readonly || this.disabled)
11163
+ return;
11164
+ this.value = Math.round(Math.max(0, Math.min(this.scale, value)) * 10000) / 10000;
11165
+ this.change(this.value);
11166
+ this.valueChange.emit(this.value);
11167
+ this.touch();
11168
+ this.cdr.markForCheck();
11169
+ }
11170
+ onKeydown(event) {
11171
+ if (this.readonly || this.disabled)
11172
+ return;
11173
+ const step = Number.isFinite(this.step) && this.step > 0 ? this.step : .5;
11174
+ const values = { ArrowRight: this.normalizedValue + step, ArrowUp: this.normalizedValue + step,
11175
+ ArrowLeft: this.normalizedValue - step, ArrowDown: this.normalizedValue - step, Home: 0, End: this.scale };
11176
+ if (event.key in values) {
11177
+ event.preventDefault();
11178
+ this.select(values[event.key]);
11179
+ }
11180
+ }
11181
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechStarsComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
11182
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: PtechStarsComponent, isStandalone: true, selector: "ptech-stars", inputs: { value: "value", max: "max", stars: "stars", step: "step", readonly: "readonly", disabled: "disabled", showValue: "showValue", label: "label", emptyLabel: "emptyLabel" }, outputs: { valueChange: "valueChange" }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => PtechStarsComponent), multi: true }], ngImport: i0, template: `
11183
+ <span class="rating" [class.interactive]="!readonly && !disabled" [class.disabled]="disabled"
11184
+ [attr.role]="readonly ? 'img' : 'slider'" [attr.aria-label]="accessibleLabel"
11185
+ [attr.tabindex]="readonly || disabled ? null : 0" [attr.aria-disabled]="disabled"
11186
+ [attr.aria-valuemin]="readonly ? null : 0" [attr.aria-valuemax]="readonly ? null : scale"
11187
+ [attr.aria-valuenow]="readonly ? null : normalizedValue" [attr.aria-valuetext]="accessibleLabel"
11188
+ (keydown)="onKeydown($event)" (blur)="touch()">
11189
+ <span class="stars" aria-hidden="true">
11190
+ @for (star of starIndexes; track star) {
11191
+ <span class="star" (click)="select((star + 1) * scale / count)">
11192
+ <span>★</span><span class="fill" [style.width.%]="fill(star)">★</span>
11193
+ </span>
11194
+ }
11195
+ </span>
11196
+ @if (showValue) { <span class="value" aria-hidden="true">{{ value == null ? emptyLabel : normalizedValue + '/' + scale }}</span> }
11197
+ </span>`, isInline: true, styles: [":host{display:inline-block}.rating{display:inline-flex;align-items:center;gap:.5rem;white-space:nowrap}.stars{display:inline-flex;font-size:var(--ptech-stars-size, 1.25rem);line-height:1.2}.star{position:relative;color:var(--ptech-stars-empty-color, #9ca3af)}.fill{position:absolute;left:0;top:0;overflow:hidden;color:var(--ptech-stars-color, #f5b800)}.value{font-size:.85em}.interactive .star{cursor:pointer}.rating:focus-visible{outline:2px solid currentColor;outline-offset:3px;border-radius:3px}.disabled{opacity:.5}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
11198
+ }
11199
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechStarsComponent, decorators: [{
11200
+ type: Component,
11201
+ args: [{ selector: 'ptech-stars', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => PtechStarsComponent), multi: true }], template: `
11202
+ <span class="rating" [class.interactive]="!readonly && !disabled" [class.disabled]="disabled"
11203
+ [attr.role]="readonly ? 'img' : 'slider'" [attr.aria-label]="accessibleLabel"
11204
+ [attr.tabindex]="readonly || disabled ? null : 0" [attr.aria-disabled]="disabled"
11205
+ [attr.aria-valuemin]="readonly ? null : 0" [attr.aria-valuemax]="readonly ? null : scale"
11206
+ [attr.aria-valuenow]="readonly ? null : normalizedValue" [attr.aria-valuetext]="accessibleLabel"
11207
+ (keydown)="onKeydown($event)" (blur)="touch()">
11208
+ <span class="stars" aria-hidden="true">
11209
+ @for (star of starIndexes; track star) {
11210
+ <span class="star" (click)="select((star + 1) * scale / count)">
11211
+ <span>★</span><span class="fill" [style.width.%]="fill(star)">★</span>
11212
+ </span>
11213
+ }
11214
+ </span>
11215
+ @if (showValue) { <span class="value" aria-hidden="true">{{ value == null ? emptyLabel : normalizedValue + '/' + scale }}</span> }
11216
+ </span>`, styles: [":host{display:inline-block}.rating{display:inline-flex;align-items:center;gap:.5rem;white-space:nowrap}.stars{display:inline-flex;font-size:var(--ptech-stars-size, 1.25rem);line-height:1.2}.star{position:relative;color:var(--ptech-stars-empty-color, #9ca3af)}.fill{position:absolute;left:0;top:0;overflow:hidden;color:var(--ptech-stars-color, #f5b800)}.value{font-size:.85em}.interactive .star{cursor:pointer}.rating:focus-visible{outline:2px solid currentColor;outline-offset:3px;border-radius:3px}.disabled{opacity:.5}\n"] }]
11217
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { value: [{
11218
+ type: Input
11219
+ }], max: [{
11220
+ type: Input
11221
+ }], stars: [{
11222
+ type: Input
11223
+ }], step: [{
11224
+ type: Input
11225
+ }], readonly: [{
11226
+ type: Input
11227
+ }], disabled: [{
11228
+ type: Input
11229
+ }], showValue: [{
11230
+ type: Input
11231
+ }], label: [{
11232
+ type: Input
11233
+ }], emptyLabel: [{
11234
+ type: Input
11235
+ }], valueChange: [{
11236
+ type: Output
11237
+ }] } });
11238
+
11133
11239
  class SnackbarMessageService {
11134
11240
  snackBar;
11135
11241
  constructor(snackBar) {
@@ -11201,6 +11307,7 @@ class PumpkinTechModule {
11201
11307
  static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.16", ngImport: i0, type: PumpkinTechModule, imports: [CommonModule,
11202
11308
  CoreMaterialModule,
11203
11309
  // standalone components para reexportar
11310
+ PtechStarsComponent,
11204
11311
  InputComponent,
11205
11312
  TextareaComponent,
11206
11313
  InputDateComponent,
@@ -11252,6 +11359,7 @@ class PumpkinTechModule {
11252
11359
  PtechLogsComponent,
11253
11360
  PtechHelpButtonComponent], exports: [
11254
11361
  // reexporta tudo junto
11362
+ PtechStarsComponent,
11255
11363
  InputComponent,
11256
11364
  TextareaComponent,
11257
11365
  InputDateComponent,
@@ -11310,7 +11418,6 @@ class PumpkinTechModule {
11310
11418
  },
11311
11419
  ], imports: [CommonModule,
11312
11420
  CoreMaterialModule,
11313
- // standalone components para reexportar
11314
11421
  InputComponent,
11315
11422
  TextareaComponent,
11316
11423
  InputDateComponent,
@@ -11367,6 +11474,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
11367
11474
  CommonModule,
11368
11475
  CoreMaterialModule,
11369
11476
  // standalone components para reexportar
11477
+ PtechStarsComponent,
11370
11478
  InputComponent,
11371
11479
  TextareaComponent,
11372
11480
  InputDateComponent,
@@ -11420,6 +11528,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
11420
11528
  ],
11421
11529
  exports: [
11422
11530
  // reexporta tudo junto
11531
+ PtechStarsComponent,
11423
11532
  InputComponent,
11424
11533
  TextareaComponent,
11425
11534
  InputDateComponent,
@@ -12895,5 +13004,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
12895
13004
  * Generated bundle index. Do not edit.
12896
13005
  */
12897
13006
 
12898
- export { ActionDialogComponent, ActionResultDialogComponent, ActionRowComponent, AlertComponent, ArrayUtil, BREADCRUMB_PREFIX$, BadgeComponent, BadgeStackComponent, BreadcrumbComponent, BreadcrumbService, ButtonComponent, CardComponent, CheckBoxComponent, ClickCatcherDirective, CoreMaterialModule, CurrencyBrlPipe, CurrencyPreferenceService, CurrencyUtil, DateAgoPipe, DateMaskDirective, DateUtil, DefaultConsoleMessageService, DefaultMessageService, DialogService, DialogShellComponent, DirectivesModule, DocumentUtil, DynamicTabDirective, EmailUtil, ExpansionPanelComponent, FakeDataService, FlagComponent, FooterComponent, ForDirective, GetFirstStringBeforeSpacePipe, HeaderComponent, IconComponent, InfoDetailComponent, InfoDetailDialogComponent, InputComponent, InputCurrencyComponent, InputDateComponent, InputDateRangeComponent, InputTimeComponent, IsLongerThanPipe, LineBreakAfterPeriodPipe, LineBreakAfterPipe, ListPaginationComponent, LoadingOverlayComponent, LoadingService, LowerCaseDirective, MESSAGE_SERVICE, MY_DATE_FORMATS, MemoryFormatPipe, ModuleChangeService, NavComponent, NavService, NumberUtil, ObjectUtil, PhoneBrazilPipe, PhoneMaskBrazilDirective, PhoneMaskSpainDirective, PhoneSpainPipe, PipesModule, ProfileMenuComponent, ProgressBarComponent, ProgressBarMultipleComponent, PtechAutocompleteComponent, PtechCarouselComponent, PtechClockService, PtechColDirective, PtechConfirmationDialogComponent, PtechConfirmationService, PtechCurrencyPipe, PtechDualListboxComponent, PtechGridDirective, PtechHelpButtonComponent, PtechInputFileComponent, PtechLogsComponent, PtechPopoverComponent, PtechTabComponent, PtechTableColumnBuilder, PtechTabsComponent, PtechTimelineComponent, PtechTimezoneClockComponent, PtechWidgetMenuComponent, PumpkinTechModule, QuantityItemsComponent, RadioGroupEntityComponent, RadioGroupEnumComponent, RedDirective, SelectEntityComponent, SelectEnumComponent, SelectQuantityItemsComponent, SlideToggleComponent, SnackbarMessageService, SpaceDropDirective, StringUtil, TableCellDirective, TableComponent, TextareaComponent, TimeDurationPipe, TitleComponent, UpperCaseDirective, UptimeFormatPipe, UuidUtil };
13007
+ export { ActionDialogComponent, ActionResultDialogComponent, ActionRowComponent, AlertComponent, ArrayUtil, BREADCRUMB_PREFIX$, BadgeComponent, BadgeStackComponent, BreadcrumbComponent, BreadcrumbService, ButtonComponent, CardComponent, CheckBoxComponent, ClickCatcherDirective, CoreMaterialModule, CurrencyBrlPipe, CurrencyPreferenceService, CurrencyUtil, DateAgoPipe, DateMaskDirective, DateUtil, DefaultConsoleMessageService, DefaultMessageService, DialogService, DialogShellComponent, DirectivesModule, DocumentUtil, DynamicTabDirective, EmailUtil, ExpansionPanelComponent, FakeDataService, FlagComponent, FooterComponent, ForDirective, GetFirstStringBeforeSpacePipe, HeaderComponent, IconComponent, InfoDetailComponent, InfoDetailDialogComponent, InputComponent, InputCurrencyComponent, InputDateComponent, InputDateRangeComponent, InputTimeComponent, IsLongerThanPipe, LineBreakAfterPeriodPipe, LineBreakAfterPipe, ListPaginationComponent, LoadingOverlayComponent, LoadingService, LowerCaseDirective, MESSAGE_SERVICE, MY_DATE_FORMATS, MemoryFormatPipe, ModuleChangeService, NavComponent, NavService, NumberUtil, ObjectUtil, PhoneBrazilPipe, PhoneMaskBrazilDirective, PhoneMaskSpainDirective, PhoneSpainPipe, PipesModule, ProfileMenuComponent, ProgressBarComponent, ProgressBarMultipleComponent, PtechAutocompleteComponent, PtechCarouselComponent, PtechClockService, PtechColDirective, PtechConfirmationDialogComponent, PtechConfirmationService, PtechCurrencyPipe, PtechDualListboxComponent, PtechGridDirective, PtechHelpButtonComponent, PtechInputFileComponent, PtechLogsComponent, PtechPopoverComponent, PtechStarsComponent, PtechTabComponent, PtechTableColumnBuilder, PtechTabsComponent, PtechTimelineComponent, PtechTimezoneClockComponent, PtechWidgetMenuComponent, PumpkinTechModule, QuantityItemsComponent, RadioGroupEntityComponent, RadioGroupEnumComponent, RedDirective, SelectEntityComponent, SelectEnumComponent, SelectQuantityItemsComponent, SlideToggleComponent, SnackbarMessageService, SpaceDropDirective, StringUtil, TableCellDirective, TableComponent, TextareaComponent, TimeDurationPipe, TitleComponent, UpperCaseDirective, UptimeFormatPipe, UuidUtil };
12899
13008
  //# sourceMappingURL=pumpkin-tech-pumpkin-tech-ng.mjs.map