Add on change action to JSON field
This commit is contained in:
parent
bbaec2e50f
commit
0957b3195a
|
@ -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}
|
||||||
|
|
Loading…
Reference in New Issue