@trycourier/react-designer 0.0.0-canary-20250902155318 → 0.0.0-canary-20250904164205

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 (33) hide show
  1. package/README.md +120 -0
  2. package/dist/cjs/index.js +40 -34
  3. package/dist/cjs/index.js.map +4 -4
  4. package/dist/cjs/styles.css +20 -0
  5. package/dist/components/Providers/Providers.types.d.ts +1 -0
  6. package/dist/components/Providers/TemplateProvider.d.ts +3 -3
  7. package/dist/components/Providers/store.d.ts +29 -4
  8. package/dist/components/Providers/useBrandActions.d.ts +11 -2
  9. package/dist/components/Providers/useTemplateActions.d.ts +7 -3
  10. package/dist/components/TemplateEditor/Channels/Push/Push.d.ts +6 -2
  11. package/dist/components/TemplateEditor/Channels/SMS/SMS.d.ts +5 -2
  12. package/dist/components/extensions/Divider/Divider.types.d.ts +2 -2
  13. package/dist/components/ui-kit/Button/Button.d.ts +1 -1
  14. package/dist/components/ui-kit/ErrorBoundary/ErrorBoundary.d.ts +22 -0
  15. package/dist/components/ui-kit/ErrorBoundary/index.d.ts +1 -0
  16. package/dist/components/ui-kit/index.d.ts +1 -0
  17. package/dist/esm/index.js +40 -34
  18. package/dist/esm/index.js.map +4 -4
  19. package/dist/esm/styles.css +20 -0
  20. package/dist/index.d.ts +2 -0
  21. package/dist/lib/api/uploadImage.d.ts +0 -1
  22. package/dist/lib/utils/errors.d.ts +26 -0
  23. package/dist/lib/utils/getTitle/demo.d.ts +1 -0
  24. package/dist/lib/utils/getTitle/getTitle.d.ts +18 -0
  25. package/dist/lib/utils/getTitle/getTitle.test.d.ts +1 -0
  26. package/dist/lib/utils/getTitle/index.d.ts +2 -0
  27. package/dist/lib/utils/getTitle/preserveStorageFormat.d.ts +30 -0
  28. package/dist/lib/utils/getTitle/preserveStorageFormat.test.d.ts +1 -0
  29. package/dist/lib/utils/index.d.ts +1 -0
  30. package/dist/lib/utils/updateElemental/updateElemental.d.ts +1 -1
  31. package/dist/styles.css +20 -0
  32. package/dist/types/elemental.types.d.ts +1 -0
  33. package/package.json +1 -1
