node_modules updated, buefy add to lib folder
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BSwitch from '@components/switch/Switch'
|
||||
|
||||
describe('BSwitch', () => {
|
||||
it('is called', () => {
|
||||
const wrapper = shallowMount(BSwitch)
|
||||
|
||||
expect(wrapper.name()).toBe('BSwitch')
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
})
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<label
|
||||
class="switch"
|
||||
:class="[size, { 'is-disabled': disabled }]"
|
||||
ref="label"
|
||||
:disabled="disabled"
|
||||
@keydown.prevent.enter="$refs.label.click()"
|
||||
@mousedown="isMouseDown = true"
|
||||
@mouseup="isMouseDown = false"
|
||||
@mouseout="isMouseDown = false"
|
||||
@blur="isMouseDown = false">
|
||||
<input
|
||||
v-model="computedValue"
|
||||
type="checkbox"
|
||||
@click.stop
|
||||
:disabled="disabled"
|
||||
:name="name"
|
||||
:required="required"
|
||||
:value="nativeValue"
|
||||
:true-value="trueValue"
|
||||
:false-value="falseValue">
|
||||
<span class="check" :class="[{ 'is-elastic': isMouseDown && !disabled }, type]"/>
|
||||
<span class="control-label"><slot/></span>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'BSwitch',
|
||||
props: {
|
||||
value: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
nativeValue: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
disabled: Boolean,
|
||||
type: String,
|
||||
name: String,
|
||||
required: Boolean,
|
||||
size: String,
|
||||
trueValue: {
|
||||
type: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
default: true
|
||||
},
|
||||
falseValue: {
|
||||
type: [String, Number, Boolean, Function, Object, Array, Symbol],
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
newValue: this.value,
|
||||
isMouseDown: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
computedValue: {
|
||||
get() {
|
||||
return this.newValue
|
||||
},
|
||||
set(value) {
|
||||
this.newValue = value
|
||||
this.$emit('input', value)
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
/**
|
||||
* When v-model change, set internal value.
|
||||
*/
|
||||
value(value) {
|
||||
this.newValue = value
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import Switch from './Switch'
|
||||
|
||||
import { use, registerComponent } from '../../utils/plugins'
|
||||
|
||||
const Plugin = {
|
||||
install(Vue) {
|
||||
registerComponent(Vue, Switch)
|
||||
}
|
||||
}
|
||||
|
||||
use(Plugin)
|
||||
|
||||
export default Plugin
|
||||
|
||||
export {
|
||||
Switch
|
||||
}
|
||||
Reference in New Issue
Block a user