@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
54 lines (53 loc) • 1.69 kB
JavaScript
"use client";
import React from 'react';
import clsx from 'clsx';
import { applySpacing } from "../space/SpacingUtils.js";
import Context from "../../shared/Context.js";
import TimelineItem from "./TimelineItem.js";
import TimelineContext from "./TimelineContext.js";
import { validateDOMAttributes, extendPropsWithContext } from "../../shared/component-helper.js";
import withComponentMarkers from "../../shared/helpers/withComponentMarkers.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const defaultProps = {
className: null,
skeleton: false,
data: null,
children: null
};
const Timeline = localProps => {
const context = React.useContext(Context);
const allProps = extendPropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.Timeline, {
skeleton: context === null || context === void 0 ? void 0 : context.skeleton
});
const {
className,
skeleton,
data,
children: childrenProp,
...props
} = allProps;
validateDOMAttributes(allProps, props);
const olProps = applySpacing(allProps, {
...props,
className: clsx("dnb-timeline dnb-space__reset", className)
});
return _jsx(TimelineContext, {
value: {
skeleton
},
children: _jsxs("ol", {
...olProps,
children: [data === null || data === void 0 ? void 0 : data.map((timelineItem, i) => _jsx(TimelineItem, {
skeleton: skeleton,
...timelineItem
}, i)), childrenProp]
})
});
};
Timeline.Item = TimelineItem;
export { TimelineItem };
withComponentMarkers(Timeline, {
_supportsSpacingProps: true
});
export default Timeline;
//# sourceMappingURL=Timeline.js.map