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

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 +108 -54
  14. package/dist/core.js +8687 -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,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
@@ -217,16 +233,31 @@ export declare interface ChaiBuilderEditorProps {
217
233
  fallbackLang?: string;
218
234
  languages?: Array<string>;
219
235
  /**
220
- * Collections props
236
+ * Page Types props
221
237
  */
222
- collections?: Collection[];
223
- searchCollectionItems?: (collectionKey: string, query: string) => Promise<CollectionItem[] | Error>;
238
+ pageTypes?: PageType[];
239
+ searchPageTypeItems?: (pageTypeKey: string, query: string) => Promise<PageTypeItem[] | Error>;
224
240
  }
225
241
 
226
242
  declare type ChaiBuilderInstance = {
227
243
  setBlocks: (blocks: ChaiBlock[]) => void;
228
244
  };
229
245
 
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[]>;
259
+ };
260
+
230
261
  declare type ClassDerivedObject = {
231
262
  cls: string;
232
263
  dark: boolean;
@@ -243,30 +274,15 @@ declare type CodeEditorProps = {
243
274
  placeholder?: string;
244
275
  };
245
276
 
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
277
  declare type CopiedValue = string | null;
258
278
 
259
279
  declare type CopyFn = (text: string) => Promise<boolean>;
260
280
 
261
281
  export declare function DarkModeSwitcher(): JSX_2.Element;
262
282
 
263
- declare type DataProvider = {
264
- providerKey: string;
265
- args: Record<string, any>;
266
- };
267
-
268
- export declare const DefaultChaiBlocks: ({ parentId, gridCols }: {
283
+ export declare const DefaultChaiBlocks: ({ parentId, position, gridCols, }: {
269
284
  parentId?: string;
285
+ position?: number;
270
286
  gridCols?: string;
271
287
  }) => JSX_2.Element;
272
288
 
@@ -298,10 +314,13 @@ declare type GlobalBlockList = Record<string, {
298
314
  description?: string;
299
315
  }>;
300
316
 
317
+ declare type HSLColor = string;
318
+
301
319
  export { i18n }
302
320
 
303
- export declare const ImportHTML: ({ parentId }: {
321
+ export declare const ImportHTML: ({ parentId, position }: {
304
322
  parentId?: string;
323
+ position?: number;
305
324
  }) => JSX_2.Element;
306
325
 
307
326
  declare type LayoutVariant = "SINGLE_SIDE_PANEL" | "DUAL_SIDE_PANEL" | "DUAL_SIDE_PANEL_ADVANCED";
@@ -311,7 +330,7 @@ export declare const mergeClasses: (...inputs: ClassValue[]) => string;
311
330
  export declare const Outline: () => JSX_2.Element;
312
331
 
313
332
  declare type OutlineMenuItem = {
314
- item: React_3.ComponentType<{
333
+ item: default_2.ComponentType<{
315
334
  blockId: string;
316
335
  }>;
317
336
  tooltip: string | ReactNode;
@@ -319,7 +338,18 @@ declare type OutlineMenuItem = {
319
338
 
320
339
  declare type OutlineMenuItems = OutlineMenuItem[];
321
340
 
322
- 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>;
323
353
 
324
354
  export { registerChaiBlock }
325
355
 
@@ -328,17 +358,16 @@ declare type RichText = string;
328
358
  declare type SavePageData = {
329
359
  autoSave: boolean;
330
360
  blocks: ChaiBlock[];
331
- providers?: DataProvider[];
332
- brandingOptions?: Record<string, any>;
333
- themeConfiguration?: Record<string, any>;
361
+ theme?: Record<string, any>;
334
362
  };
335
363
 
336
364
  export declare const ScreenSizes: () => JSX_2.Element;
337
365
 
338
- export declare const ThemeOptions: ({ showHeading, className, }: {
366
+ declare interface ThemeConfigProps {
339
367
  className?: string;
340
- showHeading?: boolean;
341
- }) => React_2.JSX.Element;
368
+ }
369
+
370
+ export declare const ThemeOptions: React_2.FC<ThemeConfigProps>;
342
371
 
343
372
  declare type TimeInSeconds = number;
344
373
 
@@ -348,8 +377,9 @@ declare type TStyleBlock = {
348
377
  prop: string;
349
378
  };
350
379
 
351
- export declare const UILibraries: ({ parentId }: {
380
+ export declare const UILibraries: ({ parentId, position }: {
352
381
  parentId?: string;
382
+ position?: number;
353
383
  }) => JSX_2.Element;
354
384
 
355
385
  declare interface UILibrary {
@@ -375,10 +405,16 @@ export declare const UndoRedo: () => JSX_2.Element;
375
405
 
376
406
  export declare const useAddBlock: () => AddBlocks;
377
407
 
378
- 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
+ };
379
415
 
380
416
  export declare const useBlockHighlight: () => {
381
- highlightBlock: (blockId: string) => void;
417
+ highlightBlock: (elementOrID: HTMLElement | string) => void;
382
418
  clearHighlight: () => void;
383
419
  lastHighlighted: HTMLElement;
384
420
  };
@@ -414,7 +450,7 @@ export declare const useCanvasWidth: () => [number, string, Function];
414
450
  /**
415
451
  * Wrapper hook around useAtom
416
452
  */
417
- 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];
418
454
 
419
455
  /**
420
456
  * Custom hook to access the current state of the code editor.
@@ -423,7 +459,7 @@ export declare const useCanvasZoom: () => [number, (args_0: number | typeof RESE
423
459
  */
424
460
  export declare const useCodeEditor: () => [CodeEditorProps, never];
425
461
 
426
- export declare const useCopyBlockIds: () => [Array<string>, Function];
462
+ export declare const useCopyBlockIds: () => [Array<string>, (blockIds: Array<string>) => void];
427
463
 
428
464
  export declare const useCopyToClipboard: () => [CopiedValue, CopyFn];
429
465
 
@@ -468,11 +504,11 @@ export declare const useLanguages: () => {
468
504
  setSelectedLang: (lang: string) => void;
469
505
  };
470
506
 
471
- 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: RESET | LayoutVariant | ((prev: LayoutVariant) => RESET | LayoutVariant)) => void];
472
508
 
473
509
  export declare const usePasteBlocks: () => {
474
- canPaste: (newParentId: string) => boolean;
475
- pasteBlocks: Function;
510
+ canPaste: (newParentId: string) => Promise<boolean>;
511
+ pasteBlocks: (newParentId: string | string[]) => Promise<void>;
476
512
  };
477
513
 
478
514
  /**
@@ -484,6 +520,8 @@ export declare const useRemoveBlocks: () => (blockIds: Array<string>) => void;
484
520
 
485
521
  export declare const useRemoveClassesFromBlocks: () => Function;
486
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
+
487
525
  export declare const useSavePage: () => {
488
526
  savePage: ThrottledFunction<(autoSave?: boolean) => Promise<boolean>>;
489
527
  saveState: "UNSAVED" | "SAVED" | "SAVING";
@@ -502,7 +540,7 @@ export declare const useSelectedBlockCurrentClasses: () => Array<ClassDerivedObj
502
540
  /**
503
541
  *
504
542
  */
505
- 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];
506
544
 
507
545
  /**
508
546
  * Hook to get selected block ids
@@ -520,10 +558,22 @@ export declare const useSelectedBreakpoints: () => [string[], Function];
520
558
  */
521
559
  export declare const useSelectedStylingBlocks: () => [TStyleBlock[], (args_0: TStyleBlock[] | ((prev: TStyleBlock[]) => TStyleBlock[])) => void];
522
560
 
523
- 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];
524
562
 
525
563
  export declare const useStylingState: () => [unknown, (...args: unknown[]) => unknown];
526
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
+
527
577
  export { useTranslation }
528
578
 
529
579
  export declare const useUILibraryBlocks: () => {
@@ -547,4 +597,8 @@ export declare const useUpdateBlocksProps: () => (blockIds: Array<string>, props
547
597
 
548
598
  export declare const useUpdateBlocksPropsRealtime: () => (blockIds: Array<string>, props: Record<string, any>) => void;
549
599
 
600
+ export declare const useWrapperBlock: () => any;
601
+
602
+ declare type VariableKey = string;
603
+
550
604
  export { }