@botonic/react 0.31.0-alpha.5 → 0.31.0-alpha.6

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 (62) hide show
  1. package/lib/cjs/components/index-types.d.ts +4 -131
  2. package/lib/cjs/components/index.d.ts +2 -1
  3. package/lib/cjs/components/index.js +4 -1
  4. package/lib/cjs/components/index.js.map +1 -1
  5. package/lib/cjs/components/webchat-settings.d.ts +15 -2
  6. package/lib/cjs/components/webchat-settings.js.map +1 -1
  7. package/lib/cjs/index-types.d.ts +4 -3
  8. package/lib/cjs/index-types.js.map +1 -1
  9. package/lib/cjs/util/webchat.d.ts +1 -1
  10. package/lib/cjs/util/webchat.js.map +1 -1
  11. package/lib/cjs/webchat/context/types.d.ts +2 -2
  12. package/lib/cjs/webchat/context/use-webchat.d.ts +2 -1
  13. package/lib/cjs/webchat/context/use-webchat.js +1 -0
  14. package/lib/cjs/webchat/context/use-webchat.js.map +1 -1
  15. package/lib/cjs/webchat/index-types.d.ts +0 -3
  16. package/lib/cjs/webchat/input-panel/textarea.d.ts +2 -2
  17. package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
  18. package/lib/cjs/webchat/theme/types.d.ts +167 -0
  19. package/lib/cjs/webchat/theme/types.js +3 -0
  20. package/lib/cjs/webchat/theme/types.js.map +1 -0
  21. package/lib/cjs/webchat/webchat.js +3 -5
  22. package/lib/cjs/webchat/webchat.js.map +1 -1
  23. package/lib/cjs/webchat-app.d.ts +3 -2
  24. package/lib/cjs/webchat-app.js.map +1 -1
  25. package/lib/esm/components/index-types.d.ts +4 -131
  26. package/lib/esm/components/index.d.ts +2 -1
  27. package/lib/esm/components/index.js +2 -1
  28. package/lib/esm/components/index.js.map +1 -1
  29. package/lib/esm/components/webchat-settings.d.ts +15 -2
  30. package/lib/esm/components/webchat-settings.js.map +1 -1
  31. package/lib/esm/index-types.d.ts +4 -3
  32. package/lib/esm/index-types.js.map +1 -1
  33. package/lib/esm/util/webchat.d.ts +1 -1
  34. package/lib/esm/util/webchat.js.map +1 -1
  35. package/lib/esm/webchat/context/types.d.ts +2 -2
  36. package/lib/esm/webchat/context/use-webchat.d.ts +2 -1
  37. package/lib/esm/webchat/context/use-webchat.js +1 -0
  38. package/lib/esm/webchat/context/use-webchat.js.map +1 -1
  39. package/lib/esm/webchat/index-types.d.ts +0 -3
  40. package/lib/esm/webchat/input-panel/textarea.d.ts +2 -2
  41. package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
  42. package/lib/esm/webchat/theme/types.d.ts +167 -0
  43. package/lib/esm/webchat/theme/types.js +2 -0
  44. package/lib/esm/webchat/theme/types.js.map +1 -0
  45. package/lib/esm/webchat/webchat.js +1 -3
  46. package/lib/esm/webchat/webchat.js.map +1 -1
  47. package/lib/esm/webchat-app.d.ts +3 -2
  48. package/lib/esm/webchat-app.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/components/index-types.ts +4 -121
  51. package/src/components/index.ts +6 -1
  52. package/src/components/webchat-settings.tsx +13 -1
  53. package/src/index-types.ts +8 -6
  54. package/src/util/webchat.ts +1 -1
  55. package/src/webchat/context/index.tsx +1 -1
  56. package/src/webchat/context/types.ts +7 -11
  57. package/src/webchat/context/use-webchat.ts +3 -1
  58. package/src/webchat/index-types.ts +0 -4
  59. package/src/webchat/input-panel/textarea.tsx +2 -2
  60. package/src/webchat/theme/types.ts +119 -0
  61. package/src/webchat/webchat.tsx +2 -2
  62. package/src/webchat-app.tsx +7 -8
@@ -2,9 +2,10 @@ import { Session } from '@botonic/core'
2
2
  import { useReducer, useRef } from 'react'
3
3
 
4
4
  import { Reply } from '../../components'
5
- import { ThemeProps, Webview } from '../../components/index-types'
5
+ import { Webview } from '../../components/index-types'
6
6
  import { COLORS, WEBCHAT } from '../../constants'
