@chaibuilder/sdk 4.0.0-beta.36 → 4.0.0-beta.37
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/dist/{2SSKDMRQ-rk5vFzuv.js → 2SSKDMRQ-B9Y7DUaU.js} +2 -2
- package/dist/{2SSKDMRQ-C3eivR9y.cjs → 2SSKDMRQ-Dost66qm.cjs} +1 -1
- package/dist/{AP7HFJJL-BMK2jPSi.js → AP7HFJJL-Db0-YeT-.js} +1 -1
- package/dist/{AP7HFJJL-2qWLZyWT.cjs → AP7HFJJL-DxBuLcYj.cjs} +1 -1
- package/dist/{IconPicker-B-NfypT7.cjs → IconPicker-BCYCPK5M.cjs} +1 -1
- package/dist/{IconPicker-BzQ_r0nM.js → IconPicker-CQPu4qCk.js} +1 -1
- package/dist/{WDYDFRGG-Bfra_-3l.cjs → WDYDFRGG-BLnyHnIr.cjs} +1 -1
- package/dist/{WDYDFRGG-1zoPbvu7.js → WDYDFRGG-DjIZGWcU.js} +2 -2
- package/dist/{active-in-another-tab-DkOOxZwb.cjs → active-in-another-tab-D6BuBAvD.cjs} +1 -1
- package/dist/{active-in-another-tab-Zrq6x3L9.js → active-in-another-tab-DvKdkseG.js} +4 -4
- package/dist/{add-new-language-page-alqCh26P.js → add-new-language-page-Bt-EHTdP.js} +3 -3
- package/dist/{add-new-language-page-Dsze4PNK.cjs → add-new-language-page-DXaV4Znu.cjs} +1 -1
- package/dist/{add-new-page-DtQYPRYM.cjs → add-new-page-D1X6uewl.cjs} +1 -1
- package/dist/{add-new-page-HoFoI257.js → add-new-page-JSrqASzg.js} +2 -2
- package/dist/{ai-panel-content-DZmolAf1.js → ai-panel-content-BcU74IAG.js} +3 -3
- package/dist/{ai-panel-content-DcM2BBcL.cjs → ai-panel-content-Ci6Vp7Cf.cjs} +1 -1
- package/dist/{ai-panel-default-lang-BmVJcDnH.cjs → ai-panel-default-lang-CfuUmamx.cjs} +2 -2
- package/dist/{ai-panel-default-lang-Bv8Fms5X.js → ai-panel-default-lang-CxEaZ63K.js} +4 -4
- package/dist/{ai-panel-other-lang-CCGz4Tql.js → ai-panel-other-lang-B1uL_scz.js} +3 -3
- package/dist/{ai-panel-other-lang-BGyP45jz.cjs → ai-panel-other-lang-BA1TOdh_.cjs} +1 -1
- package/dist/{ai-prompt-input-CJLPetgL.cjs → ai-prompt-input-BuP52voq.cjs} +1 -1
- package/dist/{ai-prompt-input-DO-zCSY_.js → ai-prompt-input-CrRc0Z7y.js} +1 -1
- package/dist/{ai-translation-prompt-DWj1gmKg.cjs → ai-translation-prompt-D8N5bmVu.cjs} +1 -1
- package/dist/{ai-translation-prompt-DXhM0OnM.js → ai-translation-prompt-DFX27zHM.js} +1 -1
- package/dist/{apply-binding-C0xIYKCN.cjs → apply-binding-BuwI_Uf5.cjs} +9 -9
- package/dist/{apply-binding-Bu5W9YFY.js → apply-binding-RQRSIe56.js} +91 -89
- package/dist/{change-password-modal-BcJsR8sq.cjs → change-password-modal-3rWUghQW.cjs} +1 -1
- package/dist/{change-password-modal-D4wVoj8S.js → change-password-modal-kdADAvi2.js} +4 -4
- package/dist/{code-editor-B87D8cT6.js → code-editor-ClZiD7lg.js} +1 -1
- package/dist/{code-editor-BTs3K_My.cjs → code-editor-gqdLU-rU.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-BHbRZL8A.cjs → continue-editing-in-this-client-CIheMKdX.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-CoZnDfgk.js → continue-editing-in-this-client-Dl72_nLZ.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +14 -14
- package/dist/{css-import-modal-DgXSYibP.cjs → css-import-modal-B2NoLsdZ.cjs} +1 -1
- package/dist/{css-import-modal-DIgM4T8d.js → css-import-modal-nJooZxLU.js} +1 -1
- package/dist/delete-page-BtG5kYkI.cjs +1 -0
- package/dist/delete-page-DNz6-CLI.js +84 -0
- package/dist/{design-token-usage-DMSy2KGp.cjs → design-token-usage-BBLfxzzo.cjs} +1 -1
- package/dist/{design-token-usage-DSpw3Kqi.js → design-token-usage-nTgxy81G.js} +1 -1
- package/dist/{digital-asset-manager-B1KUqVJc.js → digital-asset-manager-BdNe83F3.js} +3 -3
- package/dist/{digital-asset-manager-DYMrQhJ7.cjs → digital-asset-manager-CASGSQ33.cjs} +1 -1
- package/dist/{duplicate-page-Cop50Nuj.cjs → duplicate-page-C7e9snhW.cjs} +1 -1
- package/dist/{duplicate-page-Bt36erFD.js → duplicate-page-DYxGlrmd.js} +12 -12
- package/dist/{dynamic-page-selector-DxJ80Cpv.cjs → dynamic-page-selector-Cot9d5fm.cjs} +1 -1
- package/dist/{dynamic-page-selector-jMUcjGtc.js → dynamic-page-selector-Seiq-wJc.js} +2 -2
- package/dist/{image-editor-CpUpmlCT.cjs → image-editor-Cfn290vp.cjs} +1 -1
- package/dist/{image-editor-CdNLsyhd.js → image-editor-JNxRYYiG.js} +1 -1
- package/dist/{index-DZheQdw-.js → index-7OSd9ssH.js} +4922 -4677
- package/dist/{index-K4yKMKbY.js → index-CHoZEbKv.js} +1881 -1744
- package/dist/index-P-2SvZA9.cjs +160 -0
- package/dist/index-d1_bmLx3.cjs +5 -0
- package/dist/{json-diff-viewer-CivVPp1k.js → json-diff-viewer-BzXIZ79o.js} +6 -6
- package/dist/{json-diff-viewer-BisiaC_I.cjs → json-diff-viewer-CMd26XKs.cjs} +1 -1
- package/dist/{lang-panel-DoPGR_AP.cjs → lang-panel-CxmuZt3k.cjs} +1 -1
- package/dist/{lang-panel-DejZsTqE.js → lang-panel-DPhpM-pr.js} +3 -3
- package/dist/{manage-design-tokens-Cdi3Ma4y.cjs → manage-design-tokens-B_-TrQgu.cjs} +1 -1
- package/dist/{manage-design-tokens-BxXReDdA.js → manage-design-tokens-QAUcjndy.js} +2 -2
- package/dist/{manage-design-tokens-modal-DyvSsIVv.js → manage-design-tokens-modal-BpkJx1YU.js} +2 -2
- package/dist/{manage-design-tokens-modal-Dr5lwyr_.cjs → manage-design-tokens-modal-Bug5H8PT.cjs} +1 -1
- package/dist/{mark-as-template-NPUbCfae.js → mark-as-template-BEz6ecRQ.js} +2 -2
- package/dist/{mark-as-template-OqwiT2Zm.cjs → mark-as-template-mD6fOtmk.cjs} +1 -1
- package/dist/{nested-path-selector-content-D6f2I80h.cjs → nested-path-selector-content-BHPOfftZ.cjs} +1 -1
- package/dist/{nested-path-selector-content-B4p9qltN.js → nested-path-selector-content-CoovvfzI.js} +1 -1
- package/dist/{no-language-page-content-DfdMEUqE.js → no-language-page-content-BAHxTRff.js} +2 -2
- package/dist/{no-language-page-content-BGlAr__k.cjs → no-language-page-content-DvBnZrhb.cjs} +1 -1
- package/dist/{no-language-page-dialog-d1oHBURV.cjs → no-language-page-dialog-AU6R_Umm.cjs} +1 -1
- package/dist/{no-language-page-dialog-3obqd_9-.js → no-language-page-dialog-Di0PXuKT.js} +2 -2
- package/dist/{page-creator-Il_h2vl4.cjs → page-creator-D5tEK7Vm.cjs} +1 -1
- package/dist/{page-creator-4ElxexYm.js → page-creator-VvmlAgTA.js} +3 -3
- package/dist/{page-lock-s-pfopxQ.cjs → page-lock-B6d47DbD.cjs} +1 -1
- package/dist/{page-lock-CT54xDQL.js → page-lock-COOgRF1e.js} +2 -2
- package/dist/{page-locked-dialog-BORNeoXe.cjs → page-locked-dialog-BKTQmsMr.cjs} +1 -1
- package/dist/{page-locked-dialog-CBL04Nga.js → page-locked-dialog-DSWy_zpi.js} +6 -6
- package/dist/{page-manager-new-DqCkZnWY.js → page-manager-new-ABq5ZgFr.js} +29 -29
- package/dist/{page-manager-new-Bp5QkZD4.cjs → page-manager-new-xSa6-2s3.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-CUEUB4bN.js → page-manager-search-and-filter-C6p6v1qj.js} +2 -2
- package/dist/{page-manager-search-and-filter-BMPaoTAI.cjs → page-manager-search-and-filter-DXgvy0ys.cjs} +1 -1
- package/dist/{page-revisions-content-1kklUJZV.cjs → page-revisions-content-BuNpklOO.cjs} +1 -1
- package/dist/{page-revisions-content-mU05KA_O.js → page-revisions-content-CAgq7kLY.js} +10 -10
- package/dist/pages.cjs +1 -1
- package/dist/pages.js +15 -15
- package/dist/{publish-pages-content-CpdTUAds.cjs → publish-pages-content-CX1nQ8PA.cjs} +1 -1
- package/dist/{publish-pages-content-CcV-xLsk.js → publish-pages-content-Ct7VDbNE.js} +23 -23
- package/dist/render.cjs +1 -1
- package/dist/render.js +124 -123
- package/dist/{rte-widget-modal-BCFhKLqA.cjs → rte-widget-modal-CHxO3TQR.cjs} +1 -1
- package/dist/{rte-widget-modal-DcXHaT-t.js → rte-widget-modal-iLgUdcBu.js} +1 -1
- package/dist/{save-to-lib-Uw9LqY5V.cjs → save-to-lib-C67fQ8_8.cjs} +1 -1
- package/dist/{save-to-lib-CXhaKw5V.js → save-to-lib-CAzWtI64.js} +62 -62
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-_r5ZoSSD.js → selected-block-display-B_6-n75b.js} +2 -2
- package/dist/{selected-block-display-DZz78Kuo.cjs → selected-block-display-DqC6ZtSA.cjs} +1 -1
- package/dist/{seo-panel-CMIMJh2W.js → seo-panel-DGnUvVO2.js} +25 -25
- package/dist/{seo-panel-Cj8ky_W6.cjs → seo-panel-DQmVSmiq.cjs} +1 -1
- package/dist/{shared-json-ld-C28DLkns.cjs → shared-json-ld-BpcG0rtf.cjs} +1 -1
- package/dist/{shared-json-ld-LWZfxt-V.js → shared-json-ld-CuMx_qAL.js} +11 -11
- package/dist/{slug-input-CQu9-5GT.cjs → slug-input-DHVDl_Dv.cjs} +1 -1
- package/dist/{slug-input-BCs8-IRf.js → slug-input-DcYoeQxL.js} +1 -1
- package/dist/{take-over-request-eNwLOB2Q.js → take-over-request-B2vspYrb.js} +5 -5
- package/dist/{take-over-request-x9nLTelf.cjs → take-over-request-BJaH6pnu.cjs} +1 -1
- package/dist/{translation-warning-modal-BfFfRg7q.cjs → translation-warning-modal-BxV_8mCE.cjs} +1 -1
- package/dist/{translation-warning-modal-KLjj1aXN.js → translation-warning-modal-DEW8JWRh.js} +1 -1
- package/dist/{unmark-as-template-GdqfA8lm.cjs → unmark-as-template-BYjs9XbH.cjs} +1 -1
- package/dist/{unmark-as-template-YGONVpmY.js → unmark-as-template-DEs6DnT4.js} +2 -2
- package/dist/{unpublish-page-D-A9A9db.js → unpublish-page-D-5iWXIB.js} +2 -2
- package/dist/{unpublish-page-CmwSkit5.cjs → unpublish-page-rlnt_4EX.cjs} +1 -1
- package/dist/{unpublished-partials-modal-Bx35iokR.cjs → unpublished-partials-modal-D50Hxk6N.cjs} +1 -1
- package/dist/{unpublished-partials-modal-UTkegPmZ.js → unpublished-partials-modal-Do2HSNYq.js} +1 -1
- package/dist/{web-preview-CZVcFxwF.js → web-preview-DRp7Zk7f.js} +1 -1
- package/dist/{web-preview-D4_3nlN-.cjs → web-preview-Daz-wyo3.cjs} +1 -1
- package/package.json +1 -1
- package/dist/delete-page-DKBN4nL1.cjs +0 -1
- package/dist/delete-page-T2VWcbyP.js +0 -71
- package/dist/index-DvOWqGdC.cjs +0 -5
- package/dist/index-W4Ur56bi.cjs +0 -160
package/dist/render.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { a as O, b as N, c as E, d as J, e as
|
|
3
|
-
import { h as
|
|
1
|
+
import { c as Ke, e as Re, f as Ae } from "./default-theme-options-saBIkWGT.js";
|
|
2
|
+
import { a as O, b as N, c as E, d as J, r as z, e as S, f as W } from "./apply-binding-RQRSIe56.js";
|
|
3
|
+
import { h as Me, i as Oe, g as Ne } from "./apply-binding-RQRSIe56.js";
|
|
4
4
|
import { jsx as m } from "react/jsx-runtime";
|
|
5
|
-
import { has as
|
|
6
|
-
import { Suspense as F, createElement as
|
|
7
|
-
import { f as
|
|
8
|
-
import { createTailwindcss as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { c as
|
|
14
|
-
async function
|
|
5
|
+
import { has as v, isFunction as w, omit as j, get as d, isString as X, isNull as q, isArray as b, uniqBy as H, filter as L, isEmpty as h, map as U, find as A, cloneDeep as Y } from "lodash-es";
|
|
6
|
+
import { Suspense as F, createElement as u } from "react";
|
|
7
|
+
import { f as T } from "./core-nSRy3D7z.js";
|
|
8
|
+
import { createTailwindcss as Z } from "@mhsdesign/jit-browser-tailwindcss";
|
|
9
|
+
import ee from "@tailwindcss/aspect-ratio";
|
|
10
|
+
import te from "@tailwindcss/container-queries";
|
|
11
|
+
import ae from "@tailwindcss/forms";
|
|
12
|
+
import re from "@tailwindcss/typography";
|
|
13
|
+
import { c as ne, g as ie } from "./get-chai-builder-theme-CyOkIlte.js";
|
|
14
|
+
async function oe(e) {
|
|
15
15
|
const t = {
|
|
16
16
|
pageProps: e.pageProps,
|
|
17
17
|
block: e.block,
|
|
@@ -19,83 +19,84 @@ async function ne(e) {
|
|
|
19
19
|
draft: e.draft,
|
|
20
20
|
inBuilder: !1
|
|
21
21
|
}, r = await e.dataProvider(t);
|
|
22
|
-
return
|
|
23
|
-
...
|
|
22
|
+
return v(r, "$metadata") && w(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, r.$metadata), e.children({
|
|
23
|
+
...j(r, "$metadata")
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
const { block: t, lang: r, fallbackLang: i, children: n, externalData: o, blocks: s, draft: a, pageProps: l, dataProviderMetadataCallback: y } = e,
|
|
28
|
-
N(t, r === i ? "" : r ?? "",
|
|
26
|
+
const se = () => /* @__PURE__ */ m("div", {}), le = (e) => {
|
|
27
|
+
const { block: t, lang: r, fallbackLang: i, children: n, externalData: o, blocks: s, draft: a, pageProps: l, dataProviderMetadataCallback: y } = e, g = T(t._type), c = d(g, "component", null), _ = d(e.repeaterData, "index", -1), P = d(e.repeaterData, "dataKey", ""), p = O(
|
|
28
|
+
N(t, r === i ? "" : r ?? "", g),
|
|
29
29
|
o ?? {},
|
|
30
|
-
{ index: _, key:
|
|
31
|
-
),
|
|
32
|
-
...f,
|
|
30
|
+
{ index: _, key: P }
|
|
31
|
+
), f = E(t, !1), x = V(s, t._id, J(t._type)), K = v(g, "dataProvider") && w(g.dataProvider), I = {
|
|
33
32
|
...p,
|
|
34
|
-
...
|
|
35
|
-
|
|
33
|
+
...f,
|
|
34
|
+
...x
|
|
35
|
+
}, B = {
|
|
36
36
|
blockProps: {},
|
|
37
37
|
inBuilder: !1,
|
|
38
38
|
lang: r || i || "en",
|
|
39
39
|
draft: a ?? !1,
|
|
40
40
|
pageData: o ?? {},
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
...I
|
|
42
|
+
};
|
|
43
|
+
let k = d(I, "_show", !0);
|
|
44
|
+
if (X(k) && k.startsWith("{{") && (k = z(k, o) !== "false"), q(c) || !k) return null;
|
|
45
|
+
if (K) {
|
|
46
|
+
const C = d(g, "suspenseFallback", se);
|
|
47
|
+
return /* @__PURE__ */ m(F, { fallback: u(C), children: /* @__PURE__ */ m(
|
|
48
|
+
oe,
|
|
48
49
|
{
|
|
49
50
|
lang: r ?? "",
|
|
50
51
|
pageProps: l,
|
|
51
|
-
block:
|
|
52
|
-
dataProvider:
|
|
52
|
+
block: I,
|
|
53
|
+
dataProvider: g.dataProvider,
|
|
53
54
|
...y ? { dataProviderMetadataCallback: y } : {},
|
|
54
55
|
draft: a ?? !1,
|
|
55
|
-
children: (R) =>
|
|
56
|
-
...
|
|
56
|
+
children: (R) => u(c, {
|
|
57
|
+
...B,
|
|
57
58
|
...R,
|
|
58
59
|
children: n({
|
|
59
60
|
_id: t._id,
|
|
60
61
|
_type: t._type,
|
|
61
|
-
...
|
|
62
|
-
repeaterItems:
|
|
63
|
-
$repeaterItemsKey:
|
|
64
|
-
repeaterTotalItems:
|
|
62
|
+
...b(p.repeaterItems) ? {
|
|
63
|
+
repeaterItems: S(p.repeaterItems, t),
|
|
64
|
+
$repeaterItemsKey: p.$repeaterItemsKey,
|
|
65
|
+
repeaterTotalItems: p.repeaterTotalItems ?? -1
|
|
65
66
|
} : {}
|
|
66
67
|
})
|
|
67
68
|
})
|
|
68
69
|
}
|
|
69
70
|
) });
|
|
70
71
|
}
|
|
71
|
-
return /* @__PURE__ */ m(F, { children:
|
|
72
|
-
...
|
|
72
|
+
return /* @__PURE__ */ m(F, { children: u(c, {
|
|
73
|
+
...B,
|
|
73
74
|
children: n({
|
|
74
75
|
_id: t._id,
|
|
75
76
|
_type: t._type,
|
|
76
|
-
...
|
|
77
|
-
repeaterItems:
|
|
78
|
-
$repeaterItemsKey:
|
|
79
|
-
repeaterTotalItems:
|
|
77
|
+
...b(p.repeaterItems) ? {
|
|
78
|
+
repeaterItems: S(p.repeaterItems, t),
|
|
79
|
+
$repeaterItemsKey: p.$repeaterItemsKey,
|
|
80
|
+
repeaterTotalItems: p.repeaterTotalItems ?? -1
|
|
80
81
|
} : {}
|
|
81
82
|
})
|
|
82
83
|
}) });
|
|
83
84
|
}, M = (e) => {
|
|
84
85
|
const { blocks: t, parent: r, repeaterData: i, type: n } = e;
|
|
85
|
-
let o =
|
|
86
|
-
|
|
86
|
+
let o = H(
|
|
87
|
+
L(t, (a) => v(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
|
|
87
88
|
"_id"
|
|
88
89
|
);
|
|
89
|
-
const s = (a) =>
|
|
90
|
-
return (n === "Heading" || n === "Paragraph" || n === "Link" || n === "Span") && (o =
|
|
90
|
+
const s = (a) => L(t, (l) => l._parent === a).length > 0;
|
|
91
|
+
return (n === "Heading" || n === "Paragraph" || n === "Link" || n === "Span") && (o = W(o)), U(o, (a, l) => a ? /* @__PURE__ */ u(le, { ...e, key: a._id ? `${a._id}-${l}` : `block-${l}`, block: a }, ({ _id: y, _type: g, repeaterItems: c, $repeaterItemsKey: _ }) => g === "Repeater" ? b(c) && c.map((P, $) => /* @__PURE__ */ u(
|
|
91
92
|
M,
|
|
92
93
|
{
|
|
93
94
|
...e,
|
|
94
95
|
parent: a._id,
|
|
95
|
-
key: `${d(a, "_parent", "root")}-${a._id}-${l}-${
|
|
96
|
-
repeaterData: { index:
|
|
96
|
+
key: `${d(a, "_parent", "root")}-${a._id}-${l}-${$}`,
|
|
97
|
+
repeaterData: { index: $, dataKey: _ }
|
|
97
98
|
}
|
|
98
|
-
)) : s(y) ? /* @__PURE__ */
|
|
99
|
+
)) : s(y) ? /* @__PURE__ */ u(
|
|
99
100
|
M,
|
|
100
101
|
{
|
|
101
102
|
...e,
|
|
@@ -116,7 +117,7 @@ const ie = () => /* @__PURE__ */ m("div", {}), oe = (e) => {
|
|
|
116
117
|
},
|
|
117
118
|
{}
|
|
118
119
|
);
|
|
119
|
-
function
|
|
120
|
+
function we(e) {
|
|
120
121
|
if (h(e.lang) && !h(e.fallbackLang))
|
|
121
122
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
122
123
|
if (h(e.blocks))
|
|
@@ -124,13 +125,13 @@ function $e(e) {
|
|
|
124
125
|
const t = e.lang ?? "en", r = e.fallbackLang ?? t;
|
|
125
126
|
return /* @__PURE__ */ m(M, { ...e, lang: t, fallbackLang: r });
|
|
126
127
|
}
|
|
127
|
-
async function
|
|
128
|
+
async function de(e) {
|
|
128
129
|
const t = await e.dataProvider;
|
|
129
|
-
return
|
|
130
|
-
...
|
|
130
|
+
return v(t, "$metadata") && w(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
|
|
131
|
+
...j(t, "$metadata")
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
|
-
const
|
|
134
|
+
const ce = () => /* @__PURE__ */ m("div", {}), ge = async (e) => {
|
|
134
135
|
const {
|
|
135
136
|
block: t,
|
|
136
137
|
lang: r,
|
|
@@ -141,80 +142,80 @@ const le = () => /* @__PURE__ */ m("div", {}), de = async (e) => {
|
|
|
141
142
|
draft: a,
|
|
142
143
|
pageProps: l,
|
|
143
144
|
dataProviderMetadataCallback: y,
|
|
144
|
-
dataProviders:
|
|
145
|
-
} = e, c =
|
|
145
|
+
dataProviders: g
|
|
146
|
+
} = e, c = T(t._type), _ = d(c, "component", null), P = d(e.repeaterData, "index", -1), $ = d(e.repeaterData, "dataKey", ""), f = O(
|
|
146
147
|
N(t, r === i ? "" : r ?? "en", c),
|
|
147
148
|
o ?? {},
|
|
148
|
-
{ index:
|
|
149
|
-
),
|
|
150
|
-
...
|
|
151
|
-
...
|
|
152
|
-
...
|
|
153
|
-
},
|
|
149
|
+
{ index: P, key: $ }
|
|
150
|
+
), x = E(t, !1), K = V(s, t._id, J(t._type)), I = v(c, "dataProvider") && w(c.dataProvider), B = {
|
|
151
|
+
...f,
|
|
152
|
+
...x,
|
|
153
|
+
...K
|
|
154
|
+
}, k = {
|
|
154
155
|
blockProps: {},
|
|
155
156
|
inBuilder: !1,
|
|
156
157
|
lang: r || i || "en",
|
|
157
158
|
draft: a ?? !1,
|
|
158
159
|
pageData: o ?? {},
|
|
159
|
-
...
|
|
160
|
-
},
|
|
161
|
-
if (
|
|
162
|
-
if (
|
|
163
|
-
const R = d(
|
|
164
|
-
return /* @__PURE__ */ m(F, { fallback:
|
|
165
|
-
|
|
160
|
+
...B
|
|
161
|
+
}, C = d(B, "_show", !0);
|
|
162
|
+
if (q(_) || !C) return null;
|
|
163
|
+
if (I) {
|
|
164
|
+
const R = d(g, t._id, Promise.resolve({})), G = d(c, "suspenseFallback", ce);
|
|
165
|
+
return /* @__PURE__ */ m(F, { fallback: u(G), children: /* @__PURE__ */ m(
|
|
166
|
+
de,
|
|
166
167
|
{
|
|
167
168
|
lang: r ?? "",
|
|
168
169
|
pageProps: l,
|
|
169
|
-
block:
|
|
170
|
+
block: B,
|
|
170
171
|
dataProvider: R,
|
|
171
172
|
...y ? { dataProviderMetadataCallback: y } : {},
|
|
172
173
|
draft: a ?? !1,
|
|
173
|
-
children: (Q) =>
|
|
174
|
-
...
|
|
174
|
+
children: (Q) => u(_, {
|
|
175
|
+
...k,
|
|
175
176
|
...Q,
|
|
176
177
|
children: n({
|
|
177
178
|
_id: t._id,
|
|
178
179
|
_type: t._type,
|
|
179
|
-
...
|
|
180
|
-
repeaterItems:
|
|
181
|
-
$repeaterItemsKey:
|
|
182
|
-
repeaterTotalItems:
|
|
180
|
+
...b(f.repeaterItems) ? {
|
|
181
|
+
repeaterItems: S(f.repeaterItems, t),
|
|
182
|
+
$repeaterItemsKey: f.$repeaterItemsKey,
|
|
183
|
+
repeaterTotalItems: f.repeaterTotalItems ?? -1
|
|
183
184
|
} : {}
|
|
184
185
|
})
|
|
185
186
|
})
|
|
186
187
|
}
|
|
187
188
|
) });
|
|
188
189
|
}
|
|
189
|
-
return
|
|
190
|
-
...
|
|
190
|
+
return u(_, {
|
|
191
|
+
...k,
|
|
191
192
|
children: n({
|
|
192
193
|
_id: t._id,
|
|
193
194
|
_type: t._type,
|
|
194
|
-
...
|
|
195
|
-
repeaterItems:
|
|
196
|
-
$repeaterItemsKey:
|
|
197
|
-
repeaterTotalItems:
|
|
195
|
+
...b(f.repeaterItems) ? {
|
|
196
|
+
repeaterItems: S(f.repeaterItems, t),
|
|
197
|
+
$repeaterItemsKey: f.$repeaterItemsKey,
|
|
198
|
+
repeaterTotalItems: f.repeaterTotalItems ?? -1
|
|
198
199
|
} : {}
|
|
199
200
|
})
|
|
200
201
|
});
|
|
201
|
-
},
|
|
202
|
+
}, D = async (e) => {
|
|
202
203
|
const { blocks: t, parent: r, repeaterData: i, type: n } = e;
|
|
203
|
-
let o =
|
|
204
|
-
|
|
204
|
+
let o = H(
|
|
205
|
+
L(t, (a) => v(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
|
|
205
206
|
"_id"
|
|
206
207
|
);
|
|
207
|
-
const s = (a) =>
|
|
208
|
-
return (n === "Heading" || n === "Paragraph" || n === "Link") && (o =
|
|
209
|
-
|
|
208
|
+
const s = (a) => L(t, (l) => l._parent === a).length > 0;
|
|
209
|
+
return (n === "Heading" || n === "Paragraph" || n === "Link") && (o = W(o)), U(o, (a) => a ? /* @__PURE__ */ u(ge, { ...e, dataProviders: e.dataProviders, key: a._id, block: a }, ({ _id: l, _type: y, repeaterItems: g, $repeaterItemsKey: c }) => y === "Repeater" ? b(g) && g.map((_, P) => /* @__PURE__ */ u(
|
|
210
|
+
D,
|
|
210
211
|
{
|
|
211
212
|
...e,
|
|
212
213
|
parent: a._id,
|
|
213
|
-
key: `${d(a, "_parent", "root")}-${a._id}-${
|
|
214
|
-
repeaterData: { index:
|
|
214
|
+
key: `${d(a, "_parent", "root")}-${a._id}-${P}`,
|
|
215
|
+
repeaterData: { index: P, dataKey: c }
|
|
215
216
|
}
|
|
216
|
-
)) : s(l) ? /* @__PURE__ */
|
|
217
|
-
|
|
217
|
+
)) : s(l) ? /* @__PURE__ */ u(
|
|
218
|
+
D,
|
|
218
219
|
{
|
|
219
220
|
...e,
|
|
220
221
|
parent: a._id,
|
|
@@ -224,20 +225,20 @@ const le = () => /* @__PURE__ */ m("div", {}), de = async (e) => {
|
|
|
224
225
|
}
|
|
225
226
|
) : null) : null);
|
|
226
227
|
};
|
|
227
|
-
async function
|
|
228
|
+
async function Ce(e) {
|
|
228
229
|
if (h(e.lang) && !h(e.fallbackLang))
|
|
229
230
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
230
231
|
if (h(e.blocks))
|
|
231
232
|
return null;
|
|
232
233
|
const t = e.lang ?? "en", r = e.fallbackLang ?? t;
|
|
233
234
|
if (e.dataProviders)
|
|
234
|
-
return /* @__PURE__ */ m(
|
|
235
|
+
return /* @__PURE__ */ m(D, { ...e, lang: t, fallbackLang: r, dataProviders: e.dataProviders });
|
|
235
236
|
const n = e.blocks.filter((o) => {
|
|
236
|
-
const s =
|
|
237
|
-
return !!(
|
|
237
|
+
const s = T(o._type);
|
|
238
|
+
return !!(v(s, "dataProvider") && w(s.dataProvider));
|
|
238
239
|
}).reduce(
|
|
239
240
|
(o, s) => {
|
|
240
|
-
const a =
|
|
241
|
+
const a = T(s._type);
|
|
241
242
|
if (!a || !a.dataProvider)
|
|
242
243
|
return o;
|
|
243
244
|
const l = {
|
|
@@ -251,44 +252,44 @@ async function Ie(e) {
|
|
|
251
252
|
},
|
|
252
253
|
{}
|
|
253
254
|
);
|
|
254
|
-
return /* @__PURE__ */ m(
|
|
255
|
+
return /* @__PURE__ */ m(D, { ...e, lang: t, fallbackLang: r, dataProviders: n });
|
|
255
256
|
}
|
|
256
|
-
function
|
|
257
|
+
function Se(e, t) {
|
|
257
258
|
const r = e.filter((i) => i._type === "GlobalBlock" || i._type === "PartialBlock");
|
|
258
259
|
for (let i = 0; i < r.length; i++) {
|
|
259
260
|
const n = r[i], o = d(n, "partialBlockId", d(n, "globalBlock", ""));
|
|
260
261
|
if (o === "") continue;
|
|
261
|
-
let s =
|
|
262
|
+
let s = Y(d(t, o, []));
|
|
262
263
|
n._parent && (s == null ? void 0 : s.length) > 0 && (s = s.map((l) => (h(l._parent) && (l._parent = n._parent), l)));
|
|
263
264
|
const a = e.indexOf(n);
|
|
264
265
|
e.splice(a, 1, ...s);
|
|
265
266
|
}
|
|
266
267
|
return e;
|
|
267
268
|
}
|
|
268
|
-
const
|
|
269
|
+
const Le = (e) => {
|
|
269
270
|
if (!e) return [];
|
|
270
271
|
try {
|
|
271
|
-
return JSON.parse(
|
|
272
|
+
return JSON.parse(ue(e)).filter((r) => !r._type.startsWith("@chai"));
|
|
272
273
|
} catch {
|
|
273
274
|
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
274
275
|
}
|
|
275
276
|
};
|
|
276
|
-
function
|
|
277
|
+
function ue(e) {
|
|
277
278
|
const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
278
279
|
return e.replace(t, (r) => {
|
|
279
280
|
const i = decodeURIComponent(r), n = i.indexOf("public");
|
|
280
281
|
return n !== -1 ? i.substring(n + 6) : i;
|
|
281
282
|
});
|
|
282
283
|
}
|
|
283
|
-
async function
|
|
284
|
-
return await
|
|
284
|
+
async function fe(e, t = [], r = !1) {
|
|
285
|
+
return await Z({
|
|
285
286
|
tailwindConfig: {
|
|
286
287
|
darkMode: "class",
|
|
287
288
|
safelist: t,
|
|
288
289
|
theme: {
|
|
289
290
|
// @ts-ignore
|
|
290
291
|
extend: {
|
|
291
|
-
...
|
|
292
|
+
...ie(),
|
|
292
293
|
keyframes: {
|
|
293
294
|
"accordion-down": {
|
|
294
295
|
from: {
|
|
@@ -313,7 +314,7 @@ async function ue(e, t = [], r = !1) {
|
|
|
313
314
|
}
|
|
314
315
|
}
|
|
315
316
|
},
|
|
316
|
-
plugins: [
|
|
317
|
+
plugins: [ae, re, ee, te, ne],
|
|
317
318
|
corePlugins: { preflight: r }
|
|
318
319
|
}
|
|
319
320
|
}).generateStylesFromContent(
|
|
@@ -323,20 +324,20 @@ async function ue(e, t = [], r = !1) {
|
|
|
323
324
|
e
|
|
324
325
|
);
|
|
325
326
|
}
|
|
326
|
-
const
|
|
327
|
+
const pe = (e, t) => {
|
|
327
328
|
const r = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, n) => `#styles:${n.replace(/^,/g, " ")}`.replace(/#styles:/g, ""));
|
|
328
|
-
return
|
|
329
|
-
},
|
|
329
|
+
return fe([r], [], t);
|
|
330
|
+
}, Te = async (e, t = !1) => await pe(e, t);
|
|
330
331
|
export {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
332
|
+
Ce as AsyncRenderChaiBlocks,
|
|
333
|
+
we as RenderChaiBlocks,
|
|
334
|
+
Me as applyChaiDataBinding,
|
|
335
|
+
Oe as applyDesignTokens,
|
|
336
|
+
Ne as convertHTMLToChaiBlocks,
|
|
337
|
+
Le as convertToBlocks,
|
|
338
|
+
Ke as getChaiThemeCssVariables,
|
|
339
|
+
Se as getMergedPartialBlocks,
|
|
340
|
+
Te as getStylesForBlocks,
|
|
341
|
+
Re as getThemeFontsCSSImport,
|
|
342
|
+
Ae as getThemeFontsLinkMarkup
|
|
342
343
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-P-2SvZA9.cjs"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),S=({isOpen:m,onClose:r,editor:t,rteElement:f})=>{const a=s.usePageExternalData(),u=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:j,to:g}=t.state.selection;if(j!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,n=c.selection.from,x=c.doc.textBetween(Math.max(0,n-1),n),l=c.doc.textBetween(n,Math.min(n+1,c.doc.content.size));let d="";n>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";l&&l!==" "&&!/[.,!?;:]/.test(l)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(s.Dialog,{open:m,onOpenChange:o=>!o&&r(),children:e.jsxs(s.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),a&&Object.keys(a).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(s.NestedPathSelector,{data:a,onSelect:u})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(p.Button,{onClick:r,children:"Done"})})]})})};exports.default=S;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
|
-
import { h as D, D as N, e as S, f as j, g as v, N as w } from "./index-
|
|
2
|
+
import { h as D, D as N, e as S, f as j, g as v, N as w } from "./index-7OSd9ssH.js";
|
|
3
3
|
import { B } from "./register-chai-top-bar-D6GjnauV.js";
|
|
4
4
|
const M = ({
|
|
5
5
|
isOpen: f,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),x=require("./index-W4Ur56bi.cjs"),b=require("./index-DvOWqGdC.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-UaU7Bwqe.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',c,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartialBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),x=require("./index-P-2SvZA9.cjs"),b=require("./index-d1_bmLx3.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-UaU7Bwqe.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',c,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartialBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;
|