@forgeroute/ui 0.3.2 → 0.3.4

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,323 @@ i0.ɵɵngDeclareClassMetadata({
10559
10560
  }]
10560
10561
  }
10561
10562
  });
10563
+ let registered = false;
10564
+ function registerChartParts() {
10565
+ if (registered) return;
10566
+ Chart.register(BarController, BarElement, CategoryScale, LinearScale, Tooltip);
10567
+ registered = true;
10568
+ }
10569
+ const VALUE_LABELS = {
10570
+ id: "uiBarChartValueLabels",
10571
+ afterDatasetsDraw(chart) {
10572
+ if (chart.options.plugins["uiBarChartValueLabels"]?.enabled === false) return;
10573
+ const ctx = chart.ctx;
10574
+ ctx.save();
10575
+ ctx.fillStyle = "#475569";
10576
+ ctx.font = "600 11px sans-serif";
10577
+ ctx.textAlign = "center";
10578
+ ctx.textBaseline = "bottom";
10579
+ chart.getDatasetMeta(0).data.forEach((bar, i) => {
10580
+ const value = chart.data.datasets[0]?.data[i];
10581
+ if (typeof value === "number" && value !== 0) ctx.fillText(String(value), bar.x, bar.y - 2);
10582
+ });
10583
+ ctx.restore();
10584
+ }
10585
+ };
10586
+ var BarChartComponent = class BarChartComponent {
10587
+ constructor() {
10588
+ this.labels = input([], ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
10589
+ this.values = input([], ...ngDevMode ? [{ debugName: "values" }] : /* istanbul ignore next */ []);
10590
+ this.color = input("#3b82f6", ...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
10591
+ this.hoverColor = input("#2563eb", ...ngDevMode ? [{ debugName: "hoverColor" }] : /* istanbul ignore next */ []);
10592
+ this.height = input(240, ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
10593
+ this.ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
10594
+ this.showValues = input(true, ...ngDevMode ? [{ debugName: "showValues" }] : /* istanbul ignore next */ []);
10595
+ this.unitSingular = input("", ...ngDevMode ? [{ debugName: "unitSingular" }] : /* istanbul ignore next */ []);
10596
+ this.unitPlural = input("", ...ngDevMode ? [{ debugName: "unitPlural" }] : /* istanbul ignore next */ []);
10597
+ this.canvas = viewChild.required("canvas", ...ngDevMode ? [{ debugName: "canvas" }] : /* istanbul ignore next */ []);
10598
+ this.zone = inject(NgZone);
10599
+ this.chart = null;
10600
+ this.tooltipText = (value) => {
10601
+ const unit = value === 1 ? this.unitSingular() : this.unitPlural();
10602
+ return unit ? `${value} ${unit}` : String(value);
10603
+ };
10604
+ this.series = computed(() => ({
10605
+ labels: this.labels(),
10606
+ data: this.values(),
10607
+ color: this.color(),
10608
+ hoverColor: this.hoverColor(),
10609
+ showValues: this.showValues()
10610
+ }), ...ngDevMode ? [{ debugName: "series" }] : /* istanbul ignore next */ []);
10611
+ effect(() => {
10612
+ const s = this.series();
10613
+ const canvas = this.canvas().nativeElement;
10614
+ if (!this.chart) {
10615
+ registerChartParts();
10616
+ this.zone.runOutsideAngular(() => {
10617
+ this.chart = new Chart(canvas, {
10618
+ type: "bar",
10619
+ data: {
10620
+ labels: s.labels,
10621
+ datasets: [{
10622
+ data: s.data,
10623
+ backgroundColor: s.color,
10624
+ hoverBackgroundColor: s.hoverColor,
10625
+ borderRadius: 3,
10626
+ borderSkipped: false
10627
+ }]
10628
+ },
10629
+ options: {
10630
+ responsive: true,
10631
+ maintainAspectRatio: false,
10632
+ animation: false,
10633
+ layout: { padding: { top: 20 } },
10634
+ plugins: {
10635
+ legend: { display: false },
10636
+ tooltip: { callbacks: { label: (item) => this.tooltipText(Number(item.raw)) } }
10637
+ },
10638
+ scales: {
10639
+ y: {
10640
+ beginAtZero: true,
10641
+ ticks: {
10642
+ precision: 0,
10643
+ color: "#94a3b8",
10644
+ font: { size: 11 }
10645
+ },
10646
+ grid: { color: "#e2e8f0" },
10647
+ border: { display: false }
10648
+ },
10649
+ x: {
10650
+ grid: { display: false },
10651
+ ticks: {
10652
+ maxRotation: 0,
10653
+ color: "#94a3b8",
10654
+ font: { size: 10 }
10655
+ },
10656
+ border: { display: false }
10657
+ }
10658
+ }
10659
+ },
10660
+ plugins: [VALUE_LABELS]
10661
+ });
10662
+ });
10663
+ }
10664
+ const chart = this.chart;
10665
+ chart.data.labels = s.labels;
10666
+ const ds = chart.data.datasets[0];
10667
+ ds.data = s.data;
10668
+ ds.backgroundColor = s.color;
10669
+ ds.hoverBackgroundColor = s.hoverColor;
10670
+ chart.options.plugins["uiBarChartValueLabels"] = { enabled: s.showValues };
10671
+ chart.update("none");
10672
+ });
10673
+ inject(DestroyRef).onDestroy(() => {
10674
+ this.chart?.destroy();
10675
+ this.chart = null;
10676
+ });
10677
+ }
10678
+ static {
10679
+ this.ɵfac = i0.ɵɵngDeclareFactory({
10680
+ minVersion: "12.0.0",
10681
+ version: "22.2.2",
10682
+ ngImport: i0,
10683
+ type: BarChartComponent,
10684
+ deps: [],
10685
+ target: i0.ɵɵFactoryTarget.Component
10686
+ });
10687
+ }
10688
+ static {
10689
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
10690
+ minVersion: "17.2.0",
10691
+ version: "22.2.2",
10692
+ type: BarChartComponent,
10693
+ isStandalone: true,
10694
+ selector: "ui-bar-chart",
10695
+ inputs: {
10696
+ labels: {
10697
+ classPropertyName: "labels",
10698
+ publicName: "labels",
10699
+ isSignal: true,
10700
+ isRequired: false,
10701
+ transformFunction: null
10702
+ },
10703
+ values: {
10704
+ classPropertyName: "values",
10705
+ publicName: "values",
10706
+ isSignal: true,
10707
+ isRequired: false,
10708
+ transformFunction: null
10709
+ },
10710
+ color: {
10711
+ classPropertyName: "color",
10712
+ publicName: "color",
10713
+ isSignal: true,
10714
+ isRequired: false,
10715
+ transformFunction: null
10716
+ },
10717
+ hoverColor: {
10718
+ classPropertyName: "hoverColor",
10719
+ publicName: "hoverColor",
10720
+ isSignal: true,
10721
+ isRequired: false,
10722
+ transformFunction: null
10723
+ },
10724
+ height: {
10725
+ classPropertyName: "height",
10726
+ publicName: "height",
10727
+ isSignal: true,
10728
+ isRequired: false,
10729
+ transformFunction: null
10730
+ },
10731
+ ariaLabel: {
10732
+ classPropertyName: "ariaLabel",
10733
+ publicName: "ariaLabel",
10734
+ isSignal: true,
10735
+ isRequired: false,
10736
+ transformFunction: null
10737
+ },
10738
+ showValues: {
10739
+ classPropertyName: "showValues",
10740
+ publicName: "showValues",
10741
+ isSignal: true,
10742
+ isRequired: false,
10743
+ transformFunction: null
10744
+ },
10745
+ unitSingular: {
10746
+ classPropertyName: "unitSingular",
10747
+ publicName: "unitSingular",
10748
+ isSignal: true,
10749
+ isRequired: false,
10750
+ transformFunction: null
10751
+ },
10752
+ unitPlural: {
10753
+ classPropertyName: "unitPlural",
10754
+ publicName: "unitPlural",
10755
+ isSignal: true,
10756
+ isRequired: false,
10757
+ transformFunction: null
10758
+ }
10759
+ },
10760
+ viewQueries: [{
10761
+ propertyName: "canvas",
10762
+ first: true,
10763
+ predicate: ["canvas"],
10764
+ descendants: true,
10765
+ isSignal: true
10766
+ }],
10767
+ ngImport: i0,
10768
+ template: `
10769
+ <div class="bc-wrap" [class.bc-default-height]="height() === 240" [style.height.px]="height()"
10770
+ role="img" [attr.aria-label]="ariaLabel() || null">
10771
+ <canvas #canvas></canvas>
10772
+ </div>
10773
+ `,
10774
+ isInline: true,
10775
+ 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"],
10776
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
10777
+ });
10778
+ }
10779
+ };
10780
+ i0.ɵɵngDeclareClassMetadata({
10781
+ minVersion: "12.0.0",
10782
+ version: "22.2.2",
10783
+ ngImport: i0,
10784
+ type: BarChartComponent,
10785
+ decorators: [{
10786
+ type: Component,
10787
+ args: [{
10788
+ selector: "ui-bar-chart",
10789
+ standalone: true,
10790
+ changeDetection: ChangeDetectionStrategy.OnPush,
10791
+ template: `
10792
+ <div class="bc-wrap" [class.bc-default-height]="height() === 240" [style.height.px]="height()"
10793
+ role="img" [attr.aria-label]="ariaLabel() || null">
10794
+ <canvas #canvas></canvas>
10795
+ </div>
10796
+ `,
10797
+ 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"]
10798
+ }]
10799
+ }],
10800
+ ctorParameters: () => [],
10801
+ propDecorators: {
10802
+ labels: [{
10803
+ type: i0.Input,
10804
+ args: [{
10805
+ isSignal: true,
10806
+ alias: "labels",
10807
+ required: false
10808
+ }]
10809
+ }],
10810
+ values: [{
10811
+ type: i0.Input,
10812
+ args: [{
10813
+ isSignal: true,
10814
+ alias: "values",
10815
+ required: false
10816
+ }]
10817
+ }],
10818
+ color: [{
10819
+ type: i0.Input,
10820
+ args: [{
10821
+ isSignal: true,
10822
+ alias: "color",
10823
+ required: false
10824
+ }]
10825
+ }],
10826
+ hoverColor: [{
10827
+ type: i0.Input,
10828
+ args: [{
10829
+ isSignal: true,
10830
+ alias: "hoverColor",
10831
+ required: false
10832
+ }]
10833
+ }],
10834
+ height: [{
10835
+ type: i0.Input,
10836
+ args: [{
10837
+ isSignal: true,
10838
+ alias: "height",
10839
+ required: false
10840
+ }]
10841
+ }],
10842
+ ariaLabel: [{
10843
+ type: i0.Input,
10844
+ args: [{
10845
+ isSignal: true,
10846
+ alias: "ariaLabel",
10847
+ required: false
10848
+ }]
10849
+ }],
10850
+ showValues: [{
10851
+ type: i0.Input,
10852
+ args: [{
10853
+ isSignal: true,
10854
+ alias: "showValues",
10855
+ required: false
10856
+ }]
10857
+ }],
10858
+ unitSingular: [{
10859
+ type: i0.Input,
10860
+ args: [{
10861
+ isSignal: true,
10862
+ alias: "unitSingular",
10863
+ required: false
10864
+ }]
10865
+ }],
10866
+ unitPlural: [{
10867
+ type: i0.Input,
10868
+ args: [{
10869
+ isSignal: true,
10870
+ alias: "unitPlural",
10871
+ required: false
10872
+ }]
10873
+ }],
10874
+ canvas: [{
10875
+ type: i0.ViewChild,
10876
+ args: ["canvas", { isSignal: true }]
10877
+ }]
10878
+ }
10879
+ });
10562
10880
  const KEY_STEP = 2;
10563
10881
  const KEY_STEP_BIG = 10;
10564
10882
  const clamp = (n) => Math.min(100, Math.max(0, Math.round(n)));
@@ -27885,6 +28203,6 @@ i0.ɵɵngDeclareClassMetadata({
27885
28203
  }]
27886
28204
  }
27887
28205
  });
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 };
28206
+ 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
28207
 
27890
28208
  //# sourceMappingURL=forgeroute-ui.mjs.map