@channelhub/widget 0.0.0-stage → 0.1.4

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 (67) hide show
  1. package/dist/ChannelHubChannels.d.ts +15 -0
  2. package/dist/ChannelHubChannels.d.ts.map +1 -0
  3. package/dist/ChannelHubInbox.d.ts +3 -0
  4. package/dist/ChannelHubInbox.d.ts.map +1 -0
  5. package/dist/LiveChatWidget.d.ts +12 -0
  6. package/dist/LiveChatWidget.d.ts.map +1 -0
  7. package/dist/api.d.ts +36 -0
  8. package/dist/api.d.ts.map +1 -0
  9. package/dist/channels/ProviderLogo.d.ts +8 -0
  10. package/dist/channels/ProviderLogo.d.ts.map +1 -0
  11. package/dist/components/ui/avatar.d.ts +8 -0
  12. package/dist/components/ui/avatar.d.ts.map +1 -0
  13. package/dist/components/ui/button.d.ts +5 -0
  14. package/dist/components/ui/button.d.ts.map +1 -0
  15. package/dist/components/ui/index.d.ts +6 -0
  16. package/dist/components/ui/index.d.ts.map +1 -0
  17. package/dist/components/ui/input.d.ts +3 -0
  18. package/dist/components/ui/input.d.ts.map +1 -0
  19. package/dist/components/ui/scroll-area.d.ts +6 -0
  20. package/dist/components/ui/scroll-area.d.ts.map +1 -0
  21. package/dist/components/ui/textarea.d.ts +3 -0
  22. package/dist/components/ui/textarea.d.ts.map +1 -0
  23. package/dist/facebook_icon.avif +0 -0
  24. package/dist/index.cjs +114 -0
  25. package/dist/index.d.ts +6 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +2376 -0
  28. package/dist/instagram_icon.avif +0 -0
  29. package/dist/livechat-standalone.d.ts +23 -0
  30. package/dist/livechat-standalone.d.ts.map +1 -0
  31. package/dist/standalone.d.ts +22 -0
  32. package/dist/standalone.d.ts.map +1 -0
  33. package/dist/telegram_icon.avif +0 -0
  34. package/dist/types.d.ts +66 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/web.avif +0 -0
  37. package/dist/zalo_icon.avif +0 -0
  38. package/package.json +45 -3
  39. package/public/facebook_icon.avif +0 -0
  40. package/public/instagram_icon.avif +0 -0
  41. package/public/telegram_icon.avif +0 -0
  42. package/public/web.avif +0 -0
  43. package/public/zalo_icon.avif +0 -0
  44. package/src/ChannelHubChannels.tsx +941 -0
  45. package/src/ChannelHubInbox.tsx +1133 -0
  46. package/src/LiveChatWidget.tsx +441 -0
  47. package/src/api.ts +100 -0
  48. package/src/assets/facebook_icon.avif +0 -0
  49. package/src/assets/instagram_icon.avif +0 -0
  50. package/src/assets/telegram_icon.avif +0 -0
  51. package/src/assets/web.avif +0 -0
  52. package/src/assets/zalo_icon.avif +0 -0
  53. package/src/assets.d.ts +4 -0
  54. package/src/channels/ProviderLogo.tsx +59 -0
  55. package/src/components/ui/avatar.tsx +2 -0
  56. package/src/components/ui/button.tsx +4 -0
  57. package/src/components/ui/index.ts +5 -0
  58. package/src/components/ui/input.tsx +2 -0
  59. package/src/components/ui/scroll-area.tsx +5 -0
  60. package/src/components/ui/textarea.tsx +7 -0
  61. package/src/index.ts +8 -0
  62. package/src/livechat-standalone.tsx +75 -0
  63. package/src/standalone.tsx +68 -0
  64. package/src/types.ts +65 -0
  65. package/tsconfig.json +14 -0
  66. package/vite.config.ts +76 -0
  67. package/README.md +0 -3
Binary file
@@ -0,0 +1,23 @@
1
+ interface LiveChatOptions {
2
+ apiUrl: string;
3
+ widgetId: string;
4
+ primaryColor?: string;
5
+ greeting?: string;
6
+ title?: string;
7
+ identifier?: string;
8
+ hmac?: string;
9
+ }
10
+ declare function init(options: LiveChatOptions): void;
11
+ declare global {
12
+ interface Window {
13
+ ChannelHubLiveChat: {
14
+ init: typeof init;
15
+ };
16
+ __channelhub_identity?: {
17
+ identifier: string;
18
+ hmac: string;
19
+ };
20
+ }
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=livechat-standalone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"livechat-standalone.d.ts","sourceRoot":"","sources":["../src/livechat-standalone.tsx"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,iBAAS,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAc5C;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,kBAAkB,EAAE;YAAE,IAAI,EAAE,OAAO,IAAI,CAAA;SAAE,CAAC;QAG1C,qBAAqB,CAAC,EAAE;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;KAC9D;CACF"}
@@ -0,0 +1,22 @@
1
+ import type { WidgetTheme } from './types.js';
2
+ interface InitOptions {
3
+ container?: string | HTMLElement;
4
+ apiUrl: string;
5
+ token: string;
6
+ theme?: WidgetTheme;
7
+ onNewMessage?: (conversationId: string) => void;
8
+ }
9
+ interface WidgetInstance {
10
+ unmount: () => void;
11
+ updateToken: (token: string) => void;
12
+ }
13
+ declare function init(options: InitOptions): WidgetInstance;
14
+ declare global {
15
+ interface Window {
16
+ ChannelHub: {
17
+ init: typeof init;
18
+ };
19
+ }
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=standalone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../src/standalone.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,UAAU,WAAW;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAED,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAID,iBAAS,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAwClD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE;YAAE,IAAI,EAAE,OAAO,IAAI,CAAA;SAAE,CAAC;KACnC;CACF"}
Binary file
@@ -0,0 +1,66 @@
1
+ export type Provider = 'facebook' | 'instagram' | 'telegram' | 'zalo' | string;
2
+ export type Connection = {
3
+ id: string;
4
+ provider: Provider;
5
+ type?: string;
6
+ metadata?: Record<string, unknown>;
7
+ };
8
+ export type Conversation = {
9
+ id: string;
10
+ connectionId: string;
11
+ providerConversationKey: string;
12
+ subject?: string;
13
+ contactName?: string;
14
+ contactPictureUrl?: string;
15
+ lastMessageAt?: string;
16
+ lastMessageText?: string;
17
+ lastMessageDirection?: 'inbound' | 'outbound';
18
+ messageCount?: number;
19
+ unreadCount?: number;
20
+ };
21
+ export type MessageAttachment = {
22
+ type: 'image' | 'video' | 'audio' | 'file' | 'sticker';
23
+ url: string;
24
+ mimeType?: string;
25
+ };
26
+ export type Message = {
27
+ id: string;
28
+ direction: 'inbound' | 'outbound';
29
+ status?: 'sending' | 'sent' | 'delivered' | 'read' | 'failed';
30
+ text?: string;
31
+ attachments?: MessageAttachment[];
32
+ occurredAt: string;
33
+ senderId?: string;
34
+ };
35
+ export type Page<T> = {
36
+ items: T[];
37
+ nextCursor?: string;
38
+ };
39
+ export type WidgetTheme = {
40
+ primaryColor?: string;
41
+ fontFamily?: string;
42
+ borderRadius?: string;
43
+ branding?: {
44
+ name?: string;
45
+ logoUrl?: string;
46
+ mark?: string;
47
+ };
48
+ };
49
+ export type ChannelHubInboxHandle = {
50
+ openConversation: (conversationId: string) => void;
51
+ refresh: () => void;
52
+ };
53
+ export type WidgetProps = {
54
+ apiUrl: string;
55
+ token: string;
56
+ theme?: WidgetTheme;
57
+ height?: number | string;
58
+ defaultConversationId?: string;
59
+ disableAttachments?: boolean;
60
+ disableNotificationSound?: boolean;
61
+ hideKeyboardHint?: boolean;
62
+ locale?: 'vi' | 'en';
63
+ onNewMessage?: (conversationId: string) => void;
64
+ onConversationSelect?: (conversationId: string) => void;
65
+ };
66
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/E,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAE/G,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE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qB,CAAC,EAAE,MAAM,CAAC;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,oBAAoB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;CACzD,CAAC"}
package/dist/web.avif ADDED
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@channelhub/widget",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.4",
4
+ "description": "Embeddable chat inbox widget for ChannelHub",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "registry": "https://registry.npmjs.org",
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/AKflower/channelhub.git",
13
+ "directory": "packages/widget"
14
+ },
15
+ "main": "./dist/index.cjs",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.cjs"
23
+ }
24
+ },
25
+ "peerDependencies": {
26
+ "react": ">=18",
27
+ "react-dom": ">=18"
28
+ },
29
+ "devDependencies": {
30
+ "@types/react": "^19.0.8",
31
+ "@types/react-dom": "^19.0.3",
32
+ "@vitejs/plugin-react": "^4.3.4",
33
+ "typescript": "^5.7.2",
34
+ "vite": "^6.0.0",
35
+ "vite-plugin-dts": "^4.3.0"
36
+ },
37
+ "dependencies": {
38
+ "lucide-react": "^0.468.0"
39
+ },
40
+ "scripts": {
41
+ "build": "vite build && tsc -p tsconfig.json --emitDeclarationOnly --outDir dist",
42
+ "build:standalone": "BUILD_TARGET=standalone vite build",
43
+ "build:livechat": "BUILD_TARGET=livechat vite build && cp dist/livechat.iife.js ../../apps/api/public/livechat.js",
44
+ "build:all": "pnpm build && pnpm build:standalone && pnpm build:livechat",
45
+ "dev": "vite build --watch",
46
+ "typecheck": "tsc -p tsconfig.json --noEmit"
47
+ }
6
48
  }
Binary file
Binary file
Binary file
Binary file
Binary file