mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Fixed #4646 - Add custom wrapper support for helper components
This commit is contained in:
parent
7618f8ba7a
commit
f16bd6ab2e
14 changed files with 196 additions and 157 deletions
|
@ -95,7 +95,7 @@
|
|||
import ChevronLeftIcon from 'primevue/icons/chevronleft';
|
||||
import ChevronRightIcon from 'primevue/icons/chevronright';
|
||||
import Ripple from 'primevue/ripple';
|
||||
import { DomHandler, UniqueComponentId } from 'primevue/utils';
|
||||
import { DomHandler, HelperSet, UniqueComponentId } from 'primevue/utils';
|
||||
import { mergeProps } from 'vue';
|
||||
import BaseTabView from './BaseTabView.vue';
|
||||
|
||||
|
@ -103,12 +103,18 @@ export default {
|
|||
name: 'TabView',
|
||||
extends: BaseTabView,
|
||||
emits: ['update:activeIndex', 'tab-change', 'tab-click'],
|
||||
provide() {
|
||||
return {
|
||||
$tabPanels: this.d_tabPanels
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
id: this.$attrs.id,
|
||||
d_activeIndex: this.activeIndex,
|
||||
isPrevButtonDisabled: true,
|
||||
isNextButtonDisabled: false
|
||||
isNextButtonDisabled: false,
|
||||
d_tabPanels: new HelperSet({ type: 'TabPanel' })
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
|
@ -130,10 +136,10 @@ export default {
|
|||
updated() {
|
||||
this.updateInkBar();
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.d_tabPanels.clear();
|
||||
},
|
||||
methods: {
|
||||
isTabPanel(child) {
|
||||
return child.type.name === 'TabPanel';
|
||||
},
|
||||
isTabActive(index) {
|
||||
return this.d_activeIndex === index;
|
||||
},
|
||||
|
@ -342,19 +348,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
tabs() {
|
||||
return this.$slots.default().reduce((tabs, child) => {
|
||||
if (this.isTabPanel(child)) {
|
||||
tabs.push(child);
|
||||
} else if (child.children && child.children instanceof Array) {
|
||||
child.children.forEach((nestedChild) => {
|
||||
if (this.isTabPanel(nestedChild)) {
|
||||
tabs.push(nestedChild);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return tabs;
|
||||
}, []);
|
||||
return this.d_tabPanels.get(this);
|
||||
},
|
||||
prevButtonAriaLabel() {
|
||||
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.previous : undefined;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue