@cometchat/skills-cli 2.4.1 → 3.0.0

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 (111) hide show
  1. package/README.md +45 -37
  2. package/dist/index.js +1821 -13090
  3. package/dist/utils/error-dictionary.js +0 -69
  4. package/package.json +10 -12
  5. package/dist/registry/schemas/config.schema.json +0 -119
  6. package/dist/registry/schemas/template.schema.json +0 -142
  7. package/dist/registry/v6/experiences/1-conversation-list/astro.template.json +0 -89
  8. package/dist/registry/v6/experiences/1-conversation-list/nextjs-pages.template.json +0 -83
  9. package/dist/registry/v6/experiences/1-conversation-list/nextjs.template.json +0 -83
  10. package/dist/registry/v6/experiences/1-conversation-list/react-router.template.json +0 -102
  11. package/dist/registry/v6/experiences/1-conversation-list/reactjs-dedicated-route.template.json +0 -81
  12. package/dist/registry/v6/experiences/1-conversation-list/reactjs.template.json +0 -86
  13. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/ChatApp.css.tpl +0 -43
  14. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/ChatApp.tsx.tpl +0 -86
  15. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/CometChatSelector.tsx.tpl +0 -40
  16. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/chat.astro.tpl +0 -17
  17. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/CometChatNoSSR.css.tpl +0 -43
  18. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/CometChatNoSSR.tsx.tpl +0 -86
  19. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/CometChatSelector.tsx.tpl +0 -41
  20. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/chat-page.tsx.tpl +0 -11
  21. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/CometChatNoSSR.css.tpl +0 -43
  22. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/CometChatNoSSR.tsx.tpl +0 -88
  23. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/CometChatSelector.tsx.tpl +0 -41
  24. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/chat-page.tsx.tpl +0 -15
  25. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChat-route.tsx.tpl +0 -22
  26. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChatNoSSR.css.tpl +0 -43
  27. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChatNoSSR.tsx.tpl +0 -87
  28. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChatSelector.tsx.tpl +0 -40
  29. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/App.css.tpl +0 -40
  30. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/App.tsx.tpl +0 -55
  31. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/CometChatSelector.tsx.tpl +0 -40
  32. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/main.tsx.tpl +0 -46
  33. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs-dedicated-route/ChatPage.tsx.tpl +0 -87
  34. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs-dedicated-route/CometChatMessenger.css.tpl +0 -20
  35. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs-dedicated-route/CometChatMessenger.tsx.tpl +0 -54
  36. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs-dedicated-route/CometChatSelector.tsx.tpl +0 -40
  37. package/dist/registry/v6/experiences/2-one-to-one/astro.template.json +0 -81
  38. package/dist/registry/v6/experiences/2-one-to-one/nextjs.template.json +0 -77
  39. package/dist/registry/v6/experiences/2-one-to-one/react-router.template.json +0 -93
  40. package/dist/registry/v6/experiences/2-one-to-one/reactjs-dedicated-route.template.json +0 -75
  41. package/dist/registry/v6/experiences/2-one-to-one/reactjs.template.json +0 -80
  42. package/dist/registry/v6/experiences/2-one-to-one/templates/astro/ChatApp.css.tpl +0 -21
  43. package/dist/registry/v6/experiences/2-one-to-one/templates/astro/ChatApp.tsx.tpl +0 -66
  44. package/dist/registry/v6/experiences/2-one-to-one/templates/astro/chat.astro.tpl +0 -17
  45. package/dist/registry/v6/experiences/2-one-to-one/templates/nextjs/CometChatNoSSR.css.tpl +0 -21
  46. package/dist/registry/v6/experiences/2-one-to-one/templates/nextjs/CometChatNoSSR.tsx.tpl +0 -66
  47. package/dist/registry/v6/experiences/2-one-to-one/templates/nextjs/chat-page.tsx.tpl +0 -11
  48. package/dist/registry/v6/experiences/2-one-to-one/templates/react-router/CometChat-route.tsx.tpl +0 -21
  49. package/dist/registry/v6/experiences/2-one-to-one/templates/react-router/CometChatNoSSR.css.tpl +0 -21
  50. package/dist/registry/v6/experiences/2-one-to-one/templates/react-router/CometChatNoSSR.tsx.tpl +0 -67
  51. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs/App.css.tpl +0 -4
  52. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs/App.tsx.tpl +0 -44
  53. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs/main.tsx.tpl +0 -46
  54. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs-dedicated-route/ChatPage.tsx.tpl +0 -84
  55. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs-dedicated-route/CometChatMessenger.css.tpl +0 -9
  56. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs-dedicated-route/CometChatMessenger.tsx.tpl +0 -43
  57. package/dist/registry/v6/experiences/3-tab-based/astro.template.json +0 -93
  58. package/dist/registry/v6/experiences/3-tab-based/nextjs.template.json +0 -90
  59. package/dist/registry/v6/experiences/3-tab-based/react-router.template.json +0 -105
  60. package/dist/registry/v6/experiences/3-tab-based/reactjs-dedicated-route.template.json +0 -89
  61. package/dist/registry/v6/experiences/3-tab-based/reactjs.template.json +0 -93
  62. package/dist/registry/v6/experiences/3-tab-based/templates/astro/ChatApp.css.tpl +0 -39
  63. package/dist/registry/v6/experiences/3-tab-based/templates/astro/ChatApp.tsx.tpl +0 -93
  64. package/dist/registry/v6/experiences/3-tab-based/templates/astro/CometChatTabs.css.tpl +0 -43
  65. package/dist/registry/v6/experiences/3-tab-based/templates/astro/CometChatTabs.tsx.tpl +0 -72
  66. package/dist/registry/v6/experiences/3-tab-based/templates/astro/chat.astro.tpl +0 -17
  67. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatNoSSR.css.tpl +0 -39
  68. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatNoSSR.tsx.tpl +0 -93
  69. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatTabs.css.tpl +0 -43
  70. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatTabs.tsx.tpl +0 -73
  71. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/chat-page.tsx.tpl +0 -11
  72. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChat-route.tsx.tpl +0 -21
  73. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatNoSSR.css.tpl +0 -39
  74. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatNoSSR.tsx.tpl +0 -94
  75. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatTabs.css.tpl +0 -43
  76. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatTabs.tsx.tpl +0 -72
  77. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/App.css.tpl +0 -7
  78. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/App.tsx.tpl +0 -62
  79. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/CometChatTabs.css.tpl +0 -43
  80. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/CometChatTabs.tsx.tpl +0 -72
  81. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/main.tsx.tpl +0 -46
  82. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/ChatPage.tsx.tpl +0 -84
  83. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/CometChatMessenger.css.tpl +0 -11
  84. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/CometChatMessenger.tsx.tpl +0 -61
  85. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/CometChatTabs.css.tpl +0 -43
  86. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/CometChatTabs.tsx.tpl +0 -72
  87. package/dist/registry/v6/features/catalog.json +0 -990
  88. package/dist/registry/v6/production/astro/cometchat-token.ts.tpl +0 -86
  89. package/dist/registry/v6/production/astro.template.json +0 -51
  90. package/dist/registry/v6/production/nextjs/route.ts.tpl +0 -79
  91. package/dist/registry/v6/production/nextjs.template.json +0 -50
  92. package/dist/registry/v6/production/react-router/api.cometchat-token.ts.tpl +0 -73
  93. package/dist/registry/v6/production/react-router.template.json +0 -58
  94. package/dist/registry/v6/user-mgmt/astro/cometchat-user.ts.tpl +0 -164
  95. package/dist/registry/v6/user-mgmt/astro.template.json +0 -33
  96. package/dist/registry/v6/user-mgmt/nextjs/route.ts.tpl +0 -212
  97. package/dist/registry/v6/user-mgmt/nextjs.template.json +0 -57
  98. package/dist/registry/v6/user-mgmt/react-router/api.cometchat-user.ts.tpl +0 -176
  99. package/dist/registry/v6/user-mgmt/react-router.template.json +0 -40
  100. package/dist/registry/v6/widget/astro/CometChatWidget.css.tpl +0 -105
  101. package/dist/registry/v6/widget/astro/CometChatWidget.tsx.tpl +0 -88
  102. package/dist/registry/v6/widget/astro.template.json +0 -38
  103. package/dist/registry/v6/widget/nextjs/CometChatWidget.css.tpl +0 -105
  104. package/dist/registry/v6/widget/nextjs/CometChatWidget.tsx.tpl +0 -88
  105. package/dist/registry/v6/widget/nextjs.template.json +0 -40
  106. package/dist/registry/v6/widget/react-router/CometChatWidget.css.tpl +0 -105
  107. package/dist/registry/v6/widget/react-router/CometChatWidget.tsx.tpl +0 -98
  108. package/dist/registry/v6/widget/react-router.template.json +0 -36
  109. package/dist/registry/v6/widget/reactjs/CometChatWidget.css.tpl +0 -105
  110. package/dist/registry/v6/widget/reactjs/CometChatWidget.tsx.tpl +0 -89
  111. package/dist/registry/v6/widget/reactjs.template.json +0 -36
