@chaibuilder/sdk 2.0.0-beta.7 → 2.0.0-beta.71

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 (53) hide show
  1. package/README.md +0 -4
  2. package/dist/ChaiThemeFn-Cort9tch.js +201 -0
  3. package/dist/ChaiThemeFn-DQu-2Eh9.cjs +13 -0
  4. package/dist/CodeEditor-B2x4yruH.cjs +1 -0
  5. package/dist/CodeEditor-VcQsGvTM.js +65 -0
  6. package/dist/Topbar-BQsjWb-A.js +16 -0
  7. package/dist/Topbar-DEw_kBMz.cjs +1 -0
  8. package/dist/chaibuilder-logo.png +0 -0
  9. package/dist/context-menu-C4lLV8gP.cjs +1 -0
  10. package/dist/{context-menu-I8woggB3.js → context-menu-D5ViOi6K.js} +260 -263
  11. package/dist/core.cjs +61 -1
  12. package/dist/core.d.ts +116 -54
  13. package/dist/core.js +8819 -123
  14. package/dist/getSplitClasses-DodqA_KW.cjs +1 -0
  15. package/dist/getSplitClasses-DphwgQiE.js +48 -0
  16. package/dist/{iconBase-Ief2hJUZ.js → iconBase-DHfFLkem.js} +6 -12
  17. package/dist/mockServiceWorker.js +39 -24
  18. package/dist/plugin-2xcljWGM.cjs +1 -0
  19. package/dist/plugin-kUMxtQR5.js +24 -0
  20. package/dist/render.cjs +2 -2
  21. package/dist/render.d.ts +35 -16
  22. package/dist/render.js +144 -134
  23. package/dist/runtime.cjs +1 -1
  24. package/dist/runtime.d.ts +0 -1
  25. package/dist/runtime.js +0 -20
  26. package/dist/{style.css → sdk.css} +1 -1
  27. package/dist/tailwind.cjs +1 -1
  28. package/dist/tailwind.d.ts +31 -26
  29. package/dist/tailwind.js +8 -10
  30. package/dist/ui.cjs +1 -1
  31. package/dist/ui.d.ts +6 -51
  32. package/dist/ui.js +210 -367
  33. package/dist/web-blocks.cjs +29 -2
  34. package/dist/web-blocks.js +1782 -831
  35. package/package.json +133 -132
  36. package/dist/CodeEditor-Bqjwy0VH.js +0 -127
  37. package/dist/CodeEditor-KUfhGPDN.cjs +0 -1
  38. package/dist/STRINGS-Xxstm-7I.js +0 -7
  39. package/dist/STRINGS-Yl7cSWDc.cjs +0 -1
  40. package/dist/Topbar-DQuMCOP6.cjs +0 -1
  41. package/dist/Topbar-g2pI6yGs.js +0 -161
  42. package/dist/context-menu-0lRey9QY.cjs +0 -1
  43. package/dist/controls-lEwMTdPQ.js +0 -234
  44. package/dist/controls-p9IwFnPx.cjs +0 -1
  45. package/dist/index-1_ZADyhv.js +0 -8554
  46. package/dist/index-QyeR27V9.cjs +0 -61
  47. package/dist/jsx-runtime-JYMCiFoE.cjs +0 -27
  48. package/dist/jsx-runtime-Sp0orL4X.js +0 -631
  49. package/dist/plugin-UiUFs2fK.js +0 -44
  50. package/dist/plugin-f6SDZ_Or.js +0 -108
  51. package/dist/plugin-jum1MjXp.cjs +0 -1
  52. package/dist/plugin-xOpS-UNV.cjs +0 -1
  53. /package/dist/{iconBase-aZzpqff_.cjs → iconBase-Cn2BsTrq.cjs} +0 -0
package/dist/core.d.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import { ChaiBlock as ChaiBlock_2 } from '@chaibuilder/runtime';
1
2
  import { ClassValue } from 'clsx';
2
- import i18n from 'i18next';
3
+ import { default as default_2 } from 'react';
4
+ import { default as i18n } from 'i18next';
3
5
  import { JSX as JSX_2 } from 'react/jsx-runtime';
4
6
  import * as React_2 from 'react';
5
- import { default as React_3 } from 'react';
6
7
  import { ReactNode } from 'react';
