This commit is contained in:
Gerard Burns 2023-11-21 13:02:06 +00:00
parent aed2328523
commit 217ac49628
1 changed files with 12 additions and 6 deletions

View File

@ -21,7 +21,7 @@
let focus = false let focus = false
const updateValue = newValue => { const updateValue = newValue => {
if (readonly) { if (readonly || disabled) {
return return
} }
if (type === "number") { if (type === "number") {
@ -32,14 +32,14 @@
} }
const onFocus = () => { const onFocus = () => {
if (readonly) { if (readonly || disabled) {
return return
} }
focus = true focus = true
} }
const onBlur = event => { const onBlur = event => {
if (readonly) { if (readonly || disabled) {
return return
} }
focus = false focus = false
@ -47,14 +47,14 @@
} }
const onInput = event => { const onInput = event => {
if (readonly || !updateOnChange) { if (readonly || !updateOnChange || disabled) {
return return
} }
updateValue(event.target.value) updateValue(event.target.value)
} }
const updateValueOnEnter = event => { const updateValueOnEnter = event => {
if (readonly) { if (readonly || disabled) {
return return
} }
if (event.key === "Enter") { if (event.key === "Enter") {
@ -66,10 +66,12 @@
if (type === "bigint") { if (type === "bigint") {
return "numeric" return "numeric"
} }
return type === "number" ? "decimal" : "text" return type === "number" ?
"decimal" : "text"
} }
onMount(() => { onMount(() => {
if (disabled) return;
focus = autofocus focus = autofocus
if (focus) field.focus() if (focus) field.focus()
}) })
@ -119,4 +121,8 @@
.spectrum-Textfield { .spectrum-Textfield {
width: 100%; width: 100%;
} }
input:focus:hover::placeholder {
color: var(--grey-8) !important;
}
</style> </style>