@sentropic/design-system-svelte 0.34.32 → 0.34.34
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/Badge.svelte +66 -2
- package/dist/Badge.svelte.d.ts +21 -0
- package/dist/Badge.svelte.d.ts.map +1 -1
- package/dist/Collapsible.svelte +55 -1
- package/dist/Collapsible.svelte.d.ts +15 -0
- package/dist/Collapsible.svelte.d.ts.map +1 -1
- package/dist/Collapsible.test.d.ts +2 -0
- package/dist/Collapsible.test.d.ts.map +1 -0
- package/dist/Collapsible.test.js +68 -0
- package/dist/SelectableList.svelte +36 -17
- package/dist/SelectableList.svelte.d.ts.map +1 -1
- package/dist/SelectableRow.svelte +53 -1
- package/dist/SelectableRow.svelte.d.ts +10 -0
- package/dist/SelectableRow.svelte.d.ts.map +1 -1
- package/dist/SolidGaugeChart.svelte +276 -0
- package/dist/SolidGaugeChart.svelte.d.ts +46 -0
- package/dist/SolidGaugeChart.svelte.d.ts.map +1 -0
- package/dist/StateTimelineChart.svelte +451 -0
- package/dist/StateTimelineChart.svelte.d.ts +43 -0
- package/dist/StateTimelineChart.svelte.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
/**
|
|
3
|
+
* SolidGaugeChart - arc PLEIN / anneau de progression (distinct du GaugeChart
|
|
4
|
+
* à aiguille). Une piste de fond + un arc rempli proportionnel à `value`, avec
|
|
5
|
+
* la valeur affichée au centre. Les seuils colorent l'arc rempli selon la zone
|
|
6
|
+
* atteinte par la valeur. API canonique (référence Svelte, React/Vue alignés).
|
|
7
|
+
*
|
|
8
|
+
* Réutilise les mêmes tons/seuils que GaugeChart : tone ∈ neutral | info |
|
|
9
|
+
* success | warning | error | category1..8.
|
|
10
|
+
*/
|
|
11
|
+
export type SolidGaugeTone =
|
|
12
|
+
| "neutral" | "info" | "success" | "warning" | "error"
|
|
13
|
+
| "category1" | "category2" | "category3" | "category4"
|
|
14
|
+
| "category5" | "category6" | "category7" | "category8";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Seuil de coloration. La zone s'étend depuis le seuil précédent (ou le
|
|
18
|
+
* minimum) jusqu'à `value`. `tone` choisit la couleur de l'arc rempli quand la
|
|
19
|
+
* valeur tombe dans cette zone.
|
|
20
|
+
*/
|
|
21
|
+
export type SolidGaugeThreshold = {
|
|
22
|
+
value: number;
|
|
23
|
+
tone: SolidGaugeTone;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type SolidGaugeFormat = "number" | "percent";
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
import ChartDataList from "./ChartDataList.svelte";
|
|
31
|
+
|
|
32
|
+
type SolidGaugeChartProps = {
|
|
33
|
+
value: number;
|
|
34
|
+
min?: number;
|
|
35
|
+
max?: number;
|
|
36
|
+
/** Bandes colorées. Triées par `value` croissante : la zone contenant la valeur teinte l'arc rempli. */
|
|
37
|
+
thresholds?: SolidGaugeThreshold[];
|
|
38
|
+
/** Rayon intérieur de l'anneau, en fraction du rayon (0..1). */
|
|
39
|
+
innerRadius?: number;
|
|
40
|
+
/** Libellé décrivant la jauge (a11y + texte sous la valeur). */
|
|
41
|
+
label?: string;
|
|
42
|
+
/** Format de la valeur centrale. */
|
|
43
|
+
format?: SolidGaugeFormat;
|
|
44
|
+
/** Suffixe d'unité (ignoré pour `percent`). */
|
|
45
|
+
unit?: string;
|
|
46
|
+
/** Diamètre du SVG. */
|
|
47
|
+
size?: number;
|
|
48
|
+
/** Angle de départ en degrés (0 = est, sens horaire). */
|
|
49
|
+
startAngle?: number;
|
|
50
|
+
/** Angle de fin en degrés. */
|
|
51
|
+
endAngle?: number;
|
|
52
|
+
class?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
let {
|
|
56
|
+
value,
|
|
57
|
+
min = 0,
|
|
58
|
+
max = 100,
|
|
59
|
+
thresholds,
|
|
60
|
+
innerRadius = 0.72,
|
|
61
|
+
label,
|
|
62
|
+
format = "number",
|
|
63
|
+
unit,
|
|
64
|
+
size = 220,
|
|
65
|
+
startAngle = 180,
|
|
66
|
+
endAngle = 360,
|
|
67
|
+
class: className
|
|
68
|
+
}: SolidGaugeChartProps = $props();
|
|
69
|
+
|
|
70
|
+
const toRad = (deg: number) => (deg * Math.PI) / 180;
|
|
71
|
+
|
|
72
|
+
const span = $derived(Math.max(max - min, 0));
|
|
73
|
+
const clamped = $derived(Math.min(Math.max(value, min), max));
|
|
74
|
+
const frac = $derived(span > 0 ? (clamped - min) / span : 0);
|
|
75
|
+
|
|
76
|
+
// Épaisseur dérivée du rayon intérieur (anneau).
|
|
77
|
+
const cx = $derived(size / 2);
|
|
78
|
+
const r = $derived(size / 2 - 2);
|
|
79
|
+
const innerR = $derived(Math.min(Math.max(innerRadius, 0), 0.95) * r);
|
|
80
|
+
const thickness = $derived(Math.max(r - innerR, 1));
|
|
81
|
+
const trackR = $derived((r + innerR) / 2);
|
|
82
|
+
const a0 = $derived(toRad(startAngle));
|
|
83
|
+
const a1 = $derived(toRad(endAngle));
|
|
84
|
+
const totalAngle = $derived(a1 - a0);
|
|
85
|
+
|
|
86
|
+
const polar = (radius: number, angle: number, centerX: number, centerY: number): [number, number] => [
|
|
87
|
+
centerX + radius * Math.cos(angle),
|
|
88
|
+
centerY + radius * Math.sin(angle)
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
// Hauteur réelle de l'arc pour cadrer le viewBox (demi-cercle → moitié).
|
|
92
|
+
const geometry = $derived.by(() => {
|
|
93
|
+
const cyRaw = size / 2;
|
|
94
|
+
const samples = 64;
|
|
95
|
+
let minY = Infinity;
|
|
96
|
+
let maxY = -Infinity;
|
|
97
|
+
for (let i = 0; i <= samples; i++) {
|
|
98
|
+
const a = a0 + (totalAngle * i) / samples;
|
|
99
|
+
const yOuter = cyRaw + r * Math.sin(a);
|
|
100
|
+
minY = Math.min(minY, yOuter);
|
|
101
|
+
maxY = Math.max(maxY, yOuter);
|
|
102
|
+
}
|
|
103
|
+
minY = Math.min(minY, cyRaw - r);
|
|
104
|
+
const vbHeight = Math.min(maxY, size) - Math.max(minY, 0);
|
|
105
|
+
return { cy: cyRaw, vbTop: Math.max(minY, 0), vbHeight: Math.max(vbHeight, thickness) };
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const cy = $derived(geometry.cy);
|
|
109
|
+
|
|
110
|
+
function arcPath(fromFrac: number, toFrac: number): string {
|
|
111
|
+
const from = a0 + totalAngle * fromFrac;
|
|
112
|
+
const to = a0 + totalAngle * toFrac;
|
|
113
|
+
const [x0, y0] = polar(trackR, from, cx, cy);
|
|
114
|
+
const [x1, y1] = polar(trackR, to, cx, cy);
|
|
115
|
+
const large = Math.abs(to - from) > Math.PI ? 1 : 0;
|
|
116
|
+
const sweep = totalAngle >= 0 ? 1 : 0;
|
|
117
|
+
return `M ${x0} ${y0} A ${trackR} ${trackR} 0 ${large} ${sweep} ${x1} ${y1}`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Tons triés par seuil croissant : la zone contenant la valeur teinte l'arc.
|
|
121
|
+
const sortedThresholds = $derived.by(() => {
|
|
122
|
+
if (!thresholds || thresholds.length === 0 || span <= 0) return [];
|
|
123
|
+
return [...thresholds].sort((a, b) => a.value - b.value);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const activeTone = $derived.by((): SolidGaugeTone | null => {
|
|
127
|
+
if (sortedThresholds.length === 0) return null;
|
|
128
|
+
let tone: SolidGaugeTone = sortedThresholds[0].tone;
|
|
129
|
+
for (const t of sortedThresholds) {
|
|
130
|
+
if (clamped >= t.value) tone = t.tone;
|
|
131
|
+
}
|
|
132
|
+
return tone;
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const formatted = $derived.by(() => {
|
|
136
|
+
if (format === "percent") {
|
|
137
|
+
const pct = span > 0 ? Math.round(frac * 100) : 0;
|
|
138
|
+
return `${pct}%`;
|
|
139
|
+
}
|
|
140
|
+
const num = Number.isInteger(clamped) ? String(clamped) : clamped.toFixed(1);
|
|
141
|
+
return unit ? `${num} ${unit}` : num;
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const ariaValueText = $derived(label ? `${label}: ${formatted}` : formatted);
|
|
145
|
+
|
|
146
|
+
const classes = $derived(["st-solidGaugeChart", className].filter(Boolean).join(" "));
|
|
147
|
+
const dataValueItems = $derived([
|
|
148
|
+
`${label ? `${label}: ` : ""}${formatted} (min ${min}, max ${max})`
|
|
149
|
+
]);
|
|
150
|
+
|
|
151
|
+
const progressClass = $derived(
|
|
152
|
+
activeTone
|
|
153
|
+
? `st-solidGaugeChart__progress st-solidGaugeChart__progress--${activeTone}`
|
|
154
|
+
: "st-solidGaugeChart__progress"
|
|
155
|
+
);
|
|
156
|
+
</script>
|
|
157
|
+
|
|
158
|
+
<div class={classes}>
|
|
159
|
+
<div
|
|
160
|
+
class="st-solidGaugeChart__visual"
|
|
161
|
+
role="meter"
|
|
162
|
+
aria-valuenow={clamped}
|
|
163
|
+
aria-valuemin={min}
|
|
164
|
+
aria-valuemax={max}
|
|
165
|
+
aria-valuetext={ariaValueText}
|
|
166
|
+
aria-label={label}
|
|
167
|
+
>
|
|
168
|
+
<svg
|
|
169
|
+
viewBox="0 {geometry.vbTop} {size} {geometry.vbHeight}"
|
|
170
|
+
width="100%"
|
|
171
|
+
height="100%"
|
|
172
|
+
focusable="false"
|
|
173
|
+
aria-hidden="true"
|
|
174
|
+
>
|
|
175
|
+
<!-- Piste de fond -->
|
|
176
|
+
<path class="st-solidGaugeChart__track" d={arcPath(0, 1)} fill="none" stroke-width={thickness} />
|
|
177
|
+
|
|
178
|
+
<!-- Arc de progression rempli -->
|
|
179
|
+
{#if frac > 0}
|
|
180
|
+
<path
|
|
181
|
+
class={progressClass}
|
|
182
|
+
d={arcPath(0, frac)}
|
|
183
|
+
fill="none"
|
|
184
|
+
stroke-width={thickness}
|
|
185
|
+
/>
|
|
186
|
+
{/if}
|
|
187
|
+
|
|
188
|
+
<!-- Valeur centrale -->
|
|
189
|
+
<text
|
|
190
|
+
class="st-solidGaugeChart__value"
|
|
191
|
+
x={cx}
|
|
192
|
+
y={cy - thickness * 0.1}
|
|
193
|
+
text-anchor="middle"
|
|
194
|
+
dominant-baseline="auto"
|
|
195
|
+
>
|
|
196
|
+
{formatted}
|
|
197
|
+
</text>
|
|
198
|
+
{#if label}
|
|
199
|
+
<text
|
|
200
|
+
class="st-solidGaugeChart__label"
|
|
201
|
+
x={cx}
|
|
202
|
+
y={cy + thickness * 0.35}
|
|
203
|
+
text-anchor="middle"
|
|
204
|
+
dominant-baseline="hanging"
|
|
205
|
+
>
|
|
206
|
+
{label}
|
|
207
|
+
</text>
|
|
208
|
+
{/if}
|
|
209
|
+
</svg>
|
|
210
|
+
</div>
|
|
211
|
+
|
|
212
|
+
<ChartDataList label={label ?? "gauge"} items={dataValueItems} />
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<style>
|
|
216
|
+
.st-solidGaugeChart {
|
|
217
|
+
color: var(--st-semantic-text-secondary);
|
|
218
|
+
display: block;
|
|
219
|
+
font-family: inherit;
|
|
220
|
+
max-width: 100%;
|
|
221
|
+
position: relative;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.st-solidGaugeChart__visual,
|
|
225
|
+
.st-solidGaugeChart svg {
|
|
226
|
+
display: block;
|
|
227
|
+
overflow: visible;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.st-solidGaugeChart__track {
|
|
231
|
+
stroke: var(--st-semantic-surface-subtle);
|
|
232
|
+
stroke-linecap: round;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.st-solidGaugeChart__progress {
|
|
236
|
+
stroke: var(--st-semantic-action-primary);
|
|
237
|
+
stroke-linecap: round;
|
|
238
|
+
transition: d var(--st-motion-fast, 200ms) var(--st-motion-easing, ease);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.st-solidGaugeChart__value {
|
|
242
|
+
fill: var(--st-semantic-text-primary);
|
|
243
|
+
font-size: 1.5rem;
|
|
244
|
+
font-variant-numeric: tabular-nums;
|
|
245
|
+
font-weight: 700;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.st-solidGaugeChart__label {
|
|
249
|
+
fill: var(--st-semantic-text-secondary);
|
|
250
|
+
font-size: 0.8125rem;
|
|
251
|
+
font-weight: 500;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/* Tons sémantiques de feedback */
|
|
255
|
+
.st-solidGaugeChart__progress--neutral { stroke: var(--st-semantic-border-strong, var(--st-semantic-surface-subtle)); }
|
|
256
|
+
.st-solidGaugeChart__progress--info { stroke: var(--st-semantic-feedback-info, var(--st-semantic-action-primary)); }
|
|
257
|
+
.st-solidGaugeChart__progress--success { stroke: var(--st-semantic-feedback-success); }
|
|
258
|
+
.st-solidGaugeChart__progress--warning { stroke: var(--st-semantic-feedback-warning); }
|
|
259
|
+
.st-solidGaugeChart__progress--error { stroke: var(--st-semantic-feedback-error); }
|
|
260
|
+
|
|
261
|
+
/* Tons catégoriels data */
|
|
262
|
+
.st-solidGaugeChart__progress--category1 { stroke: var(--st-semantic-data-category1); }
|
|
263
|
+
.st-solidGaugeChart__progress--category2 { stroke: var(--st-semantic-data-category2); }
|
|
264
|
+
.st-solidGaugeChart__progress--category3 { stroke: var(--st-semantic-data-category3); }
|
|
265
|
+
.st-solidGaugeChart__progress--category4 { stroke: var(--st-semantic-data-category4); }
|
|
266
|
+
.st-solidGaugeChart__progress--category5 { stroke: var(--st-semantic-data-category5); }
|
|
267
|
+
.st-solidGaugeChart__progress--category6 { stroke: var(--st-semantic-data-category6); }
|
|
268
|
+
.st-solidGaugeChart__progress--category7 { stroke: var(--st-semantic-data-category7); }
|
|
269
|
+
.st-solidGaugeChart__progress--category8 { stroke: var(--st-semantic-data-category8); }
|
|
270
|
+
|
|
271
|
+
@media (prefers-reduced-motion: reduce) {
|
|
272
|
+
.st-solidGaugeChart__progress {
|
|
273
|
+
transition: none;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SolidGaugeChart - arc PLEIN / anneau de progression (distinct du GaugeChart
|
|
3
|
+
* à aiguille). Une piste de fond + un arc rempli proportionnel à `value`, avec
|
|
4
|
+
* la valeur affichée au centre. Les seuils colorent l'arc rempli selon la zone
|
|
5
|
+
* atteinte par la valeur. API canonique (référence Svelte, React/Vue alignés).
|
|
6
|
+
*
|
|
7
|
+
* Réutilise les mêmes tons/seuils que GaugeChart : tone ∈ neutral | info |
|
|
8
|
+
* success | warning | error | category1..8.
|
|
9
|
+
*/
|
|
10
|
+
export type SolidGaugeTone = "neutral" | "info" | "success" | "warning" | "error" | "category1" | "category2" | "category3" | "category4" | "category5" | "category6" | "category7" | "category8";
|
|
11
|
+
/**
|
|
12
|
+
* Seuil de coloration. La zone s'étend depuis le seuil précédent (ou le
|
|
13
|
+
* minimum) jusqu'à `value`. `tone` choisit la couleur de l'arc rempli quand la
|
|
14
|
+
* valeur tombe dans cette zone.
|
|
15
|
+
*/
|
|
16
|
+
export type SolidGaugeThreshold = {
|
|
17
|
+
value: number;
|
|
18
|
+
tone: SolidGaugeTone;
|
|
19
|
+
};
|
|
20
|
+
export type SolidGaugeFormat = "number" | "percent";
|
|
21
|
+
type SolidGaugeChartProps = {
|
|
22
|
+
value: number;
|
|
23
|
+
min?: number;
|
|
24
|
+
max?: number;
|
|
25
|
+
/** Bandes colorées. Triées par `value` croissante : la zone contenant la valeur teinte l'arc rempli. */
|
|
26
|
+
thresholds?: SolidGaugeThreshold[];
|
|
27
|
+
/** Rayon intérieur de l'anneau, en fraction du rayon (0..1). */
|
|
28
|
+
innerRadius?: number;
|
|
29
|
+
/** Libellé décrivant la jauge (a11y + texte sous la valeur). */
|
|
30
|
+
label?: string;
|
|
31
|
+
/** Format de la valeur centrale. */
|
|
32
|
+
format?: SolidGaugeFormat;
|
|
33
|
+
/** Suffixe d'unité (ignoré pour `percent`). */
|
|
34
|
+
unit?: string;
|
|
35
|
+
/** Diamètre du SVG. */
|
|
36
|
+
size?: number;
|
|
37
|
+
/** Angle de départ en degrés (0 = est, sens horaire). */
|
|
38
|
+
startAngle?: number;
|
|
39
|
+
/** Angle de fin en degrés. */
|
|
40
|
+
endAngle?: number;
|
|
41
|
+
class?: string;
|
|
42
|
+
};
|
|
43
|
+
declare const SolidGaugeChart: import("svelte").Component<SolidGaugeChartProps, {}, "">;
|
|
44
|
+
type SolidGaugeChart = ReturnType<typeof SolidGaugeChart>;
|
|
45
|
+
export default SolidGaugeChart;
|
|
46
|
+
//# sourceMappingURL=SolidGaugeChart.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidGaugeChart.svelte.d.ts","sourceRoot":"","sources":["../src/lib/SolidGaugeChart.svelte.ts"],"names":[],"mappings":"AAGE;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GACtB,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GACpD,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,GACrD,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAE1D;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAMpD,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wGAAwG;IACxG,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACnC,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA4IJ,QAAA,MAAM,eAAe,0DAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
|