@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
73 lines • 3.78 kB
JavaScript
import React from "react";
import { omit } from "../../util/index.js";
export const parseRows = (rowChildren) => {
const parsedChildren = [];
rowChildren === null || rowChildren === void 0 ? void 0 : rowChildren.forEach((r) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
const periods = [];
if (React.isValidElement(r) && ((_a = r === null || r === void 0 ? void 0 : r.props) === null || _a === void 0 ? void 0 : _a.children)) {
if (Array.isArray(r.props.children)) {
for (let i = 0; i < r.props.children.length; i++) {
const p = r.props.children[i];
periods.push({
start: (_b = p === null || p === void 0 ? void 0 : p.props) === null || _b === void 0 ? void 0 : _b.start,
end: (_c = p === null || p === void 0 ? void 0 : p.props) === null || _c === void 0 ? void 0 : _c.end,
status: ((_d = p === null || p === void 0 ? void 0 : p.props) === null || _d === void 0 ? void 0 : _d.status) || "neutral",
onSelectPeriod: (_e = p.props) === null || _e === void 0 ? void 0 : _e.onSelectPeriod,
label: r.props.label,
icon: p.props.icon,
children: p.props.children,
isActive: p.props.isActive,
statusLabel: p.props.statusLabel,
restProps: omit(p.props, [
"start",
"end",
"status",
"onSelectPeriod",
"label",
"icon",
"children",
"isActive",
"statusLabel",
]),
ref: p === null || p === void 0 ? void 0 : p.ref,
});
}
}
else {
periods.push({
start: r.props.children.props.start,
end: r.props.children.props.end,
status: ((_f = r.props.children.props) === null || _f === void 0 ? void 0 : _f.status) || "neutral",
onSelectPeriod: (_g = r.props.children.props) === null || _g === void 0 ? void 0 : _g.onSelectPeriod,
label: r.props.label,
icon: (_h = r.props.children.props) === null || _h === void 0 ? void 0 : _h.icon,
children: (_j = r.props.children.props) === null || _j === void 0 ? void 0 : _j.children,
statusLabel: (_k = r.props.children.props) === null || _k === void 0 ? void 0 : _k.statusLabel,
restProps: omit(r.props.children.props, [
"start",
"end",
"status",
"onSelectPeriod",
"label",
"icon",
"children",
"isActive",
"statusLabel",
]),
ref: (_m = (_l = r.props) === null || _l === void 0 ? void 0 : _l.children) === null || _m === void 0 ? void 0 : _m.ref,
});
}
parsedChildren.push({
label: r.props.label,
icon: r.props.icon,
headingTag: r.props.headingTag,
periods,
restProps: omit(r.props, ["label", "icon", "headingTag"]),
ref: r === null || r === void 0 ? void 0 : r.ref,
});
}
});
return parsedChildren;
};
//# sourceMappingURL=timeline.js.map