1
0
Fork 0
mirror of synced 2024-07-05 06:20:55 +12:00

Fix combobox disabled state and remove unnecessary props

This commit is contained in:
Andrew Kingston 2021-04-29 15:24:59 +01:00
parent bd8269619c
commit b5ee768cb1
13 changed files with 28 additions and 18 deletions

View file

@ -17,6 +17,6 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<Checkbox {error} {disabled} {text} {value} on:change={onChange} /> <Checkbox {error} {disabled} {text} {value} on:change={onChange} />
</Field> </Field>

View file

@ -8,7 +8,7 @@
export let disabled = false export let disabled = false
export let labelPosition = "above" export let labelPosition = "above"
export let error = null export let error = null
export let placeholder = "Choose an option" export let placeholder = "Choose an option or type"
export let options = [] export let options = []
export let getOptionLabel = option => extractProperty(option, "label") export let getOptionLabel = option => extractProperty(option, "label")
export let getOptionValue = option => extractProperty(option, "value") export let getOptionValue = option => extractProperty(option, "value")
@ -26,7 +26,7 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<Combobox <Combobox
{error} {error}
{disabled} {disabled}

View file

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

View file

@ -18,7 +18,7 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<DatePicker <DatePicker
{error} {error}
{disabled} {disabled}

View file

@ -19,7 +19,7 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<CoreDropzone <CoreDropzone
{error} {error}
{disabled} {disabled}

View file

@ -5,7 +5,6 @@
export let id = null export let id = null
export let label = null export let label = null
export let labelPosition = "above" export let labelPosition = "above"
export let disabled = false
export let error = null export let error = null
</script> </script>

View file

@ -19,7 +19,7 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<TextField <TextField
{error} {error}
{disabled} {disabled}

View file

@ -21,7 +21,7 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<Multiselect <Multiselect
{error} {error}
{disabled} {disabled}

View file

@ -25,7 +25,7 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<RadioGroup <RadioGroup
{error} {error}
{disabled} {disabled}

View file

@ -16,7 +16,7 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled}> <Field {label} {labelPosition}>
<Search <Search
{disabled} {disabled}
{value} {value}

View file

@ -27,7 +27,7 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<Select <Select
{error} {error}
{disabled} {disabled}

View file

@ -18,7 +18,7 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<TextArea <TextArea
bind:getCaretPosition bind:getCaretPosition
{error} {error}

View file

@ -17,6 +17,6 @@
} }
</script> </script>
<Field {label} {labelPosition} {disabled} {error}> <Field {label} {labelPosition} {error}>
<Switch {error} {disabled} {text} {value} on:change={onChange} /> <Switch {error} {disabled} {text} {value} on:change={onChange} />
</Field> </Field>