@botonic/react 0.31.0-alpha.2 → 0.31.5-alpha.1

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 (122) hide show
  1. package/lib/cjs/components/audio.d.ts +1 -1
  2. package/lib/cjs/components/custom-message.d.ts +2 -2
  3. package/lib/cjs/components/document.d.ts +1 -1
  4. package/lib/cjs/components/handoff.d.ts +1 -1
  5. package/lib/cjs/components/image.d.ts +1 -1
  6. package/lib/cjs/components/index-types.d.ts +1 -0
  7. package/lib/cjs/components/message/message-feedback.d.ts +1 -1
  8. package/lib/cjs/components/message/message-footer.d.ts +1 -1
  9. package/lib/cjs/components/message/timestamps.d.ts +1 -1
  10. package/lib/cjs/components/multichannel/multichannel-button.d.ts +1 -1
  11. package/lib/cjs/components/multichannel/multichannel-reply.d.ts +1 -1
  12. package/lib/cjs/components/multichannel/multichannel-text.d.ts +1 -1
  13. package/lib/cjs/components/raw.d.ts +1 -1
  14. package/lib/cjs/components/text.d.ts +1 -1
  15. package/lib/cjs/components/video.d.ts +1 -1
  16. package/lib/cjs/contexts.js +3 -0
  17. package/lib/cjs/contexts.js.map +1 -1
  18. package/lib/cjs/dev-app.js +2 -5
  19. package/lib/cjs/dev-app.js.map +1 -1
  20. package/lib/cjs/index-types.d.ts +1 -0
  21. package/lib/cjs/react-bot.d.ts +1 -1
  22. package/lib/cjs/util/error-boundary.d.ts +1 -1
  23. package/lib/cjs/util/react.d.ts +1 -1
  24. package/lib/cjs/webchat/chat-area/index.d.ts +1 -1
  25. package/lib/cjs/webchat/components/common.d.ts +1 -1
  26. package/lib/cjs/webchat/components/conditional-animation.d.ts +1 -1
  27. package/lib/cjs/webchat/components/opened-persistent-menu.d.ts +1 -1
  28. package/lib/cjs/webchat/cover-component/index.d.ts +6 -0
  29. package/lib/cjs/webchat/cover-component/index.js +21 -0
  30. package/lib/cjs/webchat/cover-component/index.js.map +1 -0
  31. package/lib/cjs/webchat/header.d.ts +1 -1
  32. package/lib/cjs/webchat/input-panel/attachment.d.ts +1 -1
  33. package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -1
  34. package/lib/cjs/webchat/input-panel/index.d.ts +1 -1
  35. package/lib/cjs/webchat/input-panel/opened-emoji-picker.d.ts +1 -1
  36. package/lib/cjs/webchat/input-panel/persistent-menu.d.ts +1 -1
  37. package/lib/cjs/webchat/input-panel/send-button.d.ts +1 -1
  38. package/lib/cjs/webchat/input-panel/textarea.d.ts +1 -1
  39. package/lib/cjs/webchat/message-list/index.d.ts +1 -1
  40. package/lib/cjs/webchat/message-list/intro-message.d.ts +1 -1
  41. package/lib/cjs/webchat/message-list/scroll-button.d.ts +0 -1
  42. package/lib/cjs/webchat/replies.d.ts +1 -1
  43. package/lib/cjs/webchat/session-view.d.ts +1 -1
  44. package/lib/cjs/webchat/session-view.js +2 -2
  45. package/lib/cjs/webchat/session-view.js.map +1 -1
  46. package/lib/cjs/webchat/trigger-button/index.d.ts +0 -1
  47. package/lib/cjs/webchat/typing-indicator/index.d.ts +1 -1
  48. package/lib/cjs/webchat/webchat-dev.d.ts +2 -2
  49. package/lib/cjs/webchat/webchat.js +10 -15
  50. package/lib/cjs/webchat/webchat.js.map +1 -1
  51. package/lib/cjs/webchat/webview.d.ts +2 -2
  52. package/lib/cjs/webchat-app.d.ts +1 -2
  53. package/lib/cjs/webchat-app.js +5 -12
  54. package/lib/cjs/webchat-app.js.map +1 -1
  55. package/lib/cjs/webview-app.js +2 -5
  56. package/lib/cjs/webview-app.js.map +1 -1
  57. package/lib/esm/components/audio.d.ts +1 -1
  58. package/lib/esm/components/custom-message.d.ts +2 -2
  59. package/lib/esm/components/document.d.ts +1 -1
  60. package/lib/esm/components/handoff.d.ts +1 -1
  61. package/lib/esm/components/image.d.ts +1 -1
  62. package/lib/esm/components/index-types.d.ts +1 -0
  63. package/lib/esm/components/message/message-feedback.d.ts +1 -1
  64. package/lib/esm/components/message/message-footer.d.ts +1 -1
  65. package/lib/esm/components/message/timestamps.d.ts +1 -1
  66. package/lib/esm/components/multichannel/multichannel-button.d.ts +1 -1
  67. package/lib/esm/components/multichannel/multichannel-reply.d.ts +1 -1
  68. package/lib/esm/components/multichannel/multichannel-text.d.ts +1 -1
  69. package/lib/esm/components/raw.d.ts +1 -1
  70. package/lib/esm/components/text.d.ts +1 -1
  71. package/lib/esm/components/video.d.ts +1 -1
  72. package/lib/esm/contexts.js +3 -0
  73. package/lib/esm/contexts.js.map +1 -1
  74. package/lib/esm/dev-app.js +2 -5
  75. package/lib/esm/dev-app.js.map +1 -1
  76. package/lib/esm/index-types.d.ts +1 -0
  77. package/lib/esm/react-bot.d.ts +1 -1
  78. package/lib/esm/util/error-boundary.d.ts +1 -1
  79. package/lib/esm/util/react.d.ts +1 -1
  80. package/lib/esm/webchat/chat-area/index.d.ts +1 -1
  81. package/lib/esm/webchat/components/common.d.ts +1 -1
  82. package/lib/esm/webchat/components/conditional-animation.d.ts +1 -1
  83. package/lib/esm/webchat/components/opened-persistent-menu.d.ts +1 -1
  84. package/lib/esm/webchat/cover-component/index.d.ts +6 -0
  85. package/lib/esm/webchat/cover-component/index.js +17 -0
  86. package/lib/esm/webchat/cover-component/index.js.map +1 -0
  87. package/lib/esm/webchat/header.d.ts +1 -1
  88. package/lib/esm/webchat/input-panel/attachment.d.ts +1 -1
  89. package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -1
  90. package/lib/esm/webchat/input-panel/index.d.ts +1 -1
  91. package/lib/esm/webchat/input-panel/opened-emoji-picker.d.ts +1 -1
  92. package/lib/esm/webchat/input-panel/persistent-menu.d.ts +1 -1
  93. package/lib/esm/webchat/input-panel/send-button.d.ts +1 -1
  94. package/lib/esm/webchat/input-panel/textarea.d.ts +1 -1
  95. package/lib/esm/webchat/message-list/index.d.ts +1 -1
  96. package/lib/esm/webchat/message-list/intro-message.d.ts +1 -1
  97. package/lib/esm/webchat/message-list/scroll-button.d.ts +0 -1
  98. package/lib/esm/webchat/replies.d.ts +1 -1
  99. package/lib/esm/webchat/session-view.d.ts +1 -1
  100. package/lib/esm/webchat/session-view.js +1 -1
  101. package/lib/esm/webchat/session-view.js.map +1 -1
  102. package/lib/esm/webchat/trigger-button/index.d.ts +0 -1
  103. package/lib/esm/webchat/typing-indicator/index.d.ts +1 -1
  104. package/lib/esm/webchat/webchat-dev.d.ts +2 -2
  105. package/lib/esm/webchat/webchat.js +10 -15
  106. package/lib/esm/webchat/webchat.js.map +1 -1
  107. package/lib/esm/webchat/webview.d.ts +2 -2
  108. package/lib/esm/webchat-app.d.ts +1 -2
  109. package/lib/esm/webchat-app.js +5 -12
  110. package/lib/esm/webchat-app.js.map +1 -1
  111. package/lib/esm/webview-app.js +2 -5
  112. package/lib/esm/webview-app.js.map +1 -1
  113. package/package.json +15 -15
  114. package/src/components/index-types.ts +1 -0
  115. package/src/contexts.tsx +3 -0
  116. package/src/dev-app.jsx +5 -5
  117. package/src/index-types.ts +1 -0
  118. package/src/webchat/cover-component/index.tsx +31 -0
  119. package/src/webchat/session-view.jsx +1 -1
  120. package/src/webchat/webchat.jsx +43 -46
  121. package/src/webchat-app.jsx +8 -12
  122. package/src/webview-app.tsx +4 -6
