@gateweb/react-utils 1.7.0 → 1.8.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,77 @@
1
+ 'use client';
2
+ var React = require('react');
3
+ var zustand = require('zustand');
4
+ var traditional = require('zustand/traditional');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var React__default = /*#__PURE__*/_interopDefault(React);
9
+
10
+ const createQueryStore = ({ query, handleChangeQuery })=>zustand.createStore()((set)=>({
11
+ query: {
12
+ ...query
13
+ },
14
+ changeQuery: (newQuery)=>{
15
+ set((pre)=>{
16
+ if (handleChangeQuery) {
17
+ return {
18
+ query: handleChangeQuery(pre.query, newQuery)
19
+ };
20
+ }
21
+ return {
22
+ query: {
23
+ ...pre.query,
24
+ ...newQuery
25
+ }
26
+ };
27
+ });
28
+ }
29
+ }));
30
+ const QueryContext = /*#__PURE__*/ React.createContext(null);
31
+ /**
32
+ * Provider to provide the store to the context
33
+ */ const QueryProvider = ({ children, query, handleChangeQuery })=>{
34
+ const storeRef = React.useRef(null);
35
+ if (!storeRef.current) {
36
+ storeRef.current = createQueryStore({
37
+ query,
38
+ handleChangeQuery
39
+ });
40
+ }
41
+ return /*#__PURE__*/ React__default.default.createElement(QueryContext.Provider, {
42
+ value: storeRef.current
43
+ }, children);
44
+ };
45
+ /**
46
+ * hook to get the store from the context
47
+ *
48
+ * because we want the return type of `selector` to be inferred by ts, we use HOF to implement the hook
49
+ *
50
+ * so you should use it like this:
51
+ *
52
+ * ```tsx
53
+ * const useQuery = useQueryContext<MyObject>(); // => will return the store hook
54
+ * const result = useQuery(q => q.query); // => will return the query object
55
+ * ```
56
+ *
57
+ * @example
58
+ *
59
+ * ```tsx
60
+ * const result1 = useQueryContext<MyObject>()(q => '1234');
61
+ * const result2 = useQueryContext<MyObject>()(q => q.changeQuery);
62
+ * const result3 = useQueryContext<MyObject>()(q => q.query);
63
+ * ```
64
+ */ const useQueryContext = ()=>{
65
+ const store = React.useContext(QueryContext);
66
+ if (!store) throw new Error('Missing QueryContext.Provider in the tree');
67
+ /**
68
+ * the hook to get the store
69
+ *
70
+ * @param selector - the selector to get the state from the store
71
+ * @param equalityFn - the equality function to compare the previous and next state, if it returns `true`, the component will not re-render
72
+ */ const useStore = (selector, equalityFn)=>traditional.useStoreWithEqualityFn(store, selector, equalityFn);
73
+ return useStore;
74
+ };
75
+
76
+ exports.QueryProvider = QueryProvider;
77
+ exports.useQueryContext = useQueryContext;
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- var react = require('react');
2
+ var React = require('react');
3
3
 
