diff --git a/components/lib/accordion/Accordion.js b/components/lib/accordion/Accordion.js
index 71522727d7..393b6b9eb5 100644
--- a/components/lib/accordion/Accordion.js
+++ b/components/lib/accordion/Accordion.js
@@ -18,7 +18,7 @@ export const Accordion = React.forwardRef((inProps, ref) => {
const [activeIndexState, setActiveIndexState] = React.useState(props.activeIndex);
const elementRef = React.useRef(null);
const activeIndex = props.onTabChange ? props.activeIndex : activeIndexState;
-
+ const count = React.Children.count(props.children);
const metaData = {
props,
state: {
@@ -33,11 +33,20 @@ export const Accordion = React.forwardRef((inProps, ref) => {
useHandleStyle(AccordionBase.css.styles, isUnstyled, { name: 'accordion' });
- const getTabPT = (tab, key) => {
- return ptmo(getTabProp(tab, 'pt'), key, {
- props: tab.props,
- parent: metaData
- });
+ const getTabPT = (tab, key, index) => {
+ const tabMetaData = {
+ props: tab.props /* @todo */,
+ parent: metaData,
+ context: {
+ index,
+ count,
+ first: index === 0,
+ last: index === count - 1,
+ selected: isSelected(index)
+ }
+ };
+
+ return mergeProps(ptm(`accordiontab.${key}`, { accordiontab: tabMetaData }), ptm(`accordiontab.${key}`, tabMetaData), ptmo(tab.props, key, tabMetaData));
};
const getTabProp = (tab, name) => AccordionTabBase.getCProp(tab, name);
@@ -99,14 +108,14 @@ export const Accordion = React.forwardRef((inProps, ref) => {
{
className: cx('tab.headertitle')
},
- getTabPT(tab, 'headertitle')
+ getTabPT(tab, 'headertitle', index)
);
const header = getTabProp(tab, 'headerTemplate') ? ObjectUtils.getJSXElement(getTabProp(tab, 'headerTemplate'), AccordionTabBase.getCProps(tab)) : {getTabProp(tab, 'header')};
const headerIconProps = mergeProps(
{
className: cx('tab.headericon')
},
- getTabPT(tab, 'headericon')
+ getTabPT(tab, 'headericon', index)
);
const icon = selected ? props.collapseIcon ||