@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,34 @@
1
+ import * as react from 'react';
2
+ import { HTMLAttributes, ReactNode } from 'react';
3
+
4
+ interface ChartCardProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
5
+ /** The title is a question a person would ask in passing: "Wächst der Rückstand?". */
6
+ question: ReactNode;
7
+ /** The answer's number, large: `85`, `+22`, or `<Count arrive value={85} />`. */
8
+ headline?: ReactNode;
9
+ /** The rest of the answer, short: "offen, Prognose 140 bis 23. Nov.". */
10
+ answer?: ReactNode;
11
+ /** A link or a small control at the end of the question row ("Berichte →"). */
12
+ action?: ReactNode;
13
+ /** One line under the chart: what it covers, what the dashes mean, the key of a paired chart. */
14
+ note?: ReactNode;
15
+ /**
16
+ * When there is nothing to show, one sentence instead of the answer and the chart
17
+ * ("Keine Wartung in den nächsten 14 Tagen."); the card shrinks to fit it.
18
+ */
19
+ empty?: ReactNode;
20
+ /** Heading level of the question. Default 3. */
21
+ headingLevel?: 2 | 3 | 4;
22
+ /** Its reading-order position in an `Arrive` stage: the card rises with the others. */
23
+ arriveIndex?: number;
24
+ /** The one chart: a `GlanceLineChart`, a `PairedBarChart`, a `BarList`, a `Meter`, a `StatusStrip`. */
25
+ children?: ReactNode;
26
+ }
27
+ /**
28
+ * A glance card (calm kit 2.56): one question, answered with a number before the plot, one
29
+ * chart, a note line. The question names the card (`aria-labelledby`). Analysis that needs
30
+ * reading time belongs in a report, not here.
31
+ */
32
+ declare function ChartCard({ question, headline, answer, action, note, empty, headingLevel, arriveIndex, className, style, children, ...props }: ChartCardProps): react.JSX.Element;
33
+
34
+ export { ChartCard, type ChartCardProps };
@@ -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. Tabular figures, so neighbours do not shift.
19
- * Under reduced motion it only fades. It announces nothing: say what changed where it
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 };
@@ -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
- function Count({ value, format, className, ...props }) {
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
- return /* @__PURE__ */ jsx("span", { ref, className: cx("uix-count", className), ...props, children: format ? format(value) : value.toLocaleString() });
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,51 @@
1
+ import * as react from 'react';
2
+ import { HTMLAttributes, RefObject } from 'react';
3
+ import { FileKindLabels } from '../file-model.js';
4
+
5
+ /** The words of a `FileDrop`, German by default. */
6
+ interface FileDropLabels {
7
+ /** The resting sentence. `{choose}` is where the choose button sits. */
8
+ prompt: string;
9
+ /** The choose button's visible word. */
10
+ choose: string;
11
+ /** The choose button's full name (it contains `choose`, WCAG 2.5.3). */
12
+ chooseLabel: string;
13
+ /** One file being dragged. */
14
+ fileOne: string;
15
+ /** `{count}` files being dragged. */
16
+ fileMany: string;
17
+ /** While dragging, with known kinds. `{files}`: `fileOne`/`fileMany`; `{kinds}`: the kind names. */
18
+ dragSummary: string;
19
+ /** While dragging, when the browser says nothing about the files. */
20
+ dragRelease: string;
21
+ }
22
+ declare const DEFAULT_FILE_DROP_LABELS: FileDropLabels;
23
+ /** The English words, for `labels` or `UixLabelsProvider` (`fileDrop`). */
24
+ declare const FILE_DROP_LABELS_EN: FileDropLabels;
25
+ interface FileDropProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onDrop'> {
26
+ /** The chosen or dropped files that match `accept`. */
27
+ onFiles: (files: File[]) => void;
28
+ /** Dropped files that do not match `accept` (the chooser never offers them). */
29
+ onReject?: (files: File[]) => void;
30
+ /** Accepted types, as for `<input accept>`. */
31
+ accept?: string;
32
+ /** Default `true`. With `false`, the first file only. */
33
+ multiple?: boolean;
34
+ disabled?: boolean;
35
+ /**
36
+ * A larger element that takes the drop as well, such as the whole attachments panel. The row
37
+ * still shows what is being dragged.
38
+ */
39
+ targetRef?: RefObject<HTMLElement | null>;
40
+ labels?: Partial<FileDropLabels>;
41
+ kindLabels?: Partial<FileKindLabels>;
42
+ }
43
+ /**
44
+ * A one-line drop row (file kit 2.57, the slim `FileDrop`): "Dateien ablegen oder auswählen",
45
+ * backed by a real file input. While files are dragged over it, before the drop, it names what
46
+ * they are from their MIME types ("2 Dateien: Bild, Protokoll") and tints itself from the
47
+ * pointer outwards, one kind colour per kind. The choose button is the keyboard path.
48
+ */
49
+ declare function FileDrop({ onFiles, onReject, accept, multiple, disabled, targetRef, labels: labelsProp, kindLabels: kindLabelsProp, className, ...props }: FileDropProps): react.JSX.Element;
50
+
51
+ export { DEFAULT_FILE_DROP_LABELS, FILE_DROP_LABELS_EN, FileDrop, type FileDropLabels, type FileDropProps };
@@ -0,0 +1,183 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { cx } from "../cx.js";
5
+ import { fillLabel } from "../fill-label.js";
6
+ import { DEFAULT_FILE_KIND_LABELS, FILE_KINDS, fileKind, fileMatchesAccept } from "../file-model.js";
7
+ import { UploadIcon } from "../icons/components.js";
8
+ import { useUixLabels } from "../labels-context.js";
9
+ const DEFAULT_FILE_DROP_LABELS = {
10
+ prompt: "Dateien ablegen oder {choose}",
11
+ choose: "ausw\xE4hlen",
12
+ chooseLabel: "Dateien ausw\xE4hlen",
13
+ fileOne: "1 Datei",
14
+ fileMany: "{count} Dateien",
15
+ dragSummary: "{files}: {kinds}",
16
+ dragRelease: "Loslassen zum Hochladen"
17
+ };
18
+ const FILE_DROP_LABELS_EN = {
19
+ prompt: "Drop files or {choose}",
20
+ choose: "choose",
21
+ chooseLabel: "Choose files",
22
+ fileOne: "1 file",
23
+ fileMany: "{count} files",
24
+ dragSummary: "{files}: {kinds}",
25
+ dragRelease: "Release to upload"
26
+ };
27
+ function draggedKinds(data) {
28
+ if (!data) return { count: 0, kinds: [] };
29
+ const seen = /* @__PURE__ */ new Set();
30
+ let count = 0;
31
+ for (const item of Array.from(data.items ?? [])) {
32
+ if (item.kind !== "file") continue;
33
+ count += 1;
34
+ seen.add(fileKind("", item.type));
35
+ }
36
+ return { count, kinds: FILE_KINDS.filter((k) => seen.has(k)) };
37
+ }
38
+ const carriesFiles = (data) => !!data && Array.from(data.types ?? []).includes("Files");
39
+ function auraFor(kinds) {
40
+ const list = kinds.length ? kinds : ["other"];
41
+ const n = list.length;
42
+ const r = 46;
43
+ return list.map((k, i) => {
44
+ const a = i / n * Math.PI * 2 - Math.PI / 2;
45
+ const dx = n > 1 ? Math.round(Math.cos(a) * r) : 0;
46
+ const dy = n > 1 ? Math.round(Math.sin(a) * r) : 0;
47
+ return `radial-gradient(circle at calc(var(--file-drop-x, 50%) + ${dx}px) calc(var(--file-drop-y, 50%) + ${dy}px), color-mix(in srgb, var(--uix-file-${k}) 30%, transparent), transparent 62%)`;
48
+ }).join(", ");
49
+ }
50
+ function FileDrop({
51
+ onFiles,
52
+ onReject,
53
+ accept,
54
+ multiple = true,
55
+ disabled = false,
56
+ targetRef,
57
+ labels: labelsProp,
58
+ kindLabels: kindLabelsProp,
59
+ className,
60
+ ...props
61
+ }) {
62
+ const provided = useUixLabels();
63
+ const labels = { ...DEFAULT_FILE_DROP_LABELS, ...provided.fileDrop, ...labelsProp };
64
+ const kindLabels = { ...DEFAULT_FILE_KIND_LABELS, ...provided.fileKinds, ...kindLabelsProp };
65
+ const rootRef = useRef(null);
66
+ const inputRef = useRef(null);
67
+ const [drag, setDrag] = useState(null);
68
+ const take = useRef(() => {
69
+ });
70
+ take.current = (list) => {
71
+ const files = Array.from(list ?? []);
72
+ if (!files.length) return;
73
+ const picked = multiple ? files : files.slice(0, 1);
74
+ const accepted = picked.filter((f) => fileMatchesAccept(f, accept));
75
+ const rejected = picked.filter((f) => !fileMatchesAccept(f, accept));
76
+ if (accepted.length) onFiles(accepted);
77
+ if (rejected.length) onReject?.(rejected);
78
+ };
79
+ useEffect(() => {
80
+ const target = targetRef?.current ?? rootRef.current;
81
+ if (!target || disabled) return void 0;
82
+ let depth = 0;
83
+ const point = (event) => {
84
+ const root = rootRef.current;
85
+ if (!root) return;
86
+ const box = root.getBoundingClientRect();
87
+ root.style.setProperty("--file-drop-x", `${Math.round(event.clientX - box.left)}px`);
88
+ root.style.setProperty("--file-drop-y", `${Math.round(event.clientY - box.top)}px`);
89
+ };
90
+ const enter = (event) => {
91
+ if (!carriesFiles(event.dataTransfer)) return;
92
+ event.preventDefault();
93
+ depth += 1;
94
+ if (depth === 1) setDrag(draggedKinds(event.dataTransfer));
95
+ point(event);
96
+ };
97
+ const over = (event) => {
98
+ if (!carriesFiles(event.dataTransfer)) return;
99
+ event.preventDefault();
100
+ if (event.dataTransfer) event.dataTransfer.dropEffect = "copy";
101
+ point(event);
102
+ };
103
+ const leave = () => {
104
+ if (depth === 0) return;
105
+ depth -= 1;
106
+ if (depth === 0) setDrag(null);
107
+ };
108
+ const drop = (event) => {
109
+ if (!carriesFiles(event.dataTransfer)) return;
110
+ event.preventDefault();
111
+ depth = 0;
112
+ setDrag(null);
113
+ take.current(event.dataTransfer?.files ?? null);
114
+ };
115
+ target.addEventListener("dragenter", enter);
116
+ target.addEventListener("dragover", over);
117
+ target.addEventListener("dragleave", leave);
118
+ target.addEventListener("drop", drop);
119
+ return () => {
120
+ target.removeEventListener("dragenter", enter);
121
+ target.removeEventListener("dragover", over);
122
+ target.removeEventListener("dragleave", leave);
123
+ target.removeEventListener("drop", drop);
124
+ setDrag(null);
125
+ };
126
+ }, [targetRef, disabled]);
127
+ const [before, after = ""] = labels.prompt.split("{choose}");
128
+ let summary = null;
129
+ if (drag) {
130
+ const files = drag.count === 1 ? labels.fileOne : fillLabel(labels.fileMany, { count: drag.count });
131
+ const named = drag.kinds.filter((k) => k !== "other" || drag.kinds.length > 1);
132
+ summary = drag.count === 0 ? labels.dragRelease : named.length ? fillLabel(labels.dragSummary, { files, kinds: named.map((k) => kindLabels[k]).join(", ") }) : files;
133
+ }
134
+ return /* @__PURE__ */ jsxs(
135
+ "div",
136
+ {
137
+ ref: rootRef,
138
+ className: cx("uix-file-drop", className),
139
+ "data-dragging": drag ? "" : void 0,
140
+ "data-disabled": disabled ? "" : void 0,
141
+ "data-file-kind": drag ? drag.kinds[0] ?? "other" : void 0,
142
+ onClick: (event) => {
143
+ if (disabled || event.target.closest("button, a, input")) return;
144
+ inputRef.current?.click();
145
+ },
146
+ ...props,
147
+ children: [
148
+ /* @__PURE__ */ jsx("span", { className: "uix-file-drop__aura", "aria-hidden": "true", style: drag ? { backgroundImage: auraFor(drag.kinds) } : void 0 }),
149
+ /* @__PURE__ */ jsx(UploadIcon, { size: "sm", className: "uix-file-drop__icon" }),
150
+ /* @__PURE__ */ jsxs("span", { className: "uix-file-drop__line", children: [
151
+ /* @__PURE__ */ jsxs("span", { className: "uix-file-drop__text", children: [
152
+ before,
153
+ /* @__PURE__ */ jsx("button", { type: "button", className: "uix-file-drop__choose", "aria-label": labels.chooseLabel, disabled, onClick: () => inputRef.current?.click(), children: labels.choose }),
154
+ after
155
+ ] }),
156
+ /* @__PURE__ */ jsx("span", { className: "uix-file-drop__summary", "aria-hidden": "true", children: summary })
157
+ ] }),
158
+ /* @__PURE__ */ jsx(
159
+ "input",
160
+ {
161
+ ref: inputRef,
162
+ type: "file",
163
+ className: "uix-visually-hidden",
164
+ tabIndex: -1,
165
+ "aria-hidden": "true",
166
+ accept,
167
+ multiple,
168
+ disabled,
169
+ onChange: (event) => {
170
+ take.current(event.currentTarget.files);
171
+ event.currentTarget.value = "";
172
+ }
173
+ }
174
+ )
175
+ ]
176
+ }
177
+ );
178
+ }
179
+ export {
180
+ DEFAULT_FILE_DROP_LABELS,
181
+ FILE_DROP_LABELS_EN,
182
+ FileDrop
183
+ };
@@ -0,0 +1,9 @@
1
+ import * as react from 'react';
2
+
3
+ /** A decorative glyph for a file's kind (Lucide-style strokes). Internal to FileUpload and Attachment (the public kind icon is FileIcon, file kit 2.57). */
4
+ declare function FileGlyph({ name, type }: {
5
+ name: string;
6
+ type?: string;
7
+ }): react.JSX.Element;
8
+
9
+ export { FileGlyph };
@@ -9,9 +9,9 @@ const PATHS = {
9
9
  text: "M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8zM14 3v5h5M8 13h8M8 17h8",
10
10
  other: "M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8zM14 3v5h5"
11
11
  };
