Add readonly prop to combobox
This commit is contained in:
parent
4145f6eccc
commit
24a700f391
|
@ -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}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 = () => {
|
||||
|
|
Loading…
Reference in New Issue