@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.
@@ -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
- value: any;
267
- label: string;
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
@@ -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 };
@@ -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
- value: any;
267
- label: string;
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
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gateweb/react-utils",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "React Utils for GateWeb",
5
5
  "homepage": "https://github.com/GatewebSolutions/react-utils",
6
6
  "files": [