Refactor #3965 - For DataViewLayoutOptions
parent
088d0aaa35
commit
80478bbfe1
|
@ -0,0 +1,35 @@
|
||||||
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
|
|
||||||
|
const classes = {
|
||||||
|
root: 'p-dataview-layout-options p-selectbutton p-buttonset',
|
||||||
|
listButton: ({ props }) => [
|
||||||
|
'p-button p-button-icon-only',
|
||||||
|
{
|
||||||
|
'p-highlight': props.modelValue === 'list'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
gridButton: ({ props }) => [
|
||||||
|
'p-button p-button-icon-only',
|
||||||
|
{
|
||||||
|
'p-highlight': props.modelValue === 'grid'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'BaseDataViewLayoutOptions',
|
||||||
|
extends: BaseComponent,
|
||||||
|
props: {
|
||||||
|
modelValue: String
|
||||||
|
},
|
||||||
|
css: {
|
||||||
|
classes
|
||||||
|
},
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
$parentInstance: this
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -83,6 +83,11 @@ export interface DataViewLayoutOptionsProps {
|
||||||
* @type {DataViewLayoutOptionsPassThroughOptions}
|
* @type {DataViewLayoutOptionsPassThroughOptions}
|
||||||
*/
|
*/
|
||||||
pt?: DataViewLayoutOptionsPassThroughOptions;
|
pt?: DataViewLayoutOptionsPassThroughOptions;
|
||||||
|
/**
|
||||||
|
* When enabled, it removes component related styles in the core.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
unstyled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="p-dataview-layout-options p-selectbutton p-buttonset" role="group" v-bind="ptm('root')">
|
<div :class="cx('root')" role="group" v-bind="ptm('root')">
|
||||||
<button :aria-label="listViewAriaLabel" :class="buttonListClass" @click="changeLayout('list')" type="button" :aria-pressed="isListButtonPressed" v-bind="ptm('listButton')">
|
<button :aria-label="listViewAriaLabel" :class="cx('listButton')" @click="changeLayout('list')" type="button" :aria-pressed="isListButtonPressed" v-bind="ptm('listButton')">
|
||||||
<slot name="listicon">
|
<slot name="listicon">
|
||||||
<BarsIcon v-bind="ptm('listIcon')" />
|
<BarsIcon v-bind="ptm('listIcon')" />
|
||||||
</slot>
|
</slot>
|
||||||
</button>
|
</button>
|
||||||
<button :aria-label="gridViewAriaLabel" :class="buttonGridClass" @click="changeLayout('grid')" type="button" :aria-pressed="isGridButtonPressed" v-bind="ptm('gridButton')">
|
<button :aria-label="gridViewAriaLabel" :class="cx('gridButton')" @click="changeLayout('grid')" type="button" :aria-pressed="isGridButtonPressed" v-bind="ptm('gridButton')">
|
||||||
<slot name="gridicon">
|
<slot name="gridicon">
|
||||||
<ThLargeIcon v-bind="ptm('gridIcon')" />
|
<ThLargeIcon v-bind="ptm('gridIcon')" />
|
||||||
</slot>
|
</slot>
|
||||||
|
@ -14,17 +14,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import BaseComponent from 'primevue/basecomponent';
|
import BaseDataViewLayoutOptions from './BaseDataViewLayoutOptions.vue';
|
||||||
import BarsIcon from 'primevue/icons/bars';
|
import BarsIcon from 'primevue/icons/bars';
|
||||||
import ThLargeIcon from 'primevue/icons/thlarge';
|
import ThLargeIcon from 'primevue/icons/thlarge';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DataViewLayoutOptions',
|
name: 'DataViewLayoutOptions',
|
||||||
extends: BaseComponent,
|
extends: BaseDataViewLayoutOptions,
|
||||||
emits: ['update:modelValue'],
|
emits: ['update:modelValue'],
|
||||||
props: {
|
|
||||||
modelValue: String
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isListButtonPressed: false,
|
isListButtonPressed: false,
|
||||||
|
@ -45,12 +42,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
buttonListClass() {
|
|
||||||
return ['p-button p-button-icon-only', { 'p-highlight': this.modelValue === 'list' }];
|
|
||||||
},
|
|
||||||
buttonGridClass() {
|
|
||||||
return ['p-button p-button-icon-only', { 'p-highlight': this.modelValue === 'grid' }];
|
|
||||||
},
|
|
||||||
listViewAriaLabel() {
|
listViewAriaLabel() {
|
||||||
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.listView : undefined;
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.listView : undefined;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue