@chaibuilder/sdk 2.0.0-beta.5 → 2.0.0-beta.50
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 +0 -4
- package/dist/ChaiThemeFn-Cort9tch.js +201 -0
- package/dist/ChaiThemeFn-DQu-2Eh9.cjs +13 -0
- package/dist/CodeEditor-CARM2Bvq.js +77 -0
- package/dist/CodeEditor-DFSAQLjb.cjs +1 -0
- package/dist/STRINGS-DtEft2kY.js +5 -0
- package/dist/STRINGS-n7COZtKr.cjs +1 -0
- package/dist/Topbar-CEyGOl06.js +16 -0
- package/dist/Topbar-pFV2NO8v.cjs +1 -0
- package/dist/{context-menu-0lRey9QY.cjs → context-menu-C_ITMOD1.cjs} +1 -1
- package/dist/{context-menu-I8woggB3.js → context-menu-FCyNTUkl.js} +66 -66
- package/dist/core.cjs +61 -1
- package/dist/core.d.ts +108 -54
- package/dist/core.js +8687 -122
- package/dist/{iconBase-Ief2hJUZ.js → iconBase-DHfFLkem.js} +6 -12
- package/dist/{jsx-runtime-Sp0orL4X.js → jsx-runtime-Drh4NO5G.js} +234 -232
- package/dist/jsx-runtime-qcKc-DpB.cjs +30 -0
- package/dist/mockServiceWorker.js +39 -24
- package/dist/plugin-2xcljWGM.cjs +1 -0
- package/dist/plugin-kUMxtQR5.js +24 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +34 -16
- package/dist/render.js +136 -136
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +0 -1
- package/dist/runtime.js +0 -20
- package/dist/{style.css → sdk.css} +1 -1
- package/dist/tailwind.cjs +1 -1
- package/dist/tailwind.d.ts +31 -26
- package/dist/tailwind.js +8 -10
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +6 -51
- package/dist/ui.js +199 -356
- package/dist/web-blocks.cjs +2 -2
- package/dist/web-blocks.js +1327 -703
- package/package.json +121 -120
- package/dist/CodeEditor-fHc8uUZi.js +0 -126
- package/dist/CodeEditor-jEPBwyMf.cjs +0 -1
- package/dist/STRINGS-Xxstm-7I.js +0 -7
- package/dist/STRINGS-Yl7cSWDc.cjs +0 -1
- package/dist/Topbar-9ltyM5Cl.js +0 -160
- package/dist/Topbar-CbNTH5d8.cjs +0 -1
- package/dist/controls-lEwMTdPQ.js +0 -234
- package/dist/controls-p9IwFnPx.cjs +0 -1
- package/dist/index-UvIwJj5Y.js +0 -8540
- package/dist/index-gHOGFo7e.cjs +0 -63
- package/dist/jsx-runtime-JYMCiFoE.cjs +0 -27
- package/dist/plugin-UiUFs2fK.js +0 -44
- package/dist/plugin-f6SDZ_Or.js +0 -108
- package/dist/plugin-jum1MjXp.cjs +0 -1
- package/dist/plugin-xOpS-UNV.cjs +0 -1
- /package/dist/{iconBase-aZzpqff_.cjs → iconBase-Cn2BsTrq.cjs} +0 -0
package/dist/core.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClassValue } from 'clsx';
|
|
2
|
-
import
|
|
2
|
+
import { default as default_2 } from 'react';
|
|
3
|
+
import { default as i18n } from 'i18next';
|
|
3
4
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
4
5
|
import * as React_2 from 'react';
|
|
5
|
-
import { default as React_3 } from 'react';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
import { registerChaiBlock } from '@chaibuilder/runtime';
|
|
8
8
|
import { RESET } from 'jotai/utils';
|
|
@@ -16,10 +16,11 @@ declare type AddBlocks = {
|
|
|
16
16
|
|
|
17
17
|
export declare const AddBlocksDialog: () => JSX_2.Element;
|
|
18
18
|
|
|
19
|
-
export declare const AddBlocksPanel: ({ className, showHeading, parentId, }: {
|
|
19
|
+
export declare const AddBlocksPanel: ({ className, showHeading, parentId, position, }: {
|
|
20
20
|
parentId?: string;
|
|
21
21
|
showHeading?: boolean;
|
|
22
22
|
className?: string;
|
|
23
|
+
position?: number;
|
|
23
24
|
}) => JSX_2.Element;
|
|
24
25
|
|
|
25
26
|
export declare const AISetContext: () => JSX_2.Element;
|
|
@@ -46,11 +47,13 @@ export declare function BlockPropsEditor(): JSX_2.Element;
|
|
|
46
47
|
|
|
47
48
|
export declare function BlockStyleEditor(): JSX_2.Element;
|
|
48
49
|
|
|
50
|
+
declare type BorderRadiusValue = false | string;
|
|
51
|
+
|
|
49
52
|
declare type Breakpoint = {
|
|
50
53
|
title: string;
|
|
51
54
|
content: string;
|
|
52
55
|
breakpoint: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | string;
|
|
53
|
-
icon:
|
|
56
|
+
icon: default_2.ReactNode | Element;
|
|
54
57
|
width: number;
|
|
55
58
|
};
|
|
56
59
|
|
|
@@ -60,22 +63,29 @@ export declare const CHAI_BUILDER_EVENTS: {
|
|
|
60
63
|
SHOW_BLOCK_SETTINGS: string;
|
|
61
64
|
};
|
|
62
65
|
|
|
63
|
-
export declare type ChaiBlock = {
|
|
66
|
+
export declare type ChaiBlock<T = Record<string, any>> = {
|
|
64
67
|
_id: string;
|
|
65
|
-
_type: string;
|
|
66
68
|
_name?: string;
|
|
67
69
|
_parent?: string | null | undefined;
|
|
68
70
|
_bindings?: Record<string, string>;
|
|
69
|
-
|
|
71
|
+
_type: string;
|
|
72
|
+
} & T;
|
|
70
73
|
|
|
71
|
-
export declare const ChaiBuilderCanvas:
|
|
74
|
+
export declare const ChaiBuilderCanvas: default_2.FC;
|
|
72
75
|
|
|
73
76
|
/**
|
|
74
77
|
* ChaiBuilder is the main entry point for the Chai Builder Studio.
|
|
75
78
|
*/
|
|
76
|
-
export declare const ChaiBuilderEditor:
|
|
79
|
+
export declare const ChaiBuilderEditor: default_2.FC<ChaiBuilderEditorProps>;
|
|
77
80
|
|
|
78
81
|
export declare interface ChaiBuilderEditorProps {
|
|
82
|
+
/**
|
|
83
|
+
* Optional pageId. If not provided, a random pageId will be generated
|
|
84
|
+
*/
|
|
85
|
+
pageId?: string;
|
|
86
|
+
themePresets?: Record<string, Partial<ChaiBuilderThemeValues>>[];
|
|
87
|
+
themeOptions?: ChaiBuilderThemeOptions | ((defaultThemeOptions: ChaiBuilderThemeOptions) => ChaiBuilderThemeOptions);
|
|
88
|
+
theme?: Partial<ChaiBuilderThemeValues>;
|
|
79
89
|
/**
|
|
80
90
|
* onError callback function
|
|
81
91
|
* @param error
|
|
@@ -93,7 +103,7 @@ export declare interface ChaiBuilderEditorProps {
|
|
|
93
103
|
/**
|
|
94
104
|
* Custom layout component
|
|
95
105
|
*/
|
|
96
|
-
layout?:
|
|
106
|
+
layout?: default_2.ComponentType;
|
|
97
107
|
/**
|
|
98
108
|
* Layout variant. Not supported with custom layout
|
|
99
109
|
*/
|
|
@@ -101,9 +111,17 @@ export declare interface ChaiBuilderEditorProps {
|
|
|
101
111
|
/**
|
|
102
112
|
* Custom media Manager component
|
|
103
113
|
*/
|
|
104
|
-
mediaManagerComponent?:
|
|
114
|
+
mediaManagerComponent?: default_2.ComponentType<{
|
|
105
115
|
onSelect: (url: string) => void;
|
|
106
116
|
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Add blocks dialog components
|
|
119
|
+
*/
|
|
120
|
+
addBlocksDialogTabs?: {
|
|
121
|
+
key: string;
|
|
122
|
+
tab: ReactComponentType;
|
|
123
|
+
tabContent: ReactComponentType;
|
|
124
|
+
}[];
|
|
107
125
|
/**
|
|
108
126
|
* HTML direction.
|
|
109
127
|
*/
|
|
@@ -159,7 +177,7 @@ export declare interface ChaiBuilderEditorProps {
|
|
|
159
177
|
uiLibraries?: Omit<UILibrary, "blocks">[];
|
|
160
178
|
getUILibraryBlocks?: (library: UILibrary) => Promise<UiLibraryBlock[]>;
|
|
161
179
|
getUILibraryBlock?: (library: UILibrary, uiLibBlock: UiLibraryBlock) => Promise<ChaiBlock[]>;
|
|
162
|
-
|
|
180
|
+
getBlockAsyncProps?: (block: ChaiBlock) => Promise<string>;
|
|
163
181
|
/**
|
|
164
182
|
* Get Global blocks
|
|
165
183
|
*/
|
|
@@ -175,9 +193,7 @@ export declare interface ChaiBuilderEditorProps {
|
|
|
175
193
|
* Blocks for the page
|
|
176
194
|
*/
|
|
177
195
|
blocks?: ChaiBlock[];
|
|
178
|
-
onSave?: ({ blocks,
|
|
179
|
-
brandingOptions?: Record<string, string>;
|
|
180
|
-
theme?: Record<string, string>;
|
|
196
|
+
onSave?: ({ blocks, theme, autoSave }: SavePageData) => Promise<boolean | Error>;
|
|
181
197
|
/**
|
|
182
198
|
* onSaveStateChange callback function
|
|
183
199
|
* @param syncStatus
|
|
@@ -217,16 +233,31 @@ export declare interface ChaiBuilderEditorProps {
|
|
|
217
233
|
fallbackLang?: string;
|
|
218
234
|
languages?: Array<string>;
|
|
219
235
|
/**
|
|
220
|
-
*
|
|
236
|
+
* Page Types props
|
|
221
237
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
238
|
+
pageTypes?: PageType[];
|
|
239
|
+
searchPageTypeItems?: (pageTypeKey: string, query: string) => Promise<PageTypeItem[] | Error>;
|
|
224
240
|
}
|
|
225
241
|
|
|
226
242
|
declare type ChaiBuilderInstance = {
|
|
227
243
|
setBlocks: (blocks: ChaiBlock[]) => void;
|
|
228
244
|
};
|
|
229
245
|
|
|
246
|
+
declare type ChaiBuilderThemeOptions = {
|
|
247
|
+
fontFamily: false | Record<VariableKey, string>;
|
|
248
|
+
borderRadius: BorderRadiusValue;
|
|
249
|
+
colors: false | {
|
|
250
|
+
group: string;
|
|
251
|
+
items: Record<VariableKey, [HSLColor, HSLColor]>;
|
|
252
|
+
}[];
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
declare type ChaiBuilderThemeValues = {
|
|
256
|
+
fontFamily: Record<string, string>;
|
|
257
|
+
borderRadius: string;
|
|
258
|
+
colors: Record<string, string[]>;
|
|
259
|
+
};
|
|
260
|
+
|
|
230
261
|
declare type ClassDerivedObject = {
|
|
231
262
|
cls: string;
|
|
232
263
|
dark: boolean;
|
|
@@ -243,30 +274,15 @@ declare type CodeEditorProps = {
|
|
|
243
274
|
placeholder?: string;
|
|
244
275
|
};
|
|
245
276
|
|
|
246
|
-
declare type Collection = {
|
|
247
|
-
key: string;
|
|
248
|
-
name: string;
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
declare type CollectionItem = {
|
|
252
|
-
id: string;
|
|
253
|
-
name: string;
|
|
254
|
-
slug?: string;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
277
|
declare type CopiedValue = string | null;
|
|
258
278
|
|
|
259
279
|
declare type CopyFn = (text: string) => Promise<boolean>;
|
|
260
280
|
|
|
261
281
|
export declare function DarkModeSwitcher(): JSX_2.Element;
|
|
262
282
|
|
|
263
|
-
declare
|
|
264
|
-
providerKey: string;
|
|
265
|
-
args: Record<string, any>;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export declare const DefaultChaiBlocks: ({ parentId, gridCols }: {
|
|
283
|
+
export declare const DefaultChaiBlocks: ({ parentId, position, gridCols, }: {
|
|
269
284
|
parentId?: string;
|
|
285
|
+
position?: number;
|
|
270
286
|
gridCols?: string;
|
|
271
287
|
}) => JSX_2.Element;
|
|
272
288
|
|
|
@@ -298,10 +314,13 @@ declare type GlobalBlockList = Record<string, {
|
|
|
298
314
|
description?: string;
|
|
299
315
|
}>;
|
|
300
316
|
|
|
317
|
+
declare type HSLColor = string;
|
|
318
|
+
|
|
301
319
|
export { i18n }
|
|
302
320
|
|
|
303
|
-
export declare const ImportHTML: ({ parentId }: {
|
|
321
|
+
export declare const ImportHTML: ({ parentId, position }: {
|
|
304
322
|
parentId?: string;
|
|
323
|
+
position?: number;
|
|
305
324
|
}) => JSX_2.Element;
|
|
306
325
|
|
|
307
326
|
declare type LayoutVariant = "SINGLE_SIDE_PANEL" | "DUAL_SIDE_PANEL" | "DUAL_SIDE_PANEL_ADVANCED";
|
|
@@ -311,7 +330,7 @@ export declare const mergeClasses: (...inputs: ClassValue[]) => string;
|
|
|
311
330
|
export declare const Outline: () => JSX_2.Element;
|
|
312
331
|
|
|
313
332
|
declare type OutlineMenuItem = {
|
|
314
|
-
item:
|
|
333
|
+
item: default_2.ComponentType<{
|
|
315
334
|
blockId: string;
|
|
316
335
|
}>;
|
|
317
336
|
tooltip: string | ReactNode;
|
|
@@ -319,7 +338,18 @@ declare type OutlineMenuItem = {
|
|
|
319
338
|
|
|
320
339
|
declare type OutlineMenuItems = OutlineMenuItem[];
|
|
321
340
|
|
|
322
|
-
declare type
|
|
341
|
+
declare type PageType = {
|
|
342
|
+
key: string;
|
|
343
|
+
name: string;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
declare type PageTypeItem = {
|
|
347
|
+
id: string;
|
|
348
|
+
name: string;
|
|
349
|
+
slug?: string;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
declare type ReactComponentType = default_2.ComponentType<any>;
|
|
323
353
|
|
|
324
354
|
export { registerChaiBlock }
|
|
325
355
|
|
|
@@ -328,17 +358,16 @@ declare type RichText = string;
|
|
|
328
358
|
declare type SavePageData = {
|
|
329
359
|
autoSave: boolean;
|
|
330
360
|
blocks: ChaiBlock[];
|
|
331
|
-
|
|
332
|
-
brandingOptions?: Record<string, any>;
|
|
333
|
-
themeConfiguration?: Record<string, any>;
|
|
361
|
+
theme?: Record<string, any>;
|
|
334
362
|
};
|
|
335
363
|
|
|
336
364
|
export declare const ScreenSizes: () => JSX_2.Element;
|
|
337
365
|
|
|
338
|
-
|
|
366
|
+
declare interface ThemeConfigProps {
|
|
339
367
|
className?: string;
|
|
340
|
-
|
|
341
|
-
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export declare const ThemeOptions: React_2.FC<ThemeConfigProps>;
|
|
342
371
|
|
|
343
372
|
declare type TimeInSeconds = number;
|
|
344
373
|
|
|
@@ -348,8 +377,9 @@ declare type TStyleBlock = {
|
|
|
348
377
|
prop: string;
|
|
349
378
|
};
|
|
350
379
|
|
|
351
|
-
export declare const UILibraries: ({ parentId }: {
|
|
380
|
+
export declare const UILibraries: ({ parentId, position }: {
|
|
352
381
|
parentId?: string;
|
|
382
|
+
position?: number;
|
|
353
383
|
}) => JSX_2.Element;
|
|
354
384
|
|
|
355
385
|
declare interface UILibrary {
|
|
@@ -375,10 +405,16 @@ export declare const UndoRedo: () => JSX_2.Element;
|
|
|
375
405
|
|
|
376
406
|
export declare const useAddBlock: () => AddBlocks;
|
|
377
407
|
|
|
378
|
-
export declare const useAddClassesToBlocks: () =>
|
|
408
|
+
export declare const useAddClassesToBlocks: () => (blockIds: Array<string>, newClasses: Array<string>, undo?: boolean) => void;
|
|
409
|
+
|
|
410
|
+
export declare const useAskAi: () => {
|
|
411
|
+
askAi: (type: "styles" | "content", blockId: string, prompt: string, onComplete?: (response?: AskAiResponse) => void) => Promise<void>;
|
|
412
|
+
loading: boolean;
|
|
413
|
+
error: any;
|
|
414
|
+
};
|
|
379
415
|
|
|
380
416
|
export declare const useBlockHighlight: () => {
|
|
381
|
-
highlightBlock: (
|
|
417
|
+
highlightBlock: (elementOrID: HTMLElement | string) => void;
|
|
382
418
|
clearHighlight: () => void;
|
|
383
419
|
lastHighlighted: HTMLElement;
|
|
384
420
|
};
|
|
@@ -414,7 +450,7 @@ export declare const useCanvasWidth: () => [number, string, Function];
|
|
|
414
450
|
/**
|
|
415
451
|
* Wrapper hook around useAtom
|
|
416
452
|
*/
|
|
417
|
-
export declare const useCanvasZoom: () => [number, (args_0: number |
|
|
453
|
+
export declare const useCanvasZoom: () => [number, (args_0: number | RESET | ((prev: number) => number | RESET)) => void];
|
|
418
454
|
|
|
419
455
|
/**
|
|
420
456
|
* Custom hook to access the current state of the code editor.
|
|
@@ -423,7 +459,7 @@ export declare const useCanvasZoom: () => [number, (args_0: number | typeof RESE
|
|
|
423
459
|
*/
|
|
424
460
|
export declare const useCodeEditor: () => [CodeEditorProps, never];
|
|
425
461
|
|
|
426
|
-
export declare const useCopyBlockIds: () => [Array<string>,
|
|
462
|
+
export declare const useCopyBlockIds: () => [Array<string>, (blockIds: Array<string>) => void];
|
|
427
463
|
|
|
428
464
|
export declare const useCopyToClipboard: () => [CopiedValue, CopyFn];
|
|
429
465
|
|
|
@@ -468,11 +504,11 @@ export declare const useLanguages: () => {
|
|
|
468
504
|
setSelectedLang: (lang: string) => void;
|
|
469
505
|
};
|
|
470
506
|
|
|
471
|
-
export declare const useLayoutVariant: () => readonly [LayoutVariant, (args_0:
|
|
507
|
+
export declare const useLayoutVariant: () => readonly [LayoutVariant, (args_0: RESET | LayoutVariant | ((prev: LayoutVariant) => RESET | LayoutVariant)) => void];
|
|
472
508
|
|
|
473
509
|
export declare const usePasteBlocks: () => {
|
|
474
|
-
canPaste: (newParentId: string) => boolean
|
|
475
|
-
pasteBlocks:
|
|
510
|
+
canPaste: (newParentId: string) => Promise<boolean>;
|
|
511
|
+
pasteBlocks: (newParentId: string | string[]) => Promise<void>;
|
|
476
512
|
};
|
|
477
513
|
|
|
478
514
|
/**
|
|
@@ -484,6 +520,8 @@ export declare const useRemoveBlocks: () => (blockIds: Array<string>) => void;
|
|
|
484
520
|
|
|
485
521
|
export declare const useRemoveClassesFromBlocks: () => Function;
|
|
486
522
|
|
|
523
|
+
export declare const useRightPanel: () => ["theme" | "block" | "ai" | "settings", (args_0: "theme" | "block" | "ai" | "settings" | ((prev: "theme" | "block" | "ai" | "settings") => "theme" | "block" | "ai" | "settings")) => void];
|
|
524
|
+
|
|
487
525
|
export declare const useSavePage: () => {
|
|
488
526
|
savePage: ThrottledFunction<(autoSave?: boolean) => Promise<boolean>>;
|
|
489
527
|
saveState: "UNSAVED" | "SAVED" | "SAVING";
|
|
@@ -502,7 +540,7 @@ export declare const useSelectedBlockCurrentClasses: () => Array<ClassDerivedObj
|
|
|
502
540
|
/**
|
|
503
541
|
*
|
|
504
542
|
*/
|
|
505
|
-
export declare const useSelectedBlockIds: () => [
|
|
543
|
+
export declare const useSelectedBlockIds: () => readonly [string[], (args_0: string[] | ((prev: string[]) => string[])) => void, (blockId: string) => void];
|
|
506
544
|
|
|
507
545
|
/**
|
|
508
546
|
* Hook to get selected block ids
|
|
@@ -520,10 +558,22 @@ export declare const useSelectedBreakpoints: () => [string[], Function];
|
|
|
520
558
|
*/
|
|
521
559
|
export declare const useSelectedStylingBlocks: () => [TStyleBlock[], (args_0: TStyleBlock[] | ((prev: TStyleBlock[]) => TStyleBlock[])) => void];
|
|
522
560
|
|
|
523
|
-
export declare const useStylingBreakpoint: () => [string, (args_0: string |
|
|
561
|
+
export declare const useStylingBreakpoint: () => [string, (args_0: string | RESET | ((prev: string) => string | RESET)) => void];
|
|
524
562
|
|
|
525
563
|
export declare const useStylingState: () => [unknown, (...args: unknown[]) => unknown];
|
|
526
564
|
|
|
565
|
+
export declare const useTheme: () => readonly [{
|
|
566
|
+
fontFamily: Record<string, string>;
|
|
567
|
+
borderRadius: string;
|
|
568
|
+
colors: Record<string, string[]>;
|
|
569
|
+
} | {
|
|
570
|
+
fontFamily?: Record<string, string>;
|
|
571
|
+
borderRadius?: string;
|
|
572
|
+
colors?: Record<string, string[]>;
|
|
573
|
+
}, (args_0: ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues> | ((prev: ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues>) => ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues>)) => void];
|
|
574
|
+
|
|
575
|
+
export declare const useThemeOptions: () => ChaiBuilderThemeOptions;
|
|
576
|
+
|
|
527
577
|
export { useTranslation }
|
|
528
578
|
|
|
529
579
|
export declare const useUILibraryBlocks: () => {
|
|
@@ -547,4 +597,8 @@ export declare const useUpdateBlocksProps: () => (blockIds: Array<string>, props
|
|
|
547
597
|
|
|
548
598
|
export declare const useUpdateBlocksPropsRealtime: () => (blockIds: Array<string>, props: Record<string, any>) => void;
|
|
549
599
|
|
|
600
|
+
export declare const useWrapperBlock: () => any;
|
|
601
|
+
|
|
602
|
+
declare type VariableKey = string;
|
|
603
|
+
|
|
550
604
|
export { }
|