@tensor_1/react 2.55.3 → 2.57.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.
Files changed (66) hide show
  1. package/README.md +68 -0
  2. package/component-inventory.json +64 -0
  3. package/dist/{ChartCore-BKK2HEfi.d.cts → ChartCore-CY5a4teJ.d.cts} +18 -2
  4. package/dist/GlanceCharts-Cb39RqDC.d.cts +88 -0
  5. package/dist/chart-analytic-guide.d.ts +1 -0
  6. package/dist/chart-analytic-guide.js +6 -1
  7. package/dist/chart-analytic.cjs +11 -1
  8. package/dist/chart-analytic.d.cts +2 -2
  9. package/dist/chart-glance.d.ts +65 -0
  10. package/dist/chart-glance.js +162 -0
  11. package/dist/chart-preset.cjs +337 -5
  12. package/dist/chart-preset.d.cts +9 -3
  13. package/dist/chart-preset.d.ts +8 -1
  14. package/dist/chart-preset.js +16 -1
  15. package/dist/chart-theme.d.ts +18 -2
  16. package/dist/chart-theme.js +6 -1
  17. package/dist/chart.cjs +337 -5
  18. package/dist/chart.d.cts +9 -3
  19. package/dist/chart.d.ts +3 -1
  20. package/dist/chart.js +9 -2
  21. package/dist/components/Arrive.d.ts +49 -0
  22. package/dist/components/Arrive.js +93 -0
  23. package/dist/components/Attachment.js +2 -2
  24. package/dist/components/Chart.d.ts +8 -1
  25. package/dist/components/Chart.js +16 -1
  26. package/dist/components/ChartCard.d.ts +34 -0
  27. package/dist/components/ChartCard.js +36 -0
  28. package/dist/components/ChartPanels.js +5 -0
  29. package/dist/components/Count.d.ts +10 -4
  30. package/dist/components/Count.js +35 -3
  31. package/dist/components/FileDrop.d.ts +51 -0
  32. package/dist/components/FileDrop.js +183 -0
  33. package/dist/components/FileGlyph.d.ts +9 -0
  34. package/dist/components/{FileIcon.js → FileGlyph.js} +2 -2
  35. package/dist/components/FileKindIcon.d.ts +36 -0
  36. package/dist/components/FileKindIcon.js +48 -0
  37. package/dist/components/FileRow.d.ts +102 -0
  38. package/dist/components/FileRow.js +164 -0
  39. package/dist/components/FileUpload.js +2 -2
  40. package/dist/components/GlanceCharts.d.ts +37 -0
  41. package/dist/components/GlanceCharts.js +128 -0
  42. package/dist/components/GlanceMarks.d.ts +63 -0
  43. package/dist/components/GlanceMarks.js +59 -0
  44. package/dist/components/Heartbeat.d.ts +5 -5
  45. package/dist/components/Meter.d.ts +12 -2
  46. package/dist/components/Meter.js +23 -13
  47. package/dist/components/StatusDot.d.ts +27 -0
  48. package/dist/components/StatusDot.js +16 -0
  49. package/dist/file-model.d.ts +41 -3
  50. package/dist/file-model.js +65 -1
  51. package/dist/icons/Icon.d.ts +5 -5
  52. package/dist/icons/components.d.ts +3 -1
  53. package/dist/icons/components.js +4 -0
  54. package/dist/icons/glyphs.d.ts +5 -1
  55. package/dist/icons/glyphs.js +6 -0
  56. package/dist/icons.cjs +10 -0
  57. package/dist/icons.d.cts +7 -25
  58. package/dist/icons.d.ts +1 -1
  59. package/dist/index.cjs +2807 -2099
  60. package/dist/index.d.cts +399 -15
  61. package/dist/index.d.ts +9 -1
  62. package/dist/index.js +41 -1
  63. package/dist/labels-context.d.ts +9 -1
  64. package/dist/types-B593xJNf.d.cts +26 -0
  65. package/package.json +1 -1
  66. package/dist/components/FileIcon.d.ts +0 -9
