@chaibuilder/sdk 2.0.0-beta.4 → 2.0.0-beta.41

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-Ba9O-eBT.js +201 -0
  3. package/dist/ChaiThemeFn-DQu-2Eh9.cjs +13 -0
  4. package/dist/CodeEditor-C5hkhszC.cjs +1 -0
  5. package/dist/CodeEditor-DmPiW1eD.js +77 -0
  6. package/dist/STRINGS-DtEft2kY.js +5 -0
  7. package/dist/STRINGS-n7COZtKr.cjs +1 -0
  8. package/dist/Topbar-XpkgGUK2.js +16 -0
  9. package/dist/Topbar-Zby0BmoN.cjs +1 -0
  10. package/dist/{context-menu-I8woggB3.js → context-menu-BsI3Hqio.js} +66 -66
  11. package/dist/{context-menu-0lRey9QY.cjs → context-menu-dsqhw1Ub.cjs} +1 -1
  12. package/dist/core.cjs +302 -1
  13. package/dist/core.d.ts +121 -81
  14. package/dist/core.js +33563 -122
  15. package/dist/{iconBase-Ief2hJUZ.js → iconBase-DHfFLkem.js} +6 -12
  16. package/dist/jsx-runtime-DGh1k5sI.cjs +31 -0
  17. package/dist/jsx-runtime-Dx-03ztt.js +445 -0
  18. package/dist/mockServiceWorker.js +39 -24
  19. package/dist/plugin-2xcljWGM.cjs +1 -0
  20. package/dist/plugin-Bvqh40K5.js +24 -0
  21. package/dist/render.cjs +2 -2
  22. package/dist/render.d.ts +36 -18
  23. package/dist/render.js +127 -127
  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 +5 -7
  31. package/dist/ui.cjs +1 -1
  32. package/dist/ui.d.ts +59 -68
  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 +105 -119
  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/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,8 @@
1
1
  import { ClassValue } from 'clsx';
2
- import i18n from 'i18next';
3
- import { JSX as JSX_2 } from 'react/jsx-runtime';
2
+ import { default as default_2 } from 'react';
3
+ import { default as i18n } from 'i18next';
4
+ import { JSX } 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';
@@ -14,19 +14,20 @@ declare type AddBlocks = {
14
14
  addPredefinedBlock: any;
15
15
  };
16
16
 
17
- export declare const AddBlocksDialog: () => JSX_2.Element;
17
+ export declare const AddBlocksDialog: () => JSX.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
- }) => JSX_2.Element;
23
+ position?: number;
24
+ }) => JSX.Element;
24
25
 
25
- export declare const AISetContext: () => JSX_2.Element;
26
+ export declare const AISetContext: () => JSX.Element;
26
27
 
27
28
  export declare const AIUserPrompt: ({ blockId }: {
28
29
  blockId: string | undefined;
29
- }) => JSX_2.Element;
30
+ }) => JSX.Element;
30
31
 
31
32
  declare type AskAiResponse = {
32
33
  blocks?: Array<{
@@ -36,21 +37,23 @@ declare type AskAiResponse = {
36
37
  error?: any;
37
38
  };
38
39
 
39
- export declare const BlockAttributesEditor: React_2.MemoExoticComponent<() => JSX_2.Element>;
40
+ export declare const BlockAttributesEditor: React_2.MemoExoticComponent<() => JSX.Element>;
40
41
 
41
42
  /**
42
43
  *
43
44
  * @returns Block Setting
44
45
  */
45
- export declare function BlockPropsEditor(): JSX_2.Element;
46
+ export declare function BlockPropsEditor(): JSX.Element;
46
47
 
47
- export declare function BlockStyleEditor(): JSX_2.Element;
48
+ export declare function BlockStyleEditor(): JSX.Element;
49
+
50
+ declare type BorderRadiusValue = false | string;
48
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,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
- } & 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
+ * 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?: React_3.ComponentType;
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?: React_3.ComponentType<{
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
- getRSCBlock?: (block: ChaiBlock) => Promise<string>;
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, providers }: SavePageData) => Promise<boolean | Error>;
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
@@ -210,14 +226,6 @@ export declare interface ChaiBuilderEditorProps {
210
226
  * Outline menu items
211
227
  */
212
228
  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
229
  _flags?: Record<string, boolean>;
222
230
  /**
223
231
  * Content locale
@@ -225,20 +233,29 @@ export declare interface ChaiBuilderEditorProps {
225
233
  fallbackLang?: string;
226
234
  languages?: Array<string>;
227
235
  /**
228
- * Collections props
236
+ * Page Types props
229
237
  */
230
- collections?: Collection[];
231
- searchCollectionItems?: (collectionKey: string, query: string) => Promise<CollectionItem[] | Error>;
238
+ pageTypes?: PageType[];
239
+ searchPageTypeItems?: (pageTypeKey: string, query: string) => Promise<PageTypeItem[] | Error>;
232
240
  }
