@gateweb/react-utils 1.16.0 → 2.0.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.
@@ -0,0 +1,289 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { AtLeastOne } from './types.mjs';
3
+
4
+ type TStoreProps<S> = {
5
+ /**
6
+ * the store object
7
+ */
8
+ store: Partial<S>;
9
+ };
10
+ type TStoreObject<S> = TStoreProps<S>['store'];
11
+ type TStoreState<S> = {
12
+ /**
13
+ * trigger the change of store
14
+ *
15
+ * @param updater - the new store or a update function
16
+ * @param options - the options for changing the store
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * // update with new store object
21
+ * changeStore({ key: 'newValue' });
22
+ * // update with a function
23
+ * changeStore(preStore => ({ ...preStore, key: 'newValue' }));
24
+ * ```
25
+ */
26
+ changeStore: (updater: TStoreObject<S> | ((preStore: TStoreObject<S>) => TStoreObject<S>), options?: {
27
+ merge: TInitialProps$1<S>['defaultMerge'];
28
+ }) => void;
29
+ } & TStoreProps<S>;
30
+ type TInitialProps$1<S> = TStoreProps<S> & {
31
+ /**
32
+ * handle the change of store when calling `changeStore`
33
+ *
34
+ * @param preStore - the previous store
35
+ * @param newStore - the new store
36
+ *
37
+ * @example
38
+ *
39
+ * ```tsx
40
+ * <StoreProvider store={{ key: 'value' }} handleChangeStore={(preStore, newStore) => {
41
+ * // Special handling: reset key when changing anotherKey
42
+ * if (newStore.anotherKey && newStore.anotherKey !== preStore.anotherKey) {
43
+ * return {
44
+ * ...preStore,
45
+ * ...newStore,
46
+ * key: 'resetValue',
47
+ * };
48
+ * }
49
+ * return {
50
+ * ...preStore,
51
+ * ...newStore,
52
+ * };
53
+ * }}>
54
+ * <App />
55
+ * </StoreProvider>
56
+ * ```
57
+ */
58
+ handleChangeStore?: (preStore: TStoreObject<S>, newStore: TStoreObject<S>) => TStoreObject<S>;
59
+ /**
60
+ * the default merge strategy when calling `changeStore`
61
+ *
62
+ * @default 'shallow'
63
+ *
64
+ * @example
65
+ *
66
+ * ```tsx
67
+ * // shallow merge
68
+ * <StoreProvider store={{ key: 'value', anotherKey: { nestedKey: 'nestedValue' } }}>
69
+ * // deep merge
70
+ * <StoreProvider store={{ key: 'value', anotherKey: { nestedKey: 'nestedValue' } }} defaultMerge="deep">
71
+ * ```
72
+ */
73
+ defaultMerge: 'shallow' | 'deep';
74
+ };
75
+ /**
76
+ * create a store context with provider and hooks
77
+ *
78
+ * @example
79
+ *
80
+ * ```tsx
81
+ * // create a store context
82
+ * const { StoreProvider, useStore, useStoreApi } = createStoreContext<MyObject>();
83
+ *
84
+ * // use the StoreProvider to provide the store to the context
85
+ * <StoreProvider store={{ key: 'value' }}>
86
+ * <App />
87
+ * </StoreProvider>
88
+ * ```
89
+ */
90
+ declare const createStoreContext: <S>() => {
91
+ StoreProvider: ({ children, store, handleChangeStore, defaultMerge, }: React.PropsWithChildren<Partial<TInitialProps$1<S>>>) => React.JSX.Element;
92
+ useStore: <T>(selector: (state: TStoreState<S>) => T, equalityFn?: (left: T, right: T) => boolean) => T;
93
+ };
94
+
95
+ type TQueryProps<Q> = {
96
+ /**
97
+ * the query object
98
+ */
99
+ query: Partial<Q>;
100
+ };
101
+ type TQueryState<Q> = {
102
+ /**
103
+ * trigger the change of query
104
+ *
105
+ * @param query - the new query
106
+ */
107
+ changeQuery: (query: TQueryProps<Q>['query']) => void;
108
+ } & TQueryProps<Q>;
109
+ type TInitialProps<Q> = Partial<TQueryProps<Q> & {
110
+ /**
111
+ * handle the change of query when calling `changeQuery`
112
+ *
113
+ * @param preQuery - the previous query
114
+ * @param newQuery - the new query
115
+ * @returns the custom new query
116
+ */
117
+ handleChangeQuery: (preQuery: TQueryProps<Q>['query'], newQuery: TQueryProps<Q>['query']) => TQueryProps<Q>['query'];
118
+ }>;
119
+ /**
120
+ * Provider to provide the store to the context
121
+ *
122
+ * @deprecated use `StoreProvider` from `core/store` instead
123
+ */
124
+ declare const QueryProvider: <Q>({ children, query, handleChangeQuery, }: React.PropsWithChildren<TInitialProps<Q>>) => React.JSX.Element;
125
+ /**
126
+ * hook to get the store from the context
127
+ *
128
+ * because we want the return type of `selector` to be inferred by ts, we use HOF to implement the hook
129
+ *
130
+ * so you should use it like this:
131
+ *
132
+ * ```tsx
133
+ * const useQuery = useQueryContext<MyObject>(); // => will return the store hook
134
+ * const result = useQuery(q => q.query); // => will return the query object
135
+ * ```
136
+ *
137
+ * @example
138
+ *
139
+ * ```tsx
140
+ * const result1 = useQueryContext<MyObject>()(q => '1234');
141
+ * const result2 = useQueryContext<MyObject>()(q => q.changeQuery);
142
+ * const result3 = useQueryContext<MyObject>()(q => q.query);
143
+ * ```
144
+ *
145
+ * @deprecated use `useStoreContext` from `core/store` instead
146
+ */
147
+ declare const useQueryContext: <Q>() => <T>(selector: (state: TQueryState<Q>) => T, equalityFn?: (left: T, right: T) => boolean) => T;
148
+
149
+ /**
150
+ * Creates a strongly-typed React Context and Provider pair for data sharing.
151
+ *
152
+ * This utility helps you avoid prop drilling by providing a reusable way to define
153
+ * context with strict type inference. It returns a custom hook for consuming the context
154
+ * and a Provider component for supplying context values.
155
+ *
156
+ * @template T - The value type for the context.
157
+ * @returns {object} An object containing:
158
+ * - useDataContext: A custom hook to access the context value. Throws an error if used outside the provider.
159
+ * - DataProvider: A Provider component to wrap your component tree and supply the context value.
160
+ *
161
+ * @example
162
+ * // Example usage:
163
+ * const { useDataContext, DataProvider } = createDataContext<{ count: number }>();
164
+ *
165
+ * function Counter() {
166
+ * const { count } = useDataContext();
167
+ * return <span>{count}</span>;
168
+ * }
169
+ *
170
+ * function App() {
171
+ * return (
172
+ * <DataProvider value={{ count: 42 }}>
173
+ * <Counter />
174
+ * </DataProvider>
175
+ * );
176
+ * }
177
+ */
178
+ declare const createDataContext: <T>() => {
179
+ readonly useDataContext: () => T & ({} | null);
180
+ readonly DataProvider: ({ children, value }: {
181
+ children: ReactNode;
182
+ value: T;
183
+ }) => React.JSX.Element;
184
+ };
185
+
186
+ type TCountdownActions = {
187
+ /** 目前秒數 */
188
+ countdown: number;
189
+ /** 是否正在倒數計時 */
190
+ isCounting: boolean;
191
+ /** 開始倒數計時 */
192
+ start: () => void;
193
+ /** 停止倒數計時 */
194
+ stop: () => void;
195
+ /** 重置倒數計時 */
196
+ reset: () => void;
197
+ };
198
+ /**
199
+ * 倒數計時器
200
+ *
201
+ * 可以透過 start() 來啟動倒數計時器
202
+ * 可以透過 stop() 來停止倒數計時器
203
+ * 可以透過 reset() 來重置倒數計時器
204
+ *
205
+ * @param initialCountdown 倒數計時器初始值
206
+ * @param enableReinitialize 允許重設初始值
207
+ */
208
+ declare const useCountdown: (initialCountdown: number, enableReinitialize?: boolean) => TCountdownActions;
209
+
210
+ type UseDisclosureReturn = {
211
+ /** Whether the disclosure is currently open. */
212
+ isOpen: boolean;
213
+ /** Open the disclosure (sets isOpen = true). */
214
+ open: () => void;
215
+ /** Close the disclosure (sets isOpen = false). */
216
+ close: () => void;
217
+ /** Toggle the disclosure state (open -> close or close -> open). */
218
+ toggle: () => void;
219
+ };
220
+ /**
221
+ * A small hook to control open/close state.
222
+ *
223
+ * Supports an optional controlled pattern by passing `isOpen` and `onChange`.
224
+ *
225
+ * @example
226
+ * const { isOpen, open, close, toggle } = useDisclosure();
227
+ */
228
+ declare function useDisclosure(initialState?: boolean): UseDisclosureReturn;
229
+
230
+ type TValueOptions<T> = AtLeastOne<{
231
+ /**
232
+ * The controlled value.
233
+ */
234
+ value?: T;
235
+ /**
236
+ * The default value.
237
+ */
238
+ defaultValue?: T;
239
+ }>;
240
+ /**
241
+ * A hook to manage a value.
242
+ *
243
+ * @example
244
+ *
245
+ * ```tsx
246
+ * const MyComponent = ({ value }: { value?: number }) => {
247
+ * const [currentValue, setCurrentValue] = useValue({ value });
248
+ * };
249
+ * ```
250
+ */
251
+ declare const useValue: <T>({ value, defaultValue }: TValueOptions<T>) => readonly [T, (newValue: T) => void];
252
+
253
+ declare function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null>): React.RefCallback<T>;
254
+
255
+ /**
256
+ * Downloads a file from a given source.
257
+ *
258
+ * @param source - The source of the file to be downloaded. It can be a URL string or a Blob object.
259
+ * @param filename - The name of the file to be downloaded. Defaults to the current timestamp if not provided.
260
+ * @param fileExtension - The file extension to be appended to the filename. Optional.
261
+ *
262
+ * @example
263
+ * downloadFile('http://example.com/file.txt', 'testfile', 'txt');
264
+ * downloadFile(new Blob(['test content'], { type: 'text/plain' }), 'testfile', 'txt');
265
+ */
266
+ declare const downloadFile: (source: string | Blob, filename?: string, fileExtension?: string) => void;
267
+
268
+ /**
269
+ * 從 localStorage 取得資料,支援槽狀取值(Json 物件)
270
+ *
271
+ * @param key 鍵值
272
+ * @param deCode 是否解碼
273
+ * @returns 取得的資料
274
+ * @example
275
+ * const data = getLocalStorage('key');
276
+ *
277
+ * const data = getLocalStorage('key.subKey');
278
+ */
279
+ declare const getLocalStorage: <T>(key: string, deCode?: boolean) => T | undefined;
280
+ /**
281
+ * 將資料(Json 物件)存入 localStorage
282
+ * @param key 鍵值
283
+ * @param value 可序列化的資料
284
+ * @param enCode 是否編碼
285
+ */
286
+ declare const setLocalStorage: (key: string, value: Record<string, any>, enCode?: boolean) => void;
287
+
288
+ export { QueryProvider, createDataContext, createStoreContext, downloadFile, getLocalStorage, mergeRefs, setLocalStorage, useCountdown, useDisclosure, useQueryContext, useValue };
289
+ export type { TCountdownActions, UseDisclosureReturn };
@@ -0,0 +1,103 @@
1
+ export { c as createStoreContext } from './store-12s-DsXc3Uo0.mjs';
2
+ export { Q as QueryProvider, u as useQueryContext } from './queryStore-12s-Dkb-Af1n.mjs';
3
+ import React, { useMemo, createContext, useContext, useState, useCallback } from 'react';
4
+ export { u as useCountdown } from './useCountdown-12s-t52WIHfq.mjs';
5
+ export { u as useDisclosure } from './useDisclosure-12s-BQAHpAXK.mjs';
6
+ export { d as downloadFile } from './download-12s-CnaJ0p_f.mjs';
7
+ export { g as getLocalStorage, s as setLocalStorage } from './webStorage-12s-Bo7x8q5t.mjs';
8
+
9
+ /**
10
+ * Creates a strongly-typed React Context and Provider pair for data sharing.
11
+ *
12
+ * This utility helps you avoid prop drilling by providing a reusable way to define
13
+ * context with strict type inference. It returns a custom hook for consuming the context
14
+ * and a Provider component for supplying context values.
15
+ *
16
+ * @template T - The value type for the context.
17
+ * @returns {object} An object containing:
18
+ * - useDataContext: A custom hook to access the context value. Throws an error if used outside the provider.
19
+ * - DataProvider: A Provider component to wrap your component tree and supply the context value.
20
+ *
21
+ * @example
22
+ * // Example usage:
23
+ * const { useDataContext, DataProvider } = createDataContext<{ count: number }>();
24
+ *
25
+ * function Counter() {
26
+ * const { count } = useDataContext();
27
+ * return <span>{count}</span>;
28
+ * }
29
+ *
30
+ * function App() {
31
+ * return (
32
+ * <DataProvider value={{ count: 42 }}>
33
+ * <Counter />
34
+ * </DataProvider>
35
+ * );
36
+ * }
37
+ */ const createDataContext = ()=>{
38
+ const Context = /*#__PURE__*/ createContext(undefined);
39
+ const useDataContext = ()=>{
40
+ const context = useContext(Context);
41
+ if (context === undefined) {
42
+ throw new Error(`useDataContext must be used within a DataProvider`);
43
+ }
44
+ return context;
45
+ };
46
+ const DataProvider = ({ children, value })=>{
47
+ const memoized = useMemo(()=>value, [
48
+ value
49
+ ]);
50
+ return /*#__PURE__*/ React.createElement(Context.Provider, {
51
+ value: memoized
52
+ }, children);
53
+ };
54
+ return {
55
+ useDataContext,
56
+ DataProvider
57
+ };
58
+ };
59
+
60
+ /**
61
+ * A hook to manage a value.
62
+ *
63
+ * @example
64
+ *
65
+ * ```tsx
66
+ * const MyComponent = ({ value }: { value?: number }) => {
67
+ * const [currentValue, setCurrentValue] = useValue({ value });
68
+ * };
69
+ * ```
70
+ */ const useValue = ({ value, defaultValue })=>{
71
+ if (value === undefined && defaultValue === undefined) {
72
+ throw new Error('Either `value` or `defaultValue` must be provided.');
73
+ }
74
+ const isControlled = value !== undefined;
75
+ const [internalValue, setInternalValue] = useState(defaultValue);
76
+ const setValue = useCallback((newValue)=>{
77
+ if (!isControlled) {
78
+ setInternalValue(newValue);
79
+ }
80
+ }, [
81
+ isControlled
82
+ ]);
83
+ const currentValue = isControlled ? value : internalValue;
84
+ return [
85
+ currentValue,
86
+ setValue
87
+ ];
88
+ };
89
+
90
+ function mergeRefs(refs) {
91
+ return (value)=>{
92
+ refs.forEach((ref)=>{
93
+ if (typeof ref === 'function') {
94
+ ref(value);
95
+ } else if (ref != null) {
96
+ // eslint-disable-next-line no-param-reassign
97
+ ref.current = value;
98
+ }
99
+ });
100
+ };
101
+ }
102
+
103
+ export { createDataContext, mergeRefs, useValue };
@@ -1,7 +1,73 @@
1
- import React, { ReactNode } from 'react';
2
- import { AtLeastOne } from './types.mjs';
3
1
  export * from './types.mjs';