12
- function FileIcon({ name, type }) {
12
+ function FileGlyph({ name, type }) {
13
13
  return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: PATHS[fileKind({ name, type })] }) });
14
14
  }
15
15
  export {
16
- FileIcon
16
+ FileGlyph
17
17
  };
@@ -0,0 +1,36 @@
1
+ import * as react from 'react';
2
+ import { HTMLAttributes } from 'react';
3
+ import { FileKind } from '../file-model.js';
4
+ import { UixIcon } from '../icons/types.js';
5
+
6
+ /** The Lucide glyph of each kind. E-Mail keeps the envelope: Lucide has no file-shaped mail icon. */
7
+ declare const FILE_KIND_GLYPHS: Readonly<Record<FileKind, UixIcon>>;
8
+ /** `md` 34 px (a list row), `sm` 30 px (a compact panel row), `lg` 52 px. */
9
+ type FileKindIconSize = 'sm' | 'md' | 'lg';
10
+ interface FileKindIconProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
11
+ /** The file name; gives the kind (by extension) and the type label. */
12
+ name?: string;
13
+ /** The MIME type; gives the kind when the name has no known extension (a drag event). */
14
+ mime?: string;
15
+ /** Sets the kind outright instead of reading it from `name` and `mime`. */
16
+ kind?: FileKind;
17
+ /**
18
+ * The type label on the corner. Default: the extension in capitals, at most four letters
19
+ * (`fileTypeLabel`). `""` hides it.
20
+ */
21
+ typeLabel?: string;
22
+ size?: FileKindIconSize;
23
+ /**
24
+ * An accessible name ("PDF-Dokument"). Without one the icon is decorative (`aria-hidden`):
25
+ * a `FileRow` already says the name and the kind in words.
26
+ */
27
+ label?: string;
28
+ }
29
+ /**
30
+ * A file's kind at a glance (file kit 2.57, variation H): the kind's Lucide glyph in the kind's
31
+ * colour (`--uix-file-<kind>`), with the type as a small solid label on its bottom-right corner,
32
+ * ringed in the surface colour. Server-renderable; it has no words of its own.
33
+ */
34
+ declare function FileKindIcon({ name, mime, kind, typeLabel, size, label, className, ...props }: FileKindIconProps): react.JSX.Element;
35
+
36
+ export { FILE_KIND_GLYPHS, FileKindIcon, type FileKindIconProps, type FileKindIconSize };
@@ -0,0 +1,48 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { cx } from "../cx.js";
3
+ import { fileKind, fileTypeLabel } from "../file-model.js";
4
+ import {
5
+ FileArchiveIcon,
6
+ FileCodeIcon,
7
+ FileIcon,
8
+ FileImageIcon,
9
+ FileSpreadsheetIcon,
10
+ FileTerminalIcon,
11
+ FileTextIcon,
12
+ MailIcon
13
+ } from "../icons/components.js";
14
+ const FILE_KIND_GLYPHS = {
15
+ img: FileImageIcon,
16
+ doc: FileTextIcon,
17
+ sheet: FileSpreadsheetIcon,
18
+ mail: MailIcon,
19
+ code: FileCodeIcon,
20
+ log: FileTerminalIcon,
21
+ archive: FileArchiveIcon,
22
+ other: FileIcon
23
+ };
24
+ const STROKE = { sm: 1.5, md: 1.5, lg: 1.4 };
25
+ function FileKindIcon({ name = "", mime, kind, typeLabel, size = "md", label, className, ...props }) {
26
+ const resolved = kind ?? fileKind(name, mime);
27
+ const Glyph = FILE_KIND_GLYPHS[resolved];
28
+ const tag = (typeLabel ?? fileTypeLabel(name)).slice(0, 4).toUpperCase();
29
+ return /* @__PURE__ */ jsxs(
30
+ "span",
31
+ {
32
+ className: cx("uix-file-icon", size !== "md" && `uix-file-icon--${size}`, className),
33
+ "data-file-kind": resolved,
34
+ role: label ? "img" : void 0,
35
+ "aria-label": label || void 0,
36
+ "aria-hidden": label ? void 0 : true,
37
+ ...props,
38
+ children: [
39
+ /* @__PURE__ */ jsx(Glyph, { className: "uix-file-icon__glyph", strokeWidth: STROKE[size] }),
40
+ tag && /* @__PURE__ */ jsx("span", { className: "uix-file-icon__type", "data-length": tag.length, children: tag })
41
+ ]
42
+ }
43
+ );
44
+ }
45
+ export {
46
+ FILE_KIND_GLYPHS,
47
+ FileKindIcon
48
+ };
@@ -0,0 +1,102 @@
1
+ import * as react from 'react';
2
+ import { HTMLAttributes, ReactNode, MouseEvent } from 'react';
3
+ import { FileKind, FileSizeFormatter, FileKindLabels } from '../file-model.js';
4
+
5
+ /**
6
+ * Where a file is (file kit 2.57):
7
+ * - `idle`: at rest, the kind's tint on the left edge. Files that were already there.
8
+ * - `uploading`: a fill in the kind's colour grows to `progress`.
9
+ * - `done`: just finished. A check draws on the icon and the fill fades; render `idle` for a
10
+ * file that was already there, so the check only plays for the upload someone watched.
11
+ * - `scanning`: the malware check after the upload. Words only, no motion.
12
+ * - `blocked`: the check found something. Amber instead of the kind colour.
13
+ * - `failed`: the upload broke. Red instead of the kind colour.
14
+ */
15
+ type FileRowState = 'idle' | 'uploading' | 'done' | 'scanning' | 'blocked' | 'failed';
16
+ /** The words of a `FileRow`, German by default. `{name}` is the file name. */
17
+ interface FileRowLabels {
18
+ /** Download button. `{name}`. */
19
+ download: string;
20
+ /** "More actions" button. `{name}`. */
21
+ more: string;
22
+ /** Cancel button while uploading. `{name}`. */
23
+ cancel: string;
24
+ /** First part of the meta line while uploading. */
25
+ uploading: string;
26
+ /** `{percent}`. */
27
+ percent: string;
28
+ /** `{loaded}`, `{total}`: formatted sizes. */
29
+ transferred: string;
30
+ /** The progress bar's name. `{name}`. */
31
+ progress: string;
32
+ /** Said once when an upload finishes. `{name}`. */
33
+ done: string;
34
+ scanning: string;
35
+ blocked: string;
36
+ failed: string;
37
+ /** The button of a blocked file. */
38
+ details: string;
39
+ /** The button of a failed upload. */
40
+ retry: string;
41
+ }
42
+ declare const DEFAULT_FILE_ROW_LABELS: FileRowLabels;
43
+ /** The English words, for `labels` or `UixLabelsProvider` (`fileRow`). */
44
+ declare const FILE_ROW_LABELS_EN: FileRowLabels;
45
+ interface FileRowProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
46
+ /** The file name as people should read it. Long names end in an ellipsis; `title` has it whole. */
47
+ name: string;
48
+ /** The MIME type, for the kind when the name has no known extension. */
49
+ mime?: string;
50
+ /** Sets the kind outright instead of reading it from `name` and `mime`. */
51
+ kind?: FileKind;
52
+ /** The type label on the icon corner. Default: the extension, at most four letters. */
53
+ typeLabel?: string;
54
+ /** Bytes. */
55
+ size?: number;
56
+ /** Who added it and when ("Lena Brandt, vor 12 Min."), after the kind and the size. */
57
+ meta?: ReactNode;
58
+ state?: FileRowState;
59
+ /** Upload progress, 0 to 1. Default `loaded / size` when both are given. */
60
+ progress?: number;
61
+ /** Bytes uploaded so far. Default `progress × size`. */
62
+ loaded?: number;
63
+ /** Replaces the words of a `blocked` or `failed` row (the reason the server gave). */
64
+ message?: ReactNode;
65
+ /** Download link: the download button becomes `<a href download>`. */
66
+ href?: string;
67
+ /** Saves under this name instead of the URL's (with `href`). */
68
+ download?: string;
69
+ /** Download handler, when the download is not a plain link. */
70
+ onDownload?: () => void;
71
+ /** Shows a "Weitere Aktionen" button; open your `Menu` from it. */
72
+ onMoreActions?: (event: MouseEvent<HTMLButtonElement>) => void;
73
+ /** Replaces the resting actions (download, more). */
74
+ actions?: ReactNode;
75
+ /** Shows the cancel button while uploading. */
76
+ onCancel?: () => void;
77
+ /** Shows "Erneut versuchen" on a failed upload. */
78
+ onRetry?: () => void;
79
+ /** Shows "Details" on a blocked file. */
80
+ onDetails?: () => void;
81
+ /** `compact`: a 30 px icon and tighter padding, for a 340 px side panel. */
82
+ density?: 'default' | 'compact';
83
+ /** `li` inside a `<ul class="uix-file-rows">`. Default `div`. */
84
+ as?: 'div' | 'li';
85
+ locale?: string;
86
+ /** Count sizes in 1024s instead of 1000s. Default `1000`. */
87
+ sizeBase?: 1000 | 1024;
88
+ formatSize?: FileSizeFormatter;
89
+ /** Words for this row; each defaults to `UixLabelsProvider` `fileRow`, then German. */
90
+ labels?: Partial<FileRowLabels>;
91
+ /** Kind names for this row; each defaults to `UixLabelsProvider` `fileKinds`, then German. */
92
+ kindLabels?: Partial<FileKindLabels>;
93
+ }
94
+ /**
95
+ * One file in a list (file kit 2.57, variation H): the kind icon, the name, a meta line (kind
96
+ * in its colour · size · who and when) and actions that appear on hover or focus. At rest its
97
+ * left edge carries a tint of the kind's colour fading into the surface; while uploading the
98
+ * same tint grows to the real progress, and fades out when the upload finishes.
99
+ */
100
+ declare function FileRow({ name, mime, kind, typeLabel, size, meta, state, progress, loaded, message, href, download, onDownload, onMoreActions, actions, onCancel, onRetry, onDetails, density, as: Root, locale, sizeBase, formatSize, labels: labelsProp, kindLabels: kindLabelsProp, className, style, ...props }: FileRowProps): react.JSX.Element;
101
+
102
+ export { DEFAULT_FILE_ROW_LABELS, FILE_ROW_LABELS_EN, FileRow, type FileRowLabels, type FileRowProps, type FileRowState };