@gateweb/react-utils 1.1.0 → 1.1.1
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 +3 -5
- package/dist/cjs/types.d.ts +16 -1
- package/dist/es/index.d.mts +3 -5
- package/dist/es/types.d.mts +16 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -262,11 +262,9 @@ declare const extractEnumLikeObject: <T extends Record<string, { [P in K]: any;
|
|
|
262
262
|
declare const createEnumLikeObject: <T extends Record<string, {
|
|
263
263
|
value: any;
|
|
264
264
|
label: string;
|
|
265
|
-
}>, N extends string>(obj: T, name: N) => { [K in `Enum${N}` | `${N}List` | `get${N}Label`]: K extends `Enum${N}` ? { [key in keyof T]: T[key]["value"]; } : K extends `${N}List` ? {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
key: string;
|
|
269
|
-
}[] : (value: TExtractValueType<T, "value">) => string | TExtractValueType<T, "value">; };
|
|
265
|
+
}>, N extends string>(obj: T, name: N) => { [K in `Enum${N}` | `${N}List` | `get${N}Label`]: K extends `Enum${N}` ? { [key in keyof T]: T[key]["value"]; } : K extends `${N}List` ? ({
|
|
266
|
+
key: keyof T;
|
|
267
|
+
} & T[keyof T])[] : (value: TExtractValueType<T, "value">) => string | TExtractValueType<T, "value">; };
|
|
270
268
|
|
|
271
269
|
/**
|
|
272
270
|
* simulate a fake api request
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -21,5 +21,20 @@
|
|
|
21
21
|
type TExtractValueType<T, K extends string> = T extends Record<string, {
|
|
22
22
|
[P in K]: infer R;
|
|
23
23
|
}> ? R : never;
|
|
24
|
+
/**
|
|
25
|
+
* A utility type that transforms an object type `T` into an array of its entries.
|
|
26
|
+
* Each entry is represented as a tuple where the first element is the key of type `K`
|
|
27
|
+
* and the second element is the corresponding value of type `T[K]`.
|
|
28
|
+
*
|
|
29
|
+
* @template T - The object type to transform into entries.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* type Example = { a: number; b: string };
|
|
33
|
+
* type ExampleEntries = Entries<Example>;
|
|
34
|
+
* // Result: ExampleEntries is [ ["a", number], ["b", string] ]
|
|
35
|
+
*/
|
|
36
|
+
type Entries<T> = {
|
|
37
|
+
[K in keyof T]: [K, T[K]];
|
|
38
|
+
}[keyof T][];
|
|
24
39
|
|
|
25
|
-
export type { TExtractValueType };
|
|
40
|
+
export type { Entries, TExtractValueType };
|
package/dist/es/index.d.mts
CHANGED
|
@@ -262,11 +262,9 @@ declare const extractEnumLikeObject: <T extends Record<string, { [P in K]: any;
|
|
|
262
262
|
declare const createEnumLikeObject: <T extends Record<string, {
|
|
263
263
|
value: any;
|
|
264
264
|
label: string;
|
|
265
|
-
}>, N extends string>(obj: T, name: N) => { [K in `Enum${N}` | `${N}List` | `get${N}Label`]: K extends `Enum${N}` ? { [key in keyof T]: T[key]["value"]; } : K extends `${N}List` ? {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
key: string;
|
|
269
|
-
}[] : (value: TExtractValueType<T, "value">) => string | TExtractValueType<T, "value">; };
|
|
265
|
+
}>, N extends string>(obj: T, name: N) => { [K in `Enum${N}` | `${N}List` | `get${N}Label`]: K extends `Enum${N}` ? { [key in keyof T]: T[key]["value"]; } : K extends `${N}List` ? ({
|
|
266
|
+
key: keyof T;
|
|
267
|
+
} & T[keyof T])[] : (value: TExtractValueType<T, "value">) => string | TExtractValueType<T, "value">; };
|
|
270
268
|
|
|
271
269
|
/**
|
|
272
270
|
* simulate a fake api request
|
package/dist/es/types.d.mts
CHANGED
|
@@ -21,5 +21,20 @@
|
|
|
21
21
|
type TExtractValueType<T, K extends string> = T extends Record<string, {
|
|
22
22
|
[P in K]: infer R;
|
|
23
23
|
}> ? R : never;
|
|
24
|
+
/**
|
|
25
|
+
* A utility type that transforms an object type `T` into an array of its entries.
|
|
26
|
+
* Each entry is represented as a tuple where the first element is the key of type `K`
|
|
27
|
+
* and the second element is the corresponding value of type `T[K]`.
|
|
28
|
+
*
|
|
29
|
+
* @template T - The object type to transform into entries.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* type Example = { a: number; b: string };
|
|
33
|
+
* type ExampleEntries = Entries<Example>;
|
|
34
|
+
* // Result: ExampleEntries is [ ["a", number], ["b", string] ]
|
|
35
|
+
*/
|
|
36
|
+
type Entries<T> = {
|
|
37
|
+
[K in keyof T]: [K, T[K]];
|
|
38
|
+
}[keyof T][];
|
|
24
39
|
|
|
25
|
-
export type { TExtractValueType };
|
|
40
|
+
export type { Entries, TExtractValueType };
|