Skip to content

Commit 91ce605

Browse files
authored
Correct passthrough (pt) implementation for Stepperpanel. (#7069)
* correct passthrough (pt) implementation for stepperpanel. Updated Stepper components to use mergeProps for pt attributes. * style: apply code formatting. * Snapshot updated for Stepper/Stepperpanel.
1 parent ee33efa commit 91ce605

File tree

5 files changed

+111
-66
lines changed

5 files changed

+111
-66
lines changed

components/lib/stepper/Stepper.js

+19-24
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,15 @@ export const Stepper = React.memo(
133133

134134
const createPanel = () => {
135135
return stepperPanels().map((step, index) => {
136-
const panelProps = mergeProps(
137-
{
138-
className: classNames(cx('stepper.header', { isStepActive, isItemDisabled, step, index, headerPosition: props.headerPosition, orientation: props.orientation })),
139-
'aria-current': isStepActive(index) && 'step',
140-
role: 'presentation',
141-
'data-p-highlight': isStepActive(index),
142-
'data-p-disabled': isItemDisabled(index),
143-
'data-p-active': isStepActive(index)
144-
},
145-
ptm('stepperpanel')
146-
);
136+
const panelProps = mergeProps({
137+
className: classNames(cx('stepper.header', { isStepActive, isItemDisabled, step, index, headerPosition: props.headerPosition, orientation: props.orientation })),
138+
'aria-current': isStepActive(index) && 'step',
139+
role: 'presentation',
140+
'data-p-highlight': isStepActive(index),
141+
'data-p-disabled': isItemDisabled(index),
142+
'data-p-active': isStepActive(index),
143+
...getStepPT(step, 'header', index)
144+
});
147145

148146
return (
149147
<li key={getStepKey(step, index)} {...panelProps}>
@@ -233,19 +231,16 @@ export const Stepper = React.memo(
233231
return stepperPanels().map((step, index) => {
234232
const contentRef = React.createRef(null);
235233

236-
const navProps = mergeProps(
237-
{
238-
ref: navRef,
239-
className: cx('panel', { props, index, isStepActive }),
240-
'aria-current': isStepActive(index) && 'step',
241-
...getStepPT(step, 'root', index),
242-
...getStepPT(step, 'panel', index),
243-
'data-p-highlight': isStepActive(index),
244-
'data-p-disabled': isItemDisabled(index),
245-
'data-p-active': isStepActive(index)
246-
},
247-
ptm('nav')
248-
);
234+
const navProps = mergeProps({
235+
ref: navRef,
236+
className: cx('stepper.panel', { props, index, isStepActive }),
237+
'aria-current': isStepActive(index) && 'step',
238+
...getStepPT(step, 'root', index),
239+
...getStepPT(step, 'panel', index),
240+
'data-p-highlight': isStepActive(index),
241+
'data-p-disabled': isItemDisabled(index),
242+
'data-p-active': isStepActive(index)
243+
});
249244

250245
const headerProps = mergeProps({
251246
className: cx('stepper.header', { step, isStepActive, isItemDisabled, index }),

components/lib/stepper/StepperBase.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ const classes = {
2525
content: ({ props }) =>
2626
classNames('p-stepper-content', {
2727
'p-toggleable-content': props.orientation === 'vertical'
28+
}),
29+
panel: ({ props, isStepActive, index }) =>
30+
classNames('p-stepper-panel', {
31+
'p-stepper-panel-active': props.orientation === 'vertical' && isStepActive(index)
2832
})
2933
},
30-
panelContainer: 'p-stepper-panels',
31-
panel: ({ props, isStepActive, index }) =>
32-
classNames('p-stepper-panel', {
33-
'p-stepper-panel-active': props.orientation === 'vertical' && isStepActive(index)
34-
})
34+
panelContainer: 'p-stepper-panels'
3535
};
3636

3737
const styles = `

components/lib/stepper/StepperContent.js

+11-14
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@ import { useMergeProps } from '../hooks/Hooks';
44
export const StepperContent = React.memo(
55
React.forwardRef((props, ref) => {
66
const mergeProps = useMergeProps();
7-
const { cx, ptm } = props;
7+
const { cx } = props;
88

9-
const rootProps = mergeProps(
10-
{
11-
ref: ref,
12-
id: props.id,
13-
className: cx('stepper.content', { stepperpanel: props.stepperpanel, index: props.index }),
14-
role: 'tabpanel',
15-
'aria-labelledby': props.ariaLabelledby,
16-
...props.getStepPT(props.stepperpanel, 'root', props.index),
17-
...props.getStepPT(props.stepperpanel, 'content', props.index),
18-
'data-p-active': props.active
19-
},
20-
ptm('stepperpanel')
21-
);
9+
const rootProps = mergeProps({
10+
ref: ref,
11+
id: props.id,
12+
className: cx('stepper.content', { stepperpanel: props.stepperpanel, index: props.index }),
13+
role: 'tabpanel',
14+
'aria-labelledby': props.ariaLabelledby,
15+
...props.getStepPT(props.stepperpanel, 'root', props.index),
16+
...props.getStepPT(props.stepperpanel, 'content', props.index),
17+
'data-p-active': props.active
18+
});
2219

2320
const createContent = () => {
2421
const ComponentToRender = props.template;

components/lib/stepper/StepperHeader.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,26 @@ export const StepperHeader = React.memo(
1414
type: 'button',
1515
tabIndex: props.disabled ? -1 : undefined,
1616
'aria-controls': props.ariaControls,
17-
onClick: (e) => props.clickCallback(e, props.index)
17+
onClick: (e) => props.clickCallback(e, props.index),
18+
...props.getStepPT(props.stepperpanel, 'action', props.index)
19+
});
20+
21+
const numberProps = mergeProps({
22+
className: cx('stepper.number'),
23+
...props.getStepPT(props.stepperpanel, 'number', props.index)
24+
});
25+
26+
const titleProps = mergeProps({
27+
className: cx('stepper.title'),
28+
...props.getStepPT(props.stepperpanel, 'title', props.index)
1829
});
1930

2031
return props.template ? (
2132
props.template()
2233
) : (
2334
<button {...buttonProps}>
24-
<span className={cx('stepper.number')}>{props.index + 1}</span>
25-
<span className={cx('stepper.title')}>{props.getStepProp(props.stepperpanel, 'header')}</span>
35+
<span {...numberProps}>{props.index + 1}</span>
36+
<span {...titleProps}>{props.getStepProp(props.stepperpanel, 'header')}</span>
2637
</button>
2738
);
2839
})

0 commit comments

Comments
 (0)