@dimah-s3/react 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/helpers/format-number.d.ts +12 -0
- package/dist/helpers/format-number.d.ts.map +1 -0
- package/dist/helpers/format-speed.d.ts +2 -1
- package/dist/helpers/format-speed.d.ts.map +1 -1
- package/dist/helpers/format-upload-progress.d.ts +3 -1
- package/dist/helpers/format-upload-progress.d.ts.map +1 -1
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/hooks/use-file-intake.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -14
- package/dist/index.js.map +1 -1
- package/dist/s3-provider.d.ts +9 -1
- package/dist/s3-provider.d.ts.map +1 -1
- package/dist/translations/types.d.ts +7 -0
- package/dist/translations/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Byte formatter for the `S3Provider` `locale`: native digits and
|
|
3
|
+
* translated unit labels (`"B(file size unit)"`, `"MB(file size unit)"`, …).
|
|
4
|
+
* Without a `locale`, sizes read `12.4 MB`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useFormatFileSize(): (bytes: number) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Count formatter for the `S3Provider` `locale`, such as `۱۲` for `fa`.
|
|
9
|
+
* Without a `locale`, counts read as plain digits.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useFormatNumber(): (value: number) => string;
|
|
12
|
+
//# sourceMappingURL=format-number.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-number.d.ts","sourceRoot":"","sources":["../../src/helpers/format-number.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAgB7D;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAQ3D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FormatFileSizeOptions } from "@dimah-s3/core";
|
|
1
2
|
/**
|
|
2
3
|
* Formats a transfer speed (bytes/second) as a human-readable string.
|
|
3
4
|
*
|
|
@@ -5,5 +6,5 @@
|
|
|
5
6
|
* formatSpeed(1_200_000) // → "1.2 MB/s"
|
|
6
7
|
* formatSpeed(512) // → "512 B/s"
|
|
7
8
|
*/
|
|
8
|
-
export declare function formatSpeed(bytesPerSecond: number): string;
|
|
9
|
+
export declare function formatSpeed(bytesPerSecond: number, options?: FormatFileSizeOptions): string;
|
|
9
10
|
//# sourceMappingURL=format-speed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-speed.d.ts","sourceRoot":"","sources":["../../src/helpers/format-speed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format-speed.d.ts","sourceRoot":"","sources":["../../src/helpers/format-speed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,CAER"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type FormatFileSizeOptions } from "@dimah-s3/core";
|
|
1
2
|
/**
|
|
2
3
|
* Formats upload progress as a human-readable transfer string.
|
|
3
4
|
*
|
|
4
5
|
* @param loaded Bytes transferred so far.
|
|
5
6
|
* @param total Total bytes to transfer (0 means unknown).
|
|
6
7
|
* @param percent Transfer percentage (0–100).
|
|
8
|
+
* @param options Locale and unit labels for the sizes.
|
|
7
9
|
*
|
|
8
10
|
* @example
|
|
9
11
|
* ```ts
|
|
@@ -14,5 +16,5 @@
|
|
|
14
16
|
* // → "1.2 MB"
|
|
15
17
|
* ```
|
|
16
18
|
*/
|
|
17
|
-
export declare function formatUploadProgress(loaded: number, total: number, percent: number): string;
|
|
19
|
+
export declare function formatUploadProgress(loaded: number, total: number, percent: number, options?: FormatFileSizeOptions): string;
|
|
18
20
|
//# sourceMappingURL=format-upload-progress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-upload-progress.d.ts","sourceRoot":"","sources":["../../src/helpers/format-upload-progress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format-upload-progress.d.ts","sourceRoot":"","sources":["../../src/helpers/format-upload-progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,CAIR"}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { formatSpeed } from "./format-speed";
|
|
|
4
4
|
export { formatEta } from "./format-eta";
|
|
5
5
|
export { useFormatValidateFileError } from "./format-validate-file-error";
|
|
6
6
|
export { useFormatDimahError } from "./format-dimah-error";
|
|
7
|
+
export { useFormatFileSize, useFormatNumber } from "./format-number";
|
|
7
8
|
export { createThrottledSpeedUpdater } from "./throttled-speed";
|
|
8
9
|
export { loadRouteCatalog, mergeRouteUploadPolicy, resolveRouteUploadPolicy, } from "./load-route-catalog";
|
|
9
10
|
export type { RouteUploadPolicy } from "./load-route-catalog";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-file-intake.d.ts","sourceRoot":"","sources":["../../src/hooks/use-file-intake.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB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Aa,EAAE,CAAC;CAC1C,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,oBAAoB,GAC5B,mBAAmB,CAkGrB;AAED,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { StoredUpload, UploadStore } from "./types/upload-store";
|
|
|
3
3
|
export type { DownloadPhase, DownloadHooks, FetchDownloadPhase, FetchDownloadProgress, FetchDownloadHooks, } from "./types/download";
|
|
4
4
|
export type { DeletePhase, DeleteHooks } from "./types/delete";
|
|
5
5
|
export { S3UploadError } from "./types/error";
|
|
6
|
-
export { APIError, S3_ERROR_CODES, buildObjectKey, fileNameFromKey, formatFileSize, isAPIError, isS3ErrorCode, sanitizeFileName, validateFile, sha256Base64, sha256File, matchesMagicBytes, sniffContentType, buildPublicObjectUrl, buildContentDisposition, type S3Api, type S3ErrorCode, type ValidateFileError, type InferS3Routes, type DimahS3Routes, type S3RouteName, type RouteCatalogResponse, } from "@dimah-s3/core";
|
|
6
|
+
export { APIError, S3_ERROR_CODES, buildObjectKey, fileNameFromKey, formatFileSize, resolveInlineDisposition, isAPIError, isS3ErrorCode, sanitizeFileName, validateFile, sha256Base64, sha256File, matchesMagicBytes, sniffContentType, buildPublicObjectUrl, buildContentDisposition, type FormatFileSizeOptions, type S3Api, type S3ErrorCode, type ValidateFileError, type InferS3Routes, type DimahS3Routes, type S3RouteName, type RouteCatalogResponse, } from "@dimah-s3/core";
|
|
7
7
|
export { defineApi } from "./api";
|
|
8
8
|
export { createS3Client, type CreateS3ClientOptions, type CreateS3ClientResult, type ReactS3Client, } from "./create-s3-client";
|
|
9
9
|
export { S3Provider, useApi, type S3ProviderProps } from "./s3-provider";
|
|
@@ -11,7 +11,7 @@ export { S3Provider, useApi, type S3ProviderProps } from "./s3-provider";
|
|
|
11
11
|
export type { Translations } from "./translations";
|
|
12
12
|
export { createLocalStorageStore, createMemoryStore } from "./store";
|
|
13
13
|
export { uploadFile, uploadFiles, multipartResumeKey, DEFAULT_MULTIPART_THRESHOLD, type UploadEngineCallbacks, type FileItem, type FileItemStatus, type MultiUploadCallbacks, } from "./upload";
|
|
14
|
-
export { formatAcceptLabels, formatUploadProgress, formatSpeed, formatEta, useFormatDimahError, useFormatValidateFileError, loadRouteCatalog, mergeRouteUploadPolicy, resolveRouteUploadPolicy, } from "./helpers";
|
|
14
|
+
export { formatAcceptLabels, formatUploadProgress, formatSpeed, formatEta, useFormatDimahError, useFormatFileSize, useFormatNumber, useFormatValidateFileError, loadRouteCatalog, mergeRouteUploadPolicy, resolveRouteUploadPolicy, } from "./helpers";
|
|
15
15
|
export type { RouteUploadPolicy } from "./helpers";
|
|
16
16
|
export { useUpload, type UseUploadOptions, type UseUploadReturn, type UploadPolicy, type FileRejection, type DropzoneRootProps, type DropzoneInputProps, } from "./hooks/use-upload";
|
|
17
17
|
export { useDownload, isFetchDownload, type UseDownloadOptions, type UseDownloadReturn, type UseNavigateDownloadOptions, type UseNavigateDownloadReturn, type UseFetchDownloadOptions, type UseFetchDownloadState, type UseFetchDownloadReturn, } from "./hooks/use-download";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACtE,YAAY,EACV,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,M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ACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,GAChC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACtE,YAAY,EACV,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB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AsB,EACtB,wBAAwB,GACzB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGnD,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,GAChC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createS3Client as createS3Client$1, sha256File, formatFileSize, isAPIError, S3_ERROR_CODES, parseFileName, DELETE_BATCH_MAX_KEYS, isS3ErrorCode, APIError, validateFile } from '@dimah-s3/core';
|
|
2
|
-
export { APIError, S3_ERROR_CODES, buildContentDisposition, buildObjectKey, buildPublicObjectUrl, fileNameFromKey, formatFileSize, isAPIError, isS3ErrorCode, matchesMagicBytes, sanitizeFileName, sha256Base64, sha256File, sniffContentType, validateFile } from '@dimah-s3/core';
|
|
3
|
-
import { createContext, useContext, useCallback, useState, useEffect, useRef,
|
|
2
|
+
export { APIError, S3_ERROR_CODES, buildContentDisposition, buildObjectKey, buildPublicObjectUrl, fileNameFromKey, formatFileSize, isAPIError, isS3ErrorCode, matchesMagicBytes, resolveInlineDisposition, sanitizeFileName, sha256Base64, sha256File, sniffContentType, validateFile } from '@dimah-s3/core';
|
|
3
|
+
import { createContext, useContext, useCallback, useMemo, useState, useEffect, useRef, useLayoutEffect } from 'react';
|
|
4
4
|
import { TranslationProvider, useTranslations } from '@fuma-translate/react';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
import { produce } from 'immer';
|
|
@@ -57,12 +57,14 @@ function defineApi(input) {
|
|
|
57
57
|
return input;
|
|
58
58
|
}
|
|
59
59
|
var S3Context = createContext(null);
|
|
60
|
+
var S3LocaleContext = createContext(void 0);
|
|
60
61
|
function S3Provider({
|
|
61
62
|
api,
|
|
62
63
|
translations,
|
|
64
|
+
locale,
|
|
63
65
|
children
|
|
64
66
|
}) {
|
|
65
|
-
return /* @__PURE__ */ jsx(S3Context.Provider, { value: api, children: translations ? /* @__PURE__ */ jsx(TranslationProvider, { translations, children }) : children });
|
|
67
|
+
return /* @__PURE__ */ jsx(S3Context.Provider, { value: api, children: /* @__PURE__ */ jsx(S3LocaleContext.Provider, { value: locale, children: translations ? /* @__PURE__ */ jsx(TranslationProvider, { translations, children }) : children }) });
|
|
66
68
|
}
|
|
67
69
|
function useApi() {
|
|
68
70
|
const ctx = useContext(S3Context);
|
|
@@ -655,13 +657,13 @@ function formatAcceptLabels(accept) {
|
|
|
655
657
|
if (!accept?.length) return [];
|
|
656
658
|
return [...new Set(accept.map(formatAcceptLabel))];
|
|
657
659
|
}
|
|
658
|
-
function formatUploadProgress(loaded, total, percent) {
|
|
659
|
-
const loadedStr = formatFileSize(loaded);
|
|
660
|
+
function formatUploadProgress(loaded, total, percent, options) {
|
|
661
|
+
const loadedStr = formatFileSize(loaded, options);
|
|
660
662
|
if (!total) return loadedStr;
|
|
661
|
-
return `${loadedStr} / ${formatFileSize(total)} (${Math.round(percent)}%)`;
|
|
663
|
+
return `${loadedStr} / ${formatFileSize(total, options)} (${Math.round(percent)}%)`;
|
|
662
664
|
}
|
|
663
|
-
function formatSpeed(bytesPerSecond) {
|
|
664
|
-
return `${formatFileSize(bytesPerSecond)}/s`;
|
|
665
|
+
function formatSpeed(bytesPerSecond, options) {
|
|
666
|
+
return `${formatFileSize(bytesPerSecond, options)}/s`;
|
|
665
667
|
}
|
|
666
668
|
|
|
667
669
|
// src/helpers/format-eta.ts
|
|
@@ -759,6 +761,38 @@ function useFormatDimahError() {
|
|
|
759
761
|
[t]
|
|
760
762
|
);
|
|
761
763
|
}
|
|
764
|
+
function useFormatFileSize() {
|
|
765
|
+
const locale = useContext(S3LocaleContext);
|
|
766
|
+
const t = useTranslations();
|
|
767
|
+
return useMemo(() => {
|
|
768
|
+
const units = {
|
|
769
|
+
B: t("B", { note: "file size unit" }),
|
|
770
|
+
KB: t("KB", { note: "file size unit" }),
|
|
771
|
+
MB: t("MB", { note: "file size unit" }),
|
|
772
|
+
GB: t("GB", { note: "file size unit" }),
|
|
773
|
+
TB: t("TB", { note: "file size unit" }),
|
|
774
|
+
PB: t("PB", { note: "file size unit" }),
|
|
775
|
+
EB: t("EB", { note: "file size unit" })
|
|
776
|
+
};
|
|
777
|
+
return (bytes) => formatFileSize(bytes, { locale, units });
|
|
778
|
+
}, [locale, t]);
|
|
779
|
+
}
|
|
780
|
+
function useFormatNumber() {
|
|
781
|
+
const locale = useContext(S3LocaleContext);
|
|
782
|
+
return useCallback(
|
|
783
|
+
(value) => locale ? numberFormat(locale).format(value) : String(value),
|
|
784
|
+
[locale]
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
var numberFormats = /* @__PURE__ */ new Map();
|
|
788
|
+
function numberFormat(locale) {
|
|
789
|
+
let format = numberFormats.get(locale);
|
|
790
|
+
if (!format) {
|
|
791
|
+
format = new Intl.NumberFormat(locale);
|
|
792
|
+
numberFormats.set(locale, format);
|
|
793
|
+
}
|
|
794
|
+
return format;
|
|
795
|
+
}
|
|
762
796
|
|
|
763
797
|
// src/helpers/throttled-speed.ts
|
|
764
798
|
function createThrottledSpeedUpdater(tracker, intervalMs = 500) {
|
|
@@ -1328,7 +1362,8 @@ function useFileIntake(options) {
|
|
|
1328
1362
|
const {
|
|
1329
1363
|
getRootProps,
|
|
1330
1364
|
getInputProps: getDropzoneInputProps,
|
|
1331
|
-
|
|
1365
|
+
inputRef,
|
|
1366
|
+
open: openDropzone,
|
|
1332
1367
|
isDragActive,
|
|
1333
1368
|
isDragAccept,
|
|
1334
1369
|
isDragReject,
|
|
@@ -1345,13 +1380,34 @@ function useFileIntake(options) {
|
|
|
1345
1380
|
onDropAccepted,
|
|
1346
1381
|
onDropRejected
|
|
1347
1382
|
});
|
|
1383
|
+
const inputsRef = useRef(/* @__PURE__ */ new Set());
|
|
1384
|
+
const attachInput = useCallback(
|
|
1385
|
+
(node) => {
|
|
1386
|
+
if (!node) return;
|
|
1387
|
+
inputsRef.current.add(node);
|
|
1388
|
+
inputRef.current = node;
|
|
1389
|
+
},
|
|
1390
|
+
[inputRef]
|
|
1391
|
+
);
|
|
1348
1392
|
const getInputProps = useCallback(
|
|
1349
|
-
(props) =>
|
|
1350
|
-
...
|
|
1351
|
-
|
|
1393
|
+
(props) => ({
|
|
1394
|
+
...getDropzoneInputProps({
|
|
1395
|
+
...props,
|
|
1396
|
+
...htmlAccept != null ? { accept: htmlAccept } : {}
|
|
1397
|
+
}),
|
|
1398
|
+
ref: attachInput
|
|
1352
1399
|
}),
|
|
1353
|
-
[getDropzoneInputProps, htmlAccept]
|
|
1400
|
+
[attachInput, getDropzoneInputProps, htmlAccept]
|
|
1354
1401
|
);
|
|
1402
|
+
const open = useCallback(() => {
|
|
1403
|
+
const inputs = inputsRef.current;
|
|
1404
|
+
for (const node of inputs) {
|
|
1405
|
+
if (!node.isConnected) inputs.delete(node);
|
|
1406
|
+
}
|
|
1407
|
+
const ref = inputRef;
|
|
1408
|
+
if (!ref.current?.isConnected) ref.current = [...inputs].at(-1) ?? null;
|
|
1409
|
+
openDropzone();
|
|
1410
|
+
}, [inputRef, openDropzone]);
|
|
1355
1411
|
return {
|
|
1356
1412
|
getRootProps,
|
|
1357
1413
|
getInputProps,
|
|
@@ -2405,6 +2461,6 @@ function normalizeFolder(folder) {
|
|
|
2405
2461
|
return parts.length > 0 ? parts.join("/") : null;
|
|
2406
2462
|
}
|
|
2407
2463
|
|
|
2408
|
-
export { DEFAULT_MULTIPART_THRESHOLD, S3Provider, S3UploadError, createLocalStorageStore, createMemoryStore, createS3Client, defineApi, formatAcceptLabels, formatEta, formatSpeed, formatUploadProgress, isFetchDownload, loadRouteCatalog, mergeRouteUploadPolicy, multipartResumeKey, readObjectListLevel, resolveRouteUploadPolicy, uploadFile, uploadFiles, useApi, useDelete, useDownload, useFormatDimahError, useFormatValidateFileError, useObjectList, useObjectUrl, useRouteUploadPolicy, useUpload };
|
|
2464
|
+
export { DEFAULT_MULTIPART_THRESHOLD, S3Provider, S3UploadError, createLocalStorageStore, createMemoryStore, createS3Client, defineApi, formatAcceptLabels, formatEta, formatSpeed, formatUploadProgress, isFetchDownload, loadRouteCatalog, mergeRouteUploadPolicy, multipartResumeKey, readObjectListLevel, resolveRouteUploadPolicy, uploadFile, uploadFiles, useApi, useDelete, useDownload, useFormatDimahError, useFormatFileSize, useFormatNumber, useFormatValidateFileError, useObjectList, useObjectUrl, useRouteUploadPolicy, useUpload };
|
|
2409
2465
|
//# sourceMappingURL=index.js.map
|
|
2410
2466
|
//# sourceMappingURL=index.js.map
|