mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 08:52:34 +00:00
Components update v.3.21.0
This commit is contained in:
parent
18497d55b1
commit
defd6ff6e2
242 changed files with 28022 additions and 17523 deletions
|
@ -1,24 +1,19 @@
|
|||
<template>
|
||||
<div :class="['p-checkbox p-component', { 'p-checkbox-focused': focused }]" @click.stop.prevent="onClick">
|
||||
<div
|
||||
ref="box"
|
||||
:class="['p-checkbox-box p-component', { 'p-highlight': checked, 'p-disabled': $attrs.disabled, 'p-focus': focused }]"
|
||||
role="checkbox"
|
||||
:aria-checked="checked"
|
||||
:tabindex="$attrs.disabled ? null : '0'"
|
||||
@keydown.space.prevent="onClick"
|
||||
@focus="onFocus($event)"
|
||||
@blur="onBlur($event)"
|
||||
>
|
||||
<div :class="['p-checkbox p-component', { 'p-checkbox-focused': focused }]" @click="onClick">
|
||||
<div class="p-hidden-accessible">
|
||||
<input ref="input" type="checkbox" :checked="checked" :disabled="$attrs.disabled" :tabindex="$attrs.disabled ? null : '0'" :aria-label="checkboxAriaLabel" @focus="onFocus($event)" @blur="onBlur($event)" @keydown="onKeydown" />
|
||||
</div>
|
||||
<div ref="box" :class="['p-checkbox-box p-component', { 'p-highlight': checked, 'p-disabled': $attrs.disabled, 'p-focus': focused }]">
|
||||
<span :class="['p-checkbox-icon', { 'pi pi-check': checked }]"></span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { DomHandler } from 'primevue/utils';
|
||||
|
||||
export default {
|
||||
name: 'RowCheckbox',
|
||||
inheritAttrs: false,
|
||||
emits: ['change'],
|
||||
props: {
|
||||
value: null,
|
||||
|
@ -32,18 +27,38 @@ export default {
|
|||
methods: {
|
||||
onClick(event) {
|
||||
if (!this.$attrs.disabled) {
|
||||
this.focused = true;
|
||||
this.$emit('change', {
|
||||
originalEvent: event,
|
||||
data: this.value
|
||||
});
|
||||
|
||||
DomHandler.focus(this.$refs.input);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
},
|
||||
onFocus() {
|
||||
this.focused = true;
|
||||
},
|
||||
onBlur() {
|
||||
this.focused = false;
|
||||
},
|
||||
onKeydown(event) {
|
||||
switch (event.code) {
|
||||
case 'Space': {
|
||||
this.onClick(event);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
checkboxAriaLabel() {
|
||||
return this.$primevue.config.locale.aria ? (this.checked ? this.$primevue.config.locale.aria.selectRow : this.$primevue.config.locale.aria.unselectRow) : undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue