|
|
|
@ -7,7 +7,7 @@ |
|
|
|
|
|
|
|
export let value = null |
|
|
|
export let id = null |
|
|
|
export let placeholder = "Choose an option" |
|
|
|
export let placeholder = "Choose an option or type" |
|
|
|
export let disabled = false |
|
|
|
export let error = null |
|
|
|
export let options = [] |
|
|
|
@ -22,7 +22,7 @@ |
|
|
|
const getFieldText = (value, options, placeholder) => { |
|
|
|
// Always use placeholder if no value |
|
|
|
if (value == null || value === "") { |
|
|
|
return placeholder || "Choose an option" |
|
|
|
return placeholder || "Choose an option or type" |
|
|
|
} |
|
|
|
|
|
|
|
// Wait for options to load if there is a value but no options |
|
|
|
@ -43,12 +43,19 @@ |
|
|
|
const onChange = e => { |
|
|
|
selectOption(e.target.value) |
|
|
|
} |
|
|
|
|
|
|
|
$: console.log(disabled) |
|
|
|
</script> |
|
|
|
|
|
|
|
<div class="spectrum-InputGroup" class:is-focused={open || focus}> |
|
|
|
<div |
|
|
|
class="spectrum-InputGroup" |
|
|
|
class:is-focused={open || focus} |
|
|
|
class:is-invalid={!!error} |
|
|
|
class:is-disabled={disabled}> |
|
|
|
<div |
|
|
|
class="spectrum-Textfield spectrum-InputGroup-textfield" |
|
|
|
class:is-disabled={!!error} |
|
|
|
class:is-invalid={!!error} |
|
|
|
class:is-disabled={disabled} |
|
|
|
class:is-focused={open || focus}> |
|
|
|
<input |
|
|
|
type="text" |
|
|
|
@ -56,6 +63,7 @@ |
|
|
|
on:blur={() => (focus = false)} |
|
|
|
on:change={onChange} |
|
|
|
{value} |
|
|
|
{disabled} |
|
|
|
{placeholder} |
|
|
|
class="spectrum-Textfield-input spectrum-InputGroup-input" /> |
|
|
|
</div> |
|
|
|
@ -63,7 +71,7 @@ |
|
|
|
class="spectrum-Picker spectrum-Picker--sizeM spectrum-InputGroup-button" |
|
|
|
tabindex="-1" |
|
|
|
aria-haspopup="true" |
|
|
|
disabled={!!error} |
|
|
|
{disabled} |
|
|
|
on:click={() => (open = true)}> |
|
|
|
<svg |
|
|
|
class="spectrum-Icon spectrum-UIIcon-ChevronDown100 spectrum-Picker-menuIcon spectrum-InputGroup-icon" |
|
|
|
@ -108,6 +116,9 @@ |
|
|
|
min-width: 0; |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
.spectrum-Textfield { |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
.spectrum-Textfield-input { |
|
|
|
width: 0; |
|
|
|
} |
|
|
|
|