-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
196 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "covid-self-report", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"author": { | ||
"name": "Christian Müller", | ||
"email": "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<template> | ||
<div class="form-group" | ||
:class="[ | ||
{'input-group': hasIcon}, | ||
{'has-danger': error}, | ||
{'focused': focused}, | ||
{'input-group-alternative': alternative}, | ||
{'has-label': label || $slots.label}, | ||
{'has-success': valid === true}, | ||
{'has-danger': valid === false} | ||
]"> | ||
<slot name="label"> | ||
<label v-if="label" :class="labelClasses"> | ||
{{label}} | ||
<span v-if="required">*</span> | ||
</label> | ||
</slot> | ||
|
||
|
||
<div v-if="addonLeftIcon || $slots.addonLeft" class="input-group-prepend"> | ||
<span class="input-group-text"> | ||
<slot name="addonLeft"> | ||
<i :class="addonLeftIcon"></i> | ||
</slot> | ||
</span> | ||
</div> | ||
<slot v-bind="slotData"> | ||
<select | ||
:disabled="disabled" | ||
:value="value" | ||
@input="$emit('input', $event.target.value)" | ||
v-on="listeners" | ||
v-bind="$attrs" | ||
class="form-control" | ||
:class="[{'is-valid': valid === true}, {'is-invalid': valid === false}, inputClasses]" | ||
aria-describedby="addon-right addon-left"> | ||
<option v-for="option of options" :key="option.id" :value="option.id">{{ option.label }}</option> | ||
</select> | ||
</slot> | ||
<div v-if="addonRightIcon || $slots.addonRight" class="input-group-append"> | ||
<span class="input-group-text"> | ||
<slot name="addonRight"> | ||
<i :class="addonRightIcon"></i> | ||
</slot> | ||
</span> | ||
</div> | ||
<slot name="infoBlock"></slot> | ||
<slot name="helpBlock"> | ||
<div class="text-danger invalid-feedback" style="display: block;" :class="{'mt-2': hasIcon}" v-if="error"> | ||
{{ error }} | ||
</div> | ||
</slot> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
inheritAttrs: false, | ||
name: "base-select", | ||
props: { | ||
required: { | ||
type: Boolean, | ||
description: "Whether input is required (adds an asterix *)" | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
description: "Whether input is disabled" | ||
}, | ||
valid: { | ||
type: Boolean, | ||
description: "Whether is valid", | ||
default: undefined | ||
}, | ||
alternative: { | ||
type: Boolean, | ||
description: "Whether input is of alternative layout" | ||
}, | ||
label: { | ||
type: String, | ||
description: "Input label (text before input)" | ||
}, | ||
error: { | ||
type: String, | ||
description: "Input error (below input)" | ||
}, | ||
labelClasses: { | ||
type: String, | ||
description: "Input label css classes" | ||
}, | ||
inputClasses: { | ||
type: String, | ||
description: "Input css classes" | ||
}, | ||
value: { | ||
type: String, | ||
description: "Input value" | ||
}, | ||
options: { | ||
type: Array, | ||
description: "Possible values" | ||
}, | ||
addonRightIcon: { | ||
type: String, | ||
description: "Addon right icon" | ||
}, | ||
addonLeftIcon: { | ||
type: String, | ||
description: "Addont left icon" | ||
} | ||
}, | ||
data() { | ||
return { | ||
focused: false | ||
}; | ||
}, | ||
computed: { | ||
listeners() { | ||
return { | ||
...this.$listeners, | ||
input: this.updateValue, | ||
focus: this.onFocus, | ||
blur: this.onBlur | ||
}; | ||
}, | ||
slotData() { | ||
return { | ||
focused: this.focused, | ||
...this.listeners | ||
}; | ||
}, | ||
hasIcon() { | ||
const {addonRight, addonLeft} = this.$slots; | ||
return ( | ||
addonRight !== undefined || | ||
addonLeft !== undefined || | ||
this.addonRightIcon !== undefined || | ||
this.addonLeftIcon !== undefined | ||
); | ||
} | ||
}, | ||
methods: { | ||
updateValue(evt) { | ||
let value = evt.target.value; | ||
this.$emit("select", value); | ||
}, | ||
onFocus(value) { | ||
this.focused = true; | ||
this.$emit("focus", value); | ||
}, | ||
onBlur(value) { | ||
this.focused = false; | ||
this.$emit("blur", value); | ||
} | ||
} | ||
}; | ||
</script> | ||
<style> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters