@gateweb/react-utils 1.2.0 → 1.3.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 +8 -2
- package/dist/cjs/index.js +20 -1
- package/dist/es/index.d.mts +8 -2
- package/dist/es/index.mjs +20 -2
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TExtractValueType } from './types.js';
|
|
2
2
|
export * from './types.js';
|
|
3
|
+
import React from 'react';
|
|
3
4
|
|
|
4
5
|
type CamelToPascal<S extends string> = S extends `${infer Head}${infer Tail}` ? `${Uppercase<Head>}${Tail}` : S;
|
|
5
6
|
/**
|
|
@@ -279,8 +280,11 @@ declare const createEnumLikeObject: <T extends Record<string, {
|
|
|
279
280
|
* console.log(result); // { result: true, data: { foo: 'bar' } }
|
|
280
281
|
*/
|
|
281
282
|
declare const fakeApi: <T>(returnValue: T, result?: boolean, time?: number) => Promise<{
|
|
282
|
-
result:
|
|
283
|
+
result: true;
|
|
283
284
|
data: T;
|
|
285
|
+
} | {
|
|
286
|
+
result: false;
|
|
287
|
+
message: string;
|
|
284
288
|
}>;
|
|
285
289
|
|
|
286
290
|
/**
|
|
@@ -427,6 +431,8 @@ declare const debounce: <P, R>(fn: (...args: P[]) => R, delay: number) => (...ar
|
|
|
427
431
|
*/
|
|
428
432
|
declare const throttle: <P, R>(fn: (...args: P[]) => R, delay: number) => (...args: P[]) => R | undefined;
|
|
429
433
|
|
|
434
|
+
declare function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null>): React.RefCallback<T>;
|
|
435
|
+
|
|
430
436
|
/**
|
|
431
437
|
* 中文
|
|
432
438
|
*
|
|
@@ -783,4 +789,4 @@ declare const getLocalStorage: <T>(key: string, deCode?: boolean) => T | undefin
|
|
|
783
789
|
*/
|
|
784
790
|
declare const setLocalStorage: (key: string, value: Record<string, any>, enCode?: boolean) => void;
|
|
785
791
|
|
|
786
|
-
export { type TCountdownActions, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, createEnumLikeObject, debounce, 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, omit, omitByValue, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, pick, pickByValue, rocEraToAd, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, validTaxId, validateDateString, validateFileType, wait };
|
|
792
|
+
export { type TCountdownActions, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, createEnumLikeObject, debounce, 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, validTaxId, validateDateString, validateFileType, wait };
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2
2
|
|
|
3
3
|
var dayjs = require('dayjs');
|
|
4
4
|
var useCountdownClient = require('./useCountdown-client-CNjGBIUB.js');
|
|
5
|
+
require('react');
|
|
5
6
|
var downloadClient = require('./download-client-DKxkL92w.js');
|
|
6
7
|
var webStorageClient = require('./webStorage-client-BGQKUfrO.js');
|
|
7
8
|
|
|
@@ -392,10 +393,14 @@ const transformObjectKey = (obj, transformFunName)=>{
|
|
|
392
393
|
* console.log(result); // { result: true, data: { foo: 'bar' } }
|
|
393
394
|
*/ const fakeApi = (returnValue, result = true, time = 1000)=>new Promise((resolve)=>{
|
|
394
395
|
setTimeout(()=>{
|
|
395
|
-
resolve({
|
|
396
|
+
if (result) resolve({
|
|
396
397
|
result,
|
|
397
398
|
data: returnValue
|
|
398
399
|
});
|
|
400
|
+
else resolve({
|
|
401
|
+
result,
|
|
402
|
+
message: 'error'
|
|
403
|
+
});
|
|
399
404
|
}, time);
|
|
400
405
|
});
|
|
401
406
|
|
|
@@ -628,6 +633,19 @@ message) {
|
|
|
628
633
|
};
|
|
629
634
|
};
|
|
630
635
|
|
|
636
|
+
function mergeRefs(refs) {
|
|
637
|
+
return (value)=>{
|
|
638
|
+
refs.forEach((ref)=>{
|
|
639
|
+
if (typeof ref === 'function') {
|
|
640
|
+
ref(value);
|
|
641
|
+
} else if (ref != null) {
|
|
642
|
+
// eslint-disable-next-line no-param-reassign
|
|
643
|
+
ref.current = value;
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
|
|
631
649
|
/**
|
|
632
650
|
* 中文
|
|
633
651
|
*
|
|
@@ -893,6 +911,7 @@ exports.isTWMobile = isTWMobile;
|
|
|
893
911
|
exports.isTWPhone = isTWPhone;
|
|
894
912
|
exports.isTimeString = isTimeString;
|
|
895
913
|
exports.isValidPassword = isValidPassword;
|
|
914
|
+
exports.mergeRefs = mergeRefs;
|
|
896
915
|
exports.omit = omit;
|
|
897
916
|
exports.omitByValue = omitByValue;
|
|
898
917
|
exports.pascalCase2CamelCase = pascalCase2CamelCase;
|
package/dist/es/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TExtractValueType } from './types.mjs';
|
|
2
2
|
export * from './types.mjs';
|
|
3
|
+
import React from 'react';
|
|
3
4
|
|
|
4
5
|
type CamelToPascal<S extends string> = S extends `${infer Head}${infer Tail}` ? `${Uppercase<Head>}${Tail}` : S;
|
|
5
6
|
/**
|
|
@@ -279,8 +280,11 @@ declare const createEnumLikeObject: <T extends Record<string, {
|
|
|
279
280
|
* console.log(result); // { result: true, data: { foo: 'bar' } }
|
|
280
281
|
*/
|
|
281
282
|
declare const fakeApi: <T>(returnValue: T, result?: boolean, time?: number) => Promise<{
|
|
282
|
-
result:
|
|
283
|
+
result: true;
|
|
283
284
|
data: T;
|
|
285
|
+
} | {
|
|
286
|
+
result: false;
|
|
287
|
+
message: string;
|
|
284
288
|
}>;
|
|
285
289
|
|
|
286
290
|
/**
|
|
@@ -427,6 +431,8 @@ declare const debounce: <P, R>(fn: (...args: P[]) => R, delay: number) => (...ar
|
|
|
427
431
|
*/
|
|
428
432
|
declare const throttle: <P, R>(fn: (...args: P[]) => R, delay: number) => (...args: P[]) => R | undefined;
|
|
429
433
|
|
|
434
|
+
declare function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null>): React.RefCallback<T>;
|
|
435
|
+
|
|
430
436
|
/**
|
|
431
437
|
* 中文
|
|
432
438
|
*
|
|
@@ -783,4 +789,4 @@ declare const getLocalStorage: <T>(key: string, deCode?: boolean) => T | undefin
|
|
|
783
789
|
*/
|
|
784
790
|
declare const setLocalStorage: (key: string, value: Record<string, any>, enCode?: boolean) => void;
|
|
785
791
|
|
|
786
|
-
export { type TCountdownActions, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, createEnumLikeObject, debounce, 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, omit, omitByValue, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, pick, pickByValue, rocEraToAd, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, validTaxId, validateDateString, validateFileType, wait };
|
|
792
|
+
export { type TCountdownActions, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, createEnumLikeObject, debounce, 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, validTaxId, validateDateString, validateFileType, wait };
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
export { u as useCountdown } from './useCountdown-client-t52WIHfq.mjs';
|
|
3
|
+
import 'react';
|
|
3
4
|
export { d as downloadFile } from './download-client-CnaJ0p_f.mjs';
|
|
4
5
|
export { g as getLocalStorage, s as setLocalStorage } from './webStorage-client-Pd-loNCg.mjs';
|
|
5
6
|
|
|
@@ -386,10 +387,14 @@ const transformObjectKey = (obj, transformFunName)=>{
|
|
|
386
387
|
* console.log(result); // { result: true, data: { foo: 'bar' } }
|
|
387
388
|
*/ const fakeApi = (returnValue, result = true, time = 1000)=>new Promise((resolve)=>{
|
|
388
389
|
setTimeout(()=>{
|
|
389
|
-
resolve({
|
|
390
|
+
if (result) resolve({
|
|
390
391
|
result,
|
|
391
392
|
data: returnValue
|
|
392
393
|
});
|
|
394
|
+
else resolve({
|
|
395
|
+
result,
|
|
396
|
+
message: 'error'
|
|
397
|
+
});
|
|
393
398
|
}, time);
|
|
394
399
|
});
|
|
395
400
|
|
|
@@ -622,6 +627,19 @@ message) {
|
|
|
622
627
|
};
|
|
623
628
|
};
|
|
624
629
|
|
|
630
|
+
function mergeRefs(refs) {
|
|
631
|
+
return (value)=>{
|
|
632
|
+
refs.forEach((ref)=>{
|
|
633
|
+
if (typeof ref === 'function') {
|
|
634
|
+
ref(value);
|
|
635
|
+
} else if (ref != null) {
|
|
636
|
+
// eslint-disable-next-line no-param-reassign
|
|
637
|
+
ref.current = value;
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
|
|
625
643
|
/**
|
|
626
644
|
* 中文
|
|
627
645
|
*
|
|
@@ -852,4 +870,4 @@ message) {
|
|
|
852
870
|
*/ const wait = (ms)=>{
|
|
853
871
|
};
|
|
854
872
|
|
|
855
|
-
export { adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, createEnumLikeObject, debounce, extractEnumLikeObject, fakeApi, formatAmount, formatBytes, formatStarMask, generatePeriodArray, getCurrentPeriod, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, isValidPassword, omit, omitByValue, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, pick, pickByValue, rocEraToAd, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, validTaxId, validateDateString, validateFileType, wait };
|
|
873
|
+
export { adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, createEnumLikeObject, debounce, extractEnumLikeObject, fakeApi, formatAmount, formatBytes, formatStarMask, generatePeriodArray, getCurrentPeriod, 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, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, validTaxId, validateDateString, validateFileType, wait };
|