1
0
Fork 0
mirror of synced 2024-08-23 05:51:29 +12:00

Allow Fancy Input validation to be triggered onBlur (#13658)

* Add free_trial to deploy camunda script

* Allow for more validation customisation on fancy input
This commit is contained in:
melohagan 2024-05-10 13:18:30 +01:00 committed by GitHub
parent 58538cc201
commit efaedbccde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,6 +11,7 @@
export let error = null
export let validate = null
export let suffix = null
export let validateOn = "change"
const dispatch = createEventDispatcher()
@ -24,7 +25,16 @@
const newValue = e.target.value
dispatch("change", newValue)
value = newValue
if (validate) {
if (validate && (error || validateOn === "change")) {
error = validate(newValue)
}
}
const onBlur = e => {
focused = false
const newValue = e.target.value
dispatch("blur", newValue)
if (validate && validateOn === "blur") {
error = validate(newValue)
}
}
@ -61,7 +71,7 @@
type={type || "text"}
on:input={onChange}
on:focus={() => (focused = true)}
on:blur={() => (focused = false)}
on:blur={onBlur}
class:placeholder
bind:this={ref}
/>