Extra typings
This commit is contained in:
parent
f697b94214
commit
48b4bf6fb4
|
@ -12,6 +12,8 @@
|
|||
import type { FieldApi, FieldState } from "."
|
||||
import { FieldValidation } from "@/index"
|
||||
|
||||
type ValueType = string | string[]
|
||||
|
||||
export let field: string | undefined = undefined
|
||||
export let label: string | undefined = undefined
|
||||
export let placeholder: string | undefined = undefined
|
||||
|
@ -19,8 +21,8 @@
|
|||
export let readonly: boolean = false
|
||||
export let validation: FieldValidation | undefined = undefined
|
||||
export let autocomplete: boolean = true
|
||||
export let defaultValue: string | string[] | undefined = undefined
|
||||
export let onChange: any
|
||||
export let defaultValue: ValueType | undefined = undefined
|
||||
export let onChange: (props: { value: ValueType }) => void
|
||||
export let filter: SearchFilter[]
|
||||
export let datasourceType: "table" | "user" = "table"
|
||||
export let primaryDisplay: string | undefined = undefined
|
||||
|
@ -89,14 +91,14 @@
|
|||
// Ensure backwards compatibility
|
||||
$: enrichedDefaultValue = enrichDefaultValue(defaultValue)
|
||||
|
||||
$: emptyValue = multiselect ? [] : undefined
|
||||
// We need to cast value to pass it down, as those components aren't typed
|
||||
$: emptyValue = multiselect ? [] : null
|
||||
$: displayValue = missingIDs.length ? emptyValue : (selectedValue as any)
|
||||
$: displayValue = (missingIDs.length ? emptyValue : selectedValue) as any
|
||||
|
||||
// Ensures that we flatten any objects so that only the IDs of the selected
|
||||
// rows are passed down. Not sure how this can be an object to begin with?
|
||||
const parseSelectedValue = (
|
||||
value: any,
|
||||
value: ValueType | undefined,
|
||||
multiselect: boolean
|
||||
): undefined | string | string[] => {
|
||||
return multiselect ? flatten(value) : flatten(value)[0]
|
||||
|
@ -141,7 +143,7 @@
|
|||
|
||||
// Builds a map of all available options, in a consistent structure
|
||||
const processOptions = (
|
||||
realValue: any | any[],
|
||||
realValue: ValueType | undefined,
|
||||
rows: Row[],
|
||||
primaryDisplay?: string
|
||||
) => {
|
||||
|
|
Loading…
Reference in New Issue