@juspay/svelte-ui-components 2.109.0 → 2.111.0
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.
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
><path d="M22 7L13.5 15.5L8.5 10.5L2 17" /><path d="M16 7H22V13" /></svg
|
|
45
45
|
>
|
|
46
46
|
</span>
|
|
47
|
+
{:else if !hideArrow}
|
|
48
|
+
<!-- Neutral/no-change glyph (design-system "— 0%" treatment): an em dash in
|
|
49
|
+
place of the trend arrow, so a flat delta still reads as a stated state. -->
|
|
50
|
+
<span class="delta-indicator-dash" aria-hidden="true">—</span>
|
|
47
51
|
{/if}
|
|
48
52
|
<span class="delta-indicator-text">{text}</span>
|
|
49
53
|
</span>
|
|
@@ -85,6 +89,11 @@
|
|
|
85
89
|
flex-shrink: 0;
|
|
86
90
|
}
|
|
87
91
|
|
|
92
|
+
.delta-indicator-dash {
|
|
93
|
+
color: inherit;
|
|
94
|
+
flex-shrink: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
88
97
|
.delta-indicator-arrow svg {
|
|
89
98
|
width: 100%;
|
|
90
99
|
height: 100%;
|
|
@@ -204,11 +204,25 @@
|
|
|
204
204
|
series.map((s, si) => {
|
|
205
205
|
const color = s.color ?? getColor(si);
|
|
206
206
|
const points: Point[] = s.data.map((d) => ({ x: xScale(d.x), y: yScale(d.y) }));
|
|
207
|
+
const finitePoints = points.filter(
|
|
208
|
+
(point) => Number.isFinite(point.x) && Number.isFinite(point.y)
|
|
209
|
+
);
|
|
210
|
+
// Design-system contract: a series with a single data point renders as a
|
|
211
|
+
// flat line at that y across the full plot width (a lone dot reads as a
|
|
212
|
+
// glitch), while the point marker itself still renders at its true x.
|
|
213
|
+
const isSinglePoint = finitePoints.length === 1;
|
|
214
|
+
const pathPoints: Point[] = isSinglePoint
|
|
215
|
+
? [
|
|
216
|
+
{ x: 0, y: finitePoints[0].y },
|
|
217
|
+
{ x: dims.innerWidth, y: finitePoints[0].y }
|
|
218
|
+
]
|
|
219
|
+
: points;
|
|
207
220
|
return {
|
|
208
221
|
color,
|
|
209
222
|
points,
|
|
210
|
-
|
|
211
|
-
|
|
223
|
+
dash: s.dash === true ? '6 4' : typeof s.dash === 'string' ? s.dash : null,
|
|
224
|
+
path: linePath(pathPoints, isSinglePoint ? 'linear' : curve),
|
|
225
|
+
areaD: areaPath(pathPoints, dims.innerHeight, isSinglePoint ? 'linear' : curve),
|
|
212
226
|
hidden: hiddenSeries.has(si)
|
|
213
227
|
};
|
|
214
228
|
})
|
|
@@ -639,6 +653,7 @@
|
|
|
639
653
|
d={line.path}
|
|
640
654
|
stroke={line.color}
|
|
641
655
|
stroke-width={strokeWidth}
|
|
656
|
+
stroke-dasharray={line.dash}
|
|
642
657
|
fill="none"
|
|
643
658
|
/>
|
|
644
659
|
{#if line.points.length === 1 && !showDots && Number.isFinite(line.points[0].x) && Number.isFinite(line.points[0].y)}
|
|
@@ -10,6 +10,12 @@ export type LineChartSeries = {
|
|
|
10
10
|
name: string;
|
|
11
11
|
data: LineChartDataPoint[];
|
|
12
12
|
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Dashed stroke for this series (e.g. a comparison/previous-period line).
|
|
15
|
+
* `true` uses the default `'6 4'` pattern; a string is passed through as a
|
|
16
|
+
* custom SVG `stroke-dasharray`. Omit for a solid line.
|
|
17
|
+
*/
|
|
18
|
+
dash?: boolean | string;
|
|
13
19
|
};
|
|
14
20
|
export type LineChartTooltipContext = {
|
|
15
21
|
x: number;
|
|
@@ -177,12 +177,29 @@
|
|
|
177
177
|
>
|
|
178
178
|
{row.value}
|
|
179
179
|
</div>
|
|
180
|
+
{#if typeof row.comparisonValue === 'string' && row.comparisonValue.length > 0}
|
|
181
|
+
<div
|
|
182
|
+
class="statcard-comparison-value"
|
|
183
|
+
data-pw={typeof testId === 'string' ? `${testId}-comparison-${rowIndex}` : null}
|
|
184
|
+
>
|
|
185
|
+
/ {row.comparisonValue}
|
|
186
|
+
</div>
|
|
187
|
+
{/if}
|
|
180
188
|
{#if typeof row.change === 'number'}
|
|
181
189
|
<DeltaIndicator
|
|
182
190
|
value={row.change}
|
|
183
191
|
invertColors={row.invertChangeColors ?? false}
|
|
184
192
|
testId={testId ? `${testId}-delta-${rowIndex}` : null}
|
|
185
193
|
/>
|
|
194
|
+
{:else if row.change === null}
|
|
195
|
+
<!-- Comparison expected but not computable — a stated "N/A" beats
|
|
196
|
+
silently rendering nothing (design-system trend states). -->
|
|
197
|
+
<div
|
|
198
|
+
class="statcard-delta statcard-delta-na"
|
|
199
|
+
data-pw={typeof testId === 'string' ? `${testId}-delta-na-${rowIndex}` : null}
|
|
200
|
+
>
|
|
201
|
+
N/A
|
|
202
|
+
</div>
|
|
186
203
|
{/if}
|
|
187
204
|
{#if typeof row.additionalContent === 'string' && row.additionalContent.length > 0}
|
|
188
205
|
<div class="statcard-row-additional">{row.additionalContent}</div>
|
|
@@ -392,6 +409,20 @@
|
|
|
392
409
|
color: var(--statcard-delta-negative-color, #dc2626);
|
|
393
410
|
}
|
|
394
411
|
|
|
412
|
+
.statcard-delta-na {
|
|
413
|
+
color: var(--statcard-delta-na-color, var(--statcard-delta-color, #6b7280));
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/* Inline comparison denominator ("₹60k / ₹10L") — a muted, slightly smaller
|
|
417
|
+
companion to the metric value, baseline-aligned by the value row. */
|
|
418
|
+
.statcard-comparison-value {
|
|
419
|
+
font-size: var(--statcard-comparison-font-size, 16px);
|
|
420
|
+
font-weight: var(--statcard-comparison-font-weight, 700);
|
|
421
|
+
color: var(--statcard-comparison-color, #c7c7c7);
|
|
422
|
+
line-height: var(--statcard-comparison-line-height, 1.4);
|
|
423
|
+
white-space: nowrap;
|
|
424
|
+
}
|
|
425
|
+
|
|
395
426
|
.statcard-subtitle {
|
|
396
427
|
order: var(--statcard-subtitle-order, 0);
|
|
397
428
|
font-size: var(--statcard-subtitle-font-size, 12px);
|
|
@@ -30,8 +30,17 @@ export type StatCardRow = {
|
|
|
30
30
|
value: string;
|
|
31
31
|
/** Optional row-level heading label. */
|
|
32
32
|
heading?: string;
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Comparison-period value rendered inline after the metric as "/ <value>"
|
|
35
|
+
* (e.g. "₹60k / ₹10L") in a muted denominator style. Omit to hide.
|
|
36
|
+
*/
|
|
37
|
+
comparisonValue?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Numeric change for the delta indicator. A number renders the delta
|
|
40
|
+
* (0 renders the neutral "— 0%" treatment); `null` means a comparison was
|
|
41
|
+
* expected but not computable and renders "N/A"; `undefined` renders nothing.
|
|
42
|
+
*/
|
|
43
|
+
change?: number | null;
|
|
35
44
|
/** Invert delta colors for lower-is-better metrics on this row. */
|
|
36
45
|
invertChangeColors?: boolean;
|
|
37
46
|
/** Additional descriptive text rendered after the delta. */
|