@@ -1,38 +0,0 @@
1
- {
2
- "$schema": "../../schemas/template.schema.json",
3
- "version": "1.0.0",
4
- "experience_id": 1,
5
- "framework": "astro",
6
- "sdk_compatibility": ">=6.0.0 <7.0.0",
7
- "default_placement": "spa-root",
8
- "deps": [],
9
- "env_vars": [],
10
- "files": [
11
- {
12
- "path": "src/cometchat/CometChatWidget.tsx",
13
- "action": "create",
14
- "template_ref": "CometChatWidget.tsx.tpl",
15
- "owned": true
16
- },
17
- {
18
- "path": "src/cometchat/CometChatWidget.css",
19
- "action": "create",
20
- "template_ref": "CometChatWidget.css.tpl",
21
- "owned": true
22
- }
23
- ],
24
- "verify_rules": [],
25
- "next_steps": [
26
- "1. The widget component is now at src/cometchat/CometChatWidget.tsx (a React island).",
27
- "2. Render it in any .astro layout or page using `client:only=\"react\"` so Astro skips SSR entirely:",
28
- " ---",
29
- " import CometChatWidget from \"../cometchat/CometChatWidget\";",
30
- " ---",
31
- " <CometChatWidget client:only=\"react\" />",
32
- "3. The widget reuses your existing CometChat init/login flow from your existing ChatApp island.",
33
- " You do NOT need to call init/login again inside the widget.",
34
- "4. Important: the widget must live in the same page where init/login runs, OR the page must mount your existing ChatApp island first. Otherwise the SDK won't be initialized when the widget tries to render.",
35
- "5. To customize position/size, edit the .cometchat-widget-button class in CometChatWidget.css.",
36
- "6. The button appears in the bottom-right corner. Click it to open a drawer with the conversation list + message thread."
37
- ]
38
- }
@@ -1,105 +0,0 @@
1
- /**
2
- * CometChatWidget styles — floating button + drawer.
3
- *
4
- * Edit the .cometchat-widget-button selector to change the button position
5
- * (default: bottom-right). Edit the .cometchat-widget-drawer selector to
6
- * change the drawer size + position.
7
- */
8
-
9
- .cometchat-widget-button {
10
- position: fixed;
11
- bottom: 24px;
12
- right: 24px;
13
- width: 56px;
14
- height: 56px;
15
- border-radius: 50%;
16
- border: none;
17
- background: var(--cometchat-primary-color, #6852D6);
18
- color: white;
19
- font-size: 24px;
20
- cursor: pointer;
21
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
22
- z-index: 9999;
23
- display: flex;
24
- align-items: center;
25
- justify-content: center;
26
- transition: transform 0.2s ease, box-shadow 0.2s ease;
27
- }
28
-
29
- .cometchat-widget-button:hover {
30
- transform: scale(1.05);
31
- box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
32
- }
33
-
34
- .cometchat-widget-button:active {
35
- transform: scale(0.98);
36
- }
37
-
38
- .cometchat-widget-drawer {
39
- position: fixed;
40
- bottom: 96px;
41
- right: 24px;
42
- width: 720px;
43
- max-width: calc(100vw - 48px);
44
- height: 600px;
45
- max-height: calc(100vh - 120px);
46
- background: white;
47
- border-radius: 12px;
48
- box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
49
- z-index: 9998;
50
- display: flex;
51
- overflow: hidden;
52
- border: 1px solid var(--cometchat-border-color-default, #e8e8e8);
53
- }
54
-
55
- .cometchat-widget-conversations {
56
- width: 280px;
57
- border-right: 1px solid var(--cometchat-border-color-default, #e8e8e8);
58
- overflow: hidden;
59
- display: flex;
60
- flex-direction: column;
61
- }
62
-
63
- .cometchat-widget-conversations > .cometchat {
64
- overflow: hidden;
65
- }
66
-
67
- .cometchat-widget-messages {
68
- flex: 1;
69
- display: flex;
70
- flex-direction: column;
71
- overflow: hidden;
72
- }
73
-
74
- .cometchat-widget-empty {
75
- flex: 1;
76
- display: flex;
77
- align-items: center;
78
- justify-content: center;
79
- background: var(--cometchat-background-color-03, #f5f5f5);
80
- color: var(--cometchat-text-color-secondary, #727272);
81
- font: var(--cometchat-font-body-regular, 400 14px Roboto);
82
- padding: 16px;
83
- text-align: center;
84
- }
85
-
86
- @media (max-width: 600px) {
87
- .cometchat-widget-drawer {
88
- bottom: 16px;
89
- right: 16px;
90
- left: 16px;
91
- width: auto;
92
- height: calc(100vh - 100px);
93
- flex-direction: column;
94
- }
95
- .cometchat-widget-conversations {
96
- width: 100%;
97
- height: 200px;
98
- border-right: none;
99
- border-bottom: 1px solid var(--cometchat-border-color-default, #e8e8e8);
100
- }
101
- .cometchat-widget-button {
102
- bottom: 16px;
103
- right: 16px;
104
- }
105
- }
@@ -1,88 +0,0 @@
1
- "use client";
2
- /**
3
- * CometChatWidget — floating chat overlay (Next.js App Router).
4
- *
5
- * Marked "use client" because it uses React state and the CometChat SDK
6
- * (which talks to the browser). Render it from any client component or
7
- * import it from a server component via:
8
- * const CometChatWidget = dynamic(() => import("./CometChatWidget"), { ssr: false });
9
- *
10
- * Assumes CometChatUIKit.init() and CometChatUIKit.login() have already
11
- * been called by the existing CometChatNoSSR.tsx integration. The widget
12
- * does NOT initialize CometChat — it just renders the existing logged-in
13
- * user's chat.
14
- */
15
- import { useEffect, useState } from "react";
16
- import {
17
- CometChatMessageComposer,
18
- CometChatMessageHeader,
19
- CometChatMessageList,
20
- } from "@cometchat/chat-uikit-react";
21
- import { CometChat } from "@cometchat/chat-sdk-javascript";
22
- import { CometChatSelector } from "./CometChatSelector";
23
- import "./CometChatWidget.css";
24
-
25
- export default function CometChatWidget() {
26
- const [open, setOpen] = useState(false);
27
- const [selectedUser, setSelectedUser] = useState<CometChat.User | undefined>();
28
- const [selectedGroup, setSelectedGroup] = useState<CometChat.Group | undefined>();
29
-
30
- // Close on Escape key
31
- useEffect(() => {
32
- if (!open) return;
33
- const handler = (e: KeyboardEvent) => {
34
- if (e.key === "Escape") setOpen(false);
35
- };
36
- window.addEventListener("keydown", handler);
37
- return () => window.removeEventListener("keydown", handler);
38
- }, [open]);
39
-
40
- return (
41
- <>
42
- <button
43
- type="button"
44
- className="cometchat-widget-button"
45
- onClick={() => setOpen((v) => !v)}
46
- aria-label={open ? "Close chat" : "Open chat"}
47
- >
48
- {open ? "✕" : "💬"}
49
- </button>
50
-
51
- {open && (
52
- <div className="cometchat-widget-drawer" role="dialog" aria-label="Chat">
53
- <div className="cometchat-widget-conversations">
54
- <CometChatSelector
55
- onSelectorItemClicked={(activeItem) => {
56
- const item =
57
- activeItem instanceof CometChat.Conversation
58
- ? activeItem.getConversationWith()
59
- : activeItem;
60
- if (item instanceof CometChat.User) {
61
- setSelectedUser(item);
62
- setSelectedGroup(undefined);
63
- } else if (item instanceof CometChat.Group) {
64
- setSelectedUser(undefined);
65
- setSelectedGroup(item);
66
- }
67
- }}
68
- />
69
- </div>
70
- {selectedUser || selectedGroup ? (
71
- <div className="cometchat-widget-messages">
72
- {selectedUser && <CometChatMessageHeader user={selectedUser} />}
73
- {selectedGroup && <CometChatMessageHeader group={selectedGroup} />}
74
- {selectedUser && <CometChatMessageList user={selectedUser} />}
75
- {selectedGroup && <CometChatMessageList group={selectedGroup} />}
76
- {selectedUser && <CometChatMessageComposer user={selectedUser} />}
77
- {selectedGroup && <CometChatMessageComposer group={selectedGroup} />}
78
- </div>
79
- ) : (
80
- <div className="cometchat-widget-empty">
81
- Select a conversation to start chatting
82
- </div>
83
- )}
84
- </div>
85
- )}
86
- </>
87
- );
88
- }
@@ -1,40 +0,0 @@
1
- {
2
- "$schema": "../../schemas/template.schema.json",
3
- "version": "1.0.0",
4
- "experience_id": 1,
5
- "framework": "nextjs",
6
- "sdk_compatibility": ">=6.0.0 <7.0.0",
7
- "default_placement": "spa-root",
8
- "deps": [],
9
- "env_vars": [],
10
- "files": [
11
- {
12
- "path": "src/app/cometchat/CometChatWidget.tsx",
13
- "action": "create",
14
- "template_ref": "CometChatWidget.tsx.tpl",
15
- "owned": true
16
- },
17
- {
18
- "path": "src/app/cometchat/CometChatWidget.css",
19
- "action": "create",
20
- "template_ref": "CometChatWidget.css.tpl",
21
- "owned": true
22
- }
23
- ],
24
- "verify_rules": [],
25
- "next_steps": [
26
- "1. The widget component is now at src/app/cometchat/CometChatWidget.tsx — it has a `\"use client\"` directive so it can use React state + the CometChat SDK in the browser.",
27
- "2. Render it in any client component or layout. Two options:",
28
- " A) Direct import in a client component:",
29
- " import CometChatWidget from \"./cometchat/CometChatWidget\";",
30
- " <CometChatWidget />",
31
- " B) Render from a server component / layout via dynamic({ssr:false}):",
32
- " import dynamic from \"next/dynamic\";",
33
- " const CometChatWidget = dynamic(() => import(\"./cometchat/CometChatWidget\"), { ssr: false });",
34
- " <CometChatWidget />",
35
- "3. The widget reuses your existing CometChat init/login flow (CometChatNoSSR.tsx).",
36
- " You do NOT need to call init/login again inside the widget.",
37
- "4. To customize position/size, edit the .cometchat-widget-button class in CometChatWidget.css.",
38
- "5. The fixed-position button appears in the bottom-right corner. Click it to open the conversation list + message thread drawer."
39
- ]
40
- }
@@ -1,105 +0,0 @@
1
- /**
2
- * CometChatWidget styles — floating button + drawer.
3
- *
4
- * Edit the .cometchat-widget-button selector to change the button position
5
- * (default: bottom-right). Edit the .cometchat-widget-drawer selector to
6
- * change the drawer size + position.
7
- */
8
-
9
- .cometchat-widget-button {
10
- position: fixed;
11
- bottom: 24px;
12
- right: 24px;
13
- width: 56px;
14
- height: 56px;
15
- border-radius: 50%;
16
- border: none;
17
- background: var(--cometchat-primary-color, #6852D6);
18
- color: white;
19
- font-size: 24px;
20
- cursor: pointer;
21
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
22
- z-index: 9999;
23
- display: flex;
24
- align-items: center;
25
- justify-content: center;
26
- transition: transform 0.2s ease, box-shadow 0.2s ease;
27
- }
28
-
29
- .cometchat-widget-button:hover {
30
- transform: scale(1.05);
31
- box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
32
- }
33
-
34
- .cometchat-widget-button:active {
35
- transform: scale(0.98);
36
- }
37
-
38
- .cometchat-widget-drawer {
39
- position: fixed;
40
- bottom: 96px;
41
- right: 24px;
42
- width: 720px;
43
- max-width: calc(100vw - 48px);
44
- height: 600px;
45
- max-height: calc(100vh - 120px);
46
- background: white;
47
- border-radius: 12px;
48
- box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
49
- z-index: 9998;
50
- display: flex;
51
- overflow: hidden;
52
- border: 1px solid var(--cometchat-border-color-default, #e8e8e8);
53
- }
54
-
55
- .cometchat-widget-conversations {
56
- width: 280px;
57
- border-right: 1px solid var(--cometchat-border-color-default, #e8e8e8);
58
- overflow: hidden;
59
- display: flex;
60
- flex-direction: column;
61
- }
62
-
63
- .cometchat-widget-conversations > .cometchat {
64
- overflow: hidden;
65
- }
66
-
67
- .cometchat-widget-messages {
68
- flex: 1;
69
- display: flex;
70
- flex-direction: column;
71
- overflow: hidden;
72
- }
73
-
74
- .cometchat-widget-empty {
75
- flex: 1;
76
- display: flex;
77
- align-items: center;
78
- justify-content: center;
79
- background: var(--cometchat-background-color-03, #f5f5f5);
80
- color: var(--cometchat-text-color-secondary, #727272);
81
- font: var(--cometchat-font-body-regular, 400 14px Roboto);
82
- padding: 16px;
83
- text-align: center;
84
- }
85
-
86
- @media (max-width: 600px) {
87
- .cometchat-widget-drawer {
88
- bottom: 16px;
89
- right: 16px;
90
- left: 16px;
91
- width: auto;
92
- height: calc(100vh - 100px);
93
- flex-direction: column;
94
- }
95
- .cometchat-widget-conversations {
96
- width: 100%;
97
- height: 200px;
98
- border-right: none;
99
- border-bottom: 1px solid var(--cometchat-border-color-default, #e8e8e8);
100
- }
101
- .cometchat-widget-button {
102
- bottom: 16px;
103
- right: 16px;
104
- }
105
- }
@@ -1,98 +0,0 @@
1
- /**
2
- * CometChatWidget — floating chat overlay (React Router v7 framework mode).
3
- *
4
- * React Router v7 SSRs by default. The CometChat SDK uses browser globals
5
- * (WebSocket, IndexedDB, etc.) that don't exist on the server, so the
6
- * widget defers its real render until after hydration via a mounted check.
7
- *
8
- * Assumes CometChatUIKit.init() and CometChatUIKit.login() have already
9
- * been called by the existing chat route. The widget does NOT initialize
10
- * CometChat — it just renders the existing logged-in user's chat.
11
- *
12
- * To use:
13
- * import CometChatWidget from "./cometchat/CometChatWidget";
14
- * // ...
15
- * <CometChatWidget />
16
- */
17
- import { useEffect, useState } from "react";
18
- import {
19
- CometChatMessageComposer,
20
- CometChatMessageHeader,
21
- CometChatMessageList,
22
- } from "@cometchat/chat-uikit-react";
23
- import { CometChat } from "@cometchat/chat-sdk-javascript";
24
- import { CometChatSelector } from "./CometChatSelector";
25
- import "./CometChatWidget.css";
26
-
27
- export default function CometChatWidget() {
28
- // SSR-safe: render nothing on the server, mount on the client.
29
- const [mounted, setMounted] = useState(false);
30
- useEffect(() => {
31
- setMounted(true);
32
- }, []);
33
-
34
- const [open, setOpen] = useState(false);
35
- const [selectedUser, setSelectedUser] = useState<CometChat.User | undefined>();
36
- const [selectedGroup, setSelectedGroup] = useState<CometChat.Group | undefined>();
37
-
38
- // Close on Escape key
39
- useEffect(() => {
40
- if (!open) return;
41
- const handler = (e: KeyboardEvent) => {
42
- if (e.key === "Escape") setOpen(false);
43
- };
44
- window.addEventListener("keydown", handler);
45
- return () => window.removeEventListener("keydown", handler);
46
- }, [open]);
47
-
48
- if (!mounted) return null;
49
-
50
- return (
51
- <>
52
- <button
53
- type="button"
54
- className="cometchat-widget-button"
55
- onClick={() => setOpen((v) => !v)}
56
- aria-label={open ? "Close chat" : "Open chat"}
57
- >
58
- {open ? "✕" : "💬"}
59
- </button>
60
-
61
- {open && (
62
- <div className="cometchat-widget-drawer" role="dialog" aria-label="Chat">
63
- <div className="cometchat-widget-conversations">
64
- <CometChatSelector
65
- onSelectorItemClicked={(activeItem) => {
66
- const item =
67
- activeItem instanceof CometChat.Conversation
68
- ? activeItem.getConversationWith()
69
- : activeItem;
70
- if (item instanceof CometChat.User) {
71
- setSelectedUser(item);
72
- setSelectedGroup(undefined);
73
- } else if (item instanceof CometChat.Group) {
74
- setSelectedUser(undefined);
75
- setSelectedGroup(item);
76
- }
77
- }}
78
- />
79
- </div>
80
- {selectedUser || selectedGroup ? (
81
- <div className="cometchat-widget-messages">
82
- {selectedUser && <CometChatMessageHeader user={selectedUser} />}
83
- {selectedGroup && <CometChatMessageHeader group={selectedGroup} />}
84
- {selectedUser && <CometChatMessageList user={selectedUser} />}
85
- {selectedGroup && <CometChatMessageList group={selectedGroup} />}
86
- {selectedUser && <CometChatMessageComposer user={selectedUser} />}
87
- {selectedGroup && <CometChatMessageComposer group={selectedGroup} />}
88
- </div>
89
- ) : (
90
- <div className="cometchat-widget-empty">
91
- Select a conversation to start chatting
92
- </div>
93
- )}
94
- </div>
95
- )}
96
- </>
97
- );
98
- }
@@ -1,36 +0,0 @@
1
- {
2
- "$schema": "../../schemas/template.schema.json",
3
- "version": "1.0.0",
4
- "experience_id": 1,
5
- "framework": "react-router",
6
- "sdk_compatibility": ">=6.0.0 <7.0.0",
7
- "default_placement": "spa-root",
8
- "deps": [],
9
- "env_vars": [],
10
- "files": [
11
- {
12
- "path": "app/cometchat/CometChatWidget.tsx",
13
- "action": "create",
14
- "template_ref": "CometChatWidget.tsx.tpl",
15
- "owned": true
16
- },
17
- {
18
- "path": "app/cometchat/CometChatWidget.css",
19
- "action": "create",
20
- "template_ref": "CometChatWidget.css.tpl",
21
- "owned": true
22
- }
23
- ],
24
- "verify_rules": [],
25
- "next_steps": [
26
- "1. The widget component is now at app/cometchat/CometChatWidget.tsx.",
27
- "2. It uses an internal mounted-check (useState + useEffect) so React Router v7's SSR pass renders nothing on the server, then mounts the real widget after hydration.",
28
- "3. Render it in your root layout (app/root.tsx) or any route component:",
29
- " import CometChatWidget from \"./cometchat/CometChatWidget\";",
30
- " // Then render <CometChatWidget /> anywhere in the JSX tree.",
31
- "4. The widget reuses your existing CometChat init/login flow from the chat route.",
32
- " You do NOT need to call init/login again inside the widget.",
33
- "5. To customize position/size, edit the .cometchat-widget-button class in CometChatWidget.css.",
34
- "6. The button appears in the bottom-right corner. Click it to open a drawer with the conversation list + message thread."
35
- ]
36
- }
@@ -1,105 +0,0 @@
1
- /**
2
- * CometChatWidget styles — floating button + drawer.
3
- *
4
- * Edit the .cometchat-widget-button selector to change the button position
5
- * (default: bottom-right). Edit the .cometchat-widget-drawer selector to
6
- * change the drawer size + position.
7
- */
8
-
9
- .cometchat-widget-button {
10
- position: fixed;
11
- bottom: 24px;
12
- right: 24px;
13
- width: 56px;
14
- height: 56px;
15
- border-radius: 50%;
16
- border: none;
17
- background: var(--cometchat-primary-color, #6852D6);
18
- color: white;
19
- font-size: 24px;
20
- cursor: pointer;
21
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
22
- z-index: 9999;
23
- display: flex;
24
- align-items: center;
25
- justify-content: center;
26
- transition: transform 0.2s ease, box-shadow 0.2s ease;
27
- }
28
-
29
- .cometchat-widget-button:hover {
30
- transform: scale(1.05);
31
- box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
32
- }
33
-
34
- .cometchat-widget-button:active {
35
- transform: scale(0.98);
36
- }
37
-
38
- .cometchat-widget-drawer {
39
- position: fixed;
40
- bottom: 96px;
41
- right: 24px;
42
- width: 720px;
43
- max-width: calc(100vw - 48px);
44
- height: 600px;
45
- max-height: calc(100vh - 120px);
46
- background: white;
47
- border-radius: 12px;
48
- box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
49
- z-index: 9998;
50
- display: flex;
51
- overflow: hidden;
52
- border: 1px solid var(--cometchat-border-color-default, #e8e8e8);
53
- }
54
-
55
- .cometchat-widget-conversations {
56
- width: 280px;
57
- border-right: 1px solid var(--cometchat-border-color-default, #e8e8e8);
58
- overflow: hidden;
59
- display: flex;
60
- flex-direction: column;
61
- }
62
-
63
- .cometchat-widget-conversations > .cometchat {
64
- overflow: hidden;
65
- }
66
-
67
- .cometchat-widget-messages {
68
- flex: 1;
69
- display: flex;
70
- flex-direction: column;
71
- overflow: hidden;
72
- }
73
-
74
- .cometchat-widget-empty {
75
- flex: 1;
76
- display: flex;
77
- align-items: center;
78
- justify-content: center;
79
- background: var(--cometchat-background-color-03, #f5f5f5);
80
- color: var(--cometchat-text-color-secondary, #727272);
81
- font: var(--cometchat-font-body-regular, 400 14px Roboto);
82
- padding: 16px;
83
- text-align: center;
84
- }
85
-
86
- @media (max-width: 600px) {
87
- .cometchat-widget-drawer {
88
- bottom: 16px;
89
- right: 16px;
90
- left: 16px;
91
- width: auto;
92
- height: calc(100vh - 100px);
93
- flex-direction: column;
94
- }
95
- .cometchat-widget-conversations {
96
- width: 100%;
97
- height: 200px;
98
- border-right: none;
99
- border-bottom: 1px solid var(--cometchat-border-color-default, #e8e8e8);
100
- }
101
- .cometchat-widget-button {
102
- bottom: 16px;
103
- right: 16px;
104
- }
105
- }