@midas-ds/components 17.35.0 → 17.36.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/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## 17.36.0 (2026-11-18)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **components,file-list:** allow preview for failed uploads ([9eefa45ed7b](https://github.com/migrationsverket/midas/commit/9eefa45ed7b))
6
+ - **components,file-list:** add an optional preview button ([cdce6cff9e3](https://github.com/migrationsverket/midas/commit/cdce6cff9e3))
7
+
8
+ ### 🏭 Refactoring
9
+
10
+ - **components,file-list:** move preview focus handling into the row ([7a53427809e](https://github.com/migrationsverket/midas/commit/7a53427809e))
11
+
12
+ ### 📖 Documentation changes
13
+
14
+ - **components,file-list:** describe all FileListItem props ([8d4a432c5c0](https://github.com/migrationsverket/midas/commit/8d4a432c5c0))
15
+
16
+ ### 🔧 Maintenance
17
+
18
+ - **components,file-list:** hide the modal preview story ([bb6cfe9063b](https://github.com/migrationsverket/midas/commit/bb6cfe9063b))
19
+
20
+ ### 🧪 Tests updated
21
+
22
+ - update visual regression screenshots ([0ce17025cfb](https://github.com/migrationsverket/midas/commit/0ce17025cfb))
23
+
1
24
  ## 17.35.0 (2026-11-17)
2
25
 
3
26
  ### 🚀 Features
@@ -1 +1 @@
1
- ._fileList_mb5n3_1{gap:var(--midas-space-small);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}._fileListItem_mb5n3_18{--file-list-success-duration:2s;flex-direction:column;display:flex}._row_mb5n3_25{background-color:var(--midas-layer-01-base);box-sizing:border-box;font-family:var(--midas-typography-font-family);height:var(--midas-size-control);transition:box-shadow var(--midas-transition-duration-fast) var(--midas-transition-timing-ease-out);align-items:center;padding-inline-start:var(--midas-space-medium);display:flex}._fileListItem_mb5n3_18[data-status=error] ._row_mb5n3_25{box-shadow:var(--midas-state-invalid)}._iconSlot_mb5n3_46{height:var(--midas-size-icon-sm);opacity:0;transition:margin-inline-end var(--midas-transition-duration-normal) var(--midas-transition-timing-ease-out), opacity var(--midas-transition-duration-normal) var(--midas-transition-timing-ease-out), width var(--midas-transition-duration-normal) var(--midas-transition-timing-ease-out);flex-shrink:0;width:0;margin-inline-end:0;position:relative}._fileListItem_mb5n3_18[data-status=uploading] ._iconSlot_mb5n3_46,._fileListItem_mb5n3_18[data-status=success] ._iconSlot_mb5n3_46{opacity:1;width:var(--midas-size-icon-sm);margin-inline-end:var(--midas-space-small)}._progressIcon_mb5n3_70{position:absolute;inset:0}._ring_mb5n3_82{border:2px solid var(--midas-icon-success);box-sizing:border-box;opacity:0;border-radius:50%;position:absolute;inset:0}._fileListItem_mb5n3_18[data-status=success] ._ring_mb5n3_82{animation:_successRing_mb5n3_1 var(--file-list-success-duration) var(--midas-transition-timing-ease-out) forwards}._checkmark_mb5n3_106{height:var(--midas-size-icon-sm);opacity:0;width:var(--midas-size-icon-sm);margin:auto;position:absolute;inset:0;transform:scale(.4)}._fileListItem_mb5n3_18[data-status=success] ._checkmark_mb5n3_106{animation:_successCheckmark_mb5n3_1 var(--file-list-success-duration) var(--midas-transition-timing-ease-out) forwards}._successIcon_mb5n3_121{color:var(--midas-icon-success)}@keyframes _successRing_mb5n3_1{0%,30%{opacity:1}55%,to{opacity:0}}@keyframes _successCheckmark_mb5n3_1{0%,30%{opacity:0;transform:scale(.4)}55%{opacity:1;transform:scale(.65)}65%,to{opacity:1;transform:scale(1)}}@media (prefers-reduced-motion:reduce){._row_mb5n3_25,._iconSlot_mb5n3_46,._ring_mb5n3_82,._checkmark_mb5n3_106,._errorReveal_mb5n3_163{transition-duration:1ms!important;animation-duration:1ms!important}}._fileInfo_mb5n3_169{align-items:baseline;gap:var(--midas-space-small);flex:1;min-width:0;display:flex}._fileName_mb5n3_177{color:var(--midas-text-primary);font-size:var(--midas-typography-font-size-30);font-weight:var(--midas-typography-weight-medium);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}._fileSize_mb5n3_186{color:var(--midas-text-secondary);font-size:var(--midas-typography-font-size-30);flex-shrink:0}._deleteButton_mb5n3_192{color:var(--midas-icon-primary);flex-shrink:0;margin-inline-start:var(--midas-space-small)}._errorReveal_mb5n3_163{max-height:0;transition:max-height var(--midas-transition-duration-normal) var(--midas-transition-timing-ease-out);overflow:clip}._fileListItem_mb5n3_18[data-status=error] ._errorReveal_mb5n3_163{max-height:6.25rem}
1
+ ._fileList_2pw69_1{gap:var(--midas-space-small);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}._fileListItem_2pw69_18{--file-list-success-duration:2s;flex-direction:column;display:flex}._row_2pw69_25{background-color:var(--midas-layer-01-base);box-sizing:border-box;font-family:var(--midas-typography-font-family);height:var(--midas-size-control);transition:box-shadow var(--midas-transition-duration-fast) var(--midas-transition-timing-ease-out);align-items:center;padding-inline-start:var(--midas-space-medium);display:flex}._fileListItem_2pw69_18[data-status=error] ._row_2pw69_25{box-shadow:var(--midas-state-invalid)}._iconSlot_2pw69_46{height:var(--midas-size-icon-sm);opacity:0;transition:margin-inline-end var(--midas-transition-duration-normal) var(--midas-transition-timing-ease-out), opacity var(--midas-transition-duration-normal) var(--midas-transition-timing-ease-out), width var(--midas-transition-duration-normal) var(--midas-transition-timing-ease-out);flex-shrink:0;width:0;margin-inline-end:0;position:relative}._fileListItem_2pw69_18[data-status=uploading] ._iconSlot_2pw69_46,._fileListItem_2pw69_18[data-status=success] ._iconSlot_2pw69_46{opacity:1;width:var(--midas-size-icon-sm);margin-inline-end:var(--midas-space-small)}._progressIcon_2pw69_70{position:absolute;inset:0}._ring_2pw69_82{border:2px solid var(--midas-icon-success);box-sizing:border-box;opacity:0;border-radius:50%;position:absolute;inset:0}._fileListItem_2pw69_18[data-status=success] ._ring_2pw69_82{animation:_successRing_2pw69_1 var(--file-list-success-duration) var(--midas-transition-timing-ease-out) forwards}._checkmark_2pw69_106{height:var(--midas-size-icon-sm);opacity:0;width:var(--midas-size-icon-sm);margin:auto;position:absolute;inset:0;transform:scale(.4)}._fileListItem_2pw69_18[data-status=success] ._checkmark_2pw69_106{animation:_successCheckmark_2pw69_1 var(--file-list-success-duration) var(--midas-transition-timing-ease-out) forwards}._successIcon_2pw69_121{color:var(--midas-icon-success)}@keyframes _successRing_2pw69_1{0%,30%{opacity:1}55%,to{opacity:0}}@keyframes _successCheckmark_2pw69_1{0%,30%{opacity:0;transform:scale(.4)}55%{opacity:1;transform:scale(.65)}65%,to{opacity:1;transform:scale(1)}}@media (prefers-reduced-motion:reduce){._row_2pw69_25,._iconSlot_2pw69_46,._ring_2pw69_82,._checkmark_2pw69_106,._errorReveal_2pw69_163{transition-duration:1ms!important;animation-duration:1ms!important}}._fileInfo_2pw69_169{align-items:baseline;gap:var(--midas-space-small);flex:1;min-width:0;display:flex}._fileName_2pw69_177{color:var(--midas-text-primary);font-size:var(--midas-typography-font-size-30);font-weight:var(--midas-typography-weight-medium);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}._fileSize_2pw69_186{color:var(--midas-text-secondary);font-size:var(--midas-typography-font-size-30);flex-shrink:0}._previewButton_2pw69_192,._deleteButton_2pw69_193{color:var(--midas-icon-primary);flex-shrink:0;margin-inline-start:var(--midas-space-small)}._errorReveal_2pw69_163{max-height:0;transition:max-height var(--midas-transition-duration-normal) var(--midas-transition-timing-ease-out);overflow:clip}._fileListItem_2pw69_18[data-status=error] ._errorReveal_2pw69_163{max-height:6.25rem}
@@ -0,0 +1,167 @@
1
+ 'use client';
2
+ import { t as e } from "./clsx-BtGY0yFD.js";
3
+ import { n as t } from "./button-BZHl22O1.js";
4
+ import { t as n } from "./progress-bar-BvueZ-dg.js";
5
+ import { t as r } from "./FeedbackStatusIcon-DX5ndhm3.js";
6
+ import { t as i } from "./field-error-CUYIkJWj.js";
7
+ import { t as a } from "./useLocalizedStringFormatter-DU97U9ZX.js";
8
+ import { useEffect as o, useId as s, useLayoutEffect as c, useRef as l } from "react";
9
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
10
+ import { Eye as p, Trash2 as m, X as h } from "lucide-react";
11
+ import { FocusScope as g, VisuallyHidden as _, useFocusManager as v } from "react-aria";
12
+ import '../assets/file-list.css';var y = {
13
+ fileList: "_fileList_2pw69_1",
14
+ fileListItem: "_fileListItem_2pw69_18",
15
+ row: "_row_2pw69_25",
16
+ iconSlot: "_iconSlot_2pw69_46",
17
+ progressIcon: "_progressIcon_2pw69_70",
18
+ ring: "_ring_2pw69_82",
19
+ successRing: "_successRing_2pw69_1",
20
+ checkmark: "_checkmark_2pw69_106",
21
+ successCheckmark: "_successCheckmark_2pw69_1",
22
+ successIcon: "_successIcon_2pw69_121",
23
+ errorReveal: "_errorReveal_2pw69_163",
24
+ fileInfo: "_fileInfo_2pw69_169",
25
+ fileName: "_fileName_2pw69_177",
26
+ fileSize: "_fileSize_2pw69_186",
27
+ previewButton: "_previewButton_2pw69_192",
28
+ deleteButton: "_deleteButton_2pw69_193"
29
+ }, b = ({ className: t, children: n, ...r }) => {
30
+ let i = l(null);
31
+ return /* @__PURE__ */ d(g, { children: /* @__PURE__ */ f("ul", {
32
+ ...r,
33
+ ref: i,
34
+ tabIndex: -1,
35
+ className: e(y.fileList, t),
36
+ children: [/* @__PURE__ */ d(x, { containerRef: i }), n]
37
+ }) });
38
+ }, x = ({ containerRef: e }) => {
39
+ let t = v(), n = l(t);
40
+ return o(() => {
41
+ n.current = t;
42
+ }), o(() => {
43
+ let t = e.current;
44
+ if (!t) return;
45
+ let r = new MutationObserver((e) => {
46
+ e.some((e) => e.removedNodes.length > 0) && document.activeElement === document.body && (n.current?.focusFirst({ tabbable: !0 }) || t.focus());
47
+ });
48
+ return r.observe(t, { childList: !0 }), () => r.disconnect();
49
+ }, [e]), null;
50
+ }, S = {
51
+ en: {
52
+ removeFile: "Remove",
53
+ cancelUpload: "Cancel",
54
+ uploading: "Uploading",
55
+ uploadComplete: "Upload complete",
56
+ uploadFailed: "Upload failed",
57
+ previewFile: "Preview"
58
+ },
59
+ sv: {
60
+ removeFile: "Ta bort",
61
+ cancelUpload: "Avbryt",
62
+ uploading: "Laddar upp",
63
+ uploadComplete: "Uppladdning klar",
64
+ uploadFailed: "Uppladdning misslyckades",
65
+ previewFile: "Förhandsgranska"
66
+ }
67
+ }, C = ({ fileName: o, fileSize: g, status: v = "idle", progress: b, errorMessage: x, onCancel: C, onDelete: T, onPreview: E, className: D }) => {
68
+ let O = a(S), k = v === "uploading", A = v === "success", j = v === "error", M = j && !!x, N = s(), P = s(), F = A ? O.format("uploadComplete") : j ? O.format("uploadFailed") : void 0, I = [F && P, M && N].filter(Boolean).join(" ") || void 0, L = k ? C ?? T : T, R = !!E && !k, z = l(null), B = l(!1);
69
+ return c(() => {
70
+ B.current && (B.current = !1, z.current?.focus());
71
+ }, [R]), /* @__PURE__ */ f("li", {
72
+ className: e(y.fileListItem, D),
73
+ "data-status": v,
74
+ children: [
75
+ /* @__PURE__ */ f("div", {
76
+ className: y.row,
77
+ children: [
78
+ /* @__PURE__ */ f("span", {
79
+ className: y.iconSlot,
80
+ children: [
81
+ k && /* @__PURE__ */ d(n, {
82
+ shape: "circular",
83
+ small: !0,
84
+ value: b,
85
+ isIndeterminate: b === void 0,
86
+ "aria-label": `${O.format("uploading")} ${o}`,
87
+ className: y.progressIcon
88
+ }),
89
+ /* @__PURE__ */ d("span", {
90
+ className: y.ring,
91
+ "aria-hidden": !0
92
+ }),
93
+ A && /* @__PURE__ */ d(r, {
94
+ status: "success",
95
+ "aria-hidden": !0,
96
+ size: 16,
97
+ className: e(y.checkmark, y.successIcon)
98
+ })
99
+ ]
100
+ }),
101
+ F && /* @__PURE__ */ d(_, {
102
+ id: P,
103
+ children: F
104
+ }),
105
+ /* @__PURE__ */ f("span", {
106
+ className: y.fileInfo,
107
+ children: [/* @__PURE__ */ d("span", {
108
+ className: y.fileName,
109
+ children: o
110
+ }), g && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(_, { children: ", " }), /* @__PURE__ */ d("span", {
111
+ className: y.fileSize,
112
+ children: g
113
+ })] })]
114
+ }),
115
+ R && /* @__PURE__ */ d(w, {
116
+ hadFocusRef: B,
117
+ variant: "icon",
118
+ onPress: E,
119
+ "aria-label": `${O.format("previewFile")} ${o}`,
120
+ "aria-describedby": I,
121
+ className: y.previewButton,
122
+ children: /* @__PURE__ */ d(p, {
123
+ size: 20,
124
+ "aria-hidden": !0
125
+ })
126
+ }),
127
+ L && /* @__PURE__ */ d(t, {
128
+ ref: z,
129
+ variant: "icon",
130
+ onPress: L,
131
+ "aria-label": `${O.format(k ? "cancelUpload" : "removeFile")} ${o}`,
132
+ "aria-describedby": I,
133
+ className: y.deleteButton,
134
+ children: d(k ? h : m, {
135
+ size: 20,
136
+ "aria-hidden": !0
137
+ })
138
+ })
139
+ ]
140
+ }),
141
+ /* @__PURE__ */ d("div", {
142
+ id: N,
143
+ className: y.errorReveal,
144
+ children: x && /* @__PURE__ */ d(i, {
145
+ isInvalid: !0,
146
+ children: x
147
+ })
148
+ }),
149
+ /* @__PURE__ */ f(_, {
150
+ role: "status",
151
+ children: [A && `${O.format("uploadComplete")}: ${o}`, M && `${o}: ${x}`]
152
+ })
153
+ ]
154
+ });
155
+ }, w = ({ hadFocusRef: e, ...n }) => {
156
+ let r = l(null);
157
+ return c(() => {
158
+ let t = r.current;
159
+ return () => {
160
+ t && document.activeElement === t && (e.current = !0);
161
+ };
162
+ }, [e]), /* @__PURE__ */ d(t, {
163
+ ...n,
164
+ ref: r
165
+ });
166
+ };
167
+ export { b as n, C as t };
@@ -1,3 +1,7 @@
1
1
  import { HTMLAttributes } from 'react';
2
2
  export type FileListProps = HTMLAttributes<HTMLUListElement>;
3
+ /**
4
+ * A list of files the user has picked or uploaded, one `FileListItem` per
5
+ * file. Give it an `aria-label` that says what the files are for.
6
+ */
3
7
  export declare const FileList: ({ className, children, ...props }: FileListProps) => import('react').JSX.Element;
@@ -1,27 +1,43 @@
1
1
  export interface FileListItemProps {
2
+ /** Shown in the row, and used in the buttons' accessible names. */
2
3
  fileName: string;
4
+ /** Shown after the file name, already formatted, e.g. `'1.2 MB'`. */
3
5
  fileSize?: string;
4
- /** @default 'idle' */
6
+ /**
7
+ * Where the file is in the upload. Decides what the row shows, and whether
8
+ * its button cancels or deletes.
9
+ * @default 'idle'
10
+ */
5
11
  status?: 'idle' | 'uploading' | 'success' | 'error';
6
12
  /** 0-100. Only meaningful when `status='uploading'`; omit for indeterminate. */
7
13
  progress?: number;
8
14
  /** Shown below the row when `status='error'`. */
9
15
  errorMessage?: string;
10
16
  /**
11
- * Called when the cancel button is pressed while `status='uploading'` —
12
- * this is where you'd abort the in-flight request (e.g.
13
- * `XMLHttpRequest.abort()` or `AbortController.abort()`). Falls back to
17
+ * Called when the cancel button is pressed while `status='uploading'`.
18
+ * This is where you'd abort the in-flight request, e.g. with
19
+ * `XMLHttpRequest.abort()` or `AbortController.abort()`. Falls back to
14
20
  * `onDelete` if omitted, so an in-progress upload isn't silently left
15
21
  * running in the background with no way to stop it.
16
22
  */
17
23
  onCancel?: () => void;
18
24
  /**
19
25
  * Called when the delete button is pressed for any status other than
20
- * `uploading` (use `onCancel` for that). `FileList` has no concept of
21
- * "uploaded" vs "local only" — if the file is already persisted
22
- * server-side by the time this fires, deleting it there too is your call.
26
+ * `uploading` (use `onCancel` for that). `FileList` doesn't know whether a
27
+ * file is uploaded or only local. If it's already stored server-side when
28
+ * this fires, deleting it there too is up to you.
23
29
  */
24
30
  onDelete?: () => void;
31
+ /**
32
+ * Shows a preview button next to the delete button. Hidden while
33
+ * `uploading`, when cancelling is the main action in the row. Shown when
34
+ * an upload failed, since the file is still on the user's device and they
35
+ * can check what they picked. Opening the preview, e.g. in a `Modal` or
36
+ * another component, is up to you.
37
+ */
38
+ onPreview?: () => void;
39
+ /** Class name for the row's `<li>`. */
25
40
  className?: string;
26
41
  }
27
- export declare const FileListItem: ({ fileName, fileSize, status, progress, errorMessage, onCancel, onDelete, className, }: FileListItemProps) => import('react').JSX.Element;
42
+ /** A row in a `FileList`, showing one file and its upload status. */
43
+ export declare const FileListItem: ({ fileName, fileSize, status, progress, errorMessage, onCancel, onDelete, onPreview, className, }: FileListItemProps) => import('react').JSX.Element;
@@ -1 +1 @@
1
- export { n as FileList, t as FileListItem } from "../chunks/file-list-Dld4Shgt.js";
1
+ export { n as FileList, t as FileListItem } from "../chunks/file-list-k2ZZ-OB2.js";
@@ -4,14 +4,16 @@ declare const _default: {
4
4
  "cancelUpload": "Cancel",
5
5
  "uploading": "Uploading",
6
6
  "uploadComplete": "Upload complete",
7
- "uploadFailed": "Upload failed"
7
+ "uploadFailed": "Upload failed",
8
+ "previewFile": "Preview"
8
9
  },
9
10
  "sv": {
10
11
  "removeFile": "Ta bort",
11
12
  "cancelUpload": "Avbryt",
12
13
  "uploading": "Laddar upp",
13
14
  "uploadComplete": "Uppladdning klar",
14
- "uploadFailed": "Uppladdning misslyckades"
15
+ "uploadFailed": "Uppladdning misslyckades",
16
+ "previewFile": "Förhandsgranska"
15
17
  }
16
18
  }
17
19
  ;
package/index.js CHANGED
@@ -30,7 +30,7 @@ import { i as ge, n as _e, r as ve, t as ye } from "./chunks/date-field-DkypCMfi
30
30
  import { n as be, t as xe } from "./chunks/date-picker-Cn9qhe2G.js";
31
31
  import { t as Se } from "./chunks/drop-zone-BL3Z-Sbj.js";
32
32
  import { a as Ce, i as we, n as Te, r as Ee, t as De } from "./chunks/empty-state-CnDZoO65.js";
33
- import { n as Oe, t as ke } from "./chunks/file-list-Dld4Shgt.js";
33
+ import { n as Oe, t as ke } from "./chunks/file-list-k2ZZ-OB2.js";
34
34
  import { t as Ae } from "./chunks/progress-bar-BvueZ-dg.js";
35
35
  import { t as je } from "./chunks/file-trigger-gOeeZzDP.js";
36
36
  import { n as Me, t as Ne } from "./chunks/grid-CFn_pqQX.js";
@@ -62,7 +62,7 @@ var bt = {
62
62
  description: "Midas Components",
63
63
  homepage: "https://designsystem.migrationsverket.se/",
64
64
  license: "CC0-1.0",
65
- version: "17.35.0",
65
+ version: "17.36.0",
66
66
  module: "./index.js",
67
67
  type: "module",
68
68
  main: "./index.js",
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "description": "Midas Components",
15
15
  "homepage": "https://designsystem.migrationsverket.se/",
16
16
  "license": "CC0-1.0",
17
- "version": "17.35.0",
17
+ "version": "17.36.0",
18
18
  "module": "./index.js",
19
19
  "type": "module",
20
20
  "main": "./index.js",
@@ -1,138 +0,0 @@
1
- 'use client';
2
- import { t as e } from "./clsx-BtGY0yFD.js";
3
- import { n as t } from "./button-BZHl22O1.js";
4
- import { t as n } from "./progress-bar-BvueZ-dg.js";
5
- import { t as r } from "./FeedbackStatusIcon-DX5ndhm3.js";
6
- import { t as i } from "./field-error-CUYIkJWj.js";
7
- import { t as a } from "./useLocalizedStringFormatter-DU97U9ZX.js";
8
- import { useEffect as o, useId as s, useRef as c } from "react";
9
- import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
10
- import { Trash2 as f, X as p } from "lucide-react";
11
- import { FocusScope as m, VisuallyHidden as h, useFocusManager as g } from "react-aria";
12
- import '../assets/file-list.css';var _ = {
13
- fileList: "_fileList_mb5n3_1",
14
- fileListItem: "_fileListItem_mb5n3_18",
15
- row: "_row_mb5n3_25",
16
- iconSlot: "_iconSlot_mb5n3_46",
17
- progressIcon: "_progressIcon_mb5n3_70",
18
- ring: "_ring_mb5n3_82",
19
- successRing: "_successRing_mb5n3_1",
20
- checkmark: "_checkmark_mb5n3_106",
21
- successCheckmark: "_successCheckmark_mb5n3_1",
22
- successIcon: "_successIcon_mb5n3_121",
23
- errorReveal: "_errorReveal_mb5n3_163",
24
- fileInfo: "_fileInfo_mb5n3_169",
25
- fileName: "_fileName_mb5n3_177",
26
- fileSize: "_fileSize_mb5n3_186",
27
- deleteButton: "_deleteButton_mb5n3_192"
28
- }, v = ({ className: t, children: n, ...r }) => {
29
- let i = c(null);
30
- return /* @__PURE__ */ u(m, { children: /* @__PURE__ */ d("ul", {
31
- ...r,
32
- ref: i,
33
- tabIndex: -1,
34
- className: e(_.fileList, t),
35
- children: [/* @__PURE__ */ u(y, { containerRef: i }), n]
36
- }) });
37
- }, y = ({ containerRef: e }) => {
38
- let t = g(), n = c(t);
39
- return o(() => {
40
- n.current = t;
41
- }), o(() => {
42
- let t = e.current;
43
- if (!t) return;
44
- let r = new MutationObserver((e) => {
45
- e.some((e) => e.removedNodes.length > 0) && document.activeElement === document.body && (n.current?.focusFirst({ tabbable: !0 }) || t.focus());
46
- });
47
- return r.observe(t, { childList: !0 }), () => r.disconnect();
48
- }, [e]), null;
49
- }, b = {
50
- en: {
51
- removeFile: "Remove",
52
- cancelUpload: "Cancel",
53
- uploading: "Uploading",
54
- uploadComplete: "Upload complete",
55
- uploadFailed: "Upload failed"
56
- },
57
- sv: {
58
- removeFile: "Ta bort",
59
- cancelUpload: "Avbryt",
60
- uploading: "Laddar upp",
61
- uploadComplete: "Uppladdning klar",
62
- uploadFailed: "Uppladdning misslyckades"
63
- }
64
- }, x = ({ fileName: o, fileSize: c, status: m = "idle", progress: g, errorMessage: v, onCancel: y, onDelete: x, className: S }) => {
65
- let C = a(b), w = m === "uploading", T = m === "success", E = m === "error", D = E && !!v, O = s(), k = s(), A = T ? C.format("uploadComplete") : E ? C.format("uploadFailed") : void 0, j = [A && k, D && O].filter(Boolean).join(" ") || void 0, M = w ? y ?? x : x;
66
- return /* @__PURE__ */ d("li", {
67
- className: e(_.fileListItem, S),
68
- "data-status": m,
69
- children: [
70
- /* @__PURE__ */ d("div", {
71
- className: _.row,
72
- children: [
73
- /* @__PURE__ */ d("span", {
74
- className: _.iconSlot,
75
- children: [
76
- w && /* @__PURE__ */ u(n, {
77
- shape: "circular",
78
- small: !0,
79
- value: g,
80
- isIndeterminate: g === void 0,
81
- "aria-label": `${C.format("uploading")} ${o}`,
82
- className: _.progressIcon
83
- }),
84
- /* @__PURE__ */ u("span", {
85
- className: _.ring,
86
- "aria-hidden": !0
87
- }),
88
- T && /* @__PURE__ */ u(r, {
89
- status: "success",
90
- "aria-hidden": !0,
91
- size: 16,
92
- className: e(_.checkmark, _.successIcon)
93
- })
94
- ]
95
- }),
96
- A && /* @__PURE__ */ u(h, {
97
- id: k,
98
- children: A
99
- }),
100
- /* @__PURE__ */ d("span", {
101
- className: _.fileInfo,
102
- children: [/* @__PURE__ */ u("span", {
103
- className: _.fileName,
104
- children: o
105
- }), c && /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(h, { children: ", " }), /* @__PURE__ */ u("span", {
106
- className: _.fileSize,
107
- children: c
108
- })] })]
109
- }),
110
- M && /* @__PURE__ */ u(t, {
111
- variant: "icon",
112
- onPress: M,
113
- "aria-label": `${C.format(w ? "cancelUpload" : "removeFile")} ${o}`,
114
- "aria-describedby": j,
115
- className: _.deleteButton,
116
- children: u(w ? p : f, {
117
- size: 20,
118
- "aria-hidden": !0
119
- })
120
- })
121
- ]
122
- }),
123
- /* @__PURE__ */ u("div", {
124
- id: O,
125
- className: _.errorReveal,
126
- children: v && /* @__PURE__ */ u(i, {
127
- isInvalid: !0,
128
- children: v
129
- })
130
- }),
131
- /* @__PURE__ */ d(h, {
132
- role: "status",
133
- children: [T && `${C.format("uploadComplete")}: ${o}`, D && `${o}: ${v}`]
134
- })
135
- ]
136
- });
137
- };
138
- export { v as n, x as t };