@teleporthq/react-components
Advanced tools
Comparing version 1.0.5 to 1.0.6
import p from "dayjs"; | ||
import r, { useRef as d, useEffect as E, useState as f } from "react"; | ||
const w = ({ date: t, format: e }) => { | ||
const n = p.unix(new Date(t).getTime() / 1e3), a = p(n).format(e); | ||
return /* @__PURE__ */ r.createElement(r.Fragment, null, a); | ||
}, H = ({ html: t }) => { | ||
const e = d(null); | ||
import n, { useRef as f, useEffect as E, useState as d } from "react"; | ||
const I = ({ date: t, format: e }) => { | ||
const r = p.unix(new Date(t).getTime() / 1e3), a = p(r).format(e); | ||
return /* @__PURE__ */ n.createElement(n.Fragment, null, a); | ||
}, M = ({ html: t }) => { | ||
const e = f(null); | ||
return E(() => { | ||
if (!t || !e.current) | ||
return; | ||
const n = document.createRange().createContextualFragment(t); | ||
e.current.append(n); | ||
}, []), /* @__PURE__ */ r.createElement("div", { style: { display: "contents" }, ref: e }); | ||
const r = document.createRange().createContextualFragment(t); | ||
e.current.append(r); | ||
}, []), /* @__PURE__ */ n.createElement("div", { style: { display: "contents" }, ref: e }); | ||
}, S = (t) => { | ||
const { | ||
fetchData: e, | ||
params: n, | ||
params: r, | ||
initialData: a, | ||
persistDataDuringLoading: s = !1, | ||
persistDataDuringLoading: c = !1, | ||
renderLoading: l = () => null, | ||
renderSuccess: c, | ||
renderSuccess: s, | ||
renderError: u = () => null | ||
} = t, [h, i] = f("idle"), [o, g] = f(a), [A, F] = f(null), D = d( | ||
} = t, [R, i] = d("idle"), [o, g] = d(a), [F, h] = d(null), y = f( | ||
t.initialData !== void 0 | ||
), y = d(s); | ||
switch (y.current = s, E(() => { | ||
if (D.current) { | ||
D.current = !1; | ||
), D = f(c); | ||
switch (D.current = c, E(() => { | ||
if (y.current) { | ||
y.current = !1; | ||
return; | ||
} | ||
(async () => { | ||
i("loading"), y.current || g(void 0); | ||
i("loading"), D.current || g(void 0); | ||
try { | ||
const m = await e(n); | ||
const m = await e(r); | ||
g(m), i("success"); | ||
} catch (m) { | ||
F(m), i("error"); | ||
h(m), i("error"); | ||
} | ||
})(); | ||
}, [n, e]), h) { | ||
}, [r, e]), R) { | ||
case "idle": | ||
case "loading": | ||
return t.persistDataDuringLoading && o ? c(o, !0) : l(); | ||
return t.persistDataDuringLoading && o ? s(o, !0) : l(); | ||
case "success": | ||
return c(o, !1); | ||
return s(o, !1); | ||
case "error": | ||
return u(A); | ||
return u(F); | ||
default: | ||
return null; | ||
} | ||
}, j = (t) => { | ||
const { items: e, renderItem: n, renderEmpty: a } = t; | ||
}, w = (t) => { | ||
const { items: e, renderItem: r, renderEmpty: a } = t; | ||
if ("data" in e && "meta" in e) { | ||
const { data: s, meta: l } = e; | ||
return Array.isArray(s) === !1 ? null : s.length === 0 ? a ? a() : null : /* @__PURE__ */ r.createElement(r.Fragment, null, s.map( | ||
(c, u) => n(typeof c == "object" ? { ...c, teleportMeta: l } : c, u) | ||
const { data: c, meta: l } = e; | ||
return Array.isArray(c) === !1 ? null : c.length === 0 ? a ? a() : null : /* @__PURE__ */ n.createElement(n.Fragment, null, c.map( | ||
(s, u) => r(typeof s == "object" ? { ...s, teleportMeta: l } : s, u) | ||
)); | ||
} | ||
return Array.isArray(e) ? e.length === 0 ? a ? a() : null : /* @__PURE__ */ r.createElement(r.Fragment, null, e.map((s, l) => n(s, l))) : null; | ||
}, v = ({ src: t, description: e }) => /* @__PURE__ */ r.createElement(r.Fragment, null, t && /* @__PURE__ */ r.createElement( | ||
return Array.isArray(e) ? e.length === 0 ? a ? a() : null : /* @__PURE__ */ n.createElement(n.Fragment, null, e.map((c, l) => r(c, l))) : null; | ||
}, A = ({ src: t, description: e }) => /* @__PURE__ */ n.createElement(n.Fragment, null, t && /* @__PURE__ */ n.createElement( | ||
"img", | ||
@@ -67,9 +67,16 @@ { | ||
} | ||
)), x = ({ node: t, children: e }) => t.attrs.src ? /* @__PURE__ */ r.createElement(v, { ...t.attrs }) : /* @__PURE__ */ r.createElement(r.Fragment, null, e); | ||
)), x = ({ node: t, children: e }) => t.attrs.src ? /* @__PURE__ */ n.createElement(A, { ...t.attrs }) : /* @__PURE__ */ n.createElement(n.Fragment, null, e), H = ({ itemData: t, mappingConfiguration: e, renderDefault: r, renderError: a }) => { | ||
try { | ||
return e?.[t.typeId] ? /* @__PURE__ */ React.createElement(React.Fragment, null, e[t.typeId]?.(t.attributes) ?? null) : /* @__PURE__ */ React.createElement(React.Fragment, null, r ? r(t) : "default case"); | ||
} catch (c) { | ||
return /* @__PURE__ */ React.createElement(React.Fragment, null, a ? a(c) : "error case"); | ||
} | ||
}; | ||
export { | ||
H as CMSMixedType, | ||
x as CaisyDocumentLink, | ||
H as DangerousHTML, | ||
M as DangerousHTML, | ||
S as DataProvider, | ||
w as DateTimePrimitive, | ||
j as Repeater | ||
I as DateTimePrimitive, | ||
w as Repeater | ||
}; |
{ | ||
"name": "@teleporthq/react-components", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-components.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
23649
16
590