@forgeroute/ui 0.3.2 → 0.3.3

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 { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, Directive, ElementRef, HostBinding, HostListener, Injectable, InjectionToken, Injector, Input, Renderer2, afterNextRender, computed, effect, forwardRef, inject, input, linkedSignal, model, output, signal, untracked, viewChild } from "@angular/core";
2
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, Directive, ElementRef, HostBinding, HostListener, Injectable, InjectionToken, Injector, Input, NgZone, Renderer2, afterNextRender, computed, effect, forwardRef, inject, input, linkedSignal, model, output, signal, untracked, viewChild } from "@angular/core";
3
3
  import { HttpClient, HttpErrorResponse, HttpParams } from "@angular/common/http";
4
4
  import { takeUntilDestroyed, toObservable } from "@angular/core/rxjs-interop";
5
5
  import { catchError, debounceTime, distinctUntilChanged, skip, switchMap } from "rxjs/operators";
@@ -7,6 +7,7 @@ import { Subject, catchError as catchError$1, debounceTime as debounceTime$1, fi
7
7
  import { DOCUMENT, DatePipe, DecimalPipe, NgTemplateOutlet } from "@angular/common";
8
8
  import * as i1 from "@angular/forms";
9
9
  import { FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR } from "@angular/forms";
10
+ import { BarController, BarElement, CategoryScale, Chart, LinearScale, Tooltip } from "chart.js";
10
11
  import { NavigationEnd, Router, RouterLink, RouterLinkActive } from "@angular/router";
11
12
  import { DomSanitizer } from "@angular/platform-browser";
12
13
  const FORGEROUTE_CONFIG = new InjectionToken("FORGEROUTE_CONFIG");
@@ -10559,6 +10560,315 @@ i0.ɵɵngDeclareClassMetadata({
10559
10560
  }]
10560
10561
  }
10561
10562
  });