233
241
 
234
242
  declare type ChaiBuilderInstance = {
235
243
  setBlocks: (blocks: ChaiBlock[]) => void;
236
244
  };
237
245
 
238
- declare type ChaiPage = {
239
- slug: string;
240
- uuid?: string;
241
- name?: string;
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[]>;
242
259
  };
243
260
 
244
261
  declare type ClassDerivedObject = {
@@ -257,32 +274,17 @@ declare type CodeEditorProps = {
257
274
  placeholder?: string;
258
275
  };
259
276
 
260
- declare type Collection = {
261
- key: string;
262
- name: string;
263
- };
264
-
265
- declare type CollectionItem = {
266
- id: string;
267
- name: string;
268
- slug?: string;
269
- };
270
-
271
277
  declare type CopiedValue = string | null;
272
278
 
273
279
  declare type CopyFn = (text: string) => Promise<boolean>;
274
280
 
275
- export declare function DarkModeSwitcher(): JSX_2.Element;
281
+ export declare function DarkModeSwitcher(): JSX.Element;
276
282
 
277
- declare type DataProvider = {
278
- providerKey: string;
279
- args: Record<string, any>;
280
- };
281
-
282
- export declare const DefaultChaiBlocks: ({ parentId, gridCols }: {
283
+ export declare const DefaultChaiBlocks: ({ parentId, position, gridCols, }: {
283
284
  parentId?: string;
285
+ position?: number;
284
286
  gridCols?: string;
285
- }) => JSX_2.Element;
287
+ }) => JSX.Element;
286
288
 
287
289
  declare type ExcludedBuilderProps = "blocks" | "subPages" | "brandingOptions" | "dataProviders";
288
290
 
@@ -312,20 +314,23 @@ declare type GlobalBlockList = Record<string, {
312
314
  description?: string;
313
315
  }>;
314
316
 
317
+ declare type HSLColor = string;
318
+
315
319
  export { i18n }
316
320
 
317
- export declare const ImportHTML: ({ parentId }: {
321
+ export declare const ImportHTML: ({ parentId, position }: {
318
322
  parentId?: string;
319
- }) => JSX_2.Element;
323
+ position?: number;
324
+ }) => JSX.Element;
320
325
 
321
326
  declare type LayoutVariant = "SINGLE_SIDE_PANEL" | "DUAL_SIDE_PANEL" | "DUAL_SIDE_PANEL_ADVANCED";
322
327
 
323
328
  export declare const mergeClasses: (...inputs: ClassValue[]) => string;
324
329
 
325
- export declare const Outline: () => JSX_2.Element;
330
+ export declare const Outline: () => JSX.Element;
326
331
 
327
332
  declare type OutlineMenuItem = {
328
- item: React_3.ComponentType<{
333
+ item: default_2.ComponentType<{
329
334
  blockId: string;
330
335
  }>;
331
336
  tooltip: string | ReactNode;
@@ -333,7 +338,18 @@ declare type OutlineMenuItem = {
333
338
 
334
339
  declare type OutlineMenuItems = OutlineMenuItem[];
335
340
 
336
- declare type ReactComponentType = React_3.ComponentType<any>;
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>;
337
353
 
338
354
  export { registerChaiBlock }
339
355
 
@@ -342,17 +358,16 @@ declare type RichText = string;
342
358
  declare type SavePageData = {
343
359
  autoSave: boolean;
344
360
  blocks: ChaiBlock[];
345
- providers?: DataProvider[];
346
- brandingOptions?: Record<string, any>;
347
- themeConfiguration?: Record<string, any>;
361
+ theme?: Record<string, any>;
348
362
  };
349
363
 
350
- export declare const ScreenSizes: () => JSX_2.Element;
364
+ export declare const ScreenSizes: () => JSX.Element;
351
365
 
352
- export declare const ThemeOptions: ({ showHeading, className, }: {
366
+ declare interface ThemeConfigProps {
353
367
  className?: string;
354
- showHeading?: boolean;
355
- }) => React_2.JSX.Element;
368
+ }
369
+
370
+ export declare const ThemeOptions: React_2.FC<ThemeConfigProps>;
356
371
 
357
372
  declare type TimeInSeconds = number;
358
373
 
@@ -362,9 +377,10 @@ declare type TStyleBlock = {
362
377
  prop: string;
363
378
  };
364
379
 
365
- export declare const UILibraries: ({ parentId }: {
380
+ export declare const UILibraries: ({ parentId, position }: {
366
381
  parentId?: string;
367
- }) => JSX_2.Element;
382
+ position?: number;
383
+ }) => JSX.Element;
368
384
 
369
385
  declare interface UILibrary {
370
386
  uuid: string;
@@ -385,14 +401,20 @@ declare type UiLibraryBlock = {
385
401
  description?: string;
386
402
  };
387
403
 
388
- export declare const UndoRedo: () => JSX_2.Element;
404
+ export declare const UndoRedo: () => JSX.Element;
389
405
 
390
406
  export declare const useAddBlock: () => AddBlocks;
391
407
 
392
- export declare const useAddClassesToBlocks: () => Function;
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
+ };
393
415
 
394
416
  export declare const useBlockHighlight: () => {
395
- highlightBlock: (blockId: string) => void;
417
+ highlightBlock: (elementOrID: HTMLElement | string) => void;
396
418
  clearHighlight: () => void;
397
419
  lastHighlighted: HTMLElement;
398
420
  };
@@ -428,7 +450,7 @@ export declare const useCanvasWidth: () => [number, string, Function];
428
450
  /**
429
451
  * Wrapper hook around useAtom
430
452
  */
431
- export declare const useCanvasZoom: () => [number, (args_0: number | typeof RESET | ((prev: number) => number | typeof RESET)) => void];
453
+ export declare const useCanvasZoom: () => [number, (args_0: number | RESET | ((prev: number) => number | RESET)) => void];
432
454
 
433
455
  /**
434
456
  * Custom hook to access the current state of the code editor.
@@ -437,7 +459,7 @@ export declare const useCanvasZoom: () => [number, (args_0: number | typeof RESE
437
459
  */
438
460
  export declare const useCodeEditor: () => [CodeEditorProps, never];
439
461
 
440
- export declare const useCopyBlockIds: () => [Array<string>, Function];
462
+ export declare const useCopyBlockIds: () => [Array<string>, (blockIds: Array<string>) => void];
441
463
 
442
464
  export declare const useCopyToClipboard: () => [CopiedValue, CopyFn];
443
465
 
@@ -482,11 +504,11 @@ export declare const useLanguages: () => {
482
504
  setSelectedLang: (lang: string) => void;
483
505
  };
484
506
 
485
- export declare const useLayoutVariant: () => readonly [LayoutVariant, (args_0: LayoutVariant | typeof RESET | ((prev: LayoutVariant) => LayoutVariant | typeof RESET)) => void];
507
+ export declare const useLayoutVariant: () => readonly [LayoutVariant, (args_0: LayoutVariant | RESET | ((prev: LayoutVariant) => LayoutVariant | RESET)) => void];
486
508
 
487
509
  export declare const usePasteBlocks: () => {
488
- canPaste: (newParentId: string) => boolean;
489
- pasteBlocks: Function;
510
+ canPaste: (newParentId: string) => Promise<boolean>;
511
+ pasteBlocks: (newParentId: string | string[]) => Promise<void>;
490
512
  };
491
513
 
492
514
  /**
@@ -498,6 +520,8 @@ export declare const useRemoveBlocks: () => (blockIds: Array<string>) => void;
498
520
 
499
521
  export declare const useRemoveClassesFromBlocks: () => Function;
500
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
+
501
525
  export declare const useSavePage: () => {
502
526
  savePage: ThrottledFunction<(autoSave?: boolean) => Promise<boolean>>;
503
527
  saveState: "UNSAVED" | "SAVED" | "SAVING";
@@ -516,7 +540,7 @@ export declare const useSelectedBlockCurrentClasses: () => Array<ClassDerivedObj
516
540
  /**
517
541
  *
518
542
  */
519
- export declare const useSelectedBlockIds: () => [Array<string>, Function, Function];
543
+ export declare const useSelectedBlockIds: () => readonly [string[], (args_0: string[] | ((prev: string[]) => string[])) => void, (blockId: string) => void];
520
544
 
521
545
  /**
522
546
  * Hook to get selected block ids
@@ -534,10 +558,22 @@ export declare const useSelectedBreakpoints: () => [string[], Function];
534
558
  */
535
559
  export declare const useSelectedStylingBlocks: () => [TStyleBlock[], (args_0: TStyleBlock[] | ((prev: TStyleBlock[]) => TStyleBlock[])) => void];
536
560
 
537
- export declare const useStylingBreakpoint: () => [string, (args_0: string | typeof RESET | ((prev: string) => string | typeof RESET)) => void];
561
+ export declare const useStylingBreakpoint: () => [string, (args_0: string | RESET | ((prev: string) => string | RESET)) => void];
538
562
 
539
563
  export declare const useStylingState: () => [unknown, (...args: unknown[]) => unknown];
540
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
+
541
577
  export { useTranslation }
542
578
 
543
579
  export declare const useUILibraryBlocks: () => {
@@ -561,4 +597,8 @@ export declare const useUpdateBlocksProps: () => (blockIds: Array<string>, props
561
597
 
562
598
  export declare const useUpdateBlocksPropsRealtime: () => (blockIds: Array<string>, props: Record<string, any>) => void;
563
599
 
600
+ export declare const useWrapperBlock: () => any;
601
+
602
+ declare type VariableKey = string;
603
+
564
604
  export { }