@chaibuilder/sdk 2.0.0-beta.5 → 2.0.0-beta.51

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