@teleporthq/react-components
Advanced tools
Comparing version 1.0.1 to 1.0.2
import y from "dayjs"; | ||
import r, { useRef as f, useEffect as E, useState as d } from "react"; | ||
const S = ({ date: e, format: t }) => { | ||
const n = y.unix(new Date(e).getTime() / 1e3), a = y(n).format(t); | ||
const w = ({ date: t, format: e }) => { | ||
const n = y.unix(new Date(t).getTime() / 1e3), a = y(n).format(e); | ||
return /* @__PURE__ */ r.createElement(r.Fragment, null, a); | ||
}, T = ({ html: e }) => { | ||
const t = f(null); | ||
}, H = ({ html: t }) => { | ||
const e = f(null); | ||
return E(() => { | ||
if (!e || !t.current) | ||
if (!t || !e.current) | ||
return; | ||
const n = document.createRange().createContextualFragment(e); | ||
t.current.append(n); | ||
}, []), /* @__PURE__ */ r.createElement("div", { style: { display: "contents" }, ref: t }); | ||
}, $ = (e) => { | ||
const n = document.createRange().createContextualFragment(t); | ||
e.current.append(n); | ||
}, []), /* @__PURE__ */ r.createElement("div", { style: { display: "contents" }, ref: e }); | ||
}, S = (t) => { | ||
const { | ||
fetchData: t, | ||
fetchData: e, | ||
params: n, | ||
@@ -23,3 +23,3 @@ initialData: a, | ||
renderError: l | ||
} = e, [h, i] = d("idle"), [o, g] = d(a), [w, F] = d(null), D = f(e.initialData !== void 0), p = f(s); | ||
} = t, [h, i] = d("idle"), [o, g] = d(a), [F, v] = d(null), D = f(t.initialData !== void 0), p = f(s); | ||
switch (p.current = s, E(() => { | ||
@@ -33,23 +33,23 @@ if (D.current) { | ||
try { | ||
const m = await t(n); | ||
const m = await e(n); | ||
g(m), i("success"); | ||
} catch (m) { | ||
F(m), i("error"); | ||
v(m), i("error"); | ||
} | ||
})(); | ||
}, [n, t]), h) { | ||
}, [n, e]), h) { | ||
case "idle": | ||
case "loading": | ||
return e.persistDataDuringLoading && o ? u(o, !0) : c ? c() : null; | ||
return t.persistDataDuringLoading && o ? u(o, !0) : c ? c() : null; | ||
case "success": | ||
return u(o, !1); | ||
case "error": | ||
return l(w); | ||
return l(F); | ||
default: | ||
return null; | ||
} | ||
}, H = (e) => { | ||
const { items: t, renderItem: n, renderEmpty: a } = e; | ||
if ("data" in t && "meta" in t) { | ||
const { data: s, meta: c } = t; | ||
}, j = (t) => { | ||
const { items: e, renderItem: n, renderEmpty: a } = t; | ||
if ("data" in e && "meta" in e) { | ||
const { data: s, meta: c } = e; | ||
return s.length === 0 ? a ? a() : null : /* @__PURE__ */ r.createElement(r.Fragment, null, s.map( | ||
@@ -59,19 +59,18 @@ (u, l) => n(typeof u == "object" ? { ...u, teleportMeta: c } : u, l) | ||
} | ||
if (Array.isArray(t)) | ||
return t.length === 0 ? a ? a() : null : /* @__PURE__ */ r.createElement(r.Fragment, null, t.map((s, c) => n(s, c))); | ||
}, v = ({ src: e, description: t }) => /* @__PURE__ */ r.createElement(r.Fragment, null, e && /* @__PURE__ */ r.createElement( | ||
if (Array.isArray(e)) | ||
return e.length === 0 ? a ? a() : null : /* @__PURE__ */ r.createElement(r.Fragment, null, e.map((s, c) => n(s, c))); | ||
}, L = ({ src: t, description: e }) => /* @__PURE__ */ r.createElement(r.Fragment, null, t && /* @__PURE__ */ r.createElement( | ||
"img", | ||
{ | ||
loading: "lazy", | ||
src: `${e}?w=1920&h=960`, | ||
srcSet: `${e}?w=3840&h=1920 1920w, ${e}?w=1920&h=960 1280w, ${e}?w=1280&h=640 640w`, | ||
alt: t ?? "" | ||
src: t, | ||
alt: e ?? "" | ||
} | ||
)), j = ({ node: e, children: t }) => e.attrs.src ? /* @__PURE__ */ r.createElement(v, { ...e.attrs }) : /* @__PURE__ */ r.createElement(r.Fragment, null, t); | ||
)), x = ({ node: t, children: e }) => t.attrs.src ? /* @__PURE__ */ r.createElement(L, { ...t.attrs }) : /* @__PURE__ */ r.createElement(r.Fragment, null, e); | ||
export { | ||
j as CaisyDocumentLink, | ||
T as DangerousHTML, | ||
$ as DataProvider, | ||
S as DateTimePrimitive, | ||
H as Repeater | ||
x as CaisyDocumentLink, | ||
H as DangerousHTML, | ||
S as DataProvider, | ||
w as DateTimePrimitive, | ||
j as Repeater | ||
}; |
{ | ||
"name": "@teleporthq/react-components", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"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
119977
501