@@ -0,0 +1,164 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
4
+ import { announcePolite } from "../announce.js";
5
+ import { cx } from "../cx.js";
6
+ import { fillLabel } from "../fill-label.js";
7
+ import { DEFAULT_FILE_KIND_LABELS, fileKind, formatFileSize } from "../file-model.js";
8
+ import { DownloadIcon, EllipsisIcon, XIcon } from "../icons/components.js";
9
+ import { useUixLabels } from "../labels-context.js";
10
+ import { Button } from "./Button.js";
11
+ import { FileKindIcon } from "./FileKindIcon.js";
12
+ const DEFAULT_FILE_ROW_LABELS = {
13
+ download: "{name} herunterladen",
14
+ more: "Weitere Aktionen f\xFCr {name}",
15
+ cancel: "Hochladen von {name} abbrechen",
16
+ uploading: "Wird hochgeladen",
17
+ percent: "{percent} %",
18
+ transferred: "{loaded} von {total}",
19
+ progress: "{name} wird hochgeladen",
20
+ done: "{name} hochgeladen",
21
+ scanning: "Wird auf Schadsoftware gepr\xFCft",
22
+ blocked: "Gesperrt: Schadsoftware gefunden. Nicht gespeichert.",
23
+ failed: "Hochladen fehlgeschlagen. Verbindung unterbrochen.",
24
+ details: "Details",
25
+ retry: "Erneut versuchen"
26
+ };
27
+ const FILE_ROW_LABELS_EN = {
28
+ download: "Download {name}",
29
+ more: "More actions for {name}",
30
+ cancel: "Cancel uploading {name}",
31
+ uploading: "Uploading",
32
+ percent: "{percent}%",
33
+ transferred: "{loaded} of {total}",
34
+ progress: "Uploading {name}",
35
+ done: "{name} uploaded",
36
+ scanning: "Checking for malware",
37
+ blocked: "Blocked: malware found. Not saved.",
38
+ failed: "Upload failed. The connection was interrupted.",
39
+ details: "Details",
40
+ retry: "Try again"
41
+ };
42
+ const clamp = (value) => Math.min(1, Math.max(0, value));
43
+ function FileRow({
44
+ name,
45
+ mime,
46
+ kind,
47
+ typeLabel,
48
+ size,
49
+ meta,
50
+ state = "idle",
51
+ progress,
52
+ loaded,
53
+ message,
54
+ href,
55
+ download,
56
+ onDownload,
57
+ onMoreActions,
58
+ actions,
59
+ onCancel,
60
+ onRetry,
61
+ onDetails,
62
+ density = "default",
63
+ as: Root = "div",
64
+ locale = "de-DE",
65
+ sizeBase,
66
+ formatSize,
67
+ labels: labelsProp,
68
+ kindLabels: kindLabelsProp,
69
+ className,
70
+ style,
71
+ ...props
72
+ }) {
73
+ const provided = useUixLabels();
74
+ const labels = { ...DEFAULT_FILE_ROW_LABELS, ...provided.fileRow, ...labelsProp };
75
+ const kindLabels = { ...DEFAULT_FILE_KIND_LABELS, ...provided.fileKinds, ...kindLabelsProp };
76
+ const resolved = kind ?? fileKind(name, mime);
77
+ const sizeText = (bytes) => formatSize ? formatSize(bytes, locale) : formatFileSize(bytes, locale, { base: sizeBase });
78
+ const ratio = clamp(progress ?? (loaded !== void 0 && size ? loaded / size : 0));
79
+ const percent = Math.round(ratio * 100);
80
+ const rootRef = useRef(null);
81
+ const previous = useRef(state);
82
+ useEffect(() => {
83
+ if (previous.current === state) return;
84
+ previous.current = state;
85
+ const words = state === "done" ? fillLabel(labels.done, { name }) : state === "blocked" ? typeof message === "string" ? message : labels.blocked : state === "failed" ? typeof message === "string" ? message : labels.failed : "";
86
+ if (words) announcePolite(state === "done" ? words : `${name}: ${words}`, rootRef.current);
87
+ }, [state, name, message, labels.done, labels.blocked, labels.failed]);
88
+ let line;
89
+ if (state === "uploading") {
90
+ const parts = [labels.uploading, fillLabel(labels.percent, { percent })];
91
+ if (size !== void 0) {
92
+ const total = sizeText(size);
93
+ let done = sizeText(loaded ?? ratio * size);
94
+ const unit = total.slice(total.lastIndexOf(" "));
95
+ if (unit.length > 1 && done.endsWith(unit)) done = done.slice(0, -unit.length);
96
+ parts.push(fillLabel(labels.transferred, { loaded: done, total }));
97
+ }
98
+ line = parts.join(" \xB7 ");
99
+ } else if (state === "scanning") line = labels.scanning;
100
+ else if (state === "blocked") line = message ?? labels.blocked;
101
+ else if (state === "failed") line = message ?? labels.failed;
102
+ else {
103
+ line = /* @__PURE__ */ jsxs(Fragment, { children: [
104
+ /* @__PURE__ */ jsx("span", { className: "uix-file-row__kind", children: kindLabels[resolved] }),
105
+ size !== void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
106
+ " \xB7 ",
107
+ sizeText(size)
108
+ ] }),
109
+ meta != null && meta !== false && /* @__PURE__ */ jsxs(Fragment, { children: [
110
+ " \xB7 ",
111
+ meta
112
+ ] })
113
+ ] });
114
+ }
115
+ let tools = null;
116
+ if (state === "uploading") {
117
+ tools = onCancel && /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", icon: true, className: "uix-file-row__keep", "aria-label": fillLabel(labels.cancel, { name }), onClick: onCancel, children: /* @__PURE__ */ jsx(XIcon, { size: "sm" }) });
118
+ } else if (state === "blocked") {
119
+ tools = onDetails && /* @__PURE__ */ jsx(Button, { type: "button", size: "xs", variant: "secondary", className: "uix-file-row__keep", onClick: onDetails, children: labels.details });
120
+ } else if (state === "failed") {
121
+ tools = onRetry && /* @__PURE__ */ jsx(Button, { type: "button", size: "xs", variant: "secondary", className: "uix-file-row__keep", onClick: onRetry, children: labels.retry });
122
+ } else if (state !== "scanning") {
123
+ tools = actions ?? /* @__PURE__ */ jsxs(Fragment, { children: [
124
+ href ? /* @__PURE__ */ jsx("a", { className: "uix-btn uix-btn--ghost uix-btn--sm uix-btn--icon", href, download: download ?? true, "aria-label": fillLabel(labels.download, { name }), onClick: onDownload, children: /* @__PURE__ */ jsx(DownloadIcon, { size: "sm" }) }) : onDownload && /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", icon: true, "aria-label": fillLabel(labels.download, { name }), onClick: onDownload, children: /* @__PURE__ */ jsx(DownloadIcon, { size: "sm" }) }),
125
+ onMoreActions && /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", icon: true, "aria-label": fillLabel(labels.more, { name }), "aria-haspopup": "menu", onClick: onMoreActions, children: /* @__PURE__ */ jsx(EllipsisIcon, { size: "sm" }) })
126
+ ] });
127
+ }
128
+ const filling = state === "uploading" || state === "done";
129
+ return /* @__PURE__ */ jsxs(
130
+ Root,
131
+ {
132
+ ref: rootRef,
133
+ className: cx("uix-file-row", density === "compact" && "uix-file-row--compact", className),
134
+ "data-file-kind": resolved,
135
+ "data-state": state,
136
+ style: filling ? { "--file-progress": state === "done" ? 1 : ratio, ...style } : style,
137
+ ...props,
138
+ children: [
139
+ filling && /* @__PURE__ */ jsx(
140
+ "span",
141
+ {
142
+ className: "uix-file-row__fill",
143
+ ...state === "uploading" ? { role: "progressbar", "aria-label": fillLabel(labels.progress, { name }), "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": percent } : { "aria-hidden": true }
144
+ }
145
+ ),
146
+ state === "uploading" && /* @__PURE__ */ jsx("span", { className: "uix-file-row__edge", "aria-hidden": "true" }),
147
+ /* @__PURE__ */ jsxs("span", { className: "uix-file-row__icon", children: [
148
+ /* @__PURE__ */ jsx(FileKindIcon, { name, kind: resolved, typeLabel, size: density === "compact" ? "sm" : "md" }),
149
+ state === "done" && /* @__PURE__ */ jsx("span", { className: "uix-file-row__check", "aria-hidden": "true", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 12 12", children: /* @__PURE__ */ jsx("path", { d: "M2.5 6.2 5 8.5l4.5-5", pathLength: 1 }) }) })
150
+ ] }),
151
+ /* @__PURE__ */ jsxs("span", { className: "uix-file-row__text", children: [
152
+ /* @__PURE__ */ jsx("span", { className: "uix-file-row__name", title: name, children: name }),
153
+ /* @__PURE__ */ jsx("span", { className: "uix-file-row__meta", children: line })
154
+ ] }),
155
+ tools && /* @__PURE__ */ jsx("span", { className: "uix-file-row__actions", children: tools })
156
+ ]
157
+ }
158
+ );
159
+ }
160
+ export {
161
+ DEFAULT_FILE_ROW_LABELS,
162
+ FILE_ROW_LABELS_EN,
163
+ FileRow
164
+ };
@@ -8,7 +8,7 @@ import { useUixLabels } from "../labels-context.js";
8
8
  import { Button } from "./Button.js";
9
9
  import { Input } from "./Input.js";
10
10
  import { Progress } from "./Progress.js";
11
- import { FileIcon } from "./FileIcon.js";
11
+ import { FileGlyph } from "./FileGlyph.js";
12
12
  const DEFAULT_FILE_UPLOAD_LABELS = {
13
13
  title: "Drop files here",
14
14
  choose: "Choose files",
@@ -120,7 +120,7 @@ function FileUpload({
120
120
  const statusText = item.status === "uploading" ? fillLabel(labels.uploading, { progress: item.progress ?? 0 }) : item.status === "done" ? labels.done : item.status === "error" ? labels.failed : labels.queued;
121
121
  const image = !!item.previewUrl;
122
122
  return /* @__PURE__ */ jsxs("li", { className: "uix-filelist__item uix-file-upload__item", "data-status": item.status, children: [
123
- image ? /* @__PURE__ */ jsx("img", { className: "uix-file-upload__thumb", src: item.previewUrl, alt: "" }) : /* @__PURE__ */ jsx("span", { className: "uix-attachment__icon", children: /* @__PURE__ */ jsx(FileIcon, { name: item.name, type: item.type }) }),
123
+ image ? /* @__PURE__ */ jsx("img", { className: "uix-file-upload__thumb", src: item.previewUrl, alt: "" }) : /* @__PURE__ */ jsx("span", { className: "uix-attachment__icon", children: /* @__PURE__ */ jsx(FileGlyph, { name: item.name, type: item.type }) }),
124
124
  /* @__PURE__ */ jsxs("div", { className: "uix-file-upload__body", children: [
125
125
  /* @__PURE__ */ jsx("span", { className: "uix-file-upload__name", children: item.name }),
126
126
  /* @__PURE__ */ jsxs("span", { className: "uix-file-upload__meta", children: [
@@ -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
+ };
@@ -4,8 +4,8 @@ import { HTMLAttributes, ReactNode } from 'react';
4
4
  type HeartbeatState = 'live' | 'idle' | 'warning' | 'danger';
5
5
  interface HeartbeatProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
6
6
  /**
7
- * `live` (default): a green dot with a pulsing ring. `warning` / `danger`: the same in that
8
- * tone. `idle`: a grey dot, no ring.
7
+ * `live` (default): a green dot. `warning` / `danger`: the same in that tone. `idle`: a grey
8
+ * dot. The dot is still (2.57): say the state in words beside it.
9
9
  */
10
10
  state?: HeartbeatState;
11
11
  /**
@@ -15,9 +15,9 @@ interface HeartbeatProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children
15
15
  label?: string;
16
16
  }
17
17
  /**
18
- * The pulsing status dot over `.uix-heartbeat` (HAR-1606), so products stop hand-writing its
19
- * three spans. Decorative unless it has a `label`. The ring stops under
20
- * `prefers-reduced-motion` (the kit's global motion guard); the dot and its colour stay.
18
+ * The status dot over `.uix-heartbeat` (HAR-1606), so products stop hand-writing its spans.
19
+ * Decorative unless it has a `label`. Still since 2.57 (Rules for apps: no pulsing on status);
20
+ * the ring span is kept in the markup for compatibility and is not drawn.
21
21
  */
22
22
  declare function Heartbeat({ state, label, className, ...props }: HeartbeatProps): react.JSX.Element;
23
23
  interface LiveIndicatorProps extends HTMLAttributes<HTMLSpanElement> {
@@ -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
- /** Horizontal utilization / threshold bar backed by `.uix-meter`. */
21
- declare function Meter({ value, tone, label, toneLabels, className, ...props }: MeterProps): react.JSX.Element;
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 };
@@ -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
- function Meter({ value = 0, tone, label, toneLabels, className, ...props }) {
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 = Math.max(0, Math.min(100, value));
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": toneWord ? `${pct}%, ${toneWord}` : void 0,
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
- children: /* @__PURE__ */ jsx(
25
- "div",
26
- {
27
- className: "uix-meter__fill",
28
- style: { "--val": pct / 100 },
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
+ };