@@ -1,7 +1,7 @@
1
1
  import { HubtypeService, INPUT } from '@botonic/core'
2
2
  import merge from 'lodash.merge'
3
3
  import React, { createRef } from 'react'
4
- import { createRoot } from 'react-dom/client'
4
+ import { render, unmountComponentAtNode } from 'react-dom'
5
5
 
6
6
  import { WEBCHAT } from './constants'
7
7
  import { SENDERS, Typing } from './index-types'
@@ -65,7 +65,6 @@ export class WebchatApp {
65
65
  this.server = server
66
66
  this.webchatRef = createRef()
67
67
  this.appId = appId
68
- this.reactRoot = null
69
68
  }
70
69
 
71
70
  createRootElement(host) {
@@ -95,9 +94,7 @@ export class WebchatApp {
95
94
  }
96
95
 
97
96
  getReactMountNode(node) {
98
- if (!node) {
99
- node = this.host
100
- }
97
+ if (!node) node = this.host
101
98
  return node.shadowRoot ? node.shadowRoot : node
102
99
  }
103
100
 
@@ -375,19 +372,18 @@ export class WebchatApp {
375
372
 
376
373
  destroy() {
377
374
  if (this.hubtypeService) this.hubtypeService.destroyPusher()
378
- this.reactRoot?.unmount()
375
+ unmountComponentAtNode(this.host)
379
376
  if (this.storage) this.storage.removeItem(this.storageKey)
380
377
  }
381
378
 
382
379
  async render(dest, optionsAtRuntime = {}) {
383
380
  onDOMLoaded(async () => {
384
381
  const isVisible = await this.resolveWebchatVisibility(optionsAtRuntime)
385
- if (isVisible) {
386
- const webchatComponent = this.getComponent(dest, optionsAtRuntime)
387
- const container = this.getReactMountNode(dest)
388
- this.reactRoot = createRoot(container) // createRoot(container!) if you use TypeScript
389
- this.reactRoot.render(webchatComponent)
390
- }
382
+ if (isVisible)
383
+ render(
384
+ this.getComponent(dest, optionsAtRuntime),
385
+ this.getReactMountNode(dest)
386
+ )
391
387
  })
392
388
  }
393
389
  }
@@ -2,7 +2,7 @@
2
2
  import { getString, params2queryString, PROVIDER } from '@botonic/core'
3
3
  import axios from 'axios'
4
4
  import React from 'react'
5
- import { createRoot } from 'react-dom/client'
5
+ import { render } from 'react-dom'
6
6
  import { BrowserRouter, Route } from 'react-router-dom'
7
7
 
8
8
  import { CloseWebviewOptions, WebviewRequestContext } from './contexts'
@@ -110,13 +110,11 @@ export class WebviewApp {
110
110
  }
111
111
 
112
112
  render(dest) {
113
- const component = (
113
+ render(
114
114
  <BrowserRouter>
115
115
  <App webviews={this.webviews} locales={this.locales} />
116
- </BrowserRouter>
116
+ </BrowserRouter>,
117
+ dest
117
118
  )
118
- const container = dest
119
- const reactRoot = createRoot(container)
120
- reactRoot.render(component)
121
119
  }
122
120
  }