@chaibuilder/sdk 2.0.0-beta.2 → 2.0.0-beta.21

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.
Files changed (44) hide show
  1. package/dist/ChaiThemeFn--DgGggh_.js +190 -0
  2. package/dist/ChaiThemeFn-bugxb1Cl.cjs +13 -0
  3. package/dist/{CodeEditor-xhb27i29.js → CodeEditor-7Cs6j_Wn.js} +14 -14
  4. package/dist/CodeEditor-Ifwz-vPV.cjs +1 -0
  5. package/dist/STRINGS-26RPxXyi.cjs +1 -0
  6. package/dist/STRINGS-BnWT5XcX.js +5 -0
  7. package/dist/Topbar-J_gRMjOQ.js +73 -0
  8. package/dist/Topbar-tTu3ihcy.cjs +1 -0
  9. package/dist/context-menu-4nQs6OxC.cjs +1 -0
  10. package/dist/{context-menu-I8woggB3.js → context-menu-oLipAPzI.js} +237 -254
  11. package/dist/core.cjs +61 -1
  12. package/dist/core.d.ts +56 -34
  13. package/dist/core.js +8598 -107
  14. package/dist/plugin-4xaTkTNB.cjs +1 -0
  15. package/dist/plugin-GuIj4Ul0.js +24 -0
  16. package/dist/render.cjs +2 -2
  17. package/dist/render.d.ts +34 -16
  18. package/dist/render.js +119 -121
  19. package/dist/runtime.cjs +1 -1
  20. package/dist/runtime.d.ts +0 -1
  21. package/dist/runtime.js +0 -20
  22. package/dist/style.css +1 -1
  23. package/dist/tailwind.cjs +1 -1
  24. package/dist/tailwind.d.ts +26 -25
  25. package/dist/tailwind.js +2 -2
  26. package/dist/ui.cjs +1 -1
  27. package/dist/ui.js +238 -223
  28. package/dist/web-blocks.cjs +2 -2
  29. package/dist/web-blocks.js +1079 -703
  30. package/package.json +6 -9
  31. package/dist/CodeEditor-e9zXhHFt.cjs +0 -1
  32. package/dist/STRINGS-Xxstm-7I.js +0 -7
  33. package/dist/STRINGS-Yl7cSWDc.cjs +0 -1
  34. package/dist/Topbar-CofpLWzO.cjs +0 -1
  35. package/dist/Topbar-xrdjosmc.js +0 -160
  36. package/dist/context-menu-0lRey9QY.cjs +0 -1
  37. package/dist/controls-lEwMTdPQ.js +0 -234
  38. package/dist/controls-p9IwFnPx.cjs +0 -1
  39. package/dist/index-CHYv1sC2.cjs +0 -63
  40. package/dist/index-s4RPN00p.js +0 -8540
  41. package/dist/plugin-UiUFs2fK.js +0 -44
  42. package/dist/plugin-f6SDZ_Or.js +0 -108
  43. package/dist/plugin-jum1MjXp.cjs +0 -1
  44. package/dist/plugin-xOpS-UNV.cjs +0 -1
package/dist/core.d.ts CHANGED
@@ -46,6 +46,8 @@ export declare function BlockPropsEditor(): JSX_2.Element;
46
46
 
47
47
  export declare function BlockStyleEditor(): JSX_2.Element;
48
48
 
