@chaibuilder/sdk 2.0.0-beta.8 → 2.0.0-beta.80

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 (54) hide show
  1. package/README.md +1 -3
  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 +123 -54
  13. package/dist/core.js +8856 -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 +41 -16
  22. package/dist/render.js +166 -139
  23. package/dist/runtime.cjs +1 -1
  24. package/dist/runtime.d.ts +6 -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 +37 -26
  29. package/dist/tailwind.js +8 -10
  30. package/dist/ui.cjs +1 -1
  31. package/dist/ui.d.ts +12 -51
  32. package/dist/ui.js +210 -367
  33. package/dist/web-blocks.cjs +2 -2
  34. package/dist/web-blocks.d.ts +6 -0
  35. package/dist/web-blocks.js +1230 -813
  36. package/package.json +135 -132
  37. package/dist/CodeEditor-BUKZyPNe.js +0 -127
  38. package/dist/CodeEditor-RngMJDM5.cjs +0 -1
  39. package/dist/STRINGS-Xxstm-7I.js +0 -7
  40. package/dist/STRINGS-Yl7cSWDc.cjs +0 -1
  41. package/dist/Topbar-34AjGxOm.js +0 -161
  42. package/dist/Topbar-s6yma9af.cjs +0 -1
  43. package/dist/context-menu-0lRey9QY.cjs +0 -1
  44. package/dist/controls-lEwMTdPQ.js +0 -234
  45. package/dist/controls-p9IwFnPx.cjs +0 -1
  46. package/dist/index-IE-FmPVl.cjs +0 -61
  47. package/dist/index-eXQ8lngR.js +0 -8554
  48. package/dist/jsx-runtime-JYMCiFoE.cjs +0 -27
  49. package/dist/jsx-runtime-Sp0orL4X.js +0 -631
  50. package/dist/plugin-UiUFs2fK.js +0 -44
  51. package/dist/plugin-f6SDZ_Or.js +0 -108
  52. package/dist/plugin-jum1MjXp.cjs +0 -1
  53. package/dist/plugin-xOpS-UNV.cjs +0 -1
  54. /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,37 @@ 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
+ pageExternalData?: Record<string, any>;
94
+ themePresets?: Record<string, Partial<ChaiBuilderThemeValues>>[];
95
+ themeOptions?: ChaiBuilderThemeOptions | ((defaultThemeOptions: ChaiBuilderThemeOptions) => ChaiBuilderThemeOptions);
96
+ theme?: Partial<ChaiBuilderThemeValues>;
97
+ themePanelComponent?: ReactComponentType;
79
98
  /**
80
99
  * onError callback function
81
100
  * @param error
@@ -93,7 +112,7 @@ export declare interface ChaiBuilderEditorProps {
93
112
  /**
94
113
  * Custom layout component
95
114
  */
96
- layout?: React_3.ComponentType;
115
+ layout?: default_2.ComponentType;
97
116
  /**
98
117
  * Layout variant. Not supported with custom layout
99
118
  */
