@tensor_1/react 2.55.2 → 2.56.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/README.md +42 -0
- package/component-inventory.json +44 -0
- package/dist/{ChartCore-BKK2HEfi.d.cts → ChartCore-CY5a4teJ.d.cts} +18 -2
- package/dist/GlanceCharts-Cb39RqDC.d.cts +88 -0
- package/dist/chart-analytic-guide.d.ts +1 -0
- package/dist/chart-analytic-guide.js +6 -1
- package/dist/chart-analytic.cjs +11 -1
- package/dist/chart-analytic.d.cts +2 -2
- package/dist/chart-glance.d.ts +65 -0
- package/dist/chart-glance.js +162 -0
- package/dist/chart-preset.cjs +337 -5
- package/dist/chart-preset.d.cts +9 -3
- package/dist/chart-preset.d.ts +8 -1
- package/dist/chart-preset.js +16 -1
- package/dist/chart-theme.d.ts +18 -2
- package/dist/chart-theme.js +6 -1
- package/dist/chart.cjs +337 -5
- package/dist/chart.d.cts +9 -3
- package/dist/chart.d.ts +3 -1
- package/dist/chart.js +9 -2
- package/dist/components/Arrive.d.ts +49 -0
- package/dist/components/Arrive.js +93 -0
- package/dist/components/Chart.d.ts +8 -1
- package/dist/components/Chart.js +16 -1
- package/dist/components/ChartCard.d.ts +34 -0
- package/dist/components/ChartCard.js +36 -0
- package/dist/components/ChartPanels.js +5 -0
- package/dist/components/Count.d.ts +10 -4
- package/dist/components/Count.js +35 -3
- package/dist/components/GlanceCharts.d.ts +37 -0
- package/dist/components/GlanceCharts.js +128 -0
- package/dist/components/GlanceMarks.d.ts +63 -0
- package/dist/components/GlanceMarks.js +59 -0
- package/dist/components/Meter.d.ts +12 -2
- package/dist/components/Meter.js +23 -13
- package/dist/components/StatusDot.d.ts +27 -0
- package/dist/components/StatusDot.js +16 -0
- package/dist/icons/Icon.d.ts +5 -5
- package/dist/index.cjs +2165 -1925
- package/dist/index.d.cts +173 -7
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { cx } from "../cx.js";
|
|
4
|
+
import { ArriveIndexProvider } from "./Arrive.js";
|
|
5
|
+
function ChartCard({ question, headline, answer, action, note, empty, headingLevel = 3, arriveIndex, className, style, children, ...props }) {
|
|
6
|
+
const id = useId();
|
|
7
|
+
const Heading = `h${headingLevel}`;
|
|
8
|
+
const arriving = typeof arriveIndex === "number";
|
|
9
|
+
const hasEmpty = empty != null && empty !== false;
|
|
10
|
+
return /* @__PURE__ */ jsxs(
|
|
11
|
+
"section",
|
|
12
|
+
{
|
|
13
|
+
className: cx("uix-chart-card", arriving && "uix-arrive__item", className),
|
|
14
|
+
"aria-labelledby": `${id}-q`,
|
|
15
|
+
style: arriving ? { "--uix-arrive-i": arriveIndex, ...style } : style,
|
|
16
|
+
...props,
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ jsxs("div", { className: "uix-chart-card__head", children: [
|
|
19
|
+
/* @__PURE__ */ jsx(Heading, { className: "uix-chart-card__question", id: `${id}-q`, children: question }),
|
|
20
|
+
action != null && /* @__PURE__ */ jsx("div", { className: "uix-chart-card__action", children: action })
|
|
21
|
+
] }),
|
|
22
|
+
hasEmpty ? /* @__PURE__ */ jsx("p", { className: "uix-chart-card__empty", children: empty }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23
|
+
(headline != null || answer != null) && /* @__PURE__ */ jsxs("p", { className: "uix-chart-card__answer", children: [
|
|
24
|
+
headline != null && /* @__PURE__ */ jsx("span", { className: "uix-chart-card__headline", children: headline }),
|
|
25
|
+
answer != null && /* @__PURE__ */ jsx("span", { children: answer })
|
|
26
|
+
] }),
|
|
27
|
+
children != null && /* @__PURE__ */ jsx("div", { className: "uix-chart-card__plot", children: arriving ? /* @__PURE__ */ jsx(ArriveIndexProvider, { index: arriveIndex, children }) : children }),
|
|
28
|
+
note != null && /* @__PURE__ */ jsx("div", { className: "uix-chart-card__note", children: note })
|
|
29
|
+
] })
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
ChartCard
|
|
36
|
+
};
|
|
@@ -6,6 +6,11 @@ import { chartPanelsModel } from "../chart-panels-model.js";
|
|
|
6
6
|
import { DEFAULT_CORRELATION_SCATTER_LABELS, correlationScatterModel } from "../correlation-scatter-model.js";
|
|
7
7
|
const CSS_VAR_TOKENS = {
|
|
8
8
|
palette: [1, 2, 3, 4, 5, 6, 7, 8].map((i) => `var(--uix-chart-${i})`),
|
|
9
|
+
series: "var(--uix-chart-series)",
|
|
10
|
+
seriesSoft: "var(--uix-chart-series-soft)",
|
|
11
|
+
categories: [1, 2, 3].map((i) => `var(--uix-chart-${i})`),
|
|
12
|
+
radius: "var(--uix-radius-md)",
|
|
13
|
+
shadow: "var(--uix-shadow-popover)",
|
|
9
14
|
neutral: "var(--uix-chart-neutral)",
|
|
10
15
|
grid: "var(--uix-chart-grid)",
|
|
11
16
|
axis: "var(--uix-chart-axis)",
|
|
@@ -10,15 +10,21 @@ interface CountProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
|
10
10
|
* server's and the browser's thousands separators cannot differ.
|
|
11
11
|
*/
|
|
12
12
|
format?: (value: number) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Count up from zero while the enclosing `Arrive` stage plays its arrival (calm kit 2.56):
|
|
15
|
+
* --uix-dur-arrive-count (600 ms), starting with its card. Only then: after the arrival, and
|
|
16
|
+
* outside a stage, a change still ticks once. Under reduced motion the number is simply there.
|
|
17
|
+
*/
|
|
18
|
+
arrive?: boolean;
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
15
21
|
* A number that ticks once when it changes (HAR-2587, motion standard §2.8): a badge count, a
|
|
16
22
|
* stat tile's value, an unread total. The new figure slides 4 px in from below when it went
|
|
17
23
|
* up and from above when it went down, with a fade; never on the first render, never a loop,
|
|
18
|
-
* never a count-up through the numbers between
|
|
19
|
-
* Under reduced motion it only fades. It announces
|
|
20
|
-
* matters (a toast, `ChangeHighlight announce`).
|
|
24
|
+
* never a count-up through the numbers between — except the one arrival count-up of `arrive`.
|
|
25
|
+
* Tabular figures, so neighbours do not shift. Under reduced motion it only fades. It announces
|
|
26
|
+
* nothing: say what changed where it matters (a toast, `ChangeHighlight announce`).
|
|
21
27
|
*/
|
|
22
|
-
declare function Count({ value, format, className, ...props }: CountProps): react.JSX.Element;
|
|
28
|
+
declare function Count({ value, format, arrive, className, ...props }: CountProps): react.JSX.Element;
|
|
23
29
|
|
|
24
30
|
export { Count, type CountProps };
|
package/dist/components/Count.js
CHANGED
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useRef } from "react";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "../cx.js";
|
|
5
|
-
|
|
5
|
+
import { prefersReducedMotion } from "../hooks/useReducedMotion.js";
|
|
6
|
+
import { tokenMs } from "../motion.js";
|
|
7
|
+
import { useArrive } from "./Arrive.js";
|
|
8
|
+
const easeOut = (t) => 1 - (1 - t) ** 3;
|
|
9
|
+
function Count({ value, format, arrive = false, className, ...props }) {
|
|
6
10
|
const ref = useRef(null);
|
|
7
11
|
const previous = useRef(value);
|
|
12
|
+
const { playing } = useArrive();
|
|
13
|
+
const [rolling, setRolling] = useState(null);
|
|
14
|
+
const counted = useRef(false);
|
|
15
|
+
const countUp = arrive && playing && !counted.current && Number.isFinite(value) && value !== 0;
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const el = ref.current;
|
|
18
|
+
if (!countUp || !el || prefersReducedMotion()) return void 0;
|
|
19
|
+
const index = Number.parseFloat(getComputedStyle(el).getPropertyValue("--uix-arrive-i")) || 0;
|
|
20
|
+
const delay = index * tokenMs("--uix-stagger-arrive", 45, el);
|
|
21
|
+
const duration = tokenMs("--uix-dur-arrive-count", 600, el);
|
|
22
|
+
const target = value;
|
|
23
|
+
let frame = 0;
|
|
24
|
+
let start = 0;
|
|
25
|
+
setRolling(0);
|
|
26
|
+
const step = (now) => {
|
|
27
|
+
if (!start) start = now + delay;
|
|
28
|
+
counted.current = true;
|
|
29
|
+
const t = Math.max(0, Math.min(1, (now - start) / duration));
|
|
30
|
+
setRolling(t >= 1 ? null : Math.round(target * easeOut(t)));
|
|
31
|
+
if (t < 1) frame = requestAnimationFrame(step);
|
|
32
|
+
};
|
|
33
|
+
frame = requestAnimationFrame(step);
|
|
34
|
+
return () => {
|
|
35
|
+
cancelAnimationFrame(frame);
|
|
36
|
+
setRolling(null);
|
|
37
|
+
};
|
|
38
|
+
}, [countUp]);
|
|
8
39
|
useEffect(() => {
|
|
9
40
|
const before = previous.current;
|
|
10
41
|
previous.current = value;
|
|
@@ -25,7 +56,8 @@ function Count({ value, format, className, ...props }) {
|
|
|
25
56
|
el.addEventListener("animationend", done);
|
|
26
57
|
return () => el.removeEventListener("animationend", done);
|
|
27
58
|
}, []);
|
|
28
|
-
|
|
59
|
+
const shown = rolling ?? value;
|
|
60
|
+
return /* @__PURE__ */ jsx("span", { ref, className: cx("uix-count", className), ...props, children: format ? format(shown) : shown.toLocaleString() });
|
|
29
61
|
}
|
|
30
62
|
export {
|
|
31
63
|
Count
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
import { ChartLabels, ChartEventHandler, ChartEngine } from './ChartCore.js';
|
|
4
|
+
import { GlanceLineInput, PairedBarsInput } from '../chart-glance.js';
|
|
5
|
+
import 'echarts';
|
|
6
|
+
import '../chart-theme.js';
|
|
7
|
+
|
|
8
|
+
/** The props every glance chart shares with Chart. */
|
|
9
|
+
interface GlanceChartBaseProps {
|
|
10
|
+
/** What the chart shows, in a sentence: its accessible name ("Offener Rückstand der letzten 12 Wochen …"). */
|
|
11
|
+
ariaLabel: string;
|
|
12
|
+
/** The header of the first column of the hidden data table ("Woche"). Default "Period". */
|
|
13
|
+
categoryLabel?: string;
|
|
14
|
+
/** Plot height in px. Default 150 (a line) or 140 (paired bars). */
|
|
15
|
+
height?: number;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
empty?: ReactNode;
|
|
20
|
+
labels?: Partial<ChartLabels>;
|
|
21
|
+
/** Charts with the same group share one crosshair and tooltip. */
|
|
22
|
+
group?: string;
|
|
23
|
+
onEvents?: Record<string, ChartEventHandler>;
|
|
24
|
+
}
|
|
25
|
+
interface GlanceLineChartProps extends GlanceLineInput, GlanceChartBaseProps {
|
|
26
|
+
}
|
|
27
|
+
interface WithEngine {
|
|
28
|
+
engine: ChartEngine;
|
|
29
|
+
}
|
|
30
|
+
/** Shared core: the line glance chart for a given ECharts build. */
|
|
31
|
+
declare function GlanceLineChartCore({ engine, ariaLabel, categoryLabel, height, className, style, loading, empty, labels, group, onEvents, ...input }: GlanceLineChartProps & WithEngine): react.JSX.Element;
|
|
32
|
+
interface PairedBarChartProps extends PairedBarsInput, GlanceChartBaseProps {
|
|
33
|
+
}
|
|
34
|
+
/** Shared core: the paired-bar glance chart for a given ECharts build. */
|
|
35
|
+
declare function PairedBarChartCore({ engine, ariaLabel, categoryLabel, height, className, style, loading, empty, labels, group, onEvents, ...input }: PairedBarChartProps & WithEngine): react.JSX.Element;
|
|
36
|
+
|
|
37
|
+
export { type GlanceChartBaseProps, GlanceLineChartCore, type GlanceLineChartProps, PairedBarChartCore, type PairedBarChartProps };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { ChartCore } from "./ChartCore.js";
|
|
5
|
+
import { useArrive, useArriveIndex } from "./Arrive.js";
|
|
6
|
+
import { GLANCE_AT_REST, PAIRED_BARS_MAX_BUCKETS, glanceLineOption, pairedBarsOption } from "../chart-glance.js";
|
|
7
|
+
import { tokenMs } from "../motion.js";
|
|
8
|
+
import { mergeChartTheme, uixChartTheme, uixChartTokens } from "../chart-theme.js";
|
|
9
|
+
import { prefersReducedMotion } from "../hooks/useReducedMotion.js";
|
|
10
|
+
function useGlanceMotion() {
|
|
11
|
+
const { playing } = useArrive();
|
|
12
|
+
const index = useArriveIndex();
|
|
13
|
+
const played = useRef(null);
|
|
14
|
+
const [settled, setSettled] = useState(false);
|
|
15
|
+
if (playing && !played.current) {
|
|
16
|
+
played.current = {
|
|
17
|
+
play: true,
|
|
18
|
+
delay: index * tokenMs("--uix-stagger-arrive", 45) + tokenMs("--uix-delay-arrive-trace", 150),
|
|
19
|
+
trace: tokenMs("--uix-dur-arrive-trace", 700),
|
|
20
|
+
grow: tokenMs("--uix-dur-arrive-grow", 500),
|
|
21
|
+
stagger: tokenMs("--uix-stagger-arrive-grow", 25)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const motion = played.current;
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!motion || settled) return void 0;
|
|
27
|
+
const drawIn = motion.delay + Math.max(motion.trace, motion.grow + motion.stagger * (PAIRED_BARS_MAX_BUCKETS - 1));
|
|
28
|
+
const timer = setTimeout(() => setSettled(true), drawIn + 50);
|
|
29
|
+
return () => clearTimeout(timer);
|
|
30
|
+
}, [motion, settled]);
|
|
31
|
+
return motion && !settled ? motion : GLANCE_AT_REST;
|
|
32
|
+
}
|
|
33
|
+
function useDrawInWhenPlayed(motion, build) {
|
|
34
|
+
const chart = useRef(null);
|
|
35
|
+
const atRestWhenDrawn = useRef(false);
|
|
36
|
+
const motionNow = useRef(motion);
|
|
37
|
+
motionNow.current = motion;
|
|
38
|
+
const buildNow = useRef(build);
|
|
39
|
+
buildNow.current = build;
|
|
40
|
+
const onReady = useCallback((instance) => {
|
|
41
|
+
chart.current = instance;
|
|
42
|
+
atRestWhenDrawn.current = !motionNow.current.play;
|
|
43
|
+
}, []);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const instance = chart.current;
|
|
46
|
+
if (!motion.play || !instance || instance.isDisposed() || !atRestWhenDrawn.current) return;
|
|
47
|
+
atRestWhenDrawn.current = false;
|
|
48
|
+
if (prefersReducedMotion()) return;
|
|
49
|
+
const element = instance.getDom();
|
|
50
|
+
instance.clear();
|
|
51
|
+
instance.setOption(mergeChartTheme(uixChartTheme(element), buildNow.current(uixChartTokens(element), motion)));
|
|
52
|
+
}, [motion]);
|
|
53
|
+
return onReady;
|
|
54
|
+
}
|
|
55
|
+
function GlanceLineChartCore({ engine, ariaLabel, categoryLabel = "Period", height = 150, className, style, loading, empty, labels, group, onEvents, ...input }) {
|
|
56
|
+
const motion = useGlanceMotion();
|
|
57
|
+
const { categories, values, name, forecast, endLabel, area, format, tooltipTitle } = input;
|
|
58
|
+
const build = (k, m) => glanceLineOption(k, { categories, values, name, forecast, endLabel, area, format, tooltipTitle }, m);
|
|
59
|
+
const onReady = useDrawInWhenPlayed(motion, build);
|
|
60
|
+
const option = useMemo(
|
|
61
|
+
() => (k) => build(k, motion),
|
|
62
|
+
// a new array with the same numbers is the same chart
|
|
63
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
+
[JSON.stringify(categories), JSON.stringify(values), name, JSON.stringify(forecast), endLabel, area, format, tooltipTitle, motion]
|
|
65
|
+
);
|
|
66
|
+
const headers = [categoryLabel, name, ...forecast ? [forecast.name] : []];
|
|
67
|
+
const rows = [
|
|
68
|
+
...categories.map((c, i) => ({ [categoryLabel]: c, [name]: values[i] ?? "" })),
|
|
69
|
+
...forecast ? forecast.categories.map((c, i) => ({ [categoryLabel]: c, [name]: "", [forecast.name]: forecast.values[i] ?? "" })) : []
|
|
70
|
+
];
|
|
71
|
+
return /* @__PURE__ */ jsx(
|
|
72
|
+
ChartCore,
|
|
73
|
+
{
|
|
74
|
+
engine,
|
|
75
|
+
option,
|
|
76
|
+
ariaLabel,
|
|
77
|
+
tableHeaders: headers,
|
|
78
|
+
tableData: rows,
|
|
79
|
+
height,
|
|
80
|
+
className,
|
|
81
|
+
style,
|
|
82
|
+
loading,
|
|
83
|
+
empty,
|
|
84
|
+
labels,
|
|
85
|
+
group,
|
|
86
|
+
onEvents,
|
|
87
|
+
onReady
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
function PairedBarChartCore({ engine, ariaLabel, categoryLabel = "Period", height = 140, className, style, loading, empty, labels, group, onEvents, ...input }) {
|
|
92
|
+
const motion = useGlanceMotion();
|
|
93
|
+
const { categories, series, comparison, format, tooltipTitle } = input;
|
|
94
|
+
if (categories.length > PAIRED_BARS_MAX_BUCKETS && typeof console !== "undefined") {
|
|
95
|
+
console.warn(`[uix] PairedBarChart reads at a glance up to ${PAIRED_BARS_MAX_BUCKETS} buckets; it has ${categories.length}. Use a line, or move it to a report.`);
|
|
96
|
+
}
|
|
97
|
+
const build = (k, m) => pairedBarsOption(k, { categories, series, comparison, format, tooltipTitle }, m);
|
|
98
|
+
const onReady = useDrawInWhenPlayed(motion, build);
|
|
99
|
+
const option = useMemo(
|
|
100
|
+
() => (k) => build(k, motion),
|
|
101
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
|
+
[JSON.stringify(categories), JSON.stringify(series), JSON.stringify(comparison), format, tooltipTitle, motion]
|
|
103
|
+
);
|
|
104
|
+
const rows = categories.map((c, i) => ({ [categoryLabel]: c, [series.name]: series.values[i] ?? "", [comparison.name]: comparison.values[i] ?? "" }));
|
|
105
|
+
return /* @__PURE__ */ jsx(
|
|
106
|
+
ChartCore,
|
|
107
|
+
{
|
|
108
|
+
engine,
|
|
109
|
+
option,
|
|
110
|
+
ariaLabel,
|
|
111
|
+
tableHeaders: [categoryLabel, series.name, comparison.name],
|
|
112
|
+
tableData: rows,
|
|
113
|
+
height,
|
|
114
|
+
className,
|
|
115
|
+
style,
|
|
116
|
+
loading,
|
|
117
|
+
empty,
|
|
118
|
+
labels,
|
|
119
|
+
group,
|
|
120
|
+
onEvents,
|
|
121
|
+
onReady
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
GlanceLineChartCore,
|
|
127
|
+
PairedBarChartCore
|
|
128
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode, SVGAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
interface BarListItem {
|
|
5
|
+
/** Stable key; defaults to the position. */
|
|
6
|
+
id?: string;
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
value: number;
|
|
9
|
+
/** What the value column shows; default the number in the runtime locale. */
|
|
10
|
+
display?: ReactNode;
|
|
11
|
+
/** `series` (default, the series blue), `comparison` (grey) or `warning` (a bucket that needs a look). */
|
|
12
|
+
tone?: 'series' | 'comparison' | 'warning';
|
|
13
|
+
}
|
|
14
|
+
interface BarListProps extends HTMLAttributes<HTMLUListElement> {
|
|
15
|
+
items: BarListItem[];
|
|
16
|
+
/** The value of a full bar. Default the largest value. */
|
|
17
|
+
max?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One row per bucket: its label, a bar and its value ("Wie alt ist der Rückstand?": four age
|
|
21
|
+
* buckets). Every value is written out, so the bars are decoration for the eye; a bar above zero
|
|
22
|
+
* is never thinner than 2 %, so a 1 next to an 82 still shows.
|
|
23
|
+
*/
|
|
24
|
+
declare function BarList({ items, max, className, ...props }: BarListProps): react.JSX.Element;
|
|
25
|
+
type StatusStripTone = 'ok' | 'warning' | 'critical' | 'unknown';
|
|
26
|
+
interface StatusStripItem {
|
|
27
|
+
id: string;
|
|
28
|
+
label: ReactNode;
|
|
29
|
+
tone: StatusStripTone;
|
|
30
|
+
/** The state in words for the affected list: "eingeschränkt", "gestört". */
|
|
31
|
+
state?: ReactNode;
|
|
32
|
+
}
|
|
33
|
+
interface StatusStripProps extends HTMLAttributes<HTMLDivElement> {
|
|
34
|
+
items: StatusStripItem[];
|
|
35
|
+
/** What the strip says as a whole, for assistive technology: "9 von 12 Diensten in Betrieb". */
|
|
36
|
+
summary: string;
|
|
37
|
+
/** List the services that are not ok under the strip (default true). */
|
|
38
|
+
listAffected?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* One cell per service, then only the affected ones by name ("Laufen die Dienste?"): the strip
|
|
42
|
+
* is the glance, the list is the answer. Critical services come first, then degraded, then
|
|
43
|
+
* unknown; healthy ones are only cells.
|
|
44
|
+
*/
|
|
45
|
+
declare function StatusStrip({ items, summary, listAffected, className, ...props }: StatusStripProps): react.JSX.Element;
|
|
46
|
+
interface SparklineProps extends Omit<SVGAttributes<SVGSVGElement>, 'values'> {
|
|
47
|
+
values: number[];
|
|
48
|
+
/** Width in px. Default 86. */
|
|
49
|
+
width?: number;
|
|
50
|
+
/** Height in px. Default 24. */
|
|
51
|
+
height?: number;
|
|
52
|
+
/** `ink` (default): a muted line with an ink endpoint. `series`: the series blue. */
|
|
53
|
+
tone?: 'ink' | 'series';
|
|
54
|
+
/**
|
|
55
|
+
* What the line says ("Rückstand der letzten 11 Wochen, von 20 auf 85"). Without it the
|
|
56
|
+
* sparkline is decoration (`aria-hidden`): say the number beside it in words.
|
|
57
|
+
*/
|
|
58
|
+
label?: string;
|
|
59
|
+
}
|
|
60
|
+
/** A trend line without axes, beside a number: an ink-grey line and a dot on the latest value. */
|
|
61
|
+
declare function Sparkline({ values, width, height, tone, label, className, ...props }: SparklineProps): react.JSX.Element;
|
|
62
|
+
|
|
63
|
+
export { BarList, type BarListItem, type BarListProps, Sparkline, type SparklineProps, StatusStrip, type StatusStripItem, type StatusStripProps, type StatusStripTone };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../cx.js";
|
|
3
|
+
import { StatusDot } from "./StatusDot.js";
|
|
4
|
+
function BarList({ items, max, className, ...props }) {
|
|
5
|
+
const top = max ?? Math.max(0, ...items.map((item) => item.value));
|
|
6
|
+
return /* @__PURE__ */ jsx("ul", { className: cx("uix-bar-list", className), ...props, children: items.map((item, index) => {
|
|
7
|
+
const share = top > 0 ? Math.max(0, Math.min(1, item.value / top)) : 0;
|
|
8
|
+
const val = item.value > 0 ? Math.max(share, 0.02) : 0;
|
|
9
|
+
return /* @__PURE__ */ jsxs("li", { className: "uix-bar-list__row", "data-tone": item.tone && item.tone !== "series" ? item.tone : void 0, children: [
|
|
10
|
+
/* @__PURE__ */ jsx("span", { className: "uix-bar-list__label", children: item.label }),
|
|
11
|
+
/* @__PURE__ */ jsx("span", { className: "uix-bar-list__track", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "uix-bar-list__bar uix-arrive__grow", style: { "--val": val, "--uix-arrive-j": index } }) }),
|
|
12
|
+
/* @__PURE__ */ jsx("span", { className: "uix-bar-list__value", children: item.display ?? item.value.toLocaleString() })
|
|
13
|
+
] }, item.id ?? index);
|
|
14
|
+
}) });
|
|
15
|
+
}
|
|
16
|
+
const STRIP_DOT = { ok: "success", warning: "warning", critical: "critical", unknown: "neutral" };
|
|
17
|
+
function StatusStrip({ items, summary, listAffected = true, className, ...props }) {
|
|
18
|
+
const rank = { critical: 0, warning: 1, unknown: 2, ok: 3 };
|
|
19
|
+
const affected = items.filter((item) => item.tone !== "ok").sort((a, b) => rank[a.tone] - rank[b.tone]);
|
|
20
|
+
return /* @__PURE__ */ jsxs("div", { className: cx("uix-status-strip", className), ...props, children: [
|
|
21
|
+
/* @__PURE__ */ jsx("div", { className: "uix-status-strip__cells", role: "img", "aria-label": summary, children: items.map((item) => /* @__PURE__ */ jsx("span", { className: "uix-status-strip__cell", "data-tone": item.tone }, item.id)) }),
|
|
22
|
+
listAffected && affected.length > 0 && /* @__PURE__ */ jsx("ul", { className: "uix-status-strip__list", children: affected.map((item) => /* @__PURE__ */ jsxs("li", { className: "uix-status-strip__item", children: [
|
|
23
|
+
/* @__PURE__ */ jsx(StatusDot, { tone: STRIP_DOT[item.tone], quiet: true, className: "uix-status-strip__name", children: item.label }),
|
|
24
|
+
item.state != null && /* @__PURE__ */ jsx("span", { className: "uix-status-strip__state", children: item.state })
|
|
25
|
+
] }, item.id)) })
|
|
26
|
+
] });
|
|
27
|
+
}
|
|
28
|
+
function Sparkline({ values, width = 86, height = 24, tone = "ink", label, className, ...props }) {
|
|
29
|
+
const finite = values.filter((v) => Number.isFinite(v));
|
|
30
|
+
const pad = 3;
|
|
31
|
+
const min = Math.min(...finite);
|
|
32
|
+
const max = Math.max(...finite);
|
|
33
|
+
const x = (i) => values.length < 2 ? width / 2 : pad + i * (width - 2 * pad) / (values.length - 1);
|
|
34
|
+
const y = (v) => height - pad - (v - min) / (max - min || 1) * (height - 2 * pad);
|
|
35
|
+
const points = values.map((v, i) => [x(i), y(v)]).filter((_, i) => Number.isFinite(values[i]));
|
|
36
|
+
const d = points.map(([px, py], i) => `${i ? "L" : "M"}${px.toFixed(1)} ${py.toFixed(1)}`).join(" ");
|
|
37
|
+
const last = points[points.length - 1];
|
|
38
|
+
return /* @__PURE__ */ jsxs(
|
|
39
|
+
"svg",
|
|
40
|
+
{
|
|
41
|
+
className: cx("uix-sparkline", tone === "series" && "uix-sparkline--series", className),
|
|
42
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
43
|
+
width,
|
|
44
|
+
height,
|
|
45
|
+
...label ? { role: "img", "aria-label": label } : { "aria-hidden": true },
|
|
46
|
+
focusable: "false",
|
|
47
|
+
...props,
|
|
48
|
+
children: [
|
|
49
|
+
points.length > 1 && /* @__PURE__ */ jsx("path", { className: "uix-sparkline__line uix-arrive__trace", d, pathLength: 1 }),
|
|
50
|
+
last && /* @__PURE__ */ jsx("circle", { className: "uix-sparkline__end", cx: last[0], cy: last[1], r: 2.5 })
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
BarList,
|
|
57
|
+
Sparkline,
|
|
58
|
+
StatusStrip
|
|
59
|
+
};
|
|
@@ -16,8 +16,18 @@ interface MeterProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
16
16
|
label?: string;
|
|
17
17
|
/** TENSOR RX-125 (UIX-04): the spoken tone words; English defaults. */
|
|
18
18
|
toneLabels?: Partial<Record<Exclude<MeterTone, 'success' | 'neutral' | 'accent'>, string>>;
|
|
19
|
+
/**
|
|
20
|
+
* A goal on the same 0–100 scale (calm kit 2.56): a thin ink mark across the track, so
|
|
21
|
+
* "42 %, target 95 %" reads from the bar itself. Clamped to 0–100.
|
|
22
|
+
*/
|
|
23
|
+
target?: number;
|
|
24
|
+
/** How the target is said after the value, e.g. "Ziel 95 %". Default `target ${target}%`. */
|
|
25
|
+
targetLabel?: string;
|
|
19
26
|
}
|
|
20
|
-
/**
|
|
21
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Horizontal utilization / threshold bar backed by `.uix-meter`. Inside an `Arrive` stage the
|
|
29
|
+
* fill slides in from its start edge on the first paint (`.uix-arrive__slide`).
|
|
30
|
+
*/
|
|
31
|
+
declare function Meter({ value, tone, label, toneLabels, target, targetLabel, className, ...props }: MeterProps): react.JSX.Element;
|
|
22
32
|
|
|
23
33
|
export { Meter, type MeterProps, type MeterTone };
|
package/dist/components/Meter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from "../cx.js";
|
|
3
3
|
const toneText = {
|
|
4
4
|
warning: "warning",
|
|
@@ -6,10 +6,23 @@ const toneText = {
|
|
|
6
6
|
attention: "needs attention",
|
|
7
7
|
overdue: "overdue"
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
const clamp = (n) => Math.max(0, Math.min(100, n));
|
|
10
|
+
function Meter({ value = 0, tone, label, toneLabels, target, targetLabel, className, ...props }) {
|
|
10
11
|
const spoken = { ...toneText, ...toneLabels };
|
|
11
|
-
const pct =
|
|
12
|
+
const pct = clamp(value);
|
|
12
13
|
const toneWord = tone ? spoken[tone] : void 0;
|
|
14
|
+
const hasTarget = typeof target === "number" && Number.isFinite(target);
|
|
15
|
+
const goal = hasTarget ? clamp(target) : 0;
|
|
16
|
+
const goalWords = hasTarget ? targetLabel ?? `target ${goal}%` : void 0;
|
|
17
|
+
const valueText = [toneWord || goalWords ? `${pct}%` : null, toneWord, goalWords].filter(Boolean).join(", ");
|
|
18
|
+
const fill = /* @__PURE__ */ jsx(
|
|
19
|
+
"div",
|
|
20
|
+
{
|
|
21
|
+
className: "uix-meter__fill uix-arrive__slide",
|
|
22
|
+
style: { "--val": pct / 100 },
|
|
23
|
+
...tone && tone !== "success" ? { "data-tone": tone } : {}
|
|
24
|
+
}
|
|
25
|
+
);
|
|
13
26
|
return /* @__PURE__ */ jsx(
|
|
14
27
|
"div",
|
|
15
28
|
{
|
|
@@ -17,18 +30,15 @@ function Meter({ value = 0, tone, label, toneLabels, className, ...props }) {
|
|
|
17
30
|
"aria-valuenow": pct,
|
|
18
31
|
"aria-valuemin": 0,
|
|
19
32
|
"aria-valuemax": 100,
|
|
20
|
-
"aria-valuetext":
|
|
33
|
+
"aria-valuetext": valueText || void 0,
|
|
21
34
|
"aria-label": label,
|
|
22
|
-
className: cx("uix-meter", className),
|
|
35
|
+
className: cx("uix-meter", hasTarget && "uix-meter--target", className),
|
|
23
36
|
...props,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
...tone && tone !== "success" ? { "data-tone": tone } : {}
|
|
30
|
-
}
|
|
31
|
-
)
|
|
37
|
+
style: hasTarget ? { "--target": goal / 100, ...props.style } : props.style,
|
|
38
|
+
children: hasTarget ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx("div", { className: "uix-meter__clip", children: fill }),
|
|
40
|
+
/* @__PURE__ */ jsx("span", { className: "uix-meter__target", "aria-hidden": "true" })
|
|
41
|
+
] }) : fill
|
|
32
42
|
}
|
|
33
43
|
);
|
|
34
44
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The signal ladder of a glance page (calm kit 2.56): `neutral` (a fact, in ink), `info`
|
|
6
|
+
* (selected, unread, new), `warning` (drifting: a deadline within two hours, a value under its
|
|
7
|
+
* target, a degraded service) and `critical` (broken now and yours to act on). `success` is for
|
|
8
|
+
* a service list that says "in Betrieb". `danger` is an alias of `critical`.
|
|
9
|
+
*/
|
|
10
|
+
type StatusDotTone = 'neutral' | 'info' | 'success' | 'warning' | 'critical' | 'danger';
|
|
11
|
+
interface StatusDotProps extends HTMLAttributes<HTMLSpanElement> {
|
|
12
|
+
tone?: StatusDotTone;
|
|
13
|
+
/** The word in ink and only the dot in the tone's hue: a list of services, a key line. */
|
|
14
|
+
quiet?: boolean;
|
|
15
|
+
size?: 'sm' | 'md';
|
|
16
|
+
/** The word. A dot without one says nothing to anyone who cannot see the hue. */
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A dot and a word, no box (calm kit 2.56). The quiet default for status on a glance page,
|
|
21
|
+
* in place of a solid red pill: "Läuft gerade", "SLA seit 2 Std. überschritten", "eingeschränkt".
|
|
22
|
+
* The words wear the tone's text role (AA on the surface and on its tint), the dot its solid role
|
|
23
|
+
* (≥ 3:1). It never pulses. For a status in a table cell use `StatusPill treatment="dot"`.
|
|
24
|
+
*/
|
|
25
|
+
declare function StatusDot({ tone, quiet, size, className, children, ...props }: StatusDotProps): react.JSX.Element;
|
|
26
|
+
|
|
27
|
+
export { StatusDot, type StatusDotProps, type StatusDotTone };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../cx.js";
|
|
3
|
+
function StatusDot({ tone = "neutral", quiet = false, size = "md", className, children, ...props }) {
|
|
4
|
+
const resolved = tone === "danger" ? "critical" : tone;
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
"span",
|
|
7
|
+
{
|
|
8
|
+
className: cx("uix-status-dot", `uix-status-dot--${resolved}`, quiet && "uix-status-dot--quiet", size === "sm" && "uix-status-dot--sm", className),
|
|
9
|
+
...props,
|
|
10
|
+
children
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
StatusDot
|
|
16
|
+
};
|
package/dist/icons/Icon.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
8
8
|
filter?: string | undefined | undefined;
|
|
9
9
|
values?: string | undefined | undefined;
|
|
10
10
|
fill: string;
|
|
11
|
+
radius?: number | string | undefined | undefined;
|
|
11
12
|
color?: string | undefined | undefined;
|
|
12
13
|
fontStyle?: number | string | undefined | undefined;
|
|
13
14
|
fontWeight?: number | string | undefined | undefined;
|
|
@@ -32,7 +33,6 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
32
33
|
x?: number | string | undefined | undefined;
|
|
33
34
|
cursor?: number | string | undefined | undefined;
|
|
34
35
|
id?: string | undefined | undefined;
|
|
35
|
-
radius?: number | string | undefined | undefined;
|
|
36
36
|
from?: number | string | undefined | undefined;
|
|
37
37
|
y?: number | string | undefined | undefined;
|
|
38
38
|
slope?: number | string | undefined | undefined;
|
|
@@ -269,13 +269,15 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
269
269
|
clip?: number | string | undefined | undefined;
|
|
270
270
|
stroke: string;
|
|
271
271
|
href?: string | undefined | undefined;
|
|
272
|
+
mask?: string | undefined | undefined;
|
|
273
|
+
path?: string | undefined | undefined;
|
|
274
|
+
key?: react.Key | null | undefined;
|
|
275
|
+
format?: number | string | undefined | undefined;
|
|
272
276
|
d?: string | undefined | undefined;
|
|
273
277
|
capHeight?: number | string | undefined | undefined;
|
|
274
278
|
dy?: number | string | undefined | undefined;
|
|
275
279
|
dx?: number | string | undefined | undefined;
|
|
276
280
|
transform?: string | undefined | undefined;
|
|
277
|
-
mask?: string | undefined | undefined;
|
|
278
|
-
path?: string | undefined | undefined;
|
|
279
281
|
method?: string | undefined | undefined;
|
|
280
282
|
crossOrigin?: "" | "anonymous" | "use-credentials" | undefined;
|
|
281
283
|
accentHeight?: number | string | undefined | undefined;
|
|
@@ -330,7 +332,6 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
330
332
|
fontSizeAdjust?: number | string | undefined | undefined;
|
|
331
333
|
fontStretch?: number | string | undefined | undefined;
|
|
332
334
|
fontVariant?: number | string | undefined | undefined;
|
|
333
|
-
format?: number | string | undefined | undefined;
|
|
334
335
|
fr?: number | string | undefined | undefined;
|
|
335
336
|
fx?: number | string | undefined | undefined;
|
|
336
337
|
fy?: number | string | undefined | undefined;
|
|
@@ -477,7 +478,6 @@ declare function renderIcon(node: IconNode, { size, tone, label, strokeWidth, cl
|
|
|
477
478
|
y2?: number | string | undefined | undefined;
|
|
478
479
|
yChannelSelector?: string | undefined | undefined;
|
|
479
480
|
zoomAndPan?: string | undefined | undefined;
|
|
480
|
-
key?: react.Key | null | undefined;
|
|
481
481
|
ref: unknown;
|
|
482
482
|
strokeWidth: string | number;
|
|
483
483
|
className: string;
|