7
7
  import { WebchatMessage } from '../../index-types'
8
+ import { ThemeProps } from '../theme/types'
8
9
  import { WebchatAction } from './actions'
9
10
  import { ClientInput, DevSettings, ErrorMessage, WebchatState } from './types'
10
11
  import { webchatReducer } from './webchat-reducer'
@@ -22,6 +23,7 @@ export const webchatInitialState: WebchatState = {
22
23
  session: { user: undefined },
23
24
  lastRoutePath: undefined,
24
25
  handoff: false,
26
+ // TODO: type create a defaultTheme using ThemeProps, and put this in initialState
25
27
  theme: {
26
28
  headerTitle: WEBCHAT.DEFAULTS.TITLE,
27
29
  brandColor: COLORS.BOTONIC_BLUE,
@@ -18,7 +18,3 @@ export interface WebchatDevProps extends WebchatArgs {
18
18
  showSessionView?: boolean
19
19
  }
20
20
  }
21
-
22
- export interface CoverComponentProps {
23
- closeComponent: () => void
24
- }
@@ -1,16 +1,16 @@
1
1
  import React, { useContext } from 'react'
2
2
  import TextareaAutosize from 'react-textarea-autosize'
3
3
 
4
- import { PersistentMenuTheme } from '../../components/index-types'
5
4
  import { WEBCHAT } from '../../constants'
6
5
  import { Typing } from '../../index-types'
7
6
  import { WebchatContext } from '../../webchat/context'
8
7
  import { useDeviceAdapter } from '../hooks'
8
+ import { PersistentMenuOptionsTheme } from '../theme/types'
9
9
  import { TextAreaContainer } from './styles'
10
10
 
11
11
  interface TextareaProps {
12
12
  host: HTMLElement
13
- persistentMenu: PersistentMenuTheme
13
+ persistentMenu: PersistentMenuOptionsTheme
14
14
  textareaRef: React.MutableRefObject<HTMLTextAreaElement | undefined>
15
15
  sendChatEvent: (event: string) => Promise<void>
16
16
  sendTextAreaText: () => Promise<void>
@@ -0,0 +1,119 @@
1
+ import {
2
+ BlockInputOption,
3
+ ButtonProps,
4
+ CustomMessageType,
5
+ } from '../../components/index-types'
6
+
7
+ interface ImagePreviewerProps {
8
+ src: string
9
+ isPreviewerOpened: boolean
10
+ closePreviewer: () => void
11
+ }
12
+ export interface CoverComponentProps {
13
+ closeComponent: () => void
14
+ }
15
+
16
+ export interface CoverComponentOptions {
17
+ component: React.ComponentType<CoverComponentProps>
18
+ props?: any
19
+ }
20
+
21
+ export type PersistentMenuCloseOption = { closeLabel: string }
22
+ export type PersistentMenuOption = { label: string } & ButtonProps
23
+
24
+ export type PersistentMenuOptionsTheme = (
25
+ | PersistentMenuCloseOption
26
+ | PersistentMenuOption
27
+ )[]
28
+
29
+ export interface PersistentMenuOptionsProps {
30
+ onClick: () => void
31
+ options: any
32
+ }
33
+
34
+ export interface BlobProps {
35
+ blobTick?: boolean
36
+ blobTickStyle?: any
37
+ blobWidth?: string
38
+ imageStyle?: any
39
+ }
40
+
41
+ export interface ThemeProps {
42
+ style?: any
43
+ coverComponent?: CoverComponentOptions
44
+ mobileBreakpoint?: number
45
+ mobileStyle?: any
46
+ webview?: { style?: any; header?: { style?: any } }
47
+ animations?: { enable?: boolean }
48
+ intro?: { style?: any; image?: string; custom?: React.ComponentType }
49
+ brand?: { color?: string; image?: string }
50
+ header?: {
51
+ title?: string
52
+ subtitle?: string
53
+ image?: string
54
+ style?: any
55
+ custom?: React.ComponentType
56
+ }
57
+ // TODO: Review if this is needed hear, or only in message.customTypes? use the same type in both places
58
+ customMessageTypes?: CustomMessageType[]
59
+ message?: {
60
+ bot?: BlobProps & { image?: string; style?: any }
61
+ agent?: { image?: string }
62
+ user?: BlobProps & { style?: any }
63
+ // TODO: Review type used in cutomTypes should be a component exported by default with customMessage function
64
+ customTypes?: CustomMessageType[]
65
+ style?: any
66
+ timestamps?: {
67
+ withImage?: boolean
68
+ format: () => string
69
+ style?: any
70
+ enable?: boolean
71
+ }
72
+ }
73
+ button?: {
74
+ autodisable?: boolean
75
+ disabledstyle?: any
76
+ hoverBackground?: string
77
+ hoverTextColor?: string
78
+ messageType?: 'text' | 'payload'
79
+ urlIcon?: { image?: string; enable?: boolean }
80
+ style?: any
81
+ custom?: React.ComponentType
82
+ }
83
+ replies?: {
84
+ align?: 'left' | 'center' | 'right'
85
+ wrap?: 'wrap' | 'nowrap'
86
+ }
87
+ carousel?: {
88
+ arrow?: {
89
+ left: { custom?: React.ComponentType }
90
+ right: { custom?: React.ComponentType }
91
+ }
92
+ enableArrows?: boolean
93
+ }
94
+ reply?: { style?: any; custom?: React.ComponentType }
95
+ triggerButton?: { image?: string; style?: any; custom?: React.ComponentType }
96
+ notifications?: {
97
+ enable?: boolean
98
+ banner?: { custom?: React.ComponentType; enable?: boolean; text?: string }
99
+ triggerButton?: { enable?: boolean }
100
+ }
101
+ scrollButton?: { enable?: boolean; custom?: React.ComponentType }
102
+ markdownStyle?: string // string template with css styles
103
+ userInput?: {
104
+ attachments?: { enable?: boolean; custom?: React.ComponentType }
105
+ blockInputs?: BlockInputOption[]
106
+ box?: { placeholder: string; style?: any }
107
+ emojiPicker?: { enable?: boolean; custom?: React.ComponentType }
108
+ menu?: {
109
+ darkBackground?: boolean
110
+ custom?: React.ComponentType<PersistentMenuOptionsProps>
111
+ }
112
+ menuButton?: { custom?: React.ComponentType }
113
+ persistentMenu?: PersistentMenuOptionsTheme
114
+ sendButton?: { enable?: boolean; custom?: React.ComponentType }
115
+ enable?: boolean
116
+ style?: any
117
+ }
118
+ imagePreviewer?: React.ComponentType<ImagePreviewerProps>
119
+ }
@@ -19,13 +19,13 @@ import { v7 as uuidv7 } from 'uuid'
19
19
  import {
20
20
  Audio,
21
21
  Document,
22
+ Handoff,
22
23
  Image,
24
+ normalizeWebchatSettings,
23
25
  Text,
24
26
  Video,
25
27
  WebchatSettingsProps,
26
28
  } from '../components'
27
- import { Handoff } from '../components/handoff'
28
- import { normalizeWebchatSettings } from '../components/webchat-settings'
29
29
  import { COLORS, MAX_ALLOWED_SIZE_MB, ROLES, WEBCHAT } from '../constants'
30
30
  import { CloseWebviewOptions, WebviewRequestContext } from '../contexts'
31
31
  import { SENDERS, WebchatProps, WebchatRef } from '../index-types'
@@ -3,13 +3,7 @@ import merge from 'lodash.merge'
3
3
  import React, { createRef } from 'react'
4
4
  import { createRoot, Root } from 'react-dom/client'
5
5
 
6
- import {
7
- BlockInputOption,
8
- CoverComponentOptions,
9
- PersistentMenuTheme,
10
- ThemeProps,
11
- WebchatSettingsProps,
12
- } from './components/index-types'
6
+ import { BlockInputOption, WebchatSettingsProps } from './components'
13
7
  import { WEBCHAT } from './constants'
14
8
  import { CloseWebviewOptions } from './contexts'
15
9
  import {
@@ -26,11 +20,16 @@ import {
26
20
  } from './index-types'
27
21
  import { msgToBotonic } from './msg-to-botonic'
28
22
  import { isShadowDOMSupported, onDOMLoaded } from './util/dom'
23
+ import {
24
+ CoverComponentOptions,
25
+ PersistentMenuOptionsTheme,
26
+ ThemeProps,
27
+ } from './webchat/theme/types'
29
28
  import { Webchat } from './webchat/webchat'
30
29
 
31
30
  export class WebchatApp {
32
31
  public theme?: ThemeProps
33
- public persistentMenu?: PersistentMenuTheme
32
+ public persistentMenu?: PersistentMenuOptionsTheme
34
33
  public coverComponent?: CoverComponentOptions
35
34
  public blockInputs?: BlockInputOption[]
36
35
  public enableEmojiPicker?: boolean