@juspay/svelte-ui-components 2.97.0 → 2.97.2
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.
|
@@ -68,7 +68,11 @@
|
|
|
68
68
|
box-shadow: var(--choicebox-focus-ring, 0 0 0 3px rgba(33, 150, 243, 0.3));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
/* Exclude the selected state from hover: without :not(.selected) this rule
|
|
72
|
+
(specificity 0,3,0) outranks .choicebox.selected (0,2,0), so hovering a
|
|
73
|
+
selected card repaints it with the neutral hover border/fill until the
|
|
74
|
+
cursor leaves. Excluding selected lets .choicebox.selected show through. */
|
|
75
|
+
.choicebox:not(.disabled):not(.selected):hover {
|
|
72
76
|
border-color: var(--choicebox-hover-border-color, #9e9e9e);
|
|
73
77
|
background: var(--choicebox-hover-background, var(--choicebox-background, #ffffff));
|
|
74
78
|
}
|
|
@@ -95,7 +95,35 @@
|
|
|
95
95
|
return Math.max(0, Math.min(chartWidth * 0.25, wanted));
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
// First-column labels render to the LEFT of their node, anchored `end` into the
|
|
99
|
+
// left margin. The bare 40px margin is nowhere near enough for real source labels
|
|
100
|
+
// ("SESSIONS", "Source A", "START") — they truncate to a few characters and, once
|
|
101
|
+
// the room falls below an ellipsis, vanish entirely. Mirror the sink gutter:
|
|
102
|
+
// reserve a capped left gutter sized from the source-node labels (sources are what
|
|
103
|
+
// land in the first column) and shift the diagram right by it.
|
|
104
|
+
let firstColumnLabelGutter = $derived.by(() => {
|
|
105
|
+
if (!showLabels || nodes.length === 0 || chartWidth <= 0) {
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
const targetIds = new Set(links.map((link) => link.target));
|
|
109
|
+
const sourceLabels = nodes
|
|
110
|
+
.filter((node) => !targetIds.has(node.id))
|
|
111
|
+
.map((node) => node.label ?? node.id);
|
|
112
|
+
if (sourceLabels.length === 0) {
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
115
|
+
const longestPx =
|
|
116
|
+
Math.max(...sourceLabels.map((label) => measureText(label, labelFont).width)) +
|
|
117
|
+
(showValues ? measureText(' (999,999)', labelFont).width : 0);
|
|
118
|
+
const wanted = longestPx + 10 + dataLabelOffsetX;
|
|
119
|
+
// Same 25% cap and 0 floor as the sink gutter so the two together can never
|
|
120
|
+
// starve the diagram, and a negative dataLabelOffsetX can't push past the margin.
|
|
121
|
+
return Math.max(0, Math.min(chartWidth * 0.25, wanted));
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
let plotWidth = $derived(
|
|
125
|
+
Math.max(0, chartWidth - MARGIN * 2 - firstColumnLabelGutter - lastColumnLabelGutter)
|
|
126
|
+
);
|
|
99
127
|
let layout = $derived(
|
|
100
128
|
computeSankeyLayout(
|
|
101
129
|
nodes,
|
|
@@ -151,12 +179,13 @@
|
|
|
151
179
|
// node.x + nodeWidth + 6 + dataLabelOffsetX, so the room before the next
|
|
152
180
|
// column's bar shrinks by the same offset. Omitting it let "fitting"
|
|
153
181
|
// labels run under the neighbouring column's node rect.
|
|
154
|
-
// First-column labels anchor `end` at node.x - 6 - offset with node.x = 0
|
|
155
|
-
//
|
|
156
|
-
//
|
|
182
|
+
// First-column labels anchor `end` at node.x - 6 - offset with node.x = 0.
|
|
183
|
+
// The diagram is shifted right by firstColumnLabelGutter, so the room to the
|
|
184
|
+
// SVG's left edge is that gutter plus the base margin, minus the inset —
|
|
185
|
+
// symmetric with the last column's sink-gutter budget below.
|
|
157
186
|
const available =
|
|
158
187
|
column === 0
|
|
159
|
-
? Math.max(0, MARGIN - 6 - dataLabelOffsetX)
|
|
188
|
+
? Math.max(0, firstColumnLabelGutter + MARGIN - 6 - dataLabelOffsetX)
|
|
160
189
|
: column === columnCount - 1
|
|
161
190
|
? Math.max(0, lastColumnLabelGutter + MARGIN - 6 - dataLabelOffsetX)
|
|
162
191
|
: Math.max(0, colWidth - nodeWidth - 12 - dataLabelOffsetX);
|
|
@@ -396,7 +425,7 @@
|
|
|
396
425
|
<div class="chart-empty">{@render empty()}</div>
|
|
397
426
|
{:else}
|
|
398
427
|
<ChartContainer bind:width={chartWidth} bind:height={chartHeight} {aspectRatio} {maxHeight}>
|
|
399
|
-
<g transform="translate({MARGIN}, {MARGIN})">
|
|
428
|
+
<g transform="translate({MARGIN + firstColumnLabelGutter}, {MARGIN})">
|
|
400
429
|
{#if columnLabels != null && columnLabels.length > 0}
|
|
401
430
|
{#each columnLabels.slice(0, columnCount) as label, ci (ci)}
|
|
402
431
|
<text
|