@opencx/widget 2.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 (125) hide show
  1. package/README.md +105 -0
  2. package/dist/basic.cjs +259 -0
  3. package/dist/basic.cjs.map +1 -0
  4. package/dist/basic.d.ts +2 -0
  5. package/dist/basic.js +40507 -0
  6. package/dist/basic.js.map +1 -0
  7. package/dist/core/client/api.d.ts +15 -0
  8. package/dist/core/client/client.d.ts +39 -0
  9. package/dist/core/client/index.d.ts +1 -0
  10. package/dist/core/errors/index.d.ts +21 -0
  11. package/dist/core/index.d.ts +3 -0
  12. package/dist/core/managers/chathistory-manager.d.ts +61 -0
  13. package/dist/core/managers/session-manager.d.ts +35 -0
  14. package/dist/core/platform/index.d.ts +20 -0
  15. package/dist/core/transport/http.transport.d.ts +17 -0
  16. package/dist/core/transport/transport.d.ts +25 -0
  17. package/dist/core/types/helpers.d.ts +5 -0
  18. package/dist/core/types/index.d.ts +32 -0
  19. package/dist/core/types/messages.d.ts +43 -0
  20. package/dist/core/types/prelude.d.ts +14 -0
  21. package/dist/core/types/pub-sub.d.ts +94 -0
  22. package/dist/core/types/schemas.d.ts +489 -0
  23. package/dist/core/types/transport.d.ts +31 -0
  24. package/dist/core/utils/genId.d.ts +2 -0
  25. package/dist/core/utils/genId.test.d.ts +1 -0
  26. package/dist/core/utils/history-to-widget-messages.d.ts +4 -0
  27. package/dist/history-to-widget-messages-CP0hKjhv.js +195 -0
  28. package/dist/history-to-widget-messages-CP0hKjhv.js.map +1 -0
  29. package/dist/history-to-widget-messages-CdbZolRN.cjs +2 -0
  30. package/dist/history-to-widget-messages-CdbZolRN.cjs.map +1 -0
  31. package/dist/index-C11ivBh5.js +2604 -0
  32. package/dist/index-C11ivBh5.js.map +1 -0
  33. package/dist/index-DQmRZV3b.cjs +18 -0
  34. package/dist/index-DQmRZV3b.cjs.map +1 -0
  35. package/dist/index.cjs +2 -0
  36. package/dist/index.cjs.map +1 -0
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +445 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/react-lib/Root.d.ts +6 -0
  41. package/dist/react-lib/hooks/handle-socket-messages.d.ts +27 -0
  42. package/dist/react-lib/hooks/index.d.ts +6 -0
  43. package/dist/react-lib/hooks/socket.d.ts +11 -0
  44. package/dist/react-lib/hooks/socketState.d.ts +2 -0
  45. package/dist/react-lib/hooks/use-sound.d.ts +13 -0
  46. package/dist/react-lib/hooks/use-sound.test.d.ts +1 -0
  47. package/dist/react-lib/hooks/use-sync-state.test.d.ts +1 -0
  48. package/dist/react-lib/hooks/useAbstractChat.d.ts +159 -0
  49. package/dist/react-lib/hooks/useAxiosInstance.d.ts +121 -0
  50. package/dist/react-lib/hooks/useBaseClient.d.ts +2 -0
  51. package/dist/react-lib/hooks/useScrollTo.d.ts +2 -0
  52. package/dist/react-lib/hooks/useSyncState.d.ts +4 -0
  53. package/dist/react-lib/hooks/useTimeoutState.d.ts +3 -0
  54. package/dist/react-lib/hooks/useUploadFiles.d.ts +21 -0
  55. package/dist/react-lib/hooks/useVote.d.ts +2 -0
  56. package/dist/react-lib/hooks/useWidgetContentHeight.d.ts +9 -0
  57. package/dist/react-lib/index.d.ts +10 -0
  58. package/dist/react-lib/locales/ar.locale.d.ts +2 -0
  59. package/dist/react-lib/locales/de.locale.d.ts +2 -0
  60. package/dist/react-lib/locales/en.locale.d.ts +55 -0
  61. package/dist/react-lib/locales/fr.locale.d.ts +2 -0
  62. package/dist/react-lib/locales/helper.d.ts +65 -0
  63. package/dist/react-lib/locales/index.d.ts +3 -0
  64. package/dist/react-lib/locales/nl.locale.d.ts +2 -0
  65. package/dist/react-lib/locales/pt.locale.d.ts +2 -0
  66. package/dist/react-lib/providers/ChatProvider.d.ts +135 -0
  67. package/dist/react-lib/providers/ClientProvider.d.ts +7 -0
  68. package/dist/react-lib/providers/ConfigDataProvider.d.ts +62 -0
  69. package/dist/react-lib/providers/ContactProvider.d.ts +58 -0
  70. package/dist/react-lib/providers/LocalesProvider.d.ts +11 -0
  71. package/dist/react-lib/providers/componentRegistry.d.ts +13 -0
  72. package/dist/react-lib/providers/use-widget-sfx.d.ts +7 -0
  73. package/dist/react-lib/providers/usePreludeData.d.ts +2 -0
  74. package/dist/react-lib/types/components.d.ts +10 -0
  75. package/dist/react-lib/types/index.d.ts +6 -0
  76. package/dist/react-lib/types/options.d.ts +43 -0
  77. package/dist/react-lib/utils/create-safe-context.d.ts +1 -0
  78. package/dist/react-lib/utils/debug.d.ts +2 -0
  79. package/dist/react-lib/utils/getters.d.ts +24 -0
  80. package/dist/react-lib/utils/index.d.ts +1 -0
  81. package/dist/react.cjs +2 -0
  82. package/dist/react.cjs.map +1 -0
  83. package/dist/react.d.ts +2 -0
  84. package/dist/react.js +41 -0
  85. package/dist/react.js.map +1 -0
  86. package/dist/src/@components/BotMessage.d.ts +9 -0
  87. package/dist/src/@components/BotMessageWrapper.d.ts +7 -0
  88. package/dist/src/@components/ChatEvent.component.d.ts +9 -0
  89. package/dist/src/@components/Fallback.component.d.ts +8 -0
  90. package/dist/src/@components/Loading.component.d.ts +2 -0
  91. package/dist/src/@components/OpenLogoSvg.d.ts +4 -0
  92. package/dist/src/@components/Text.component.d.ts +3 -0
  93. package/dist/src/@components/index.d.ts +6 -0
  94. package/dist/src/@components/markdown.d.ts +3 -0
  95. package/dist/src/components/MotionDiv.d.ts +18 -0
  96. package/dist/src/components/RenderFile.d.ts +7 -0
  97. package/dist/src/components/avatar.d.ts +6 -0
  98. package/dist/src/components/button.d.ts +11 -0
  99. package/dist/src/components/dialog.d.ts +276 -0
  100. package/dist/src/components/dropdown-menu.d.ts +27 -0
  101. package/dist/src/components/input.d.ts +5 -0
  102. package/dist/src/components/keyboard.d.ts +7 -0
  103. package/dist/src/components/popover.d.ts +8 -0
  104. package/dist/src/components/skeleton.d.ts +3 -0
  105. package/dist/src/components/switch.d.ts +4 -0
  106. package/dist/src/components/tooltip.d.ts +10 -0
  107. package/dist/src/components/userMessage.d.ts +8 -0
  108. package/dist/src/components/wobble.d.ts +15 -0
  109. package/dist/src/designs/basic/WidgetPopoverTrigger.d.ts +5 -0
  110. package/dist/src/designs/basic/index.d.ts +5 -0
  111. package/dist/src/designs/basic/screens/chat-screen/ChatFooter.d.ts +2 -0
  112. package/dist/src/designs/basic/screens/chat-screen/ChatHeader.d.ts +2 -0
  113. package/dist/src/designs/basic/screens/chat-screen/ChatScreen.d.ts +2 -0
  114. package/dist/src/designs/basic/screens/chat-screen/SessionClosedDialog.d.ts +2 -0
  115. package/dist/src/designs/basic/screens/root-screen.d.ts +2 -0
  116. package/dist/src/designs/basic/screens/welcome-screen/WelcomeScreen.d.ts +2 -0
  117. package/dist/src/designs/constants.d.ts +15 -0
  118. package/dist/src/hooks/useShouldCollectData.d.ts +3 -0
  119. package/dist/src/index.d.ts +9 -0
  120. package/dist/src/render.d.ts +2 -0
  121. package/dist/src/utils.d.ts +2 -0
  122. package/dist/style.css +1 -0
  123. package/dist-embed/script.js +476 -0
  124. package/dist-embed/script.js.map +1 -0
  125. package/package.json +153 -0
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # The one and only chat widget for open
2
+
3
+ ## How to Get Started
4
+
5
+ ### 1. Install the Package
6
+
7
+ ```bash
8
+ pnpm add @opencopilot/widget
9
+ ```
10
+
11
+ ### 2. Import the package
12
+
13
+ ```javascript
14
+ import { Widget, WidgetRoot } from "@opencopilot/widget/basic";
15
+ ```
16
+
17
+ ### 3. Use the Widget
18
+
19
+ ```javascript
20
+ <div>
21
+ <WidgetRoot>
22
+ <Widget />
23
+ </WidgetRoot>
24
+ </div>
25
+ ```
26
+
27
+ Widget Root is just the data layer for the widget. It is required to be present in the parent component of the widget.
28
+ You can Pass options to the `WidgetRoot` component to customize the widget.
29
+
30
+ ```typescript
31
+ type WidgetOptions = {
32
+ token: string;
33
+ headers?: Record<string, string>;
34
+ queryParams?: Record<string, string>;
35
+ initialMessages: string;
36
+ apiUrl: string;
37
+ socketUrl: string;
38
+ debug?: boolean;
39
+ language?: LangType;
40
+ user?: {
41
+ name?: string;
42
+ email?: string;
43
+ phone?: string;
44
+ customData?: Record<string, string>;
45
+ avatarUrl?: string;
46
+ };
47
+ bot?: {
48
+ name?: string;
49
+ avatarUrl?: string;
50
+ };
51
+ components?: ComponentType[];
52
+ };
53
+ ```
54
+
55
+ also you must import the css file too.
56
+
57
+ ```javascript
58
+ import "@opencopilot/widget/index.css";
59
+ ```
60
+
61
+ also the styles are scoped to the widget only so the widget should have a container with `data-chat-widget`
62
+
63
+ ```javascript
64
+ import { Widget, WidgetRoot, WidgetPopover } from "@opencopilot/widget";
65
+ import "@opencopilot/widget/index.css";
66
+ <div data-chat-widget>
67
+ <WidgetRoot>
68
+ <Widget />
69
+ </WidgetRoot>
70
+ </div>;
71
+ ```
72
+
73
+ ## How about the WidgetPopover ?
74
+
75
+ It's a component that you can use to show the widget in a popover fixed to the bottom left corner
76
+
77
+ ```javascript
78
+ <div data-chat-widget>
79
+ <WidgetPopover>
80
+ <Widget />
81
+ </WidgetPopover>
82
+ </div>
83
+ ```
84
+
85
+ ## How can i Change the colors of the widget ?
86
+
87
+ these are the css variables that you can change to customize the widget
88
+ you may add these variables to the parent container of the widget
89
+ to override the default colors
90
+
91
+ ```
92
+ const vars = `
93
+ [--primary:211_65%_59%]
94
+ [--foreground:0_0%_0%]
95
+ [--background:0_0%_100%]
96
+ [--secondary:0_0%_96%]
97
+ [--primary-foreground:217_72%_18%]
98
+ [--accent:0_0_22%]
99
+ `;
100
+ ```
101
+
102
+ ## I don't want your ui ? can i use my own ?
103
+
104
+ Yes You can, every thing in this lib is exported so u can build your own ui on top of it
105
+ Even the core hook of the widget is exported so you can use it to build your own ui