@amsterdam/design-system-react
Version:
All React components from the Amsterdam Design System. Use it to compose pages in your website or application.
34 lines (33 loc) • 1.85 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { clsx } from 'clsx';
import { forwardRef, useImperativeHandle, useRef } from 'react';
import { useKeyboardFocus } from '../common/useKeyboardFocus';
import { headingLevels } from '../Heading/Heading';
import { ProgressListContext } from './ProgressListContext';
import { ProgressListStep } from './ProgressListStep';
import { ProgressListSubstep } from './ProgressListSubstep';
import { ProgressListSubsteps } from './ProgressListSubsteps';
export const progressListHeadingLevels = headingLevels.filter((level) => level !== 1);
const ProgressListRoot = forwardRef(({ children, className, collapsible = false, completedAccessibleText, currentAccessibleText, headingLevel, ...restProps }, ref) => {
const innerRef = useRef(null);
useImperativeHandle(ref, () => innerRef.current);
const { keyDown } = useKeyboardFocus(innerRef, {
focusableElements: ['.ams-progress-list__button:not([disabled])'],
rotating: true,
});
return (_jsx(ProgressListContext.Provider, { value: {
collapsible,
completedAccessibleText: completedAccessibleText ?? 'Klaar',
currentAccessibleText: currentAccessibleText ?? 'Bezig',
headingLevel,
}, children: _jsx("ol", { ...restProps, className: clsx('ams-progress-list', `ams-progress-list--heading-${headingLevel}`, className), onKeyDown: collapsible ? keyDown : undefined, ref: innerRef, children: children }) }));
});
/**
* @see {@link https://designsystem.amsterdam/?path=/docs/components-containers-progress-list--docs Progress List docs at Amsterdam Design System}
*/
export const ProgressList = Object.assign(ProgressListRoot, {
Step: ProgressListStep,
Substep: ProgressListSubstep,
Substeps: ProgressListSubsteps,
});
ProgressListRoot.displayName = 'ProgressList';