@opencx/widget 3.0.100 → 4.0.17

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 (146) hide show
  1. package/README.md +3 -73
  2. package/dist-embed/script.js +151 -194
  3. package/dist-embed/script.js.map +1 -1
  4. package/package.json +11 -173
  5. package/dist/designs.cjs +0 -79
  6. package/dist/designs.cjs.map +0 -1
  7. package/dist/designs.d.ts +0 -2
  8. package/dist/designs.js +0 -17770
  9. package/dist/designs.js.map +0 -1
  10. package/dist/index.cjs +0 -2
  11. package/dist/index.cjs.map +0 -1
  12. package/dist/index.d.ts +0 -2
  13. package/dist/index.js +0 -8
  14. package/dist/index.js.map +0 -1
  15. package/dist/is-exhaustive-9o43S91P.cjs +0 -2
  16. package/dist/is-exhaustive-9o43S91P.cjs.map +0 -1
  17. package/dist/is-exhaustive-DGJzQK69.js +0 -7
  18. package/dist/is-exhaustive-DGJzQK69.js.map +0 -1
  19. package/dist/react.cjs +0 -2
  20. package/dist/react.cjs.map +0 -1
  21. package/dist/react.d.ts +0 -2
  22. package/dist/react.js +0 -34
  23. package/dist/react.js.map +0 -1
  24. package/dist/src/designs/react/WidgetPopoverAnchor.d.ts +0 -2
  25. package/dist/src/designs/react/WidgetPopoverContent.d.ts +0 -3
  26. package/dist/src/designs/react/WidgetPopoverTrigger.d.ts +0 -3
  27. package/dist/src/designs/react/components/AgentOrBotAvatar.d.ts +0 -6
  28. package/dist/src/designs/react/components/AttachmentPreview.d.ts +0 -7
  29. package/dist/src/designs/react/components/BotOrAgentMessage.d.ts +0 -7
  30. package/dist/src/designs/react/components/BotOrAgentMessageGroup.d.ts +0 -7
  31. package/dist/src/designs/react/components/Header.d.ts +0 -3
  32. package/dist/src/designs/react/components/MightSolveUserIssueSuggestedReplies.d.ts +0 -2
  33. package/dist/src/designs/react/components/PoweredByOpen.d.ts +0 -4
  34. package/dist/src/designs/react/components/SuggestedReplyButton.d.ts +0 -5
  35. package/dist/src/designs/react/components/UserMessage.d.ts +0 -8
  36. package/dist/src/designs/react/components/UserMessageGroup.d.ts +0 -5
  37. package/dist/src/designs/react/components/VoteButtons.d.ts +0 -8
  38. package/dist/src/designs/react/components/custom-components/BotOrAgentTextResponse.component.d.ts +0 -16
  39. package/dist/src/designs/react/components/custom-components/Fallback.component.d.ts +0 -6
  40. package/dist/src/designs/react/components/custom-components/Handoff.component.d.ts +0 -3
  41. package/dist/src/designs/react/components/custom-components/Loading.component.d.ts +0 -6
  42. package/dist/src/designs/react/components/lib/DynamicIcon.d.ts +0 -6
  43. package/dist/src/designs/react/components/lib/LoadingSpinner.d.ts +0 -4
  44. package/dist/src/designs/react/components/lib/MotionDiv.d.ts +0 -19
  45. package/dist/src/designs/react/components/lib/avatar.d.ts +0 -6
  46. package/dist/src/designs/react/components/lib/button.d.ts +0 -11
  47. package/dist/src/designs/react/components/lib/dialog.d.ts +0 -24
  48. package/dist/src/designs/react/components/lib/dropdown-menu.d.ts +0 -27
  49. package/dist/src/designs/react/components/lib/input.d.ts +0 -4
  50. package/dist/src/designs/react/components/lib/popover.d.ts +0 -8
  51. package/dist/src/designs/react/components/lib/skeleton.d.ts +0 -3
  52. package/dist/src/designs/react/components/lib/switch.d.ts +0 -4
  53. package/dist/src/designs/react/components/lib/tooltip.d.ts +0 -10
  54. package/dist/src/designs/react/components/lib/utils/cn.d.ts +0 -2
  55. package/dist/src/designs/react/components/lib/widget-portal.d.ts +0 -9
  56. package/dist/src/designs/react/components/lib/wobble.d.ts +0 -26
  57. package/dist/src/designs/react/components/markdown.d.ts +0 -3
  58. package/dist/src/designs/react/components/svg/ChatBubbleSvg.d.ts +0 -5
  59. package/dist/src/designs/react/components/svg/OpenLogoSvg.d.ts +0 -4
  60. package/dist/src/designs/react/hooks/useCanvas.d.ts +0 -3
  61. package/dist/src/designs/react/hooks/useIsSmallScreen.d.ts +0 -3
  62. package/dist/src/designs/react/hooks/useLocale.d.ts +0 -6
  63. package/dist/src/designs/react/hooks/useSetWidgetSize.d.ts +0 -8
  64. package/dist/src/designs/react/hooks/useTheme.d.ts +0 -62
  65. package/dist/src/designs/react/hooks/useWidgetContentHeight.d.ts +0 -3
  66. package/dist/src/designs/react/index.d.ts +0 -9
  67. package/dist/src/designs/react/screens/chat/ChatCanvas.d.ts +0 -2
  68. package/dist/src/designs/react/screens/chat/ChatFooter.d.ts +0 -2
  69. package/dist/src/designs/react/screens/chat/ChatMain.d.ts +0 -2
  70. package/dist/src/designs/react/screens/chat/index.d.ts +0 -2
  71. package/dist/src/designs/react/screens/index.d.ts +0 -2
  72. package/dist/src/designs/react/screens/sessions/index.d.ts +0 -2
  73. package/dist/src/designs/react/screens/welcome/index.d.ts +0 -2
  74. package/dist/src/designs/react/utils/data-component.d.ts +0 -7
  75. package/dist/src/designs/react/utils/group-messages-by-type.d.ts +0 -5
  76. package/dist/src/designs/translation/ar.locale.d.ts +0 -2
  77. package/dist/src/designs/translation/de.locale.d.ts +0 -2
  78. package/dist/src/designs/translation/en.locale.d.ts +0 -2
  79. package/dist/src/designs/translation/es.locale.d.ts +0 -2
  80. package/dist/src/designs/translation/fr.locale.d.ts +0 -2
  81. package/dist/src/designs/translation/index.d.ts +0 -16
  82. package/dist/src/designs/translation/nl.locale.d.ts +0 -2
  83. package/dist/src/designs/translation/pt.locale.d.ts +0 -2
  84. package/dist/src/designs/translation/tr.locale.d.ts +0 -2
  85. package/dist/src/designs/translation/translation.types.d.ts +0 -4
  86. package/dist/src/embedded/index.d.ts +0 -11
  87. package/dist/src/headless/core/__tests__/api-caller.mock.d.ts +0 -1
  88. package/dist/src/headless/core/__tests__/context/contact/auth/auto-create-unverified-anonymous.spec.d.ts +0 -0
  89. package/dist/src/headless/core/__tests__/context/contact/auth/auto-create-unverified-with-user-data-provided-by-org.spec.d.ts +0 -0
  90. package/dist/src/headless/core/__tests__/context/contact/auth/manually-create-unverified-with-user-data-provided-by-user.spec.d.ts +0 -0
  91. package/dist/src/headless/core/__tests__/context/contact/auth/with-secure-token.spec.d.ts +0 -0
  92. package/dist/src/headless/core/__tests__/context/contact/should-collect-data.spec.d.ts +0 -0
  93. package/dist/src/headless/core/__tests__/test-utils.d.ts +0 -419
  94. package/dist/src/headless/core/__tests__/utils/Poller.spec.d.ts +0 -1
  95. package/dist/src/headless/core/__tests__/utils/PrimitiveState.spec.d.ts +0 -1
  96. package/dist/src/headless/core/__tests__/utils/uuid.spec.d.ts +0 -1
  97. package/dist/src/headless/core/api/api-caller.d.ts +0 -437
  98. package/dist/src/headless/core/api/client.d.ts +0 -12
  99. package/dist/src/headless/core/api/schema.d.ts +0 -928
  100. package/dist/src/headless/core/context/active-session-polling.ctx.d.ts +0 -25
  101. package/dist/src/headless/core/context/contact.ctx.d.ts +0 -30
  102. package/dist/src/headless/core/context/message.ctx.d.ts +0 -38
  103. package/dist/src/headless/core/context/router.ctx.d.ts +0 -33
  104. package/dist/src/headless/core/context/session.ctx.d.ts +0 -119
  105. package/dist/src/headless/core/context/storage.ctx.d.ts +0 -15
  106. package/dist/src/headless/core/context/widget.ctx.d.ts +0 -27
  107. package/dist/src/headless/core/index.d.ts +0 -15
  108. package/dist/src/headless/core/types/agent-or-bot.d.ts +0 -6
  109. package/dist/src/headless/core/types/component-name.d.ts +0 -1
  110. package/dist/src/headless/core/types/dtos.d.ts +0 -12
  111. package/dist/src/headless/core/types/external-storage.d.ts +0 -5
  112. package/dist/src/headless/core/types/helpers.d.ts +0 -2
  113. package/dist/src/headless/core/types/icons.d.ts +0 -3
  114. package/dist/src/headless/core/types/json-value.d.ts +0 -7
  115. package/dist/src/headless/core/types/messages.d.ts +0 -55
  116. package/dist/src/headless/core/types/widget-config.d.ts +0 -400
  117. package/dist/src/headless/core/utils/Poller.d.ts +0 -12
  118. package/dist/src/headless/core/utils/PrimitiveState.d.ts +0 -13
  119. package/dist/src/headless/core/utils/is-exhaustive.d.ts +0 -1
  120. package/dist/src/headless/core/utils/run-catching.d.ts +0 -13
  121. package/dist/src/headless/core/utils/uuid.d.ts +0 -1
  122. package/dist/src/headless/react/ComponentRegistry.d.ts +0 -10
  123. package/dist/src/headless/react/WidgetProvider.d.ts +0 -25
  124. package/dist/src/headless/react/hooks/useConfig.d.ts +0 -1
  125. package/dist/src/headless/react/hooks/useContact.d.ts +0 -12
  126. package/dist/src/headless/react/hooks/useDocumentDir.d.ts +0 -3
  127. package/dist/src/headless/react/hooks/useIsAwaitingBotReply.d.ts +0 -3
  128. package/dist/src/headless/react/hooks/useMessages.d.ts +0 -14
  129. package/dist/src/headless/react/hooks/useModes.d.ts +0 -15
  130. package/dist/src/headless/react/hooks/usePreludeData.d.ts +0 -38
  131. package/dist/src/headless/react/hooks/usePrimitiveState.d.ts +0 -2
  132. package/dist/src/headless/react/hooks/useSessions.d.ts +0 -104
  133. package/dist/src/headless/react/hooks/useUploadFiles.d.ts +0 -21
  134. package/dist/src/headless/react/hooks/useVote.d.ts +0 -18
  135. package/dist/src/headless/react/hooks/useWidgetRouter.d.ts +0 -7
  136. package/dist/src/headless/react/hooks/useWidgetTrigger.d.ts +0 -10
  137. package/dist/src/headless/react/index.d.ts +0 -14
  138. package/dist/src/headless/react/types/components.d.ts +0 -7
  139. package/dist/useModes-B1EFXU-e.cjs +0 -2
  140. package/dist/useModes-B1EFXU-e.cjs.map +0 -1
  141. package/dist/useModes-BCCAwNcR.js +0 -259
  142. package/dist/useModes-BCCAwNcR.js.map +0 -1
  143. package/dist/widget.ctx-B-jCTG4Y.js +0 -698
  144. package/dist/widget.ctx-B-jCTG4Y.js.map +0 -1
  145. package/dist/widget.ctx-XvIjOOOZ.cjs +0 -5
  146. package/dist/widget.ctx-XvIjOOOZ.cjs.map +0 -1