10563
+ Chart.register(BarController, BarElement, CategoryScale, LinearScale, Tooltip);
10564
+ const VALUE_LABELS = {
10565
+ id: "uiBarChartValueLabels",
10566
+ afterDatasetsDraw(chart) {
10567
+ if (chart.options.plugins["uiBarChartValueLabels"]?.enabled === false) return;
10568
+ const ctx = chart.ctx;
10569
+ ctx.save();
10570
+ ctx.fillStyle = "#475569";
10571
+ ctx.font = "600 11px sans-serif";
10572
+ ctx.textAlign = "center";
10573
+ ctx.textBaseline = "bottom";
10574
+ chart.getDatasetMeta(0).data.forEach((bar, i) => {
10575
+ const value = chart.data.datasets[0]?.data[i];
10576
+ if (typeof value === "number" && value !== 0) ctx.fillText(String(value), bar.x, bar.y - 2);
10577
+ });
10578
+ ctx.restore();
10579
+ }
10580
+ };
10581
+ var BarChartComponent = class BarChartComponent {
10582
+ constructor() {
10583
+ this.labels = input([], ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
10584
+ this.values = input([], ...ngDevMode ? [{ debugName: "values" }] : /* istanbul ignore next */ []);
10585
+ this.color = input("#3b82f6", ...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
10586
+ this.hoverColor = input("#2563eb", ...ngDevMode ? [{ debugName: "hoverColor" }] : /* istanbul ignore next */ []);
10587
+ this.height = input(240, ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
10588
+ this.ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
10589
+ this.showValues = input(true, ...ngDevMode ? [{ debugName: "showValues" }] : /* istanbul ignore next */ []);
10590
+ this.unitSingular = input("", ...ngDevMode ? [{ debugName: "unitSingular" }] : /* istanbul ignore next */ []);
10591
+ this.unitPlural = input("", ...ngDevMode ? [{ debugName: "unitPlural" }] : /* istanbul ignore next */ []);
10592
+ this.canvas = viewChild.required("canvas", ...ngDevMode ? [{ debugName: "canvas" }] : /* istanbul ignore next */ []);
10593
+ this.zone = inject(NgZone);
10594
+ this.chart = null;
10595
+ this.tooltipText = (value) => {
10596
+ const unit = value === 1 ? this.unitSingular() : this.unitPlural();
10597
+ return unit ? `${value} ${unit}` : String(value);
10598
+ };
10599
+ this.series = computed(() => ({
10600
+ labels: this.labels(),
10601
+ data: this.values(),
10602
+ color: this.color(),
10603
+ hoverColor: this.hoverColor(),
10604
+ showValues: this.showValues()
10605
+ }), ...ngDevMode ? [{ debugName: "series" }] : /* istanbul ignore next */ []);
10606
+ effect(() => {
10607
+ const s = this.series();
10608
+ const canvas = this.canvas().nativeElement;
10609
+ if (!this.chart) this.zone.runOutsideAngular(() => {
10610
+ this.chart = new Chart(canvas, {
10611
+ type: "bar",
10612
+ data: {
10613
+ labels: s.labels,
10614
+ datasets: [{
10615
+ data: s.data,
10616
+ backgroundColor: s.color,
10617
+ hoverBackgroundColor: s.hoverColor,
10618
+ borderRadius: 3,
10619
+ borderSkipped: false
10620
+ }]
10621
+ },
10622
+ options: {
10623
+ responsive: true,
10624
+ maintainAspectRatio: false,
10625
+ animation: false,
10626
+ layout: { padding: { top: 20 } },
10627
+ plugins: {
10628
+ legend: { display: false },
10629
+ tooltip: { callbacks: { label: (item) => this.tooltipText(Number(item.raw)) } }
10630
+ },
10631
+ scales: {
10632
+ y: {
10633
+ beginAtZero: true,
10634
+ ticks: {
10635
+ precision: 0,
10636
+ color: "#94a3b8",
10637
+ font: { size: 11 }
10638
+ },
10639
+ grid: { color: "#e2e8f0" },
10640
+ border: { display: false }
10641
+ },
10642
+ x: {
10643
+ grid: { display: false },
10644
+ ticks: {
10645
+ maxRotation: 0,
10646
+ color: "#94a3b8",
10647
+ font: { size: 10 }
10648
+ },
10649
+ border: { display: false }
10650
+ }
10651
+ }
10652
+ },
10653
+ plugins: [VALUE_LABELS]
10654
+ });
10655
+ });
10656
+ const chart = this.chart;
10657
+ chart.data.labels = s.labels;
10658
+ const ds = chart.data.datasets[0];
10659
+ ds.data = s.data;
10660
+ ds.backgroundColor = s.color;
10661
+ ds.hoverBackgroundColor = s.hoverColor;
10662
+ chart.options.plugins["uiBarChartValueLabels"] = { enabled: s.showValues };
10663
+ chart.update("none");
10664
+ });
10665
+ inject(DestroyRef).onDestroy(() => {
10666
+ this.chart?.destroy();
10667
+ this.chart = null;
10668
+ });
10669
+ }
10670
+ static {
10671
+ this.ɵfac = i0.ɵɵngDeclareFactory({
10672
+ minVersion: "12.0.0",
10673
+ version: "22.2.2",
10674
+ ngImport: i0,
10675
+ type: BarChartComponent,
10676
+ deps: [],
10677
+ target: i0.ɵɵFactoryTarget.Component
10678
+ });
10679
+ }
10680
+ static {
10681
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
10682
+ minVersion: "17.2.0",
10683
+ version: "22.2.2",
10684
+ type: BarChartComponent,
10685
+ isStandalone: true,
10686
+ selector: "ui-bar-chart",
10687
+ inputs: {
10688
+ labels: {
10689
+ classPropertyName: "labels",
10690
+ publicName: "labels",
10691
+ isSignal: true,
10692
+ isRequired: false,
10693
+ transformFunction: null
10694
+ },
10695
+ values: {
10696
+ classPropertyName: "values",
10697
+ publicName: "values",
10698
+ isSignal: true,
10699
+ isRequired: false,
10700
+ transformFunction: null
10701
+ },
10702
+ color: {
10703
+ classPropertyName: "color",
10704
+ publicName: "color",
10705
+ isSignal: true,
10706
+ isRequired: false,
10707
+ transformFunction: null
10708
+ },
10709
+ hoverColor: {
10710
+ classPropertyName: "hoverColor",
10711
+ publicName: "hoverColor",
10712
+ isSignal: true,
10713
+ isRequired: false,
10714
+ transformFunction: null
10715
+ },
10716
+ height: {
10717
+ classPropertyName: "height",
10718
+ publicName: "height",
10719
+ isSignal: true,
10720
+ isRequired: false,
10721
+ transformFunction: null
10722
+ },
10723
+ ariaLabel: {
10724
+ classPropertyName: "ariaLabel",
10725
+ publicName: "ariaLabel",
10726
+ isSignal: true,
10727
+ isRequired: false,
10728
+ transformFunction: null
10729
+ },
10730
+ showValues: {
10731
+ classPropertyName: "showValues",
10732
+ publicName: "showValues",
10733
+ isSignal: true,
10734
+ isRequired: false,
10735
+ transformFunction: null
10736
+ },
10737
+ unitSingular: {
10738
+ classPropertyName: "unitSingular",
10739
+ publicName: "unitSingular",
10740
+ isSignal: true,
10741
+ isRequired: false,
10742
+ transformFunction: null
10743
+ },
10744
+ unitPlural: {
10745
+ classPropertyName: "unitPlural",
10746
+ publicName: "unitPlural",
10747
+ isSignal: true,
10748
+ isRequired: false,
10749
+ transformFunction: null
10750
+ }
10751
+ },
10752
+ viewQueries: [{
10753
+ propertyName: "canvas",
10754
+ first: true,
10755
+ predicate: ["canvas"],
10756
+ descendants: true,
10757
+ isSignal: true
10758
+ }],
10759
+ ngImport: i0,
10760
+ template: `
10761
+ <div class="bc-wrap" [class.bc-default-height]="height() === 240" [style.height.px]="height()"
10762
+ role="img" [attr.aria-label]="ariaLabel() || null">
10763
+ <canvas #canvas></canvas>
10764
+ </div>
10765
+ `,
10766
+ isInline: true,
10767
+ styles: [":host{display:block}.bc-wrap{position:relative}@media(max-width:768px){.bc-wrap.bc-default-height{height:200px!important}}@media(max-width:480px){.bc-wrap.bc-default-height{height:160px!important}}\n"],
10768
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
10769
+ });
10770
+ }
10771
+ };
10772
+ i0.ɵɵngDeclareClassMetadata({
10773
+ minVersion: "12.0.0",
10774
+ version: "22.2.2",
10775
+ ngImport: i0,
10776
+ type: BarChartComponent,
10777
+ decorators: [{
10778
+ type: Component,
10779
+ args: [{
10780
+ selector: "ui-bar-chart",
10781
+ standalone: true,
10782
+ changeDetection: ChangeDetectionStrategy.OnPush,
10783
+ template: `
10784
+ <div class="bc-wrap" [class.bc-default-height]="height() === 240" [style.height.px]="height()"
10785
+ role="img" [attr.aria-label]="ariaLabel() || null">
10786
+ <canvas #canvas></canvas>
10787
+ </div>
10788
+ `,
10789
+ styles: [":host{display:block}.bc-wrap{position:relative}@media(max-width:768px){.bc-wrap.bc-default-height{height:200px!important}}@media(max-width:480px){.bc-wrap.bc-default-height{height:160px!important}}\n"]
10790
+ }]
10791
+ }],
10792
+ ctorParameters: () => [],
10793
+ propDecorators: {
10794
+ labels: [{
10795
+ type: i0.Input,
10796
+ args: [{
10797
+ isSignal: true,
10798
+ alias: "labels",
10799
+ required: false
10800
+ }]
10801
+ }],
10802
+ values: [{
10803
+ type: i0.Input,
10804
+ args: [{
10805
+ isSignal: true,
10806
+ alias: "values",
10807
+ required: false
10808
+ }]
10809
+ }],
10810
+ color: [{
10811
+ type: i0.Input,
10812
+ args: [{
10813
+ isSignal: true,
10814
+ alias: "color",
10815
+ required: false
10816
+ }]
10817
+ }],
10818
+ hoverColor: [{
10819
+ type: i0.Input,
10820
+ args: [{
10821
+ isSignal: true,
10822
+ alias: "hoverColor",
10823
+ required: false
10824
+ }]
10825
+ }],
10826
+ height: [{
10827
+ type: i0.Input,
10828
+ args: [{
10829
+ isSignal: true,
10830
+ alias: "height",
10831
+ required: false
10832
+ }]
10833
+ }],
10834
+ ariaLabel: [{
10835
+ type: i0.Input,
10836
+ args: [{
10837
+ isSignal: true,
10838
+ alias: "ariaLabel",
10839
+ required: false
10840
+ }]
10841
+ }],
10842
+ showValues: [{
10843
+ type: i0.Input,
10844
+ args: [{
10845
+ isSignal: true,
10846
+ alias: "showValues",
10847
+ required: false
10848
+ }]
10849
+ }],
10850
+ unitSingular: [{
10851
+ type: i0.Input,
10852
+ args: [{
10853
+ isSignal: true,
10854
+ alias: "unitSingular",
10855
+ required: false
10856
+ }]
10857
+ }],
10858
+ unitPlural: [{
10859
+ type: i0.Input,
10860
+ args: [{
10861
+ isSignal: true,
10862
+ alias: "unitPlural",
10863
+ required: false
10864
+ }]
10865
+ }],
10866
+ canvas: [{
10867
+ type: i0.ViewChild,
10868
+ args: ["canvas", { isSignal: true }]
10869
+ }]
10870
+ }
10871
+ });
10562
10872
  const KEY_STEP = 2;
10563
10873
  const KEY_STEP_BIG = 10;
10564
10874
  const clamp = (n) => Math.min(100, Math.max(0, Math.round(n)));
@@ -27885,6 +28195,6 @@ i0.ɵɵngDeclareClassMetadata({
27885
28195
  }]
27886
28196
  }
