integra-ng 20.1.9 → 20.1.10

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,11 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Output, Input, Component, ContentChildren, ElementRef, ViewChild, createComponent, Directive, Optional, Self, forwardRef, HostListener, ChangeDetectionStrategy, signal, inject, EnvironmentInjector, ApplicationRef, Injectable, input, computed, ViewEncapsulation, Inject } from '@angular/core';
2
+ import { EventEmitter, Output, Input, Component, ContentChildren, ElementRef, ViewChild, createComponent, Directive, Optional, Self, forwardRef, HostListener, ChangeDetectionStrategy, signal, inject, EnvironmentInjector, ApplicationRef, Injectable, input, computed, ViewEncapsulation, ViewChildren, Inject } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { NgClass, CommonModule, NgTemplateOutlet, NgIf, NgFor, NgStyle, DOCUMENT } from '@angular/common';
5
5
  import * as i2 from '@angular/forms';
6
6
  import { FormsModule, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
7
7
  import { take } from 'rxjs/operators';
8
8
  import { Subject, BehaviorSubject } from 'rxjs';
9
+ import { Chart, registerables } from 'chart.js';
9
10
  import * as i1$1 from '@angular/platform-browser';
10
11
 
11
12
  var lastId = 0;
@@ -6807,6 +6808,434 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
6807
6808
  args: ['document:mouseup']
6808
6809
  }] } });
6809
6810
 
