@aiaiai-pt/design-system 0.61.0 → 0.61.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.
|
@@ -513,7 +513,11 @@
|
|
|
513
513
|
const type = parameterType(parameter);
|
|
514
514
|
if (type === "bool" || type === "boolean") return false;
|
|
515
515
|
if (type === "number" || type === "integer") return "";
|
|
516
|
-
|
|
516
|
+
// A choice with no declared default starts EMPTY (the placeholder), never
|
|
517
|
+
// on its first option: a pre-selected option is a value nobody chose,
|
|
518
|
+
// and it rides the payload (atelier#2838 — staff creates wrote untouched
|
|
519
|
+
// `location_level: "building"`). A required one blocks submit until picked.
|
|
520
|
+
if (type === "enum" || type === "select") return "";
|
|
517
521
|
// #34 — an unset single `relationship` summary is null on the wire
|
|
518
522
|
// (string|null contract). Legacy `object_reference` keeps its "" seed.
|
|
519
523
|
if (type === "relationship") return null;
|
package/components/EChart.svelte
CHANGED
|
@@ -170,6 +170,26 @@
|
|
|
170
170
|
/** @type {import('echarts/core').EChartsType | undefined} */
|
|
171
171
|
let _chart = $state();
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Resolve CSS Color 4/5 values (e.g. `color-mix(...)`, `oklch(...)`,
|
|
175
|
+
* space-separated `rgb(... / ...)`) into ZRender-safe `rgb()`/`rgba()` via a
|
|
176
|
+
* transient DOM probe. Simple `#hex` and comma `rgb()`/`rgba()` pass straight
|
|
177
|
+
* through without touching the DOM.
|
|
178
|
+
*/
|
|
179
|
+
const ZRENDER_SAFE_COLOR = /^(?:#[0-9a-f]{3,8}|rgba?\(\s*[0-9.]+\s*,\s*[0-9.]+\s*,\s*[0-9.]+(?:\s*,\s*[0-9.]+)?\s*\))$/i;
|
|
180
|
+
|
|
181
|
+
function resolveColor(el, raw) {
|
|
182
|
+
if (!raw || ZRENDER_SAFE_COLOR.test(raw)) return raw;
|
|
183
|
+
if (typeof document === "undefined") return raw;
|
|
184
|
+
const probe = document.createElement("span");
|
|
185
|
+
probe.style.display = "none";
|
|
186
|
+
probe.style.color = raw;
|
|
187
|
+
el.appendChild(probe);
|
|
188
|
+
const resolved = getComputedStyle(probe).color.trim();
|
|
189
|
+
probe.remove();
|
|
190
|
+
return resolved || raw;
|
|
191
|
+
}
|
|
192
|
+
|
|
173
193
|
/** Build the ECharts option from current data + the container's tokens. */
|
|
174
194
|
function buildOption() {
|
|
175
195
|
const el = container;
|
|
@@ -177,7 +197,7 @@
|
|
|
177
197
|
const cs = getComputedStyle(el);
|
|
178
198
|
const token = (name, fallback) => {
|
|
179
199
|
const v = cs.getPropertyValue(name).trim();
|
|
180
|
-
return v || fallback;
|
|
200
|
+
return resolveColor(el, v || fallback);
|
|
181
201
|
};
|
|
182
202
|
return buildChartOption(chartData, {
|
|
183
203
|
tokens: {
|
|
@@ -351,6 +371,10 @@
|
|
|
351
371
|
font-weight: 600;
|
|
352
372
|
}
|
|
353
373
|
|
|
374
|
+
.echart-table thead th:not(:first-child) {
|
|
375
|
+
text-align: end;
|
|
376
|
+
}
|
|
377
|
+
|
|
354
378
|
.echart-table tr[data-band] {
|
|
355
379
|
background: var(--chart-band-bg);
|
|
356
380
|
}
|
|
@@ -361,12 +385,12 @@
|
|
|
361
385
|
}
|
|
362
386
|
.echart-table tbody th {
|
|
363
387
|
font-weight: 400;
|
|
364
|
-
color: var(--color-text
|
|
388
|
+
color: var(--color-text);
|
|
365
389
|
}
|
|
366
390
|
|
|
367
391
|
.echart-table td {
|
|
368
392
|
text-align: end;
|
|
369
393
|
font-variant-numeric: tabular-nums;
|
|
370
|
-
color: var(--color-text
|
|
394
|
+
color: var(--color-text);
|
|
371
395
|
}
|
|
372
396
|
</style>
|
|
@@ -59,10 +59,21 @@ export interface BuildChartOptionOpts {
|
|
|
59
59
|
/** The same, for the secondary value axis. */
|
|
60
60
|
ySecondaryCeiling?: number;
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Apply an alpha multiplier to a CSS colour and emit ZRender-safe `rgb()` /
|
|
64
|
+
* `rgba()` syntax.
|
|
65
|
+
*
|
|
66
|
+
* Why NOT `color-mix(in srgb, ...)`: Canvas 2D draws `color-mix(...)` at rest,
|
|
67
|
+
* but ECharts 6 / ZRender computes hover (`emphasis`) colours in JS via
|
|
68
|
+
* `zrender/lib/tool/color.lift()`, whose parser only accepts `#hex`, `rgb()`,
|
|
69
|
+
* `rgba()`, `hsl()`, and named CSS colours. Passing `color-mix(...)` makes
|
|
70
|
+
* `lift()` return `undefined`, turning hovered bars/slices invisible.
|
|
71
|
+
*/
|
|
72
|
+
export declare function withAlpha(color: string, alpha: number): string;
|
|
62
73
|
/**
|
|
63
74
|
* Per-series / per-slice colour: an alpha ramp off the accent so N series stay
|
|
64
|
-
* distinguishable AND on-theme without a hardcoded palette.
|
|
65
|
-
*
|
|
75
|
+
* distinguishable AND on-theme without a hardcoded palette. Emits ZRender-safe
|
|
76
|
+
* `rgb()`/`rgba()` so ECharts emphasis (`color.lift`) works on hover.
|
|
66
77
|
*/
|
|
67
78
|
export declare function seriesColor(accent: string, i: number): string;
|
|
68
79
|
/** A muted series: the secondary text colour, light enough to sit behind the accent. */
|
|
@@ -80,14 +80,78 @@ function makeFmt(locale: string): (value: number) => string {
|
|
|
80
80
|
return (value: number) => nf.format(value);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Parse a CSS hex (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) or `rgb()`/`rgba()`
|
|
85
|
+
* string (comma or CSS Color 4 space/slash syntax) into `[r, g, b, a]`, or null
|
|
86
|
+
* if unrecognised.
|
|
87
|
+
*/
|
|
88
|
+
function parseRgb(color: string): [number, number, number, number] | null {
|
|
89
|
+
const s = color.trim();
|
|
90
|
+
if (s.startsWith("#")) {
|
|
91
|
+
const hex = s.slice(1);
|
|
92
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
93
|
+
const r = parseInt(hex[0] + hex[0], 16);
|
|
94
|
+
const g = parseInt(hex[1] + hex[1], 16);
|
|
95
|
+
const b = parseInt(hex[2] + hex[2], 16);
|
|
96
|
+
const a = hex.length === 4 ? parseInt(hex[3] + hex[3], 16) / 255 : 1;
|
|
97
|
+
if ([r, g, b, a].every(Number.isFinite)) return [r, g, b, a];
|
|
98
|
+
} else if (hex.length === 6 || hex.length === 8) {
|
|
99
|
+
const r = parseInt(hex.slice(0, 2), 16);
|
|
100
|
+
const g = parseInt(hex.slice(2, 4), 16);
|
|
101
|
+
const b = parseInt(hex.slice(4, 6), 16);
|
|
102
|
+
const a = hex.length === 8 ? parseInt(hex.slice(6, 8), 16) / 255 : 1;
|
|
103
|
+
if ([r, g, b, a].every(Number.isFinite)) return [r, g, b, a];
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const m = s.match(
|
|
109
|
+
/^rgba?\(\s*([0-9.]+)\s*[,\s]\s*([0-9.]+)\s*[,\s]\s*([0-9.]+)(?:\s*[,/]\s*([0-9.]+%?))?\s*\)$/i,
|
|
110
|
+
);
|
|
111
|
+
if (!m) return null;
|
|
112
|
+
const r = Math.round(Number(m[1]));
|
|
113
|
+
const g = Math.round(Number(m[2]));
|
|
114
|
+
const b = Math.round(Number(m[3]));
|
|
115
|
+
let a = 1;
|
|
116
|
+
if (m[4] !== undefined) {
|
|
117
|
+
a = m[4].endsWith("%") ? parseFloat(m[4]) / 100 : Number(m[4]);
|
|
118
|
+
}
|
|
119
|
+
if (![r, g, b, a].every(Number.isFinite)) return null;
|
|
120
|
+
return [
|
|
121
|
+
Math.min(255, Math.max(0, r)),
|
|
122
|
+
Math.min(255, Math.max(0, g)),
|
|
123
|
+
Math.min(255, Math.max(0, b)),
|
|
124
|
+
Math.min(1, Math.max(0, a)),
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Apply an alpha multiplier to a CSS colour and emit ZRender-safe `rgb()` /
|
|
130
|
+
* `rgba()` syntax.
|
|
131
|
+
*
|
|
132
|
+
* Why NOT `color-mix(in srgb, ...)`: Canvas 2D draws `color-mix(...)` at rest,
|
|
133
|
+
* but ECharts 6 / ZRender computes hover (`emphasis`) colours in JS via
|
|
134
|
+
* `zrender/lib/tool/color.lift()`, whose parser only accepts `#hex`, `rgb()`,
|
|
135
|
+
* `rgba()`, `hsl()`, and named CSS colours. Passing `color-mix(...)` makes
|
|
136
|
+
* `lift()` return `undefined`, turning hovered bars/slices invisible.
|
|
137
|
+
*/
|
|
138
|
+
export function withAlpha(color: string, alpha: number): string {
|
|
139
|
+
const clamped = Math.min(1, Math.max(0, alpha));
|
|
140
|
+
const parsed = parseRgb(color);
|
|
141
|
+
if (!parsed) return color.trim();
|
|
142
|
+
const [r, g, b, baseA] = parsed;
|
|
143
|
+
const outA = Math.round(baseA * clamped * 1000) / 1000;
|
|
144
|
+
return outA >= 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${outA})`;
|
|
145
|
+
}
|
|
146
|
+
|
|
83
147
|
/**
|
|
84
148
|
* Per-series / per-slice colour: an alpha ramp off the accent so N series stay
|
|
85
|
-
* distinguishable AND on-theme without a hardcoded palette.
|
|
86
|
-
*
|
|
149
|
+
* distinguishable AND on-theme without a hardcoded palette. Emits ZRender-safe
|
|
150
|
+
* `rgb()`/`rgba()` so ECharts emphasis (`color.lift`) works on hover.
|
|
87
151
|
*/
|
|
88
152
|
export function seriesColor(accent: string, i: number): string {
|
|
89
153
|
const alpha = Math.max(0.35, 1 - i * 0.15);
|
|
90
|
-
return
|
|
154
|
+
return withAlpha(accent, alpha);
|
|
91
155
|
}
|
|
92
156
|
|
|
93
157
|
/** True when the chart should render as a pie/donut (single-measure mode). */
|
|
@@ -140,7 +204,7 @@ function buildPieOption(
|
|
|
140
204
|
|
|
141
205
|
/** A muted series: the secondary text colour, light enough to sit behind the accent. */
|
|
142
206
|
export function mutedColor(textSecondary: string): string {
|
|
143
|
-
return
|
|
207
|
+
return withAlpha(textSecondary, 0.35);
|
|
144
208
|
}
|
|
145
209
|
|
|
146
210
|
/** Map one shaped series → its ECharts series object. `i` counts accent series only. */
|
|
@@ -213,8 +277,7 @@ function bandArea(
|
|
|
213
277
|
return {
|
|
214
278
|
silent: true,
|
|
215
279
|
itemStyle: {
|
|
216
|
-
color:
|
|
217
|
-
tokens.band || `color-mix(in srgb, ${tokens.accent} 16%, transparent)`,
|
|
280
|
+
color: tokens.band || withAlpha(tokens.accent, 0.16),
|
|
218
281
|
},
|
|
219
282
|
label: {
|
|
220
283
|
show: Boolean(band.label),
|
|
@@ -303,7 +366,10 @@ function buildCartesianOption(
|
|
|
303
366
|
tooltip: {
|
|
304
367
|
...tooltipChrome(tokens),
|
|
305
368
|
trigger: "axis",
|
|
306
|
-
axisPointer: {
|
|
369
|
+
axisPointer: {
|
|
370
|
+
type: "shadow",
|
|
371
|
+
shadowStyle: { color: withAlpha(tokens.textSecondary, 0.08) },
|
|
372
|
+
},
|
|
307
373
|
formatter: (
|
|
308
374
|
ps: Array<{
|
|
309
375
|
axisValueLabel?: string;
|