@gateweb/react-utils 0.0.3 → 0.0.4

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.
@@ -1,3 +1,5 @@
1
+ export * from './types.js';
2
+
1
3
  type CamelToPascal<S extends string> = S extends `${infer Head}${infer Tail}` ? `${Uppercase<Head>}${Tail}` : S;
2
4
  /**
3
5
  * convert CamelCase string to PascalCase string
@@ -600,28 +602,4 @@ declare const getLocalStorage: <T>(key: string, deCode?: boolean) => T | undefin
600
602
  */
601
603
  declare const setLocalStorage: (key: string, value: Record<string, any>, enCode?: boolean) => void;
602
604
 
603
- /**
604
- * 從對象類型中提取特定屬性的值類型。
605
- *
606
- * @template T 要處理的對象類型
607
- * @template K 要提取的屬性名(字符串字面量類型)
608
- *
609
- * @description
610
- * 這個類型用於從一個對象類型 T 中提取指定屬性 K 的值類型。
611
- * T 應該是一個對象,其每個屬性都是另一個包含 K 屬性的對象。
612
- * 如果 T 不符合這個結構,或者指定的屬性 K 不存在,則返回 never。
613
- *
614
- * @example
615
- * type Obj = {
616
- * a: { value: string },
617
- * b: { value: number }
618
- * };
619
- * type Result = ExtractValueType<Obj, 'value'>; // string | number
620
- *
621
- * @returns 返回 T 中所有 K 屬性值的聯合類型,如果不符合條件則返回 never
622
- */
623
- type TExtractValueType<T, K extends string> = T extends Record<string, {
624
- [P in K]: infer R;
625
- }> ? R : never;
626
-
627
- export { type TCountdownActions, type TExtractValueType, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, debounce, downloadFile, formatAmount, formatStarMask, generatePeriodArray, getCurrentPeriod, getLocalStorage, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, omit, omitByValue, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, rocEraToAd, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, validTaxId, validateDateString, validateFileType };
605
+ export { type TCountdownActions, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, debounce, downloadFile, formatAmount, formatStarMask, generatePeriodArray, getCurrentPeriod, getLocalStorage, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, omit, omitByValue, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, rocEraToAd, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, validTaxId, validateDateString, validateFileType };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 從對象類型中提取特定屬性的值類型。
3
+ *
4
+ * @template T 要處理的對象類型
5
+ * @template K 要提取的屬性名(字符串字面量類型)
6
+ *
7
+ * @description
8
+ * 這個類型用於從一個對象類型 T 中提取指定屬性 K 的值類型。
9
+ * T 應該是一個對象,其每個屬性都是另一個包含 K 屬性的對象。
10
+ * 如果 T 不符合這個結構,或者指定的屬性 K 不存在,則返回 never。
11
+ *
12
+ * @example
13
+ * type Obj = {
14
+ * a: { value: string },
15
+ * b: { value: number }
16
+ * };
17
+ * type Result = ExtractValueType<Obj, 'value'>; // string | number
18
+ *
19
+ * @returns 返回 T 中所有 K 屬性值的聯合類型,如果不符合條件則返回 never
20
+ */
21
+ type TExtractValueType<T, K extends string> = T extends Record<string, {
22
+ [P in K]: infer R;
23
+ }> ? R : never;
24
+
25
+ export type { TExtractValueType };
@@ -0,0 +1 @@
1
+
@@ -1,3 +1,5 @@
1
+ export * from './types.mjs';
2
+
1
3
  type CamelToPascal<S extends string> = S extends `${infer Head}${infer Tail}` ? `${Uppercase<Head>}${Tail}` : S;
2
4
  /**
3
5
  * convert CamelCase string to PascalCase string
@@ -600,28 +602,4 @@ declare const getLocalStorage: <T>(key: string, deCode?: boolean) => T | undefin
600
602
  */
601
603
  declare const setLocalStorage: (key: string, value: Record<string, any>, enCode?: boolean) => void;
602
604
 
