@aquera/nile-visualization 2.9.40 → 2.9.42
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 +9 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +2 -0
- package/dist/src/internal/types/chart-pagination-config.type.d.ts +32 -0
- package/dist/src/internal/types/chart-pagination-config.type.js +2 -0
- package/dist/src/internal/types/nile-chart-config-input.type.d.ts +2 -1
- package/dist/src/internal/types/separated-chart-config-input.type.d.ts +2 -1
- package/dist/src/internal/utils/chart-events.d.ts +3 -0
- package/dist/src/internal/utils/chart-events.js +4 -0
- package/dist/src/internal/utils/chart-pagination.d.ts +145 -0
- package/dist/src/internal/utils/chart-pagination.js +1502 -0
- package/dist/src/internal/utils/highcharts-provider.js +2 -0
- package/dist/src/nile-chart/nile-chart-config.d.ts +2 -1
- package/dist/src/nile-chart/nile-chart.css.js +2 -1
- package/dist/src/nile-kpi-chart/index.d.ts +1 -1
- package/dist/src/nile-kpi-chart/nile-kpi-chart.css.d.ts +1 -1
- package/dist/src/nile-kpi-chart/nile-kpi-chart.css.js +87 -33
- package/dist/src/nile-kpi-chart/nile-kpi-chart.d.ts +10 -5
- package/dist/src/nile-kpi-chart/nile-kpi-chart.js +105 -19
- package/dist/src/nile-kpi-chart/nile-kpi-chart.test.d.ts +1 -0
- package/dist/src/nile-kpi-chart/nile-kpi-chart.test.js +373 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { registerNileChartEvents } from './chart-events.js';
|
|
9
9
|
import { applyHighchartsCompat } from './highcharts-compat.js';
|
|
10
|
+
import { registerNileChartPagination } from './chart-pagination.js';
|
|
10
11
|
let _Highcharts;
|
|
11
12
|
let _initPromise = null;
|
|
12
13
|
// Gridline strength per theme (the gridline colour below is a token mixed at this strength).
|
|
@@ -226,6 +227,7 @@ async function init() {
|
|
|
226
227
|
});
|
|
227
228
|
registerNileChartEvents(_Highcharts);
|
|
228
229
|
applyHighchartsCompat(_Highcharts);
|
|
230
|
+
registerNileChartPagination(_Highcharts);
|
|
229
231
|
return _Highcharts;
|
|
230
232
|
}
|
|
231
233
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ChartPaginationField } from '../internal/types/chart-pagination-config.type.js';
|
|
1
2
|
import type { ChartConfigType } from '../internal/types/chart-config.type.js';
|
|
2
3
|
export type ChartType = ChartConfigType['type'];
|
|
3
4
|
import type { BarChartSeriesData } from '../nile-bar-chart/nile-bar-chart.js';
|
|
@@ -90,7 +91,7 @@ export interface NileAiConfig {
|
|
|
90
91
|
placeholder?: string;
|
|
91
92
|
welcomeMessage?: string;
|
|
92
93
|
}
|
|
93
|
-
export interface NileChartConfigBase extends HighchartsPassthroughConfig {
|
|
94
|
+
export interface NileChartConfigBase extends HighchartsPassthroughConfig, ChartPaginationField {
|
|
94
95
|
chartTitle?: string;
|
|
95
96
|
chartSubtitle?: string;
|
|
96
97
|
/** Info text shown on hover/focus of an icon beside the header title. Empty → no icon (needs a title). */
|
|
@@ -1125,7 +1125,8 @@ export const styles = css `
|
|
|
1125
1125
|
font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
|
|
1126
1126
|
font-size: var(--nile-type-scale-4, var(--ng-font-size-text-md));
|
|
1127
1127
|
font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));
|
|
1128
|
-
|
|
1128
|
+
/* room for the inline badge's padding and border, which overflow: hidden would clip */
|
|
1129
|
+
line-height: 1.75;
|
|
1129
1130
|
color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));
|
|
1130
1131
|
}
|
|
1131
1132
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NileKpiChart } from './nile-kpi-chart.js';
|
|
2
|
-
export type { ChartKpiSeparatedPayload, KpiConfig, NileKpiConfigInputType, TrendDirection, KpiVariant, } from './nile-kpi-chart.js';
|
|
2
|
+
export type { ChartKpiSeparatedPayload, KpiConfig, NileKpiConfigInputType, TrendDirection, KpiVariant, KpiTitleOverflow, } from './nile-kpi-chart.js';
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Global tooltip styles — injected once into document.head so the tooltip
|
|
3
3
|
* element on document.body is styled independently of the shadow DOM.
|
|
4
4
|
*/
|
|
5
|
-
export declare const tooltipCss = "\n .nile-kpi-tooltip {\n position: fixed;\n display: none;\n transform: translate(-50%, calc(-100% - 10px));\n background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));\n color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));\n font-family: var(--nile-font-family-serif, var(--ng-font-family-body));\n font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));\n font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));\n line-height: 1.4;\n padding: var(--nile-spacing-xs, var(--ng-spacing-xs)) var(--nile-spacing-md, var(--ng-spacing-md));\n border-radius: var(--nile-radius-radius-xl, var(--ng-radius-sm));\n border: var(--nile-border-width-1, var(--ng-stroke-width-1)) solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));\n pointer-events: none;\n white-space: normal;\n max-width: 260px;\n word-break: break-word;\n z-index: 2;\n box-shadow: var(--nile-box-shadow-3, var(--ng-shadow-sm));\n }\n\n .nile-kpi-tooltip::after {\n content: '';\n position: absolute;\n top: 100%;\n left: 50
|
|
5
|
+
export declare const tooltipCss = "\n .nile-kpi-tooltip {\n position: fixed;\n display: none;\n transform: translate(-50%, calc(-100% - 10px));\n background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));\n color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));\n font-family: var(--nile-font-family-serif, var(--ng-font-family-body));\n font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));\n font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));\n line-height: 1.4;\n padding: var(--nile-spacing-xs, var(--ng-spacing-xs)) var(--nile-spacing-md, var(--ng-spacing-md));\n border-radius: var(--nile-radius-radius-xl, var(--ng-radius-sm));\n border: var(--nile-border-width-1, var(--ng-stroke-width-1)) solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));\n pointer-events: none;\n white-space: normal;\n /* sizes to its text so it can't shrink to a one-character column near the window edge */\n width: max-content;\n /* border-box: max-width caps the total width, padding and border included */\n box-sizing: border-box;\n max-width: min(260px, calc(100vw - 16px));\n word-break: break-word;\n z-index: 2;\n box-shadow: var(--nile-box-shadow-3, var(--ng-shadow-sm));\n }\n\n /* _showTip() sets --nile-kpi-tip-arrow-x so the arrow keeps pointing at the data point */\n .nile-kpi-tooltip::after {\n content: '';\n position: absolute;\n top: 100%;\n left: var(--nile-kpi-tip-arrow-x, 50%);\n transform: translateX(-50%);\n border: var(--nile-border-size-5, 5px) solid transparent;\n border-top-color: var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));\n }\n\n /* No room above the point: sit below it, arrow on top. */\n .nile-kpi-tooltip[data-placement='bottom'] {\n transform: translate(-50%, 10px);\n }\n .nile-kpi-tooltip[data-placement='bottom']::after {\n top: auto;\n bottom: 100%;\n border-top-color: transparent;\n border-bottom-color: var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));\n }\n .nile-kpi-marker {\n position: fixed;\n display: none;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n z-index: 1;\n }\n";
|
|
6
6
|
export declare const styles: import("lit").CSSResult;
|
|
@@ -19,21 +19,37 @@ export const tooltipCss = `
|
|
|
19
19
|
border: var(--nile-border-width-1, var(--ng-stroke-width-1)) solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
|
|
20
20
|
pointer-events: none;
|
|
21
21
|
white-space: normal;
|
|
22
|
-
|
|
22
|
+
/* sizes to its text so it can't shrink to a one-character column near the window edge */
|
|
23
|
+
width: max-content;
|
|
24
|
+
/* border-box: max-width caps the total width, padding and border included */
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
max-width: min(260px, calc(100vw - 16px));
|
|
23
27
|
word-break: break-word;
|
|
24
28
|
z-index: 2;
|
|
25
29
|
box-shadow: var(--nile-box-shadow-3, var(--ng-shadow-sm));
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
/* _showTip() sets --nile-kpi-tip-arrow-x so the arrow keeps pointing at the data point */
|
|
28
33
|
.nile-kpi-tooltip::after {
|
|
29
34
|
content: '';
|
|
30
35
|
position: absolute;
|
|
31
36
|
top: 100%;
|
|
32
|
-
left: 50
|
|
37
|
+
left: var(--nile-kpi-tip-arrow-x, 50%);
|
|
33
38
|
transform: translateX(-50%);
|
|
34
39
|
border: var(--nile-border-size-5, 5px) solid transparent;
|
|
35
40
|
border-top-color: var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
|
|
36
41
|
}
|
|
42
|
+
|
|
43
|
+
/* No room above the point: sit below it, arrow on top. */
|
|
44
|
+
.nile-kpi-tooltip[data-placement='bottom'] {
|
|
45
|
+
transform: translate(-50%, 10px);
|
|
46
|
+
}
|
|
47
|
+
.nile-kpi-tooltip[data-placement='bottom']::after {
|
|
48
|
+
top: auto;
|
|
49
|
+
bottom: 100%;
|
|
50
|
+
border-top-color: transparent;
|
|
51
|
+
border-bottom-color: var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
|
|
52
|
+
}
|
|
37
53
|
.nile-kpi-marker {
|
|
38
54
|
position: fixed;
|
|
39
55
|
display: none;
|
|
@@ -172,6 +188,29 @@ export const styles = css `
|
|
|
172
188
|
flex-shrink: 0;
|
|
173
189
|
}
|
|
174
190
|
|
|
191
|
+
/* The 3-line clamp is on the inner span, not the <p>, so the <p>'s display stays under the card's visibility rules */
|
|
192
|
+
:host([variant='compact']) .kpi-label {
|
|
193
|
+
white-space: normal;
|
|
194
|
+
text-overflow: clip;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
:host([variant='compact']) .kpi-label-text {
|
|
198
|
+
display: -webkit-box;
|
|
199
|
+
-webkit-box-orient: vertical;
|
|
200
|
+
/* _fitDescription lowers --kpi-title-lines when the title would push the value out of the card */
|
|
201
|
+
-webkit-line-clamp: var(--kpi-title-lines, 3);
|
|
202
|
+
line-clamp: var(--kpi-title-lines, 3);
|
|
203
|
+
overflow: hidden;
|
|
204
|
+
text-overflow: ellipsis;
|
|
205
|
+
overflow-wrap: normal;
|
|
206
|
+
word-break: normal;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
:host([variant='compact'][title-overflow='break']) .kpi-label,
|
|
210
|
+
:host([variant='compact'][title-overflow='break']) .kpi-label-text {
|
|
211
|
+
overflow-wrap: anywhere;
|
|
212
|
+
}
|
|
213
|
+
|
|
175
214
|
.kpi-value-row {
|
|
176
215
|
display: flex;
|
|
177
216
|
align-items: center;
|
|
@@ -394,6 +433,11 @@ export const styles = css `
|
|
|
394
433
|
flex-shrink: 0;
|
|
395
434
|
}
|
|
396
435
|
|
|
436
|
+
/* set when the title leaves the compact sparkline less than its minimum height */
|
|
437
|
+
:host([variant='compact'][data-hide-spark]) .kpi-sparkline {
|
|
438
|
+
display: none;
|
|
439
|
+
}
|
|
440
|
+
|
|
397
441
|
/* Set by the component when the card is too short to show the description whole. */
|
|
398
442
|
:host([data-hide-desc][data-hide-desc]) .kpi-description,
|
|
399
443
|
:host([data-hide-desc][data-hide-desc]) .kpi-forecast {
|
|
@@ -647,10 +691,15 @@ export const styles = css `
|
|
|
647
691
|
display: inline-flex;
|
|
648
692
|
}
|
|
649
693
|
|
|
650
|
-
/*
|
|
651
|
-
|
|
652
|
-
:host([has-header-
|
|
653
|
-
|
|
694
|
+
/* the title stays visible beside header controls even where the short-card rules hide it */
|
|
695
|
+
:host([variant='compact'][has-header-lead]) .kpi-label,
|
|
696
|
+
:host([variant='compact'][has-header-actions]) .kpi-label {
|
|
697
|
+
display: block;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/* with lead/actions present the title wraps instead of truncating, so it never runs under the controls */
|
|
701
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-label,
|
|
702
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-label {
|
|
654
703
|
white-space: normal;
|
|
655
704
|
overflow: visible;
|
|
656
705
|
text-overflow: clip;
|
|
@@ -659,8 +708,8 @@ export const styles = css `
|
|
|
659
708
|
word-break: normal;
|
|
660
709
|
}
|
|
661
710
|
|
|
662
|
-
:host([has-header-lead]) .kpi-label-text,
|
|
663
|
-
:host([has-header-actions]) .kpi-label-text {
|
|
711
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-label-text,
|
|
712
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-label-text {
|
|
664
713
|
/* clip (not hidden) so the text stays part of the line-clamp's flow */
|
|
665
714
|
overflow: clip;
|
|
666
715
|
text-overflow: ellipsis;
|
|
@@ -691,8 +740,8 @@ export const styles = css `
|
|
|
691
740
|
|
|
692
741
|
/* A wrapping title is capped by card height so a long one can't push the value and
|
|
693
742
|
sparkline out of the card; the rest is cut with an ellipsis (full text is in the tooltip). */
|
|
694
|
-
:host([has-header-lead]) .kpi-label,
|
|
695
|
-
:host([has-header-actions]) .kpi-label {
|
|
743
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-label,
|
|
744
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-label {
|
|
696
745
|
display: -webkit-box;
|
|
697
746
|
-webkit-box-orient: vertical;
|
|
698
747
|
-webkit-line-clamp: 4;
|
|
@@ -700,35 +749,47 @@ export const styles = css `
|
|
|
700
749
|
}
|
|
701
750
|
|
|
702
751
|
@container (max-height: 230px) {
|
|
703
|
-
:host([has-header-lead]) .kpi-label,
|
|
704
|
-
:host([has-header-actions]) .kpi-label {
|
|
752
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-label,
|
|
753
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-label {
|
|
705
754
|
-webkit-line-clamp: 3;
|
|
706
755
|
}
|
|
707
756
|
}
|
|
708
757
|
|
|
709
758
|
/* Very short cards: two lines. Anything taller keeps three, and the sparkline gives way instead. */
|
|
710
759
|
@container (max-height: 125px) {
|
|
711
|
-
:host([has-header-lead]) .kpi-label,
|
|
712
|
-
:host([has-header-actions]) .kpi-label {
|
|
760
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-label,
|
|
761
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-label {
|
|
713
762
|
-webkit-line-clamp: 2;
|
|
714
763
|
}
|
|
715
764
|
}
|
|
716
765
|
|
|
717
|
-
/* With header controls the trend + mover + actions float at the top-right and the title
|
|
718
|
-
wraps AROUND them: first lines are shortened by a spacer, later lines use the full width. */
|
|
719
766
|
.kpi-header-controls {
|
|
720
767
|
display: contents;
|
|
721
768
|
}
|
|
722
769
|
|
|
723
|
-
|
|
724
|
-
:host([has-header-
|
|
770
|
+
/* title and controls sit side by side, so the title's first line starts level with the controls */
|
|
771
|
+
:host([variant='compact'][has-header-lead]) .kpi-header,
|
|
772
|
+
:host([variant='compact'][has-header-actions]) .kpi-header {
|
|
773
|
+
display: flex;
|
|
774
|
+
align-items: flex-start;
|
|
775
|
+
gap: var(--nile-spacing-xs, var(--ng-spacing-xs));
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
:host([variant='compact'][has-header-lead]) .kpi-header .kpi-tip:not([data-kpi-tip='trend']),
|
|
779
|
+
:host([variant='compact'][has-header-actions]) .kpi-header .kpi-tip:not([data-kpi-tip='trend']) {
|
|
780
|
+
display: block;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/* the trend, mover and actions float top-right and the title wraps around them via a spacer on its first lines */
|
|
784
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-header,
|
|
785
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-header {
|
|
725
786
|
display: block;
|
|
726
787
|
position: relative;
|
|
727
788
|
min-height: var(--kpi-controls-h, 0px);
|
|
728
789
|
}
|
|
729
790
|
|
|
730
|
-
:host([has-header-lead]) .kpi-header-controls,
|
|
731
|
-
:host([has-header-actions]) .kpi-header-controls {
|
|
791
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-header-controls,
|
|
792
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-header-controls {
|
|
732
793
|
display: flex;
|
|
733
794
|
position: absolute;
|
|
734
795
|
top: 0;
|
|
@@ -737,23 +798,23 @@ export const styles = css `
|
|
|
737
798
|
gap: var(--nile-spacing-xs, var(--ng-spacing-xs));
|
|
738
799
|
}
|
|
739
800
|
|
|
740
|
-
:host([has-header-lead]) .kpi-header .kpi-tip:not([data-kpi-tip='trend']),
|
|
741
|
-
:host([has-header-actions]) .kpi-header .kpi-tip:not([data-kpi-tip='trend']) {
|
|
801
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-header .kpi-tip:not([data-kpi-tip='trend']),
|
|
802
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-header .kpi-tip:not([data-kpi-tip='trend']) {
|
|
742
803
|
display: block;
|
|
743
804
|
min-width: 0;
|
|
744
805
|
width: 100%;
|
|
745
806
|
}
|
|
746
807
|
|
|
747
|
-
:host([has-header-lead]) .kpi-header .kpi-label-text::before,
|
|
748
|
-
:host([has-header-actions]) .kpi-header .kpi-label-text::before {
|
|
808
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-header .kpi-label-text::before,
|
|
809
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-header .kpi-label-text::before {
|
|
749
810
|
content: '';
|
|
750
811
|
float: right;
|
|
751
812
|
width: calc(var(--kpi-controls-w, 0px) + var(--nile-spacing-xs, var(--ng-spacing-xs)));
|
|
752
813
|
height: var(--kpi-controls-h, 0px);
|
|
753
814
|
}
|
|
754
815
|
|
|
755
|
-
:host([has-header-lead]) .kpi-header .kpi-label-text,
|
|
756
|
-
:host([has-header-actions]) .kpi-header .kpi-label-text {
|
|
816
|
+
:host([has-header-lead]:not([variant='compact'])) .kpi-header .kpi-label-text,
|
|
817
|
+
:host([has-header-actions]:not([variant='compact'])) .kpi-header .kpi-label-text {
|
|
757
818
|
display: block;
|
|
758
819
|
}
|
|
759
820
|
|
|
@@ -932,13 +993,6 @@ export const styles = css `
|
|
|
932
993
|
display: inline-flex;
|
|
933
994
|
}
|
|
934
995
|
|
|
935
|
-
/* Compact titles that wrap beside header controls keep their line cap (the block
|
|
936
|
-
rule above would otherwise cancel -webkit-box). */
|
|
937
|
-
:host([variant='compact'][has-header-lead]) .kpi-label,
|
|
938
|
-
:host([variant='compact'][has-header-actions]) .kpi-label {
|
|
939
|
-
display: -webkit-box;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
996
|
/* 1. The sparkline stays at every size; it only goes when the card is too short for anything else. */
|
|
943
997
|
@container (max-height: 72px) {
|
|
944
998
|
:host([variant='compact']) .kpi-sparkline {
|
|
@@ -8,6 +8,8 @@ export type SparklineType = 'area' | 'line' | 'column' | 'bar' | 'spline' | 'are
|
|
|
8
8
|
export type KpiValueFormat = 'auto' | 'K' | 'M' | 'B' | 'T' | 'none';
|
|
9
9
|
export type KpiNumberSystem = 'indian' | 'international';
|
|
10
10
|
export type KpiInfoPlacement = 'top-right' | 'center-right' | 'bottom-right' | 'top-left' | 'center-left' | 'bottom-left';
|
|
11
|
+
/** How compact titles handle an oversized word: `'ellipsis'` cuts it with `…`, `'break'` splits it. */
|
|
12
|
+
export type KpiTitleOverflow = 'ellipsis' | 'break';
|
|
11
13
|
/** `chart` slice for `<nile-kpi-chart>.config` (discriminated by `type: 'kpi'`). */
|
|
12
14
|
export interface ChartKpiSeparatedPayload {
|
|
13
15
|
type: 'kpi';
|
|
@@ -82,6 +84,8 @@ export interface ChartKpiSeparatedPayload {
|
|
|
82
84
|
loadingText?: string;
|
|
83
85
|
/** Whether the hover tooltip is shown on value / sparkline / gauge (default: true). */
|
|
84
86
|
tooltipEnabled?: boolean;
|
|
87
|
+
/** How the compact title handles text that doesn't fit; see `KpiTitleOverflow`. */
|
|
88
|
+
titleOverflow?: KpiTitleOverflow;
|
|
85
89
|
/** Accent bar colour for the 'accent' variant (default: brand blue). */
|
|
86
90
|
accentColor?: string;
|
|
87
91
|
cardBackground?: string;
|
|
@@ -149,6 +153,8 @@ export declare class NileKpiChart extends NileElement {
|
|
|
149
153
|
private sparklineChart;
|
|
150
154
|
private gaugeChart;
|
|
151
155
|
private resizeObserver;
|
|
156
|
+
/** Pending late re-check of the sparkline size (see initSparkline). */
|
|
157
|
+
private _sparkSettleTimer;
|
|
152
158
|
/** Latched once the fit safety-net has fallen back to inline-size (see _reconcileFit). */
|
|
153
159
|
private _fitInlineFallback;
|
|
154
160
|
/** Tooltip element on document.body — outside shadow DOM, never clipped. */
|
|
@@ -264,6 +270,8 @@ export declare class NileKpiChart extends NileElement {
|
|
|
264
270
|
loadingText: string;
|
|
265
271
|
/** Whether the hover tooltip is shown on value / sparkline / gauge. */
|
|
266
272
|
tooltipEnabled: boolean;
|
|
273
|
+
/** How the compact title handles text that doesn't fit; see `KpiTitleOverflow`. */
|
|
274
|
+
titleOverflow: KpiTitleOverflow;
|
|
267
275
|
cardBackground: string;
|
|
268
276
|
cardBorderColor: string;
|
|
269
277
|
cardBorderWidth: string | number;
|
|
@@ -350,9 +358,7 @@ export declare class NileKpiChart extends NileElement {
|
|
|
350
358
|
*/
|
|
351
359
|
private _fitDescription;
|
|
352
360
|
/**
|
|
353
|
-
* True when `el`
|
|
354
|
-
* lines hidden by -webkit-line-clamp without reporting them as overflow, so the clamp is lifted for
|
|
355
|
-
* one synchronous measurement and the full height compared with the clamped height.
|
|
361
|
+
* True when `el` shows less than its full text. Chrome hides -webkit-line-clamp lines without reporting overflow, so the clamp is lifted for one measurement.
|
|
356
362
|
*/
|
|
357
363
|
private _isLabelTruncated;
|
|
358
364
|
private _syncTruncationTips;
|
|
@@ -373,8 +379,7 @@ export declare class NileKpiChart extends NileElement {
|
|
|
373
379
|
/** Mirrors the header slots' content onto the host (`has-header-lead` / `has-header-actions`). */
|
|
374
380
|
private _onHeaderSlotChange;
|
|
375
381
|
/**
|
|
376
|
-
*
|
|
377
|
-
* them (its first lines are shortened by a spacer of this size) and uses the full width below.
|
|
382
|
+
* Sizes the spacer the title wraps around beside floating header controls; compact lays them out side by side and skips it.
|
|
378
383
|
*/
|
|
379
384
|
private _controlsObserved;
|
|
380
385
|
private _syncHeaderControls;
|
|
@@ -23,6 +23,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
23
23
|
this.sparklineChart = null;
|
|
24
24
|
this.gaugeChart = null;
|
|
25
25
|
this.resizeObserver = null;
|
|
26
|
+
/** Pending late re-check of the sparkline size (see initSparkline). */
|
|
27
|
+
this._sparkSettleTimer = null;
|
|
26
28
|
/** Latched once the fit safety-net has fallen back to inline-size (see _reconcileFit). */
|
|
27
29
|
this._fitInlineFallback = false;
|
|
28
30
|
/** Tooltip element on document.body — outside shadow DOM, never clipped. */
|
|
@@ -136,6 +138,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
136
138
|
this.loadingText = 'Loading...';
|
|
137
139
|
/** Whether the hover tooltip is shown on value / sparkline / gauge. */
|
|
138
140
|
this.tooltipEnabled = true;
|
|
141
|
+
/** How the compact title handles text that doesn't fit; see `KpiTitleOverflow`. */
|
|
142
|
+
this.titleOverflow = 'ellipsis';
|
|
139
143
|
// ── Card chrome ──
|
|
140
144
|
this.cardBackground = '';
|
|
141
145
|
this.cardBorderColor = '';
|
|
@@ -252,8 +256,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
252
256
|
this._syncHeaderControls();
|
|
253
257
|
};
|
|
254
258
|
/**
|
|
255
|
-
*
|
|
256
|
-
* them (its first lines are shortened by a spacer of this size) and uses the full width below.
|
|
259
|
+
* Sizes the spacer the title wraps around beside floating header controls; compact lays them out side by side and skips it.
|
|
257
260
|
*/
|
|
258
261
|
this._controlsObserved = null;
|
|
259
262
|
}
|
|
@@ -273,10 +276,27 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
273
276
|
_showTip(text, x, y) {
|
|
274
277
|
if (!this._tipEl || !this.tooltipEnabled)
|
|
275
278
|
return;
|
|
276
|
-
this._tipEl
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
279
|
+
const tip = this._tipEl;
|
|
280
|
+
tip.textContent = text;
|
|
281
|
+
tip.style.left = `${x}px`;
|
|
282
|
+
tip.style.top = `${y}px`;
|
|
283
|
+
tip.removeAttribute('data-placement');
|
|
284
|
+
tip.style.removeProperty('--nile-kpi-tip-arrow-x');
|
|
285
|
+
tip.style.display = 'block';
|
|
286
|
+
// Centred on the point; shifted back inside the window (the arrow follows) and flipped below when there is no room above.
|
|
287
|
+
const margin = 8;
|
|
288
|
+
const gap = 10;
|
|
289
|
+
const vw = document.documentElement.clientWidth;
|
|
290
|
+
const { width, height } = tip.getBoundingClientRect();
|
|
291
|
+
const half = width / 2;
|
|
292
|
+
const left = width + margin * 2 > vw ? vw / 2 : Math.min(Math.max(x, half + margin), vw - half - margin);
|
|
293
|
+
if (left !== x) {
|
|
294
|
+
tip.style.left = `${left}px`;
|
|
295
|
+
const arrowX = Math.min(Math.max(half + (x - left), 12), width - 12);
|
|
296
|
+
tip.style.setProperty('--nile-kpi-tip-arrow-x', `${arrowX}px`);
|
|
297
|
+
}
|
|
298
|
+
if (y - height - gap < margin)
|
|
299
|
+
tip.setAttribute('data-placement', 'bottom');
|
|
280
300
|
}
|
|
281
301
|
_showMarker(x, y, color) {
|
|
282
302
|
if (!this._markerEl || !this.tooltipEnabled)
|
|
@@ -586,6 +606,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
586
606
|
this.loadingText = c.loadingText;
|
|
587
607
|
if (c.tooltipEnabled !== undefined)
|
|
588
608
|
this.tooltipEnabled = c.tooltipEnabled;
|
|
609
|
+
if (c.titleOverflow !== undefined)
|
|
610
|
+
this.titleOverflow = c.titleOverflow;
|
|
589
611
|
if (c.accentColor !== undefined)
|
|
590
612
|
this.accentColor = c.accentColor;
|
|
591
613
|
if (c.cardBackground !== undefined)
|
|
@@ -700,7 +722,12 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
700
722
|
this.initGauge();
|
|
701
723
|
this.setupResizeObserver();
|
|
702
724
|
requestAnimationFrame(() => this._reconcileFit());
|
|
703
|
-
|
|
725
|
+
// Web fonts change how the title wraps, which changes how much room the rest of the card has.
|
|
726
|
+
void document.fonts?.ready.then(() => {
|
|
727
|
+
if (this.variant === 'compact')
|
|
728
|
+
this._fitDescription(true);
|
|
729
|
+
this._syncTruncationTips();
|
|
730
|
+
});
|
|
704
731
|
}
|
|
705
732
|
updated(changedProperties) {
|
|
706
733
|
const hasValue = this.value !== '' && this.value !== null && this.value !== undefined;
|
|
@@ -803,10 +830,12 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
803
830
|
const drawn = chart.container;
|
|
804
831
|
const prevDisplay = drawn.style.display;
|
|
805
832
|
drawn.style.display = 'none';
|
|
806
|
-
|
|
833
|
+
// Layout size, not getBoundingClientRect(): the latter includes transforms, which ResizeObserver can't see change.
|
|
834
|
+
const boxW = this.sparklineContainer.offsetWidth;
|
|
835
|
+
const boxH = this.sparklineContainer.offsetHeight;
|
|
807
836
|
drawn.style.display = prevDisplay;
|
|
808
|
-
const w = Math.max(1,
|
|
809
|
-
const h = Math.max(22,
|
|
837
|
+
const w = Math.max(1, boxW);
|
|
838
|
+
const h = Math.max(22, boxH);
|
|
810
839
|
if (w === chart.chartWidth && h === chart.chartHeight)
|
|
811
840
|
return;
|
|
812
841
|
chart.update({ chart: { width: w, height: h } }, true, false, false);
|
|
@@ -1059,6 +1088,14 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1059
1088
|
this.syncSparklineChartSize();
|
|
1060
1089
|
requestAnimationFrame(() => this.syncSparklineChartSize());
|
|
1061
1090
|
});
|
|
1091
|
+
// Re-check once layout settles: a wrapper that sizes after the chart is built can leave the observer a step behind.
|
|
1092
|
+
const chart = this.sparklineChart;
|
|
1093
|
+
const resync = () => {
|
|
1094
|
+
if (this.sparklineChart === chart && this.isConnected)
|
|
1095
|
+
this.syncSparklineChartSize();
|
|
1096
|
+
};
|
|
1097
|
+
void document.fonts?.ready.then(resync);
|
|
1098
|
+
this._sparkSettleTimer = window.setTimeout(resync, 250);
|
|
1062
1099
|
this.sparklineContainer.addEventListener('mousemove', this._onSparklineMouseMove);
|
|
1063
1100
|
this.sparklineContainer.addEventListener('mouseleave', this._onSparklineMouseLeave);
|
|
1064
1101
|
this.emit('nile-chart-ready', { chart: this.sparklineChart });
|
|
@@ -1080,6 +1117,10 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1080
1117
|
this.emit('nile-chart-ready', { chart: this.gaugeChart });
|
|
1081
1118
|
}
|
|
1082
1119
|
destroySparkline() {
|
|
1120
|
+
if (this._sparkSettleTimer !== null) {
|
|
1121
|
+
clearTimeout(this._sparkSettleTimer);
|
|
1122
|
+
this._sparkSettleTimer = null;
|
|
1123
|
+
}
|
|
1083
1124
|
if (this.sparklineContainer) {
|
|
1084
1125
|
this.sparklineContainer.removeEventListener('mousemove', this._onSparklineMouseMove);
|
|
1085
1126
|
this.sparklineContainer.removeEventListener('mouseleave', this._onSparklineMouseLeave);
|
|
@@ -1125,13 +1166,33 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1125
1166
|
return;
|
|
1126
1167
|
this._fitSize = size;
|
|
1127
1168
|
this.removeAttribute('data-hide-desc');
|
|
1169
|
+
this.removeAttribute('data-hide-spark');
|
|
1170
|
+
this.style.removeProperty('--kpi-title-lines');
|
|
1128
1171
|
if (kpi.scrollHeight > kpi.clientHeight + 1)
|
|
1129
1172
|
this.setAttribute('data-hide-desc', '');
|
|
1173
|
+
// Compact is all-or-nothing: hide the sparkline whole when the title leaves it less than its minimum height.
|
|
1174
|
+
if (this.variant === 'compact') {
|
|
1175
|
+
const spark = this.shadowRoot?.querySelector('.kpi-sparkline');
|
|
1176
|
+
if (spark &&
|
|
1177
|
+
getComputedStyle(spark).display !== 'none' &&
|
|
1178
|
+
spark.getBoundingClientRect().bottom > kpi.getBoundingClientRect().bottom + 4) {
|
|
1179
|
+
this.setAttribute('data-hide-spark', '');
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
// Give title lines back (3 -> 2 -> 1) only while the value still overflows the card.
|
|
1183
|
+
const text = this.variant === 'compact' ? this.shadowRoot?.querySelector('.kpi-label-text') : null;
|
|
1184
|
+
if (text && text.getBoundingClientRect().height > 0) {
|
|
1185
|
+
const lineHeight = parseFloat(getComputedStyle(text).lineHeight) || 0;
|
|
1186
|
+
const showsMoreThan = (n) => text.getBoundingClientRect().height > lineHeight * (n + 0.5);
|
|
1187
|
+
for (let lines = 2; lines >= 1; lines--) {
|
|
1188
|
+
if (!lineHeight || !showsMoreThan(lines) || kpi.scrollHeight <= kpi.clientHeight + 1)
|
|
1189
|
+
break;
|
|
1190
|
+
this.style.setProperty('--kpi-title-lines', String(lines));
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1130
1193
|
}
|
|
1131
1194
|
/**
|
|
1132
|
-
* True when `el`
|
|
1133
|
-
* lines hidden by -webkit-line-clamp without reporting them as overflow, so the clamp is lifted for
|
|
1134
|
-
* one synchronous measurement and the full height compared with the clamped height.
|
|
1195
|
+
* True when `el` shows less than its full text. Chrome hides -webkit-line-clamp lines without reporting overflow, so the clamp is lifted for one measurement.
|
|
1135
1196
|
*/
|
|
1136
1197
|
_isLabelTruncated(el, isLabel) {
|
|
1137
1198
|
if (el.scrollWidth > el.clientWidth)
|
|
@@ -1141,14 +1202,34 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1141
1202
|
return true;
|
|
1142
1203
|
if (!isLabel)
|
|
1143
1204
|
return el.scrollHeight > el.clientHeight + 1;
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1205
|
+
if (this.variant !== 'compact') {
|
|
1206
|
+
// Non-compact: the clamp is on the <p> itself.
|
|
1207
|
+
const clamped = el.clientHeight;
|
|
1208
|
+
const prev = el.style.getPropertyValue('-webkit-line-clamp');
|
|
1209
|
+
el.style.setProperty('-webkit-line-clamp', 'unset');
|
|
1210
|
+
const full = el.scrollHeight;
|
|
1211
|
+
if (prev)
|
|
1212
|
+
el.style.setProperty('-webkit-line-clamp', prev);
|
|
1213
|
+
else
|
|
1214
|
+
el.style.removeProperty('-webkit-line-clamp');
|
|
1215
|
+
return full > clamped + 1;
|
|
1216
|
+
}
|
|
1217
|
+
if (!text)
|
|
1218
|
+
return false;
|
|
1219
|
+
const clamped = text.clientHeight;
|
|
1220
|
+
const prev = text.style.getPropertyValue('-webkit-line-clamp');
|
|
1221
|
+
const prevStd = text.style.getPropertyValue('line-clamp');
|
|
1222
|
+
text.style.setProperty('-webkit-line-clamp', 'unset');
|
|
1223
|
+
text.style.setProperty('line-clamp', 'unset');
|
|
1224
|
+
const full = text.scrollHeight;
|
|
1148
1225
|
if (prev)
|
|
1149
|
-
|
|
1226
|
+
text.style.setProperty('-webkit-line-clamp', prev);
|
|
1227
|
+
else
|
|
1228
|
+
text.style.removeProperty('-webkit-line-clamp');
|
|
1229
|
+
if (prevStd)
|
|
1230
|
+
text.style.setProperty('line-clamp', prevStd);
|
|
1150
1231
|
else
|
|
1151
|
-
|
|
1232
|
+
text.style.removeProperty('line-clamp');
|
|
1152
1233
|
return full > clamped + 1;
|
|
1153
1234
|
}
|
|
1154
1235
|
_syncTruncationTips() {
|
|
@@ -1263,6 +1344,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1263
1344
|
`;
|
|
1264
1345
|
}
|
|
1265
1346
|
_syncHeaderControls() {
|
|
1347
|
+
if (this.variant === 'compact')
|
|
1348
|
+
return;
|
|
1266
1349
|
const header = this.shadowRoot?.querySelector('.kpi-header');
|
|
1267
1350
|
const controls = header?.querySelector('.kpi-header-controls');
|
|
1268
1351
|
if (!header || !controls)
|
|
@@ -1534,6 +1617,9 @@ __decorate([
|
|
|
1534
1617
|
__decorate([
|
|
1535
1618
|
property({ type: Boolean, attribute: 'tooltip-enabled' })
|
|
1536
1619
|
], NileKpiChart.prototype, "tooltipEnabled", void 0);
|
|
1620
|
+
__decorate([
|
|
1621
|
+
property({ type: String, attribute: 'title-overflow', reflect: true })
|
|
1622
|
+
], NileKpiChart.prototype, "titleOverflow", void 0);
|
|
1537
1623
|
__decorate([
|
|
1538
1624
|
property({ type: String, attribute: 'card-background' })
|
|
1539
1625
|
], NileKpiChart.prototype, "cardBackground", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './nile-kpi-chart';
|