Add on change action to string field
This commit is contained in:
parent
0957b3195a
commit
b886fe95c2
1 changed files with 10 additions and 1 deletions
|
@ -10,9 +10,17 @@
|
|||
export let validation
|
||||
export let defaultValue = ""
|
||||
export let align
|
||||
export let onChange
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Field
|
||||
|
@ -21,6 +29,7 @@
|
|||
{disabled}
|
||||
{validation}
|
||||
{defaultValue}
|
||||
{onChange}
|
||||
type={type === "number" ? "number" : "string"}
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
|
@ -29,7 +38,7 @@
|
|||
<CoreTextField
|
||||
updateOnChange={false}
|
||||
value={fieldState.value}
|
||||
on:change={e => fieldApi.setValue(e.detail)}
|
||||
on:change={handleChange}
|
||||
disabled={fieldState.disabled}
|
||||
error={fieldState.error}
|
||||
id={fieldState.fieldId}
|
||||
|
|
Loading…
Reference in a new issue