-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
c4a23e3
commit 5d2778a
Showing
8 changed files
with
183 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,75 @@ | ||
<template> | ||
<div :class="['p-accordion-tab', {'p-accordion-tab-active': showPanel}]"> | ||
<div :class="['p-accordion-header', {'p-highlight': showPanel, 'p-disabled': disabled}]"> | ||
<a role="tab" class="p-accordion-header-link" @click="onTabClick" @keydown="onTabKeydown" :tabindex="disabled ? null : '0'" | ||
:aria-expanded="showPanel" :id="ariaId + '_header'" :aria-controls="ariaId + '_content'"> | ||
<span :class="['p-accordion-toggle-icon pi', {'pi-chevron-right': !showPanel, 'pi-chevron-down': showPanel}]"></span> | ||
<span class="p-accordion-header-text" v-if="header">{{header}}</span> | ||
<slot name="header"></slot> | ||
</a> | ||
</div> | ||
<transition name="p-toggleable-content"> | ||
<div class="p-toggleable-content" v-if="showPanel" | ||
role="region" :id="ariaId + '_content'" :aria-labelledby="ariaId + '_header'"> | ||
<div class="p-accordion-content"> | ||
<slot></slot> | ||
</div> | ||
</div> | ||
</transition> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import UniqueComponentId from '../utils/UniqueComponentId'; | ||
import DomHandler from '../utils/DomHandler'; | ||
export default { | ||
name: 'accordiontab', | ||
props: { | ||
header: null, | ||
disabled: Boolean | ||
}, | ||
render() { | ||
return null; | ||
data() { | ||
return { | ||
el: null | ||
} | ||
}, | ||
mounted() { | ||
this.el = this.$el; | ||
}, | ||
methods: { | ||
onTabClick() { | ||
if (!this.disabled) { | ||
this.$parent.onToggle(this, DomHandler.index(this.el)); | ||
} | ||
}, | ||
onTabKeydown(event) { | ||
if (event.which === 13) { | ||
this.onTabClick(event); | ||
} | ||
}, | ||
findIsActive() { | ||
return this.isTabActive(DomHandler.index(this.el)); | ||
}, | ||
isTabActive(index) { | ||
let activeArray = this.$parent.d_activeIndex; | ||
if (this.$parent.multiple) { | ||
return activeArray && activeArray.includes(index); | ||
} | ||
else | ||
return index === activeArray; | ||
}, | ||
}, | ||
computed: { | ||
showPanel() { | ||
if (this.el) { | ||
return this.findIsActive(); | ||
} | ||
return false; | ||
}, | ||
ariaId() { | ||
return UniqueComponentId(); | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,46 @@ | ||
<template> | ||
<div class="p-tabview-panel" role="tabpanel" v-show="showPanel"> | ||
<slot></slot> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import DomHandler from '../utils/DomHandler'; | ||
export default { | ||
name: 'tabpanel', | ||
props: { | ||
header: null, | ||
disabled: Boolean | ||
}, | ||
render() { | ||
return null; | ||
data() { | ||
return { | ||
el: null | ||
} | ||
}, | ||
mounted() { | ||
this.el = this.$el; | ||
}, | ||
computed: { | ||
showPanel() { | ||
if (this.el) { | ||
return this.findIsActive(); | ||
} | ||
return false; | ||
} | ||
}, | ||
methods: { | ||
findIsActive() { | ||
return this.isTabActive(DomHandler.index(this.el)); | ||
}, | ||
isTabActive(index) { | ||
let activeArray = this.$parent.d_activeIndex; | ||
if (this.$parent.multiple) { | ||
return activeArray && activeArray.includes(index); | ||
} | ||
else { | ||
return index === activeArray; | ||
} | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.