49
+ declare type BorderRadiusValue = false | string;
50
+
49
51
  declare type Breakpoint = {
50
52
  title: string;
51
53
  content: string;
@@ -60,13 +62,13 @@ export declare const CHAI_BUILDER_EVENTS: {
60
62
  SHOW_BLOCK_SETTINGS: string;
61
63
  };
62
64
 
63
- export declare type ChaiBlock = {
65
+ export declare type ChaiBlock<T = Record<string, any>> = {
64
66
  _id: string;
65
- _type: string;
66
67
  _name?: string;
67
68
  _parent?: string | null | undefined;
68
69
  _bindings?: Record<string, string>;
69
- } & Record<string, any>;
70
+ _type: string;
71
+ } & T;
70
72
 
71
73
  export declare const ChaiBuilderCanvas: React_3.FC;
72
74
 
@@ -76,6 +78,9 @@ export declare const ChaiBuilderCanvas: React_3.FC;
76
78
  export declare const ChaiBuilderEditor: React_3.FC<ChaiBuilderEditorProps>;
77
79
 
78
80
  export declare interface ChaiBuilderEditorProps {
81
+ themePresets?: Record<string, Partial<ChaiBuilderThemeValues>>[];
82
+ themeOptions?: ChaiBuilderThemeOptions | ((defaultThemeOptions: ChaiBuilderThemeOptions) => ChaiBuilderThemeOptions);
83
+ theme?: Partial<ChaiBuilderThemeValues>;
79
84
  /**
80
85
  * onError callback function
81
86
  * @param error
@@ -159,7 +164,7 @@ export declare interface ChaiBuilderEditorProps {
159
164
  uiLibraries?: Omit<UILibrary, "blocks">[];
160
165
  getUILibraryBlocks?: (library: UILibrary) => Promise<UiLibraryBlock[]>;
161
166
  getUILibraryBlock?: (library: UILibrary, uiLibBlock: UiLibraryBlock) => Promise<ChaiBlock[]>;
162
- getRSCBlock?: (block: ChaiBlock) => Promise<string>;
167
+ getBlockAsyncProps?: (block: ChaiBlock) => Promise<string>;
163
168
  /**
164
169
  * Get Global blocks
165
170
  */
@@ -175,9 +180,7 @@ export declare interface ChaiBuilderEditorProps {
175
180
  * Blocks for the page
176
181
  */
177
182
  blocks?: ChaiBlock[];
178
- onSave?: ({ blocks, providers }: SavePageData) => Promise<boolean | Error>;
179
- brandingOptions?: Record<string, string>;
180
- theme?: Record<string, string>;
183
+ onSave?: ({ blocks, theme, autoSave }: SavePageData) => Promise<boolean | Error>;
181
184
  /**
182
185
  * onSaveStateChange callback function
183
186
  * @param syncStatus
@@ -210,14 +213,6 @@ export declare interface ChaiBuilderEditorProps {
210
213
  * Outline menu items
211
214
  */
212
215
  outlineMenuItems?: OutlineMenuItems;
213
- /**
214
- * Deprecated: getPages callback function. use collections instead
215
- */
216
- getPages?: () => Promise<ChaiPage[]>;
217
- /**
218
- * Unsplash access key
219
- */
220
- unsplashAccessKey?: string;
221
216
  _flags?: Record<string, boolean>;
222
217
  /**
223
218
  * Content locale
@@ -235,10 +230,19 @@ declare type ChaiBuilderInstance = {
235
230
  setBlocks: (blocks: ChaiBlock[]) => void;
236
231
  };
237
232
 
238
- declare type ChaiPage = {
239
- slug: string;
240
- uuid?: string;
241
- name?: string;
233
+ declare type ChaiBuilderThemeOptions = {
234
+ fontFamily: false | Record<VariableKey, string>;
235
+ borderRadius: BorderRadiusValue;
236
+ colors: false | {
237
+ group: string;
238
+ items: Record<VariableKey, [HSLColor, HSLColor]>;
239
+ }[];
240
+ };
241
+
242
+ declare type ChaiBuilderThemeValues = {
243
+ fontFamily: Record<string, string>;
244
+ borderRadius: string;
245
+ colors: Record<string, string[]>;
242
246
  };
243
247
 
244
248
  declare type ClassDerivedObject = {
@@ -274,11 +278,6 @@ declare type CopyFn = (text: string) => Promise<boolean>;
274
278
 
275
279
  export declare function DarkModeSwitcher(): JSX_2.Element;
276
280
 
277
- declare type DataProvider = {
278
- providerKey: string;
279
- args: Record<string, any>;
280
- };
281
-
282
281
  export declare const DefaultChaiBlocks: ({ parentId, gridCols }: {
283
282
  parentId?: string;
284
283
  gridCols?: string;
@@ -312,6 +311,8 @@ declare type GlobalBlockList = Record<string, {
312
311
  description?: string;
313
312
  }>;
314
313
 
314
+ declare type HSLColor = string;
315
+
315
316
  export { i18n }
316
317
 
317
318
  export declare const ImportHTML: ({ parentId }: {
@@ -342,17 +343,16 @@ declare type RichText = string;
342
343
  declare type SavePageData = {
343
344
  autoSave: boolean;
344
345
  blocks: ChaiBlock[];
345
- providers?: DataProvider[];
346
- brandingOptions?: Record<string, any>;
347
- themeConfiguration?: Record<string, any>;
346
+ theme?: Record<string, any>;
348
347
  };
349
348
 
350
349
  export declare const ScreenSizes: () => JSX_2.Element;
351
350
 
352
- export declare const ThemeOptions: ({ showHeading, className, }: {
351
+ declare interface ThemeConfigProps {
353
352
  className?: string;
354
- showHeading?: boolean;
355
- }) => React_2.JSX.Element;
353
+ }
354
+
355
+ export declare const ThemeOptions: React_2.FC<ThemeConfigProps>;
356
356
 
357
357
  declare type TimeInSeconds = number;
358
358
 
@@ -391,6 +391,12 @@ export declare const useAddBlock: () => AddBlocks;
391
391
 
392
392
  export declare const useAddClassesToBlocks: () => Function;
393
393
 
394
+ export declare const useAskAi: () => {
395
+ askAi: (type: "styles" | "content", blockId: string, prompt: string, onComplete?: (response?: AskAiResponse) => void) => Promise<void>;
396
+ loading: boolean;
397
+ error: any;
398
+ };
399
+
394
400
  export declare const useBlockHighlight: () => {
395
401
  highlightBlock: (blockId: string) => void;
396
402
  clearHighlight: () => void;
@@ -437,7 +443,7 @@ export declare const useCanvasZoom: () => [number, (args_0: number | typeof RESE
437
443
  */
438
444
  export declare const useCodeEditor: () => [CodeEditorProps, never];
439
445
 
440
- export declare const useCopyBlockIds: () => [Array<string>, Function];
446
+ export declare const useCopyBlockIds: () => [string[], (blockIds: Array<string>) => void];
441
447
 
442
448
  export declare const useCopyToClipboard: () => [CopiedValue, CopyFn];
443
449
 
@@ -485,8 +491,8 @@ export declare const useLanguages: () => {
485
491
  export declare const useLayoutVariant: () => readonly [LayoutVariant, (args_0: LayoutVariant | typeof RESET | ((prev: LayoutVariant) => LayoutVariant | typeof RESET)) => void];
486
492
 
487
493
  export declare const usePasteBlocks: () => {
488
- canPaste: (newParentId: string) => boolean;
489
- pasteBlocks: Function;
494
+ canPaste: (newParentId: string) => Promise<boolean>;
495
+ pasteBlocks: (newParentId: string | string[]) => Promise<void>;
490
496
  };
491
497
 
492
498
  /**
@@ -498,6 +504,8 @@ export declare const useRemoveBlocks: () => (blockIds: Array<string>) => void;
498
504
 
499
505
  export declare const useRemoveClassesFromBlocks: () => Function;
500
506
 
507
+ export declare const useRightPanel: () => ["theme" | "block" | "ai", (args_0: "theme" | "block" | "ai" | ((prev: "theme" | "block" | "ai") => "theme" | "block" | "ai")) => void];
508
+
501
509
  export declare const useSavePage: () => {
502
510
  savePage: ThrottledFunction<(autoSave?: boolean) => Promise<boolean>>;
503
511
  saveState: "UNSAVED" | "SAVED" | "SAVING";
@@ -516,7 +524,7 @@ export declare const useSelectedBlockCurrentClasses: () => Array<ClassDerivedObj
516
524
  /**
517
525
  *
518
526
  */
519
- export declare const useSelectedBlockIds: () => [Array<string>, Function, Function];
527
+ export declare const useSelectedBlockIds: () => readonly [string[], (args_0: string[] | ((prev: string[]) => string[])) => void, (blockId: string) => void];
520
528
 
521
529
  /**
522
530
  * Hook to get selected block ids
@@ -538,6 +546,18 @@ export declare const useStylingBreakpoint: () => [string, (args_0: string | type
538
546
 
539
547
  export declare const useStylingState: () => [unknown, (...args: unknown[]) => unknown];
540
548
 
549
+ export declare const useTheme: () => readonly [{
550
+ readonly fontFamily: Record<string, string>;
551
+ readonly borderRadius: string;
552
+ readonly colors: Record<string, string[]>;
553
+ } | {
554
+ fontFamily?: Record<string, string>;
555
+ borderRadius?: string;
556
+ colors?: Record<string, string[]>;
557
+ }, (args_0: ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues> | ((prev: ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues>) => ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues>)) => void];
558
+
559
+ export declare const useThemeOptions: () => ChaiBuilderThemeOptions;
560
+
541
561
  export { useTranslation }
542
562
 
543
563
  export declare const useUILibraryBlocks: () => {
@@ -561,4 +581,6 @@ export declare const useUpdateBlocksProps: () => (blockIds: Array<string>, props
561
581
 
562
582
  export declare const useUpdateBlocksPropsRealtime: () => (blockIds: Array<string>, props: Record<string, any>) => void;
563
583
 
584
+ declare type VariableKey = string;
585
+
564
586
  export { }