603
- /**
604
- * 從對象類型中提取特定屬性的值類型。
605
- *
606
- * @template T 要處理的對象類型
607
- * @template K 要提取的屬性名(字符串字面量類型)
608
- *
609
- * @description
610
- * 這個類型用於從一個對象類型 T 中提取指定屬性 K 的值類型。
611
- * T 應該是一個對象,其每個屬性都是另一個包含 K 屬性的對象。
612
- * 如果 T 不符合這個結構,或者指定的屬性 K 不存在,則返回 never。
613
- *
614
- * @example
615
- * type Obj = {
616
- * a: { value: string },
617
- * b: { value: number }
618
- * };
619
- * type Result = ExtractValueType<Obj, 'value'>; // string | number
620
- *
621
- * @returns 返回 T 中所有 K 屬性值的聯合類型,如果不符合條件則返回 never
622
- */
623
- type TExtractValueType<T, K extends string> = T extends Record<string, {
624
- [P in K]: infer R;
625
- }> ? R : never;
626
-
627
- export { type TCountdownActions, type TExtractValueType, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, debounce, downloadFile, formatAmount, formatStarMask, generatePeriodArray, getCurrentPeriod, getLocalStorage, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, omit, omitByValue, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, rocEraToAd, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, validTaxId, validateDateString, validateFileType };
605
+ export { type TCountdownActions, adToRocEra, camelCase2PascalCase, camelCase2SnakeCase, camelString2PascalString, camelString2SnakeString, debounce, downloadFile, formatAmount, formatStarMask, generatePeriodArray, getCurrentPeriod, getLocalStorage, getMimeType, invariant, isChinese, isDateString, isDateTimeString, isEmail, isEnglish, isNonZeroStart, isNumber, isNumberAtLeastN, isNumberN, isNumberNM, isServer, isTWMobile, isTWPhone, isTimeString, omit, omitByValue, pascalCase2CamelCase, pascalCase2SnakeCase, pascalString2CamelString, pascalString2SnakeString, rocEraToAd, setLocalStorage, snakeCase2CamelCase, snakeCase2PascalCase, snakeString2CamelString, snakeString2PascalString, throttle, useCountdown, validTaxId, validateDateString, validateFileType };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 從對象類型中提取特定屬性的值類型。
3
+ *
4
+ * @template T 要處理的對象類型
5
+ * @template K 要提取的屬性名(字符串字面量類型)
6
+ *
7
+ * @description
8
+ * 這個類型用於從一個對象類型 T 中提取指定屬性 K 的值類型。
9
+ * T 應該是一個對象,其每個屬性都是另一個包含 K 屬性的對象。
10
+ * 如果 T 不符合這個結構,或者指定的屬性 K 不存在,則返回 never。
11
+ *
12
+ * @example
13
+ * type Obj = {
14
+ * a: { value: string },
15
+ * b: { value: number }
16
+ * };
17
+ * type Result = ExtractValueType<Obj, 'value'>; // string | number
18
+ *
19
+ * @returns 返回 T 中所有 K 屬性值的聯合類型,如果不符合條件則返回 never
20
+ */
21
+ type TExtractValueType<T, K extends string> = T extends Record<string, {
22
+ [P in K]: infer R;
23
+ }> ? R : never;
24
+
25
+ export type { TExtractValueType };
@@ -0,0 +1 @@
1
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gateweb/react-utils",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "React Utils for GateWeb",
5
5
  "homepage": "https://github.com/GatewebSolutions/react-utils",
6
6
  "files": [
@@ -19,6 +19,16 @@
19
19
  "types": "./dist/cjs/index.d.ts",
20
20
  "default": "./dist/cjs/index.js"
21
21
  }
22
+ },
23
+ "./types": {
24
+ "import": {
25
+ "types": "./dist/es/types.d.mts",
26
+ "default": "./dist/es/types.mjs"
27
+ },
28
+ "require": {
29
+ "types": "./dist/cjs/types.d.ts",
30
+ "default": "./dist/cjs/types.js"
31
+ }
22
32
  }
23
33
  },
24
34
  "publishConfig": {