@gateweb/react-utils 1.16.0 → 1.17.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/cjs/index.d.ts +71 -3
- package/dist/cjs/index.js +34 -774
- package/dist/cjs/webStorage-12s-P8HpaTRP.js +911 -0
- package/dist/es/index.d.mts +71 -3
- package/dist/es/index.mjs +2 -746
- package/dist/es/webStorage-12s-gvD4qbeR.mjs +879 -0
- package/package.json +1 -1
- package/dist/cjs/webStorage-12s-DHr9PcPl.js +0 -53
- package/dist/es/webStorage-12s-W1DItzhS.mjs +0 -52
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,6 +2,74 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import { AtLeastOne } from './types.js';
|
|
3
3
|
export * from './types.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 將位元組陣列編碼為 base64 字串
|
|
7
|
+
*
|
|
8
|
+
* @param bytes 要編碼的位元組陣列
|
|
9
|
+
* @returns base64 編碼的字串
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const bytes = new TextEncoder().encode('Hello World');
|
|
14
|
+
* const encoded = encodeBase64(bytes);
|
|
15
|
+
* console.log(encoded); // 'SGVsbG8gV29ybGQ='
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare const encodeBase64: (bytes: Uint8Array) => string;
|
|
19
|
+
/**
|
|
20
|
+
* 將 base64 字串解碼為位元組陣列
|
|
21
|
+
*
|
|
22
|
+
* @param base64 要解碼的 base64 字串(支援 base64url 格式)
|
|
23
|
+
* @returns 解碼後的位元組陣列
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const decoded = decodeBase64('SGVsbG8gV29ybGQ=');
|
|
28
|
+
* const text = new TextDecoder().decode(decoded);
|
|
29
|
+
* console.log(text); // 'Hello World'
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare const decodeBase64: (base64: string) => Uint8Array;
|
|
33
|
+
/**
|
|
34
|
+
* JSON 可序列化的資料類型
|
|
35
|
+
*/
|
|
36
|
+
type JsonSerializable = string | number | boolean | null | JsonSerializable[] | {
|
|
37
|
+
[key: string]: JsonSerializable;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 將 JSON 資料編碼為 base64 字串
|
|
41
|
+
*
|
|
42
|
+
* @param data 要編碼的 JSON 可序列化資料
|
|
43
|
+
* @returns base64 編碼的字串
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const data = { name: 'John', age: 30 };
|
|
48
|
+
* const encoded = encodeJson(data);
|
|
49
|
+
* console.log(encoded); // 'eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9'
|
|
50
|
+
*
|
|
51
|
+
* const array = [1, 2, 3];
|
|
52
|
+
* const encodedArray = encodeJson(array);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare const encodeJson: <T extends JsonSerializable>(data: T) => string;
|
|
56
|
+
/**
|
|
57
|
+
* 將 base64 字串解碼為 JSON 資料
|
|
58
|
+
*
|
|
59
|
+
* @param b64 要解碼的 base64 字串
|
|
60
|
+
* @returns 解碼後的資料
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const encoded = 'eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9';
|
|
65
|
+
* const decoded = decodeJson<{ name: string; age: number }>(encoded);
|
|
66
|
+
* console.log(decoded); // { name: 'John', age: 30 }
|
|
67
|
+
*
|
|
68
|
+
* const decodedArray = decodeJson<number[]>(encodedArray);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare const decodeJson: <T extends JsonSerializable>(b64: string) => T;
|
|
72
|
+
|
|
5
73
|
declare const FILE_SIZE_UNITS: readonly ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
6
74
|
type FileSizeUnit = (typeof FILE_SIZE_UNITS)[number];
|
|
7
75
|
/**
|
|
@@ -1336,7 +1404,7 @@ declare const getCurrentPeriod: () => string;
|
|
|
1336
1404
|
declare const downloadFile: (source: string | Blob, filename?: string, fileExtension?: string) => void;
|
|
1337
1405
|
|
|
1338
1406
|
/**
|
|
1339
|
-
* 從 localStorage 取得資料,支援槽狀取值
|
|
1407
|
+
* 從 localStorage 取得資料,支援槽狀取值(Json 物件)
|
|
1340
1408
|
*
|
|
1341
1409
|
* @param key 鍵值
|
|
1342
1410
|
* @param deCode 是否解碼
|
|
@@ -1348,12 +1416,12 @@ declare const downloadFile: (source: string | Blob, filename?: string, fileExten
|
|
|
1348
1416
|
*/
|
|
1349
1417
|
declare const getLocalStorage: <T>(key: string, deCode?: boolean) => T | undefined;
|
|
1350
1418
|
/**
|
|
1351
|
-
*
|
|
1419
|
+
* 將資料(Json 物件)存入 localStorage
|
|
1352
1420
|
* @param key 鍵值
|
|
1353
1421
|
* @param value 可序列化的資料
|
|
1354
1422
|
* @param enCode 是否編碼
|
|
1355
1423
|
*/
|
|
1356
1424
|
declare const setLocalStorage: (key: string, value: Record<string, any>, enCode?: boolean) => void;
|
|
1357
1425
|
|
|
1358
|
-
export { ByteSize, MimeTypeMap, OtherMimeType, QueryProvider, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, convertBytes, createDataContext, createEnumLikeObject, debounce, deepClone, deepMerge, downloadFile, extractEnumLikeObject, fakeApi, formatAmount, formatBytes, formatStarMask, generatePeriodArray, getCurrentPeriod, getLocalStorage, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isEqual, isNil, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, isValidPassword, maskString, mergeConfig, mergeRefs, objectToSearchParams, omit, omitByValue, parseFileInfoFromFilename, parseFilenameFromDisposition, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, pick, pickByValue, renameKey, rocEraToAd, searchParamsToObject, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, useDisclosure, useQueryContext, useValue, validTaxId, validateDateString, validateFileType, wait };
|
|
1426
|
+
export { ByteSize, MimeTypeMap, OtherMimeType, QueryProvider, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, convertBytes, createDataContext, createEnumLikeObject, debounce, decodeBase64, decodeJson, deepClone, deepMerge, downloadFile, encodeBase64, encodeJson, extractEnumLikeObject, fakeApi, formatAmount, formatBytes, formatStarMask, generatePeriodArray, getCurrentPeriod, getLocalStorage, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isEqual, isNil, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, isValidPassword, maskString, mergeConfig, mergeRefs, objectToSearchParams, omit, omitByValue, parseFileInfoFromFilename, parseFilenameFromDisposition, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, pick, pickByValue, renameKey, rocEraToAd, searchParamsToObject, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, useDisclosure, useQueryContext, useValue, validTaxId, validateDateString, validateFileType, wait };
|
|
1359
1427
|
export type { MimeTypeExtension, MimeTypeValue, PartialBy, RequiredBy, TCountdownActions, UseDisclosureReturn };
|