@tensor_1/react 2.56.0 → 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.
package/README.md CHANGED
@@ -922,6 +922,32 @@ A full-screen media viewer (HAR-1367; TENSOR's capture viewer, MOTUS's programme
922
922
  - **Attachment:** the name is the link (`href`, `download`, `renderLink`). It has a quieter `meta` line, a `state` slot (e.g. a "Scanning" `StatusPill`), `actions`, `onRemove`, and `status` `loading` | `error` | `forbidden` (no link, and the reason shown). It's server-renderable.
923
923
  - Pure helpers: `formatFileSize`, `fileMatchesAccept`, `partitionFiles`, `fileKind`.
924
924
 
925
+ ### File kit: kinds, the file row and the slim drop row (2.57.0)
926
+
927
+ Attachments that show what they are before you read the name, and an upload you can watch (variation H of the 2026-11-05 attachments study; TENSOR's Anhänge panel). Each kind of file has a hue (`--uix-file-<kind>`) and a Lucide glyph; a row's left edge carries the kind's tint, and that tint becomes the upload fill.
928
+
929
+ ```tsx
930
+ <section ref={panel} aria-labelledby="files-h">
931
+ <h3 id="files-h">Anhänge</h3>
932
+ <FileDrop targetRef={panel} accept=".pdf,.log,image/*" onFiles={(files) => files.forEach(startUpload)} />
933
+ <ul className="uix-file-rows">
934
+ {files.map((f) => (
935
+ <FileRow key={f.id} as="li" density="compact" name={f.name} size={f.size} meta={`${f.by}, ${f.at}`}
936
+ state={f.state} progress={f.progress} href={f.url}
937
+ onMoreActions={(e) => openMenu(f, e.currentTarget)} onCancel={() => cancel(f)} onRetry={() => retry(f)} />
938
+ ))}
939
+ </ul>
940
+ </section>
941
+ ```
942
+
943
+ - **Kinds:** `fileKind(name, mime)` gives one of `img` Bild, `doc` Dokument, `sheet` Tabelle, `mail` E-Mail, `code` Code & Konfiguration, `log` Protokoll, `archive` Archiv, `other` Datei. A known extension wins over the MIME type (a `.log` arrives as `text/plain`); pass `''` as the name when only the type is known, as in a drag event. The lists are `FILE_KIND_EXTENSIONS`. None of the hues is red (red stays for broken) and none is the brand blue (blue stays for actions); in light five of them are the calm chart slots.
944
+ - **`FileKindIcon`:** the glyph in the kind's colour with the extension (`fileTypeLabel`: at most four capitals) as a solid label on the corner, ringed in the surface colour. `size` `sm` 30 px (a compact row), `md` 34 px, `lg` 52 px. Decorative unless you pass `label`. It is server-renderable. (`FileIcon` in `./icons` is the plain `file` glyph, hence the name.)
945
+ - **`FileRow` states:** `idle` (files that were already there), `uploading` (the fill scales to `progress`, 0 to 1, or `loaded / size`, with a thin leading edge; "Wird hochgeladen · 62 % · 1,5 von 2,4 MB" and Abbrechen with `onCancel`), `done` (just finished: a check draws on the icon and the fill fades over 1.2 s; render `idle` afterwards), `scanning` ("Wird auf Schadsoftware geprüft", no motion), `blocked` (amber, Details with `onDetails`) and `failed` (red, Erneut versuchen with `onRetry`). `message` replaces the words of the last two. The outcome of an upload is announced once, never the progress.
946
+ - **Actions:** `href` makes the download a link (`download` sets the saved name), or pass `onDownload`; `onMoreActions` adds "Weitere Aktionen" for your `Menu`; `actions` replaces both. With a fine pointer they appear on hover and focus; on touch they are always there.
947
+ - **`FileDrop`:** one dashed line, "Dateien ablegen oder auswählen", backed by a real file input. The choose button is the one tab stop and opens the chooser; a click anywhere on the row does too. While files are dragged over it (or over `targetRef`, such as the whole panel), it reads their MIME types and names them ("2 Dateien: Bild, Protokoll") and tints itself from the pointer outwards, one colour per kind. A drop hands the files that match `accept` to `onFiles` and the rest to `onReject`.
948
+ - **Motion:** tokens only, transform and opacity, nothing loops. Under reduced motion the fill jumps and the check only fades.
949
+ - **Words:** German by default. For English pass `FILE_ROW_LABELS_EN`, `FILE_DROP_LABELS_EN` and `FILE_KIND_LABELS_EN` to `UixLabelsProvider` (`fileRow`, `fileDrop`, `fileKinds`) or to one instance's `labels` / `kindLabels`. Sizes use `formatFileSize` in `locale` (default `de-DE`), `sizeBase` or `formatSize`.
950
+
925
951
  ### TextDiff
926
952
 
927
953
  A two-way diff of two texts (HAR-1368; TENSOR's knowledge-article version diff). `DiffViewer` stays the three-way configuration diff.
@@ -293,6 +293,18 @@
293
293
  "name": "Field",
294
294
  "subpath": "."
295
295
  },
296
+ {
297
+ "name": "FileDrop",
298
+ "subpath": "."
299
+ },
300
+ {
301
+ "name": "FileKindIcon",
302
+ "subpath": "."
303
+ },
304
+ {
305
+ "name": "FileRow",
306
+ "subpath": "."
307
+ },
296
308
  {
297
309
  "name": "FileUpload",
298
310
  "subpath": "."
@@ -1257,6 +1269,10 @@
1257
1269
  "name": "FileCheckIcon",
1258
1270
  "subpath": "./icons"
1259
1271
  },
1272
+ {
1273
+ "name": "FileCodeIcon",
1274
+ "subpath": "./icons"
1275
+ },
1260
1276
  {
1261
1277
  "name": "FileDownIcon",
1262
1278
  "subpath": "./icons"
@@ -1289,6 +1305,10 @@
1289
1305
  "name": "FileSpreadsheetIcon",
1290
1306
  "subpath": "./icons"
1291
1307
  },
1308
+ {
1309
+ "name": "FileTerminalIcon",
1310
+ "subpath": "./icons"
1311
+ },
1292
1312
  {
1293
1313
  "name": "FileTextIcon",
1294
1314
  "subpath": "./icons"
@@ -4,7 +4,7 @@ import { formatFileSize } from "../file-model.js";
4
4
  import { renderUixLink } from "../link.js";
5
5
  import { DEFAULT_ATTACHMENT_LABELS } from "../attachment-labels.js";
6
6
  import { AttachmentRemoveButton, AttachmentText } from "./AttachmentParts.js";
7
- import { FileIcon } from "./FileIcon.js";
7
+ import { FileGlyph } from "./FileGlyph.js";
8
8
  function Attachment({
9
9
  name,
10
10
  size,
@@ -39,7 +39,7 @@ function Attachment({
39
39
  ...download ? { download: typeof download === "string" ? download : "" } : {}
40
40
  }) : /* @__PURE__ */ jsx("span", { className: "uix-attachment__name", children: name });
41
41
  return /* @__PURE__ */ jsxs("li", { className: cx("uix-attachment", className), "data-status": status === "ready" ? void 0 : status, "aria-busy": status === "loading" || void 0, ...props, children: [
42
- /* @__PURE__ */ jsx("span", { className: "uix-attachment__icon", "aria-hidden": "true", children: thumbnail ?? /* @__PURE__ */ jsx(FileIcon, { name, type }) }),
42
+ /* @__PURE__ */ jsx("span", { className: "uix-attachment__icon", "aria-hidden": "true", children: thumbnail ?? /* @__PURE__ */ jsx(FileGlyph, { name, type }) }),
43
43
  /* @__PURE__ */ jsxs("span", { className: "uix-attachment__body", children: [
44
44
  /* @__PURE__ */ jsxs("span", { className: "uix-attachment__line", children: [
45
45
  nameNode,
@@ -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 };