4
2
 
3
+ /**
4
+ * 將位元組陣列編碼為 base64 字串
5
+ *
6
+ * @param bytes 要編碼的位元組陣列
7
+ * @returns base64 編碼的字串
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const bytes = new TextEncoder().encode('Hello World');
12
+ * const encoded = encodeBase64(bytes);
13
+ * console.log(encoded); // 'SGVsbG8gV29ybGQ='
14
+ * ```
15
+ */
16
+ declare const encodeBase64: (bytes: Uint8Array) => string;
17
+ /**
18
+ * 將 base64 字串解碼為位元組陣列
19
+ *
20
+ * @param base64 要解碼的 base64 字串(支援 base64url 格式)
21
+ * @returns 解碼後的位元組陣列
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const decoded = decodeBase64('SGVsbG8gV29ybGQ=');
26
+ * const text = new TextDecoder().decode(decoded);
27
+ * console.log(text); // 'Hello World'
28
+ * ```
29
+ */
30
+ declare const decodeBase64: (base64: string) => Uint8Array;
31
+ /**
32
+ * JSON 可序列化的資料類型
33
+ */
34
+ type JsonSerializable = string | number | boolean | null | JsonSerializable[] | {
35
+ [key: string]: JsonSerializable;
36
+ };
37
+ /**
38
+ * 將 JSON 資料編碼為 base64 字串
39
+ *
40
+ * @param data 要編碼的 JSON 可序列化資料
41
+ * @returns base64 編碼的字串
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const data = { name: 'John', age: 30 };
46
+ * const encoded = encodeJson(data);
47
+ * console.log(encoded); // 'eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9'
48
+ *
49
+ * const array = [1, 2, 3];
50
+ * const encodedArray = encodeJson(array);
51
+ * ```
52
+ */
53
+ declare const encodeJson: <T extends JsonSerializable>(data: T) => string;
54
+ /**
55
+ * 將 base64 字串解碼為 JSON 資料
56
+ *
57
+ * @param b64 要解碼的 base64 字串
58
+ * @returns 解碼後的資料
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const encoded = 'eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9';
63
+ * const decoded = decodeJson<{ name: string; age: number }>(encoded);
64
+ * console.log(decoded); // { name: 'John', age: 30 }
65
+ *
66
+ * const decodedArray = decodeJson<number[]>(encodedArray);
67
+ * ```
68
+ */
69
+ declare const decodeJson: <T extends JsonSerializable>(b64: string) => T;
70
+
5
71
  declare const FILE_SIZE_UNITS: readonly ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
6
72
  type FileSizeUnit = (typeof FILE_SIZE_UNITS)[number];
7
73
  /**
@@ -1115,162 +1181,6 @@ declare const validateDateString: (dateString: string, format: string) => boolea
1115
1181
  */
1116
1182
  declare const isNil: (value: unknown) => value is null | undefined;
1117
1183
 
1118
- type TQueryProps<Q> = {
1119
- /**
1120
- * the query object
1121
- */
1122
- query: Partial<Q>;
1123
- };
1124
- type TQueryState<Q> = {
1125
- /**
1126
- * trigger the change of query
1127
- *
1128
- * @param query - the new query
1129
- */
1130
- changeQuery: (query: TQueryProps<Q>['query']) => void;
1131
- } & TQueryProps<Q>;
1132
- type TInitialProps<Q> = Partial<TQueryProps<Q> & {
1133
- /**
1134
- * handle the change of query when calling `changeQuery`
1135
- *
1136
- * @param preQuery - the previous query
1137
- * @param newQuery - the new query
1138
- * @returns the custom new query
1139
- */
1140
- handleChangeQuery: (preQuery: TQueryProps<Q>['query'], newQuery: TQueryProps<Q>['query']) => TQueryProps<Q>['query'];
1141
- }>;
1142
- /**
1143
- * Provider to provide the store to the context
1144
- */
1145
- declare const QueryProvider: <Q>({ children, query, handleChangeQuery, }: React.PropsWithChildren<TInitialProps<Q>>) => React.JSX.Element;
1146
- /**
1147
- * hook to get the store from the context
1148
- *
1149
- * because we want the return type of `selector` to be inferred by ts, we use HOF to implement the hook
1150
- *
1151
- * so you should use it like this:
1152
- *
1153
- * ```tsx
1154
- * const useQuery = useQueryContext<MyObject>(); // => will return the store hook
1155
- * const result = useQuery(q => q.query); // => will return the query object
1156
- * ```
1157
- *
1158
- * @example
1159
- *
1160
- * ```tsx
1161
- * const result1 = useQueryContext<MyObject>()(q => '1234');
1162
- * const result2 = useQueryContext<MyObject>()(q => q.changeQuery);
1163
- * const result3 = useQueryContext<MyObject>()(q => q.query);
1164
- * ```
1165
- */
1166
- declare const useQueryContext: <Q>() => <T>(selector: (state: TQueryState<Q>) => T, equalityFn?: (left: T, right: T) => boolean) => T;
1167
-
1168
- /**
1169
- * Creates a strongly-typed React Context and Provider pair for data sharing.
1170
- *
1171
- * This utility helps you avoid prop drilling by providing a reusable way to define
1172
- * context with strict type inference. It returns a custom hook for consuming the context
1173
- * and a Provider component for supplying context values.
1174
- *
1175
- * @template T - The value type for the context.
1176
- * @returns {object} An object containing:
1177
- * - useDataContext: A custom hook to access the context value. Throws an error if used outside the provider.
1178
- * - DataProvider: A Provider component to wrap your component tree and supply the context value.
1179
- *
1180
- * @example
1181
- * // Example usage:
1182
- * const { useDataContext, DataProvider } = createDataContext<{ count: number }>();
1183
- *
1184
- * function Counter() {
1185
- * const { count } = useDataContext();
1186
- * return <span>{count}</span>;
1187
- * }
1188
- *
1189
- * function App() {
1190
- * return (
1191
- * <DataProvider value={{ count: 42 }}>
1192
- * <Counter />
1193
- * </DataProvider>
1194
- * );
1195
- * }
1196
- */
1197
- declare const createDataContext: <T>() => {
1198
- readonly useDataContext: () => T & ({} | null);
1199
- readonly DataProvider: ({ children, value }: {
1200
- children: ReactNode;
1201
- value: T;
1202
- }) => React.JSX.Element;
1203
- };
1204
-
1205
- type TCountdownActions = {
1206
- /** 目前秒數 */
1207
- countdown: number;
1208
- /** 是否正在倒數計時 */
1209
- isCounting: boolean;
1210
- /** 開始倒數計時 */
1211
- start: () => void;
1212
- /** 停止倒數計時 */
1213
- stop: () => void;
1214
- /** 重置倒數計時 */
1215
- reset: () => void;
1216
- };
1217
- /**
1218
- * 倒數計時器
1219
- *
1220
- * 可以透過 start() 來啟動倒數計時器
1221
- * 可以透過 stop() 來停止倒數計時器
1222
- * 可以透過 reset() 來重置倒數計時器
1223
- *
1224
- * @param initialCountdown 倒數計時器初始值
1225
- * @param enableReinitialize 允許重設初始值
1226
- */
1227
- declare const useCountdown: (initialCountdown: number, enableReinitialize?: boolean) => TCountdownActions;
1228
-
1229
- type UseDisclosureReturn = {
1230
- /** Whether the disclosure is currently open. */
1231
- isOpen: boolean;
1232
- /** Open the disclosure (sets isOpen = true). */
1233
- open: () => void;
1234
- /** Close the disclosure (sets isOpen = false). */
1235
- close: () => void;
1236
- /** Toggle the disclosure state (open -> close or close -> open). */
1237
- toggle: () => void;
1238
- };
1239
- /**
1240
- * A small hook to control open/close state.
1241
- *
1242
- * Supports an optional controlled pattern by passing `isOpen` and `onChange`.
1243
- *
1244
- * @example
1245
- * const { isOpen, open, close, toggle } = useDisclosure();
1246
- */
1247
- declare function useDisclosure(initialState?: boolean): UseDisclosureReturn;
1248
-
1249
- type TValueOptions<T> = AtLeastOne<{
1250
- /**
1251
- * The controlled value.
1252
- */
1253
- value?: T;
1254
- /**
1255
- * The default value.
1256
- */
1257
- defaultValue?: T;
1258
- }>;
1259
- /**
1260
- * A hook to manage a value.
1261
- *
1262
- * @example
1263
- *
1264
- * ```tsx
1265
- * const MyComponent = ({ value }: { value?: number }) => {
1266
- * const [currentValue, setCurrentValue] = useValue({ value });
1267
- * };
1268
- * ```
1269
- */
1270
- declare const useValue: <T>({ value, defaultValue }: TValueOptions<T>) => readonly [T, (newValue: T) => void];
1271
-
1272
- declare function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null>): React.RefCallback<T>;
1273
-
1274
1184
  /**
1275
1185
  * 民國年轉西元年
1276
1186
  * @param dateString 日期字串
@@ -1322,38 +1232,5 @@ declare const generatePeriodArray: () => string[];
1322
1232
  */
