UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

80 lines 4.11 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseRows = void 0; const react_1 = __importDefault(require("react")); const util_1 = require("../../util"); 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_1.default.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: (0, util_1.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: (0, util_1.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: (0, util_1.omit)(r.props, ["label", "icon", "headingTag"]), ref: r === null || r === void 0 ? void 0 : r.ref, }); } }); return parsedChildren; }; exports.parseRows = parseRows; //# sourceMappingURL=timeline.js.map