@mathews_cometchat/bubble-builder 1.0.0-alpha12 → 1.0.0-alpha14

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 (37) hide show
  1. package/dist/App.d.ts +1 -0
  2. package/dist/bridge/api.d.ts +64 -0
  3. package/dist/bubble-builder.es.js +1403 -784
  4. package/dist/bubble-builder.umd.js +5 -5
  5. package/dist/components/Canvas.d.ts +2 -0
  6. package/dist/components/CanvasViewToggle.d.ts +4 -0
  7. package/dist/components/EditorLayout.d.ts +2 -0
  8. package/dist/components/ElementTree.d.ts +2 -0
  9. package/dist/components/LeftPanel.d.ts +2 -0
  10. package/dist/components/NotificationPreview.d.ts +3 -0
  11. package/dist/components/RightPanel.d.ts +2 -0
  12. package/dist/components/ShortcutsPanel.d.ts +2 -0
  13. package/dist/components/TemplateLibrary.d.ts +2 -0
  14. package/dist/components/TopBar.d.ts +2 -0
  15. package/dist/components/properties/ActionEditor.d.ts +7 -0
  16. package/dist/components/properties/BubbleSettingsEditor.d.ts +1 -0
  17. package/dist/components/properties/ElementPropertyEditor.d.ts +7 -0
  18. package/dist/components/properties/IconPicker.d.ts +6 -0
  19. package/dist/components/properties/NotificationEditor.d.ts +1 -0
  20. package/dist/components/properties/VariableInput.d.ts +10 -0
  21. package/dist/components/renderers/ElementRenderer.d.ts +19 -0
  22. package/dist/components/ui/Button.d.ts +8 -0
  23. package/dist/components/ui/Modal.d.ts +11 -0
  24. package/dist/config/builder-config.d.ts +31 -0
  25. package/dist/config/component-templates.d.ts +9 -0
  26. package/dist/config/element-defaults.d.ts +8 -0
  27. package/dist/config/icon-library.d.ts +11 -0
  28. package/dist/config/theme.d.ts +11 -0
  29. package/dist/config/uikit-theme.d.ts +73 -0
  30. package/dist/hooks/useKeyboardShortcuts.d.ts +1 -0
  31. package/dist/lib.d.ts +45 -0
  32. package/dist/store/builder-store.d.ts +86 -0
  33. package/dist/types/schema.d.ts +315 -0
  34. package/dist/utils/element-errors.d.ts +9 -0
  35. package/dist/utils/id.d.ts +4 -0
  36. package/dist/utils/validate.d.ts +6 -0
  37. package/package.json +10 -5
