Skip to content

Commit

Permalink
chore(lib): update Select
Browse files Browse the repository at this point in the history
- In `src/components/select/Select.vue`,
    - `v-model` binding conforms to Vue 3,
        - `value` prop --> `modelValue`
        - `input` event --> `update:modelValue`
    - Automatic ESLint fix is applied.
  • Loading branch information
kikuomax committed Jul 15, 2022
1 parent 5efb26e commit 2f255e3
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/components/select/Select.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<div
class="control"
:class="{ 'is-expanded': expanded, 'has-icons-left': icon }">
:class="{ 'is-expanded': expanded, 'has-icons-left': icon }"
>
<span class="select" :class="spanClasses">

<select
Expand All @@ -11,19 +12,21 @@
:size="nativeSize"
v-bind="$attrs"
@blur="$emit('blur', $event) && checkHtml5Validity()"
@focus="$emit('focus', $event)">
@focus="$emit('focus', $event)"
>

<template v-if="placeholder">
<option
v-if="computedValue == null"
:value="null"
disabled
hidden>
hidden
>
{{ placeholder }}
</option>
</template>

<slot/>
<slot />

</select>
</span>
Expand All @@ -33,7 +36,8 @@
class="is-left"
:icon="icon"
:pack="iconPack"
:size="iconSize"/>
:size="iconSize"
/>
</div>
</template>

Expand All @@ -49,7 +53,7 @@ export default {
mixins: [FormElementMixin],
inheritAttrs: false,
props: {
value: {
modelValue: {
type: [String, Number, Boolean, Object, Array, Function, Date],
default: null
},
Expand All @@ -59,7 +63,7 @@ export default {
},
data() {
return {
selected: this.value,
selected: this.modelValue,
_elementRef: 'select'
}
},
Expand All @@ -70,7 +74,7 @@ export default {
},
set(value) {
this.selected = value
this.$emit('input', value)
this.$emit('update:modelValue', value)
!this.isValid && this.checkHtml5Validity()
}
},
Expand All @@ -90,7 +94,7 @@ export default {
* 1. Set the selected option.
* 2. If it's invalid, validate again.
*/
value(value) {
modelValue(value) {
this.selected = value
!this.isValid && this.checkHtml5Validity()
}
Expand Down

0 comments on commit 2f255e3

Please sign in to comment.