4
4
  /**
5
5
  * 倒數計時器
@@ -11,17 +11,17 @@ var react = require('react');
11
11
  * @param initialCountdown 倒數計時器初始值
12
12
  * @param enableReinitialize 允許重設初始值
13
13
  */ const useCountdown = (initialCountdown, enableReinitialize = false)=>{
14
- const [countdown, setCountdown] = react.useState(initialCountdown);
15
- const [isCounting, setIsCounting] = react.useState(false);
16
- const initialValues = react.useRef(initialCountdown);
17
- const isMounted = react.useRef(false);
18
- react.useEffect(()=>{
14
+ const [countdown, setCountdown] = React.useState(initialCountdown);
15
+ const [isCounting, setIsCounting] = React.useState(false);
16
+ const initialValues = React.useRef(initialCountdown);
17
+ const isMounted = React.useRef(false);
18
+ React.useEffect(()=>{
19
19
  isMounted.current = true;
20
20
  return ()=>{
21
21
  isMounted.current = false;
22
22
  };
23
23
  }, []);
24
- react.useEffect(()=>{
24
+ React.useEffect(()=>{
25
25
  if (isMounted.current && initialValues.current !== initialCountdown && enableReinitialize) {
26
26
  initialValues.current = initialCountdown;
27
27
  setCountdown(initialCountdown);
@@ -30,7 +30,7 @@ var react = require('react');
30
30
  initialCountdown,
31
31
  enableReinitialize
32
32
  ]);
33
- react.useEffect(()=>{
33
+ React.useEffect(()=>{
34
34
  let timer;
35
35
  if (isCounting && countdown > 0) {
36
36
  timer = setTimeout(()=>{
@@ -2,6 +2,130 @@ import { TExtractValueType, AtLeastOne } from './types.mjs';
2
2
  export * from './types.mjs';
3
3
  import React from 'react';
4
4
 
5
+ declare const FILE_SIZE_UNITS: readonly ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
6
+ type FileSizeUnit = (typeof FILE_SIZE_UNITS)[number];
7
+ /**
8
+ * 代表字節大小的類,提供各種格式化和轉換方法
9
+ */
10
+ declare class ByteSize {
11
+ private readonly bytes;
12
+ /**
13
+ * 建立一個新的 ByteSize 實例
14
+ * @param bytes 位元組數值
15
+ */
16
+ constructor(bytes: number);
17
+ /**
18
+ * 取得原始位元組數值
19
+ */
20
+ get value(): number;
21
+ /**
22
+ * 將位元組轉換為指定單位的數值
23
+ *
24
+ * @param unit 目標單位 (例如 'KB', 'MB', 'GB')
25
+ * @returns 轉換後的數值
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const size = createByteSize(1024);
30
+ * size.to('KB'); // 1
31
+ * size.to('MB'); // 0.0009765625
32
+ * ```
33
+ */
34
+ to(unit: FileSizeUnit): number;
35
+ /**
36
+ * 轉換為適當單位的可讀字符串
37
+ *
38
+ * @param unit 指定單位 (例如 'KB', 'MB', 'GB'),不指定則自動選擇最適合的單位
39
+ * @param decimals 小數點位數 (預設為 2)
40
+ * @returns 格式化後的字符串
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const size = createByteSize(1024);
45
+ * size.format(); // '1.00 KB'
46
+ * size.format('KB'); // '1.00 KB'
47
+ * size.format('MB', 3); // '0.001 MB'
48
+ * ```
49
+ */
50
+ format(unit?: FileSizeUnit, decimals?: number): string;
51
+ /**
52
+ * 比較兩個 ByteSize 實例
53
+ *
54
+ * @param other 要比較的另一個 ByteSize 實例
55
+ * @returns 比較結果:-1 表示小於,0 表示等於,1 表示大於
56
+ */
57
+ compareTo(other: ByteSize): number;
58
+ /**
59
+ * 轉換為字符串表示
60
+ * @returns 預設格式化的字符串
61
+ */
62
+ toString(): string;
63
+ }
64
+ /**
65
+ * 將位元組轉換為可讀字符串 (保留舊的 API 以確保向後兼容)
66
+ *
67
+ * @param bytes 位元組數值
68
+ * @param unit 目標單位 (例如 'KB', 'MB', 'GB'),不指定則自動選擇最適合的單位
69
+ * @param decimals 小數點位數 (預設為 2)
70
+ * @returns 格式化後的字符串
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * convertBytes(0) // '0 Bytes'
75
+ * convertBytes(1024, 'KB') // '1 KB'
76
+ * convertBytes(1024, 'KB', 2) // '1.00 KB'
77
+ * convertBytes(1024 * 1024, 'MB') // '1 MB'
78
+ * convertBytes(1024 * 1024, 'KB') // '1024 KB'
79
+ * ```
80
+ */
81
+ declare const convertBytes: (bytes: number, unit?: FileSizeUnit, decimals?: number) => string;
82
+
83
+ type SearchParamsObject = Record<string, string | number | boolean | null | undefined | (string | number | boolean)[]>;
84
+ /**
85
+ * 將單層物件轉換為 URLSearchParams 物件
86
+ * - 會自動排除 null、undefined、空字串和空陣列的值
87
+ * - 陣列會以逗號連接為字串
88
+ *
89
+ * @param obj - 要轉換的物件,只支援單層物件,其中值可以是 string、number、boolean、null、undefined 或字串陣列
90
+ * @returns URLSearchParams 實例
91
+ *
92
+ * @example
93
+ * const params = { a: '1', b: 123, c: false, d: ['1','2'], e: null, f: undefined, g: '', h: [] };
94
+ * objectToSearchParams(params).toString(); // 'a=1&b=123&c=false&d=1%2C2'
95
+ */
96
+ declare const objectToSearchParams: <T extends SearchParamsObject>(obj: T) => URLSearchParams;
97
+ /**
98
+ * 支援的型別轉換器類型
99
+ */
100
+ type TypeConverter = 'string' | 'number' | 'boolean' | 'array';
101
+ /**
102
+ * 型別轉換映射表
103
+ */
104
+ type TypeConverterMap<T extends object = Record<string, unknown>> = {
105
+ [K in keyof T]?: TypeConverter;
106
+ };
107
+ /**
108
+ * 將 URLSearchParams 或字串轉換為物件
109
+ *
110
+ * @param searchParams - 要轉換的搜尋參數字串或 URLSearchParams 實例
111
+ * @param typeMap - 可選的型別轉換映射表,用於指定每個參數的目標型別
112
+ * @returns
113
+ *
114
+ * @example
115
+ * const queryString = 'a=1&b=123&c=true&d=1,2,3&e=false';
116
+ * const result = searchParamsToObject(queryString);
117
+ * // result: { a: '1', b: '123', c: 'true', d: '1,2,3', e: 'false' }
118
+ * const result = searchParamsToObject(queryString, {
119
+ * a: 'string',
120
+ * b: 'number',
121
+ * c: 'boolean',
122
+ * d: 'array',
123
+ * e: 'boolean',
124
+ * });
125
+ * // result: { a: '1', b: 123, c: true, d: ['1', '2', '3'], e: false }
126
+ */
127
+ declare const searchParamsToObject: <T extends object = SearchParamsObject>(searchParams: string | URLSearchParams, typeMap?: TypeConverterMap<T>) => Partial<T>;
128
+
5
129
  type CamelToPascal<S extends string> = S extends `${infer Head}${infer Tail}` ? `${Uppercase<Head>}${Tail}` : S;
6
130
  /**
7
131
  * convert CamelCase string to PascalCase string
@@ -158,54 +282,69 @@ declare const snakeCase2CamelCase: <T extends Record<string, any>>(obj: T) => Tr
158
282
  declare const snakeCase2PascalCase: <T extends Record<string, any>>(obj: T) => TransformObjectKey<T, "SnakeToPascal">;
159
283
 
160
284
  /**
161
- * 取得去年今年以及明年期別陣列
285
+ * 將數字轉換成金額千分位格式
286
+ *
287
+ * @param num - 數字
162
288
  *
163
289
  * @example
164
- * // 假設 今年為 112 年
165
- * generatePeriodArray() // 11102 ~ 11312
290
+ *
291
+ * formatAmount(1234567) // '1,234,567'
166
292
  */
167
- declare const generatePeriodArray: () => string[];
293
+ declare const formatAmount: (num: number) => string;
168
294
  /**
169
- * 取得當前期別
170
- *
171
- * 報稅期限次期開始15日內
172
- *
173
- * 雙數月沒有特殊規則,期別皆為當月開頭
295
+ * 將字串的第 n - m 個字轉換成星號
174
296
  *
175
- * 單數月15號以前,期別為上個月否則為下個月開頭
297
+ * @param str - 字串
298
+ * @param n - 起始位置
299
+ * @param m - 結束位置
176
300
  *
177
301
  * @example
178
302
  *
179
- * // 假設今天是 111-02-15
180
- * getCurrentPeriod() // 11102
181
- * // 假設今天是 111-02-16
182
- * getCurrentPeriod() // 11102
183
- * // 假設今天是 111-03-15
184
- * getCurrentPeriod() // 11102
185
- * // 假設今天是 111-03-16
186
- * getCurrentPeriod() // 11104
303
+ * formatString('123456', 1, 4) // '1****6'
187
304
  */
188
- declare const getCurrentPeriod: () => string;
305
+ declare const formatStarMask: (str: string, n: number, m: number) => string;
189
306
  /**
190
- * 民國年轉西元年
191
- * @param dateString 日期字串
192
- * @param format 日期格式
307
+ * format file size to human readable string
308
+ *
309
+ * it will convert bytes to KB, MB, GB, TB, PB, EB, ZB, YB
310
+ *
311
+ * @param bytes file size in bytes
312
+ * @param decimals number of decimal places (default is 2)
313
+ *
193
314
  * @example
194
315
  *
195
- * rocEraToAd('1100201') // 20210201
196
- * rocEraToAd('11002', 'YYYYMM') // 202102
316
+ * ```js
317
+ * formatBytes(0) // 0 Bytes
318
+ * formatBytes(1024) // 1 KB
319
+ * formatBytes(1024, 2) // 1.00 KB
320
+ * formatBytes(1024 * 1024) // 1 MB
321
+ * ```
322
+ * @deprecated use `convertBytes` instead
197
323
  */
198
- declare const rocEraToAd: (dateString: string, format?: string) => string;
324
+ declare const formatBytes: (bytes: number, decimals?: number) => string;
325
+
199
326
  /**
200
- * 西元年轉民國年
201
- * @param dateString 日期字串
202
- * @param format 日期格式
203
- * @example
327
+ * 檢查兩個值是否相等(包含陣列等引用型別)
328
+ * - 支援基本型別的直接比較
329
+ * - 特別處理空陣列比較
330
+ * - 支援非空陣列的深度比較
204
331
  *
205
- * adToRocEra('20210201') // 1100201
206
- * adToRocEra('202102', 'YYYYMM') // 11002
332
+ * @param value1 - 第一個值
333
+ * @param value2 - 第二個值
334
+ * @returns 如果值相等則返回 true
335
+ *
336
+ * @example
337
+ * // 基本型別比較
338
+ * isEqual(1, 1); // true
339
+ * isEqual('abc', 'abc'); // true
340
+ * isEqual(null, null); // true
341
+ *
342
+ * // 陣列比較
343
+ * isEqual([], []); // true
344
+ * isEqual([1, 2], [1, 2]); // true
345
+ * isEqual([1, 2], [1, 3]); // false
207
346
  */
208
- declare const adToRocEra: (dateString: string, format?: string) => string;
347
+ declare const isEqual: (value1: unknown, value2: unknown) => boolean;
209
348
 
210
349
  /**
211
350
  * 將指定格式的物件轉換成類似 enum 的物件
@@ -323,53 +462,6 @@ declare const validateFileType: (file: File, accepts: string[]) => boolean;
323
462
  */
324
463
  declare const getMimeType: (fileName: string) => "image/jpeg" | "image/png" | "application/pdf" | "application/zip" | "text/csv" | "text/plain" | "application/octet-stream";
325
464
 
326
- type TCountdownActions = {
327
- /** 目前秒數 */
328
- countdown: number;
329
- /** 是否正在倒數計時 */
330
- isCounting: boolean;
331
- /** 開始倒數計時 */
332
- start: () => void;
333
- /** 停止倒數計時 */
334
- stop: () => void;
335
- /** 重置倒數計時 */
336
- reset: () => void;
337
- };
338
- /**
339
- * 倒數計時器
340
- *
341
- * 可以透過 start() 來啟動倒數計時器
342
- * 可以透過 stop() 來停止倒數計時器
343
- * 可以透過 reset() 來重置倒數計時器
344
- *
345
- * @param initialCountdown 倒數計時器初始值
346
- * @param enableReinitialize 允許重設初始值
347
- */
348
- declare const useCountdown: (initialCountdown: number, enableReinitialize?: boolean) => TCountdownActions;
349
-
350
- type TValueOptions<T> = AtLeastOne<{
351
- /**
352
- * The controlled value.
353
- */
354
- value?: T;
355
- /**
356
- * The default value.
357
- */
358
- defaultValue?: T;
359
- }>;
360
- /**
361
- * A hook to manage a value.
362
- *
363
- * @example
364
- *
365
- * ```tsx
366
- * const MyComponent = ({ value }: { value?: number }) => {
367
- * const [currentValue, setCurrentValue] = useValue({ value });
368
- * };
369
- * ```
370
- */
371
- declare const useValue: <T>({ value, defaultValue }: TValueOptions<T>) => readonly [T, (newValue: T) => void];
372
-
373
465
  declare function invariant(condition: any, message?: string | (() => string)): asserts condition;
374
466
 
375
467
  /**
@@ -395,8 +487,8 @@ declare const omit: <T extends object, K extends [...(keyof T)[]]>(object: T, ..
395
487
  * @param values 要排除的 value
396
488
  *
397
489
  * @example
398
- * const a = { a: undefined, b: null, c: 3, d: 4 };
399
- * const b = omitByValue(a, undefined, null); // { c: 3, d: 4 }
490
+ * const a = { a: undefined, b: null, c: 3, d: 4, e: [] };
491
+ * const b = omitByValue(a, undefined, null, []); // { c: 3, d: 4 }
400
492
  */
401
493
  declare const omitByValue: <T extends object, K extends any[]>(object: T, ...values: K) => Pick<T, { [K2 in keyof T]: T[K2] extends K[number] ? never : K2; }[keyof T]>;
402
494
  /**
@@ -419,8 +511,8 @@ declare const pick: <T extends object, K extends [...(keyof T)[]]>(object: T, ..
419
511
  *
420
512
  * @example
421
513
  *
422
- * const a = { a: 1, b: 2, c: 3, d: 4 };
423
- * const b = pickByValue(a, 1, 2); // { a: 1, b: 2 }
514
+ * const a = { a: 1, b: 2, c: 3, d: 4, e: [] };
515
+ * const b = pickByValue(a, 1, 2, []); // { a: 1, b: 2, e: [] }
424
516
  */
425
517
  declare const pickByValue: <T extends object, K extends any[]>(object: T, ...values: K) => Pick<T, { [K2 in keyof T]: T[K2] extends K[number] ? K2 : never; }[keyof T]>;
426
518
  /**
@@ -503,7 +595,11 @@ declare const debounce: <P, R>(fn: (...args: P[]) => R, delay: number) => (...ar
503
595
  */
504
596
  declare const throttle: <P, R>(fn: (...args: P[]) => R, delay: number) => (...args: P[]) => R | undefined;
505
597
 
506
- declare function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null>): React.RefCallback<T>;
598
+ /**
599
+ * Wait for a given amount of time
600
+ * @param ms time to wait in milliseconds
601
+ */
602
+ declare const wait: (ms: number) => void;
507
603
 
508
604
  /**
509
605
  * 中文
@@ -737,47 +833,6 @@ declare const isTWMobile: () => RegExp;
737
833
  */
738
834
  declare const isTWPhone: () => RegExp;
739
835
 
740
- /**
741
- * 將數字轉換成金額千分位格式
742
- *
743
- * @param num - 數字
744
- *
745
- * @example
746
- *
747
- * formatAmount(1234567) // '1,234,567'
748
- */
749
- declare const formatAmount: (num: number) => string;
750
- /**
751
- * 將字串的第 n - m 個字轉換成星號
752
- *
753
- * @param str - 字串
754
- * @param n - 起始位置
755
- * @param m - 結束位置
756
- *
757
- * @example
758
- *
759
- * formatString('123456', 1, 4) // '1****6'
760
- */
761
- declare const formatStarMask: (str: string, n: number, m: number) => string;
762
- /**
763
- * format file size to human readable string
764
- *
765
- * it will convert bytes to KB, MB, GB, TB, PB, EB, ZB, YB
766
- *
767
- * @param bytes file size in bytes
768
- * @param decimals number of decimal places (default is 2)
769
- *
770
- * @example
771
- *
772
- * ```js
773
- * formatBytes(0) // 0 Bytes
774
- * formatBytes(1024) // 1 KB
775
- * formatBytes(1024, 2) // 1.00 KB
776
- * formatBytes(1024 * 1024) // 1 MB
777
- * ```
778
- */
779
- declare const formatBytes: (bytes: number, decimals?: number) => string;
780
-
781
836
  /**
782
837
  * 檢查稅務編號是否符合正確的編號規則。
783
838
  *
@@ -822,11 +877,155 @@ declare const validTaxId: (taxId: string) => boolean;
822
877
  */
823
878
  declare const validateDateString: (dateString: string, format: string) => boolean;
824
879
 
880
+ type TQueryProps<Q> = {
881
+ /**
882
+ * the query object
883
+ */
884
+ query: Partial<Q>;
885
+ };
886
+ type TQueryState<Q> = {
887
+ /**
888
+ * trigger the change of query
889
+ *
890
+ * @param query - the new query
891
+ */
892
+ changeQuery: (query: TQueryProps<Q>['query']) => void;
893
+ } & TQueryProps<Q>;
894
+ type TInitialProps<Q> = Partial<TQueryProps<Q> & {
895
+ /**
896
+ * handle the change of query when calling `changeQuery`
897
+ *
898
+ * @param preQuery - the previous query
899
+ * @param newQuery - the new query
900
+ * @returns the custom new query
901
+ */
902
+ handleChangeQuery: (preQuery: TQueryProps<Q>['query'], newQuery: TQueryProps<Q>['query']) => TQueryProps<Q>['query'];
903
+ }>;
825
904
  /**
826
- * Wait for a given amount of time
827
- * @param ms time to wait in milliseconds
905
+ * Provider to provide the store to the context
828
906
  */
829
- declare const wait: (ms: number) => void;
907
+ declare const QueryProvider: <Q>({ children, query, handleChangeQuery, }: React.PropsWithChildren<TInitialProps<Q>>) => React.JSX.Element;
908
+ /**
909
+ * hook to get the store from the context
910
+ *
911
+ * because we want the return type of `selector` to be inferred by ts, we use HOF to implement the hook
912
+ *
913
+ * so you should use it like this:
914
+ *
915
+ * ```tsx
916
+ * const useQuery = useQueryContext<MyObject>(); // => will return the store hook
917
+ * const result = useQuery(q => q.query); // => will return the query object
918
+ * ```
919
+ *
920
+ * @example
921
+ *
922
+ * ```tsx
923
+ * const result1 = useQueryContext<MyObject>()(q => '1234');
924
+ * const result2 = useQueryContext<MyObject>()(q => q.changeQuery);
925
+ * const result3 = useQueryContext<MyObject>()(q => q.query);
926
+ * ```
927
+ */
928
+ declare const useQueryContext: <Q>() => <T>(selector: (state: TQueryState<Q>) => T, equalityFn?: (left: T, right: T) => boolean) => T;
929
+
930
+ type TCountdownActions = {
931
+ /** 目前秒數 */
932
+ countdown: number;
933
+ /** 是否正在倒數計時 */
934
+ isCounting: boolean;
935
+ /** 開始倒數計時 */
936
+ start: () => void;
937
+ /** 停止倒數計時 */
938
+ stop: () => void;
939
+ /** 重置倒數計時 */
940
+ reset: () => void;
941
+ };
942
+ /**
943
+ * 倒數計時器
944
+ *
945
+ * 可以透過 start() 來啟動倒數計時器
946
+ * 可以透過 stop() 來停止倒數計時器
947
+ * 可以透過 reset() 來重置倒數計時器
948
+ *
949
+ * @param initialCountdown 倒數計時器初始值
950
+ * @param enableReinitialize 允許重設初始值
951
+ */
952
+ declare const useCountdown: (initialCountdown: number, enableReinitialize?: boolean) => TCountdownActions;
953
+
954
+ type TValueOptions<T> = AtLeastOne<{
955
+ /**
956
+ * The controlled value.
957
+ */
958
+ value?: T;
959
+ /**
960
+ * The default value.
961
+ */
962
+ defaultValue?: T;
963
+ }>;
964
+ /**
965
+ * A hook to manage a value.
966
+ *
967
+ * @example
968
+ *
969
+ * ```tsx
970
+ * const MyComponent = ({ value }: { value?: number }) => {
971
+ * const [currentValue, setCurrentValue] = useValue({ value });
972
+ * };
973
+ * ```
974
+ */
975
+ declare const useValue: <T>({ value, defaultValue }: TValueOptions<T>) => readonly [T, (newValue: T) => void];
976
+
977
+ declare function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null>): React.RefCallback<T>;
978
+
979
+ /**
980
+ * 民國年轉西元年
981
+ * @param dateString 日期字串
982
+ * @param format 日期格式
983
+ * @example
984
+ *
985
+ * rocEraToAd('1100201') // 20210201
986
+ * rocEraToAd('11002', 'YYYYMM') // 202102
987
+ */
988
+ declare const rocEraToAd: (dateString: string, format?: string) => string;
989
+ /**
990
+ * 西元年轉民國年
991
+ * @param dateString 日期字串
992
+ * @param format 日期格式
993
+ * @example
994
+ *
995
+ * adToRocEra('20210201') // 1100201
996
+ * adToRocEra('202102', 'YYYYMM') // 11002
997
+ */
998
+ declare const adToRocEra: (dateString: string, format?: string) => string;
999
+
1000
+ /**
1001
+ * 取得去年今年以及明年期別陣列
1002
+ *
1003
+ * @example
1004
+ * // 假設 今年為 112 年
1005
+ * generatePeriodArray() // 11102 ~ 11312
1006
+ */
1007
+ declare const generatePeriodArray: () => string[];
1008
+ /**
1009
+ * 取得當前期別
1010
+ *
1011
+ * 報稅期限次期開始15日內
1012
+ *
1013
+ * 雙數月沒有特殊規則,期別皆為當月開頭
1014
+ *
1015
+ * 單數月15號以前,期別為上個月否則為下個月開頭
1016
+ *
1017
+ * @example
1018
+ *
1019
+ * // 假設今天是 111-02-15
1020
+ * getCurrentPeriod() // 11102
1021
+ * // 假設今天是 111-02-16
1022
+ * getCurrentPeriod() // 11102
1023
+ * // 假設今天是 111-03-15
1024
+ * getCurrentPeriod() // 11102
1025
+ * // 假設今天是 111-03-16
1026
+ * getCurrentPeriod() // 11104
1027
+ */
1028
+ declare const getCurrentPeriod: () => string;
830
1029
 
831
1030
  /**
832
1031
  * Downloads a file from a given source.
@@ -861,5 +1060,4 @@ declare const getLocalStorage: <T>(key: string, deCode?: boolean) => T | undefin
861
1060
  */
862
1061
  declare const setLocalStorage: (key: string, value: Record<string, any>, enCode?: boolean) => void;
863
1062
 
864
- export { adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, createEnumLikeObject, debounce, deepMerge, downloadFile, extractEnumLikeObject, fakeApi, formatAmount, formatBytes, formatStarMask, generatePeriodArray, getCurrentPeriod, getLocalStorage, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, isValidPassword, mergeRefs, omit, omitByValue, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, pick, pickByValue, rocEraToAd, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, useValue, validTaxId, validateDateString, validateFileType, wait };
865
- export type { PartialBy, RequiredBy, TCountdownActions };
1063
+ export { ByteSize, type PartialBy, QueryProvider, type RequiredBy, type TCountdownActions, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, convertBytes, createEnumLikeObject, debounce, deepMerge, downloadFile, extractEnumLikeObject, fakeApi, formatAmount, formatBytes, formatStarMask, generatePeriodArray, getCurrentPeriod, getLocalStorage, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isEqual, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, isValidPassword, mergeRefs, objectToSearchParams, omit, omitByValue, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, pick, pickByValue, rocEraToAd, searchParamsToObject, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, useQueryContext, useValue, validTaxId, validateDateString, validateFileType, wait };