@@ -101,9 +120,17 @@ export declare interface ChaiBuilderEditorProps {
101
120
  /**
102
121
  * Custom media Manager component
103
122
  */
104
- mediaManagerComponent?: React_3.ComponentType<{
123
+ mediaManagerComponent?: default_2.ComponentType<{
105
124
  onSelect: (url: string) => void;
106
125
  }>;
126
+ /**
127
+ * Add blocks dialog components
128
+ */
129
+ addBlocksDialogTabs?: {
130
+ key: string;
131
+ tab: ReactComponentType;
132
+ tabContent: ReactComponentType;
133
+ }[];
107
134
  /**
108
135
  * HTML direction.
109
136
  */
@@ -159,7 +186,7 @@ export declare interface ChaiBuilderEditorProps {
159
186
  uiLibraries?: Omit<UILibrary, "blocks">[];
160
187
  getUILibraryBlocks?: (library: UILibrary) => Promise<UiLibraryBlock[]>;
161
188
  getUILibraryBlock?: (library: UILibrary, uiLibBlock: UiLibraryBlock) => Promise<ChaiBlock[]>;
162
- getRSCBlock?: (block: ChaiBlock) => Promise<string>;
189
+ getBlockAsyncProps?: (block: ChaiBlock) => Promise<string>;
163
190
  /**
164
191
  * Get Global blocks
165
192
  */
@@ -175,9 +202,7 @@ export declare interface ChaiBuilderEditorProps {
175
202
  * Blocks for the page
176
203
  */
177
204
  blocks?: ChaiBlock[];
178
- onSave?: ({ blocks, providers }: SavePageData) => Promise<boolean | Error>;
179
- brandingOptions?: Record<string, string>;
180
- theme?: Record<string, string>;
205
+ onSave?: ({ blocks, theme, autoSave }: SavePageData) => Promise<boolean | Error>;
181
206
  /**
182
207
  * onSaveStateChange callback function
183
208
  * @param syncStatus
@@ -217,16 +242,31 @@ export declare interface ChaiBuilderEditorProps {
217
242
  fallbackLang?: string;
218
243
  languages?: Array<string>;
219
244
  /**
220
- * Collections props
245
+ * Page Types props
221
246
  */
222
- collections?: Collection[];
223
- searchCollectionItems?: (collectionKey: string, query: string) => Promise<CollectionItem[] | Error>;
247
+ pageTypes?: PageType[];
248
+ searchPageTypeItems?: (pageTypeKey: string, query: string) => Promise<PageTypeItem[] | Error>;
224
249
  }
225
250
 
226
251
  declare type ChaiBuilderInstance = {
227
252
  setBlocks: (blocks: ChaiBlock[]) => void;
228
253
  };
229
254
 
255
+ declare type ChaiBuilderThemeOptions = {
256
+ fontFamily: false | Record<VariableKey, string>;
257
+ borderRadius: BorderRadiusValue;
258
+ colors: false | {
259
+ group: string;
260
+ items: Record<VariableKey, [HSLColor, HSLColor]>;
261
+ }[];
262
+ };
263
+
264
+ declare type ChaiBuilderThemeValues = {
265
+ fontFamily: Record<string, string>;
266
+ borderRadius: string;
267
+ colors: Record<string, string[]>;
268
+ };
269
+
230
270
  declare type ClassDerivedObject = {
231
271
  cls: string;
232
272
  dark: boolean;
@@ -243,30 +283,15 @@ declare type CodeEditorProps = {
243
283
  placeholder?: string;
244
284
  };
245
285
 
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
286
  declare type CopiedValue = string | null;
258
287
 
259
288
  declare type CopyFn = (text: string) => Promise<boolean>;
260
289
 
261
290
  export declare function DarkModeSwitcher(): JSX_2.Element;
262
291
 
263
- declare type DataProvider = {
264
- providerKey: string;
265
- args: Record<string, any>;
266
- };
267
-
268
- export declare const DefaultChaiBlocks: ({ parentId, gridCols }: {
292
+ export declare const DefaultChaiBlocks: ({ parentId, position, gridCols, }: {
269
293
  parentId?: string;
294
+ position?: number;
270
295
  gridCols?: string;
271
296
  }) => JSX_2.Element;
272
297
 
@@ -298,10 +323,13 @@ declare type GlobalBlockList = Record<string, {
298
323
  description?: string;
299
324
  }>;
300
325
 
326
+ declare type HSLColor = string;
327
+
301
328
  export { i18n }
302
329
 
303
- export declare const ImportHTML: ({ parentId }: {
330
+ export declare const ImportHTML: ({ parentId, position }: {
304
331
  parentId?: string;
332
+ position?: number;
305
333
  }) => JSX_2.Element;
306
334
 
307
335
  declare type LayoutVariant = "SINGLE_SIDE_PANEL" | "DUAL_SIDE_PANEL" | "DUAL_SIDE_PANEL_ADVANCED";
@@ -311,7 +339,7 @@ export declare const mergeClasses: (...inputs: ClassValue[]) => string;
311
339
  export declare const Outline: () => JSX_2.Element;
312
340
 
313
341
  declare type OutlineMenuItem = {
314
- item: React_3.ComponentType<{
342
+ item: default_2.ComponentType<{
315
343
  blockId: string;
316
344
  }>;
317
345
  tooltip: string | ReactNode;
@@ -319,7 +347,18 @@ declare type OutlineMenuItem = {
319
347
 
320
348
  declare type OutlineMenuItems = OutlineMenuItem[];
321
349
 
322
- declare type ReactComponentType = React_3.ComponentType<any>;
350
+ declare type PageType = {
351
+ key: string;
352
+ name: string;
353
+ };
354
+
355
+ declare type PageTypeItem = {
356
+ id: string;
357
+ name: string;
358
+ slug?: string;
359
+ };
360
+
361
+ declare type ReactComponentType = default_2.ComponentType<any>;
323
362
 
324
363
  export { registerChaiBlock }
325
364
 
@@ -328,17 +367,16 @@ declare type RichText = string;
328
367
  declare type SavePageData = {
329
368
  autoSave: boolean;
330
369
  blocks: ChaiBlock[];
331
- providers?: DataProvider[];
332
- brandingOptions?: Record<string, any>;
333
- themeConfiguration?: Record<string, any>;
370
+ theme?: Record<string, any>;
334
371
  };
335
372
 
336
373
  export declare const ScreenSizes: () => JSX_2.Element;
337
374
 
338
- export declare const ThemeOptions: ({ showHeading, className, }: {
375
+ declare interface ThemeConfigProps {
339
376
  className?: string;
340
- showHeading?: boolean;
341
- }) => React_2.JSX.Element;
377
+ }
378
+
379
+ export declare const ThemeOptions: React_2.FC<ThemeConfigProps>;
342
380
 
343
381
  declare type TimeInSeconds = number;
344
382
 
@@ -348,8 +386,9 @@ declare type TStyleBlock = {
348
386
  prop: string;
349
387
  };
350
388
 
351
- export declare const UILibraries: ({ parentId }: {
389
+ export declare const UILibraries: ({ parentId, position }: {
352
390
  parentId?: string;
391
+ position?: number;
353
392
  }) => JSX_2.Element;
354
393
 
355
394
  declare interface UILibrary {
@@ -375,10 +414,16 @@ export declare const UndoRedo: () => JSX_2.Element;
375
414
 
376
415
  export declare const useAddBlock: () => AddBlocks;
377
416
 
378
- export declare const useAddClassesToBlocks: () => Function;
417
+ export declare const useAddClassesToBlocks: () => (blockIds: Array<string>, newClasses: Array<string>, undo?: boolean) => void;
418
+
419
+ export declare const useAskAi: () => {
420
+ askAi: (type: "styles" | "content", blockId: string, prompt: string, onComplete?: (response?: AskAiResponse) => void) => Promise<void>;
421
+ loading: boolean;
422
+ error: any;
423
+ };
379
424
 
380
425
  export declare const useBlockHighlight: () => {
381
- highlightBlock: (blockId: string) => void;
426
+ highlightBlock: (elementOrID: HTMLElement | string) => void;
382
427
  clearHighlight: () => void;
383
428
  lastHighlighted: HTMLElement;
384
429
  };
@@ -414,7 +459,7 @@ export declare const useCanvasWidth: () => [number, string, Function];
414
459
  /**
415
460
  * Wrapper hook around useAtom
416
461
  */
417
- export declare const useCanvasZoom: () => [number, (args_0: number | typeof RESET | ((prev: number) => number | typeof RESET)) => void];
462
+ export declare const useCanvasZoom: () => [number, (args_0: number | RESET | ((prev: number) => number | RESET)) => void];
418
463
 
419
464
  /**
420
465
  * Custom hook to access the current state of the code editor.
@@ -423,7 +468,7 @@ export declare const useCanvasZoom: () => [number, (args_0: number | typeof RESE
423
468
  */
424
469
  export declare const useCodeEditor: () => [CodeEditorProps, never];
425
470
 
426
- export declare const useCopyBlockIds: () => [Array<string>, Function];
471
+ export declare const useCopyBlockIds: () => [Array<string>, (blockIds: Array<string>) => void];
427
472
 
428
473
  export declare const useCopyToClipboard: () => [CopiedValue, CopyFn];
429
474
 
@@ -468,11 +513,11 @@ export declare const useLanguages: () => {
468
513
  setSelectedLang: (lang: string) => void;
469
514
  };
470
515
 
471
- export declare const useLayoutVariant: () => readonly [LayoutVariant, (args_0: LayoutVariant | typeof RESET | ((prev: LayoutVariant) => LayoutVariant | typeof RESET)) => void];
516
+ export declare const useLayoutVariant: () => readonly [LayoutVariant, (args_0: RESET | LayoutVariant | ((prev: LayoutVariant) => RESET | LayoutVariant)) => void];
472
517
 
473
518
  export declare const usePasteBlocks: () => {
474
- canPaste: (newParentId: string) => boolean;
475
- pasteBlocks: Function;
519
+ canPaste: (newParentId: string) => Promise<boolean>;
520
+ pasteBlocks: (newParentId: string | string[]) => Promise<void>;
476
521
  };
477
522
 
478
523
  /**
@@ -484,6 +529,8 @@ export declare const useRemoveBlocks: () => (blockIds: Array<string>) => void;
484
529
 
485
530
  export declare const useRemoveClassesFromBlocks: () => Function;
486
531
 
532
+ export declare const useRightPanel: () => ["theme" | "block" | "ai" | "settings", (args_0: "theme" | "block" | "ai" | "settings" | ((prev: "theme" | "block" | "ai" | "settings") => "theme" | "block" | "ai" | "settings")) => void];
533
+
487
534
  export declare const useSavePage: () => {
488
535
  savePage: ThrottledFunction<(autoSave?: boolean) => Promise<boolean>>;
489
536
  saveState: "UNSAVED" | "SAVED" | "SAVING";
@@ -502,7 +549,7 @@ export declare const useSelectedBlockCurrentClasses: () => Array<ClassDerivedObj
502
549
  /**
503
550
  *
504
551
  */
505
- export declare const useSelectedBlockIds: () => [Array<string>, Function, Function];
552
+ export declare const useSelectedBlockIds: () => readonly [string[], (args_0: string[] | ((prev: string[]) => string[])) => void, (blockId: string) => void];
506
553
 
507
554
  /**
508
555
  * Hook to get selected block ids
@@ -520,10 +567,22 @@ export declare const useSelectedBreakpoints: () => [string[], Function];
520
567
  */
521
568
  export declare const useSelectedStylingBlocks: () => [TStyleBlock[], (args_0: TStyleBlock[] | ((prev: TStyleBlock[]) => TStyleBlock[])) => void];
522
569
 
523
- export declare const useStylingBreakpoint: () => [string, (args_0: string | typeof RESET | ((prev: string) => string | typeof RESET)) => void];
570
+ export declare const useStylingBreakpoint: () => [string, (args_0: string | RESET | ((prev: string) => string | RESET)) => void];
524
571
 
525
572
  export declare const useStylingState: () => [unknown, (...args: unknown[]) => unknown];
526
573
 
574
+ export declare const useTheme: () => readonly [{
575
+ fontFamily: Record<string, string>;
576
+ borderRadius: string;
577
+ colors: Record<string, string[]>;
578
+ } | {
579
+ fontFamily?: Record<string, string>;
580
+ borderRadius?: string;
581
+ colors?: Record<string, string[]>;
582
+ }, (args_0: ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues> | ((prev: ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues>) => ChaiBuilderThemeValues | Partial<ChaiBuilderThemeValues>)) => void];
583
+
584
+ export declare const useThemeOptions: () => ChaiBuilderThemeOptions;
585
+
527
586
  export { useTranslation }
528
587
 
529
588
  export declare const useUILibraryBlocks: () => {
@@ -547,4 +606,14 @@ export declare const useUpdateBlocksProps: () => (blockIds: Array<string>, props
547
606
 
548
607
  export declare const useUpdateBlocksPropsRealtime: () => (blockIds: Array<string>, props: Record<string, any>) => void;
549
608
 
609
+ export declare const useWrapperBlock: () => ChaiBlock_2;
610
+
611
+ declare type VariableKey = string;
612
+
550
613
  export { }
614
+
615
+ declare global {
616
+ interface Window {
617
+ clarity: any;
618
+ }
619
+ }