@chaibuilder/sdk 4.0.0-beta.1 → 4.0.0-beta.3
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/README.md +27 -20
- package/dist/2SSKDMRQ-BnsZi3K3.cjs +1 -0
- package/dist/2SSKDMRQ-CnSDkQcy.js +42 -0
- package/dist/AP7HFJJL-B31839PG.cjs +1228 -0
- package/dist/AP7HFJJL-CymCmW14.js +9214 -0
- package/dist/IconPicker-B1rWC-Ex.js +59 -0
- package/dist/IconPicker-DREyo007.cjs +1 -0
- package/dist/WDYDFRGG-BUVnbAci.js +33 -0
- package/dist/WDYDFRGG-BxhOCHc3.cjs +1 -0
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
- package/dist/actions-registery-CZ1w0NKa.js +15545 -0
- package/dist/actions-registery-YnFmU21O.cjs +418 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +3202 -0
- package/dist/actions.js +216 -0
- package/dist/active-in-another-tab-B47YjQGN.cjs +1 -0
- package/dist/active-in-another-tab-CyjngVA6.js +34 -0
- package/dist/add-new-language-page-88xzrUy8.cjs +1 -0
- package/dist/add-new-language-page-WmlCnytQ.js +401 -0
- package/dist/add-new-page-VW2wAYZp.js +31 -0
- package/dist/add-new-page-soZ8GAkN.cjs +1 -0
- package/dist/ai-panel-content-7zCil042.cjs +1 -0
- package/dist/ai-panel-content-D_o7Q_A-.js +61 -0
- package/dist/ai-panel-default-lang-COYaxNwn.cjs +3 -0
- package/dist/ai-panel-default-lang-DnElspF0.js +341 -0
- package/dist/ai-panel-other-lang-CkynNlAU.cjs +1 -0
- package/dist/ai-panel-other-lang-Dp0E9_Hx.js +162 -0
- package/dist/ai-prompt-input-Bhc0ds7X.js +655 -0
- package/dist/ai-prompt-input-CThbVp0_.cjs +1 -0
- package/dist/ai-translation-prompt-C2kJQFDX.cjs +1 -0
- package/dist/ai-translation-prompt-CZ55HQmo.js +28 -0
- package/dist/apply-binding-6iwlED02.js +833 -0
- package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
- package/dist/code-display-BnqzqzoP.cjs +1 -0
- package/dist/{code-display-337R7Dev.js → code-display-DhD_RBcg.js} +1 -1
- package/dist/code-editor-DRIAnNbb.js +50 -0
- package/dist/code-editor-o3___nu2.cjs +1 -0
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/continue-editing-in-this-client-CS2aQ7yY.js +24 -0
- package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +1 -0
- package/dist/core-BoRDjj4h.cjs +1 -0
- package/dist/core-yvI6kCyw.js +56 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +51 -383
- package/dist/core.js +39 -106
- package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-Byg6wV0O.js} +36 -36
- package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
- package/dist/delete-design-token-BRZZiWtQ.js +40 -0
- package/dist/delete-design-token-DkVs1oBf.cjs +1 -0
- package/dist/delete-page-BzyX9TN-.js +70 -0
- package/dist/delete-page-DxX7PFIE.cjs +1 -0
- package/dist/design-token-usage-CAHzEGgJ.cjs +1 -0
- package/dist/design-token-usage-xQs6SlaJ.js +113 -0
- package/dist/digital-asset-manager--uO8Agia.cjs +1 -0
- package/dist/digital-asset-manager-DbtwzxRz.js +876 -0
- package/dist/duplicate-page-BR7Dlo9d.js +133 -0
- package/dist/duplicate-page-CaNAbXwV.cjs +1 -0
- package/dist/dynamic-page-selector-Cb5r_W8s.js +85 -0
- package/dist/dynamic-page-selector-Cxk_gjni.cjs +1 -0
- package/dist/fonts-B-Xt29pe.cjs +1 -0
- package/dist/fonts-DRly3Wzd.js +78 -0
- package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
- package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
- package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/image-editor-DV8kUKhl.js +108 -0
- package/dist/image-editor-G-K28aTS.cjs +1 -0
- package/dist/index-B-rSiAp_.cjs +1 -0
- package/dist/index-Ct7ElCGK.js +19069 -0
- package/dist/index-DF5DEvqb.cjs +160 -0
- package/dist/index-Dxfyt4d4.js +39 -0
- package/dist/index-WQwzsC7A.cjs +5 -0
- package/dist/index-ZuacEL1j.js +4732 -0
- package/dist/json-diff-viewer-D7z4zNvv.cjs +8 -0
- package/dist/json-diff-viewer-krslPepD.js +258 -0
- package/dist/lang-panel-BwIewMyw.js +215 -0
- package/dist/lang-panel-DT96k1xg.cjs +1 -0
- package/dist/manage-design-tokens-Caz_20VK.js +240 -0
- package/dist/manage-design-tokens-CrmLe7UT.cjs +1 -0
- package/dist/mark-as-template-D295ZQtU.js +156 -0
- package/dist/mark-as-template-W3LmpiqN.cjs +1 -0
- package/dist/models-5gOsRC56.cjs +1 -0
- package/dist/models-D95ZYr_x.js +70 -0
- package/dist/nested-path-selector-content-CKYYK-C5.js +87 -0
- package/dist/nested-path-selector-content-CoS_d3dc.cjs +1 -0
- package/dist/no-language-page-content-BvqRBP6y.js +42 -0
- package/dist/no-language-page-content-DkfeMl90.cjs +1 -0
- package/dist/no-language-page-dialog-BcEoqyQB.cjs +1 -0
- package/dist/no-language-page-dialog-PjNqTUpl.js +10 -0
- package/dist/page-creator-C4gc5NSC.cjs +1 -0
- package/dist/page-creator-DiOITEMw.js +795 -0
- package/dist/page-lock-BdYmCks0.cjs +1 -0
- package/dist/page-lock-Bfbs6RgL.js +30 -0
- package/dist/page-locked-dialog-B1FAtK92.cjs +1 -0
- package/dist/page-locked-dialog-B6MKTRfY.js +133 -0
- package/dist/page-manager-new-CHDueBDk.cjs +1 -0
- package/dist/page-manager-new-CzX22g2n.js +394 -0
- package/dist/page-manager-search-and-filter-CM0UMb6U.js +201 -0
- package/dist/page-manager-search-and-filter-DkkRIH86.cjs +1 -0
- package/dist/page-revisions-content-ChY-4f2V.cjs +1 -0
- package/dist/page-revisions-content-NH9JK4Ey.js +445 -0
- package/dist/pages.cjs +1 -0
- package/dist/pages.d.ts +491 -0
- package/dist/pages.js +27 -0
- package/dist/plugin-3ZKK6RXm.js +245 -0
- package/dist/plugin-C6rgJDNQ.cjs +22 -0
- package/dist/publish-pages-content-D9aixMN5.js +178 -0
- package/dist/publish-pages-content-x-JuSFJ9.cjs +1 -0
- package/dist/register-partial-type-BjtdfKHE.js +36 -0
- package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +26 -13
- package/dist/render.js +130 -124
- package/dist/rte-widget-modal-BaHIuEjF.cjs +1 -0
- package/dist/rte-widget-modal-DOJEXLIf.js +38 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +306 -7
- package/dist/runtime.js +44 -1
- package/dist/save-to-lib-Cgpxw8-g.cjs +1 -0
- package/dist/save-to-lib-eiOc_SSN.js +422 -0
- package/dist/sdk.css +1 -1
- package/dist/selected-block-display-BgRY82CT.cjs +16 -0
- package/dist/selected-block-display-CBFePS19.js +319 -0
- package/dist/seo-panel-C1-iMOR1.js +798 -0
- package/dist/seo-panel-DfAb8U7W.cjs +2 -0
- package/dist/shared-json-ld-B4PxAM_0.js +565 -0
- package/dist/shared-json-ld-DzG398hr.cjs +1 -0
- package/dist/slug-input-AwNJs9im.js +86 -0
- package/dist/slug-input-C_ijLQ_X.cjs +1 -0
- package/dist/supabase-actions.cjs +1 -0
- package/dist/supabase-actions.d.ts +284 -0
- package/dist/supabase-actions.js +524 -0
- package/dist/take-over-request-BNxcjY2j.cjs +1 -0
- package/dist/take-over-request-C4FeDtN_.js +63 -0
- package/dist/theme-panel-footer-Cq9pljro.cjs +1 -0
- package/dist/theme-panel-footer-uBQqSJXm.js +25 -0
- package/dist/translation-warning-modal-B64YqlbI.js +26 -0
- package/dist/translation-warning-modal-BZAcwM2_.cjs +1 -0
- package/dist/unmark-as-template-CZ9sQp_P.js +39 -0
- package/dist/unmark-as-template-EVvk0vmp.cjs +1 -0
- package/dist/unpublish-page-D4VwOlxc.js +27 -0
- package/dist/unpublish-page-bdSmwAVQ.cjs +1 -0
- package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
- package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
- package/dist/{tailwind.cjs → utils.cjs} +1 -1
- package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
- package/dist/utils.js +7 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +0 -6
- package/dist/web-blocks.js +248 -241
- package/dist/web-preview-Cio70gk5.cjs +1 -0
- package/dist/web-preview-Djy6WIyj.js +73 -0
- package/package.json +175 -105
- package/dist/IconPicker-CGWn9C4u.cjs +0 -1
- package/dist/IconPicker-QvxJ-4Ez.js +0 -64
- package/dist/apply-binding-DCno1xQL.js +0 -711
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/code-display-BZ1x7SqI.cjs +0 -1
- package/dist/code-editor-B28LoECM.cjs +0 -1
- package/dist/code-editor-CfG2FhJ-.js +0 -58
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/css-import-modal-CENUYvcl.cjs +0 -13
- package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
- package/dist/index-CaGNHF7f.js +0 -12209
- package/dist/index-Gn6pJt2v.cjs +0 -166
- package/dist/mockServiceWorker.js +0 -307
- package/dist/plugin-B5627hMN.js +0 -195
- package/dist/plugin-UxTRfDum.cjs +0 -22
- package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
- package/dist/rte-widget-modal-Dte0od04.js +0 -41
- package/dist/tailwind.js +0 -7
- package/dist/tooltip-A4qGk781.cjs +0 -1
- package/dist/tooltip-tLiIOgjq.js +0 -1067
- package/dist/ui.cjs +0 -1
- package/dist/ui.d.ts +0 -415
- package/dist/ui.js +0 -129
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { B as b, c as z, a9 as se, aa as ie, P as oe, I as L, aE as le, am as ce, aF as de, L as P } from "./index-Ct7ElCGK.js";
|
|
3
|
+
import { ar as D, as as G, A as _, ay as ue } from "./index-ZuacEL1j.js";
|
|
4
|
+
import { useQuery as K, useMutation as U, useQueryClient as me } from "@tanstack/react-query";
|
|
5
|
+
import { toast as N } from "sonner";
|
|
6
|
+
import { Trash2 as Y, Plus as pe, ImageIcon as he, X as fe, AlertCircle as ge } from "lucide-react";
|
|
7
|
+
import { useState as f, useRef as V, useMemo as S, useEffect as w, useCallback as be } from "react";
|
|
8
|
+
import { c as ve } from "./image-compression-DsZ1oqpb.js";
|
|
9
|
+
import { isEmpty as ye, set as ke, has as Ne } from "lodash-es";
|
|
10
|
+
const Be = (r) => {
|
|
11
|
+
const a = D(), o = G();
|
|
12
|
+
return U({
|
|
13
|
+
mutationFn: async (t) => o(a, {
|
|
14
|
+
action: _.UPSERT_LIBRARY_ITEM,
|
|
15
|
+
data: t
|
|
16
|
+
}),
|
|
17
|
+
onSuccess: (t) => {
|
|
18
|
+
r ? r(t) : N.success("Block saved successfully");
|
|
19
|
+
},
|
|
20
|
+
onError: (t) => {
|
|
21
|
+
console.error("Error saving block:", t), N.error("Failed to save block", {
|
|
22
|
+
description: t instanceof Error ? t.message : "Unknown error"
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}, Ce = (r) => {
|
|
27
|
+
const a = D(), o = G();
|
|
28
|
+
return K({
|
|
29
|
+
staleTime: "static",
|
|
30
|
+
queryKey: [_.GET_LIBRARY_ITEM, r],
|
|
31
|
+
enabled: !!r,
|
|
32
|
+
// Only run query if blockId is provided
|
|
33
|
+
queryFn: async () => {
|
|
34
|
+
if (!r) return null;
|
|
35
|
+
try {
|
|
36
|
+
return await o(a, {
|
|
37
|
+
action: _.GET_LIBRARY_ITEM,
|
|
38
|
+
data: { id: r }
|
|
39
|
+
});
|
|
40
|
+
} catch (t) {
|
|
41
|
+
throw console.error(t), new Error("The block could not be found on the server. It may have been deleted.");
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
retry: !1
|
|
45
|
+
});
|
|
46
|
+
}, Ie = (r) => {
|
|
47
|
+
const a = D(), o = G();
|
|
48
|
+
return U({
|
|
49
|
+
mutationFn: async (t) => o(a, {
|
|
50
|
+
action: _.DELETE_LIBRARY_ITEM,
|
|
51
|
+
data: { id: t }
|
|
52
|
+
}),
|
|
53
|
+
onSuccess: () => {
|
|
54
|
+
r ? r() : N.success("Block deleted successfully");
|
|
55
|
+
},
|
|
56
|
+
onError: (t) => {
|
|
57
|
+
console.error("Error deleting block:", t), N.error("Failed to delete block", {
|
|
58
|
+
description: t instanceof Error ? t.message : "Unknown error"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}, we = ({
|
|
63
|
+
blockId: r,
|
|
64
|
+
libBlockId: a,
|
|
65
|
+
isOpen: o,
|
|
66
|
+
onClose: t,
|
|
67
|
+
blockName: u,
|
|
68
|
+
trigger: p
|
|
69
|
+
}) => {
|
|
70
|
+
const [d, l] = f(!1), c = z(), v = Ie(() => {
|
|
71
|
+
c([r], { _libBlockId: void 0 }), N.success("Block deleted successfully"), l(!1), t();
|
|
72
|
+
});
|
|
73
|
+
return /* @__PURE__ */ i(se, { open: o, onOpenChange: (m) => !m && t(), children: [
|
|
74
|
+
/* @__PURE__ */ e(ie, { asChild: !0, children: p || /* @__PURE__ */ i(b, { type: "button", variant: "destructive", size: "sm", onClick: (m) => m.preventDefault(), disabled: d, children: [
|
|
75
|
+
/* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4" }),
|
|
76
|
+
"Delete"
|
|
77
|
+
] }) }),
|
|
78
|
+
/* @__PURE__ */ e(
|
|
79
|
+
oe,
|
|
80
|
+
{
|
|
81
|
+
className: "z-[9999] w-72 p-4",
|
|
82
|
+
sideOffset: 5,
|
|
83
|
+
align: "center",
|
|
84
|
+
children: /* @__PURE__ */ i("div", { className: "space-y-3", children: [
|
|
85
|
+
/* @__PURE__ */ e("h4", { className: "font-medium", children: "Delete Block" }),
|
|
86
|
+
/* @__PURE__ */ i("p", { className: "text-sm", children: [
|
|
87
|
+
"Are you sure you want to delete the block",
|
|
88
|
+
/* @__PURE__ */ i("span", { className: "font-medium", children: [
|
|
89
|
+
' "',
|
|
90
|
+
u,
|
|
91
|
+
'"'
|
|
92
|
+
] }),
|
|
93
|
+
"?"
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "This block will be permanently removed from the library. This action cannot be undone." }),
|
|
96
|
+
/* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-2", children: [
|
|
97
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "sm", onClick: t, disabled: d, children: "Cancel" }),
|
|
98
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "destructive", size: "sm", onClick: () => {
|
|
99
|
+
l(!0), v.mutate(a);
|
|
100
|
+
}, disabled: d, children: d ? "Deleting..." : "Delete" })
|
|
101
|
+
] })
|
|
102
|
+
] })
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] });
|
|
106
|
+
}, Ee = ({
|
|
107
|
+
blockId: r,
|
|
108
|
+
libBlockId: a,
|
|
109
|
+
blockName: o,
|
|
110
|
+
size: t = "sm",
|
|
111
|
+
className: u = "",
|
|
112
|
+
close: p
|
|
113
|
+
}) => {
|
|
114
|
+
const [d, l] = f(!1);
|
|
115
|
+
return /* @__PURE__ */ e(
|
|
116
|
+
we,
|
|
117
|
+
{
|
|
118
|
+
blockId: r,
|
|
119
|
+
libBlockId: a,
|
|
120
|
+
isOpen: d,
|
|
121
|
+
onClose: () => {
|
|
122
|
+
l(!1), p();
|
|
123
|
+
},
|
|
124
|
+
blockName: o,
|
|
125
|
+
trigger: /* @__PURE__ */ i(
|
|
126
|
+
b,
|
|
127
|
+
{
|
|
128
|
+
type: "button",
|
|
129
|
+
variant: "destructive",
|
|
130
|
+
size: t,
|
|
131
|
+
className: u,
|
|
132
|
+
onClick: () => l(!0),
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4" }),
|
|
135
|
+
"Delete"
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}, xe = () => {
|
|
142
|
+
const r = D(), a = G(), o = me(), {
|
|
143
|
+
data: t = [],
|
|
144
|
+
isLoading: u,
|
|
145
|
+
error: p
|
|
146
|
+
} = K({
|
|
147
|
+
queryKey: ["library-groups"],
|
|
148
|
+
staleTime: "static",
|
|
149
|
+
placeholderData: [],
|
|
150
|
+
queryFn: async () => {
|
|
151
|
+
try {
|
|
152
|
+
return await a(r, {
|
|
153
|
+
action: "GET_LIBRARY_GROUPS"
|
|
154
|
+
}) || [];
|
|
155
|
+
} catch (c) {
|
|
156
|
+
return console.error("Error fetching library groups:", c), [];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}), { mutateAsync: d, isPending: l } = U({
|
|
160
|
+
mutationFn: async (c) => {
|
|
161
|
+
if (!c.trim())
|
|
162
|
+
throw new Error("Group name is required");
|
|
163
|
+
return a(r, {
|
|
164
|
+
action: "CREATE_BLOCK_GROUP",
|
|
165
|
+
data: { name: c }
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
onSuccess: () => {
|
|
169
|
+
o.invalidateQueries({
|
|
170
|
+
queryKey: ["library-groups"]
|
|
171
|
+
}), N.success("Group created successfully");
|
|
172
|
+
},
|
|
173
|
+
onError: (c) => {
|
|
174
|
+
console.error("Error creating group:", c), N.error("Failed to create group", {
|
|
175
|
+
description: c instanceof Error ? c.message : "Unknown error"
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
groups: t,
|
|
181
|
+
isLoading: u,
|
|
182
|
+
error: p,
|
|
183
|
+
createGroup: d,
|
|
184
|
+
isCreating: l
|
|
185
|
+
};
|
|
186
|
+
}, Pe = ({ value: r, onChange: a }) => {
|
|
187
|
+
const [o, t] = f(!1), [u, p] = f(""), d = V(null), { groups: l } = xe(), [c, v] = f([
|
|
188
|
+
{ id: "hero", name: "Hero" },
|
|
189
|
+
{ id: "feature", name: "Feature" },
|
|
190
|
+
{ id: "footer", name: "Footer" },
|
|
191
|
+
{ id: "content", name: "Content" },
|
|
192
|
+
{ id: "testimonial", name: "Testimonial" },
|
|
193
|
+
{ id: "pricing", name: "Pricing" },
|
|
194
|
+
{ id: "login", name: "Login" },
|
|
195
|
+
{ id: "logos", name: "Logos" },
|
|
196
|
+
{ id: "about", name: "About" },
|
|
197
|
+
{ id: "banner", name: "Banner" },
|
|
198
|
+
{ id: "blog", name: "Blog" },
|
|
199
|
+
{ id: "careers", name: "Careers" },
|
|
200
|
+
{ id: "casestudy", name: "Casestudy" },
|
|
201
|
+
{ id: "changelog", name: "Changelog" },
|
|
202
|
+
{ id: "compare", name: "Compare" },
|
|
203
|
+
{ id: "contact", name: "Contact" },
|
|
204
|
+
{ id: "cta", name: "Cta" },
|
|
205
|
+
{ id: "faq", name: "Faq" },
|
|
206
|
+
{ id: "gallery", name: "Gallery" },
|
|
207
|
+
{ id: "integration", name: "Integration" },
|
|
208
|
+
{ id: "list", name: "List" },
|
|
209
|
+
{ id: "navbar", name: "Navbar" },
|
|
210
|
+
{ id: "product", name: "Product" },
|
|
211
|
+
{ id: "signup", name: "Signup" },
|
|
212
|
+
{ id: "stats", name: "Stats" },
|
|
213
|
+
{ id: "team", name: "Team" },
|
|
214
|
+
{ id: "timeline", name: "Timeline" }
|
|
215
|
+
]), h = S(
|
|
216
|
+
() => [
|
|
217
|
+
...l,
|
|
218
|
+
...c.filter((n) => !l.some((B) => B.id === n.id))
|
|
219
|
+
],
|
|
220
|
+
[l, c]
|
|
221
|
+
), g = () => {
|
|
222
|
+
const n = u.trim();
|
|
223
|
+
if (!n) return;
|
|
224
|
+
const B = { id: n, name: n };
|
|
225
|
+
v((E) => [...E, B]), a(B.id), p(""), t(!1);
|
|
226
|
+
};
|
|
227
|
+
w(() => {
|
|
228
|
+
o && d.current && d.current.focus();
|
|
229
|
+
}, [o]);
|
|
230
|
+
const m = (n) => {
|
|
231
|
+
n.key === "Enter" && (n.preventDefault(), g());
|
|
232
|
+
};
|
|
233
|
+
return w(() => {
|
|
234
|
+
r && !h.some((n) => n.id === r) && a("");
|
|
235
|
+
}, [r, h, a]), o ? /* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
236
|
+
/* @__PURE__ */ e(
|
|
237
|
+
L,
|
|
238
|
+
{
|
|
239
|
+
ref: d,
|
|
240
|
+
placeholder: "Enter new group name",
|
|
241
|
+
value: u,
|
|
242
|
+
onChange: (n) => p(n.target.value),
|
|
243
|
+
onKeyDown: m
|
|
244
|
+
}
|
|
245
|
+
),
|
|
246
|
+
/* @__PURE__ */ i("div", { className: "flex justify-end gap-2", children: [
|
|
247
|
+
/* @__PURE__ */ e(b, { variant: "outline", size: "sm", onClick: () => t(!1), children: "Cancel" }),
|
|
248
|
+
/* @__PURE__ */ e(b, { size: "sm", onClick: g, children: "Create" })
|
|
249
|
+
] })
|
|
250
|
+
] }) : /* @__PURE__ */ i("div", { className: "flex gap-2", children: [
|
|
251
|
+
/* @__PURE__ */ i(
|
|
252
|
+
"select",
|
|
253
|
+
{
|
|
254
|
+
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",
|
|
255
|
+
value: r,
|
|
256
|
+
onChange: (n) => a(n.target.value),
|
|
257
|
+
children: [
|
|
258
|
+
/* @__PURE__ */ e("option", { value: "", children: "Select a group" }),
|
|
259
|
+
l.length > 0 && /* @__PURE__ */ e("optgroup", { label: "Library Groups", children: l.map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.name }, `lib-${n.id}`)) }),
|
|
260
|
+
c.length > 0 && /* @__PURE__ */ e("optgroup", { label: "Predefined Groups", children: c.filter((n) => !l.some((B) => B.id === n.id)).map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.name }, `local-${n.id}`)) })
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
/* @__PURE__ */ e(b, { type: "button", size: "icon", variant: "outline", onClick: () => t(!0), children: /* @__PURE__ */ e(pe, { className: "h-4 w-4" }) })
|
|
265
|
+
] });
|
|
266
|
+
}, Le = ({ value: r, onChange: a }) => {
|
|
267
|
+
const [o, t] = f(!1), u = V(null), p = be(
|
|
268
|
+
async (c) => {
|
|
269
|
+
var h;
|
|
270
|
+
const v = (h = c.target.files) == null ? void 0 : h[0];
|
|
271
|
+
if (v)
|
|
272
|
+
try {
|
|
273
|
+
t(!0);
|
|
274
|
+
let g = v;
|
|
275
|
+
v.type.startsWith("image/") && (g = await ve(v));
|
|
276
|
+
const m = new FileReader();
|
|
277
|
+
m.onloadend = () => {
|
|
278
|
+
a(m.result), t(!1);
|
|
279
|
+
}, m.readAsDataURL(g);
|
|
280
|
+
} catch (g) {
|
|
281
|
+
console.error("Error reading file:", g), t(!1), N.error("Failed to process image", {
|
|
282
|
+
description: g instanceof Error ? g.message : "Unknown error"
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
[a]
|
|
287
|
+
);
|
|
288
|
+
return /* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
289
|
+
/* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
290
|
+
/* @__PURE__ */ e(L, { type: "file", ref: u, onChange: p, accept: "image/*", className: "hidden" }),
|
|
291
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: () => {
|
|
292
|
+
var c;
|
|
293
|
+
(c = u.current) == null || c.click();
|
|
294
|
+
}, disabled: o, className: "w-full", children: o ? /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
|
|
295
|
+
/* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
296
|
+
"Uploading..."
|
|
297
|
+
] }) : /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
|
|
298
|
+
/* @__PURE__ */ e(he, { className: "h-4 w-4" }),
|
|
299
|
+
"Select image"
|
|
300
|
+
] }) }),
|
|
301
|
+
r && /* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "icon", onClick: () => {
|
|
302
|
+
a(""), u.current && (u.current.value = "");
|
|
303
|
+
}, children: /* @__PURE__ */ e(fe, { className: "h-4 w-4" }) })
|
|
304
|
+
] }),
|
|
305
|
+
r && /* @__PURE__ */ e("div", { className: "aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border", children: /* @__PURE__ */ e("img", { src: r, alt: "Preview", className: "h-full w-full object-contain" }) })
|
|
306
|
+
] });
|
|
307
|
+
}, qe = (r) => {
|
|
308
|
+
const { blocks: a, close: o, blockId: t } = r, { getPartailBlocks: u } = le(), p = a.find((s) => s._id === t), d = p == null ? void 0 : p._libBlockId, l = !!d, c = S(() => a.some((s) => s._type === "PartialBlock" || s._type === "GlobalBlock"), [a]), v = S(() => {
|
|
309
|
+
let s = [];
|
|
310
|
+
for (const y of a)
|
|
311
|
+
if (y._type === "PartialBlock" || y._type === "GlobalBlock") {
|
|
312
|
+
let k = u(y.partialBlockId);
|
|
313
|
+
y._parent && (k == null ? void 0 : k.length) > 0 && (k = k.map((R) => (ye(R._parent) && ke(R, "_parent", y._parent), R))), s = [...s, ...k];
|
|
314
|
+
} else
|
|
315
|
+
s.push(y);
|
|
316
|
+
return s;
|
|
317
|
+
}, [a, u]), [h, g] = f(""), [m, n] = f(""), [B, E] = f(""), [x, A] = f(""), [C, W] = f({}), [Q, $] = f(!1), [H, q] = f(l), [X, J] = f(!1), { hasPermission: Z } = ce(), ee = Z(ue.DELETE_LIBRARY_BLOCK), M = z(), te = () => {
|
|
318
|
+
M([t], { _libBlockId: void 0 }), N.success("Block delinked from library"), o();
|
|
319
|
+
}, {
|
|
320
|
+
data: I,
|
|
321
|
+
isLoading: F,
|
|
322
|
+
isError: O
|
|
323
|
+
} = Ce(d);
|
|
324
|
+
w(() => {
|
|
325
|
+
O && l && (J(!0), q(!1));
|
|
326
|
+
}, [O, l]), w(() => {
|
|
327
|
+
I && !F && (g(I.name || ""), n(I.group || ""), E(I.description || ""), A(I.preview || ""), q(!1));
|
|
328
|
+
}, [I, F]), w(() => {
|
|
329
|
+
const s = h.trim().length >= 2, y = m.trim() !== "";
|
|
330
|
+
$(s && y);
|
|
331
|
+
}, [h, m]);
|
|
332
|
+
const re = () => {
|
|
333
|
+
const s = {};
|
|
334
|
+
return h.trim() ? h.length < 2 && (s.name = "Name must be at least 2 characters") : s.name = "Name is required", m || (s.group = "Group is required"), W(s), Object.keys(s).length === 0;
|
|
335
|
+
}, { resetLibrary: ae } = de({ id: "" }), j = Be((s) => {
|
|
336
|
+
l || M([t], { _libBlockId: s.id }), N.success(`Block ${l ? "updated" : "saved"} successfully`), ae(s.library), o();
|
|
337
|
+
}), ne = async (s) => {
|
|
338
|
+
if (s.preventDefault(), !re()) return;
|
|
339
|
+
const y = v.map((k) => (Ne(k, "_libBlockId") && delete k._libBlockId, k));
|
|
340
|
+
j.mutate({
|
|
341
|
+
name: h.trim(),
|
|
342
|
+
group: m,
|
|
343
|
+
blocks: y,
|
|
344
|
+
description: B.trim(),
|
|
345
|
+
// Only include previewImage if it exists and is a base64 image
|
|
346
|
+
...x && x.startsWith("data:") ? { previewImage: x } : {},
|
|
347
|
+
// Include id if in edit mode
|
|
348
|
+
...l ? { id: d } : {}
|
|
349
|
+
});
|
|
350
|
+
}, T = j.isPending;
|
|
351
|
+
return H || F ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }) }) : X ? /* @__PURE__ */ i("div", { className: "space-y-4 p-6", children: [
|
|
352
|
+
/* @__PURE__ */ e("div", { className: "font-medium text-destructive", children: "Block Not Found" }),
|
|
353
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "This block could not be found on the server. It may have been deleted." }),
|
|
354
|
+
/* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-4", children: [
|
|
355
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, children: "Cancel" }),
|
|
356
|
+
/* @__PURE__ */ e(b, { onClick: te, variant: "destructive", children: "Delink Block" })
|
|
357
|
+
] })
|
|
358
|
+
] }) : /* @__PURE__ */ i("div", { children: [
|
|
359
|
+
c && /* @__PURE__ */ i("div", { className: "mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive", children: [
|
|
360
|
+
/* @__PURE__ */ e(ge, { className: "mt-0.5 h-5 w-5 flex-shrink-0" }),
|
|
361
|
+
/* @__PURE__ */ i("div", { children: [
|
|
362
|
+
/* @__PURE__ */ e("p", { className: "font-medium", children: "Partial Blocks Detected" }),
|
|
363
|
+
/* @__PURE__ */ e("p", { className: "mt-1 text-xs", children: "This block contains one or more Partial Blocks. Partial blocks will be merged into the library block" })
|
|
364
|
+
] })
|
|
365
|
+
] }),
|
|
366
|
+
/* @__PURE__ */ i("form", { onSubmit: ne, className: "space-y-4", children: [
|
|
367
|
+
/* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
368
|
+
/* @__PURE__ */ e(P, { htmlFor: "name", className: C.name ? "text-destructive" : "", children: "Name" }),
|
|
369
|
+
/* @__PURE__ */ e(
|
|
370
|
+
L,
|
|
371
|
+
{
|
|
372
|
+
id: "name",
|
|
373
|
+
placeholder: "Enter block name",
|
|
374
|
+
value: h,
|
|
375
|
+
onChange: (s) => g(s.target.value),
|
|
376
|
+
className: C.name ? "border-destructive" : ""
|
|
377
|
+
}
|
|
378
|
+
),
|
|
379
|
+
C.name && /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: C.name })
|
|
380
|
+
] }),
|
|
381
|
+
/* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
382
|
+
/* @__PURE__ */ e(P, { htmlFor: "group", className: C.group ? "text-destructive" : "", children: "Group" }),
|
|
383
|
+
/* @__PURE__ */ e(Pe, { value: m, onChange: n }),
|
|
384
|
+
C.group && /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: C.group })
|
|
385
|
+
] }),
|
|
386
|
+
/* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
387
|
+
/* @__PURE__ */ e(P, { htmlFor: "description", children: "Description (optional)" }),
|
|
388
|
+
/* @__PURE__ */ e(
|
|
389
|
+
L,
|
|
390
|
+
{
|
|
391
|
+
id: "description",
|
|
392
|
+
placeholder: "Enter a brief description",
|
|
393
|
+
className: "resize-none",
|
|
394
|
+
value: B,
|
|
395
|
+
onChange: (s) => E(s.target.value)
|
|
396
|
+
}
|
|
397
|
+
)
|
|
398
|
+
] }),
|
|
399
|
+
/* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
400
|
+
/* @__PURE__ */ e(P, { htmlFor: "previewImage", children: "Preview Image (optional)" }),
|
|
401
|
+
/* @__PURE__ */ e(Le, { value: x, onChange: A })
|
|
402
|
+
] }),
|
|
403
|
+
/* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-2", children: [
|
|
404
|
+
l && ee && /* @__PURE__ */ e(
|
|
405
|
+
Ee,
|
|
406
|
+
{
|
|
407
|
+
blockId: t,
|
|
408
|
+
libBlockId: d,
|
|
409
|
+
blockName: h,
|
|
410
|
+
className: "mr-auto",
|
|
411
|
+
close: o
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, disabled: T, children: "Cancel" }),
|
|
415
|
+
/* @__PURE__ */ e(b, { type: "submit", disabled: T || !Q, children: T ? "Saving..." : l ? "Update Block" : "Save Block" })
|
|
416
|
+
] })
|
|
417
|
+
] })
|
|
418
|
+
] });
|
|
419
|
+
};
|
|
420
|
+
export {
|
|
421
|
+
qe as default
|
|
422
|
+
};
|