@imaginario27/air-ui-utils 1.0.4 → 1.0.6
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/package.json +2 -2
- package/utils/data.ts +9 -4
- package/utils/formValidation.ts +0 -2
- package/utils/pdfExport.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imaginario27/air-ui-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"author": "imaginario27",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://air-ui.netlify.app/",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"happy-dom": "18.0.1",
|
|
33
33
|
"prettier": "3.6.2",
|
|
34
34
|
"ts-node": "10.9.2",
|
|
35
|
-
"typescript": "5.9.
|
|
35
|
+
"typescript": "5.9.3",
|
|
36
36
|
"vitest": "3.2.4"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/utils/data.ts
CHANGED
|
@@ -56,7 +56,7 @@ export function getPaginatedData<T>(
|
|
|
56
56
|
* value: user => slugify(user.name),
|
|
57
57
|
* })
|
|
58
58
|
*/
|
|
59
|
-
export const convertToSelectOptions = <T
|
|
59
|
+
export const convertToSelectOptions = <T extends Record<string, any>>(
|
|
60
60
|
originArray: T[],
|
|
61
61
|
keyMap: Partial<Record<keyof SelectOption, keyof T | ((item: T) => any)>>
|
|
62
62
|
): SelectOption[] => {
|
|
@@ -68,14 +68,18 @@ export const convertToSelectOptions = <T = Record<string, any>>(
|
|
|
68
68
|
.map((item) => {
|
|
69
69
|
const option: Partial<SelectOption> = {}
|
|
70
70
|
|
|
71
|
-
for (const [
|
|
71
|
+
for (const [rawKey, source] of Object.entries(keyMap) as [
|
|
72
|
+
keyof SelectOption,
|
|
73
|
+
keyof T | ((item: T) => any)
|
|
74
|
+
][]) {
|
|
72
75
|
const value =
|
|
73
76
|
typeof source === 'function'
|
|
74
77
|
? source(item)
|
|
75
|
-
: item[source
|
|
78
|
+
: item[source]
|
|
76
79
|
|
|
77
80
|
if (value !== undefined) {
|
|
78
|
-
|
|
81
|
+
// Prevents error by casting to indexable object
|
|
82
|
+
;(option as Record<keyof SelectOption, unknown>)[rawKey] = value
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
|
|
@@ -92,3 +96,4 @@ export const convertToSelectOptions = <T = Record<string, any>>(
|
|
|
92
96
|
})
|
|
93
97
|
.filter(Boolean) as SelectOption[]
|
|
94
98
|
}
|
|
99
|
+
|
package/utils/formValidation.ts
CHANGED
package/utils/pdfExport.ts
CHANGED