1
0
Fork 0
mirror of synced 2024-06-28 19:10:33 +12:00

Add readonly prop to combobox

This commit is contained in:
Andrew Kingston 2021-11-23 16:40:31 +00:00
parent 4145f6eccc
commit 24a700f391
3 changed files with 8 additions and 4 deletions

View file

@ -6,6 +6,7 @@
export let value = null
export let label = undefined
export let disabled = false
export let readonly = false
export let labelPosition = "above"
export let error = null
export let placeholder = "Choose an option or type"
@ -33,6 +34,7 @@
{value}
{options}
{placeholder}
{readonly}
{getOptionLabel}
{getOptionValue}
on:change={onChange}

View file

@ -9,6 +9,7 @@
export let id = null
export let placeholder = "Choose an option or type"
export let disabled = false
export let readonly = false
export let error = null
export let options = []
export let getOptionLabel = option => option
@ -73,6 +74,7 @@
value={value || ""}
placeholder={placeholder || ""}
{disabled}
{readonly}
class="spectrum-Textfield-input spectrum-InputGroup-input"
/>
</div>

View file

@ -16,15 +16,15 @@
const dispatch = createEventDispatcher()
let focus = false
const updateValue = value => {
const updateValue = newValue => {
if (readonly) {
return
}
if (type === "number") {
const float = parseFloat(value)
value = isNaN(float) ? null : float
const float = parseFloat(newValue)
newValue = isNaN(float) ? null : float
}
dispatch("change", value)
dispatch("change", newValue)
}
const onFocus = () => {