7
8
  import { registerChaiBlock } from '@chaibuilder/runtime';
8
9
  import { RESET } from 'jotai/utils';
@@ -16,10 +17,11 @@ declare type AddBlocks = {
16
17
 
17
18
  export declare const AddBlocksDialog: () => JSX_2.Element;
18
19
 
19
- export declare const AddBlocksPanel: ({ className, showHeading, parentId, }: {
20
+ export declare const AddBlocksPanel: ({ className, showHeading, parentId, position, }: {
20
21
  parentId?: string;
21
22
  showHeading?: boolean;
22
23
  className?: string;
24
+ position?: number;
23
25
  }) => JSX_2.Element;
24
26
 
25
27
  export declare const AISetContext: () => JSX_2.Element;
@@ -46,11 +48,13 @@ export declare function BlockPropsEditor(): JSX_2.Element;
46
48
 
47
49
  export declare function BlockStyleEditor(): JSX_2.Element;
48
50
 
51
+ declare type BorderRadiusValue = false | string;
52
+
49
53
  declare type Breakpoint = {
50
54
  title: string;
51
55
  content: string;
52
56
  breakpoint: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | string;
53
- icon: React_3.ReactNode | Element;
57
+ icon: default_2.ReactNode | Element;
54
58
  width: number;
55
59
  };
56
60
 
@@ -60,22 +64,36 @@ export declare const CHAI_BUILDER_EVENTS: {
60
64
  SHOW_BLOCK_SETTINGS: string;
61
65
  };
62
66
 
63
- export declare type ChaiBlock = {
67
+ export declare type ChaiBlock<T = Record<string, any>> = {
64
68
  _id: string;
65
- _type: string;
66
69
  _name?: string;
67
70
  _parent?: string | null | undefined;
68
71
  _bindings?: Record<string, string>;
69
- } & Record<string, any>;
72
+ _type: string;
73
+ } & T;
70
74
 
71
- export declare const ChaiBuilderCanvas: React_3.FC;
75
+ export declare const ChaiBuilderCanvas: default_2.FC;
72
76
 
73
77
  /**
74
78
  * ChaiBuilder is the main entry point for the Chai Builder Studio.
75
79
  */
76
- export declare const ChaiBuilderEditor: React_3.FC<ChaiBuilderEditorProps>;
80
+ export declare const ChaiBuilderEditor: default_2.FC<ChaiBuilderEditorProps>;
77
81
 
78
82
  export declare interface ChaiBuilderEditorProps {
83
+ /**
84
+ * RJSF Fields and Widgets
85
+ */
86
+ rjsfFields?: Record<string, default_2.ComponentType<any>>;
87
+ rjsfWidgets?: Record<string, default_2.ComponentType<any>>;
88
+ rjsfTemplates?: Record<string, default_2.ComponentType<any>>;
89
+ /**
90
+ * Optional pageId. If not provided, a random pageId will be generated
91
+ */
92
+ pageId?: string;
93
+ themePresets?: Record<string, Partial<ChaiBuilderThemeValues>>[];
94
+ themeOptions?: ChaiBuilderThemeOptions | ((defaultThemeOptions: ChaiBuilderThemeOptions) => ChaiBuilderThemeOptions);
95
+ theme?: Partial<ChaiBuilderThemeValues>;
96
+ themePanelComponent?: ReactComponentType;
79
97
  /**
80
98
  * onError callback function
81
99
  * @param error
@@ -93,7 +111,7 @@ export declare interface ChaiBuilderEditorProps {
93
111
  /**
94
112
  * Custom layout component
95
113
  */
96
- layout?: React_3.ComponentType;
114
+ layout?: default_2.ComponentType;
97
115
  /**
98
116
  * Layout variant. Not supported with custom layout
99
117
  */
@@ -101,9 +119,17 @@ export declare interface ChaiBuilderEditorProps {
101
119
  /**
102
120
  * Custom media Manager component
103
121
  */
104
- mediaManagerComponent?: React_3.ComponentType<{
122
+ mediaManagerComponent?: default_2.ComponentType<{
105
123
  onSelect: (url: string) => void;
106
124
  }>;
125
+ /**
126
+ * Add blocks dialog components
127
+ */
128
+ addBlocksDialogTabs?: {
129
+ key: string;
130
+ tab: ReactComponentType;
131
+ tabContent: ReactComponentType;
132
+ }[];
107
133
  /**
108
134
  * HTML direction.
109
135
  */
@@ -159,7 +185,7 @@ export declare interface ChaiBuilderEditorProps {
159
185
  uiLibraries?: Omit<UILibrary, "blocks">[];
160
186
  getUILibraryBlocks?: (library: UILibrary) => Promise<UiLibraryBlock[]>;
161
187
  getUILibraryBlock?: (library: UILibrary, uiLibBlock: UiLibraryBlock) => Promise<ChaiBlock[]>;
162
- getRSCBlock?: (block: ChaiBlock) => Promise<string>;
188
+ getBlockAsyncProps?: (block: ChaiBlock) => Promise<string>;
163
189
  /**
164
190
  * Get Global blocks
165
191
  */
@@ -175,9 +201,7 @@ export declare interface ChaiBuilderEditorProps {
175
201
  * Blocks for the page
176
202
  */
177
203
  blocks?: ChaiBlock[];
178
- onSave?: ({ blocks, providers }: SavePageData) => Promise<boolean | Error>;
179
- brandingOptions?: Record<string, string>;
180
- theme?: Record<string, string>;
204
+ onSave?: ({ blocks, theme, autoSave }: SavePageData) => Promise<boolean | Error>;
181
205
  /**
182
206
  * onSaveStateChange callback function
183
207
  * @param syncStatus
@@ -217,16 +241,31 @@ export declare interface ChaiBuilderEditorProps {
217
241
  fallbackLang?: string;
218
242
  languages?: Array<string>;
219
243
  /**
220
- * Collections props
244
+ * Page Types props
221
245
  */
222
- collections?: Collection[];
223
- searchCollectionItems?: (collectionKey: string, query: string) => Promise<CollectionItem[] | Error>;
246
+ pageTypes?: PageType[];
247
+ searchPageTypeItems?: (pageTypeKey: string, query: string) => Promise<PageTypeItem[] | Error>;
224
248
  }
225
249
 
226
250
  declare type ChaiBuilderInstance = {
227
251
  setBlocks: (blocks: ChaiBlock[]) => void;
228
252
  };
229
253
 
254
+ declare type ChaiBuilderThemeOptions = {
255
+ fontFamily: false | Record<VariableKey, string>;
256
+ borderRadius: BorderRadiusValue;
257
+ colors: false | {
258
+ group: string;
259
+ items: Record<VariableKey, [HSLColor, HSLColor]>;
260
+ }[];
261
+ };
262
+
263
+ declare type ChaiBuilderThemeValues = {
264
+ fontFamily: Record<string, string>;
265
+ borderRadius: string;
266
+ colors: Record<string, string[]>;
267
+ };
268
+
230
269
  declare type ClassDerivedObject = {
231
270
  cls: string;
232
271
  dark: boolean;
@@ -243,30 +282,15 @@ declare type CodeEditorProps = {
243
282
  placeholder?: string;
244
283
  };
245
284
 
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
285
  declare type CopiedValue = string | null;
258
286
 
259
287
  declare type CopyFn = (text: string) => Promise<boolean>;
260
288
 
261
289
  export declare function DarkModeSwitcher(): JSX_2.Element;
262
290
 
263
- declare type DataProvider = {
264
- providerKey: string;
265
- args: Record<string, any>;
266
- };
267
-
268
- export declare const DefaultChaiBlocks: ({ parentId, gridCols }: {
291
+ export declare const DefaultChaiBlocks: ({ parentId, position, gridCols, }: {
269
292
  parentId?: string;
293
+ position?: number;
270
294
  gridCols?: string;
271
295
  }) => JSX_2.Element;
272
296
 
@@ -298,10 +322,13 @@ declare type GlobalBlockList = Record<string, {
298
322
  description?: string;
299
323
  }>;
300
324
 
325
+ declare type HSLColor = string;
326
+
301
327
  export { i18n }
302
328
 
303
- export declare const ImportHTML: ({ parentId }: {
329
+ export declare const ImportHTML: ({ parentId, position }: {
304
330
  parentId?: string;
331
+ position?: number;
305
332
  }) => JSX_2.Element;
306
333
 
307
334
  declare type LayoutVariant = "SINGLE_SIDE_PANEL" | "DUAL_SIDE_PANEL" | "DUAL_SIDE_PANEL_ADVANCED";
@@ -311,7 +338,7 @@ export declare const mergeClasses: (...inputs: ClassValue[]) => string;
311
338
  export declare const Outline: () => JSX_2.Element;
312
339
 
313
340
  declare type OutlineMenuItem = {
314
- item: React_3.ComponentType<{
341
+ item: default_2.ComponentType<{
315
342
  blockId: string;
316
343
  }>;
317
344
  tooltip: string | ReactNode;
@@ -319,7 +346,18 @@ declare type OutlineMenuItem = {
319
346
 
320
347
  declare type OutlineMenuItems = OutlineMenuItem[];
321
348
 
322
- declare type ReactComponentType = React_3.ComponentType<any>;
349
+ declare type PageType = {
350
+ key: string;
351
+ name: string;
352
+ };
353
+
354
+ declare type PageTypeItem = {
355
+ id: string;
356
+ name: string;
357
+ slug?: string;
358
+ };
359
+
360
+ declare type ReactComponentType = default_2.ComponentType<any>;
323
361
 
324
362
  export { registerChaiBlock }
325
363
 
@@ -328,17 +366,16 @@ declare type RichText = string;
328
366
  declare type SavePageData = {
329
367
  autoSave: boolean;
330
368
  blocks: ChaiBlock[];
331
- providers?: DataProvider[];
332
- brandingOptions?: Record<string, any>;
333
- themeConfiguration?: Record<string, any>;
369
+ theme?: Record<string, any>;
334
370
  };
335
371
 
336
372
  export declare const ScreenSizes: () => JSX_2.Element;
337
373
 
338
- export declare const ThemeOptions: ({ showHeading, className, }: {
374
+ declare interface ThemeConfigProps {
339
375
  className?: string;
340
- showHeading?: boolean;
341
- }) => React_2.JSX.Element;
376
+ }
377
+
378
+ export declare const ThemeOptions: React_2.FC<ThemeConfigProps>;
342
379
 
343
380
  declare type TimeInSeconds = number;
344
381
 
@@ -348,8 +385,9 @@ declare type TStyleBlock = {
348
385
  prop: string;
349
386
  };
350
387
 
351
- export declare const UILibraries: ({ parentId }: {
388
+ export declare const UILibraries: ({ parentId, position }: {
352
389
  parentId?: string;
390
+ position?: number;
353
391
  }) => JSX_2.Element;
354
392
 
355
393
  declare interface UILibrary {
@@ -375,10 +413,16 @@ export declare const UndoRedo: () => JSX_2.Element;
375
413
 
376
414
  export declare const useAddBlock: () => AddBlocks;
377
415
 
378
- export declare const useAddClassesToBlocks: () => Function;
416
+ export declare const useAddClassesToBlocks: () => (blockIds: Array<string>, newClasses: Array<string>, undo?: boolean) => void;
417
+
418
+ export declare const useAskAi: () => {
419
+ askAi: (type: "styles" | "content", blockId: string, prompt: string, onComplete?: (response?: AskAiResponse) => void) => Promise<void>;
420
+ loading: boolean;
421
+ error: any;
422
+ };
379
423
 
380
424
  export declare const useBlockHighlight: () => {
381
- highlightBlock: (blockId: string) => void;
425
+ highlightBlock: (elementOrID: HTMLElement | string) => void;
382
426
  clearHighlight: () => void;
383
427
  lastHighlighted: HTMLElement;
384
428
  };
@@ -414,7 +458,7 @@ export declare const useCanvasWidth: () => [number, string, Function];
414
458
  /**
415
459
  * Wrapper hook around useAtom
416
460
  */
417
- export declare const useCanvasZoom: () => [number, (args_0: number | typeof RESET | ((prev: number) => number | typeof RESET)) => void];
461
+ export declare const useCanvasZoom: () => [number, (args_0: number | RESET | ((prev: number) => number | RESET)) => void];
418
462
 
419
463
  /**
420
464
  * Custom hook to access the current state of the code editor.
@@ -423,7 +467,7 @@ export declare const useCanvasZoom: () => [number, (args_0: number | typeof RESE
423
467
  */
424
468
  export declare const useCodeEditor: () => [CodeEditorProps, never];
425
469
 
426
- export declare const useCopyBlockIds: () => [Array<string>, Function];
470
+ export declare const useCopyBlockIds: () => [Array<string>, (blockIds: Array<string>) => void];
427
471
 
428
472
  export declare const useCopyToClipboard: () => [CopiedValue, CopyFn];
429
473
 
@@ -468,11 +512,11 @@ export declare const useLanguages: () => {
468
512
  setSelectedLang: (lang: string) => void;
469
513
  };
470
514
 
471
- export declare const useLayoutVariant: () => readonly [LayoutVariant, (args_0: LayoutVariant | typeof RESET | ((prev: LayoutVariant) => LayoutVariant | typeof RESET)) => void];
515
+ export declare const useLayoutVariant: () => readonly [LayoutVariant, (args_0: RESET | LayoutVariant | ((prev: LayoutVariant) => RESET | LayoutVariant)) => void];
472
516
 
473
517
  export declare const usePasteBlocks: () => {
474
- canPaste: (newParentId: string) => boolean;
475
- pasteBlocks: Function;
518
+ canPaste: (newParentId: string) => Promise<boolean>;
519
+ pasteBlocks: (newParentId: string | string[]) => Promise<void>;
476
520
  };
477
521
 
478
522
  /**
@@ -484,6 +528,8 @@ export declare const useRemoveBlocks: () => (blockIds: Array<string>) => void;
484
528
 
485
529
  export declare const useRemoveClassesFromBlocks: () => Function;
486
530
 
531
+ export declare const useRightPanel: () => ["theme" | "block" | "ai" | "settings", (args_0: "theme" | "block" | "ai" | "settings" | ((prev: "theme" | "block" | "ai" | "settings") => "theme" | "block" | "ai" | "settings")) => void];
532
+
487
533
  export declare const useSavePage: () => {
488
534
  savePage: ThrottledFunction<(autoSave?: boolean) => Promise<boolean>>;
489
535
  saveState: "UNSAVED" | "SAVED" | "SAVING";
@@ -502,7 +548,7 @@ export declare const useSelectedBlockCurrentClasses: () => Array<ClassDerivedObj
502
548
  /**
503
549
  *
504
550
  */
505
- export declare const useSelectedBlockIds: () => [Array<string>, Function, Function];
551
+ export declare const useSelectedBlockIds: () => readonly [string[], (args_0: string[] | ((prev: string[]) => string[])) => void, (blockId: string) => void];
506
552
 
507
553
  /**
508
554
  * Hook to get selected block ids
@@ -520,10 +566,22 @@ export declare const useSelectedBreakpoints: () => [string[], Function];
520
566
  */
521
567
  export declare const useSelectedStylingBlocks: () => [TStyleBlock[], (args_0: TStyleBlock[] | ((prev: TStyleBlock[]) => TStyleBlock[])) => void];
522
568
 
523
- export declare const useStylingBreakpoint: () => [string, (args_0: string | typeof RESET | ((prev: string) => string | typeof RESET)) => void];
569
+ export declare const useStylingBreakpoint: () => [string, (args_0: string | RESET | ((prev: string) => string | RESET)) => void];
524
570
 
525
571
  export declare const useStylingState: () => [unknown, (...args: unknown[]) => unknown];
526
572
 
573
+ export declare const useTheme: () => readonly [{
574
+ fontFamily: Record<string, string>;
575
+ borderRadius: string;
576
+ colors: Record<string, string[]>;
577
+ } | {
578
+ fontFamily?: Record<string, string>;
579
+ borderRadius?: string;
580
+ colors?: Record<string, string[]>;
581
+ }, (args_0: ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues> | ((prev: ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues>) => ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues>)) => void];
582
+
583
+ export declare const useThemeOptions: () => ChaiBuilderThemeOptions;
584
+
527
585
  export { useTranslation }
528
586
 
529
587
  export declare const useUILibraryBlocks: () => {
@@ -547,4 +605,8 @@ export declare const useUpdateBlocksProps: () => (blockIds: Array<string>, props
547
605
 
548
606
  export declare const useUpdateBlocksPropsRealtime: () => (blockIds: Array<string>, props: Record<string, any>) => void;
549
607
 
608
+ export declare const useWrapperBlock: () => ChaiBlock_2;
609
+
610
+ declare type VariableKey = string;
611
+
550
612
  export { }