webim-adapter 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/webim-adapter.js +114 -95
- package/build/webim-embed.js +3 -3
- package/build/webim-ssr.js +120 -101
- package/package.json +1 -1
package/build/webim-adapter.js
CHANGED
|
@@ -326,7 +326,7 @@ async function z({ apiUrl: e, tenant: t, slug: n, locale: r, preview: i, token:
|
|
|
326
326
|
locale: r
|
|
327
327
|
}), p = [...new Set(Object.values(f.blocks ?? {}).map((e) => e?.type?.resolvedName === "CollectionList" ? e.props?.collection : e?.type?.resolvedName === "TableBlock" || e?.type?.resolvedName === "OrgChartBlock" ? e.props?.source : null).filter(Boolean))];
|
|
328
328
|
if (p.length) {
|
|
329
|
-
let e = (e) => e.startsWith("api:") ? `${c}/data/${encodeURIComponent(e.slice(4))}` : `${c}/dynamic/${encodeURIComponent(e)}${r ? `?locale=${encodeURIComponent(r)}` : ""}`, t = await Promise.all(p.map((t) => s(e(t), { headers: l }).then(R).then((e) => [t, Array.isArray(e) ? e : []]).catch(() => [t, []])));
|
|
329
|
+
let e = (e) => e.startsWith("api:") ? `${c}/data/${encodeURIComponent(e.slice(4))}` : `${c}/dynamic/${encodeURIComponent(e)}${r ? `?locale=${encodeURIComponent(r)}` : ""}`, t = await Promise.all(p.map((t) => s(e(t), { headers: l }).then(R).then((e) => [t, Array.isArray(e) ? e : Array.isArray(e?.data) ? e.data : []]).catch(() => [t, []])));
|
|
330
330
|
f.datasets = Object.fromEntries(t);
|
|
331
331
|
}
|
|
332
332
|
return f;
|
|
@@ -475,7 +475,8 @@ var ie = /* @__PURE__ */ new Set([
|
|
|
475
475
|
"ckb"
|
|
476
476
|
]), ae = (e) => ie.has(String(e || "").toLowerCase().split(/[-_]/)[0]) ? "rtl" : "ltr", oe = (e, t) => e === "ltr" || e === "rtl" ? e : t ? ae(t) : void 0, V = t({
|
|
477
477
|
tenant: "",
|
|
478
|
-
apiUrl: "/api"
|
|
478
|
+
apiUrl: "/api",
|
|
479
|
+
locale: ""
|
|
479
480
|
}), H = t(null), U = t(null), se = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
480
481
|
function W(e, t) {
|
|
481
482
|
if (t) return t.includes(".") ? t.split(".").reduce((e, t) => e && typeof e == "object" ? e[t] : void 0, e) : e?.[t];
|
|
@@ -491,7 +492,7 @@ var G = (e) => {
|
|
|
491
492
|
return t;
|
|
492
493
|
};
|
|
493
494
|
function K(e) {
|
|
494
|
-
return e == null ? "" : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : typeof e == "object" && !Array.isArray(e) && ("name" in e || "slug" in e) ? String(e.name ?? e.slug ?? "") : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : Array.isArray(e?.parts) ? e.parts.map((e) => e?.text ?? "").join("") : Array.isArray(e?.items) ? e.items.map((e) => e?.text ?? "").join(" ") : e && (e.name != null || e.slug != null) ? String(e.name ?? e.slug) : "").filter(Boolean).join(" ") : "";
|
|
495
|
+
return e == null ? "" : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : typeof e == "object" && !Array.isArray(e) && ("label" in e || "name" in e || "slug" in e) ? String(e.label ?? e.name ?? e.slug ?? "") : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : Array.isArray(e?.parts) ? e.parts.map((e) => e?.text ?? "").join("") : Array.isArray(e?.items) ? e.items.map((e) => e?.text ?? "").join(" ") : e && (e.label != null || e.name != null || e.slug != null) ? String(e.label ?? e.name ?? e.slug) : "").filter(Boolean).join(" ") : "";
|
|
495
496
|
}
|
|
496
497
|
function ce(e, t) {
|
|
497
498
|
let n = t?.data ?? {}, r = G(n);
|
|
@@ -1521,14 +1522,20 @@ var tt = {
|
|
|
1521
1522
|
width: "100%",
|
|
1522
1523
|
boxSizing: "border-box"
|
|
1523
1524
|
};
|
|
1524
|
-
function rt(
|
|
1525
|
-
let
|
|
1525
|
+
function rt(e, t) {
|
|
1526
|
+
let n = Array.isArray(e?.options) ? e.options : [];
|
|
1527
|
+
if (!e?.parentField) return n;
|
|
1528
|
+
let r = t?.[e.parentField];
|
|
1529
|
+
return r ? n.filter((e) => typeof e == "string" ? !1 : !e.parent || e.parent === r) : [];
|
|
1530
|
+
}
|
|
1531
|
+
function it({ field: e, value: t, onChange: n, inert: r, values: i }) {
|
|
1532
|
+
let a = /* @__PURE__ */ u("span", {
|
|
1526
1533
|
style: {
|
|
1527
1534
|
...Ze,
|
|
1528
1535
|
fontSize: 14
|
|
1529
1536
|
},
|
|
1530
1537
|
children: [e.label, e.required ? " *" : ""]
|
|
1531
|
-
}),
|
|
1538
|
+
}), o = {
|
|
1532
1539
|
name: e.name,
|
|
1533
1540
|
required: e.required || void 0,
|
|
1534
1541
|
placeholder: e.placeholder || void 0,
|
|
@@ -1576,20 +1583,21 @@ function rt({ field: e, value: t, onChange: n, inert: r }) {
|
|
|
1576
1583
|
}) : null : /* @__PURE__ */ u("label", {
|
|
1577
1584
|
style: tt,
|
|
1578
1585
|
children: [
|
|
1579
|
-
|
|
1586
|
+
a,
|
|
1580
1587
|
e.type === "textarea" || e.multiline ? /* @__PURE__ */ l("textarea", {
|
|
1581
|
-
...
|
|
1588
|
+
...o,
|
|
1582
1589
|
rows: 4,
|
|
1583
1590
|
style: {
|
|
1584
1591
|
...nt,
|
|
1585
1592
|
resize: "vertical"
|
|
1586
1593
|
}
|
|
1587
1594
|
}) : e.type === "select" ? /* @__PURE__ */ u("select", {
|
|
1588
|
-
...
|
|
1595
|
+
...o,
|
|
1596
|
+
disabled: o.disabled || !!e.parentField && !i?.[e.parentField],
|
|
1589
1597
|
children: [/* @__PURE__ */ l("option", {
|
|
1590
1598
|
value: "",
|
|
1591
1599
|
children: e.placeholder || "—"
|
|
1592
|
-
}), (e
|
|
1600
|
+
}), rt(e, i).map((e, t) => /* @__PURE__ */ l("option", {
|
|
1593
1601
|
value: typeof e == "string" ? e : e.value,
|
|
1594
1602
|
children: typeof e == "string" ? e : e.label ?? e.value
|
|
1595
1603
|
}, t))]
|
|
@@ -1616,7 +1624,7 @@ function rt({ field: e, value: t, onChange: n, inert: r }) {
|
|
|
1616
1624
|
fontSize: 14
|
|
1617
1625
|
}
|
|
1618
1626
|
}) : /* @__PURE__ */ l("input", {
|
|
1619
|
-
...
|
|
1627
|
+
...o,
|
|
1620
1628
|
type: {
|
|
1621
1629
|
email: "email",
|
|
1622
1630
|
number: "number",
|
|
@@ -1636,7 +1644,7 @@ function rt({ field: e, value: t, onChange: n, inert: r }) {
|
|
|
1636
1644
|
]
|
|
1637
1645
|
});
|
|
1638
1646
|
}
|
|
1639
|
-
function
|
|
1647
|
+
function at({ style: e, action: t, method: i, name: a, enctype: o, formSlug: d, auto: f, submitLabel: p, nodeRef: h, inert: g, children: _, linked: v, show: y }) {
|
|
1640
1648
|
let { tenant: b, apiUrl: x } = n(V), [S, C] = s("form"), [w, T] = s(null), [E, D] = s({}), [O, k] = s(0), A = g ? y || "form" : S;
|
|
1641
1649
|
r(() => {
|
|
1642
1650
|
if (!f || !d) return;
|
|
@@ -1664,10 +1672,14 @@ function it({ style: e, action: t, method: i, name: a, enctype: o, formSlug: d,
|
|
|
1664
1672
|
})), P = M.length > 1, F = Math.min(O, Math.max(0, N.length - 1)), I = P ? N[F]?.fields ?? [] : N.flatMap((e) => e.fields), L = I.filter((e) => {
|
|
1665
1673
|
let t = E[e.name];
|
|
1666
1674
|
return e.required && (t == null || t === "" || t === !1);
|
|
1667
|
-
}), ee = F >= N.length - 1, R = (e, t) => D((n) =>
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1675
|
+
}), ee = F >= N.length - 1, R = (e, t) => D((n) => {
|
|
1676
|
+
let r = {
|
|
1677
|
+
...n,
|
|
1678
|
+
[e]: t
|
|
1679
|
+
};
|
|
1680
|
+
for (let t of Array.isArray(w?.fields) ? w.fields : []) t?.parentField === e && delete r[t.name];
|
|
1681
|
+
return r;
|
|
1682
|
+
});
|
|
1671
1683
|
return /* @__PURE__ */ u("div", {
|
|
1672
1684
|
ref: h,
|
|
1673
1685
|
style: m(e),
|
|
@@ -1718,7 +1730,7 @@ function it({ style: e, action: t, method: i, name: a, enctype: o, formSlug: d,
|
|
|
1718
1730
|
display: A === "success" ? "none" : "flex"
|
|
1719
1731
|
},
|
|
1720
1732
|
children: f && d ? /* @__PURE__ */ u(c, { children: [
|
|
1721
|
-
P && /* @__PURE__ */ l(
|
|
1733
|
+
P && /* @__PURE__ */ l(_t, {
|
|
1722
1734
|
steps: N.map((e) => ({ label: e.section?.label ?? "Start" })),
|
|
1723
1735
|
active: F + 1,
|
|
1724
1736
|
style: { marginBottom: 8 }
|
|
@@ -1731,9 +1743,10 @@ function it({ style: e, action: t, method: i, name: a, enctype: o, formSlug: d,
|
|
|
1731
1743
|
},
|
|
1732
1744
|
children: N[F].section.help
|
|
1733
1745
|
}),
|
|
1734
|
-
I.map((e) => /* @__PURE__ */ l(
|
|
1746
|
+
I.map((e) => /* @__PURE__ */ l(it, {
|
|
1735
1747
|
field: e,
|
|
1736
1748
|
value: E[e.name],
|
|
1749
|
+
values: E,
|
|
1737
1750
|
onChange: R,
|
|
1738
1751
|
inert: g
|
|
1739
1752
|
}, e.name)),
|
|
@@ -1803,7 +1816,7 @@ function it({ style: e, action: t, method: i, name: a, enctype: o, formSlug: d,
|
|
|
1803
1816
|
]
|
|
1804
1817
|
});
|
|
1805
1818
|
}
|
|
1806
|
-
function
|
|
1819
|
+
function ot({ text: e, parts: t, style: n, nodeRef: r, linked: i }) {
|
|
1807
1820
|
return /* @__PURE__ */ l("label", {
|
|
1808
1821
|
ref: r,
|
|
1809
1822
|
style: {
|
|
@@ -1813,7 +1826,7 @@ function at({ text: e, parts: t, style: n, nodeRef: r, linked: i }) {
|
|
|
1813
1826
|
children: X(t, e, i)
|
|
1814
1827
|
});
|
|
1815
1828
|
}
|
|
1816
|
-
function
|
|
1829
|
+
function st({ type: e = "text", name: t, placeholder: n, required: r, style: i, nodeRef: a, inert: o }) {
|
|
1817
1830
|
return /* @__PURE__ */ l("input", {
|
|
1818
1831
|
ref: a,
|
|
1819
1832
|
type: e,
|
|
@@ -1827,7 +1840,7 @@ function ot({ type: e = "text", name: t, placeholder: n, required: r, style: i,
|
|
|
1827
1840
|
...$e(o)
|
|
1828
1841
|
});
|
|
1829
1842
|
}
|
|
1830
|
-
function
|
|
1843
|
+
function ct({ name: e, placeholder: t, rows: n = 4, required: r, style: i, nodeRef: a, inert: o }) {
|
|
1831
1844
|
return /* @__PURE__ */ l("textarea", {
|
|
1832
1845
|
ref: a,
|
|
1833
1846
|
name: e || void 0,
|
|
@@ -1842,7 +1855,7 @@ function st({ name: e, placeholder: t, rows: n = 4, required: r, style: i, nodeR
|
|
|
1842
1855
|
...$e(o)
|
|
1843
1856
|
});
|
|
1844
1857
|
}
|
|
1845
|
-
function
|
|
1858
|
+
function lt({ kind: e = "checkbox", label: t, name: n, value: r, required: i, style: a, nodeRef: o, inert: s }) {
|
|
1846
1859
|
return /* @__PURE__ */ u("label", {
|
|
1847
1860
|
ref: o,
|
|
1848
1861
|
style: {
|
|
@@ -1863,7 +1876,7 @@ function ct({ kind: e = "checkbox", label: t, name: n, value: r, required: i, st
|
|
|
1863
1876
|
}), t]
|
|
1864
1877
|
});
|
|
1865
1878
|
}
|
|
1866
|
-
function
|
|
1879
|
+
function ut({ name: e, placeholder: t, options: n = [], required: r, style: i, nodeRef: a, inert: o }) {
|
|
1867
1880
|
return /* @__PURE__ */ u("select", {
|
|
1868
1881
|
ref: a,
|
|
1869
1882
|
name: e || void 0,
|
|
@@ -1886,7 +1899,7 @@ function lt({ name: e, placeholder: t, options: n = [], required: r, style: i, n
|
|
|
1886
1899
|
}, t))]
|
|
1887
1900
|
});
|
|
1888
1901
|
}
|
|
1889
|
-
function
|
|
1902
|
+
function dt({ name: e, accept: t, required: n, text: r = "Choose a file…", style: i, nodeRef: a, inert: o }) {
|
|
1890
1903
|
let [c, d] = s(null);
|
|
1891
1904
|
return /* @__PURE__ */ u("label", {
|
|
1892
1905
|
ref: a,
|
|
@@ -1918,7 +1931,7 @@ function ut({ name: e, accept: t, required: n, text: r = "Choose a file…", sty
|
|
|
1918
1931
|
]
|
|
1919
1932
|
});
|
|
1920
1933
|
}
|
|
1921
|
-
function
|
|
1934
|
+
function ft({ text: e = "Submit", style: t, nodeRef: n, inert: r }) {
|
|
1922
1935
|
return /* @__PURE__ */ l("button", {
|
|
1923
1936
|
ref: n,
|
|
1924
1937
|
type: r ? "button" : "submit",
|
|
@@ -1938,7 +1951,7 @@ function dt({ text: e = "Submit", style: t, nodeRef: n, inert: r }) {
|
|
|
1938
1951
|
children: e
|
|
1939
1952
|
});
|
|
1940
1953
|
}
|
|
1941
|
-
function
|
|
1954
|
+
function pt({ cols: e = 2, rows: t = 1, style: n, nodeRef: r, linked: i }) {
|
|
1942
1955
|
let a = Math.max(1, (Number(e) || 1) * (Number(t) || 1));
|
|
1943
1956
|
return /* @__PURE__ */ l("div", {
|
|
1944
1957
|
ref: r,
|
|
@@ -1955,48 +1968,52 @@ function ft({ cols: e = 2, rows: t = 1, style: n, nodeRef: r, linked: i }) {
|
|
|
1955
1968
|
}, t))
|
|
1956
1969
|
});
|
|
1957
1970
|
}
|
|
1958
|
-
function
|
|
1959
|
-
let { tenant: _, apiUrl: v } = n(V),
|
|
1971
|
+
function mt({ collection: e, limit: t = 6, layout: i = "grid", columns: a = 3, imageField: o, titleField: c = "name", textField: d, custom: f, templateId: p, style: h, nodeRef: g }) {
|
|
1972
|
+
let { tenant: _, apiUrl: v, locale: y } = n(V), b = n(U), x = n(H)?.[e], [S, C] = s(null);
|
|
1960
1973
|
if (r(() => {
|
|
1961
|
-
if (!e ||
|
|
1962
|
-
let t = !0, n = e.startsWith("api:") ? `${v}/data/${encodeURIComponent(e.slice(4))}` : `${v}/dynamic/${encodeURIComponent(e)}`;
|
|
1963
|
-
return fetch(n, { headers: _ ? { "x-tenant": _ } : {} }).then((e) => e.json()).then((e) =>
|
|
1974
|
+
if (!e || x) return;
|
|
1975
|
+
let t = !0, n = e.startsWith("api:") ? `${v}/data/${encodeURIComponent(e.slice(4))}` : `${v}/dynamic/${encodeURIComponent(e)}${y ? `?locale=${encodeURIComponent(y)}` : ""}`;
|
|
1976
|
+
return fetch(n, { headers: _ ? { "x-tenant": _ } : {} }).then((e) => e.json()).then((e) => {
|
|
1977
|
+
let n = Array.isArray(e?.payload) ? e.payload : Array.isArray(e?.payload?.data) ? e.payload.data : [];
|
|
1978
|
+
return t && C(n.filter((e) => e && typeof e == "object"));
|
|
1979
|
+
}).catch(() => t && C([])), () => {
|
|
1964
1980
|
t = !1;
|
|
1965
1981
|
};
|
|
1966
1982
|
}, [
|
|
1967
1983
|
e,
|
|
1968
1984
|
_,
|
|
1969
1985
|
v,
|
|
1970
|
-
|
|
1986
|
+
y,
|
|
1987
|
+
x
|
|
1971
1988
|
]), !e) return null;
|
|
1972
|
-
let
|
|
1989
|
+
let w = (x ?? S ?? []).slice(0, Math.max(1, Number(t) || 6)), T = Math.min(Math.max(Number(a) || 3, 1), 6), E = i === "list" ? {
|
|
1973
1990
|
display: "flex",
|
|
1974
1991
|
flexDirection: "column",
|
|
1975
1992
|
gap: 20
|
|
1976
1993
|
} : {
|
|
1977
1994
|
display: "grid",
|
|
1978
|
-
gridTemplateColumns: `repeat(${
|
|
1995
|
+
gridTemplateColumns: `repeat(${T}, minmax(0, 1fr))`,
|
|
1979
1996
|
gap: 24
|
|
1980
1997
|
};
|
|
1981
|
-
return f && p &&
|
|
1998
|
+
return f && p && b?.render ? /* @__PURE__ */ l("div", {
|
|
1982
1999
|
ref: g,
|
|
1983
2000
|
style: {
|
|
1984
2001
|
width: "100%",
|
|
1985
|
-
...
|
|
2002
|
+
...E,
|
|
1986
2003
|
...m(h)
|
|
1987
2004
|
},
|
|
1988
|
-
children:
|
|
2005
|
+
children: w.map((e) => /* @__PURE__ */ l("div", {
|
|
1989
2006
|
style: { minWidth: 0 },
|
|
1990
|
-
children:
|
|
2007
|
+
children: b.render(p, (t) => ce(t, e))
|
|
1991
2008
|
}, e.id ?? e?.data?.slug))
|
|
1992
2009
|
}) : /* @__PURE__ */ l("div", {
|
|
1993
2010
|
ref: g,
|
|
1994
2011
|
style: {
|
|
1995
2012
|
width: "100%",
|
|
1996
|
-
...
|
|
2013
|
+
...E,
|
|
1997
2014
|
...m(h)
|
|
1998
2015
|
},
|
|
1999
|
-
children:
|
|
2016
|
+
children: w.map((e) => {
|
|
2000
2017
|
let t = o ? W(e?.data, o) : null, n = c ? K(W(e?.data, c)) : null, r = d ? W(e?.data, d) : null, a = Array.isArray(r) ? r : null, s = a || r == null ? null : K(r), f = i === "list";
|
|
2001
2018
|
return /* @__PURE__ */ u("div", {
|
|
2002
2019
|
style: {
|
|
@@ -2052,7 +2069,7 @@ function pt({ collection: e, limit: t = 6, layout: i = "grid", columns: a = 3, i
|
|
|
2052
2069
|
})
|
|
2053
2070
|
});
|
|
2054
2071
|
}
|
|
2055
|
-
function
|
|
2072
|
+
function ht({ items: e = [], separator: t = "/", style: n, nodeRef: r }) {
|
|
2056
2073
|
return e.length ? /* @__PURE__ */ l("nav", {
|
|
2057
2074
|
ref: r,
|
|
2058
2075
|
"aria-label": "Breadcrumb",
|
|
@@ -2102,7 +2119,7 @@ function mt({ items: e = [], separator: t = "/", style: n, nodeRef: r }) {
|
|
|
2102
2119
|
})
|
|
2103
2120
|
}) : null;
|
|
2104
2121
|
}
|
|
2105
|
-
function
|
|
2122
|
+
function gt({ pages: e = 5, current: t = 1, prevNext: n = !0, href: r = "#", style: i, nodeRef: a }) {
|
|
2106
2123
|
let o = Math.min(Math.max(Number(e) || 1, 1), 50), s = Math.min(Math.max(Number(t) || 1, 1), o), c = (e) => r && r !== "#" ? r.replace("{page}", String(e)) : "#", d = (e) => ({
|
|
2107
2124
|
display: "inline-flex",
|
|
2108
2125
|
alignItems: "center",
|
|
@@ -2155,7 +2172,7 @@ function ht({ pages: e = 5, current: t = 1, prevNext: n = !0, href: r = "#", sty
|
|
|
2155
2172
|
]
|
|
2156
2173
|
});
|
|
2157
2174
|
}
|
|
2158
|
-
function
|
|
2175
|
+
function _t({ steps: t = [], active: n = 1, vertical: r = !1, style: i, nodeRef: a }) {
|
|
2159
2176
|
if (!t.length) return null;
|
|
2160
2177
|
let o = Math.min(Math.max(Number(n) || 1, 1), t.length), s = (e) => ({
|
|
2161
2178
|
width: 32,
|
|
@@ -2233,7 +2250,7 @@ function gt({ steps: t = [], active: n = 1, vertical: r = !1, style: i, nodeRef:
|
|
|
2233
2250
|
})
|
|
2234
2251
|
});
|
|
2235
2252
|
}
|
|
2236
|
-
var
|
|
2253
|
+
var vt = {
|
|
2237
2254
|
small: {
|
|
2238
2255
|
w: 132,
|
|
2239
2256
|
h: 46,
|
|
@@ -2255,10 +2272,10 @@ var _t = {
|
|
|
2255
2272
|
title: 12.5,
|
|
2256
2273
|
avatar: 46
|
|
2257
2274
|
}
|
|
2258
|
-
},
|
|
2259
|
-
|
|
2260
|
-
function
|
|
2261
|
-
let r =
|
|
2275
|
+
}, yt = (e) => vt[e] ?? vt.medium;
|
|
2276
|
+
vt.medium.w, vt.medium.h;
|
|
2277
|
+
function bt(e, { size: t = "medium", horizontal: n = !1 } = {}) {
|
|
2278
|
+
let r = yt(t), i = n ? r.h : r.w, a = n ? 16 : 20, o = (n ? r.w : r.h) + (n ? 56 : 48), s = Array.isArray(e) ? e.filter((e) => e && e.id) : [], c = new Set(s.map((e) => e.id)), l = /* @__PURE__ */ new Map(), u = [];
|
|
2262
2279
|
for (let e of s) e.parent && c.has(e.parent) && e.parent !== e.id ? (l.has(e.parent) || l.set(e.parent, []), l.get(e.parent).push(e)) : u.push(e);
|
|
2263
2280
|
let d = /* @__PURE__ */ new Map(), f = (e, t) => {
|
|
2264
2281
|
if (t.has(e.id)) return 0;
|
|
@@ -2310,18 +2327,18 @@ function yt(e, { size: t = "medium", horizontal: n = !1 } = {}) {
|
|
|
2310
2327
|
horizontal: n
|
|
2311
2328
|
};
|
|
2312
2329
|
}
|
|
2313
|
-
var
|
|
2330
|
+
var xt = (e, t) => {
|
|
2314
2331
|
let n = String(e ?? "");
|
|
2315
2332
|
return n.length > t ? `${n.slice(0, t - 1)}…` : n;
|
|
2316
|
-
},
|
|
2333
|
+
}, St = (e) => {
|
|
2317
2334
|
let t = /^#([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(String(e ?? "").trim());
|
|
2318
2335
|
if (!t) return "#ffffff";
|
|
2319
2336
|
let n = t[1];
|
|
2320
2337
|
n.length === 3 && (n = [...n].map((e) => e + e).join(""));
|
|
2321
2338
|
let r = parseInt(n, 16);
|
|
2322
2339
|
return .299 * (r >> 16 & 255) + .587 * (r >> 8 & 255) + .114 * (r & 255) > 150 ? "#111827" : "#ffffff";
|
|
2323
|
-
},
|
|
2324
|
-
function
|
|
2340
|
+
}, Ct = (e) => !!(e?.cv?.trim?.() || e?.photo);
|
|
2341
|
+
function wt(e, t = {}) {
|
|
2325
2342
|
let n = Array.isArray(e) ? e.filter((e) => e && typeof e == "object" && e.id) : [], r = (e) => Array.isArray(e) ? e[0] : e, i = (e) => e == null ? "" : K(e);
|
|
2326
2343
|
return n.map((e) => {
|
|
2327
2344
|
let n = e.data ?? {}, a = r(n[t.parentField]), o = a && typeof a == "object" ? a.id ?? null : a || null;
|
|
@@ -2336,11 +2353,11 @@ function Ct(e, t = {}) {
|
|
|
2336
2353
|
};
|
|
2337
2354
|
});
|
|
2338
2355
|
}
|
|
2339
|
-
var
|
|
2356
|
+
var Tt = {
|
|
2340
2357
|
size: 36,
|
|
2341
2358
|
pad: 10
|
|
2342
2359
|
};
|
|
2343
|
-
function
|
|
2360
|
+
function Et({ node: e, onClose: t }) {
|
|
2344
2361
|
return r(() => {
|
|
2345
2362
|
let e = (e) => e.key === "Escape" && t();
|
|
2346
2363
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
@@ -2458,7 +2475,7 @@ function Tt({ node: e, onClose: t }) {
|
|
|
2458
2475
|
})
|
|
2459
2476
|
});
|
|
2460
2477
|
}
|
|
2461
|
-
function
|
|
2478
|
+
function Dt({ nodes: e = [], source: t, nameField: a, titleField: o, photoField: d, parentField: f, cvField: p, hrefField: h, size: g = "medium", horizontal: _ = !1, style: v, nodeRef: y, interactive: b = !0 }) {
|
|
2462
2479
|
let x = i(), [S, C] = s(null), { tenant: w, apiUrl: T } = n(V), E = n(H)?.[t], [D, O] = s(null);
|
|
2463
2480
|
r(() => {
|
|
2464
2481
|
if (!t || E) return;
|
|
@@ -2475,14 +2492,14 @@ function Et({ nodes: e = [], source: t, nameField: a, titleField: o, photoField:
|
|
|
2475
2492
|
T,
|
|
2476
2493
|
E
|
|
2477
2494
|
]);
|
|
2478
|
-
let k = t ?
|
|
2495
|
+
let k = t ? wt(E ?? D ?? [], {
|
|
2479
2496
|
nameField: a,
|
|
2480
2497
|
titleField: o,
|
|
2481
2498
|
photoField: d,
|
|
2482
2499
|
parentField: f,
|
|
2483
2500
|
cvField: p,
|
|
2484
2501
|
hrefField: h
|
|
2485
|
-
}) : e, A =
|
|
2502
|
+
}) : e, A = yt(g), { boxes: j, links: M, width: N, height: P } = bt(k, {
|
|
2486
2503
|
size: g,
|
|
2487
2504
|
horizontal: _
|
|
2488
2505
|
});
|
|
@@ -2528,7 +2545,7 @@ function Et({ nodes: e = [], source: t, nameField: a, titleField: o, photoField:
|
|
|
2528
2545
|
stroke: "rgba(148, 163, 184, 0.7)",
|
|
2529
2546
|
strokeWidth: "1.5"
|
|
2530
2547
|
}, t)), j.map(({ node: e, x: t, y: n }) => {
|
|
2531
|
-
let r = F.has(e.id), i = !!e.color2, a = !!e.color || r || i, o = e.color || (r ? "var(--page-accent, #4f46e5)" : "var(--page-bg, #ffffff)"), s = e.color ?
|
|
2548
|
+
let r = F.has(e.id), i = !!e.color2, a = !!e.color || r || i, o = e.color || (r ? "var(--page-accent, #4f46e5)" : "var(--page-bg, #ffffff)"), s = e.color ? St(e.color) : r ? "var(--page-accent-text, #ffffff)" : "var(--page-text, #111827)", d = i ? St(e.color2) : s, f = b && (Ct(e) || e.href), p = () => Ct(e) ? C(e) : window.open(e.href, "_blank", "noreferrer"), m = e.photo ? t + Tt.pad + A.avatar + 8 : t + A.w / 2, h = e.photo ? "start" : "middle", g = e.photo ? Math.floor((A.w - A.avatar - 26) / 7) : Math.floor(A.w / 7.6), _ = A.h / 2, v = [e.name, e.title].map((e) => String(e ?? "").trim()).filter(Boolean);
|
|
2532
2549
|
return /* @__PURE__ */ u("g", {
|
|
2533
2550
|
onClick: f ? p : void 0,
|
|
2534
2551
|
style: f ? { cursor: "pointer" } : void 0,
|
|
@@ -2592,13 +2609,13 @@ function Et({ nodes: e = [], source: t, nameField: a, titleField: o, photoField:
|
|
|
2592
2609
|
e.photo && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("clipPath", {
|
|
2593
2610
|
id: `${x}-${e.id}`,
|
|
2594
2611
|
children: /* @__PURE__ */ l("circle", {
|
|
2595
|
-
cx: t +
|
|
2612
|
+
cx: t + Tt.pad + A.avatar / 2,
|
|
2596
2613
|
cy: n + A.h / 2,
|
|
2597
2614
|
r: A.avatar / 2
|
|
2598
2615
|
})
|
|
2599
2616
|
}), /* @__PURE__ */ l("image", {
|
|
2600
2617
|
href: e.photo,
|
|
2601
|
-
x: t +
|
|
2618
|
+
x: t + Tt.pad,
|
|
2602
2619
|
y: n + (A.h - A.avatar) / 2,
|
|
2603
2620
|
width: A.avatar,
|
|
2604
2621
|
height: A.avatar,
|
|
@@ -2612,7 +2629,7 @@ function Et({ nodes: e = [], source: t, nameField: a, titleField: o, photoField:
|
|
|
2612
2629
|
fontSize: A.title,
|
|
2613
2630
|
fontWeight: "600",
|
|
2614
2631
|
fill: s,
|
|
2615
|
-
children:
|
|
2632
|
+
children: xt(e.title, g + 4)
|
|
2616
2633
|
}), e.name && /* @__PURE__ */ l("text", {
|
|
2617
2634
|
x: m,
|
|
2618
2635
|
y: n + _ + _ / 2 + A.name * .35,
|
|
@@ -2620,7 +2637,7 @@ function Et({ nodes: e = [], source: t, nameField: a, titleField: o, photoField:
|
|
|
2620
2637
|
fontSize: A.name,
|
|
2621
2638
|
fontWeight: "600",
|
|
2622
2639
|
fill: d,
|
|
2623
|
-
children:
|
|
2640
|
+
children: xt(e.name, g)
|
|
2624
2641
|
})] }) : /* @__PURE__ */ u(c, { children: [v[0] && /* @__PURE__ */ l("text", {
|
|
2625
2642
|
x: m,
|
|
2626
2643
|
y: n + (v[1] ? A.h * .43 : A.h * .57),
|
|
@@ -2628,7 +2645,7 @@ function Et({ nodes: e = [], source: t, nameField: a, titleField: o, photoField:
|
|
|
2628
2645
|
fontSize: A.name,
|
|
2629
2646
|
fontWeight: "600",
|
|
2630
2647
|
fill: s,
|
|
2631
|
-
children:
|
|
2648
|
+
children: xt(v[0], g)
|
|
2632
2649
|
}), v[1] && /* @__PURE__ */ l("text", {
|
|
2633
2650
|
x: m,
|
|
2634
2651
|
y: n + A.h * .73,
|
|
@@ -2636,18 +2653,18 @@ function Et({ nodes: e = [], source: t, nameField: a, titleField: o, photoField:
|
|
|
2636
2653
|
fontSize: A.title,
|
|
2637
2654
|
opacity: "0.7",
|
|
2638
2655
|
fill: s,
|
|
2639
|
-
children:
|
|
2656
|
+
children: xt(v[1], g + 4)
|
|
2640
2657
|
})] })
|
|
2641
2658
|
]
|
|
2642
2659
|
}, e.id);
|
|
2643
2660
|
})]
|
|
2644
|
-
}), S && /* @__PURE__ */ l(
|
|
2661
|
+
}), S && /* @__PURE__ */ l(Et, {
|
|
2645
2662
|
node: S,
|
|
2646
2663
|
onClose: () => C(null)
|
|
2647
2664
|
})]
|
|
2648
2665
|
});
|
|
2649
2666
|
}
|
|
2650
|
-
function
|
|
2667
|
+
function Ot({ columns: e = [], rows: t = [], source: i, limit: a = 10, striped: o = !0, bordered: c = !1, compact: d = !1, style: f, nodeRef: p }) {
|
|
2651
2668
|
let { tenant: h, apiUrl: g } = n(V), _ = n(H)?.[i], [v, y] = s(null);
|
|
2652
2669
|
if (r(() => {
|
|
2653
2670
|
if (!i || _) return;
|
|
@@ -2698,7 +2715,7 @@ function Dt({ columns: e = [], rows: t = [], source: i, limit: a = 10, striped:
|
|
|
2698
2715
|
})
|
|
2699
2716
|
});
|
|
2700
2717
|
}
|
|
2701
|
-
var
|
|
2718
|
+
var kt = {
|
|
2702
2719
|
PageRoot: pe,
|
|
2703
2720
|
Section: me,
|
|
2704
2721
|
Container: he,
|
|
@@ -2711,13 +2728,13 @@ var Ot = {
|
|
|
2711
2728
|
SliderBlock: We,
|
|
2712
2729
|
CanvasSlider: Ge,
|
|
2713
2730
|
TabsBlock: Je,
|
|
2714
|
-
QuickStack:
|
|
2715
|
-
CollectionList:
|
|
2716
|
-
BreadcrumbsBlock:
|
|
2717
|
-
PaginationBlock:
|
|
2718
|
-
StepperBlock:
|
|
2719
|
-
OrgChartBlock:
|
|
2720
|
-
TableBlock:
|
|
2731
|
+
QuickStack: pt,
|
|
2732
|
+
CollectionList: mt,
|
|
2733
|
+
BreadcrumbsBlock: ht,
|
|
2734
|
+
PaginationBlock: gt,
|
|
2735
|
+
StepperBlock: _t,
|
|
2736
|
+
OrgChartBlock: Dt,
|
|
2737
|
+
TableBlock: Ot,
|
|
2721
2738
|
AccordionBlock: Ye,
|
|
2722
2739
|
NavbarBlock: qe,
|
|
2723
2740
|
ListBlock: Ee,
|
|
@@ -2730,21 +2747,21 @@ var Ot = {
|
|
|
2730
2747
|
YouTubeBlock: Pe,
|
|
2731
2748
|
IframeBlock: Fe,
|
|
2732
2749
|
EmbedBlock: Ie,
|
|
2733
|
-
FormBlock:
|
|
2734
|
-
FormLabel:
|
|
2735
|
-
FormInput:
|
|
2736
|
-
FormTextarea:
|
|
2737
|
-
FormCheckbox: (e) => /* @__PURE__ */ l(
|
|
2750
|
+
FormBlock: at,
|
|
2751
|
+
FormLabel: ot,
|
|
2752
|
+
FormInput: st,
|
|
2753
|
+
FormTextarea: ct,
|
|
2754
|
+
FormCheckbox: (e) => /* @__PURE__ */ l(lt, {
|
|
2738
2755
|
kind: "checkbox",
|
|
2739
2756
|
...e
|
|
2740
2757
|
}),
|
|
2741
|
-
FormRadio: (e) => /* @__PURE__ */ l(
|
|
2758
|
+
FormRadio: (e) => /* @__PURE__ */ l(lt, {
|
|
2742
2759
|
kind: "radio",
|
|
2743
2760
|
...e
|
|
2744
2761
|
}),
|
|
2745
|
-
FormSelect:
|
|
2746
|
-
FormFile:
|
|
2747
|
-
FormSubmit:
|
|
2762
|
+
FormSelect: ut,
|
|
2763
|
+
FormFile: dt,
|
|
2764
|
+
FormSubmit: ft
|
|
2748
2765
|
};
|
|
2749
2766
|
//#endregion
|
|
2750
2767
|
//#region ../ui/src/components/builder/render.jsx
|
|
@@ -2758,7 +2775,7 @@ function $(t, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
|
|
|
2758
2775
|
let c = new Set(i).add(n);
|
|
2759
2776
|
return /* @__PURE__ */ l(e, { children: $(s.template.rootId, s.template.nodes, r, c, a) }, t);
|
|
2760
2777
|
}
|
|
2761
|
-
let u =
|
|
2778
|
+
let u = kt[s];
|
|
2762
2779
|
if (!u) return null;
|
|
2763
2780
|
let d = (o.nodes ?? []).map((e) => $(e, n, r, i, a)).filter(Boolean), f = Object.entries(o.linkedNodes ?? {}), p = f.length ? Object.fromEntries(f.map(([e, t]) => [e, $(t, n, r, i)])) : void 0;
|
|
2764
2781
|
return /* @__PURE__ */ l(u, {
|
|
@@ -2773,8 +2790,8 @@ function $(t, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
|
|
|
2773
2790
|
}
|
|
2774
2791
|
//#endregion
|
|
2775
2792
|
//#region ../ui/src/components/builder/PageRenderer.jsx
|
|
2776
|
-
var
|
|
2777
|
-
function
|
|
2793
|
+
var At = (e) => Object.entries(e).map(([e, t]) => `${e}: ${t};`).join(" ");
|
|
2794
|
+
function jt({ blocks: e, theme: t, components: n, mode: i = "auto", style: o, custom: s, tenant: c, apiUrl: d, datasets: f, locale: p, direction: m }) {
|
|
2778
2795
|
let h = s?.js?.trim();
|
|
2779
2796
|
if (r(() => {
|
|
2780
2797
|
if (!h) return;
|
|
@@ -2796,7 +2813,8 @@ function At({ blocks: e, theme: t, components: n, mode: i = "auto", style: o, cu
|
|
|
2796
2813
|
if (i !== "auto") return /* @__PURE__ */ l(V.Provider, {
|
|
2797
2814
|
value: {
|
|
2798
2815
|
tenant: c || "",
|
|
2799
|
-
apiUrl: d || "/api"
|
|
2816
|
+
apiUrl: d || "/api",
|
|
2817
|
+
locale: p || ""
|
|
2800
2818
|
},
|
|
2801
2819
|
children: /* @__PURE__ */ l(H.Provider, {
|
|
2802
2820
|
value: f ?? null,
|
|
@@ -2824,7 +2842,8 @@ function At({ blocks: e, theme: t, components: n, mode: i = "auto", style: o, cu
|
|
|
2824
2842
|
return /* @__PURE__ */ l(V.Provider, {
|
|
2825
2843
|
value: {
|
|
2826
2844
|
tenant: c || "",
|
|
2827
|
-
apiUrl: d || "/api"
|
|
2845
|
+
apiUrl: d || "/api",
|
|
2846
|
+
locale: p || ""
|
|
2828
2847
|
},
|
|
2829
2848
|
children: /* @__PURE__ */ l(H.Provider, {
|
|
2830
2849
|
value: f ?? null,
|
|
@@ -2839,8 +2858,8 @@ function At({ blocks: e, theme: t, components: n, mode: i = "auto", style: o, cu
|
|
|
2839
2858
|
...o
|
|
2840
2859
|
},
|
|
2841
2860
|
children: [
|
|
2842
|
-
/* @__PURE__ */ l("style", { children: `.webim-page { ${
|
|
2843
|
-
@media (prefers-color-scheme: dark) { .webim-page { ${
|
|
2861
|
+
/* @__PURE__ */ l("style", { children: `.webim-page { ${At(P(w.light))} }
|
|
2862
|
+
@media (prefers-color-scheme: dark) { .webim-page { ${At(P(w.dark))} } }` }),
|
|
2844
2863
|
C,
|
|
2845
2864
|
b && /* @__PURE__ */ l("style", { children: b }),
|
|
2846
2865
|
x && /* @__PURE__ */ l("style", { children: x }),
|
|
@@ -2854,8 +2873,8 @@ function At({ blocks: e, theme: t, components: n, mode: i = "auto", style: o, cu
|
|
|
2854
2873
|
}
|
|
2855
2874
|
//#endregion
|
|
2856
2875
|
//#region src/WebimContent.jsx
|
|
2857
|
-
function
|
|
2858
|
-
return e?.blocks?.ROOT ? /* @__PURE__ */ l(
|
|
2876
|
+
function Mt({ bundle: e, mode: t = "auto", style: n }) {
|
|
2877
|
+
return e?.blocks?.ROOT ? /* @__PURE__ */ l(jt, {
|
|
2859
2878
|
blocks: e.blocks,
|
|
2860
2879
|
theme: e.theme,
|
|
2861
2880
|
components: e.components,
|
|
@@ -2871,7 +2890,7 @@ function jt({ bundle: e, mode: t = "auto", style: n }) {
|
|
|
2871
2890
|
}
|
|
2872
2891
|
//#endregion
|
|
2873
2892
|
//#region src/WebimPage.jsx
|
|
2874
|
-
function
|
|
2893
|
+
function Nt({ apiUrl: e, tenant: t, slug: n, locale: i, preview: a, token: c, mode: u = "auto", style: d, fallback: f = null, errorFallback: p = null, onLoad: m, onError: h }) {
|
|
2875
2894
|
let [g, _] = s({ status: "loading" }), v = o({
|
|
2876
2895
|
onLoad: m,
|
|
2877
2896
|
onError: h
|
|
@@ -2908,11 +2927,11 @@ function Mt({ apiUrl: e, tenant: t, slug: n, locale: i, preview: a, token: c, mo
|
|
|
2908
2927
|
i,
|
|
2909
2928
|
a,
|
|
2910
2929
|
c
|
|
2911
|
-
]), g.status === "loading" ? f : g.status === "error" ? typeof p == "function" ? p(g.error) : p : /* @__PURE__ */ l(
|
|
2930
|
+
]), g.status === "loading" ? f : g.status === "error" ? typeof p == "function" ? p(g.error) : p : /* @__PURE__ */ l(Mt, {
|
|
2912
2931
|
bundle: g.bundle,
|
|
2913
2932
|
mode: u,
|
|
2914
2933
|
style: d
|
|
2915
2934
|
});
|
|
2916
2935
|
}
|
|
2917
2936
|
//#endregion
|
|
2918
|
-
export {
|
|
2937
|
+
export { jt as PageRenderer, Mt as WebimContent, Nt as WebimPage, z as fetchPage, Se as renderRichContent, L as resolveTheme };
|