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