Add on change action to string field
This commit is contained in:
parent
e7ca90cd6b
commit
5d2c337d5d
|
@ -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 New Issue