primevue-mirror/components/lib/dataviewlayoutoptions/DataViewLayoutOptions.vue

50 lines
1.5 KiB
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
<SelectButton :class="cx('root')" :modelValue="modelValue" :options="options" :allowEmpty="false" :unstyled="unstyled" @update:modelValue="changeLayout">
<template #option="{ option }">
<slot v-if="option === 'list'" name="listicon">
<BarsIcon v-bind="ptm('listIcon')" />
</slot>
<slot v-else-if="option === 'grid'" name="gridicon">
<ThLargeIcon v-bind="ptm('gridIcon')" />
</slot>
</template>
</SelectButton>
2022-09-06 12:03:37 +00:00
</template>
<script>
import BarsIcon from 'primevue/icons/bars';
import ThLargeIcon from 'primevue/icons/thlarge';
import SelectButton from 'primevue/selectbutton';
import BaseDataViewLayoutOptions from './BaseDataViewLayoutOptions.vue';
2022-09-14 11:26:01 +00:00
export default {
name: 'DataViewLayoutOptions',
extends: BaseDataViewLayoutOptions,
2024-02-12 13:02:20 +00:00
inheritAttrs: false,
2022-09-14 11:26:01 +00:00
emits: ['update:modelValue'],
2022-12-08 11:04:25 +00:00
data() {
return {
options: ['list', 'grid']
2022-12-08 11:04:25 +00:00
};
},
2022-09-14 11:26:01 +00:00
methods: {
changeLayout(layout) {
this.$emit('update:modelValue', layout);
}
},
computed: {
2022-12-08 11:04:25 +00:00
listViewAriaLabel() {
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.listView : undefined;
},
gridViewAriaLabel() {
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.gridView : undefined;
2022-09-14 11:26:01 +00:00
}
},
components: {
SelectButton,
BarsIcon,
ThLargeIcon
2022-09-14 11:26:01 +00:00
}
};
2022-09-06 12:03:37 +00:00
</script>