@@ -0,0 +1,2 @@
1
+ import './Canvas.css';
2
+ export declare const Canvas: import("react").NamedExoticComponent<object>;
@@ -0,0 +1,4 @@
1
+ export declare const CanvasViewToggle: import("react").NamedExoticComponent<{
2
+ platform: "ios" | "android";
3
+ setPlatform: (p: "ios" | "android") => void;
4
+ }>;
@@ -0,0 +1,2 @@
1
+ import './EditorLayout.css';
2
+ export declare const EditorLayout: import("react").NamedExoticComponent<object>;
@@ -0,0 +1,2 @@
1
+ import './ElementTree.css';
2
+ export declare function ElementTree(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import './LeftPanel.css';
2
+ export declare const LeftPanel: import("react").NamedExoticComponent<object>;
@@ -0,0 +1,3 @@
1
+ export declare const NotificationPreview: import("react").NamedExoticComponent<{
2
+ platform: "ios" | "android";
3
+ }>;
@@ -0,0 +1,2 @@
1
+ import './RightPanel.css';
2
+ export declare const RightPanel: import("react").NamedExoticComponent<object>;
@@ -0,0 +1,2 @@
1
+ import './ShortcutsPanel.css';
2
+ export declare const ShortcutsPanel: import("react").NamedExoticComponent<object>;
@@ -0,0 +1,2 @@
1
+ import './TemplateLibrary.css';
2
+ export declare const TemplateLibrary: import("react").NamedExoticComponent<object>;
@@ -0,0 +1,2 @@
1
+ import './TopBar.css';
2
+ export declare const TopBar: import("react").NamedExoticComponent<object>;
@@ -0,0 +1,7 @@
1
+ import type { BubbleAction } from '../../types/schema';
2
+ interface Props {
3
+ action: BubbleAction;
4
+ onChange: (action: BubbleAction) => void;
5
+ }
6
+ export declare const ActionEditor: import("react").NamedExoticComponent<Props>;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare const BubbleSettingsEditor: import("react").NamedExoticComponent<object>;
@@ -0,0 +1,7 @@
1
+ import type { BubbleElement } from '../../types/schema';
2
+ interface Props {
3
+ element: BubbleElement;
4
+ onUpdate: (updates: Partial<BubbleElement>) => void;
5
+ }
6
+ export declare const ElementPropertyEditor: import("react").NamedExoticComponent<Props>;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ value: string;
3
+ onChange: (v: string) => void;
4
+ }
5
+ export declare const IconPicker: import("react").NamedExoticComponent<Props>;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare const NotificationEditor: import("react").NamedExoticComponent<object>;
@@ -0,0 +1,10 @@
1
+ interface VariableInputProps {
2
+ value: string;
3
+ onChange: (v: string) => void;
4
+ placeholder?: string;
5
+ multiline?: boolean;
6
+ rows?: number;
7
+ style?: React.CSSProperties;
8
+ }
9
+ export declare const VariableInput: import("react").NamedExoticComponent<VariableInputProps>;
10
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { BubbleElement } from '../../types/schema';
2
+ interface ElementRendererProps {
3
+ element: BubbleElement;
4
+ path: number[];
5
+ selectedPath: number[] | null;
6
+ selectedPaths: number[][];
7
+ onSelect: (path: number[] | null) => void;
8
+ onToggleSelect: (path: number[]) => void;
9
+ onMove: (path: number[], direction: 'up' | 'down') => void;
10
+ onRemove: (path: number[]) => void;
11
+ onWrap: (path: number[], wrapperType: 'row' | 'column' | 'grid') => void;
12
+ onUnwrap: (path: number[]) => void;
13
+ onDuplicate: (path: number[]) => void;
14
+ isFirst: boolean;
15
+ isLast: boolean;
16
+ inRow?: boolean;
17
+ }
18
+ export declare const ElementRenderer: import("react").NamedExoticComponent<ElementRendererProps>;
19
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ReactNode, ButtonHTMLAttributes } from 'react';
2
+ type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'link';
3
+ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
+ variant?: ButtonVariant;
5
+ children: ReactNode;
6
+ }
7
+ export declare const Button: import("react").NamedExoticComponent<ButtonProps>;
8
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { ReactNode, CSSProperties } from 'react';
2
+ interface ModalProps {
3
+ title: string;
4
+ onClose: () => void;
5
+ children: ReactNode;
6
+ footer?: ReactNode;
7
+ width?: number;
8
+ style?: CSSProperties;
9
+ }
10
+ export declare const Modal: import("react").NamedExoticComponent<ModalProps>;
11
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { BubbleMessage } from '../types/schema';
2
+ export interface BubbleVariable {
3
+ /** Variable name used in {{name}} tokens, e.g. 'user.name' */
4
+ name: string;
5
+ /** Human-readable label shown in the picker */
6
+ label?: string;
7
+ /** Short description */
8
+ description?: string;
9
+ /** Category for grouping in the picker */
10
+ category?: string;
11
+ }
12
+ export interface NotificationConfig {
13
+ /** App name shown in the notification preview */
14
+ appName?: string;
15
+ /** App icon URL shown in the notification preview */
16
+ appIcon?: string;
17
+ }
18
+ /** Which channels the builder supports */
19
+ export type BuilderChannels = 'inapp' | 'push' | 'both';
20
+ /** Module-level config accessible by components */
21
+ export declare const builderConfig: {
22
+ appId?: string;
23
+ region?: string;
24
+ token?: string;
25
+ onSave?: (json: BubbleMessage, name: string, description: string) => void;
26
+ onChange?: (json: BubbleMessage) => void;
27
+ hideTopBar?: boolean;
28
+ hideTemplateLibrary?: boolean;
29
+ channels?: BuilderChannels;
30
+ notification?: NotificationConfig;
31
+ };
@@ -0,0 +1,9 @@
1
+ export interface ComponentTemplate {
2
+ name: string;
3
+ category: string;
4
+ icon: string;
5
+ description: string;
6
+ elements: Record<string, unknown>[];
7
+ }
8
+ export declare const COMPONENT_TEMPLATES: ComponentTemplate[];
9
+ export declare const COMPONENT_CATEGORIES: string[];
@@ -0,0 +1,8 @@
1
+ import type { BubbleElement } from '../types/schema';
2
+ export declare const ELEMENT_DEFAULTS: Map<string, () => BubbleElement>;
3
+ export declare const ELEMENT_PALETTE: {
4
+ readonly Layout: readonly ["row", "column", "grid", "accordion", "tabs"];
5
+ readonly Content: readonly ["text", "image", "icon", "avatar", "badge", "divider", "spacer", "chip", "markdown", "codeBlock"];
6
+ readonly 'Data Display': readonly ["table", "progressBar"];
7
+ readonly Actions: readonly ["button", "iconButton", "link"];
8
+ };
@@ -0,0 +1,11 @@
1
+ export interface IconEntry {
2
+ name: string;
3
+ label: string;
4
+ url: string;
5
+ category: string;
6
+ }
7
+ export declare const ICON_LIBRARY: IconEntry[];
8
+ export declare const ICON_MAP: Map<string, IconEntry>;
9
+ export declare const ICON_CATEGORIES: string[];
10
+ /** Resolve an icon name to its URL. Returns the name as-is if it's already a URL. */
11
+ export declare function resolveIconUrl(nameOrUrl: string): string;
@@ -0,0 +1,11 @@
1
+ import type { UIKitColorMode } from './uikit-theme';
2
+ /** Build a flat token map from UIKit theme colors */
3
+ export declare function buildTokensFromUIKit(colors: UIKitColorMode): Record<string, string>;
4
+ export declare const THEME_TOKENS: Record<string, string>;
5
+ export declare const DARK_THEME_TOKENS: Record<string, string>;
6
+ export declare let THEME_TOKEN_NAMES: string[];
7
+ export declare function setActiveTheme(dark: boolean): void;
8
+ /** Sync active theme tokens from the UIKit theme store */
9
+ export declare function syncThemeTokens(lightColors: UIKitColorMode, darkColors: UIKitColorMode, isDark: boolean): void;
10
+ export declare function resolveColor(value: string | undefined, fallback?: string): string;
11
+ export declare const TEXT_VARIANT_STYLES: Record<string, React.CSSProperties>;
@@ -0,0 +1,73 @@
1
+ export declare function hexToRgb(hex: string): {
2
+ r: number;
3
+ g: number;
4
+ b: number;
5
+ };
6
+ export declare function rgbToHex(r: number, g: number, b: number): string;
7
+ export declare const SHADE_KEYS: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
8
+ export declare function generateExtendedPrimary(primary: string): {
9
+ light: Record<number, string>;
10
+ dark: Record<number, string>;
11
+ };
12
+ export declare function generateSpacingScale(baseUnit?: number, steps?: number): Record<string, number>;
13
+ export declare function generatePadding(scale: Record<string, number>): Record<string, number>;
14
+ export declare function generateRadius(scale: Record<string, number>): Record<string, number>;
15
+ export interface UIKitColorMode {
16
+ primary: string;
17
+ extendedPrimary: Record<number, string>;
18
+ neutral: Record<number, string>;
19
+ alert: {
20
+ info: string;
21
+ warning: string;
22
+ success: string;
23
+ error: string;
24
+ };
25
+ staticColors: {
26
+ black: string;
27
+ white: string;
28
+ };
29
+ sendBubble: {
30
+ background: string;
31
+ text: string;
32
+ textHighlight: string;
33
+ link: string;
34
+ timestamp: string;
35
+ icon: string;
36
+ };
37
+ receiveBubble: {
38
+ background: string;
39
+ text: string;
40
+ textHighlight: string;
41
+ link: string;
42
+ timestamp: string;
43
+ icon: string;
44
+ };
45
+ }
46
+ export interface UIKitTheme {
47
+ name: string;
48
+ version: string;
49
+ spacing: {
50
+ baseUnit: number;
51
+ scale: Record<string, number>;
52
+ padding: Record<string, number>;
53
+ radius: Record<string, number>;
54
+ };
55
+ typography: {
56
+ fontFamily: string;
57
+ scale: Record<string, {
58
+ size: number;
59
+ lineHeight: number;
60
+ weight?: string;
61
+ }>;
62
+ weights: {
63
+ bold: string;
64
+ medium: string;
65
+ regular: string;
66
+ };
67
+ };
68
+ colors: {
69
+ light: UIKitColorMode;
70
+ dark: UIKitColorMode;
71
+ };
72
+ }
73
+ export declare function createDefaultTheme(): UIKitTheme;
@@ -0,0 +1 @@
1
+ export declare function useKeyboardShortcuts(): void;
package/dist/lib.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ import type { BubbleMessage } from './types/schema';
2
+ import type { BubbleVariable, NotificationConfig, BuilderChannels } from './config/builder-config';
3
+ import './index.css';
4
+ export type { BubbleVariable } from './config/builder-config';
5
+ export type { NotificationConfig, BuilderChannels } from './config/builder-config';
6
+ export interface BubbleBuilderOptions {
7
+ /** CometChat app ID (required for template save/load APIs) */
8
+ appId?: string;
9
+ /** App region — us, eu, etc. (required for template save/load APIs) */
10
+ region?: string;
11
+ /** Bearer token for REST API calls (required for template save/load APIs) */
12
+ token?: string;
13
+ /** Existing bubble JSON to load for editing */
14
+ bubble?: BubbleMessage;
15
+ /** Template name */
16
+ templateName?: string;
17
+ /** Called when user clicks Save */
18
+ onSave?: (json: BubbleMessage, name: string, description: string) => void;
19
+ /** Called whenever the bubble JSON changes (any edit). Use for real-time sync. */
20
+ onChange?: (json: BubbleMessage) => void;
21
+ /** Available variables for {{placeholder}} insertion in text/URL fields */
22
+ variables?: BubbleVariable[];
23
+ /** Hide the top toolbar (save, export, import, undo/redo, template name). Default: false */
24
+ hideTopBar?: boolean;
25
+ /** Hide the template library view — go straight to editor. Default: false */
26
+ hideTemplateLibrary?: boolean;
27
+ /** Which channels to show: 'inapp' (default), 'push', or 'both'. */
28
+ channels?: BuilderChannels;
29
+ /** Push notification preview config (app name, icon). Only used when channels is 'push' or 'both'. */
30
+ notification?: NotificationConfig;
31
+ }
32
+ export interface BubbleBuilderInstance {
33
+ loadBubble: (bubble: BubbleMessage, name?: string) => void;
34
+ getBubbleJSON: () => BubbleMessage;
35
+ /** Update the available variables for {{placeholder}} insertion at any time */
36
+ setVariables: (variables: BubbleVariable[]) => void;
37
+ /** Switch which channels are available: 'inapp', 'push', or 'both' */
38
+ setChannels: (channels: BuilderChannels) => void;
39
+ /** Switch between 'bubble' (in-app) and 'notification' (push) canvas views */
40
+ setCanvasView: (view: 'bubble' | 'notification') => void;
41
+ destroy: () => void;
42
+ }
43
+ export { builderConfig } from './config/builder-config';
44
+ export declare function mountBubbleBuilder(container: HTMLElement, options: BubbleBuilderOptions): BubbleBuilderInstance;
45
+ export type { BubbleMessage } from './types/schema';
@@ -0,0 +1,86 @@
1
+ import type { BubbleElement, BubbleSettings, BubbleMessage, Template } from '../types/schema';
2
+ import type { BubbleVariable } from '../config/builder-config';
3
+ export interface BuilderState {
4
+ templateId: string | null;
5
+ templateName: string;
6
+ templateDescription: string;
7
+ body: BubbleElement[];
8
+ settings: BubbleSettings;
9
+ fallbackText: string;
10
+ notificationTitle: string;
11
+ notificationBody: string;
12
+ notificationEnabled: boolean;
13
+ /** Which view the canvas shows: bubble editor or notification preview */
14
+ canvasView: 'bubble' | 'notification';
15
+ /** Which channels are available */
16
+ channels: 'inapp' | 'push' | 'both';
17
+ selectedPath: number[] | null;
18
+ selectedPaths: number[][];
19
+ isDirty: boolean;
20
+ useThemePlaceholders: boolean;
21
+ view: 'library' | 'editor';
22
+ clipboard: BubbleElement | null;
23
+ showTemplatePicker: boolean;
24
+ variables: BubbleVariable[];
25
+ history: {
26
+ body: BubbleElement[];
27
+ settings: BubbleSettings;
28
+ }[];
29
+ historyIndex: number;
30
+ templates: Template[];
31
+ templatesLoading: boolean;
32
+ templatesMeta: {
33
+ previous?: {
34
+ affix: string;
35
+ createdAt: number;
36
+ };
37
+ next?: {
38
+ affix: string;
39
+ createdAt: number;
40
+ };
41
+ } | null;
42
+ setView: (view: 'library' | 'editor') => void;
43
+ setShowTemplatePicker: (show: boolean) => void;
44
+ selectElement: (path: number[] | null) => void;
45
+ toggleSelectElement: (path: number[]) => void;
46
+ addElement: (element: BubbleElement, parentPath?: number[]) => void;
47
+ updateElement: (path: number[], updates: Partial<BubbleElement>) => void;
48
+ removeElement: (path: number[]) => void;
49
+ moveElement: (path: number[], direction: 'up' | 'down') => void;
50
+ updateSettings: (settings: Partial<BubbleSettings>) => void;
51
+ setFallbackText: (text: string) => void;
52
+ setNotificationTitle: (text: string) => void;
53
+ setNotificationBody: (text: string) => void;
54
+ setNotificationEnabled: (enabled: boolean) => void;
55
+ setCanvasView: (view: 'bubble' | 'notification') => void;
56
+ setChannels: (channels: 'inapp' | 'push' | 'both') => void;
57
+ setUseThemePlaceholders: (use: boolean) => void;
58
+ setVariables: (variables: BubbleVariable[]) => void;
59
+ setTemplateName: (name: string) => void;
60
+ setTemplateDescription: (desc: string) => void;
61
+ loadBubble: (bubble: BubbleMessage, templateId?: string, name?: string, desc?: string) => void;
62
+ newBubble: () => void;
63
+ getBubbleJSON: (opts?: {
64
+ stripEmpty?: boolean;
65
+ }) => BubbleMessage;
66
+ setTemplates: (templates: Template[]) => void;
67
+ fetchTemplates: (search?: string) => Promise<void>;
68
+ fetchNextPage: () => Promise<void>;
69
+ fetchPrevPage: () => Promise<void>;
70
+ saveTemplate: () => Promise<void>;
71
+ deleteTemplate: (id: string) => Promise<void>;
72
+ reorderElement: (fromPath: number[], toPath: number[], toIndex: number) => void;
73
+ moveElementToPath: (fromPath: number[], toParentPath: number[], toIndex: number) => void;
74
+ wrapElement: (path: number[], wrapperType: 'row' | 'column' | 'grid') => void;
75
+ unwrapElement: (path: number[]) => void;
76
+ wrapSelected: (wrapperType: 'row' | 'column' | 'grid') => void;
77
+ duplicateElement: (path: number[]) => void;
78
+ copyElement: (path: number[]) => void;
79
+ pasteElement: (targetPath?: number[]) => void;
80
+ undo: () => void;
81
+ redo: () => void;
82
+ canUndo: () => boolean;
83
+ canRedo: () => boolean;
84
+ clearAll: () => void;
85
+ }
86
+ export declare const useBuilderStore: import("zustand").UseBoundStore<import("zustand").StoreApi<BuilderState>>;