Migrated calendar to new v-model and $attrs api
parent
572691e063
commit
b8b9c336d7
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="containerClass" @click="onClick($event)">
|
<div :class="containerClass" @click="onClick($event)" :style="style">
|
||||||
<div class="p-hidden-accessible">
|
<div class="p-hidden-accessible">
|
||||||
<input ref="input" type="checkbox" :checked="checked" :value="value" v-bind="$attrs" @focus="onFocus($event)" @blur="onBlur($event)">
|
<input ref="input" type="checkbox" :checked="checked" :value="value" v-bind="$attrs" @focus="onFocus" @blur="onBlur">
|
||||||
</div>
|
</div>
|
||||||
<div ref="box" :class="['p-checkbox-box', {'p-highlight': checked, 'p-disabled': $attrs.disabled, 'p-focus': focused}]" role="checkbox" :aria-checked="checked">
|
<div ref="box" :class="['p-checkbox-box', {'p-highlight': checked, 'p-disabled': $attrs.disabled, 'p-focus': focused}]" role="checkbox" :aria-checked="checked">
|
||||||
<span :class="['p-checkbox-icon', {'pi pi-check': checked}]"></span>
|
<span :class="['p-checkbox-icon', {'pi pi-check': checked}]"></span>
|
||||||
|
@ -17,11 +17,9 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
value: null,
|
value: null,
|
||||||
modelValue: null,
|
modelValue: null,
|
||||||
binary: Boolean
|
binary: Boolean,
|
||||||
},
|
class: null,
|
||||||
model: {
|
style: null
|
||||||
prop: 'modelValue',
|
|
||||||
event: 'input'
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -44,18 +42,16 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('click', event);
|
this.$emit('click', event);
|
||||||
this.$emit('input', newModelValue);
|
this.$emit('update:modelValue', newModelValue);
|
||||||
this.$emit('change', event);
|
this.$emit('change', event);
|
||||||
this.$refs.input.focus();
|
this.$refs.input.focus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onFocus(event) {
|
onFocus() {
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
this.$emit('focus', event);
|
|
||||||
},
|
},
|
||||||
onBlur(event) {
|
onBlur() {
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
this.$emit('blur', event);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -63,7 +59,7 @@ export default {
|
||||||
return this.binary ? this.modelValue : ObjectUtils.contains(this.value, this.modelValue);
|
return this.binary ? this.modelValue : ObjectUtils.contains(this.value, this.modelValue);
|
||||||
},
|
},
|
||||||
containerClass() {
|
containerClass() {
|
||||||
return ['p-checkbox p-component', {'p-checkbox-checked': this.checked, 'p-checkbox-disabled': this.$attrs.disabled, 'p-checkbox-focused': this.focused}];
|
return ['p-checkbox p-component', this.class, {'p-checkbox-checked': this.checked, 'p-checkbox-disabled': this.$attrs.disabled, 'p-checkbox-focused': this.focused}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="containerClass" @click="onClick($event)">
|
<div :class="containerClass" @click="onClick($event)" :style="style">
|
||||||
<div class="p-hidden-accessible">
|
<div class="p-hidden-accessible">
|
||||||
<input ref="input" type="radio" :checked="checked" :value="value" v-bind="$attrs" @focus="onFocus($event)" @blur="onBlur($event)">
|
<input ref="input" type="radio" :checked="checked" :value="value" v-bind="$attrs" @focus="onFocus" @blur="onBlur">
|
||||||
</div>
|
</div>
|
||||||
<div ref="box" :class="['p-radiobutton-box', {'p-highlight': checked, 'p-disabled': $attrs.disabled, 'p-focus': focused}]" role="radio" :aria-checked="checked">
|
<div ref="box" :class="['p-radiobutton-box', {'p-highlight': checked, 'p-disabled': $attrs.disabled, 'p-focus': focused}]" role="radio" :aria-checked="checked">
|
||||||
<div class="p-radiobutton-icon"></div>
|
<div class="p-radiobutton-icon"></div>
|
||||||
|
@ -16,11 +16,9 @@ export default {
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: null,
|
value: null,
|
||||||
modelValue: null
|
modelValue: null,
|
||||||
},
|
class: null,
|
||||||
model: {
|
style: null
|
||||||
prop: 'modelValue',
|
|
||||||
event: 'input'
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -31,7 +29,7 @@ export default {
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
if (!this.$attrs.disabled) {
|
if (!this.$attrs.disabled) {
|
||||||
this.$emit('click', event);
|
this.$emit('click', event);
|
||||||
this.$emit('input', this.value);
|
this.$emit('update:modelValue', this.value);
|
||||||
this.$refs.input.focus();
|
this.$refs.input.focus();
|
||||||
|
|
||||||
if (!this.checked) {
|
if (!this.checked) {
|
||||||
|
@ -39,13 +37,11 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onFocus(event) {
|
onFocus() {
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
this.$emit('focus', event);
|
|
||||||
},
|
},
|
||||||
onBlur(event) {
|
onBlur() {
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
this.$emit('blur', event);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -53,7 +49,7 @@ export default {
|
||||||
return this.modelValue != null && ObjectUtils.equals(this.modelValue, this.value);
|
return this.modelValue != null && ObjectUtils.equals(this.modelValue, this.value);
|
||||||
},
|
},
|
||||||
containerClass() {
|
containerClass() {
|
||||||
return ['p-radiobutton p-component', {'p-radiobutton-checked': this.checked, 'p-radiobutton-disabled': this.$attrs.disabled, 'p-radiobutton-focused': this.focused}];
|
return ['p-radiobutton p-component', this.class, {'p-radiobutton-checked': this.checked, 'p-radiobutton-disabled': this.$attrs.disabled, 'p-radiobutton-focused': this.focused}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue