Add on change action to JSON field

This commit is contained in:
Andrew Kingston 2022-04-14 09:47:00 +01:00
parent bbaec2e50f
commit 0957b3195a
1 changed files with 10 additions and 1 deletions

View File

@ -8,6 +8,7 @@
export let placeholder
export let disabled = false
export let defaultValue = ""
export let onChange
const component = getContext("component")
const validation = [
@ -33,6 +34,14 @@
return value
}
}
const handleChange = e => {
const value = parseValue(e.detail)
fieldApi.setValue(value)
if (onChange) {
onChange({ value })
}
}
</script>
<Field
@ -49,7 +58,7 @@
<div style="--height: {height};">
<CoreTextArea
value={serialiseValue(fieldState.value)}
on:change={e => fieldApi.setValue(parseValue(e.detail))}
on:change={handleChange}
disabled={fieldState.disabled}
error={fieldState.error}
id={fieldState.fieldId}