UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

50 lines 1.8 kB
import React from "react"; import { omit } from "../../util/index.js"; import { getChildRef } from "../../util/getChildRef.js"; export const parseRows = (rowChildren) => { const parsedChildren = []; rowChildren === null || rowChildren === void 0 ? void 0 : rowChildren.forEach((row) => { const periods = []; if (!React.isValidElement(row) || !row.props.children) { return; } React.Children.toArray(row.props.children).forEach((period) => { if (!React.isValidElement(period)) { return; } periods.push({ start: period.props.start, end: period.props.end, status: period.props.status || "neutral", onSelectPeriod: period.props.onSelectPeriod, icon: period.props.icon, children: period.props.children, isActive: period.props.isActive, statusLabel: period.props.statusLabel, restProps: omit(period.props, [ "start", "end", "status", "onSelectPeriod", "icon", "children", "isActive", "statusLabel", "placement", ]), ref: getChildRef(period), }); }); parsedChildren.push({ label: row.props.label, icon: row.props.icon, headingTag: row.props.headingTag, periods, restProps: omit(row.props, ["label", "icon", "headingTag"]), ref: getChildRef(row), }); }); return parsedChildren; }; //# sourceMappingURL=timeline.js.map