UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

73 lines (72 loc) 3.46 kB
import { jsxs as f, Fragment as g, jsx as a } from "react/jsx-runtime"; import { cloneDeep as D, keys as x, find as w, isArray as v, isString as F, isObject as N, isDate as L, first as A, get as $ } from "lodash-es"; function I(s, d, o) { const u = /\[\d+\]\./g, t = /\.(\d)+/g; s = s.replace(t, "[$1]"); const h = `${s.split(".").join(".properties.")}.title`, b = `${s}.ui:title`, e = h.replace(u, ".items."), l = b.replace(u, ".items."), n = h.match(u); let i = A(n); i && (i = i.substring(1, i.length - 2), i = isNaN(parseInt(i)) ? "" : `${parseInt(i) + 1}`); const r = $(o, b) || $(d.properties, h) || $(o, l) || $(d.properties, e) || `${e}`; return `${i ? "[" + i + "] " : ""}${r}`; } function V(s, d, o, u) { function t(e, l, n) { return Object.keys(e).forEach((r) => { e[r] === null ? l[n + r] = "" : /*if the value is a proper array*/ v(e[r]) && !F(e[r]) ? e[r].forEach((m, S) => { if (v(m) || N(e[r]) && !F(m)) t(m, l, `${n}${r}[${S}].`); else { let p = l[`${n}${r}`]; p = p ? `${p}, ` : "", l[`${n}${r}`] = p + m; } }) : N(e[r]) && !L(e[r]) ? t(e[r], l, `${n}${r}.`) : l[n + r] = e[r]; }), l; } const c = t(D(s), {}, ""); return console.log(c), x(c).map((e) => { let l = c[e]; c[e] === !1 && (l = "false"), c[e] === !0 && (l = "true"); const n = e.indexOf("."); return { screen: w(d, { id: e.substring(0, n) }), label: I(e, o, u), value: l }; }).filter((e) => e.label.indexOf(".properties.included.title") === -1).filter((e) => e.screen && typeof e.value < "u").map((e) => ({ label: e.label, value: e.value, screen: e.screen })).sort((e, l) => e.screen.order - l.screen.order); } function U(s) { let d = []; d = V( D(s.formData), s.steps, s.schema, s.uiSchema ); let o = ""; const u = /* @__PURE__ */ f(g, { children: [ /* @__PURE__ */ a("table", { className: "table summary-table-header", children: /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ f("tr", { children: [ /* @__PURE__ */ a("th", { children: "Step" }), /* @__PURE__ */ a("th", { children: "Label" }), /* @__PURE__ */ a("th", { children: "Value" }) ] }) }) }), /* @__PURE__ */ a("div", { className: "scroll-area table-body", children: /* @__PURE__ */ a("table", { className: "table summary-table", children: /* @__PURE__ */ a("tbody", { children: d.map((t, c) => /* @__PURE__ */ f("tr", { children: [ /* @__PURE__ */ a("td", { children: o !== t.screen.id && (o = t.screen.id) && /* @__PURE__ */ a("span", { children: t.screen.title }) }), /* @__PURE__ */ a("td", { children: t.label }), /* @__PURE__ */ a("td", { children: t.value }) ] }, `${c}-${t.screen.id}-${t.label}`)) }) }) }) ] }); return /* @__PURE__ */ f(g, { children: [ /* @__PURE__ */ a("p", { className: "step-exclude-directions", children: 'Below is all of the data you have entered. Before submitting, click "Validate" to ensure that all of the required data has been entered.' }), /* @__PURE__ */ a("button", { className: "nav-link pull-right", onClick: () => window.print(), children: "Print this data" }), /* @__PURE__ */ a("div", { className: "panel panel-default padding-full wrap", children: /* @__PURE__ */ a("div", { className: "summary scroll-area", children: u }) }) ] }); } export { U as default, V as getFlatData }; //# sourceMappingURL=SummaryTable.js.map