@imaginario27/air-ui-utils 1.0.5 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imaginario27/air-ui-utils",
3
- "version": "1.0.5",
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.2",
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 = Record<string, any>>(
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 [optionKey, source] of Object.entries(keyMap)) {
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 as keyof T]
78
+ : item[source]
76
79
 
77
80
  if (value !== undefined) {
78
- option[optionKey as keyof SelectOption] = value
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
+
@@ -1,6 +1,4 @@
1
1
 
2
- import { FieldError } from '@/models/constants/form'
3
-
4
2
  /**
5
3
  * Validates a field value to ensure it is not empty, null, or undefined.
6
4
  *
@@ -1,6 +1,6 @@
1
1
  import jsPDF from "jspdf"
2
2
  import autoTable from "jspdf-autotable"
3
- import type { Headers } from "@/models/types/pdfExportTable"
3
+ import type { Headers } from "../models/types/pdfExportTable"
4
4
 
5
5
  /**
6
6
  * Exports data to a PDF file.