-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathStepperActionRow.tsx
More file actions
41 lines (34 loc) 路 1.06 KB
/
Copy pathStepperActionRow.tsx
File metadata and controls
41 lines (34 loc) 路 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, { useContext } from 'react';
import { StepperContext } from './StepperContext';
import ActionRow from '../ActionRow';
export interface StepperActionRowProps {
/** Specifies the content of the `ActionRow`. */
children: React.ReactNode;
/**
* An identifier of the `ActionRow`. When `activeKey` on the
* `Stepper` equals to the `eventKey`, the `ActionRow` will be displayed.
*/
eventKey: string;
/** Specifies the base element */
as?: React.ElementType;
[key: string]: any; // For additional props passed through
}
interface StepperActionRowComponent {
(props: StepperActionRowProps): JSX.Element | null;
Spacer: typeof ActionRow.Spacer;
}
function StepperActionRow({
as = ActionRow,
children,
eventKey,
...props
}: StepperActionRowProps) {
const { activeKey } = useContext(StepperContext);
const isActive = activeKey === eventKey;
if (!isActive) {
return null;
}
return React.createElement(as, props, children);
}
(StepperActionRow as StepperActionRowComponent).Spacer = ActionRow.Spacer;
export default StepperActionRow;