6811
+ // Register all Chart.js components
6812
+ Chart.register(...registerables);
6813
+ /**
6814
+ * Chart Component
6815
+ *
6816
+ * A Chart.js-based chart component for displaying various chart types.
6817
+ * Supports multiple charts in a responsive grid layout.
6818
+ *
6819
+ * @example
6820
+ * ```html
6821
+ * <i-chart
6822
+ * [charts]="myCharts"
6823
+ * height="25rem">
6824
+ * </i-chart>
6825
+ * ```
6826
+ *
6827
+ * @example
6828
+ * ```typescript
6829
+ * myCharts: IChartData[] = [
6830
+ * {
6831
+ * chartId: 'sales-chart',
6832
+ * chartType: 'bar',
6833
+ * labels: ['Jan', 'Feb', 'Mar'],
6834
+ * dataSets: [{
6835
+ * label: 'Sales',
6836
+ * data: [100, 200, 150],
6837
+ * backgroundColors: ['--blue-500', '--green-500', '--orange-500']
6838
+ * }]
6839
+ * }
6840
+ * ];
6841
+ * ```
6842
+ */
6843
+ class IChart {
6844
+ /**
6845
+ * Array of chart data objects to render
6846
+ */
6847
+ charts = [];
6848
+ /**
6849
+ * Default height for charts
6850
+ * @default '20rem'
6851
+ */
6852
+ height = '20rem';
6853
+ /**
6854
+ * Whether charts should be responsive
6855
+ * @default true
6856
+ */
6857
+ responsive = true;
6858
+ /**
6859
+ * Reference to all canvas elements
6860
+ * @internal
6861
+ */
6862
+ canvasElements;
6863
+ /**
6864
+ * Array of display configurations for each chart
6865
+ * @internal
6866
+ */
6867
+ chartDisplays = [];
6868
+ /**
6869
+ * Chart.js instances for cleanup
6870
+ * @internal
6871
+ */
6872
+ chartInstances = [];
6873
+ /**
6874
+ * Flag to track if component has initialized
6875
+ * @internal
6876
+ */
6877
+ initialized = false;
6878
+ /**
6879
+ * Reference to pending animation frame for cleanup
6880
+ * @internal
6881
+ */
6882
+ pendingAnimationFrame = null;
6883
+ ngAfterViewInit() {
6884
+ this.initialized = true;
6885
+ this.initializeCharts();
6886
+ }
6887
+ ngOnChanges(changes) {
6888
+ if (changes['charts'] && this.initialized) {
6889
+ this.destroyCharts();
6890
+ this.initializeCharts();
6891
+ }
6892
+ }
6893
+ ngOnDestroy() {
6894
+ this.cancelPendingInitialization();
6895
+ this.destroyCharts();
6896
+ }
6897
+ /**
6898
+ * Cancel any pending chart initialization
6899
+ * @internal
6900
+ */
6901
+ cancelPendingInitialization() {
6902
+ if (this.pendingAnimationFrame !== null) {
6903
+ cancelAnimationFrame(this.pendingAnimationFrame);
6904
+ this.pendingAnimationFrame = null;
6905
+ }
6906
+ }
6907
+ /**
6908
+ * Initialize all charts
6909
+ * @internal
6910
+ */
6911
+ initializeCharts() {
6912
+ this.chartDisplays = this.charts.map((chart) => this.transformToChartDisplay(chart));
6913
+ // Cancel any pending initialization
6914
+ this.cancelPendingInitialization();
6915
+ // Use requestAnimationFrame for proper timing after view update
6916
+ this.pendingAnimationFrame = requestAnimationFrame(() => {
6917
+ this.pendingAnimationFrame = null;
6918
+ this.canvasElements.forEach((canvasRef, index) => {
6919
+ const chartDisplay = this.chartDisplays[index];
6920
+ if (chartDisplay && canvasRef) {
6921
+ const chartInstance = this.createChartInstance(canvasRef.nativeElement, chartDisplay);
6922
+ this.chartInstances.push(chartInstance);
6923
+ }
6924
+ });
6925
+ });
6926
+ }
6927
+ /**
6928
+ * Destroy all chart instances
6929
+ * @internal
6930
+ */
6931
+ destroyCharts() {
6932
+ this.chartInstances.forEach((chart) => {
6933
+ chart.destroy();
6934
+ });
6935
+ this.chartInstances = [];
6936
+ this.chartDisplays = [];
6937
+ }
6938
+ /**
6939
+ * Create a Chart.js instance
6940
+ * @internal
6941
+ */
6942
+ createChartInstance(canvas, display) {
6943
+ const config = {
6944
+ type: display.type,
6945
+ data: display.data,
6946
+ options: display.options,
6947
+ };
6948
+ return new Chart(canvas, config);
6949
+ }
6950
+ /**
6951
+ * Transform IChartData to IChartDisplay
6952
+ * @internal
6953
+ */
6954
+ transformToChartDisplay(chart) {
6955
+ const documentStyle = getComputedStyle(document.documentElement);
6956
+ const textColor = documentStyle.getPropertyValue('--text-color') || '#333';
6957
+ const textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary') || '#666';
6958
+ const surfaceBorder = documentStyle.getPropertyValue('--surface-border') || '#ddd';
6959
+ const chartType = this.mapChartType(chart.chartType);
6960
+ const height = this.getChartHeight(chart.chartType);
6961
+ const options = this.getChartOptions(chart.chartType, textColor, textColorSecondary, surfaceBorder);
6962
+ const data = {
6963
+ labels: chart.labels,
6964
+ datasets: chart.dataSets.map((dataset) => this.transformDataset(dataset, documentStyle)),
6965
+ };
6966
+ return {
6967
+ type: chartType,
6968
+ data,
6969
+ options,
6970
+ height,
6971
+ };
6972
+ }
6973
+ /**
6974
+ * Map custom chart type strings to Chart.js types
6975
+ * @internal
6976
+ */
6977
+ mapChartType(chartType) {
6978
+ const typeMap = {
6979
+ bar: 'bar',
6980
+ 'bar-stack': 'bar',
6981
+ 'bar-large': 'bar',
6982
+ 'bar-horizontal': 'bar',
6983
+ pie: 'pie',
6984
+ doughnut: 'doughnut',
6985
+ line: 'line',
6986
+ scatter: 'scatter',
6987
+ bubble: 'bubble',
6988
+ polarArea: 'polarArea',
6989
+ radar: 'radar',
6990
+ };
6991
+ return typeMap[chartType] || 'bar';
6992
+ }
6993
+ /**
6994
+ * Get chart height based on chart type
6995
+ * @internal
6996
+ */
6997
+ getChartHeight(chartType) {
6998
+ if (chartType === 'bar-large') {
6999
+ return '40rem';
7000
+ }
7001
+ return this.height;
7002
+ }
7003
+ /**
7004
+ * Get chart options based on chart type
7005
+ * @internal
7006
+ */
7007
+ getChartOptions(chartType, textColor, textColorSecondary, surfaceBorder) {
7008
+ const baseOptions = {
7009
+ maintainAspectRatio: false,
7010
+ responsive: this.responsive,
7011
+ plugins: {
7012
+ legend: {
7013
+ labels: {
7014
+ color: textColor,
7015
+ },
7016
+ },
7017
+ },
7018
+ };
7019
+ switch (chartType) {
7020
+ case 'bar':
7021
+ return {
7022
+ ...baseOptions,
7023
+ scales: this.getBarScales(textColorSecondary, surfaceBorder),
7024
+ };
7025
+ case 'bar-stack':
7026
+ return {
7027
+ ...baseOptions,
7028
+ scales: this.getStackedBarScales(textColorSecondary, surfaceBorder),
7029
+ };
7030
+ case 'bar-large':
7031
+ return {
7032
+ ...baseOptions,
7033
+ scales: this.getBarScales(textColorSecondary, surfaceBorder),
7034
+ };
7035
+ case 'bar-horizontal':
7036
+ return {
7037
+ ...baseOptions,
7038
+ indexAxis: 'y',
7039
+ scales: this.getBarScales(textColorSecondary, surfaceBorder),
7040
+ };
7041
+ case 'pie':
7042
+ case 'doughnut':
7043
+ return {
7044
+ ...baseOptions,
7045
+ plugins: {
7046
+ legend: {
7047
+ labels: {
7048
+ color: textColor,
7049
+ },
7050
+ position: 'bottom',
7051
+ },
7052
+ },
7053
+ };
7054
+ case 'line':
7055
+ return {
7056
+ ...baseOptions,
7057
+ scales: this.getLineScales(textColorSecondary, surfaceBorder),
7058
+ };
7059
+ case 'radar':
7060
+ return {
7061
+ ...baseOptions,
7062
+ plugins: {
7063
+ legend: {
7064
+ labels: {
7065
+ color: textColor,
7066
+ },
7067
+ },
7068
+ },
7069
+ scales: {
7070
+ r: {
7071
+ grid: {
7072
+ color: surfaceBorder,
7073
+ },
7074
+ pointLabels: {
7075
+ color: textColorSecondary,
7076
+ },
7077
+ },
7078
+ },
7079
+ };
7080
+ case 'polarArea':
7081
+ return {
7082
+ ...baseOptions,
7083
+ scales: {
7084
+ r: {
7085
+ grid: {
7086
+ color: surfaceBorder,
7087
+ },
7088
+ },
7089
+ },
7090
+ };
7091
+ default:
7092
+ return baseOptions;
7093
+ }
7094
+ }
7095
+ /**
7096
+ * Get scales configuration for bar charts
7097
+ * @internal
7098
+ */
7099
+ getBarScales(textColorSecondary, surfaceBorder) {
7100
+ return {
7101
+ x: {
7102
+ ticks: {
7103
+ color: textColorSecondary,
7104
+ },
7105
+ grid: {
7106
+ color: surfaceBorder,
7107
+ },
7108
+ },
7109
+ y: {
7110
+ ticks: {
7111
+ color: textColorSecondary,
7112
+ },
7113
+ grid: {
7114
+ color: surfaceBorder,
7115
+ },
7116
+ },
7117
+ };
7118
+ }
7119
+ /**
7120
+ * Get scales configuration for stacked bar charts
7121
+ * @internal
7122
+ */
7123
+ getStackedBarScales(textColorSecondary, surfaceBorder) {
7124
+ return {
7125
+ x: {
7126
+ stacked: true,
7127
+ ticks: {
7128
+ color: textColorSecondary,
7129
+ },
7130
+ grid: {
7131
+ color: surfaceBorder,
7132
+ },
7133
+ },
7134
+ y: {
7135
+ stacked: true,
7136
+ ticks: {
7137
+ color: textColorSecondary,
7138
+ },
7139
+ grid: {
7140
+ color: surfaceBorder,
7141
+ },
7142
+ },
7143
+ };
7144
+ }
7145
+ /**
7146
+ * Get scales configuration for line charts
7147
+ * @internal
7148
+ */
7149
+ getLineScales(textColorSecondary, surfaceBorder) {
7150
+ return {
7151
+ x: {
7152
+ ticks: {
7153
+ color: textColorSecondary,
7154
+ },
7155
+ grid: {
7156
+ color: surfaceBorder,
7157
+ },
7158
+ },
7159
+ y: {
7160
+ ticks: {
7161
+ color: textColorSecondary,
7162
+ },
7163
+ grid: {
7164
+ color: surfaceBorder,
7165
+ },
7166
+ },
7167
+ };
7168
+ }
7169
+ /**
7170
+ * Transform dataset with resolved colors
7171
+ * @internal
7172
+ */
7173
+ transformDataset(dataset, documentStyle) {
7174
+ return {
7175
+ label: dataset.label,
7176
+ data: dataset.data,
7177
+ backgroundColor: dataset.backgroundColors.map((color) => {
7178
+ const resolvedColor = this.resolveColor(color, documentStyle);
7179
+ return this.addTransparency(resolvedColor);
7180
+ }),
7181
+ borderColor: dataset.backgroundColors.map((color) => this.resolveColor(color, documentStyle)),
7182
+ borderWidth: 1,
7183
+ };
7184
+ }
7185
+ /**
7186
+ * Resolve CSS variable to hex color or return as-is
7187
+ * @internal
7188
+ */
7189
+ resolveColor(color, documentStyle) {
7190
+ if (color.startsWith('--')) {
7191
+ const resolvedColor = documentStyle.getPropertyValue(color).trim();
7192
+ return resolvedColor || color;
7193
+ }
7194
+ return color;
7195
+ }
7196
+ /**
7197
+ * Add transparency to a hex color
7198
+ * @internal
7199
+ */
7200
+ addTransparency(color) {
7201
+ // If it's a hex color, add transparency
7202
+ if (color.startsWith('#')) {
7203
+ return color + 'bf'; // ~75% opacity
7204
+ }
7205
+ return color;
7206
+ }
7207
+ /**
7208
+ * Get the height style for a chart display
7209
+ * @param display - The chart display configuration
7210
+ * @returns The height CSS value
7211
+ */
7212
+ getChartHeightStyle(display) {
7213
+ return display.height || this.height;
7214
+ }
7215
+ /**
7216
+ * Get the number of active chart instances (for testing)
7217
+ * @returns The count of active chart instances
7218
+ */
7219
+ getChartInstanceCount() {
7220
+ return this.chartInstances.length;
7221
+ }
7222
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: IChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
7223
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.3", type: IChart, isStandalone: true, selector: "i-chart", inputs: { charts: "charts", height: "height", responsive: "responsive" }, viewQueries: [{ propertyName: "canvasElements", predicate: ["chartCanvas"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"i-charts-container\">\n @for (chartDisplay of chartDisplays; track chartDisplay) {\n <div class=\"i-chart-item\" [style.height]=\"getChartHeightStyle(chartDisplay)\">\n <canvas #chartCanvas></canvas>\n </div>\n }\n</div>\n", styles: [".i-charts-container{display:flex;flex-wrap:wrap;width:100%;gap:4rem}.i-chart-item{flex:1 1 45%;min-width:300px;box-sizing:border-box}@media (max-width: 768px){.i-charts-container{flex-direction:column}.i-chart-item{width:100%}}\n"] });
7224
+ }
7225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: IChart, decorators: [{
7226
+ type: Component,
7227
+ args: [{ selector: 'i-chart', standalone: true, imports: [], template: "<div class=\"i-charts-container\">\n @for (chartDisplay of chartDisplays; track chartDisplay) {\n <div class=\"i-chart-item\" [style.height]=\"getChartHeightStyle(chartDisplay)\">\n <canvas #chartCanvas></canvas>\n </div>\n }\n</div>\n", styles: [".i-charts-container{display:flex;flex-wrap:wrap;width:100%;gap:4rem}.i-chart-item{flex:1 1 45%;min-width:300px;box-sizing:border-box}@media (max-width: 768px){.i-charts-container{flex-direction:column}.i-chart-item{width:100%}}\n"] }]
7228
+ }], propDecorators: { charts: [{
7229
+ type: Input
7230
+ }], height: [{
7231
+ type: Input
7232
+ }], responsive: [{
7233
+ type: Input
7234
+ }], canvasElements: [{
7235
+ type: ViewChildren,
7236
+ args: ['chartCanvas']
7237
+ }] } });
7238
+
6810
7239
  /**
6811
7240
  * Service for broadcasting data update events across the application.
6812
7241
  *
@@ -7265,5 +7694,5 @@ var zindexutils = ZIndexUtils();
7265
7694
  * Generated bundle index. Do not edit.
7266
7695
  */