package/README.md CHANGED
@@ -1,75 +1,5 @@
1
- # OpenCX Widget
1
+ # OpenCX Widget - Embed
2
2
 
3
- ## Getting Started
3
+ The default React widget. Embeddable in HTML.
4
4
 
5
- ### Embedded in HTML
6
-
7
- ```html
8
- <head>
9
- <script src="https://unpkg.com/@opencx/widget@latest/dist-embed/script.js"></script>
10
- <script>
11
- const options = {
12
- token: 'your-token-here',
13
- };
14
- window.addEventListener('DOMContentLoaded', () => {
15
- initOpenScript(options);
16
- });
17
- </script>
18
- </head>
19
- ```
20
-
21
- ### Default React Widget
22
-
23
- Install the package:
24
-
25
- ```bash
26
- pnpm add @opencx/widget
27
- ```
28
-
29
- Render the widget:
30
-
31
- ```tsx
32
- import { Widget } from '@opencx/widget/designs';
33
-
34
- function YourComponent() {
35
- return (
36
- <Widget
37
- options={{
38
- token: 'your-token-here',
39
- }}
40
- />
41
- );
42
- }
43
- ```
44
-
45
- ### Framework-Agnostic Headless Widget
46
-
47
- The core package exports the widget engine that can be used with any framework:
48
-
49
- - Check the [`React` adapter](https://github.com/openchatai/widget/tree/main/src/headless/react) on how to attach the widget engine to a framework.
50
- - Check the [default `React` widget](https://github.com/openchatai/widget/tree/main/src/designs/react) on how to use the engine; collecting user data, navigating between screens, sending messages, handling loading states, etc.
51
-
52
- ## Widget Options
53
-
54
- - [Available options](https://github.com/openchatai/widget/tree/main/src/headless/core/types/widget-config.ts)
55
- - [Usage example](https://github.com/openchatai/widget/tree/main/index.tsx)
56
-
57
- ## Authentication
58
-
59
- The widget supports a variety of ways to authenticate, or not, your users:
60
-
61
- 1. **Completely anonymous**: Leave `WidgetConfig.collectUserData` and `WidgetConfig.user` empty or explicitly `undefined`
62
- 2. **Manually collect user data**: Pass `WidgetConfig.collectUserData` as `true`
63
- - Users will have to input a `name` and an `email` to enter the chat.
64
- - A contact will be created with the inputted email. But the session will be considered `unverified`, since the user can input any `email`.
65
- - The user will be saved in `localStorage` and they won't have to input a `name` and `email` on future visits.
66
- 3. **Programmatically pass user data**: Populate `WidgetConfig.user.data` with a `name` and `email`
67
- - The session will still be considered `unverified`, because malicious users can still intercept outgoing browser requests and tamper with the user data
68
- - If `WidgetConfig.collectUserData` is `true` and `WidgetConfig.user.data.email` was also passed, the `email` will take precedence and `collectUserData` will be ignored.
69
- 4. **Secure authentication**: Get a `token` for your user by letting your backend hit a request to `api.open.cx/widget/authenticate-user` ([API reference](https://docs.open.cx/api-reference/widget/authenticate-contact)) and pass the token in `WidgetConfig.user.token`
70
- - The session will be `verified`, so your human agents can share private data with the user (in case the session was handed-over to humans)
71
- - `customData` in the authentication request will be saved, since contacts have no way to tamper with them
72
-
73
- ## Workspace Management
74
-
75
- If you support multiple workspaces per user or contact, you can pass the user's workspace id in `WidgetConfig.user.externalId`. This way, sessions will be scoped by that external id.
5
+ For more information, check [the documentation](https://docs.open.cx/widget/getting-started)