@coristen/widget 0.1.8 → 0.1.10

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.
package/README.md CHANGED
@@ -1,39 +1,20 @@
1
- # @coristen/widget
2
-
3
- Install the Coristen customer-experience widget in any React application.
4
-
5
- ```bash
6
- npm install @coristen/widget
7
- ```
8
-
9
- ```tsx
10
- import { CoristenWidget } from "@coristen/widget"
11
- import "@coristen/widget/styles.css"
12
-
13
- export default function App() {
14
- return <CoristenWidget apiKey="coristen_pk_..." />
15
- }
16
- ```
17
-
18
- Public websites use `apiKey`; visitors are remembered in that browser. For an
19
- authenticated app, use an identity route instead so conversations follow the
20
- signed-in customer:
21
-
22
- ```tsx
23
- <CoristenWidget identity="/api/coristen/identity" />
24
- ```
25
-
26
- Create the route with the server-only helper:
27
-
28
- ```ts
29
- import { coristenIdentity } from "@coristen/widget/server"
30
-
31
- export const { GET } = coristenIdentity(async (request) => {
32
- const user = await getSignedInUser(request)
33
- return user ? { id: user.id, name: user.name, email: user.email } : null
34
- })
35
- ```
36
-
37
- Set `CORISTEN_KEY` on the server when using identity mode. Identity mode renders
38
- only for a verified signed-in customer; it never falls back to anonymous access.
39
- Use `apiUrl="http://localhost:3000"` while developing Coristen locally.
1
+ # @coristen/widget
2
+
3
+ Add Coristen to a React application.
4
+
5
+ ```bash
6
+ npm install @coristen/widget
7
+ ```
8
+
9
+ ```tsx
10
+ import { CoristenWidget } from "@coristen/widget"
11
+ import "@coristen/widget/styles.css"
12
+
13
+ export default function App() {
14
+ return <CoristenWidget apiKey="coristen_pk_..." />
15
+ }
16
+ ```
17
+
18
+ Use `CoristenDock` for a side panel and `CoristenModal` for a modal. See the
19
+ [Coristen documentation](https://github.com/brayanj4y/coristen/tree/master/apps/docs/content/docs)
20
+ for installation, identity, security, and API details.
package/dist/api.d.ts CHANGED
@@ -1,3 +1,11 @@
1
+ export type WidgetSuggestion = {
2
+ title: string;
3
+ message: string;
4
+ };
5
+ export type WidgetWelcome = {
6
+ message?: string;
7
+ suggestions?: WidgetSuggestion[];
8
+ };
1
9
  export type ChatMessage = {
2
10
  _id: string;
3
11
  _creationTime: number;
@@ -27,6 +35,7 @@ export type ChatAttachment = {
27
35
  };
28
36
  export type WidgetSettings = {
29
37
  name: string;
38
+ logoUrl?: string | null;
30
39
  agentName: string;
31
40
  agentImageUrl: string | null;
32
41
  brandColor: string;
@@ -47,6 +56,10 @@ export type WidgetSettings = {
47
56
  allowedAttachmentTypes: string[];
48
57
  };
49
58
  export declare const widgetApi: {
59
+ welcomeSuggestions: import("convex/server").FunctionReference<"query", "public", {
60
+ workspaceId: string;
61
+ sessionToken: string;
62
+ }, WidgetSuggestion[], string | undefined>;
50
63
  workspace: import("convex/server").FunctionReference<"query", "public", {
51
64
  workspaceId: string;
52
65
  }, WidgetSettings | null, string | undefined>;
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,12 +1,21 @@
1
- import type { WidgetSettings } from "./api";
1
+ import { type MouseEventHandler, type ReactElement, type ReactNode } from "react";
2
+ import type { WidgetSettings, WidgetWelcome } from "./api";
2
3
  type CoristenWidgetOptions = {
3
4
  apiUrl?: string;
5
+ open?: boolean;
6
+ onOpenChange?: (open: boolean) => void;
4
7
  defaultOpen?: boolean;
8
+ defaultEmail?: string;
9
+ welcome?: WidgetWelcome;
5
10
  fontSize?: string;
6
11
  appearance?: WidgetAppearance;
7
12
  onReady?: () => void;
8
13
  onError?: (error: Error) => void;
9
14
  };
15
+ type WidgetTriggerElement = ReactElement<{
16
+ "aria-expanded"?: boolean;
17
+ onClick?: MouseEventHandler<HTMLElement>;
18
+ }>;
10
19
  export type CoristenWidgetProps = CoristenWidgetOptions & ({
11
20
  apiKey: string;
12
21
  identity?: never;
@@ -14,9 +23,20 @@ export type CoristenWidgetProps = CoristenWidgetOptions & ({
14
23
  identity: string;
15
24
  apiKey?: never;
16
25
  });
17
- export type WidgetAppearance = Partial<Pick<WidgetSettings, "brandColor" | "position" | "theme" | "tintedGrayscale" | "accentEnabled" | "accentHeader" | "accentSendIcon" | "radius" | "bubbleIcon" | "bubbleColor" | "showPoweredBy">>;
18
- export declare function CoristenWidget({ identity, apiKey, apiUrl, defaultOpen, fontSize, appearance, onReady, onError, }: CoristenWidgetProps): import("react").JSX.Element | null;
26
+ export type CoristenModalProps = CoristenWidgetProps & {
27
+ trigger: WidgetTriggerElement;
28
+ };
29
+ export type CoristenDockProps = CoristenWidgetProps & {
30
+ children: ReactNode;
31
+ side?: "left" | "right";
32
+ trigger: WidgetTriggerElement;
33
+ };
34
+ export type WidgetAppearance = Partial<Pick<WidgetSettings, "brandColor" | "logoUrl" | "position" | "theme" | "tintedGrayscale" | "accentEnabled" | "accentHeader" | "accentSendIcon" | "radius" | "bubbleIcon" | "bubbleColor" | "showPoweredBy">>;
35
+ export declare function CoristenWidget(props: CoristenWidgetProps): import("react").JSX.Element;
36
+ export declare function CoristenModal({ trigger, ...props }: CoristenModalProps): import("react").JSX.Element;
37
+ export declare function CoristenDock({ children, side, trigger, open: controlledOpen, onOpenChange, defaultOpen, appearance, ...props }: CoristenDockProps): import("react").JSX.Element;
19
38
  export type { WidgetSettings } from "./api";
39
+ export type { WidgetWelcome, WidgetSuggestion } from "./api";
20
40
  export declare const coristenWidget: {
21
41
  open(): void;
22
42
  close(): void;