Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct passthrough (pt) implementation for Stepperpanel. #7069

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 19 additions & 24 deletions components/lib/stepper/Stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,15 @@ export const Stepper = React.memo(

const createPanel = () => {
return stepperPanels().map((step, index) => {
const panelProps = mergeProps(
{
className: classNames(cx('stepper.header', { isStepActive, isItemDisabled, step, index, headerPosition: props.headerPosition, orientation: props.orientation })),
'aria-current': isStepActive(index) && 'step',
role: 'presentation',
'data-p-highlight': isStepActive(index),
'data-p-disabled': isItemDisabled(index),
'data-p-active': isStepActive(index)
},
ptm('stepperpanel')
);
const panelProps = mergeProps({
className: classNames(cx('stepper.header', { isStepActive, isItemDisabled, step, index, headerPosition: props.headerPosition, orientation: props.orientation })),
'aria-current': isStepActive(index) && 'step',
role: 'presentation',
'data-p-highlight': isStepActive(index),
'data-p-disabled': isItemDisabled(index),
'data-p-active': isStepActive(index),
...getStepPT(step, 'header', index)
});

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

const navProps = mergeProps(
{
ref: navRef,
className: cx('panel', { props, index, isStepActive }),
'aria-current': isStepActive(index) && 'step',
...getStepPT(step, 'root', index),
...getStepPT(step, 'panel', index),
'data-p-highlight': isStepActive(index),
'data-p-disabled': isItemDisabled(index),
'data-p-active': isStepActive(index)
},
ptm('nav')
);
const navProps = mergeProps({
ref: navRef,
className: cx('stepper.panel', { props, index, isStepActive }),
'aria-current': isStepActive(index) && 'step',
...getStepPT(step, 'root', index),
...getStepPT(step, 'panel', index),
'data-p-highlight': isStepActive(index),
'data-p-disabled': isItemDisabled(index),
'data-p-active': isStepActive(index)
});

const headerProps = mergeProps({
className: cx('stepper.header', { step, isStepActive, isItemDisabled, index }),
Expand Down
10 changes: 5 additions & 5 deletions components/lib/stepper/StepperBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const classes = {
content: ({ props }) =>
classNames('p-stepper-content', {
'p-toggleable-content': props.orientation === 'vertical'
}),
panel: ({ props, isStepActive, index }) =>
classNames('p-stepper-panel', {
'p-stepper-panel-active': props.orientation === 'vertical' && isStepActive(index)
})
},
panelContainer: 'p-stepper-panels',
panel: ({ props, isStepActive, index }) =>
classNames('p-stepper-panel', {
'p-stepper-panel-active': props.orientation === 'vertical' && isStepActive(index)
})
panelContainer: 'p-stepper-panels'
};

const styles = `
Expand Down
25 changes: 11 additions & 14 deletions components/lib/stepper/StepperContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@ import { useMergeProps } from '../hooks/Hooks';
export const StepperContent = React.memo(
React.forwardRef((props, ref) => {
const mergeProps = useMergeProps();
const { cx, ptm } = props;
const { cx } = props;

const rootProps = mergeProps(
{
ref: ref,
id: props.id,
className: cx('stepper.content', { stepperpanel: props.stepperpanel, index: props.index }),
role: 'tabpanel',
'aria-labelledby': props.ariaLabelledby,
...props.getStepPT(props.stepperpanel, 'root', props.index),
...props.getStepPT(props.stepperpanel, 'content', props.index),
'data-p-active': props.active
},
ptm('stepperpanel')
);
const rootProps = mergeProps({
ref: ref,
id: props.id,
className: cx('stepper.content', { stepperpanel: props.stepperpanel, index: props.index }),
role: 'tabpanel',
'aria-labelledby': props.ariaLabelledby,
...props.getStepPT(props.stepperpanel, 'root', props.index),
...props.getStepPT(props.stepperpanel, 'content', props.index),
'data-p-active': props.active
});

const createContent = () => {
const ComponentToRender = props.template;
Expand Down
17 changes: 14 additions & 3 deletions components/lib/stepper/StepperHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@ export const StepperHeader = React.memo(
type: 'button',
tabIndex: props.disabled ? -1 : undefined,
'aria-controls': props.ariaControls,
onClick: (e) => props.clickCallback(e, props.index)
onClick: (e) => props.clickCallback(e, props.index),
...props.getStepPT(props.stepperpanel, 'action', props.index)
});

const numberProps = mergeProps({
className: cx('stepper.number'),
...props.getStepPT(props.stepperpanel, 'number', props.index)
});

const titleProps = mergeProps({
className: cx('stepper.title'),
...props.getStepPT(props.stepperpanel, 'title', props.index)
});

return props.template ? (
props.template()
) : (
<button {...buttonProps}>
<span className={cx('stepper.number')}>{props.index + 1}</span>
<span className={cx('stepper.title')}>{props.getStepProp(props.stepperpanel, 'header')}</span>
<span {...numberProps}>{props.index + 1}</span>
<span {...titleProps}>{props.getStepProp(props.stepperpanel, 'header')}</span>
</button>
);
})
Expand Down
Loading
Loading