@dimah-s3/ui 1.6.0 → 1.7.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/dist/components/dimah-s3/attachment/file-attachment.d.ts.map +1 -1
- package/dist/components/dimah-s3/delete/delete-button.d.ts +1 -1
- package/dist/components/dimah-s3/delete/delete-button.d.ts.map +1 -1
- package/dist/components/dimah-s3/download/progress-download-button.d.ts +1 -1
- package/dist/components/dimah-s3/download/progress-download-button.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-breadcrumb.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-menu.d.ts +1 -1
- package/dist/components/dimah-s3/list/object-list-menu.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-selection-state.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-selection.d.ts +1 -1
- package/dist/components/dimah-s3/list/object-list-selection.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-usage.d.ts +1 -1
- package/dist/components/dimah-s3/list/object-list-usage.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list.d.ts +3 -1
- package/dist/components/dimah-s3/list/object-list.d.ts.map +1 -1
- package/dist/components/dimah-s3/upload/multi-upload-status.d.ts.map +1 -1
- package/dist/components/dimah-s3/upload/upload-dropzone.d.ts.map +1 -1
- package/dist/components/dimah-s3/upload/upload-status.d.ts.map +1 -1
- package/dist/hooks/use-delete-ui.d.ts.map +1 -1
- package/dist/hooks/use-download-toast.d.ts.map +1 -1
- package/dist/hooks/use-file-reject-toast.d.ts +1 -1
- package/dist/hooks/use-file-reject-toast.d.ts.map +1 -1
- package/dist/hooks/use-upload-toast.d.ts.map +1 -1
- package/dist/index.js +141 -120
- package/dist/index.js.map +1 -1
- package/dist/lib/format-expires-in.d.ts.map +1 -1
- package/dist/lib/isolate-text.d.ts +7 -0
- package/dist/lib/isolate-text.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import { Button as Button$1 } from '@base-ui/react/button';
|
|
|
6
6
|
import { cva } from 'class-variance-authority';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { useFormatDimahError, useFormatFileSize, useFormatNumber, formatEta, isFetchDownload, formatAcceptLabels } from '@dimah-s3/react';
|
|
10
|
+
import { truncateFileName, fileNameFromKey, DELETE_BATCH_MAX_KEYS } from '@dimah-s3/core';
|
|
11
11
|
import { mergeProps } from '@base-ui/react/merge-props';
|
|
12
12
|
import { useRender } from '@base-ui/react/use-render';
|
|
13
13
|
import { FileIcon, defaultStyles } from 'react-file-icon';
|
|
@@ -543,6 +543,8 @@ function FileAttachment({
|
|
|
543
543
|
}) {
|
|
544
544
|
const t = useTranslations();
|
|
545
545
|
const formatError = useFormatDimahError();
|
|
546
|
+
const formatFileSize = useFormatFileSize();
|
|
547
|
+
const formatNumber = useFormatNumber();
|
|
546
548
|
const errorText = error == null ? null : typeof error === "string" ? error : formatError(error);
|
|
547
549
|
const progress = PROGRESS_BY_SIZE[size];
|
|
548
550
|
const resolvedDescription = description ?? (state === "error" ? errorText ?? t("Upload failed", { note: "status" }) : fileSize != null ? formatFileSize(fileSize) : null);
|
|
@@ -559,7 +561,7 @@ function FileAttachment({
|
|
|
559
561
|
className: progress.className,
|
|
560
562
|
label: state === "uploading" ? t("{percent}%", {
|
|
561
563
|
note: "progress",
|
|
562
|
-
variables: { percent:
|
|
564
|
+
variables: { percent: formatNumber(Math.round(percent)) }
|
|
563
565
|
}) : void 0
|
|
564
566
|
}
|
|
565
567
|
) }) : state === "error" ? /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-dimah-s3-destructive/20 text-dimah-s3-destructive", children: /* @__PURE__ */ jsx(AlertCircleIcon, {}) }) : null;
|
|
@@ -739,6 +741,7 @@ function MultiUploadStatus({
|
|
|
739
741
|
}) {
|
|
740
742
|
const t = useTranslations();
|
|
741
743
|
const formatError = useFormatDimahError();
|
|
744
|
+
const formatNumber = useFormatNumber();
|
|
742
745
|
const { phase, files, progress, error } = upload;
|
|
743
746
|
const onCancel = upload.cancel;
|
|
744
747
|
const onPause = upload.resumable ? upload.detach : void 0;
|
|
@@ -757,10 +760,10 @@ function MultiUploadStatus({
|
|
|
757
760
|
t("{done}/{total} files", {
|
|
758
761
|
note: "upload progress",
|
|
759
762
|
variables: {
|
|
760
|
-
done:
|
|
763
|
+
done: formatNumber(
|
|
761
764
|
files.filter((f) => f.status === "success").length
|
|
762
765
|
),
|
|
763
|
-
total:
|
|
766
|
+
total: formatNumber(files.length)
|
|
764
767
|
}
|
|
765
768
|
}),
|
|
766
769
|
eta ? /* @__PURE__ */ jsxs("span", { className: "font-normal text-dimah-s3-muted-foreground", children: [
|
|
@@ -807,7 +810,7 @@ function MultiUploadStatus({
|
|
|
807
810
|
state: "done",
|
|
808
811
|
title: t("All {count} file(s) uploaded", {
|
|
809
812
|
note: "status",
|
|
810
|
-
variables: { count:
|
|
813
|
+
variables: { count: formatNumber(files.length) }
|
|
811
814
|
}),
|
|
812
815
|
onDismiss: upload.reset,
|
|
813
816
|
...layout
|
|
@@ -894,6 +897,7 @@ function UploadFileStatus({
|
|
|
894
897
|
}) {
|
|
895
898
|
const t = useTranslations();
|
|
896
899
|
const formatError = useFormatDimahError();
|
|
900
|
+
const formatFileSize = useFormatFileSize();
|
|
897
901
|
const errorText = error ? formatError(error) : null;
|
|
898
902
|
const layout = { size, orientation, className };
|
|
899
903
|
const progress = file?.progress;
|
|
@@ -1193,19 +1197,14 @@ function Toaster({
|
|
|
1193
1197
|
}
|
|
1194
1198
|
Toast$1.createToastManager;
|
|
1195
1199
|
Toast$1.useToastManager;
|
|
1196
|
-
function
|
|
1197
|
-
return /* @__PURE__ */ jsx("
|
|
1198
|
-
}
|
|
1199
|
-
function progressNode(loaded, total) {
|
|
1200
|
-
return /* @__PURE__ */ jsxs("span", { dir: "ltr", className: "inline-block whitespace-nowrap tabular-nums", children: [
|
|
1201
|
-
formatFileSize(loaded),
|
|
1202
|
-
" / ",
|
|
1203
|
-
formatFileSize(total)
|
|
1204
|
-
] });
|
|
1200
|
+
function numbersNode(text) {
|
|
1201
|
+
return /* @__PURE__ */ jsx("bdi", { className: "inline-block whitespace-nowrap tabular-nums", children: text });
|
|
1205
1202
|
}
|
|
1206
1203
|
function useUploadToast(upload, enabled) {
|
|
1207
1204
|
const t = useTranslations();
|
|
1208
1205
|
const formatError = useFormatDimahError();
|
|
1206
|
+
const formatFileSize = useFormatFileSize();
|
|
1207
|
+
const formatNumber = useFormatNumber();
|
|
1209
1208
|
const toastIdRef = useRef(null);
|
|
1210
1209
|
const prevPhaseRef = useRef(upload.phase);
|
|
1211
1210
|
const cancelRef = useRef(upload.cancel);
|
|
@@ -1230,15 +1229,15 @@ function useUploadToast(upload, enabled) {
|
|
|
1230
1229
|
type: "success",
|
|
1231
1230
|
title: t("{count} file(s) uploaded", {
|
|
1232
1231
|
note: "toast",
|
|
1233
|
-
variables: { count:
|
|
1232
|
+
variables: { count: formatNumber(files.length) }
|
|
1234
1233
|
}),
|
|
1235
|
-
description:
|
|
1234
|
+
description: numbersNode(formatFileSize(total))
|
|
1236
1235
|
});
|
|
1237
1236
|
} else if (file) {
|
|
1238
1237
|
toast.add({
|
|
1239
1238
|
type: "success",
|
|
1240
1239
|
title: t("Upload complete", { note: "toast" }),
|
|
1241
|
-
description:
|
|
1240
|
+
description: numbersNode(formatFileSize(file.size))
|
|
1242
1241
|
});
|
|
1243
1242
|
}
|
|
1244
1243
|
toastIdRef.current = null;
|
|
@@ -1251,31 +1250,35 @@ function useUploadToast(upload, enabled) {
|
|
|
1251
1250
|
toast.add({
|
|
1252
1251
|
type: "error",
|
|
1253
1252
|
title: t("Upload finished with errors", { note: "toast" }),
|
|
1254
|
-
description: /* @__PURE__ */ jsx(
|
|
1255
|
-
"
|
|
1256
|
-
{
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
children: t("{succeeded} succeeded, {failed} failed", {
|
|
1260
|
-
note: "toast",
|
|
1261
|
-
variables: {
|
|
1262
|
-
succeeded: String(succeeded),
|
|
1263
|
-
failed: String(failed)
|
|
1264
|
-
}
|
|
1265
|
-
})
|
|
1253
|
+
description: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: t("{succeeded} succeeded, {failed} failed", {
|
|
1254
|
+
note: "toast",
|
|
1255
|
+
variables: {
|
|
1256
|
+
succeeded: formatNumber(succeeded),
|
|
1257
|
+
failed: formatNumber(failed)
|
|
1266
1258
|
}
|
|
1267
|
-
)
|
|
1259
|
+
}) })
|
|
1268
1260
|
});
|
|
1269
1261
|
} else {
|
|
1270
1262
|
toast.add({
|
|
1271
1263
|
type: "error",
|
|
1272
1264
|
title: t("Upload failed", { note: "toast" }),
|
|
1273
|
-
description: /* @__PURE__ */ jsx("span", {
|
|
1265
|
+
description: /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children: error ? formatError(error) : file?.error ? formatError(file.error) : t("Unknown error", { note: "fallback" }) })
|
|
1274
1266
|
});
|
|
1275
1267
|
}
|
|
1276
1268
|
toastIdRef.current = null;
|
|
1277
1269
|
}
|
|
1278
|
-
}, [
|
|
1270
|
+
}, [
|
|
1271
|
+
enabled,
|
|
1272
|
+
phase,
|
|
1273
|
+
file,
|
|
1274
|
+
files,
|
|
1275
|
+
progress,
|
|
1276
|
+
error,
|
|
1277
|
+
t,
|
|
1278
|
+
formatError,
|
|
1279
|
+
formatFileSize,
|
|
1280
|
+
formatNumber
|
|
1281
|
+
]);
|
|
1279
1282
|
useEffect(() => {
|
|
1280
1283
|
if (!enabled || phase !== "uploading") return;
|
|
1281
1284
|
const isMulti = files.length > 1;
|
|
@@ -1286,11 +1289,15 @@ function useUploadToast(upload, enabled) {
|
|
|
1286
1289
|
title: t("Uploading {done}/{total}", {
|
|
1287
1290
|
note: "toast",
|
|
1288
1291
|
variables: {
|
|
1289
|
-
done:
|
|
1290
|
-
|
|
1292
|
+
done: formatNumber(
|
|
1293
|
+
files.filter((f) => f.status === "success").length
|
|
1294
|
+
),
|
|
1295
|
+
total: formatNumber(files.length)
|
|
1291
1296
|
}
|
|
1292
1297
|
}),
|
|
1293
|
-
description:
|
|
1298
|
+
description: numbersNode(
|
|
1299
|
+
`${formatFileSize(progress.loaded)} / ${formatFileSize(progress.total)}`
|
|
1300
|
+
),
|
|
1294
1301
|
actionProps: {
|
|
1295
1302
|
children: t("Cancel", { note: "toast action" }),
|
|
1296
1303
|
onClick: () => cancelRef.current()
|
|
@@ -1299,7 +1306,9 @@ function useUploadToast(upload, enabled) {
|
|
|
1299
1306
|
type: "loading",
|
|
1300
1307
|
timeout: 0,
|
|
1301
1308
|
title: t("Uploading", { note: "toast" }),
|
|
1302
|
-
description:
|
|
1309
|
+
description: numbersNode(
|
|
1310
|
+
`${formatFileSize(singleProgress.loaded)} / ${formatFileSize(file.size)}`
|
|
1311
|
+
),
|
|
1303
1312
|
actionProps: {
|
|
1304
1313
|
children: t("Cancel", { note: "toast action" }),
|
|
1305
1314
|
onClick: () => cancelRef.current()
|
|
@@ -1311,24 +1320,29 @@ function useUploadToast(upload, enabled) {
|
|
|
1311
1320
|
} else {
|
|
1312
1321
|
toastIdRef.current = toast.add(payload);
|
|
1313
1322
|
}
|
|
1314
|
-
}, [enabled, phase, file, files, progress, t]);
|
|
1323
|
+
}, [enabled, phase, file, files, progress, t, formatFileSize, formatNumber]);
|
|
1315
1324
|
}
|
|
1316
|
-
function rejectionSummary(rejections, t) {
|
|
1325
|
+
function rejectionSummary(rejections, t, formatNumber) {
|
|
1317
1326
|
const first = rejections[0];
|
|
1318
1327
|
if (!first) {
|
|
1319
1328
|
return t("Some files were rejected", { note: "toast" });
|
|
1320
1329
|
}
|
|
1321
1330
|
const detail = first.errors[0]?.message ?? t("File type or size not allowed", { note: "toast" });
|
|
1322
1331
|
if (rejections.length === 1) {
|
|
1323
|
-
return
|
|
1332
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1333
|
+
/* @__PURE__ */ jsx("bdi", { children: first.file.name }),
|
|
1334
|
+
": ",
|
|
1335
|
+
detail
|
|
1336
|
+
] });
|
|
1324
1337
|
}
|
|
1325
1338
|
return t("{count} files were rejected", {
|
|
1326
1339
|
note: "toast",
|
|
1327
|
-
variables: { count:
|
|
1340
|
+
variables: { count: formatNumber(rejections.length) }
|
|
1328
1341
|
});
|
|
1329
1342
|
}
|
|
1330
1343
|
function useFileRejectToast(fileRejections, enabled) {
|
|
1331
1344
|
const t = useTranslations();
|
|
1345
|
+
const formatNumber = useFormatNumber();
|
|
1332
1346
|
const prevRef = useRef([]);
|
|
1333
1347
|
useEffect(() => {
|
|
1334
1348
|
if (!enabled) return;
|
|
@@ -1341,9 +1355,9 @@ function useFileRejectToast(fileRejections, enabled) {
|
|
|
1341
1355
|
toast.add({
|
|
1342
1356
|
type: "error",
|
|
1343
1357
|
title: t("File not accepted", { note: "toast" }),
|
|
1344
|
-
description: /* @__PURE__ */ jsx("span", {
|
|
1358
|
+
description: /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children: rejectionSummary(fileRejections, t, formatNumber) })
|
|
1345
1359
|
});
|
|
1346
|
-
}, [enabled, fileRejections, t]);
|
|
1360
|
+
}, [enabled, fileRejections, t, formatNumber]);
|
|
1347
1361
|
}
|
|
1348
1362
|
function useUploadUi(upload, {
|
|
1349
1363
|
toast: enableToast = true,
|
|
@@ -1433,7 +1447,7 @@ function ButtonShell({
|
|
|
1433
1447
|
status
|
|
1434
1448
|
] });
|
|
1435
1449
|
}
|
|
1436
|
-
function dropzoneHints(policy, t) {
|
|
1450
|
+
function dropzoneHints(policy, t, format) {
|
|
1437
1451
|
const acceptLabels = formatAcceptLabels(policy.accept);
|
|
1438
1452
|
const maxFiles = policy.maxFiles;
|
|
1439
1453
|
const limitParts = [];
|
|
@@ -1441,12 +1455,12 @@ function dropzoneHints(policy, t) {
|
|
|
1441
1455
|
limitParts.push(
|
|
1442
1456
|
t("You can upload {count} files", {
|
|
1443
1457
|
note: "dropzone hint",
|
|
1444
|
-
variables: { count:
|
|
1458
|
+
variables: { count: format.number(maxFiles) }
|
|
1445
1459
|
})
|
|
1446
1460
|
);
|
|
1447
1461
|
}
|
|
1448
1462
|
if (policy.maxFileSize != null) {
|
|
1449
|
-
const size =
|
|
1463
|
+
const size = format.fileSize(policy.maxFileSize);
|
|
1450
1464
|
limitParts.push(
|
|
1451
1465
|
maxFiles > 1 ? t("Each up to {size}", {
|
|
1452
1466
|
note: "dropzone hint",
|
|
@@ -1479,7 +1493,12 @@ function UploadDropzone({
|
|
|
1479
1493
|
const isDisabled = Boolean(disabled) || upload.isPending;
|
|
1480
1494
|
const hasCustomChrome = children != null;
|
|
1481
1495
|
const dropzoneLabel = label ?? t("Drag and drop files here", { note: "dropzone" });
|
|
1482
|
-
const
|
|
1496
|
+
const formatFileSize = useFormatFileSize();
|
|
1497
|
+
const formatNumber = useFormatNumber();
|
|
1498
|
+
const { limitsLine, acceptLine } = dropzoneHints(upload.policy, t, {
|
|
1499
|
+
fileSize: formatFileSize,
|
|
1500
|
+
number: formatNumber
|
|
1501
|
+
});
|
|
1483
1502
|
const { statusNode } = useUploadUi(upload, {
|
|
1484
1503
|
toast: enableToast,
|
|
1485
1504
|
attachmentSize,
|
|
@@ -1537,6 +1556,7 @@ function UploadDropzone({
|
|
|
1537
1556
|
}
|
|
1538
1557
|
function useDownloadToast(download, { enabled = true, objectKey, fileName, fileSize }) {
|
|
1539
1558
|
const t = useTranslations();
|
|
1559
|
+
const formatFileSize = useFormatFileSize();
|
|
1540
1560
|
const formatDimahError = useFormatDimahError();
|
|
1541
1561
|
const displayName = fileName ?? fileNameFromKey(objectKey) ?? objectKey;
|
|
1542
1562
|
const toastIdRef = useRef(null);
|
|
@@ -1559,7 +1579,7 @@ function useDownloadToast(download, { enabled = true, objectKey, fileName, fileS
|
|
|
1559
1579
|
const prev = prevPhaseRef.current;
|
|
1560
1580
|
prevPhaseRef.current = phase;
|
|
1561
1581
|
if (!enabled || activeKey !== objectKey) return;
|
|
1562
|
-
const errorNode = (value) => /* @__PURE__ */ jsx("span", {
|
|
1582
|
+
const errorNode = (value) => /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children: formatDimahError(value) });
|
|
1563
1583
|
const closeLoading = () => {
|
|
1564
1584
|
if (toastIdRef.current) {
|
|
1565
1585
|
toast.close(toastIdRef.current);
|
|
@@ -1573,7 +1593,7 @@ function useDownloadToast(download, { enabled = true, objectKey, fileName, fileS
|
|
|
1573
1593
|
type: "loading",
|
|
1574
1594
|
timeout: 0,
|
|
1575
1595
|
title: t("Downloading", { note: "toast" }),
|
|
1576
|
-
description: /* @__PURE__ */ jsx("
|
|
1596
|
+
description: /* @__PURE__ */ jsx("bdi", { children: truncateFileName(displayName) }),
|
|
1577
1597
|
actionProps: {
|
|
1578
1598
|
children: t("Cancel", { note: "toast action" }),
|
|
1579
1599
|
onClick: () => cancelRef.current?.()
|
|
@@ -1593,14 +1613,7 @@ function useDownloadToast(download, { enabled = true, objectKey, fileName, fileS
|
|
|
1593
1613
|
" ",
|
|
1594
1614
|
"\xB7",
|
|
1595
1615
|
" ",
|
|
1596
|
-
/* @__PURE__ */ jsx(
|
|
1597
|
-
"span",
|
|
1598
|
-
{
|
|
1599
|
-
dir: "ltr",
|
|
1600
|
-
className: "inline-block whitespace-nowrap tabular-nums",
|
|
1601
|
-
children: formatFileSize(fileSize)
|
|
1602
|
-
}
|
|
1603
|
-
)
|
|
1616
|
+
/* @__PURE__ */ jsx("bdi", { className: "inline-block whitespace-nowrap tabular-nums", children: formatFileSize(fileSize) })
|
|
1604
1617
|
] }) : null
|
|
1605
1618
|
] })
|
|
1606
1619
|
});
|
|
@@ -1620,7 +1633,7 @@ function useDownloadToast(download, { enabled = true, objectKey, fileName, fileS
|
|
|
1620
1633
|
toast.add({
|
|
1621
1634
|
type: "info",
|
|
1622
1635
|
title: t("Download cancelled", { note: "toast" }),
|
|
1623
|
-
description: /* @__PURE__ */ jsx("
|
|
1636
|
+
description: /* @__PURE__ */ jsx("bdi", { children: truncateFileName(displayName) })
|
|
1624
1637
|
});
|
|
1625
1638
|
}
|
|
1626
1639
|
return;
|
|
@@ -1651,7 +1664,8 @@ function useDownloadToast(download, { enabled = true, objectKey, fileName, fileS
|
|
|
1651
1664
|
activeKey,
|
|
1652
1665
|
objectKey,
|
|
1653
1666
|
t,
|
|
1654
|
-
formatDimahError
|
|
1667
|
+
formatDimahError,
|
|
1668
|
+
formatFileSize
|
|
1655
1669
|
]);
|
|
1656
1670
|
useEffect(() => {
|
|
1657
1671
|
if (!enabled || activeKey !== objectKey || phase !== "downloading" || !progress) {
|
|
@@ -1662,16 +1676,13 @@ function useDownloadToast(download, { enabled = true, objectKey, fileName, fileS
|
|
|
1662
1676
|
type: "loading",
|
|
1663
1677
|
timeout: 0,
|
|
1664
1678
|
title: t("Downloading", { note: "toast" }),
|
|
1665
|
-
description: /* @__PURE__ */
|
|
1666
|
-
formatFileSize(progress.loaded),
|
|
1667
|
-
progress.total > 0 ? ` / ${formatFileSize(progress.total)}` : null
|
|
1668
|
-
] }),
|
|
1679
|
+
description: /* @__PURE__ */ jsx("bdi", { className: "inline-block whitespace-nowrap tabular-nums", children: progress.total > 0 ? `${formatFileSize(progress.loaded)} / ${formatFileSize(progress.total)}` : formatFileSize(progress.loaded) }),
|
|
1669
1680
|
actionProps: {
|
|
1670
1681
|
children: t("Cancel", { note: "toast action" }),
|
|
1671
1682
|
onClick: () => cancelRef.current?.()
|
|
1672
1683
|
}
|
|
1673
1684
|
});
|
|
1674
|
-
}, [enabled, phase, progress, t, activeKey, objectKey]);
|
|
1685
|
+
}, [enabled, phase, progress, t, activeKey, objectKey, formatFileSize]);
|
|
1675
1686
|
}
|
|
1676
1687
|
function useDownloadUi(download, {
|
|
1677
1688
|
toast: enableToast = true,
|
|
@@ -1798,6 +1809,7 @@ function ProgressDownloadButton({
|
|
|
1798
1809
|
attachmentOrientation
|
|
1799
1810
|
}) {
|
|
1800
1811
|
const t = useTranslations();
|
|
1812
|
+
const formatFileSize = useFormatFileSize();
|
|
1801
1813
|
const isThis = download.objectKey === objectKey;
|
|
1802
1814
|
const isPendingThis = download.isPending && isThis;
|
|
1803
1815
|
const { statusNode } = useDownloadUi(download, {
|
|
@@ -2029,14 +2041,14 @@ function useDeleteToast(del, { enabled = true, objectKey, displayName }) {
|
|
|
2029
2041
|
toast.add({
|
|
2030
2042
|
type: "success",
|
|
2031
2043
|
title: t("File deleted", { note: "toast" }),
|
|
2032
|
-
description: /* @__PURE__ */ jsx("
|
|
2044
|
+
description: /* @__PURE__ */ jsx("bdi", { children: truncateFileName(displayName) })
|
|
2033
2045
|
});
|
|
2034
2046
|
}
|
|
2035
2047
|
if (del.phase === "error") {
|
|
2036
2048
|
toast.add({
|
|
2037
2049
|
type: "error",
|
|
2038
2050
|
title: t("Delete failed", { note: "toast" }),
|
|
2039
|
-
description: /* @__PURE__ */ jsx("span", {
|
|
2051
|
+
description: /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children: formatDimahError(del.error) })
|
|
2040
2052
|
});
|
|
2041
2053
|
}
|
|
2042
2054
|
}, [
|
|
@@ -2050,6 +2062,11 @@ function useDeleteToast(del, { enabled = true, objectKey, displayName }) {
|
|
|
2050
2062
|
formatDimahError
|
|
2051
2063
|
]);
|
|
2052
2064
|
}
|
|
2065
|
+
|
|
2066
|
+
// src/lib/isolate-text.ts
|
|
2067
|
+
function isolateText(value) {
|
|
2068
|
+
return `\u2068${value}\u2069`;
|
|
2069
|
+
}
|
|
2053
2070
|
function useDeleteUi(del, {
|
|
2054
2071
|
toast: enableToast = true,
|
|
2055
2072
|
objectKey,
|
|
@@ -2070,7 +2087,7 @@ function useDeleteUi(del, {
|
|
|
2070
2087
|
state: "done",
|
|
2071
2088
|
title: t('"{name}" deleted', {
|
|
2072
2089
|
note: "status",
|
|
2073
|
-
variables: { name: truncateFileName(displayName) }
|
|
2090
|
+
variables: { name: isolateText(truncateFileName(displayName)) }
|
|
2074
2091
|
}),
|
|
2075
2092
|
onDismiss: del.reset,
|
|
2076
2093
|
size: attachmentSize,
|
|
@@ -2089,9 +2106,6 @@ function useDeleteUi(del, {
|
|
|
2089
2106
|
) : null;
|
|
2090
2107
|
return { statusNode };
|
|
2091
2108
|
}
|
|
2092
|
-
function isolateLtr(value) {
|
|
2093
|
-
return `\u2066${value}\u2069`;
|
|
2094
|
-
}
|
|
2095
2109
|
function DeleteButton({
|
|
2096
2110
|
delete: del,
|
|
2097
2111
|
objectKey,
|
|
@@ -2113,6 +2127,7 @@ function DeleteButton({
|
|
|
2113
2127
|
attachmentOrientation
|
|
2114
2128
|
}) {
|
|
2115
2129
|
const t = useTranslations();
|
|
2130
|
+
const formatFileSize = useFormatFileSize();
|
|
2116
2131
|
const displayName = fileName ?? fileNameFromKey(objectKey) ?? objectKey;
|
|
2117
2132
|
const isThis = del.objectKey === objectKey;
|
|
2118
2133
|
const isDeletingThis = del.isDeleting && isThis;
|
|
@@ -2128,12 +2143,13 @@ function DeleteButton({
|
|
|
2128
2143
|
isDeletingThis ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin", "data-icon": "inline-start" }) : /* @__PURE__ */ jsx(Trash2Icon, { "data-icon": "inline-start" }),
|
|
2129
2144
|
label ?? t("Delete", { note: "button" })
|
|
2130
2145
|
] });
|
|
2131
|
-
const
|
|
2146
|
+
const name = isolateText(truncateFileName(displayName));
|
|
2147
|
+
const fileLabel = fileSize != null ? `${name} (${isolateText(formatFileSize(fileSize))})` : name;
|
|
2132
2148
|
const description = confirmDescription ?? t(
|
|
2133
2149
|
'Are you sure you want to delete "{name}"? This action cannot be undone.',
|
|
2134
2150
|
{
|
|
2135
2151
|
note: "dialog description",
|
|
2136
|
-
variables: { name:
|
|
2152
|
+
variables: { name: fileLabel }
|
|
2137
2153
|
}
|
|
2138
2154
|
);
|
|
2139
2155
|
return /* @__PURE__ */ jsxs("div", { className: cn("inline-flex flex-col gap-2", className), children: [
|
|
@@ -2174,14 +2190,7 @@ function DeleteButton({
|
|
|
2174
2190
|
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
2175
2191
|
/* @__PURE__ */ jsx(AlertDialogMedia, { children: /* @__PURE__ */ jsx(Trash2Icon, {}) }),
|
|
2176
2192
|
/* @__PURE__ */ jsx(AlertDialogTitle, { children: confirmTitle ?? t("Delete file?", { note: "dialog title" }) }),
|
|
2177
|
-
/* @__PURE__ */ jsx(
|
|
2178
|
-
AlertDialogDescription,
|
|
2179
|
-
{
|
|
2180
|
-
dir: "auto",
|
|
2181
|
-
className: "[overflow-wrap:anywhere]",
|
|
2182
|
-
children: description
|
|
2183
|
-
}
|
|
2184
|
-
)
|
|
2193
|
+
/* @__PURE__ */ jsx(AlertDialogDescription, { className: "[overflow-wrap:anywhere]", children: description })
|
|
2185
2194
|
] }),
|
|
2186
2195
|
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
2187
2196
|
/* @__PURE__ */ jsx(AlertDialogCancel, { children: t("Cancel", { note: "dialog button" }) }),
|
|
@@ -2438,7 +2447,7 @@ function ObjectListBreadcrumb({
|
|
|
2438
2447
|
{
|
|
2439
2448
|
disabled: navigate == null,
|
|
2440
2449
|
onClick: () => navigate?.(trail.slice(0, index + 1)),
|
|
2441
|
-
children: /* @__PURE__ */ jsx("span", { className: "truncate", children: folder.name })
|
|
2450
|
+
children: /* @__PURE__ */ jsx("span", { className: "truncate", children: /* @__PURE__ */ jsx("bdi", { children: folder.name }) })
|
|
2442
2451
|
},
|
|
2443
2452
|
folder.id
|
|
2444
2453
|
)) })
|
|
@@ -2451,13 +2460,13 @@ function ObjectListBreadcrumb({
|
|
|
2451
2460
|
const current = trailIndex === trail.length - 1;
|
|
2452
2461
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2453
2462
|
/* @__PURE__ */ jsx(BreadcrumbSeparator, {}),
|
|
2454
|
-
/* @__PURE__ */ jsx(BreadcrumbItem, { className: "min-w-0", children: current || navigate == null ? /* @__PURE__ */ jsx(BreadcrumbPage, { className: "max-w-40 truncate sm:max-w-56", children: folder.name }) : /* @__PURE__ */ jsx(
|
|
2463
|
+
/* @__PURE__ */ jsx(BreadcrumbItem, { className: "min-w-0", children: current || navigate == null ? /* @__PURE__ */ jsx(BreadcrumbPage, { className: "max-w-40 truncate sm:max-w-56", children: /* @__PURE__ */ jsx("bdi", { children: folder.name }) }) : /* @__PURE__ */ jsx(
|
|
2455
2464
|
BreadcrumbLink,
|
|
2456
2465
|
{
|
|
2457
2466
|
className: "max-w-40 truncate sm:max-w-56",
|
|
2458
2467
|
render: /* @__PURE__ */ jsx("button", { type: "button" }),
|
|
2459
2468
|
onClick: () => navigate(trail.slice(0, trailIndex + 1)),
|
|
2460
|
-
children: folder.name
|
|
2469
|
+
children: /* @__PURE__ */ jsx("bdi", { children: folder.name })
|
|
2461
2470
|
}
|
|
2462
2471
|
) })
|
|
2463
2472
|
] }, folder.id);
|
|
@@ -2713,12 +2722,20 @@ function splitFileName(name) {
|
|
|
2713
2722
|
if (!FILE_EXTENSION.test(extension)) return { stem: name, extension: "" };
|
|
2714
2723
|
return { stem: name.slice(0, dot), extension };
|
|
2715
2724
|
}
|
|
2716
|
-
function
|
|
2717
|
-
const { stem, extension } = splitFileName(name);
|
|
2718
|
-
return /* @__PURE__ */ jsxs(
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2725
|
+
function NameLabel({ name, kind }) {
|
|
2726
|
+
const { stem, extension } = kind === "file" ? splitFileName(name) : { stem: name, extension: "" };
|
|
2727
|
+
return /* @__PURE__ */ jsxs(
|
|
2728
|
+
"span",
|
|
2729
|
+
{
|
|
2730
|
+
dir: "auto",
|
|
2731
|
+
title: name,
|
|
2732
|
+
className: "inline-flex max-w-full min-w-0 align-top",
|
|
2733
|
+
children: [
|
|
2734
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: stem }),
|
|
2735
|
+
extension ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: extension }) : null
|
|
2736
|
+
]
|
|
2737
|
+
}
|
|
2738
|
+
);
|
|
2722
2739
|
}
|
|
2723
2740
|
function ObjectListRow({
|
|
2724
2741
|
kind,
|
|
@@ -2775,7 +2792,7 @@ function ObjectListRow({
|
|
|
2775
2792
|
className: cn("min-w-0 gap-0 overflow-hidden", actions && "pe-2"),
|
|
2776
2793
|
children: [
|
|
2777
2794
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
2778
|
-
/* @__PURE__ */ jsx(ItemTitle, { className: "line-clamp-none block w-full min-w-0 overflow-hidden font-normal", children: /* @__PURE__ */ jsx(
|
|
2795
|
+
/* @__PURE__ */ jsx(ItemTitle, { className: "line-clamp-none block w-full min-w-0 overflow-hidden font-normal", children: /* @__PURE__ */ jsx(NameLabel, { name: title, kind }) }),
|
|
2779
2796
|
showMeta ? /* @__PURE__ */ jsx("div", { className: "shrink-0", children: meta }) : null
|
|
2780
2797
|
] }),
|
|
2781
2798
|
described ? /* @__PURE__ */ jsx(ItemDescription, { className: "min-w-0 truncate text-xs leading-4 text-dimah-s3-muted-foreground", children: description }) : null
|
|
@@ -2819,6 +2836,7 @@ function useObjectListSelection({
|
|
|
2819
2836
|
const selectedFolderIdSig = JSON.stringify(selectedFolderIds);
|
|
2820
2837
|
const onSelectionChangeRef = useRef(onSelectionChange);
|
|
2821
2838
|
const getKeyRef = useRef(getKey);
|
|
2839
|
+
const rowsRef = useRef({ items, folders });
|
|
2822
2840
|
const rowsSelectable = filesSelectable || foldersSelectable;
|
|
2823
2841
|
const selectedCount = selectedFileKeys.length + selectedFolderIds.length;
|
|
2824
2842
|
const visibleCount = visibleFileKeys.length + visibleFolderIds.length;
|
|
@@ -2838,7 +2856,8 @@ function useObjectListSelection({
|
|
|
2838
2856
|
useEffect(() => {
|
|
2839
2857
|
onSelectionChangeRef.current = onSelectionChange;
|
|
2840
2858
|
getKeyRef.current = getKey;
|
|
2841
|
-
|
|
2859
|
+
rowsRef.current = { items, folders };
|
|
2860
|
+
}, [folders, getKey, items, onSelectionChange]);
|
|
2842
2861
|
useEffect(() => {
|
|
2843
2862
|
const notify = onSelectionChangeRef.current;
|
|
2844
2863
|
if (!notify) return;
|
|
@@ -2846,11 +2865,12 @@ function useObjectListSelection({
|
|
|
2846
2865
|
const folderSet = new Set(
|
|
2847
2866
|
JSON.parse(selectedFolderIdSig)
|
|
2848
2867
|
);
|
|
2868
|
+
const rows = rowsRef.current;
|
|
2849
2869
|
notify({
|
|
2850
|
-
items: items.filter((item) => fileSet.has(getKeyRef.current(item))),
|
|
2851
|
-
folders: folders.filter((folder) => folderSet.has(folder.id))
|
|
2870
|
+
items: rows.items.filter((item) => fileSet.has(getKeyRef.current(item))),
|
|
2871
|
+
folders: rows.folders.filter((folder) => folderSet.has(folder.id))
|
|
2852
2872
|
});
|
|
2853
|
-
}, [
|
|
2873
|
+
}, [selectedFileKeySig, selectedFolderIdSig]);
|
|
2854
2874
|
const selectionRows = [];
|
|
2855
2875
|
if (foldersSelectable) {
|
|
2856
2876
|
for (const folder of folders) {
|
|
@@ -2999,6 +3019,7 @@ function ObjectListSelection({
|
|
|
2999
3019
|
onDeleted
|
|
3000
3020
|
}) {
|
|
3001
3021
|
const t = useTranslations();
|
|
3022
|
+
const formatNumber = useFormatNumber();
|
|
3002
3023
|
const [phase, setPhase] = useState(
|
|
3003
3024
|
"idle"
|
|
3004
3025
|
);
|
|
@@ -3074,7 +3095,7 @@ function ObjectListSelection({
|
|
|
3074
3095
|
type: "success",
|
|
3075
3096
|
title: t("Deleted {count} files", {
|
|
3076
3097
|
note: "object list selection",
|
|
3077
|
-
variables: { count:
|
|
3098
|
+
variables: { count: formatNumber(deleted.length) }
|
|
3078
3099
|
})
|
|
3079
3100
|
});
|
|
3080
3101
|
}
|
|
@@ -3083,7 +3104,7 @@ function ObjectListSelection({
|
|
|
3083
3104
|
type: "error",
|
|
3084
3105
|
title: t("Could not delete {count} files", {
|
|
3085
3106
|
note: "object list selection",
|
|
3086
|
-
variables: { count:
|
|
3107
|
+
variables: { count: formatNumber(failed.length) }
|
|
3087
3108
|
})
|
|
3088
3109
|
});
|
|
3089
3110
|
}
|
|
@@ -3104,10 +3125,10 @@ function ObjectListSelection({
|
|
|
3104
3125
|
children: [
|
|
3105
3126
|
/* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums", children: onThisPage ? t("{count} selected on this page", {
|
|
3106
3127
|
note: "object list selection",
|
|
3107
|
-
variables: { count:
|
|
3128
|
+
variables: { count: formatNumber(selectedCount) }
|
|
3108
3129
|
}) : t("{count} selected", {
|
|
3109
3130
|
note: "object list selection",
|
|
3110
|
-
variables: { count:
|
|
3131
|
+
variables: { count: formatNumber(selectedCount) }
|
|
3111
3132
|
}) }),
|
|
3112
3133
|
visibleNote ? /* @__PURE__ */ jsx("span", { className: "ms-2 font-normal text-dimah-s3-muted-foreground", children: visibleNote }) : null
|
|
3113
3134
|
]
|
|
@@ -3155,7 +3176,9 @@ function ObjectListSelection({
|
|
|
3155
3176
|
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
3156
3177
|
/* @__PURE__ */ jsx(AlertDialogTitle, { children: t("Delete {count} files?", {
|
|
3157
3178
|
note: "object list selection",
|
|
3158
|
-
variables: {
|
|
3179
|
+
variables: {
|
|
3180
|
+
count: formatNumber(planned?.entries.length ?? 0)
|
|
3181
|
+
}
|
|
3159
3182
|
}) }),
|
|
3160
3183
|
/* @__PURE__ */ jsxs(AlertDialogDescription, { children: [
|
|
3161
3184
|
t("This action cannot be undone.", {
|
|
@@ -3432,6 +3455,8 @@ function ObjectListUsageLine({
|
|
|
3432
3455
|
limits
|
|
3433
3456
|
}) {
|
|
3434
3457
|
const t = useTranslations();
|
|
3458
|
+
const formatFileSize = useFormatFileSize();
|
|
3459
|
+
const formatNumber = useFormatNumber();
|
|
3435
3460
|
const byteCap = finiteCap(limits?.maxBytes);
|
|
3436
3461
|
const fileCap = finiteCap(limits?.maxFiles);
|
|
3437
3462
|
const bytesLabel = byteCap == null ? formatFileSize(usage.totalBytes) : t("{used} of {max}", {
|
|
@@ -3443,12 +3468,12 @@ function ObjectListUsageLine({
|
|
|
3443
3468
|
});
|
|
3444
3469
|
const filesLabel = fileCap == null ? usage.objectCount === 1 ? t("1 file", { note: "object list usage" }) : t("{count} files", {
|
|
3445
3470
|
note: "object list usage",
|
|
3446
|
-
variables: { count:
|
|
3471
|
+
variables: { count: formatNumber(usage.objectCount) }
|
|
3447
3472
|
}) : t("{count} of {max} files", {
|
|
3448
3473
|
note: "object list usage",
|
|
3449
3474
|
variables: {
|
|
3450
|
-
count:
|
|
3451
|
-
max:
|
|
3475
|
+
count: formatNumber(usage.objectCount),
|
|
3476
|
+
max: formatNumber(fileCap)
|
|
3452
3477
|
}
|
|
3453
3478
|
});
|
|
3454
3479
|
const byteRatio = fillRatio(usage.totalBytes, byteCap);
|
|
@@ -3732,7 +3757,10 @@ function ObjectListFrame({
|
|
|
3732
3757
|
]
|
|
3733
3758
|
}
|
|
3734
3759
|
),
|
|
3735
|
-
upload ? /* @__PURE__ */
|
|
3760
|
+
upload ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3761
|
+
/* @__PURE__ */ jsx("input", { ...upload.getInputProps() }),
|
|
3762
|
+
/* @__PURE__ */ jsx(ObjectListDropOverlay, { upload })
|
|
3763
|
+
] }) : null
|
|
3736
3764
|
] });
|
|
3737
3765
|
}
|
|
3738
3766
|
function cssLength(value) {
|
|
@@ -3757,6 +3785,7 @@ function durationParts(seconds) {
|
|
|
3757
3785
|
}
|
|
3758
3786
|
function useShareExpiryLabel() {
|
|
3759
3787
|
const t = useTranslations();
|
|
3788
|
+
const formatNumber = useFormatNumber();
|
|
3760
3789
|
return (seconds) => {
|
|
3761
3790
|
if (seconds <= 0) {
|
|
3762
3791
|
return t("This link works while you can access this file.", {
|
|
@@ -3764,7 +3793,7 @@ function useShareExpiryLabel() {
|
|
|
3764
3793
|
});
|
|
3765
3794
|
}
|
|
3766
3795
|
const { unit, count } = durationParts(seconds);
|
|
3767
|
-
const value =
|
|
3796
|
+
const value = formatNumber(count);
|
|
3768
3797
|
if (unit === "day") {
|
|
3769
3798
|
return count === 1 ? t("Expires in 1 day", { note: "object list menu" }) : t("Expires in {count} days", {
|
|
3770
3799
|
note: "object list menu",
|
|
@@ -3951,10 +3980,12 @@ function DeleteConfirm({
|
|
|
3951
3980
|
fileSize
|
|
3952
3981
|
}) {
|
|
3953
3982
|
const t = useTranslations();
|
|
3983
|
+
const formatFileSize = useFormatFileSize();
|
|
3954
3984
|
const displayName = fileName ?? fileNameFromKey(objectKey) ?? objectKey;
|
|
3955
3985
|
const isThis = remove.objectKey === objectKey;
|
|
3956
3986
|
useDeleteToast(remove, { objectKey, displayName });
|
|
3957
|
-
const
|
|
3987
|
+
const name = isolateText(truncateFileName(displayName));
|
|
3988
|
+
const fileLabel = fileSize != null ? `${name} (${isolateText(formatFileSize(fileSize))})` : name;
|
|
3958
3989
|
return /* @__PURE__ */ jsx(
|
|
3959
3990
|
AlertDialog,
|
|
3960
3991
|
{
|
|
@@ -3966,20 +3997,13 @@ function DeleteConfirm({
|
|
|
3966
3997
|
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
3967
3998
|
/* @__PURE__ */ jsx(AlertDialogMedia, { children: /* @__PURE__ */ jsx(Trash2Icon, {}) }),
|
|
3968
3999
|
/* @__PURE__ */ jsx(AlertDialogTitle, { children: t("Delete file?", { note: "dialog title" }) }),
|
|
3969
|
-
/* @__PURE__ */ jsx(
|
|
3970
|
-
|
|
4000
|
+
/* @__PURE__ */ jsx(AlertDialogDescription, { className: "[overflow-wrap:anywhere]", children: t(
|
|
4001
|
+
'Are you sure you want to delete "{name}"? This action cannot be undone.',
|
|
3971
4002
|
{
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
children: t(
|
|
3975
|
-
'Are you sure you want to delete "{name}"? This action cannot be undone.',
|
|
3976
|
-
{
|
|
3977
|
-
note: "dialog description",
|
|
3978
|
-
variables: { name: isolateLtr2(fileLabel) }
|
|
3979
|
-
}
|
|
3980
|
-
)
|
|
4003
|
+
note: "dialog description",
|
|
4004
|
+
variables: { name: fileLabel }
|
|
3981
4005
|
}
|
|
3982
|
-
)
|
|
4006
|
+
) })
|
|
3983
4007
|
] }),
|
|
3984
4008
|
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
3985
4009
|
/* @__PURE__ */ jsx(AlertDialogCancel, { children: t("Cancel", { note: "dialog button" }) }),
|
|
@@ -3996,9 +4020,6 @@ function DeleteConfirm({
|
|
|
3996
4020
|
}
|
|
3997
4021
|
);
|
|
3998
4022
|
}
|
|
3999
|
-
function isolateLtr2(value) {
|
|
4000
|
-
return `\u2066${value}\u2069`;
|
|
4001
|
-
}
|
|
4002
4023
|
function useRowDeleted(remove, objectKey, onDeleted) {
|
|
4003
4024
|
const onDeletedRef = useRef(onDeleted);
|
|
4004
4025
|
const notified = useRef(false);
|