@@ -1637,6 +1637,10 @@ body {
1637
1637
  .courier-border-primary {
1638
1638
  border-color: var(--primary);
1639
1639
  }
1640
+ .courier-border-red-200 {
1641
+ --tw-border-opacity: 1;
1642
+ border-color: rgb(254 202 202 / var(--tw-border-opacity, 1));
1643
+ }
1640
1644
  .courier-border-transparent {
1641
1645
  border-color: transparent;
1642
1646
  }
@@ -1745,6 +1749,10 @@ body {
1745
1749
  .courier-bg-primary {
1746
1750
  background-color: var(--primary);
1747
1751
  }
1752
+ .courier-bg-red-50 {
1753
+ --tw-bg-opacity: 1;
1754
+ background-color: rgb(254 242 242 / var(--tw-bg-opacity, 1));
1755
+ }
1748
1756
  .courier-bg-red-500 {
1749
1757
  --tw-bg-opacity: 1;
1750
1758
  background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));
@@ -2052,6 +2060,10 @@ body {
2052
2060
  --tw-text-opacity: 1;
2053
2061
  color: rgb(107 114 128 / var(--tw-text-opacity, 1));
2054
2062
  }
2063
+ .courier-text-gray-600 {
2064
+ --tw-text-opacity: 1;
2065
+ color: rgb(75 85 99 / var(--tw-text-opacity, 1));
2066
+ }
2055
2067
  .courier-text-inherit {
2056
2068
  color: inherit;
2057
2069
  }
@@ -2077,6 +2089,14 @@ body {
2077
2089
  --tw-text-opacity: 1;
2078
2090
  color: rgb(239 68 68 / var(--tw-text-opacity, 1));
2079
2091
  }
2092
+ .courier-text-red-600 {
2093
+ --tw-text-opacity: 1;
2094
+ color: rgb(220 38 38 / var(--tw-text-opacity, 1));
2095
+ }
2096
+ .courier-text-red-800 {
2097
+ --tw-text-opacity: 1;
2098
+ color: rgb(153 27 27 / var(--tw-text-opacity, 1));
2099
+ }
2080
2100
  .courier-text-ring {
2081
2101
  color: var(--ring);
2082
2102
  }
@@ -1,6 +1,7 @@
1
1
  import type { ReactNode } from "react";
2
2
  export interface BasicProviderProps {
3
3
  apiUrl?: string;
4
+ uploadImageUrl?: string;
4
5
  children: ReactNode;
5
6
  tenantId: string;
6
7
  token: string;
@@ -1,9 +1,9 @@
1
1
  import type { BasicProviderProps } from "./Providers.types";
2
- import { useTemplateActions } from "./useTemplateActions";
2
+ import { type TemplateActions, type MessageRouting } from "./store";
3
3
  type TemplateProviderProps = BasicProviderProps & {
4
4
  templateId: string;
5
- getTemplate?: (actions: ReturnType<typeof useTemplateActions>) => Promise<void>;
6
- saveTemplate?: (actions: ReturnType<typeof useTemplateActions>, options?: any) => Promise<void>;
5
+ getTemplate?: (actions: TemplateActions) => Promise<void>;
6
+ saveTemplate?: (actions: TemplateActions, options?: MessageRouting) => Promise<void>;
7
7
  };
8
8
  export declare const overrideFunctions: {
9
9
  getTemplate: TemplateProviderProps["getTemplate"] | null;
@@ -1,4 +1,5 @@
1
1
  import type { ElementalContent } from "@/types/elemental.types";
2
+ import type { TemplateError } from "@/lib/utils/errors";
2
3
  export type MessageRoutingMethod = "all" | "single";
3
4
  export type MessageRoutingChannel = string | MessageRouting;
4
5
  export interface MessageRouting {
@@ -83,6 +84,9 @@ export declare const editorStore: {
83
84
  export declare const apiUrlAtom: import("jotai").PrimitiveAtom<string> & {
84
85
  init: string;
85
86
  };
87
+ export declare const uploadImageUrlAtom: import("jotai").PrimitiveAtom<string> & {
88
+ init: string;
89
+ };
86
90
  export declare const tokenAtom: import("jotai").PrimitiveAtom<string> & {
87
91
  init: string;
88
92
  };
@@ -104,12 +108,33 @@ export declare const isTemplateSavingAtom: import("jotai").PrimitiveAtom<boolean
104
108
  export declare const isTemplatePublishingAtom: import("jotai").PrimitiveAtom<boolean | null> & {
105
109
  init: boolean | null;
106
110
  };
107
- export declare const templateErrorAtom: import("jotai").PrimitiveAtom<string | null> & {
108
- init: string | null;
111
+ export declare const templateErrorAtom: import("jotai").PrimitiveAtom<TemplateError | null> & {
112
+ init: TemplateError | null;
109
113
  };
110
114
  export declare const brandApplyAtom: import("jotai").PrimitiveAtom<boolean> & {
111
115
  init: boolean;
112
116
  };
117
+ export interface TemplateActions {
118
+ getTemplate: (options?: {
119
+ includeBrand?: boolean;
120
+ }) => Promise<void>;
121
+ saveTemplate: (options?: MessageRouting) => Promise<void>;
122
+ publishTemplate: () => Promise<unknown>;
123
+ isTemplateLoading: boolean | null;
124
+ setIsTemplateLoading: (loading: boolean | null) => void;
125
+ isTemplateSaving: boolean | null;
126
+ setIsTemplateSaving: (saving: boolean | null) => void;
127
+ isTemplatePublishing: boolean | null;
128
+ setIsTemplatePublishing: (publishing: boolean | null) => void;
129
+ templateError: TemplateError | null;
130
+ setTemplateError: (error: string | TemplateError | null) => void;
131
+ templateData: TenantData | null;
132
+ setTemplateData: (data: TenantData | null) => void;
133
+ templateEditorContent: ElementalContent | null | undefined;
134
+ setTemplateEditorContent: (content: ElementalContent | null) => void;
135
+ createCustomError: (message: string, details?: Record<string, unknown>) => TemplateError;
136
+ convertLegacyError: (error: string | TemplateError) => TemplateError;
137
+ }
113
138
  export declare const getTemplateOverrideAtom: import("jotai").PrimitiveAtom<((options?: {
114
139
  includeBrand?: boolean;
115
140
  }) => Promise<void>) | null> & {
@@ -117,6 +142,6 @@ export declare const getTemplateOverrideAtom: import("jotai").PrimitiveAtom<((op
117
142
  includeBrand?: boolean;
118
143
  }) => Promise<void>) | null;
119
144
  };
120
- export declare const saveTemplateOverrideAtom: import("jotai").PrimitiveAtom<((actions: any, options?: any) => Promise<void>) | null> & {
121
- init: ((actions: any, options?: any) => Promise<void>) | null;
145
+ export declare const saveTemplateOverrideAtom: import("jotai").PrimitiveAtom<((actions: TemplateActions, options?: MessageRouting) => Promise<void>) | null> & {
146
+ init: ((actions: TemplateActions, options?: MessageRouting) => Promise<void>) | null;
122
147
  };
@@ -1,13 +1,22 @@
1
+ import { type TemplateError } from "@/lib/utils/errors";
2
+ import { type MessageRouting } from "./store";
1
3
  export declare function useBrandActions(): {
2
4
  getTemplate: (options?: {
3
5
  includeBrand?: boolean;
4
6
  }) => Promise<void>;
5
- saveTemplate: (options?: any) => Promise<void>;
7
+ saveTemplate: (options?: MessageRouting) => Promise<void>;
6
8
  saveBrand: (settings?: Record<string, unknown> | undefined) => Promise<any>;
7
9
  publishBrand: () => Promise<any>;
8
10
  isTemplateLoading: boolean | null;
11
+ setIsTemplateLoading: (args_0: boolean | ((prev: boolean | null) => boolean | null) | null) => void;
9
12
  isTemplateSaving: boolean | null;
13
+ setIsTemplateSaving: (args_0: boolean | ((prev: boolean | null) => boolean | null) | null) => void;
10
14
  isTemplatePublishing: boolean | null;
11
- templateError: string | null;
15
+ setIsTemplatePublishing: (args_0: boolean | ((prev: boolean | null) => boolean | null) | null) => void;
16
+ templateError: TemplateError | null;
17
+ setTemplateError: (error: string | TemplateError | null) => void;
12
18
  templateData: import("./store").TenantData | null;
19
+ setTemplateData: (args_0: import("./store").TenantData | ((prev: import("./store").TenantData | null) => import("./store").TenantData | null) | null) => void;
20
+ createCustomError: (message: string, toastProps?: import("sonner").ExternalToast) => TemplateError;
21
+ convertLegacyError: (error: string | TemplateError) => TemplateError;
13
22
  };
@@ -1,8 +1,10 @@
1
+ import { type TemplateError } from "@/lib/utils/errors";
2
+ import { type MessageRouting } from "./store";
1
3
  export declare function useTemplateActions(): {
2
4
  getTemplate: (options?: {
3
5
  includeBrand?: boolean;
4
6
  }) => Promise<void>;
5
- saveTemplate: (options?: any) => Promise<void>;
7
+ saveTemplate: (options?: MessageRouting) => Promise<void>;
6
8
  publishTemplate: () => Promise<any>;
7
9
  isTemplateLoading: boolean | null;
8
10
  setIsTemplateLoading: (args_0: boolean | ((prev: boolean | null) => boolean | null) | null) => void;
@@ -10,10 +12,12 @@ export declare function useTemplateActions(): {
10
12
  setIsTemplateSaving: (args_0: boolean | ((prev: boolean | null) => boolean | null) | null) => void;
11
13
  isTemplatePublishing: boolean | null;
12
14
  setIsTemplatePublishing: (args_0: boolean | ((prev: boolean | null) => boolean | null) | null) => void;
13
- templateError: string | null;
14
- setTemplateError: (args_0: string | ((prev: string | null) => string | null) | null) => void;
15
+ templateError: TemplateError | null;
16
+ setTemplateError: (error: string | TemplateError | null) => void;
15
17
  templateData: import("./store").TenantData | null;
16
18
  setTemplateData: (args_0: import("./store").TenantData | ((prev: import("./store").TenantData | null) => import("./store").TenantData | null) | null) => void;
17
19
  templateEditorContent: import("../TemplateEditor").ElementalContent | null | undefined;
18
20
  setTemplateEditorContent: (args_0: import("../TemplateEditor").ElementalContent | ((prev: import("../TemplateEditor").ElementalContent | null | undefined) => import("../TemplateEditor").ElementalContent | null | undefined) | null | undefined) => void;
21
+ createCustomError: (message: string, toastProps?: import("sonner").ExternalToast) => TemplateError;
22
+ convertLegacyError: (error: string | TemplateError) => TemplateError;
19
23
  };
@@ -2,7 +2,6 @@ import type { MessageRouting } from "@/components/Providers/store";
2
2
  import type { TextMenuConfig } from "@/components/ui/TextMenu/config";
3
3
  import type { TiptapDoc } from "@/lib/utils";
4
4
  import type { ChannelType } from "@/store";
5
- import type { ElementalNode } from "@/types/elemental.types";
6
5
  import type { AnyExtension, Editor } from "@tiptap/react";
7
6
  import type { TemplateEditorProps } from "../../TemplateEditor";
8
7
  export declare const PushEditorContent: ({ value }: {
@@ -26,6 +25,11 @@ export interface PushProps extends Pick<TemplateEditorProps, "hidePublish" | "th
26
25
  }) => React.ReactNode;
27
26
  render?: (props: PushRenderProps) => React.ReactNode;
28
27
  }
29
- export declare const defaultPushContent: ElementalNode[];
28
+ export declare const defaultPushContent: {
29
+ raw: {
30
+ title: string;
31
+ text: string;
32
+ };
33
+ };
30
34
  export declare const PushConfig: TextMenuConfig;
31
35
  export declare const Push: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<PushProps & import("react").RefAttributes<HTMLDivElement>>>;
@@ -1,11 +1,14 @@
1
1
  import type { TextMenuConfig } from "@/components/ui/TextMenu/config";
2
2
  import type { TiptapDoc } from "@/lib/utils";
3
- import type { ElementalNode } from "@/types/elemental.types";
4
3
  import type { AnyExtension, Editor } from "@tiptap/react";
5
4
  import type { MessageRouting } from "../../../Providers/store";
6
5
  import type { ChannelType } from "@/store";
7
6
  import type { TemplateEditorProps } from "../../TemplateEditor";
8
- export declare const defaultSMSContent: ElementalNode[];
7
+ export declare const defaultSMSContent: {
8
+ raw: {
9
+ text: string;
10
+ };
11
+ };
9
12
  export declare const SMSEditorContent: ({ value }: {
10
13
  value?: TiptapDoc | null;
11
14
  }) => import("react/jsx-runtime").JSX.Element;
@@ -6,14 +6,14 @@ export declare const dividerSchema: z.ZodObject<{
6
6
  radius: z.ZodNumber;
7
7
  variant: z.ZodDefault<z.ZodEnum<["divider", "spacer"]>>;
8
8
  }, "strip", z.ZodTypeAny, {
9
- color: string;
10
9
  padding: number;
10
+ color: string;
11
11
  size: number;
12
12
  radius: number;
13
13
  variant: "divider" | "spacer";
14
14
  }, {
15
- color: string;
16
15
  padding: number;
16
+ color: string;
17
17
  size: number;
18
18
  radius: number;
19
19
  variant?: "divider" | "spacer" | undefined;
@@ -4,7 +4,7 @@ export type ButtonVariant = "primary" | "secondary" | "tertiary" | "quaternary"
4
4
  export type ButtonSize = "medium" | "small" | "icon" | "iconSmall";
5
5
  export declare const buttonVariants: (props?: ({
6
6
  variant?: "link" | "primary" | "secondary" | "tertiary" | "quaternary" | "outline" | "ghost" | null | undefined;
7
- size?: "small" | "medium" | "icon" | "iconSmall" | null | undefined;
7
+ size?: "icon" | "small" | "medium" | "iconSmall" | null | undefined;
8
8
  active?: boolean | null | undefined;
9
9
  disabled?: boolean | null | undefined;
10
10
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
@@ -0,0 +1,22 @@
1
+ import type { ErrorInfo, ReactNode } from "react";
2
+ import { Component } from "react";
3
+ interface ErrorBoundaryProps {
4
+ children: ReactNode;
5
+ fallback?: ReactNode;
6
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
7
+ }
8
+ interface ErrorBoundaryState {
9
+ hasError: boolean;
10
+ error?: Error;
11
+ }
12
+ /**
13
+ * Error Boundary component that catches JavaScript errors in the component tree
14
+ * and integrates with the template error system
15
+ */
16
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
17
+ constructor(props: ErrorBoundaryProps);
18
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
19
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
20
+ render(): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
21
+ }
22
+ export {};
@@ -0,0 +1 @@
1
+ export { ErrorBoundary } from "./ErrorBoundary";
@@ -1,6 +1,7 @@
1
1
  export * from "./Button";
2
2
  export * from "./Divider";
3
3
  export * from "./DropdownMenu";
4
+ export * from "./ErrorBoundary";
4
5
  export * from "./Form";
5
6
  export * from "./AlertDialog";
6
7
  export * from "./Input";