@r2digisolutions/components 0.21.34 → 0.22.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.
- package/dist/components/molecules/AreaLineChart/AreaLineChart.svelte +37 -58
- package/dist/components/molecules/BarChart/BarChart.svelte +21 -39
- package/dist/components/molecules/MultiLineChart/MultiLineChart.svelte +2 -4
- package/dist/components/molecules/StackedBarChart/StackedBarChart.svelte +1 -3
- package/dist/components/organisms/AssistantChat/AssistantChat.svelte +18 -4
- package/dist/components/organisms/AssistantChat/AssistantChat.svelte.d.ts +2 -0
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
}: AreaLineChartProps = $props();
|
|
51
51
|
|
|
52
52
|
const W = 500;
|
|
53
|
-
const pad: ChartPad = { ...DEFAULT_PAD, b:
|
|
53
|
+
const pad: ChartPad = { ...DEFAULT_PAD, b: 32 };
|
|
54
54
|
const uid = `alc-${Math.random().toString(36).slice(2, 8)}`;
|
|
55
55
|
|
|
56
56
|
let tipIndex = $state<number | null>(null);
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
const domain = $derived.by(() => {
|
|
60
60
|
if (yMin !== undefined && yMax !== undefined) return { min: yMin, max: yMax };
|
|
61
61
|
const auto = scaleDomain(values);
|
|
62
|
-
/** Counts never go below zero unless the caller sets an explicit floor. */
|
|
63
62
|
if (yMin !== undefined) return { min: yMin, max: Math.max(auto.max, yMin + 1) };
|
|
64
63
|
if (values.length > 0 && Math.min(...values) >= 0 && auto.min < 0) {
|
|
65
64
|
return { min: 0, max: auto.max };
|
|
@@ -70,32 +69,19 @@
|
|
|
70
69
|
const line = $derived(smooth ? smoothLinePath(points) : linearLinePath(points));
|
|
71
70
|
const area = $derived(areaPath(line, points, height, pad));
|
|
72
71
|
|
|
73
|
-
const integerValues = $derived(values.every((v) => Number.isInteger(v)));
|
|
72
|
+
const integerValues = $derived(values.length > 0 && values.every((v) => Number.isInteger(v)));
|
|
74
73
|
|
|
75
74
|
const gridYs = $derived.by(() => {
|
|
76
75
|
const { min, max } = domain;
|
|
77
76
|
return [0, 0.5, 1].map((t) => {
|
|
78
77
|
const raw = min + t * (max - min);
|
|
79
|
-
const label = integerValues ? String(Math.round(raw)) : formatTick(raw);
|
|
80
78
|
return {
|
|
81
79
|
y: pad.t + (1 - t) * (height - pad.t - pad.b),
|
|
82
|
-
label
|
|
80
|
+
label: integerValues ? String(Math.round(raw)) : formatTick(raw)
|
|
83
81
|
};
|
|
84
82
|
});
|
|
85
83
|
});
|
|
86
84
|
|
|
87
|
-
/** First / last / sparse middle — HTML so labels stay readable (SVG stretch does not squash them). */
|
|
88
|
-
const xLabels = $derived.by(() => {
|
|
89
|
-
const out: { label: string; leftPct: number }[] = [];
|
|
90
|
-
for (let i = 0; i < data.length; i++) {
|
|
91
|
-
const show = i === 0 || i === data.length - 1 || data.length <= 7;
|
|
92
|
-
const p = points[i];
|
|
93
|
-
if (!show || !p) continue;
|
|
94
|
-
out.push({ label: data[i].label, leftPct: (p.x / W) * 100 });
|
|
95
|
-
}
|
|
96
|
-
return out;
|
|
97
|
-
});
|
|
98
|
-
|
|
99
85
|
const tip = $derived.by(() => {
|
|
100
86
|
if (tipIndex == null || !points[tipIndex]) return null;
|
|
101
87
|
const p = points[tipIndex];
|
|
@@ -116,49 +102,16 @@
|
|
|
116
102
|
}
|
|
117
103
|
</script>
|
|
118
104
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
>
|
|
125
|
-
<!-- HTML axis labels: preserveAspectRatio=none would distort SVG <text> -->
|
|
126
|
-
{#if showGrid}
|
|
127
|
-
<div class="pointer-events-none absolute inset-0 z-[1]">
|
|
128
|
-
{#each gridYs as g (g.label + g.y)}
|
|
129
|
-
<span
|
|
130
|
-
class="text-secondary absolute -translate-y-1/2 text-[11px] leading-none tabular-nums"
|
|
131
|
-
style:left="0"
|
|
132
|
-
style:top={`${(g.y / height) * 100}%`}
|
|
133
|
-
style:width={`${(pad.l / W) * 100}%`}
|
|
134
|
-
style:text-align="right"
|
|
135
|
-
style:padding-right="6px"
|
|
136
|
-
>
|
|
137
|
-
{g.label}
|
|
138
|
-
</span>
|
|
139
|
-
{/each}
|
|
140
|
-
</div>
|
|
141
|
-
{/if}
|
|
142
|
-
|
|
143
|
-
<div
|
|
144
|
-
class="pointer-events-none absolute inset-x-0 bottom-0 z-[1]"
|
|
145
|
-
style:height={`${(pad.b / height) * 100}%`}
|
|
146
|
-
>
|
|
147
|
-
{#each xLabels as xl (xl.label + xl.leftPct)}
|
|
148
|
-
<span
|
|
149
|
-
class="text-secondary absolute top-1 -translate-x-1/2 text-[11px] leading-none whitespace-nowrap"
|
|
150
|
-
style:left={`${xl.leftPct}%`}
|
|
151
|
-
>
|
|
152
|
-
{xl.label}
|
|
153
|
-
</span>
|
|
154
|
-
{/each}
|
|
155
|
-
</div>
|
|
156
|
-
|
|
105
|
+
<!--
|
|
106
|
+
Keep aspect ratio (h-auto, no preserveAspectRatio=none).
|
|
107
|
+
Stretching to a fixed CSS height warps curves/dots — as in Ads vs gestor.
|
|
108
|
+
-->
|
|
109
|
+
<div class={['relative w-full select-none', className]}>
|
|
157
110
|
<svg
|
|
158
111
|
viewBox={`0 0 ${W} ${height}`}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
aria-
|
|
112
|
+
class="h-auto w-full overflow-visible"
|
|
113
|
+
role="img"
|
|
114
|
+
aria-label="Area line chart"
|
|
162
115
|
>
|
|
163
116
|
<defs>
|
|
164
117
|
<linearGradient id="{uid}-fill" x1="0" y1="0" x2="0" y2="1">
|
|
@@ -185,6 +138,15 @@
|
|
|
185
138
|
stroke-width="1"
|
|
186
139
|
stroke-dasharray="4 4"
|
|
187
140
|
/>
|
|
141
|
+
<text
|
|
142
|
+
x={pad.l - 8}
|
|
143
|
+
y={g.y + 3}
|
|
144
|
+
text-anchor="end"
|
|
145
|
+
class="fill-muted"
|
|
146
|
+
font-size="10"
|
|
147
|
+
>
|
|
148
|
+
{g.label}
|
|
149
|
+
</text>
|
|
188
150
|
{/each}
|
|
189
151
|
{/if}
|
|
190
152
|
|
|
@@ -230,6 +192,23 @@
|
|
|
230
192
|
/>
|
|
231
193
|
{/if}
|
|
232
194
|
{/each}
|
|
195
|
+
|
|
196
|
+
{#each data as d, i (i)}
|
|
197
|
+
{#if i === 0 || i === data.length - 1 || data.length <= 7}
|
|
198
|
+
{@const p = points[i]}
|
|
199
|
+
{#if p}
|
|
200
|
+
<text
|
|
201
|
+
x={p.x}
|
|
202
|
+
y={height - 8}
|
|
203
|
+
text-anchor="middle"
|
|
204
|
+
class="fill-muted"
|
|
205
|
+
font-size="10"
|
|
206
|
+
>
|
|
207
|
+
{d.label}
|
|
208
|
+
</text>
|
|
209
|
+
{/if}
|
|
210
|
+
{/if}
|
|
211
|
+
{/each}
|
|
233
212
|
</svg>
|
|
234
213
|
|
|
235
214
|
{#if tip}
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
}: BarChartProps = $props();
|
|
30
30
|
|
|
31
31
|
const W = 420;
|
|
32
|
-
const pad = { t:
|
|
32
|
+
const pad = { t: 24, r: 12, b: 32, l: 12 };
|
|
33
33
|
const uid = `bc-${Math.random().toString(36).slice(2, 8)}`;
|
|
34
34
|
const color = 'var(--color-brand-500, #6366f1)';
|
|
35
35
|
|
|
@@ -66,50 +66,18 @@
|
|
|
66
66
|
};
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
function axisLabel(label: string): string {
|
|
70
|
-
return label.length > 14 ? `${label.slice(0, 14)}…` : label;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
69
|
function select(i: number) {
|
|
74
70
|
if (!interactive) return;
|
|
75
71
|
tipIndex = tipIndex === i ? null : i;
|
|
76
72
|
}
|
|
77
73
|
</script>
|
|
78
74
|
|
|
79
|
-
<div
|
|
80
|
-
class={['relative w-full select-none', className]}
|
|
81
|
-
style:height={`${height}px`}
|
|
82
|
-
role="img"
|
|
83
|
-
aria-label="Bar chart"
|
|
84
|
-
>
|
|
85
|
-
<!-- HTML labels stay readable; SVG stretch would squash <text> -->
|
|
86
|
-
{#each bars as b, i (b.label + i)}
|
|
87
|
-
{#if showValues && b.value > 0}
|
|
88
|
-
<span
|
|
89
|
-
class="text-secondary pointer-events-none absolute z-[1] -translate-x-1/2 -translate-y-full text-[11px] font-semibold tabular-nums"
|
|
90
|
-
style:left={`${(b.cx / W) * 100}%`}
|
|
91
|
-
style:top={`${(b.y / height) * 100}%`}
|
|
92
|
-
style:margin-top="-2px"
|
|
93
|
-
>
|
|
94
|
-
{formatTick(b.value, 0)}{unit}
|
|
95
|
-
</span>
|
|
96
|
-
{/if}
|
|
97
|
-
<span
|
|
98
|
-
class="text-secondary pointer-events-none absolute z-[1] -translate-x-1/2 truncate text-center text-[11px] leading-tight"
|
|
99
|
-
style:left={`${(b.cx / W) * 100}%`}
|
|
100
|
-
style:bottom="4px"
|
|
101
|
-
style:max-width={`${((W - pad.l - pad.r) / Math.max(data.length, 1) / W) * 100}%`}
|
|
102
|
-
title={b.label}
|
|
103
|
-
>
|
|
104
|
-
{axisLabel(b.label)}
|
|
105
|
-
</span>
|
|
106
|
-
{/each}
|
|
107
|
-
|
|
75
|
+
<div class={['relative w-full select-none', className]}>
|
|
108
76
|
<svg
|
|
109
77
|
viewBox={`0 0 ${W} ${height}`}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
aria-
|
|
78
|
+
class="h-auto w-full overflow-visible"
|
|
79
|
+
role="img"
|
|
80
|
+
aria-label="Bar chart"
|
|
113
81
|
>
|
|
114
82
|
<defs>
|
|
115
83
|
<linearGradient id="{uid}-bar" x1="0" y1="0" x2="0" y2="1">
|
|
@@ -118,7 +86,7 @@
|
|
|
118
86
|
</linearGradient>
|
|
119
87
|
</defs>
|
|
120
88
|
|
|
121
|
-
{#each bars as b, i
|
|
89
|
+
{#each bars as b, i}
|
|
122
90
|
<rect
|
|
123
91
|
x={b.x}
|
|
124
92
|
y={b.y}
|
|
@@ -129,9 +97,23 @@
|
|
|
129
97
|
opacity={tipIndex == null || tipIndex === i ? 1 : 0.35}
|
|
130
98
|
class="transition-opacity"
|
|
131
99
|
/>
|
|
100
|
+
{#if showValues && b.value > 0}
|
|
101
|
+
<text
|
|
102
|
+
x={b.cx}
|
|
103
|
+
y={b.y - 6}
|
|
104
|
+
text-anchor="middle"
|
|
105
|
+
class="fill-secondary"
|
|
106
|
+
font-size="10"
|
|
107
|
+
font-weight="600"
|
|
108
|
+
>
|
|
109
|
+
{formatTick(b.value, 0)}{unit}
|
|
110
|
+
</text>
|
|
111
|
+
{/if}
|
|
112
|
+
<text x={b.cx} y={height - 8} text-anchor="middle" class="fill-muted" font-size="10">
|
|
113
|
+
{b.label}
|
|
114
|
+
</text>
|
|
132
115
|
{#if interactive}
|
|
133
116
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
134
|
-
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
135
117
|
<rect
|
|
136
118
|
x={b.x - 4}
|
|
137
119
|
y={pad.t}
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
})
|
|
79
79
|
);
|
|
80
80
|
|
|
81
|
-
const integerValues = $derived(allValues.every((v) => Number.isInteger(v)));
|
|
81
|
+
const integerValues = $derived(allValues.length > 0 && allValues.every((v) => Number.isInteger(v)));
|
|
82
82
|
|
|
83
83
|
const gridYs = $derived.by(() => {
|
|
84
84
|
const { min, max } = domain;
|
|
@@ -121,9 +121,7 @@
|
|
|
121
121
|
<div class={['relative w-full select-none', className]}>
|
|
122
122
|
<svg
|
|
123
123
|
viewBox={`0 0 ${W} ${height}`}
|
|
124
|
-
|
|
125
|
-
class="block w-full overflow-visible"
|
|
126
|
-
style:height={`${height}px`}
|
|
124
|
+
class="h-auto w-full overflow-visible"
|
|
127
125
|
role="img"
|
|
128
126
|
aria-label="Multi-line chart"
|
|
129
127
|
>
|
|
@@ -100,9 +100,7 @@
|
|
|
100
100
|
<div class="relative w-full select-none">
|
|
101
101
|
<svg
|
|
102
102
|
viewBox={`0 0 ${W} ${height}`}
|
|
103
|
-
|
|
104
|
-
class="block w-full overflow-visible"
|
|
105
|
-
style:height={`${height}px`}
|
|
103
|
+
class="h-auto w-full overflow-visible"
|
|
106
104
|
role="img"
|
|
107
105
|
aria-label="Stacked bar chart"
|
|
108
106
|
>
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
draft?: string;
|
|
39
39
|
loading?: boolean;
|
|
40
40
|
loadingLabel?: string;
|
|
41
|
+
/** Atom-style progress lines inside the pending assistant bubble. */
|
|
42
|
+
statusSteps?: string[];
|
|
41
43
|
/** When false, the spinner bubble is hidden (parent paints status in a message). */
|
|
42
44
|
showLoadingBubble?: boolean;
|
|
43
45
|
error?: string | null;
|
|
@@ -83,6 +85,7 @@
|
|
|
83
85
|
draft = $bindable(''),
|
|
84
86
|
loading = false,
|
|
85
87
|
loadingLabel = 'Procesando…',
|
|
88
|
+
statusSteps = [],
|
|
86
89
|
showLoadingBubble = true,
|
|
87
90
|
error = null,
|
|
88
91
|
voiceEnabled = true,
|
|
@@ -309,10 +312,21 @@
|
|
|
309
312
|
class="rounded-2xl rounded-bl-sm bg-surface-overlay px-3.5 py-2.5 text-sm leading-relaxed text-primary max-w-[calc(100%-2rem)] whitespace-pre-wrap"
|
|
310
313
|
>
|
|
311
314
|
{#if message.id === pendingAssistantId}
|
|
312
|
-
<
|
|
313
|
-
<
|
|
314
|
-
|
|
315
|
-
|
|
315
|
+
<div class="gap-1.5 flex flex-col">
|
|
316
|
+
<span class="gap-2 text-muted flex items-center">
|
|
317
|
+
<LoaderCircle size={14} strokeWidth={2} class="animate-spin shrink-0" />
|
|
318
|
+
{#if statusSteps.length === 0}
|
|
319
|
+
<span class="text-xs">{loadingLabel}</span>
|
|
320
|
+
{/if}
|
|
321
|
+
</span>
|
|
322
|
+
{#if statusSteps.length}
|
|
323
|
+
{#each statusSteps as step, i (i)}
|
|
324
|
+
<p class="text-[11px] text-muted">→ {step}</p>
|
|
325
|
+
{/each}
|
|
326
|
+
{/if}
|
|
327
|
+
</div>
|
|
328
|
+
{:else if loading && message === messages[messages.length - 1] && message.content}
|
|
329
|
+
{message.content}<span class="animate-pulse">▍</span>
|
|
316
330
|
{:else}
|
|
317
331
|
{message.content}
|
|
318
332
|
{/if}
|
|
@@ -20,6 +20,8 @@ interface AssistantChatProps {
|
|
|
20
20
|
draft?: string;
|
|
21
21
|
loading?: boolean;
|
|
22
22
|
loadingLabel?: string;
|
|
23
|
+
/** Atom-style progress lines inside the pending assistant bubble. */
|
|
24
|
+
statusSteps?: string[];
|
|
23
25
|
/** When false, the spinner bubble is hidden (parent paints status in a message). */
|
|
24
26
|
showLoadingBubble?: boolean;
|
|
25
27
|
error?: string | null;
|