7267
7696
 
7268
- export { AbstractDialog, ConfirmationDialogComponent, ConfirmationDialogService, DataUpdateEventService, DialogService, EmptyStateComponent, EmptyStateTableComponent, IAccordion, IAccordionList, IButton, ICalendar, ICard, ICheckbox, IChip, IChipsComponent, IDialog, IDialogActions, IDialogBase, IInputText, IListbox, IMessage, IMultiSelect, IPanel, IRadioButton, ISelect, ITabPanel, ITable, ITabs, ITreeView, IWhisper, SeoService, StructuredDataService, TooltipComponent, TooltipDirective, UniqueComponentId, WhisperService, ZIndexUtils, lastId };
7697
+ export { AbstractDialog, ConfirmationDialogComponent, ConfirmationDialogService, DataUpdateEventService, DialogService, EmptyStateComponent, EmptyStateTableComponent, IAccordion, IAccordionList, IButton, ICalendar, ICard, IChart, ICheckbox, IChip, IChipsComponent, IDialog, IDialogActions, IDialogBase, IInputText, IListbox, IMessage, IMultiSelect, IPanel, IRadioButton, ISelect, ITabPanel, ITable, ITabs, ITreeView, IWhisper, SeoService, StructuredDataService, TooltipComponent, TooltipDirective, UniqueComponentId, WhisperService, ZIndexUtils, lastId };
7269
7698
  //# sourceMappingURL=integra-ng.mjs.map