27887
28197
  });
27888
- export { AlertComponent, AppShellComponent, AvatarComponent, BADGE_VARIANT_STYLES, BadgeComponent, BulkMessagePanelComponent, ButtonComponent, CheckboxComponent, ChipComponent, ChipGroupComponent, ColumnFilterComponent, ComboboxComponent, ConfirmOutletComponent, ConfirmService, ContactPickerComponent, DEFAULT_DOCUMENT_SUBJECT, DOCUMENT_PURPOSE_OPTIONS, DROPDOWN_GROUP, DataTableComponent, DateInputComponent, DateRangePickerComponent, DatetimeInputComponent, DetailCardComponent, DiscountSelectorComponent, DividerComponent, DocumentSendOptionsComponent, DropdownComponent, EmptyStateComponent, ErrorComponent, ErrorStateComponent, FORGEROUTE_CONFIG, FileInputComponent, FormRowComponent, FormSectionComponent, HintComponent, ImagePreviewComponent, ImageRepositionComponent, ImportExportComponent, KpiCardComponent, ListItemComponent, MAX_CC, ModalComponent, MoreMenuComponent, MultiSelectComponent, PaginationComponent, PanelInfoListComponent, PillTabsComponent, ProgressBarComponent, QrCodeComponent, QuickFilterTabsComponent, RICH_TEXT_OPTIONS, RadioComponent, RadioGroupComponent, RadioMatrixComponent, RichTextEditorComponent, SEMANTIC_BADGE_MAP, SearchInputComponent, SelectComponent, SendMessagePanelComponent, SidePanelComponent, SkeletonComponent, TableToolbarComponent, TemplatePickerComponent, TextInputComponent, TextareaInputComponent, TimeInputComponent, ToastComponent, ToastService, ToggleBadgeComponent, TooltipDirective, US_STATES, UiFieldValidity, VideoPickerComponent, appShellGroupsStorageKey, autoVariant, builtInActionIcon, createFieldReveal, decodeFilterValues, encodeFilterValue, encodeFilterValues, errorContextInterceptor, formatIsoDate, formatIsoDateTime, formatTime, getEligibleIds, getEligibleOptions, getErrorMessage, humanReadableMessage, isoKey, issueToErrors, maxLengthIssue, messagePreviewHtml, parseCcList, parseIso, parseTime, pluralize, requiredIssue, resolvePreset, suggestDocumentSubject };
28198
+ export { AlertComponent, AppShellComponent, AvatarComponent, BADGE_VARIANT_STYLES, BadgeComponent, BarChartComponent, BulkMessagePanelComponent, ButtonComponent, CheckboxComponent, ChipComponent, ChipGroupComponent, ColumnFilterComponent, ComboboxComponent, ConfirmOutletComponent, ConfirmService, ContactPickerComponent, DEFAULT_DOCUMENT_SUBJECT, DOCUMENT_PURPOSE_OPTIONS, DROPDOWN_GROUP, DataTableComponent, DateInputComponent, DateRangePickerComponent, DatetimeInputComponent, DetailCardComponent, DiscountSelectorComponent, DividerComponent, DocumentSendOptionsComponent, DropdownComponent, EmptyStateComponent, ErrorComponent, ErrorStateComponent, FORGEROUTE_CONFIG, FileInputComponent, FormRowComponent, FormSectionComponent, HintComponent, ImagePreviewComponent, ImageRepositionComponent, ImportExportComponent, KpiCardComponent, ListItemComponent, MAX_CC, ModalComponent, MoreMenuComponent, MultiSelectComponent, PaginationComponent, PanelInfoListComponent, PillTabsComponent, ProgressBarComponent, QrCodeComponent, QuickFilterTabsComponent, RICH_TEXT_OPTIONS, RadioComponent, RadioGroupComponent, RadioMatrixComponent, RichTextEditorComponent, SEMANTIC_BADGE_MAP, SearchInputComponent, SelectComponent, SendMessagePanelComponent, SidePanelComponent, SkeletonComponent, TableToolbarComponent, TemplatePickerComponent, TextInputComponent, TextareaInputComponent, TimeInputComponent, ToastComponent, ToastService, ToggleBadgeComponent, TooltipDirective, US_STATES, UiFieldValidity, VideoPickerComponent, appShellGroupsStorageKey, autoVariant, builtInActionIcon, createFieldReveal, decodeFilterValues, encodeFilterValue, encodeFilterValues, errorContextInterceptor, formatIsoDate, formatIsoDateTime, formatTime, getEligibleIds, getEligibleOptions, getErrorMessage, humanReadableMessage, isoKey, issueToErrors, maxLengthIssue, messagePreviewHtml, parseCcList, parseIso, parseTime, pluralize, requiredIssue, resolvePreset, suggestDocumentSubject };
27889
28199
 
27890
28200
  //# sourceMappingURL=forgeroute-ui.mjs.map