@chaibuilder/sdk 4.0.0-beta.2 → 4.0.0-beta.4
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-C4VFVd-q.cjs → 2SSKDMRQ-CopJgtZb.cjs} +1 -1
- package/dist/{2SSKDMRQ-DSnzF_1o.js → 2SSKDMRQ-Difo_1pg.js} +2 -2
- package/dist/{AP7HFJJL-Cxwj01Aq.js → AP7HFJJL-BPuPBqj4.js} +1 -1
- package/dist/{AP7HFJJL-B7YYCY9q.cjs → AP7HFJJL-DYxDgaOs.cjs} +1 -1
- package/dist/{IconPicker-RqVvq6G2.js → IconPicker-B2-oriq2.js} +8 -7
- package/dist/IconPicker-C0oycHbs.cjs +1 -0
- package/dist/{WDYDFRGG-b3T2SQbz.cjs → WDYDFRGG-DbejaRPK.cjs} +1 -1
- package/dist/{WDYDFRGG-C7aSUcjs.js → WDYDFRGG-KK8pkcW1.js} +2 -2
- package/dist/{actions-registery-YnFmU21O.cjs → actions-registery-JdxhXhT6.cjs} +1 -1
- package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-y_ENc8zj.js} +2 -2
- package/dist/actions.cjs +1 -1
- package/dist/actions.js +2 -2
- package/dist/active-in-another-tab-Cu_ASKtx.cjs +1 -0
- package/dist/active-in-another-tab-DkR2HWI4.js +35 -0
- package/dist/add-new-language-page-BXuwluuU.cjs +1 -0
- package/dist/{add-new-language-page-D7NDABl1.js → add-new-language-page-CBY0RR6q.js} +54 -53
- package/dist/{add-new-page-BNfwKjRd.cjs → add-new-page-C_PzKby8.cjs} +1 -1
- package/dist/{add-new-page-B4hc0B-g.js → add-new-page-DJLJFLAd.js} +2 -2
- package/dist/{ai-panel-content-BnbURb7j.js → ai-panel-content--YM01Aly.js} +12 -11
- package/dist/ai-panel-content-rRmJdH7L.cjs +1 -0
- package/dist/{ai-panel-default-lang-oVk4TDeb.js → ai-panel-default-lang-BZl0tPYo.js} +40 -40
- package/dist/{ai-panel-default-lang-3tCHzab5.cjs → ai-panel-default-lang-D2zhXvKP.cjs} +2 -2
- package/dist/{ai-panel-other-lang-DmQ3QMDD.js → ai-panel-other-lang-Bfjk2CYZ.js} +8 -8
- package/dist/{ai-panel-other-lang-BBHCCSen.cjs → ai-panel-other-lang-Y4bEKHoG.cjs} +1 -1
- package/dist/{ai-prompt-input-DaTyfib-.js → ai-prompt-input-DueQYNf-.js} +68 -67
- package/dist/ai-prompt-input-N9PcYCFa.cjs +1 -0
- package/dist/{ai-translation-prompt-DJPe2O-n.js → ai-translation-prompt-B36F3d7K.js} +2 -2
- package/dist/ai-translation-prompt-IAdWMNZb.cjs +1 -0
- package/dist/{apply-binding-6iwlED02.js → apply-binding-BvWfJCSZ.js} +204 -196
- package/dist/apply-binding-IsUf6UWJ.cjs +1 -0
- package/dist/{code-display-BzBq5xSn.js → code-display-Ck81Id9K.js} +1 -1
- package/dist/code-display-DloSPyPr.cjs +1 -0
- package/dist/{code-editor-DWWnphW9.js → code-editor-Bb7JumZy.js} +11 -10
- package/dist/code-editor-DQB8lAOk.cjs +1 -0
- package/dist/{continue-editing-in-this-client-BllU94XG.js → continue-editing-in-this-client-Dm9cCj7K.js} +10 -9
- package/dist/continue-editing-in-this-client-DmGFLHXw.cjs +1 -0
- package/dist/core-Dr7QYemB.js +56 -0
- package/dist/core-Y0lXLwkq.cjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +3 -3
- package/dist/core.js +41 -39
- package/dist/{css-import-modal-D72a-16X.js → css-import-modal-9P_0uNa4.js} +4 -3
- package/dist/css-import-modal-Rh1QAVxo.cjs +13 -0
- package/dist/{delete-design-token-D_TLlO3I.cjs → delete-design-token-BG8yHcS5.cjs} +1 -1
- package/dist/{delete-design-token-Cd1ZDtqT.js → delete-design-token-COvR4G1S.js} +1 -1
- package/dist/{delete-page-DC8pzvWW.js → delete-page-CNucxe4P.js} +11 -10
- package/dist/delete-page-DAvEjHwF.cjs +1 -0
- package/dist/design-token-usage-CXglXgcJ.cjs +1 -0
- package/dist/{design-token-usage-DE4XCDdn.js → design-token-usage-MNYsFlPG.js} +14 -13
- package/dist/digital-asset-manager-CB5MRBcW.cjs +1 -0
- package/dist/{digital-asset-manager-C_gL_0YY.js → digital-asset-manager-CqCWBO0s.js} +6 -5
- package/dist/{duplicate-page-BoVhko2q.js → duplicate-page-BknLfqr0.js} +19 -18
- package/dist/duplicate-page-DzZByALW.cjs +1 -0
- package/dist/{dynamic-page-selector-CSndg2-y.js → dynamic-page-selector-DoW7OyUB.js} +15 -14
- package/dist/dynamic-page-selector-WA007Sni.cjs +1 -0
- package/dist/get-chai-builder-tailwind-config-BFePCEIS.cjs +1 -0
- package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-BXf_xLHk.js} +5 -5
- package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-BApShjRz.cjs} +1 -1
- package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-DDVRJQ6Z.js} +1 -1
- package/dist/{image-editor-oypq8asR.js → image-editor-CQnNtak2.js} +1 -1
- package/dist/{image-editor-DTspjj_c.cjs → image-editor-CqwaVxO2.cjs} +1 -1
- package/dist/index-C0-pgg_p.cjs +5 -0
- package/dist/index-C99FhuF1.cjs +160 -0
- package/dist/{index-BDnwJqMw.js → index-Dno42B0a.js} +716 -714
- package/dist/{index-S8ibZk9Q.js → index-rAcNbjk_.js} +3744 -3920
- package/dist/{json-diff-viewer-XX1pgabt.cjs → json-diff-viewer-CLuUHiPU.cjs} +3 -3
- package/dist/{json-diff-viewer-B5dr-Y_L.js → json-diff-viewer-CMvGUvJ2.js} +5 -4
- package/dist/{lang-panel-Cn83SRzd.js → lang-panel-CnwTb05j.js} +15 -14
- package/dist/lang-panel-fDCYm5Jm.cjs +1 -0
- package/dist/{manage-design-tokens-lP4HLS0P.js → manage-design-tokens-BsSZE9Vs.js} +12 -11
- package/dist/manage-design-tokens-BvH5KTJX.cjs +1 -0
- package/dist/mark-as-template-CpWEBJGd.cjs +1 -0
- package/dist/{mark-as-template-jncsjfHm.js → mark-as-template-DBLshWb5.js} +17 -16
- package/dist/{nested-path-selector-content-B-8LqhXI.js → nested-path-selector-content-6OBJ8LG8.js} +24 -23
- package/dist/nested-path-selector-content-C2sD9dkq.cjs +1 -0
- package/dist/no-language-page-content-BvPDdccK.cjs +1 -0
- package/dist/{no-language-page-content-D_zd9Rb0.js → no-language-page-content-CzENgtnu.js} +10 -9
- package/dist/{no-language-page-dialog-C5Ps6YYL.js → no-language-page-dialog-CbYI2cVg.js} +2 -2
- package/dist/{no-language-page-dialog-fXmbQO7L.cjs → no-language-page-dialog-CgW4yJBC.cjs} +1 -1
- package/dist/{page-creator-wCMtlE6Z.js → page-creator-Cc83uQqw.js} +113 -112
- package/dist/page-creator-g8GqgcKH.cjs +1 -0
- package/dist/{page-lock-BPCxfv9J.js → page-lock-BJUkyxdh.js} +2 -2
- package/dist/{page-lock-DweiYy1w.cjs → page-lock-CT7SmQqp.cjs} +1 -1
- package/dist/page-locked-dialog-Co5b9XIZ.cjs +1 -0
- package/dist/{page-locked-dialog-ByGl18_m.js → page-locked-dialog-DsEbWRed.js} +18 -15
- package/dist/{page-manager-new-BWFE-S-O.js → page-manager-new-5rFP5DyQ.js} +30 -29
- package/dist/page-manager-new-BOkJImo2.cjs +1 -0
- package/dist/page-manager-search-and-filter-Bfm0j1gg.cjs +1 -0
- package/dist/{page-manager-search-and-filter-kNJFWJ86.js → page-manager-search-and-filter-zq-LfhQ1.js} +13 -12
- package/dist/{page-revisions-content-Ulr8slUN.js → page-revisions-content-D38G2tJM.js} +34 -31
- package/dist/page-revisions-content-ag-MHBGr.cjs +1 -0
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +22 -23
- package/dist/pages.js +12 -12
- package/dist/{plugin-C6rgJDNQ.cjs → plugin-BGlQf0iy.cjs} +1 -1
- package/dist/{plugin-3ZKK6RXm.js → plugin-C-ht41UZ.js} +1 -1
- package/dist/publish-pages-content-BiX-GMLw.cjs +1 -0
- package/dist/{publish-pages-content-BTPzt_m4.js → publish-pages-content-CS7f41Ac.js} +66 -65
- package/dist/register-chai-top-bar-BqwKw4uy.cjs +1 -0
- package/dist/register-chai-top-bar-ESJHs5s-.js +237 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +2 -2
- package/dist/render.js +87 -80
- package/dist/rte-widget-modal-BKNx2wln.cjs +1 -0
- package/dist/{rte-widget-modal-Rk_NW3KU.js → rte-widget-modal-D6Zik0Ta.js} +15 -14
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +168 -4
- package/dist/runtime.js +68 -38
- package/dist/{save-to-lib-BK3uTFss.js → save-to-lib-WwOzbgiF.js} +39 -38
- package/dist/save-to-lib-ffjCZYJ5.cjs +1 -0
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-CU3TwIMA.js → selected-block-display-B1SG_UXw.js} +37 -36
- package/dist/selected-block-display-BOgnQRLF.cjs +16 -0
- package/dist/{seo-panel-jbzxFioc.js → seo-panel-BkOgRoWd.js} +12 -11
- package/dist/seo-panel-FjS1UF_y.cjs +2 -0
- package/dist/{shared-json-ld-BL_dv3_q.js → shared-json-ld-uka9TOgA.js} +68 -67
- package/dist/shared-json-ld-yJkXjENy.cjs +1 -0
- package/dist/slug-input-Cyd6NR6J.cjs +1 -0
- package/dist/{slug-input-1qwKkXhA.js → slug-input-DHLmUNrH.js} +9 -8
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +1 -1
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-DKvKi3mM.js → take-over-request-Ca0X-qyf.js} +17 -16
- package/dist/take-over-request-CmpJVe9T.cjs +1 -0
- package/dist/{theme-panel-footer-DbMDLYGI.js → theme-panel-footer-BUXIu252.js} +11 -10
- package/dist/theme-panel-footer-CKO9YYwZ.cjs +1 -0
- package/dist/{translation-warning-modal-9wTwIy_9.js → translation-warning-modal-DrpFeI83.js} +9 -8
- package/dist/translation-warning-modal-pSZVKcNW.cjs +1 -0
- package/dist/{unmark-as-template-Dulvf7Zw.js → unmark-as-template-BMqgelv-.js} +11 -10
- package/dist/unmark-as-template-DF1Ms4VN.cjs +1 -0
- package/dist/unpublish-page-BJ0Bsvt2.js +28 -0
- package/dist/unpublish-page-Bsq2yEqQ.cjs +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +4 -1
- package/dist/utils.js +2 -2
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +5 -5
- package/dist/{web-preview-DXE4Jnf5.js → web-preview-D6h1L2nV.js} +2 -2
- package/dist/web-preview-kres0aG7.cjs +1 -0
- package/package.json +4 -2
- package/dist/IconPicker-C9-ieDWm.cjs +0 -1
- package/dist/active-in-another-tab-Clng6zpY.cjs +0 -1
- package/dist/active-in-another-tab-wb8qolB8.js +0 -34
- package/dist/add-new-language-page-C4BuMTaN.cjs +0 -1
- package/dist/ai-panel-content-DPy2jgKw.cjs +0 -1
- package/dist/ai-prompt-input-b5ty81RB.cjs +0 -1
- package/dist/ai-translation-prompt-c0Q3zkT2.cjs +0 -1
- package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
- package/dist/code-display-Q3_sK_Ta.cjs +0 -1
- package/dist/code-editor-BQZi6-FB.cjs +0 -1
- package/dist/continue-editing-in-this-client-D9HyD4GP.cjs +0 -1
- package/dist/core-BoRDjj4h.cjs +0 -1
- package/dist/core-yvI6kCyw.js +0 -56
- package/dist/css-import-modal-BSMGKA2T.cjs +0 -13
- package/dist/delete-page-ByQwBupJ.cjs +0 -1
- package/dist/design-token-usage-BqZeR1sT.cjs +0 -1
- package/dist/digital-asset-manager-BYLKFEYi.cjs +0 -1
- package/dist/duplicate-page-vdvwLQLo.cjs +0 -1
- package/dist/dynamic-page-selector-DdnbCuQZ.cjs +0 -1
- package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
- package/dist/index-CbwxUFy_.cjs +0 -5
- package/dist/index-CnSjWE1P.cjs +0 -160
- package/dist/lang-panel-BPxex-M2.cjs +0 -1
- package/dist/manage-design-tokens-ConiyuPr.cjs +0 -1
- package/dist/mark-as-template-DYRxre1f.cjs +0 -1
- package/dist/nested-path-selector-content-BYtLi7mC.cjs +0 -1
- package/dist/no-language-page-content-DAbLq0gX.cjs +0 -1
- package/dist/page-creator-VWIB2VAs.cjs +0 -1
- package/dist/page-locked-dialog-BlbgvaG2.cjs +0 -1
- package/dist/page-manager-new-D0lGfNnS.cjs +0 -1
- package/dist/page-manager-search-and-filter-DpGMoOII.cjs +0 -1
- package/dist/page-revisions-content-DYxXZqmh.cjs +0 -1
- package/dist/publish-pages-content-D6g8GAsd.cjs +0 -1
- package/dist/rte-widget-modal-DrMzWWjw.cjs +0 -1
- package/dist/save-to-lib-DHHUO12i.cjs +0 -1
- package/dist/selected-block-display-DSFhddPj.cjs +0 -16
- package/dist/seo-panel-Dl0IDV09.cjs +0 -2
- package/dist/shared-json-ld-DPNkqDC1.cjs +0 -1
- package/dist/slug-input-YVLjtTI3.cjs +0 -1
- package/dist/take-over-request-DvMIg_cZ.cjs +0 -1
- package/dist/theme-panel-footer-BMOaPLWc.cjs +0 -1
- package/dist/translation-warning-modal-DjTwz75c.cjs +0 -1
- package/dist/unmark-as-template-CdqIJJER.cjs +0 -1
- package/dist/unpublish-page-BwSVBf0_.cjs +0 -1
- package/dist/unpublish-page-Degu5Cy9.js +0 -27
- package/dist/web-preview-YzKxyXft.cjs +0 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -1,15 +1,36 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
1
2
|
import { default as default_2 } from 'react';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
2
4
|
import { RJSFSchema } from '@rjsf/utils';
|
|
3
5
|
import { UiSchema } from '@rjsf/utils';
|
|
4
6
|
|
|
7
|
+
export declare const ADD_BLOCK_TABS: Record<string, AddBlockTab>;
|
|
8
|
+
|
|
9
|
+
export declare type AddBlockTab = {
|
|
10
|
+
id: string;
|
|
11
|
+
tab: React.ComponentType;
|
|
12
|
+
tabContent: React.ComponentType;
|
|
13
|
+
};
|
|
14
|
+
|
|
5
15
|
export declare const builderProp: (options: ChaiBlockPropSchema) => ChaiBlockPropSchema;
|
|
6
16
|
|
|
17
|
+
export declare const CHAI_BUILDER_PANELS: Record<string, ChaiSidebarPanel>;
|
|
18
|
+
|
|
7
19
|
export declare let CHAI_GLOBAL_DATA_PROVIDER: (args: {
|
|
8
20
|
lang: string;
|
|
9
21
|
draft: boolean;
|
|
10
22
|
inBuilder: boolean;
|
|
11
23
|
}) => Promise<any>;
|
|
12
24
|
|
|
25
|
+
declare type ChaiAsset = {
|
|
26
|
+
url: string;
|
|
27
|
+
id?: string;
|
|
28
|
+
thumbnailUrl?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
width?: number;
|
|
31
|
+
height?: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
13
34
|
export declare type ChaiAsyncProp<T> = T | undefined;
|
|
14
35
|
|
|
15
36
|
export declare type ChaiBlock<BlockProps = Record<string, any>> = {
|
|
@@ -19,6 +40,23 @@ export declare type ChaiBlock<BlockProps = Record<string, any>> = {
|
|
|
19
40
|
_parent?: string | null;
|
|
20
41
|
} & BlockProps;
|
|
21
42
|
|
|
43
|
+
declare type ChaiBlock_2<T = Record<string, any>> = {
|
|
44
|
+
_id: string;
|
|
45
|
+
_name?: string;
|
|
46
|
+
_parent?: string | null | undefined;
|
|
47
|
+
_libBlock?: string;
|
|
48
|
+
_type: string;
|
|
49
|
+
partialBlockId?: string;
|
|
50
|
+
} & T;
|
|
51
|
+
|
|
52
|
+
declare type ChaiBlock_3<T = Record<string, any>> = {
|
|
53
|
+
_id: string;
|
|
54
|
+
_name?: string;
|
|
55
|
+
_parent?: string | null | undefined;
|
|
56
|
+
_type: string;
|
|
57
|
+
_libBlock?: string;
|
|
58
|
+
} & T;
|
|
59
|
+
|
|
22
60
|
export declare type ChaiBlockComponentProps<BlockProps, PageData = Record<string, unknown>> = ChaiBlock<BlockProps> & {
|
|
23
61
|
$loading?: boolean;
|
|
24
62
|
blockProps: Record<string, string>;
|
|
@@ -131,6 +169,12 @@ declare type ChaiDynamicPage = {
|
|
|
131
169
|
primaryPage?: string;
|
|
132
170
|
};
|
|
133
171
|
|
|
172
|
+
declare type ChaiFlagOptions = {
|
|
173
|
+
key: string;
|
|
174
|
+
value?: any;
|
|
175
|
+
description?: string;
|
|
176
|
+
};
|
|
177
|
+
|
|
134
178
|
export declare type ChaiFont = ChaiFontViaUrl | ChaiFontViaSrc;
|
|
135
179
|
|
|
136
180
|
export declare type ChaiFontViaSrc = {
|
|
@@ -152,6 +196,33 @@ export declare type ChaiFontViaUrl = {
|
|
|
152
196
|
fallback: string;
|
|
153
197
|
};
|
|
154
198
|
|
|
199
|
+
declare type ChaiLibrary<T = Record<string, any>> = {
|
|
200
|
+
id: string;
|
|
201
|
+
name: string;
|
|
202
|
+
blocks?: ChaiLibraryBlock[];
|
|
203
|
+
description?: string;
|
|
204
|
+
} & T;
|
|
205
|
+
|
|
206
|
+
declare type ChaiLibraryBlock<T = Record<string, any>> = {
|
|
207
|
+
id: string;
|
|
208
|
+
group: string;
|
|
209
|
+
name: string;
|
|
210
|
+
preview?: string;
|
|
211
|
+
tags?: string[];
|
|
212
|
+
description?: string;
|
|
213
|
+
} & T;
|
|
214
|
+
|
|
215
|
+
declare type ChaiLibraryConfig<T> = {
|
|
216
|
+
id: string;
|
|
217
|
+
name: string;
|
|
218
|
+
description: string;
|
|
219
|
+
getBlocksList: (library: ChaiLibrary) => Promise<ChaiLibraryBlock<T>[]>;
|
|
220
|
+
getBlock: ({ library, block, }: {
|
|
221
|
+
library: ChaiLibrary;
|
|
222
|
+
block: ChaiLibraryBlock<T>;
|
|
223
|
+
}) => Promise<HTMLString | ChaiBlock_2[]>;
|
|
224
|
+
};
|
|
225
|
+
|
|
155
226
|
export declare interface ChaiPageProps {
|
|
156
227
|
slug: string;
|
|
157
228
|
searchParams?: Record<string, string>;
|
|
@@ -173,6 +244,23 @@ export declare interface ChaiServerBlockDefinition<T = Record<string, any>, K =
|
|
|
173
244
|
suspenseFallback?: default_2.ComponentType<any>;
|
|
174
245
|
}
|
|
175
246
|
|
|
247
|
+
export declare interface ChaiSidebarPanel {
|
|
248
|
+
id: string;
|
|
249
|
+
position: "top" | "bottom";
|
|
250
|
+
view?: "standard" | "modal" | "overlay" | "drawer";
|
|
251
|
+
button: React.ComponentType<{
|
|
252
|
+
isActive: boolean;
|
|
253
|
+
show: () => void;
|
|
254
|
+
panelId: string;
|
|
255
|
+
position: "top" | "bottom";
|
|
256
|
+
}>;
|
|
257
|
+
label: string;
|
|
258
|
+
panel?: ComponentType;
|
|
259
|
+
width?: number;
|
|
260
|
+
isInternal?: boolean;
|
|
261
|
+
icon?: React.ReactNode;
|
|
262
|
+
}
|
|
263
|
+
|
|
176
264
|
export declare type ChaiStyles = {
|
|
177
265
|
[key: string]: string;
|
|
178
266
|
};
|
|
@@ -213,7 +301,7 @@ export declare const COLLECTIONS: Record<string, CollectionConfig<any>>;
|
|
|
213
301
|
|
|
214
302
|
export declare const defaultChaiStyles: (classes: string) => string;
|
|
215
303
|
|
|
216
|
-
export declare const getAIBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) =>
|
|
304
|
+
export declare const getAIBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => ChaiBlockDefinition<Record<string, any>, Record<string, any>> | ChaiServerBlockDefinition<Record<string, any>, Record<string, any>> | never[];
|
|
217
305
|
|
|
218
306
|
export declare const getAllRegisteredFonts: () => ChaiFont[];
|
|
219
307
|
|
|
@@ -232,17 +320,35 @@ export declare const getChaiGlobalData: (args: {
|
|
|
232
320
|
inBuilder: boolean;
|
|
233
321
|
}) => Promise<any>;
|
|
234
322
|
|
|
323
|
+
export declare const getChaiLibrary: (id: string) => ChaiLibraryConfig<any>;
|
|
324
|
+
|
|
235
325
|
export declare const getChaiPageType: (key: keyof typeof PAGE_TYPES) => ChaiBuilderPageType;
|
|
236
326
|
|
|
237
327
|
export declare const getChaiPageTypes: () => ChaiBuilderPageType[];
|
|
238
328
|
|
|
239
329
|
export declare const getDefaultBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => Record<string, any>;
|
|
240
330
|
|
|
241
|
-
export declare const getI18nBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) =>
|
|
331
|
+
export declare const getI18nBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => ChaiBlockDefinition<Record<string, any>, Record<string, any>> | ChaiServerBlockDefinition<Record<string, any>, Record<string, any>> | never[];
|
|
332
|
+
|
|
333
|
+
export declare const getPreImportHTML: (code: string) => Promise<string>;
|
|
242
334
|
|
|
243
335
|
export declare const getRegisteredChaiBlock: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => ChaiBlockDefinition | null;
|
|
244
336
|
|
|
245
|
-
export declare const getRegisteredFont: (family: string) => ChaiFont;
|
|
337
|
+
export declare const getRegisteredFont: (family: string) => ChaiFont | undefined;
|
|
338
|
+
|
|
339
|
+
declare type HTMLString = string;
|
|
340
|
+
|
|
341
|
+
export declare const IfChaiFeatureFlag: ({ flagKey, children }: {
|
|
342
|
+
flagKey: string;
|
|
343
|
+
children: React.ReactNode;
|
|
344
|
+
}) => ReactNode;
|
|
345
|
+
|
|
346
|
+
export declare type MediaManagerProps = {
|
|
347
|
+
assetId?: string;
|
|
348
|
+
close: () => void;
|
|
349
|
+
onSelect: (assets: ChaiAsset | ChaiAsset[]) => void;
|
|
350
|
+
mode?: "image" | "video" | "audio";
|
|
351
|
+
};
|
|
246
352
|
|
|
247
353
|
export declare const PAGE_TYPES: Record<string, ChaiBuilderPageType>;
|
|
248
354
|
|
|
@@ -252,12 +358,24 @@ declare type PageTypeSearchResult = {
|
|
|
252
358
|
slug?: string;
|
|
253
359
|
};
|
|
254
360
|
|
|
361
|
+
export declare const registerBlockSettingField: (id: string, component: React.ComponentType<any>) => void;
|
|
362
|
+
|
|
363
|
+
export declare const registerBlockSettingTemplate: (id: string, component: React.ComponentType<any>) => void;
|
|
364
|
+
|
|
365
|
+
export declare const registerBlockSettingWidget: (id: string, component: React.ComponentType<any>) => void;
|
|
366
|
+
|
|
367
|
+
export declare const registerChaiAddBlockTab: (id: string, tab: Omit<AddBlockTab, "id">) => void;
|
|
368
|
+
|
|
255
369
|
export declare const registerChaiBlock: <T extends Record<string, any> = Record<string, any>, K extends Record<string, any> = Record<string, any>>(component: default_2.ComponentType<ChaiBlockComponentProps<T>>, options: ChaiBlockDefinitionOptions<T, K>) => void;
|
|
256
370
|
|
|
257
371
|
export declare const registerChaiBlockSchema: (blockSchema: ChaiBlockSchema) => ChaiBlockSchemas;
|
|
258
372
|
|
|
259
373
|
export declare function registerChaiCollection<T = Record<any, any>>(id: string, collection: Omit<CollectionConfig<T>, "id">): void;
|
|
260
374
|
|
|
375
|
+
export declare const registerChaiFeatureFlag: (key: string, flagOptions: Omit<ChaiFlagOptions, "key">) => void;
|
|
376
|
+
|
|
377
|
+
export declare const registerChaiFeatureFlags: (flags: Record<string, Omit<ChaiFlagOptions, "key">>) => void;
|
|
378
|
+
|
|
261
379
|
export declare const registerChaiFont: (family: string, font: Omit<ChaiFont, "family">) => void;
|
|
262
380
|
|
|
263
381
|
export declare const registerChaiGlobalDataProvider: <T>(globalDataProvider: (args: {
|
|
@@ -266,16 +384,42 @@ export declare const registerChaiGlobalDataProvider: <T>(globalDataProvider: (ar
|
|
|
266
384
|
inBuilder: boolean;
|
|
267
385
|
}) => Promise<T>) => void;
|
|
268
386
|
|
|
387
|
+
export declare const registerChaiLibrary: <T extends Record<string, any> = Record<string, any>>(id: string, library: Omit<ChaiLibraryConfig<T>, "id">) => void;
|
|
388
|
+
|
|
389
|
+
export declare const registerChaiMediaManager: (component: React.ComponentType<MediaManagerProps>) => void;
|
|
390
|
+
|
|
269
391
|
export declare const registerChaiPageType: (key: string, pageTypeOptions: Omit<ChaiBuilderPageType, "key" | "hasSlug">) => void;
|
|
270
392
|
|
|
271
393
|
export declare const registerChaiPartialType: (key: string, pageTypeOptions: Omit<ChaiBuilderPageType, "key">) => void;
|
|
272
394
|
|
|
395
|
+
export declare const registerChaiPreImportHTMLHook: (fn: (code: string) => Promise<string>) => void;
|
|
396
|
+
|
|
397
|
+
export declare const registerChaiSaveToLibrary: (component: ComponentType<SaveToLibraryProps>) => void;
|
|
398
|
+
|
|
273
399
|
export declare const registerChaiServerBlock: <T extends Record<string, any> = Record<string, any>, K extends Record<string, any> = Record<string, any>>(component: default_2.ComponentType<ChaiBlockComponentProps<T>>, options: Pick<ChaiBlockDefinition<T, K>, "type" | "dataProvider" | "i18nProps" | "aiProps">) => void;
|
|
274
400
|
|
|
401
|
+
export declare const registerChaiSidebarPanel: (panelId: string, panelOptions: Omit<ChaiSidebarPanel, "id">) => void;
|
|
402
|
+
|
|
403
|
+
export declare const registerChaiTopBar: (component: React.ComponentType) => void;
|
|
404
|
+
|
|
275
405
|
declare const REGISTERED_CHAI_BLOCKS: Record<string, ChaiBlockDefinition | ChaiServerBlockDefinition>;
|
|
276
406
|
|
|
407
|
+
export declare const resetSaveToLibrary: () => void;
|
|
408
|
+
|
|
409
|
+
export declare const RJSF_EXTENSIONS: Record<string, {
|
|
410
|
+
id: string;
|
|
411
|
+
component: React.ComponentType<any>;
|
|
412
|
+
type: string;
|
|
413
|
+
}>;
|
|
414
|
+
|
|
277
415
|
export declare const runtimeProp: (options: ChaiBlockPropSchema) => ChaiBlockPropSchema;
|
|
278
416
|
|
|
417
|
+
export declare type SaveToLibraryProps = {
|
|
418
|
+
blockId: string;
|
|
419
|
+
blocks: ChaiBlock_3[];
|
|
420
|
+
close: () => void;
|
|
421
|
+
};
|
|
422
|
+
|
|
279
423
|
export declare const setChaiBlockComponent: <T extends Record<string, any> = Record<string, any>>(type: keyof typeof REGISTERED_CHAI_BLOCKS, component: default_2.ComponentType<ChaiBlockComponentProps<T>>) => void;
|
|
280
424
|
|
|
281
425
|
export declare const setChaiBlockDataProvider: <K extends Record<string, any> = Record<string, any>>(type: string, dataProvider: (args: {
|
|
@@ -300,10 +444,30 @@ export declare const stylesProp: (defaultClasses?: string) => ChaiBlockPropSchem
|
|
|
300
444
|
|
|
301
445
|
export declare const syncBlocksWithDefaults: (blocks: ChaiBlock[]) => ChaiBlock[];
|
|
302
446
|
|
|
303
|
-
export declare const
|
|
447
|
+
export declare const useBlockSettingComponents: (type: "widget" | "field" | "template") => Record<string, React.ComponentType<any>>;
|
|
448
|
+
|
|
449
|
+
export declare const useChaiAddBlockTabs: () => AddBlockTab[];
|
|
450
|
+
|
|
451
|
+
export declare const useChaiFeatureFlag: (flagKey: string) => boolean;
|
|
452
|
+
|
|
453
|
+
export declare const useChaiFeatureFlags: () => Record<string, ChaiFlagOptions>;
|
|
454
|
+
|
|
455
|
+
export declare const useChaiLibraries: () => ChaiLibraryConfig<any>[];
|
|
456
|
+
|
|
457
|
+
export declare const useChaiSidebarPanels: (position: "top" | "bottom") => ChaiSidebarPanel[];
|
|
458
|
+
|
|
459
|
+
export declare const useMediaManagerComponent: () => ComponentType<MediaManagerProps>;
|
|
460
|
+
|
|
461
|
+
export declare const useRegisteredChaiBlock: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => ChaiBlockDefinition<Record<string, any>, Record<string, any>> | ChaiServerBlockDefinition<Record<string, any>, Record<string, any>> | null;
|
|
304
462
|
|
|
305
463
|
export declare const useRegisteredChaiBlocks: () => Record<string, ChaiBlockDefinition<Record<string, any>, Record<string, any>> | ChaiServerBlockDefinition<Record<string, any>, Record<string, any>>>;
|
|
306
464
|
|
|
307
465
|
export declare const useRegisteredFonts: () => ChaiFont[];
|
|
308
466
|
|
|
467
|
+
export declare const useSaveToLibraryComponent: () => ComponentType<SaveToLibraryProps> | null;
|
|
468
|
+
|
|
469
|
+
export declare const useToggleChaiFeatureFlag: (flagKey: string) => () => void;
|
|
470
|
+
|
|
471
|
+
export declare const useTopBarComponent: () => ComponentType< {}>;
|
|
472
|
+
|
|
309
473
|
export { }
|
package/dist/runtime.js
CHANGED
|
@@ -1,44 +1,74 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { S as i, b as o, d as g, r as l, a as C, s as h } from "./index-Dxfyt4d4.js";
|
|
2
|
+
import { A as n, C as p, I as u, R as B, k as d, o as P, a as k, b as S, r as m, c as T, e as F, f as b, j as L, m as y, p as A, q as f, v as I, x as D, t as R, u as v, d as _, h as E, g as x, l as M, w as O, n as H, s as G, i as N, y as j } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
+
import { b as q, C as w, P as J, a as K, g as U, d as V, f as X, e as Y, r as z, c as Q, h as Z, i as $ } from "./register-partial-type-BjtdfKHE.js";
|
|
4
|
+
import { a as ae, g as se, r as re, u as te } from "./fonts-DRly3Wzd.js";
|
|
5
|
+
import { s as e } from "./core-Dr7QYemB.js";
|
|
6
|
+
import { c as oe, g as ge, a as le, b as Ce, d as he, e as ce, r as ne, f as pe, h as ue, i as Be, u as de, j as Pe } from "./core-Dr7QYemB.js";
|
|
6
7
|
const s = e;
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
9
|
+
n as ADD_BLOCK_TABS,
|
|
10
|
+
p as CHAI_BUILDER_PANELS,
|
|
11
|
+
q as CHAI_GLOBAL_DATA_PROVIDER,
|
|
12
|
+
w as COLLECTIONS,
|
|
13
|
+
u as IfChaiFeatureFlag,
|
|
14
|
+
J as PAGE_TYPES,
|
|
15
|
+
B as RJSF_EXTENSIONS,
|
|
16
|
+
i as StylesProp,
|
|
17
|
+
o as builderProp,
|
|
18
|
+
oe as closestBlockProp,
|
|
19
|
+
g as defaultChaiStyles,
|
|
20
|
+
ge as getAIBlockProps,
|
|
21
|
+
ae as getAllRegisteredFonts,
|
|
22
|
+
le as getBlockFormSchemas,
|
|
23
|
+
K as getChaiCollection,
|
|
24
|
+
U as getChaiCollections,
|
|
25
|
+
V as getChaiGlobalData,
|
|
26
|
+
d as getChaiLibrary,
|
|
27
|
+
X as getChaiPageType,
|
|
28
|
+
Y as getChaiPageTypes,
|
|
29
|
+
Ce as getDefaultBlockProps,
|
|
30
|
+
he as getI18nBlockProps,
|
|
31
|
+
P as getPreImportHTML,
|
|
32
|
+
ce as getRegisteredChaiBlock,
|
|
33
|
+
se as getRegisteredFont,
|
|
34
|
+
k as registerBlockSettingField,
|
|
35
|
+
S as registerBlockSettingTemplate,
|
|
36
|
+
m as registerBlockSettingWidget,
|
|
37
|
+
T as registerChaiAddBlockTab,
|
|
38
|
+
ne as registerChaiBlock,
|
|
39
|
+
l as registerChaiBlockSchema,
|
|
40
|
+
z as registerChaiCollection,
|
|
41
|
+
F as registerChaiFeatureFlag,
|
|
42
|
+
b as registerChaiFeatureFlags,
|
|
43
|
+
re as registerChaiFont,
|
|
44
|
+
Q as registerChaiGlobalDataProvider,
|
|
45
|
+
L as registerChaiLibrary,
|
|
46
|
+
y as registerChaiMediaManager,
|
|
47
|
+
Z as registerChaiPageType,
|
|
48
|
+
$ as registerChaiPartialType,
|
|
49
|
+
A as registerChaiPreImportHTMLHook,
|
|
50
|
+
f as registerChaiSaveToLibrary,
|
|
51
|
+
pe as registerChaiServerBlock,
|
|
52
|
+
I as registerChaiSidebarPanel,
|
|
53
|
+
D as registerChaiTopBar,
|
|
54
|
+
R as resetSaveToLibrary,
|
|
35
55
|
C as runtimeProp,
|
|
36
|
-
|
|
56
|
+
ue as setChaiBlockComponent,
|
|
37
57
|
s as setChaiBlockDataProvider,
|
|
38
58
|
e as setChaiServerBlockDataProvider,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
h as stylesProp,
|
|
60
|
+
Be as syncBlocksWithDefaults,
|
|
61
|
+
v as useBlockSettingComponents,
|
|
62
|
+
_ as useChaiAddBlockTabs,
|
|
63
|
+
E as useChaiFeatureFlag,
|
|
64
|
+
x as useChaiFeatureFlags,
|
|
65
|
+
M as useChaiLibraries,
|
|
66
|
+
O as useChaiSidebarPanels,
|
|
67
|
+
H as useMediaManagerComponent,
|
|
68
|
+
de as useRegisteredChaiBlock,
|
|
69
|
+
Pe as useRegisteredChaiBlocks,
|
|
70
|
+
te as useRegisteredFonts,
|
|
71
|
+
G as useSaveToLibraryComponent,
|
|
72
|
+
N as useToggleChaiFeatureFlag,
|
|
73
|
+
j as useTopBarComponent
|
|
44
74
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
2
|
-
import { B as b,
|
|
3
|
-
import {
|
|
2
|
+
import { B as b, z as L } from "./register-chai-top-bar-ESJHs5s-.js";
|
|
3
|
+
import { c as j, a6 as se, a7 as ie, P as oe, az as le, ai as ce, aA as de, L as P } from "./index-rAcNbjk_.js";
|
|
4
|
+
import { ar as D, as as G, A as _, ay as ue } from "./index-Dno42B0a.js";
|
|
4
5
|
import { useQuery as K, useMutation as U, useQueryClient as me } from "@tanstack/react-query";
|
|
5
6
|
import { toast as N } from "sonner";
|
|
6
|
-
import { Trash2 as Y, Plus as pe, ImageIcon as
|
|
7
|
-
import { useState as
|
|
7
|
+
import { Trash2 as Y, Plus as pe, ImageIcon as fe, X as he, AlertCircle as ge } from "lucide-react";
|
|
8
|
+
import { useState as h, useRef as V, useMemo as S, useEffect as w, useCallback as be } from "react";
|
|
8
9
|
import { c as ve } from "./image-compression-DsZ1oqpb.js";
|
|
9
10
|
import { isEmpty as ye, set as ke, has as Ne } from "lodash-es";
|
|
10
11
|
const Be = (r) => {
|
|
@@ -67,7 +68,7 @@ const Be = (r) => {
|
|
|
67
68
|
blockName: u,
|
|
68
69
|
trigger: p
|
|
69
70
|
}) => {
|
|
70
|
-
const [d, l] =
|
|
71
|
+
const [d, l] = h(!1), c = j(), v = Ie(() => {
|
|
71
72
|
c([r], { _libBlockId: void 0 }), N.success("Block deleted successfully"), l(!1), t();
|
|
72
73
|
});
|
|
73
74
|
return /* @__PURE__ */ i(se, { open: o, onOpenChange: (m) => !m && t(), children: [
|
|
@@ -111,7 +112,7 @@ const Be = (r) => {
|
|
|
111
112
|
className: u = "",
|
|
112
113
|
close: p
|
|
113
114
|
}) => {
|
|
114
|
-
const [d, l] =
|
|
115
|
+
const [d, l] = h(!1);
|
|
115
116
|
return /* @__PURE__ */ e(
|
|
116
117
|
we,
|
|
117
118
|
{
|
|
@@ -184,7 +185,7 @@ const Be = (r) => {
|
|
|
184
185
|
isCreating: l
|
|
185
186
|
};
|
|
186
187
|
}, Pe = ({ value: r, onChange: a }) => {
|
|
187
|
-
const [o, t] =
|
|
188
|
+
const [o, t] = h(!1), [u, p] = h(""), d = V(null), { groups: l } = xe(), [c, v] = h([
|
|
188
189
|
{ id: "hero", name: "Hero" },
|
|
189
190
|
{ id: "feature", name: "Feature" },
|
|
190
191
|
{ id: "footer", name: "Footer" },
|
|
@@ -212,7 +213,7 @@ const Be = (r) => {
|
|
|
212
213
|
{ id: "stats", name: "Stats" },
|
|
213
214
|
{ id: "team", name: "Team" },
|
|
214
215
|
{ id: "timeline", name: "Timeline" }
|
|
215
|
-
]),
|
|
216
|
+
]), f = S(
|
|
216
217
|
() => [
|
|
217
218
|
...l,
|
|
218
219
|
...c.filter((n) => !l.some((B) => B.id === n.id))
|
|
@@ -231,8 +232,8 @@ const Be = (r) => {
|
|
|
231
232
|
n.key === "Enter" && (n.preventDefault(), g());
|
|
232
233
|
};
|
|
233
234
|
return w(() => {
|
|
234
|
-
r && !
|
|
235
|
-
}, [r,
|
|
235
|
+
r && !f.some((n) => n.id === r) && a("");
|
|
236
|
+
}, [r, f, a]), o ? /* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
236
237
|
/* @__PURE__ */ e(
|
|
237
238
|
L,
|
|
238
239
|
{
|
|
@@ -264,10 +265,10 @@ const Be = (r) => {
|
|
|
264
265
|
/* @__PURE__ */ e(b, { type: "button", size: "icon", variant: "outline", onClick: () => t(!0), children: /* @__PURE__ */ e(pe, { className: "h-4 w-4" }) })
|
|
265
266
|
] });
|
|
266
267
|
}, Le = ({ value: r, onChange: a }) => {
|
|
267
|
-
const [o, t] =
|
|
268
|
+
const [o, t] = h(!1), u = V(null), p = be(
|
|
268
269
|
async (c) => {
|
|
269
|
-
var
|
|
270
|
-
const v = (
|
|
270
|
+
var f;
|
|
271
|
+
const v = (f = c.target.files) == null ? void 0 : f[0];
|
|
271
272
|
if (v)
|
|
272
273
|
try {
|
|
273
274
|
t(!0);
|
|
@@ -295,16 +296,16 @@ const Be = (r) => {
|
|
|
295
296
|
/* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
296
297
|
"Uploading..."
|
|
297
298
|
] }) : /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
|
|
298
|
-
/* @__PURE__ */ e(
|
|
299
|
+
/* @__PURE__ */ e(fe, { className: "h-4 w-4" }),
|
|
299
300
|
"Select image"
|
|
300
301
|
] }) }),
|
|
301
302
|
r && /* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "icon", onClick: () => {
|
|
302
303
|
a(""), u.current && (u.current.value = "");
|
|
303
|
-
}, children: /* @__PURE__ */ e(
|
|
304
|
+
}, children: /* @__PURE__ */ e(he, { className: "h-4 w-4" }) })
|
|
304
305
|
] }),
|
|
305
306
|
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
|
] });
|
|
307
|
-
},
|
|
308
|
+
}, ze = (r) => {
|
|
308
309
|
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
310
|
let s = [];
|
|
310
311
|
for (const y of a)
|
|
@@ -314,31 +315,31 @@ const Be = (r) => {
|
|
|
314
315
|
} else
|
|
315
316
|
s.push(y);
|
|
316
317
|
return s;
|
|
317
|
-
}, [a, u]), [
|
|
318
|
-
|
|
318
|
+
}, [a, u]), [f, g] = h(""), [m, n] = h(""), [B, E] = h(""), [x, A] = h(""), [C, W] = h({}), [Q, $] = h(!1), [H, q] = h(l), [X, J] = h(!1), { hasPermission: Z } = ce(), ee = Z(ue.DELETE_LIBRARY_BLOCK), z = j(), te = () => {
|
|
319
|
+
z([t], { _libBlockId: void 0 }), N.success("Block delinked from library"), o();
|
|
319
320
|
}, {
|
|
320
321
|
data: I,
|
|
321
|
-
isLoading:
|
|
322
|
-
isError:
|
|
322
|
+
isLoading: T,
|
|
323
|
+
isError: M
|
|
323
324
|
} = Ce(d);
|
|
324
325
|
w(() => {
|
|
325
|
-
|
|
326
|
-
}, [
|
|
327
|
-
I && !
|
|
328
|
-
}, [I,
|
|
329
|
-
const s =
|
|
326
|
+
M && l && (J(!0), q(!1));
|
|
327
|
+
}, [M, l]), w(() => {
|
|
328
|
+
I && !T && (g(I.name || ""), n(I.group || ""), E(I.description || ""), A(I.preview || ""), q(!1));
|
|
329
|
+
}, [I, T]), w(() => {
|
|
330
|
+
const s = f.trim().length >= 2, y = m.trim() !== "";
|
|
330
331
|
$(s && y);
|
|
331
|
-
}, [
|
|
332
|
+
}, [f, m]);
|
|
332
333
|
const re = () => {
|
|
333
334
|
const s = {};
|
|
334
|
-
return
|
|
335
|
-
}, { resetLibrary: ae } = de({ id: "" }),
|
|
336
|
-
l ||
|
|
335
|
+
return f.trim() ? f.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;
|
|
336
|
+
}, { resetLibrary: ae } = de({ id: "" }), O = Be((s) => {
|
|
337
|
+
l || z([t], { _libBlockId: s.id }), N.success(`Block ${l ? "updated" : "saved"} successfully`), ae(s.library), o();
|
|
337
338
|
}), ne = async (s) => {
|
|
338
339
|
if (s.preventDefault(), !re()) return;
|
|
339
340
|
const y = v.map((k) => (Ne(k, "_libBlockId") && delete k._libBlockId, k));
|
|
340
|
-
|
|
341
|
-
name:
|
|
341
|
+
O.mutate({
|
|
342
|
+
name: f.trim(),
|
|
342
343
|
group: m,
|
|
343
344
|
blocks: y,
|
|
344
345
|
description: B.trim(),
|
|
@@ -347,8 +348,8 @@ const Be = (r) => {
|
|
|
347
348
|
// Include id if in edit mode
|
|
348
349
|
...l ? { id: d } : {}
|
|
349
350
|
});
|
|
350
|
-
},
|
|
351
|
-
return H ||
|
|
351
|
+
}, F = O.isPending;
|
|
352
|
+
return H || T ? /* @__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
353
|
/* @__PURE__ */ e("div", { className: "font-medium text-destructive", children: "Block Not Found" }),
|
|
353
354
|
/* @__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
355
|
/* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-4", children: [
|
|
@@ -371,7 +372,7 @@ const Be = (r) => {
|
|
|
371
372
|
{
|
|
372
373
|
id: "name",
|
|
373
374
|
placeholder: "Enter block name",
|
|
374
|
-
value:
|
|
375
|
+
value: f,
|
|
375
376
|
onChange: (s) => g(s.target.value),
|
|
376
377
|
className: C.name ? "border-destructive" : ""
|
|
377
378
|
}
|
|
@@ -406,17 +407,17 @@ const Be = (r) => {
|
|
|
406
407
|
{
|
|
407
408
|
blockId: t,
|
|
408
409
|
libBlockId: d,
|
|
409
|
-
blockName:
|
|
410
|
+
blockName: f,
|
|
410
411
|
className: "mr-auto",
|
|
411
412
|
close: o
|
|
412
413
|
}
|
|
413
414
|
),
|
|
414
|
-
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, disabled:
|
|
415
|
-
/* @__PURE__ */ e(b, { type: "submit", disabled:
|
|
415
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, disabled: F, children: "Cancel" }),
|
|
416
|
+
/* @__PURE__ */ e(b, { type: "submit", disabled: F || !Q, children: F ? "Saving..." : l ? "Update Block" : "Save Block" })
|
|
416
417
|
] })
|
|
417
418
|
] })
|
|
418
419
|
] });
|
|
419
420
|
};
|
|
420
421
|
export {
|
|
421
|
-
|
|
422
|
+
ze as default
|
|
422
423
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./register-chai-top-bar-BqwKw4uy.cjs"),b=require("./index-C99FhuF1.cjs"),x=require("./index-C0-pgg_p.cjs"),C=require("@tanstack/react-query"),j=require("sonner"),E=require("lucide-react"),i=require("react"),X=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),J=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.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"})}})},Z=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useQuery({staleTime:"static",queryKey:[x.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:x.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})},ee=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:t}}),onSuccess:()=>{s?s():j.toast.success("Block deleted successfully")},onError:t=>{console.error("Error deleting block:",t),j.toast.error("Failed to delete block",{description:t instanceof Error?t.message:"Unknown error"})}})},te=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:m,trigger:f})=>{const[d,o]=i.useState(!1),c=b.useUpdateBlocksPropsRealtime(),y=ee(()=>{c([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),p=()=>{o(!0),y.mutate(r)},g=e.jsxs(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:h=>h.preventDefault(),disabled:d,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(b.Popover,{open:l,onOpenChange:h=>!h&&t(),children:[e.jsx(b.PopoverTrigger,{asChild:!0,children:f||g}),e.jsx(b.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:[' "',m,'"']}),"?"]}),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(u.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:d,children:"Cancel"}),e.jsx(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:p,disabled:d,children:d?"Deleting...":"Delete"})]})]})})]})},se=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:m="",close:f})=>{const[d,o]=i.useState(!1);return e.jsx(te,{blockId:s,libBlockId:r,isOpen:d,onClose:()=>{o(!1),f()},blockName:l,trigger:e.jsxs(u.Button,{type:"button",variant:"destructive",size:t,className:m,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},re=()=>{const s=x.useApiUrl(),r=x.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:m,error:f}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(c){return console.error("Error fetching library groups:",c),[]}}}),{mutateAsync:d,isPending:o}=C.useMutation({mutationFn:async c=>{if(!c.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:c}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:c=>{console.error("Error creating group:",c),j.toast.error("Failed to create group",{description:c instanceof Error?c.message:"Unknown error"})}});return{groups:t,isLoading:m,error:f,createGroup:d,isCreating:o}},ne=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[m,f]=i.useState(""),d=i.useRef(null),{groups:o}=re(),[c,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"}]),p=i.useMemo(()=>[...o,...c.filter(n=>!o.some(B=>B.id===n.id))],[o,c]),g=()=>{const n=m.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),f(""),t(!1)};i.useEffect(()=>{l&&d.current&&d.current.focus()},[l]);const h=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!p.some(n=>n.id===s)&&r("")},[s,p,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(u.Input,{ref:d,placeholder:"Enter new group name",value:m,onChange:n=>f(n.target.value),onKeyDown:h}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(u.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}`))}),c.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:c.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(u.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),m=i.useRef(null),f=i.useCallback(async c=>{var p;const y=(p=c.target.files)==null?void 0:p[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await X.compressImageIfNeeded(y));const h=new FileReader;h.onloadend=()=>{r(h.result),t(!1)},h.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]),d=()=>{r(""),m.current&&(m.current.value="")},o=()=>{var c;(c=m.current)==null||c.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u.Input,{type:"file",ref:m,onChange:f,accept:"image/*",className:"hidden"}),e.jsx(u.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(u.Button,{type:"button",variant:"outline",size:"icon",onClick:d,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"})})]})},oe=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartailBlocks:m}=b.usePartialBlocksStore(),f=r.find(a=>a._id===t),d=f==null?void 0:f._libBlockId,o=!!d,c=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const v of r)if(v._type==="PartialBlock"||v._type==="GlobalBlock"){let k=m(v.partialBlockId);v._parent&&(k==null?void 0:k.length)>0&&(k=k.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",v._parent),T))),a=[...a,...k]}else a.push(v);return a},[r,m]),[p,g]=i.useState(""),[h,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,A]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=b.usePermissions(),Q=Y(x.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=b.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=Z(d);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=p.trim().length>=2,v=h.trim()!=="";M(a&&v)},[p,h]);const W=()=>{const a={};return p.trim()?p.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",h||(a.group="Group is required"),A(a),Object.keys(a).length===0},{resetLibrary:$}=b.useLibraryBlocks({id:""}),U=J(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 v=y.map(k=>(R.has(k,"_libBlockId")&&delete k._libBlockId,k));U.mutate({name:p.trim(),group:h,blocks:v,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:d}:{}})},L=U.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(u.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(u.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[c&&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(b.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(u.Input,{id:"name",placeholder:"Enter block name",value:p,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(b.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ne,{value:h,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(b.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(u.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(b.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(ae,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(se,{blockId:t,libBlockId:d,blockName:p,className:"mr-auto",close:l}),e.jsx(u.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(u.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=oe;
|