1323
1233
  declare const getCurrentPeriod: () => string;
1324
1234
 
1325
- /**
1326
- * Downloads a file from a given source.
1327
- *
1328
- * @param source - The source of the file to be downloaded. It can be a URL string or a Blob object.
1329
- * @param filename - The name of the file to be downloaded. Defaults to the current timestamp if not provided.
1330
- * @param fileExtension - The file extension to be appended to the filename. Optional.
1331
- *
1332
- * @example
1333
- * downloadFile('http://example.com/file.txt', 'testfile', 'txt');
1334
- * downloadFile(new Blob(['test content'], { type: 'text/plain' }), 'testfile', 'txt');
1335
- */
1336
- declare const downloadFile: (source: string | Blob, filename?: string, fileExtension?: string) => void;
1337
-
1338
- /**
1339
- * 從 localStorage 取得資料,支援槽狀取值
1340
- *
1341
- * @param key 鍵值
1342
- * @param deCode 是否解碼
1343
- * @returns 取得的資料
1344
- * @example
1345
- * const data = getLocalStorage('key');
1346
- *
1347
- * const data = getLocalStorage('key.subKey');
1348
- */
1349
- declare const getLocalStorage: <T>(key: string, deCode?: boolean) => T | undefined;
1350
- /**
1351
- * 將資料存入 localStorage
1352
- * @param key 鍵值
1353
- * @param value 可序列化的資料
1354
- * @param enCode 是否編碼
1355
- */
1356
- declare const setLocalStorage: (key: string, value: Record<string, any>, enCode?: boolean) => void;
1357
-
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 };
1359
- export type { MimeTypeExtension, MimeTypeValue, PartialBy, RequiredBy, TCountdownActions, UseDisclosureReturn };
1235
+ export { ByteSize, MimeTypeMap, OtherMimeType, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, convertBytes, createEnumLikeObject, debounce, decodeBase64, decodeJson, deepClone, deepMerge, encodeBase64, encodeJson, extractEnumLikeObject, fakeApi, formatAmount, formatBytes, formatStarMask, generatePeriodArray, getCurrentPeriod, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isEqual, isNil, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, isValidPassword, maskString, mergeConfig, objectToSearchParams, omit, omitByValue, parseFileInfoFromFilename, parseFilenameFromDisposition, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, pick, pickByValue, renameKey, rocEraToAd, searchParamsToObject, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, validTaxId, validateDateString, validateFileType, wait };
1236
+ export type { MimeTypeExtension, MimeTypeValue, PartialBy, RequiredBy };