@botonic/react 0.34.1 → 0.35.0-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.
- package/lib/cjs/components/{button.d.ts → button/index.d.ts} +4 -5
- package/lib/cjs/components/{button.js → button/index.js} +26 -56
- package/lib/cjs/components/button/index.js.map +1 -0
- package/lib/cjs/components/button/styles.d.ts +2 -0
- package/lib/cjs/components/button/styles.js +40 -0
- package/lib/cjs/components/button/styles.js.map +1 -0
- package/lib/cjs/components/buttons-disabler.d.ts +20 -23
- package/lib/cjs/components/buttons-disabler.js +11 -26
- package/lib/cjs/components/buttons-disabler.js.map +1 -1
- package/lib/cjs/components/carousel.js +1 -1
- package/lib/cjs/components/carousel.js.map +1 -1
- package/lib/cjs/components/element.js +3 -3
- package/lib/cjs/components/element.js.map +1 -1
- package/lib/cjs/components/image.js +1 -1
- package/lib/cjs/components/image.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +1 -1
- package/lib/cjs/components/index.d.ts +1 -1
- package/lib/cjs/components/index.js +2 -2
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/message/index.js +7 -7
- package/lib/cjs/components/message/index.js.map +1 -1
- package/lib/cjs/components/message/message-image.js +1 -1
- package/lib/cjs/components/message/message-image.js.map +1 -1
- package/lib/cjs/components/message/styles.d.ts +11 -11
- package/lib/cjs/components/message/timestamps.js +1 -1
- package/lib/cjs/components/message/timestamps.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-button.js +4 -4
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js +2 -2
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-utils.js +2 -2
- package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/cjs/components/reply.js +3 -1
- package/lib/cjs/components/reply.js.map +1 -1
- package/lib/cjs/components/webchat-settings.d.ts +6 -3
- package/lib/cjs/components/webchat-settings.js.map +1 -1
- package/lib/cjs/constants.d.ts +0 -12
- package/lib/cjs/constants.js +0 -12
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/contexts.d.ts +1 -5
- package/lib/cjs/contexts.js +10 -5
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/dev-app.js +3 -11
- package/lib/cjs/dev-app.js.map +1 -1
- package/lib/cjs/index-types.d.ts +6 -28
- package/lib/cjs/index-types.js.map +1 -1
- package/lib/cjs/msg-to-botonic.js +2 -2
- package/lib/cjs/msg-to-botonic.js.map +1 -1
- package/lib/cjs/react-bot.d.ts +16 -6
- package/lib/cjs/react-bot.js +5 -6
- package/lib/cjs/react-bot.js.map +1 -1
- package/lib/cjs/shared/styles.d.ts +2 -2
- package/lib/cjs/time-zone-to-country-code.d.ts +1 -0
- package/lib/cjs/time-zone-to-country-code.js +108 -0
- package/lib/cjs/time-zone-to-country-code.js.map +1 -0
- package/lib/cjs/util/webchat.d.ts +4 -2
- package/lib/cjs/util/webchat.js +35 -1
- package/lib/cjs/util/webchat.js.map +1 -1
- package/lib/cjs/webchat/chat-area/styles.d.ts +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
- package/lib/cjs/webchat/components/opened-persistent-menu.js +4 -4
- package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/context/index.d.ts +1 -1
- package/lib/cjs/webchat/context/index.js +4 -7
- package/lib/cjs/webchat/context/index.js.map +1 -1
- package/lib/cjs/webchat/context/types.d.ts +16 -9
- package/lib/cjs/webchat/context/use-webchat.d.ts +3 -4
- package/lib/cjs/webchat/context/use-webchat.js +35 -43
- package/lib/cjs/webchat/context/use-webchat.js.map +1 -1
- package/lib/cjs/webchat/header/default-header.js +5 -5
- package/lib/cjs/webchat/header/default-header.js.map +1 -1
- package/lib/cjs/webchat/header/styles.d.ts +7 -7
- package/lib/cjs/webchat/header/styles.js +5 -1
- package/lib/cjs/webchat/header/styles.js.map +1 -1
- package/lib/cjs/webchat/index-types.d.ts +0 -11
- package/lib/cjs/webchat/input-panel/attachment.d.ts +1 -2
- package/lib/cjs/webchat/input-panel/attachment.js +6 -5
- package/lib/cjs/webchat/input-panel/attachment.js.map +1 -1
- package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -2
- package/lib/cjs/webchat/input-panel/emoji-picker.js +6 -5
- package/lib/cjs/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/cjs/webchat/input-panel/index.d.ts +1 -4
- package/lib/cjs/webchat/input-panel/index.js +2 -2
- package/lib/cjs/webchat/input-panel/index.js.map +1 -1
- package/lib/cjs/webchat/input-panel/persistent-menu.d.ts +1 -2
- package/lib/cjs/webchat/input-panel/persistent-menu.js +5 -4
- package/lib/cjs/webchat/input-panel/persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/input-panel/send-button.js +4 -3
- package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
- package/lib/cjs/webchat/input-panel/styles.d.ts +3 -3
- package/lib/cjs/webchat/input-panel/textarea.d.ts +1 -3
- package/lib/cjs/webchat/input-panel/textarea.js +7 -5
- package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
- package/lib/cjs/webchat/message-list/intro-message.js +1 -1
- package/lib/cjs/webchat/message-list/intro-message.js.map +1 -1
- package/lib/cjs/webchat/message-list/styles.d.ts +5 -5
- package/lib/cjs/webchat/message-list/use-notifications.js +4 -4
- package/lib/cjs/webchat/message-list/use-notifications.js.map +1 -1
- package/lib/cjs/webchat/replies/styles.d.ts +3 -3
- package/lib/cjs/webchat/styles.d.ts +4 -9
- package/lib/cjs/webchat/styles.js +18 -7
- package/lib/cjs/webchat/styles.js.map +1 -1
- package/lib/cjs/webchat/theme/default-theme.d.ts +2 -0
- package/lib/cjs/webchat/theme/default-theme.js +104 -0
- package/lib/cjs/webchat/theme/default-theme.js.map +1 -0
- package/lib/cjs/webchat/theme/types.d.ts +59 -12
- package/lib/cjs/webchat/trigger-button/index.js +3 -3
- package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
- package/lib/cjs/webchat/trigger-button/styles.d.ts +3 -3
- package/lib/cjs/webchat/typing-indicator/styles.d.ts +3 -3
- package/lib/cjs/webchat/webchat-dev.d.ts +1 -1
- package/lib/cjs/webchat/webchat.js +26 -34
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview/index.js +1 -14
- package/lib/cjs/webchat/webview/index.js.map +1 -1
- package/lib/cjs/webchat/webview/styles.d.ts +6 -6
- package/lib/cjs/webchat/webview/styles.js +16 -2
- package/lib/cjs/webchat/webview/styles.js.map +1 -1
- package/lib/cjs/webchat-app.d.ts +35 -2
- package/lib/cjs/webchat-app.js +45 -17
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/cjs/webchat.template.html +43 -2
- package/lib/cjs/webview-app.js +0 -1
- package/lib/cjs/webview-app.js.map +1 -1
- package/lib/esm/components/{button.d.ts → button/index.d.ts} +4 -5
- package/lib/esm/components/{button.js → button/index.js} +26 -55
- package/lib/esm/components/button/index.js.map +1 -0
- package/lib/esm/components/button/styles.d.ts +2 -0
- package/lib/esm/components/button/styles.js +36 -0
- package/lib/esm/components/button/styles.js.map +1 -0
- package/lib/esm/components/buttons-disabler.d.ts +20 -23
- package/lib/esm/components/buttons-disabler.js +11 -26
- package/lib/esm/components/buttons-disabler.js.map +1 -1
- package/lib/esm/components/carousel.js +1 -1
- package/lib/esm/components/carousel.js.map +1 -1
- package/lib/esm/components/element.js +1 -1
- package/lib/esm/components/element.js.map +1 -1
- package/lib/esm/components/image.js +1 -1
- package/lib/esm/components/image.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +1 -1
- package/lib/esm/components/index.d.ts +1 -1
- package/lib/esm/components/index.js +1 -1
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/message/index.js +5 -5
- package/lib/esm/components/message/index.js.map +1 -1
- package/lib/esm/components/message/message-image.js +1 -1
- package/lib/esm/components/message/message-image.js.map +1 -1
- package/lib/esm/components/message/styles.d.ts +11 -11
- package/lib/esm/components/message/timestamps.js +1 -1
- package/lib/esm/components/message/timestamps.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-button.js +1 -1
- package/lib/esm/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-utils.js +1 -1
- package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/esm/components/reply.js +4 -2
- package/lib/esm/components/reply.js.map +1 -1
- package/lib/esm/components/webchat-settings.d.ts +6 -3
- package/lib/esm/components/webchat-settings.js.map +1 -1
- package/lib/esm/constants.d.ts +0 -12
- package/lib/esm/constants.js +0 -12
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/contexts.d.ts +1 -5
- package/lib/esm/contexts.js +10 -5
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/dev-app.js +3 -11
- package/lib/esm/dev-app.js.map +1 -1
- package/lib/esm/index-types.d.ts +6 -28
- package/lib/esm/index-types.js.map +1 -1
- package/lib/esm/msg-to-botonic.js +1 -1
- package/lib/esm/msg-to-botonic.js.map +1 -1
- package/lib/esm/react-bot.d.ts +16 -6
- package/lib/esm/react-bot.js +5 -6
- package/lib/esm/react-bot.js.map +1 -1
- package/lib/esm/shared/styles.d.ts +2 -2
- package/lib/esm/time-zone-to-country-code.d.ts +1 -0
- package/lib/esm/time-zone-to-country-code.js +105 -0
- package/lib/esm/time-zone-to-country-code.js.map +1 -0
- package/lib/esm/util/webchat.d.ts +4 -2
- package/lib/esm/util/webchat.js +33 -0
- package/lib/esm/util/webchat.js.map +1 -1
- package/lib/esm/webchat/chat-area/styles.d.ts +1 -1
- package/lib/esm/webchat/components/conditional-animation.js +1 -1
- package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
- package/lib/esm/webchat/components/opened-persistent-menu.js +2 -2
- package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/esm/webchat/context/index.d.ts +1 -1
- package/lib/esm/webchat/context/index.js +2 -4
- package/lib/esm/webchat/context/index.js.map +1 -1
- package/lib/esm/webchat/context/types.d.ts +16 -9
- package/lib/esm/webchat/context/use-webchat.d.ts +3 -4
- package/lib/esm/webchat/context/use-webchat.js +33 -41
- package/lib/esm/webchat/context/use-webchat.js.map +1 -1
- package/lib/esm/webchat/header/default-header.js +6 -6
- package/lib/esm/webchat/header/default-header.js.map +1 -1
- package/lib/esm/webchat/header/styles.d.ts +7 -7
- package/lib/esm/webchat/header/styles.js +6 -2
- package/lib/esm/webchat/header/styles.js.map +1 -1
- package/lib/esm/webchat/index-types.d.ts +0 -11
- package/lib/esm/webchat/input-panel/attachment.d.ts +1 -2
- package/lib/esm/webchat/input-panel/attachment.js +7 -6
- package/lib/esm/webchat/input-panel/attachment.js.map +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -2
- package/lib/esm/webchat/input-panel/emoji-picker.js +7 -6
- package/lib/esm/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/esm/webchat/input-panel/index.d.ts +1 -4
- package/lib/esm/webchat/input-panel/index.js +2 -2
- package/lib/esm/webchat/input-panel/index.js.map +1 -1
- package/lib/esm/webchat/input-panel/persistent-menu.d.ts +1 -2
- package/lib/esm/webchat/input-panel/persistent-menu.js +6 -5
- package/lib/esm/webchat/input-panel/persistent-menu.js.map +1 -1
- package/lib/esm/webchat/input-panel/send-button.js +5 -4
- package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
- package/lib/esm/webchat/input-panel/styles.d.ts +3 -3
- package/lib/esm/webchat/input-panel/textarea.d.ts +1 -3
- package/lib/esm/webchat/input-panel/textarea.js +7 -5
- package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
- package/lib/esm/webchat/message-list/intro-message.js +1 -1
- package/lib/esm/webchat/message-list/intro-message.js.map +1 -1
- package/lib/esm/webchat/message-list/styles.d.ts +5 -5
- package/lib/esm/webchat/message-list/use-notifications.js +4 -4
- package/lib/esm/webchat/message-list/use-notifications.js.map +1 -1
- package/lib/esm/webchat/replies/styles.d.ts +3 -3
- package/lib/esm/webchat/styles.d.ts +4 -9
- package/lib/esm/webchat/styles.js +19 -8
- package/lib/esm/webchat/styles.js.map +1 -1
- package/lib/esm/webchat/theme/default-theme.d.ts +2 -0
- package/lib/esm/webchat/theme/default-theme.js +101 -0
- package/lib/esm/webchat/theme/default-theme.js.map +1 -0
- package/lib/esm/webchat/theme/types.d.ts +59 -12
- package/lib/esm/webchat/trigger-button/index.js +3 -3
- package/lib/esm/webchat/trigger-button/index.js.map +1 -1
- package/lib/esm/webchat/trigger-button/styles.d.ts +3 -3
- package/lib/esm/webchat/typing-indicator/styles.d.ts +3 -3
- package/lib/esm/webchat/webchat-dev.d.ts +1 -1
- package/lib/esm/webchat/webchat.js +29 -37
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview/index.js +1 -14
- package/lib/esm/webchat/webview/index.js.map +1 -1
- package/lib/esm/webchat/webview/styles.d.ts +6 -6
- package/lib/esm/webchat/webview/styles.js +17 -3
- package/lib/esm/webchat/webview/styles.js.map +1 -1
- package/lib/esm/webchat-app.d.ts +35 -2
- package/lib/esm/webchat-app.js +45 -17
- package/lib/esm/webchat-app.js.map +1 -1
- package/lib/esm/webchat.template.html +43 -2
- package/lib/esm/webview-app.js +1 -2
- package/lib/esm/webview-app.js.map +1 -1
- package/package.json +4 -2
- package/src/components/{button.tsx → button/index.tsx} +26 -102
- package/src/components/button/styles.ts +38 -0
- package/src/components/{buttons-disabler.js → buttons-disabler.ts} +35 -39
- package/src/components/carousel.tsx +1 -2
- package/src/components/element.tsx +1 -1
- package/src/components/image.tsx +3 -2
- package/src/components/index-types.ts +1 -1
- package/src/components/index.ts +1 -1
- package/src/components/message/index.jsx +5 -9
- package/src/components/message/message-image.tsx +1 -4
- package/src/components/message/timestamps.tsx +1 -2
- package/src/components/multichannel/multichannel-button.jsx +1 -1
- package/src/components/multichannel/multichannel-carousel.jsx +1 -1
- package/src/components/multichannel/multichannel-utils.js +1 -1
- package/src/components/reply.tsx +2 -8
- package/src/components/webchat-settings.tsx +11 -3
- package/src/constants.js +0 -12
- package/src/contexts.tsx +11 -12
- package/src/dev-app.jsx +1 -25
- package/src/index-types.ts +8 -26
- package/src/msg-to-botonic.jsx +1 -1
- package/src/react-bot.tsx +51 -0
- package/src/time-zone-to-country-code.ts +104 -0
- package/src/util/webchat.ts +41 -2
- package/src/webchat/components/conditional-animation.jsx +2 -2
- package/src/webchat/components/opened-persistent-menu.jsx +2 -3
- package/src/webchat/context/index.tsx +3 -5
- package/src/webchat/context/types.ts +18 -13
- package/src/webchat/context/use-webchat.ts +36 -43
- package/src/webchat/header/default-header.tsx +6 -17
- package/src/webchat/header/styles.ts +6 -2
- package/src/webchat/index-types.ts +0 -12
- package/src/webchat/input-panel/attachment.tsx +5 -16
- package/src/webchat/input-panel/emoji-picker.tsx +5 -15
- package/src/webchat/input-panel/index.tsx +2 -13
- package/src/webchat/input-panel/persistent-menu.tsx +5 -15
- package/src/webchat/input-panel/send-button.tsx +3 -9
- package/src/webchat/input-panel/textarea.tsx +8 -14
- package/src/webchat/message-list/intro-message.tsx +1 -2
- package/src/webchat/message-list/use-notifications.ts +4 -8
- package/src/webchat/styles.ts +20 -14
- package/src/webchat/theme/default-theme.ts +102 -0
- package/src/webchat/theme/theme.d.ts +8 -0
- package/src/webchat/theme/types.ts +111 -24
- package/src/webchat/trigger-button/index.tsx +3 -5
- package/src/webchat/webchat.tsx +79 -102
- package/src/webchat/webview/index.tsx +0 -14
- package/src/webchat/webview/styles.ts +16 -2
- package/src/webchat-app.tsx +88 -35
- package/src/webchat.template.html +43 -2
- package/src/webview-app.tsx +1 -3
- package/lib/cjs/components/button.js.map +0 -1
- package/lib/esm/components/button.js.map +0 -1
- package/src/react-bot.jsx +0 -38
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
export const timeZoneToCountryCode: Record<string, string> = {
|
|
3
|
+
'Africa/Abidjan': 'CI',
|
|
4
|
+
'Africa/Accra': 'GH',
|
|
5
|
+
'Africa/Addis_Ababa': 'ET',
|
|
6
|
+
'Africa/Algiers': 'DZ',
|
|
7
|
+
'Africa/Asmara': 'ER',
|
|
8
|
+
'Africa/Bamako': 'ML',
|
|
9
|
+
'Africa/Bangui': 'CF',
|
|
10
|
+
'Africa/Banjul': 'GM',
|
|
11
|
+
'Africa/Bissau': 'GW',
|
|
12
|
+
'Africa/Blantyre': 'MW',
|
|
13
|
+
'Africa/Brazzaville': 'CG',
|
|
14
|
+
'Africa/Bujumbura': 'BI',
|
|
15
|
+
'Africa/Cairo': 'EG',
|
|
16
|
+
'Africa/Casablanca': 'MA',
|
|
17
|
+
'Africa/Ceuta': 'ES',
|
|
18
|
+
'Africa/Conakry': 'GN',
|
|
19
|
+
'Africa/Dakar': 'SN',
|
|
20
|
+
'Africa/Dar_es_Salaam': 'TZ',
|
|
21
|
+
'Africa/Djibouti': 'DJ',
|
|
22
|
+
'Africa/Douala': 'CM',
|
|
23
|
+
'Africa/El_Aaiun': 'EH',
|
|
24
|
+
'Africa/Freetown': 'SL',
|
|
25
|
+
'Africa/Gaborone': 'BW',
|
|
26
|
+
'Africa/Harare': 'ZW',
|
|
27
|
+
'Africa/Johannesburg': 'ZA',
|
|
28
|
+
'Africa/Juba': 'SS',
|
|
29
|
+
'Africa/Kampala': 'UG',
|
|
30
|
+
'Africa/Khartoum': 'SD',
|
|
31
|
+
'Africa/Kigali': 'RW',
|
|
32
|
+
'Africa/Kinshasa': 'CD',
|
|
33
|
+
'Africa/Lagos': 'NG',
|
|
34
|
+
'Africa/Libreville': 'GA',
|
|
35
|
+
'Africa/Lome': 'TG',
|
|
36
|
+
'Africa/Luanda': 'AO',
|
|
37
|
+
'Africa/Lubumbashi': 'CD',
|
|
38
|
+
'Africa/Lusaka': 'ZM',
|
|
39
|
+
'Africa/Malabo': 'GQ',
|
|
40
|
+
'Africa/Maputo': 'MZ',
|
|
41
|
+
'Africa/Maseru': 'LS',
|
|
42
|
+
'Africa/Mbabane': 'SZ',
|
|
43
|
+
'Africa/Mogadishu': 'SO',
|
|
44
|
+
'Africa/Monrovia': 'LR',
|
|
45
|
+
'Africa/Nairobi': 'KE',
|
|
46
|
+
'Africa/Ndjamena': 'TD',
|
|
47
|
+
'Africa/Niamey': 'NE',
|
|
48
|
+
'Africa/Nouakchott': 'MR',
|
|
49
|
+
'Africa/Ouagadougou': 'BF',
|
|
50
|
+
'Africa/Porto-Novo': 'BJ',
|
|
51
|
+
'Africa/Sao_Tome': 'ST',
|
|
52
|
+
'Africa/Tripoli': 'LY',
|
|
53
|
+
'Africa/Tunis': 'TN',
|
|
54
|
+
'Africa/Windhoek': 'NA',
|
|
55
|
+
'America/Argentina/Buenos_Aires': 'AR',
|
|
56
|
+
'America/Bogota': 'CO',
|
|
57
|
+
'America/Caracas': 'VE',
|
|
58
|
+
'America/Chicago': 'US',
|
|
59
|
+
'America/Denver': 'US',
|
|
60
|
+
'America/Guatemala': 'GT',
|
|
61
|
+
'America/Halifax': 'CA',
|
|
62
|
+
'America/La_Paz': 'BO',
|
|
63
|
+
'America/Lima': 'PE',
|
|
64
|
+
'America/Los_Angeles': 'US',
|
|
65
|
+
'America/Mexico_City': 'MX',
|
|
66
|
+
'America/Montevideo': 'UY',
|
|
67
|
+
'America/New_York': 'US',
|
|
68
|
+
'America/Phoenix': 'US',
|
|
69
|
+
'America/Santiago': 'CL',
|
|
70
|
+
'America/Sao_Paulo': 'BR',
|
|
71
|
+
'America/Toronto': 'CA',
|
|
72
|
+
'Asia/Bangkok': 'TH',
|
|
73
|
+
'Asia/Colombo': 'LK',
|
|
74
|
+
'Asia/Dubai': 'AE',
|
|
75
|
+
'Asia/Hong_Kong': 'HK',
|
|
76
|
+
'Asia/Jakarta': 'ID',
|
|
77
|
+
'Asia/Kolkata': 'IN',
|
|
78
|
+
'Asia/Manila': 'PH',
|
|
79
|
+
'Asia/Seoul': 'KR',
|
|
80
|
+
'Asia/Shanghai': 'CN',
|
|
81
|
+
'Asia/Singapore': 'SG',
|
|
82
|
+
'Asia/Taipei': 'TW',
|
|
83
|
+
'Asia/Tokyo': 'JP',
|
|
84
|
+
'Australia/Brisbane': 'AU',
|
|
85
|
+
'Australia/Melbourne': 'AU',
|
|
86
|
+
'Australia/Perth': 'AU',
|
|
87
|
+
'Australia/Sydney': 'AU',
|
|
88
|
+
'Europe/Amsterdam': 'NL',
|
|
89
|
+
'Europe/Berlin': 'DE',
|
|
90
|
+
'Europe/Brussels': 'BE',
|
|
91
|
+
'Europe/Bucharest': 'RO',
|
|
92
|
+
'Europe/Copenhagen': 'DK',
|
|
93
|
+
'Europe/Helsinki': 'FI',
|
|
94
|
+
'Europe/Lisbon': 'PT',
|
|
95
|
+
'Europe/London': 'GB',
|
|
96
|
+
'Europe/Madrid': 'ES',
|
|
97
|
+
'Europe/Oslo': 'NO',
|
|
98
|
+
'Europe/Paris': 'FR',
|
|
99
|
+
'Europe/Prague': 'CZ',
|
|
100
|
+
'Europe/Rome': 'IT',
|
|
101
|
+
'Europe/Stockholm': 'SE',
|
|
102
|
+
'Europe/Warsaw': 'PL',
|
|
103
|
+
'Pacific/Auckland': 'NZ',
|
|
104
|
+
}
|
package/src/util/webchat.ts
CHANGED
|
@@ -3,7 +3,9 @@ import UAParser from 'ua-parser-js'
|
|
|
3
3
|
import { v7 as uuidv7 } from 'uuid'
|
|
4
4
|
|
|
5
5
|
import { WEBCHAT } from '../constants'
|
|
6
|
-
import {
|
|
6
|
+
import { timeZoneToCountryCode } from '../time-zone-to-country-code'
|
|
7
|
+
import { ClientUser } from '../webchat/context/types'
|
|
8
|
+
import { WebchatTheme } from '../webchat/theme/types'
|
|
7
9
|
import { getProperty } from './objects'
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -12,7 +14,7 @@ import { getProperty } from './objects'
|
|
|
12
14
|
* If property doesn't exist, returns the defaultValue.
|
|
13
15
|
*/
|
|
14
16
|
export const _getThemeProperty =
|
|
15
|
-
(theme:
|
|
17
|
+
(theme: WebchatTheme) => (property: string, defaultValue?: any) => {
|
|
16
18
|
for (const [key, value] of Object.entries(WEBCHAT.CUSTOM_PROPERTIES)) {
|
|
17
19
|
if (value === property) {
|
|
18
20
|
const nestedProperty = getProperty(theme, value)
|
|
@@ -48,6 +50,43 @@ export const initSession = (
|
|
|
48
50
|
return session
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
export function updateUserLocaleAndCountry(user: Partial<ClientUser>) {
|
|
54
|
+
user.locale = getLocale(user)
|
|
55
|
+
user.country = getCountry(user)
|
|
56
|
+
user.system_locale = getSystemLocale(user)
|
|
57
|
+
|
|
58
|
+
return user
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getLocale(user: Partial<ClientUser>) {
|
|
62
|
+
if (user.locale) {
|
|
63
|
+
return user.locale
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return user.extra_data?.language
|
|
67
|
+
? (user.extra_data?.language as string)
|
|
68
|
+
: navigator.language
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getCountry(user: Partial<ClientUser>) {
|
|
72
|
+
if (user.country) {
|
|
73
|
+
return user.country
|
|
74
|
+
}
|
|
75
|
+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
76
|
+
const userCountry = timeZoneToCountryCode[timeZone]
|
|
77
|
+
|
|
78
|
+
return user.extra_data?.country
|
|
79
|
+
? (user.extra_data?.country as string)
|
|
80
|
+
: userCountry
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getSystemLocale(user: Partial<ClientUser>) {
|
|
84
|
+
if (user.system_locale) {
|
|
85
|
+
return user.system_locale
|
|
86
|
+
}
|
|
87
|
+
return getLocale(user)
|
|
88
|
+
}
|
|
89
|
+
|
|
51
90
|
export const shouldKeepSessionOnReload = ({
|
|
52
91
|
initialDevSettings,
|
|
53
92
|
devSettings,
|
|
@@ -9,9 +9,9 @@ export const ConditionalAnimation = props => {
|
|
|
9
9
|
const { getThemeProperty } = useContext(WebchatContext)
|
|
10
10
|
|
|
11
11
|
const animationsEnabled = getThemeProperty(
|
|
12
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableAnimations
|
|
13
|
-
props.enableAnimations !== undefined ? props.enableAnimations : true
|
|
12
|
+
WEBCHAT.CUSTOM_PROPERTIES.enableAnimations
|
|
14
13
|
)
|
|
14
|
+
|
|
15
15
|
return (
|
|
16
16
|
<ConditionalWrapper
|
|
17
17
|
condition={animationsEnabled}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import { Button } from '../../components/button'
|
|
4
|
+
import { Button } from '../../components/button/index'
|
|
5
5
|
import { ROLES, WEBCHAT } from '../../constants'
|
|
6
6
|
import { WebchatContext } from '../context'
|
|
7
7
|
import { useComponentVisible } from '../hooks'
|
|
@@ -18,8 +18,7 @@ export const OpenedPersistentMenu = ({ onClick, options, borderRadius }) => {
|
|
|
18
18
|
const { ref, isComponentVisible } = useComponentVisible(true, onClick)
|
|
19
19
|
const { getThemeProperty } = useContext(WebchatContext)
|
|
20
20
|
const CustomPersistentMenu = getThemeProperty(
|
|
21
|
-
WEBCHAT.CUSTOM_PROPERTIES.customPersistentMenu
|
|
22
|
-
undefined
|
|
21
|
+
WEBCHAT.CUSTOM_PROPERTIES.customPersistentMenu
|
|
23
22
|
)
|
|
24
23
|
let closeLabel = 'Cancel'
|
|
25
24
|
try {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { createContext } from 'react'
|
|
2
2
|
|
|
3
|
-
import { WebchatContextProps } from './types'
|
|
4
|
-
import { webchatInitialState } from './use-webchat'
|
|
3
|
+
import { WebchatContextProps, WebchatState } from './types'
|
|
5
4
|
|
|
6
5
|
export { WebchatState } from './types'
|
|
7
|
-
export { useWebchat
|
|
6
|
+
export { useWebchat } from './use-webchat'
|
|
8
7
|
|
|
9
8
|
export const WebchatContext = createContext<WebchatContextProps>({
|
|
10
9
|
addMessage: () => {
|
|
@@ -43,7 +42,6 @@ export const WebchatContext = createContext<WebchatContextProps>({
|
|
|
43
42
|
sendText: async () => {
|
|
44
43
|
return
|
|
45
44
|
},
|
|
46
|
-
theme: {}, // TODO: Remove this attribute and use allways webchatState.theme
|
|
47
45
|
toggleCoverComponent: () => {
|
|
48
46
|
return
|
|
49
47
|
},
|
|
@@ -71,7 +69,7 @@ export const WebchatContext = createContext<WebchatContextProps>({
|
|
|
71
69
|
updateWebchatDevSettings: () => {
|
|
72
70
|
return
|
|
73
71
|
},
|
|
74
|
-
webchatState:
|
|
72
|
+
webchatState: {} as WebchatState,
|
|
75
73
|
trackEvent: async () => {
|
|
76
74
|
return
|
|
77
75
|
},
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Input as CoreInput,
|
|
3
|
-
Session as CoreSession,
|
|
4
|
-
SessionUser as CoreSessionUser,
|
|
5
|
-
} from '@botonic/core'
|
|
1
|
+
import { Input as CoreInput, Session as CoreSession } from '@botonic/core'
|
|
6
2
|
|
|
7
3
|
import { Reply, WebchatSettingsProps, Webview } from '../../components'
|
|
8
4
|
import { CloseWebviewOptions } from '../../contexts'
|
|
9
5
|
import { TrackEventFunction, WebchatMessage } from '../../index-types'
|
|
10
|
-
import {
|
|
11
|
-
import { ThemeProps } from '../theme/types'
|
|
6
|
+
import { WebchatTheme } from '../theme/types'
|
|
12
7
|
|
|
13
8
|
export interface ErrorMessage {
|
|
14
9
|
message?: string
|
|
@@ -20,8 +15,6 @@ export interface DevSettings {
|
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
export interface WebchatState {
|
|
23
|
-
width: number // TODO: move this inside webchatState.theme.style
|
|
24
|
-
height: number // TODO: move this inside webchatState.theme.style
|
|
25
18
|
messagesJSON: any[]
|
|
26
19
|
messagesComponents: any[]
|
|
27
20
|
replies?: (typeof Reply)[]
|
|
@@ -32,8 +25,8 @@ export interface WebchatState {
|
|
|
32
25
|
session: Partial<CoreSession>
|
|
33
26
|
lastRoutePath?: string
|
|
34
27
|
handoff: boolean
|
|
35
|
-
theme:
|
|
36
|
-
themeUpdates: Partial<
|
|
28
|
+
theme: WebchatTheme
|
|
29
|
+
themeUpdates: Partial<WebchatTheme>
|
|
37
30
|
error: ErrorMessage
|
|
38
31
|
online: boolean
|
|
39
32
|
devSettings: DevSettings
|
|
@@ -51,6 +44,19 @@ export interface WebchatState {
|
|
|
51
44
|
|
|
52
45
|
// ClientInput: type for sendInput and updateLatestInput function without message_id and bot_interaction_id because backend set this values
|
|
53
46
|
export type ClientInput = Omit<CoreInput, 'message_id' | 'bot_interaction_id'>
|
|
47
|
+
// ClientSession: type for session in frontend when webchat is deployed
|
|
48
|
+
export type ClientSession = {
|
|
49
|
+
user: ClientUser
|
|
50
|
+
}
|
|
51
|
+
// ClientUser: type for user in frontend when webchat is deployed
|
|
52
|
+
export type ClientUser = {
|
|
53
|
+
id: string
|
|
54
|
+
name: string
|
|
55
|
+
locale: string
|
|
56
|
+
country: string
|
|
57
|
+
system_locale?: string
|
|
58
|
+
extra_data?: Record<string, any>
|
|
59
|
+
}
|
|
54
60
|
|
|
55
61
|
export interface WebchatContextProps {
|
|
56
62
|
addMessage: (message: WebchatMessage) => void
|
|
@@ -65,7 +71,6 @@ export interface WebchatContextProps {
|
|
|
65
71
|
sendText: (text: string, payload?: string) => Promise<void>
|
|
66
72
|
setIsInputFocused: (isInputFocused: boolean) => void
|
|
67
73
|
setLastMessageVisible: (isLastMessageVisible: boolean) => void
|
|
68
|
-
theme: ThemeProps // TODO: Remove this attribute and use allways webchatState.theme
|
|
69
74
|
toggleWebchat: (toggle: boolean) => void
|
|
70
75
|
toggleEmojiPicker: (toggle: boolean) => void
|
|
71
76
|
togglePersistentMenu: (toggle: boolean) => void
|
|
@@ -73,7 +78,7 @@ export interface WebchatContextProps {
|
|
|
73
78
|
updateLatestInput: (input: ClientInput) => void
|
|
74
79
|
updateMessage: (message: WebchatMessage) => void
|
|
75
80
|
updateReplies: (replies: (typeof Reply)[]) => void
|
|
76
|
-
updateUser: (user:
|
|
81
|
+
updateUser: (user: ClientUser) => void
|
|
77
82
|
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
78
83
|
trackEvent?: TrackEventFunction
|
|
79
84
|
webchatState: WebchatState
|
|
@@ -3,51 +3,41 @@ import { useReducer, useRef } from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { Reply } from '../../components'
|
|
5
5
|
import { Webview } from '../../components/index-types'
|
|
6
|
-
import { COLORS, WEBCHAT } from '../../constants'
|
|
7
6
|
import { WebchatMessage } from '../../index-types'
|
|
8
|
-
import {
|
|
7
|
+
import { defaultTheme } from '../theme/default-theme'
|
|
8
|
+
import { WebchatTheme } from '../theme/types'
|
|
9
9
|
import { WebchatAction } from './actions'
|
|
10
10
|
import { ClientInput, DevSettings, ErrorMessage, WebchatState } from './types'
|
|
11
11
|
import { webchatReducer } from './webchat-reducer'
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
isWebchatOpen: false,
|
|
42
|
-
isEmojiPickerOpen: false,
|
|
43
|
-
isPersistentMenuOpen: false,
|
|
44
|
-
isCoverComponentOpen: false,
|
|
45
|
-
isCustomComponentRendered: false,
|
|
46
|
-
lastMessageUpdate: undefined,
|
|
47
|
-
currentAttachment: undefined,
|
|
48
|
-
numUnreadMessages: 0,
|
|
49
|
-
isLastMessageVisible: true,
|
|
50
|
-
isInputFocused: false,
|
|
13
|
+
function getWebchatInitialState(initialTheme: WebchatTheme): WebchatState {
|
|
14
|
+
return {
|
|
15
|
+
replies: [],
|
|
16
|
+
messagesJSON: [],
|
|
17
|
+
messagesComponents: [],
|
|
18
|
+
latestInput: {},
|
|
19
|
+
typing: false,
|
|
20
|
+
webview: null,
|
|
21
|
+
webviewParams: null,
|
|
22
|
+
session: { user: undefined },
|
|
23
|
+
lastRoutePath: undefined,
|
|
24
|
+
handoff: false,
|
|
25
|
+
theme: initialTheme,
|
|
26
|
+
themeUpdates: {},
|
|
27
|
+
error: {},
|
|
28
|
+
online: true,
|
|
29
|
+
devSettings: { keepSessionOnReload: false },
|
|
30
|
+
isWebchatOpen: false,
|
|
31
|
+
isEmojiPickerOpen: false,
|
|
32
|
+
isPersistentMenuOpen: false,
|
|
33
|
+
isCoverComponentOpen: false,
|
|
34
|
+
isCustomComponentRendered: false,
|
|
35
|
+
lastMessageUpdate: undefined,
|
|
36
|
+
currentAttachment: undefined,
|
|
37
|
+
numUnreadMessages: 0,
|
|
38
|
+
isLastMessageVisible: true,
|
|
39
|
+
isInputFocused: false,
|
|
40
|
+
}
|
|
51
41
|
}
|
|
52
42
|
|
|
53
43
|
export interface UseWebchat {
|
|
@@ -73,7 +63,7 @@ export interface UseWebchat {
|
|
|
73
63
|
updateMessage: (message: WebchatMessage) => void
|
|
74
64
|
updateReplies: (replies: (typeof Reply)[]) => void
|
|
75
65
|
updateSession: (session: Partial<Session>) => void
|
|
76
|
-
updateTheme: (theme:
|
|
66
|
+
updateTheme: (theme: WebchatTheme, themeUpdates?: WebchatTheme) => void
|
|
77
67
|
updateTyping: (typing: boolean) => void
|
|
78
68
|
updateWebview: (webview: Webview, params: Record<string, string>) => void
|
|
79
69
|
removeReplies: () => void
|
|
@@ -87,7 +77,10 @@ export interface UseWebchat {
|
|
|
87
77
|
inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
|
|
88
78
|
}
|
|
89
79
|
|
|
90
|
-
export function useWebchat(): UseWebchat {
|
|
80
|
+
export function useWebchat(theme?: WebchatTheme): UseWebchat {
|
|
81
|
+
const initialTheme = theme || defaultTheme
|
|
82
|
+
const webchatInitialState = getWebchatInitialState(initialTheme)
|
|
83
|
+
|
|
91
84
|
const [webchatState, webchatDispatch] = useReducer(
|
|
92
85
|
webchatReducer,
|
|
93
86
|
webchatInitialState
|
|
@@ -154,7 +147,7 @@ export function useWebchat(): UseWebchat {
|
|
|
154
147
|
payload: handoff,
|
|
155
148
|
})
|
|
156
149
|
|
|
157
|
-
const updateTheme = (theme:
|
|
150
|
+
const updateTheme = (theme: WebchatTheme, themeUpdates?: WebchatTheme) => {
|
|
158
151
|
const payload =
|
|
159
152
|
themeUpdates !== undefined ? { theme, themeUpdates } : { theme }
|
|
160
153
|
webchatDispatch({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ROLES, WEBCHAT } from '../../constants'
|
|
4
4
|
import { Scale } from '../../shared/styles'
|
|
5
5
|
import { resolveImage } from '../../util/environment'
|
|
6
6
|
import { ConditionalWrapper } from '../../util/react'
|
|
@@ -18,36 +18,25 @@ export const DefaultHeader = () => {
|
|
|
18
18
|
const { getThemeProperty, toggleWebchat } = useContext(WebchatContext)
|
|
19
19
|
|
|
20
20
|
const animationsEnabled = getThemeProperty(
|
|
21
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableAnimations
|
|
22
|
-
true
|
|
21
|
+
WEBCHAT.CUSTOM_PROPERTIES.enableAnimations
|
|
23
22
|
)
|
|
24
23
|
|
|
25
24
|
const headerImage = getThemeProperty(
|
|
26
25
|
WEBCHAT.CUSTOM_PROPERTIES.headerImage,
|
|
27
|
-
getThemeProperty(
|
|
28
|
-
WEBCHAT.CUSTOM_PROPERTIES.brandImage,
|
|
29
|
-
WEBCHAT.DEFAULTS.LOGO
|
|
30
|
-
)
|
|
26
|
+
getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.brandImage)
|
|
31
27
|
)
|
|
32
28
|
|
|
33
|
-
const headerTitle = getThemeProperty(
|
|
34
|
-
WEBCHAT.CUSTOM_PROPERTIES.headerTitle,
|
|
35
|
-
WEBCHAT.DEFAULTS.TITLE
|
|
36
|
-
)
|
|
29
|
+
const headerTitle = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.headerTitle)
|
|
37
30
|
|
|
38
31
|
const headerSubtitle = getThemeProperty(
|
|
39
|
-
WEBCHAT.CUSTOM_PROPERTIES.headerSubtitle
|
|
40
|
-
''
|
|
32
|
+
WEBCHAT.CUSTOM_PROPERTIES.headerSubtitle
|
|
41
33
|
)
|
|
42
34
|
|
|
43
35
|
const handleCloseWebchat = () => {
|
|
44
36
|
toggleWebchat(false)
|
|
45
37
|
}
|
|
46
38
|
|
|
47
|
-
const color = getThemeProperty(
|
|
48
|
-
WEBCHAT.CUSTOM_PROPERTIES.brandColor,
|
|
49
|
-
COLORS.BOTONIC_BLUE
|
|
50
|
-
)
|
|
39
|
+
const color = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.brandColor)
|
|
51
40
|
|
|
52
41
|
return (
|
|
53
42
|
<HeaderContainer
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from 'styled-components'
|
|
2
2
|
|
|
3
|
-
import { COLORS
|
|
3
|
+
import { COLORS } from '../../constants'
|
|
4
4
|
|
|
5
5
|
export const HeaderContainer = styled.div`
|
|
6
6
|
display: flex;
|
|
@@ -9,9 +9,13 @@ export const HeaderContainer = styled.div`
|
|
|
9
9
|
${COLORS.BLEACHED_CEDAR_PURPLE} 0%,
|
|
10
10
|
${props => props.color} 100%
|
|
11
11
|
);
|
|
12
|
-
border-radius: ${
|
|
12
|
+
border-radius: ${props => props.theme.header?.style?.borderRadius};
|
|
13
13
|
z-index: 2;
|
|
14
14
|
height: inherit;
|
|
15
|
+
|
|
16
|
+
@media (max-width: ${props => props.theme.mobileBreakpoint}px) {
|
|
17
|
+
border-radius: ${props => props.theme.header?.mobileStyle?.borderRadius};
|
|
18
|
+
}
|
|
15
19
|
`
|
|
16
20
|
|
|
17
21
|
export const ImageContainer = styled.div`
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { WebchatArgs } from '../index-types'
|
|
2
2
|
|
|
3
|
-
export interface WebchatStateTheme {
|
|
4
|
-
headerTitle: string
|
|
5
|
-
brandColor: string
|
|
6
|
-
brandImage: string
|
|
7
|
-
triggerButtonImage: undefined
|
|
8
|
-
textPlaceholder: string
|
|
9
|
-
style: {
|
|
10
|
-
fontFamily: string
|
|
11
|
-
borderRadius?: string
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
3
|
export interface WebchatDevProps extends WebchatArgs {
|
|
16
4
|
initialDevSettings?: {
|
|
17
5
|
keepSessionOnReload?: boolean
|
|
@@ -1,38 +1,27 @@
|
|
|
1
1
|
import React, { useContext, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
import AttachmentIcon from '../../assets/attachment-icon.svg'
|
|
4
|
-
import { ROLES
|
|
4
|
+
import { ROLES } from '../../constants'
|
|
5
5
|
import { WebchatContext } from '../../webchat/context'
|
|
6
6
|
import { Icon } from '../components/common'
|
|
7
7
|
import { ConditionalAnimation } from '../components/conditional-animation'
|
|
8
8
|
|
|
9
9
|
interface AttachmentProps {
|
|
10
10
|
accept: string
|
|
11
|
-
enableAttachments?: boolean
|
|
12
11
|
onChange: (event: any) => void
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
export const Attachment = ({
|
|
16
|
-
|
|
17
|
-
enableAttachments,
|
|
18
|
-
onChange,
|
|
19
|
-
}: AttachmentProps) => {
|
|
20
|
-
const { getThemeProperty } = useContext(WebchatContext)
|
|
14
|
+
export const Attachment = ({ accept, onChange }: AttachmentProps) => {
|
|
15
|
+
const { webchatState } = useContext(WebchatContext)
|
|
21
16
|
|
|
22
17
|
const fileInputRef = useRef<HTMLInputElement | null>(null)
|
|
23
18
|
|
|
24
|
-
const CustomAttachments =
|
|
25
|
-
WEBCHAT.CUSTOM_PROPERTIES.customAttachments,
|
|
26
|
-
undefined
|
|
27
|
-
)
|
|
19
|
+
const CustomAttachments = webchatState.theme.userInput?.attachments?.custom
|
|
28
20
|
|
|
29
21
|
const isAttachmentsEnabled = () => {
|
|
30
22
|
const hasCustomAttachments = !!CustomAttachments
|
|
31
23
|
return (
|
|
32
|
-
|
|
33
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableAttachments,
|
|
34
|
-
enableAttachments
|
|
35
|
-
) ?? hasCustomAttachments
|
|
24
|
+
webchatState.theme.userInput?.attachments?.enable ?? hasCustomAttachments
|
|
36
25
|
)
|
|
37
26
|
}
|
|
38
27
|
const attachmentsEnabled = isAttachmentsEnabled()
|
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import LogoEmoji from '../../assets/emojiButton.svg'
|
|
4
|
-
import { ROLES
|
|
4
|
+
import { ROLES } from '../../constants'
|
|
5
5
|
import { WebchatContext } from '../../webchat/context'
|
|
6
6
|
import { Icon } from '../components/common'
|
|
7
7
|
import { ConditionalAnimation } from '../components/conditional-animation'
|
|
8
8
|
|
|
9
9
|
interface EmojiPickerProps {
|
|
10
|
-
enableEmojiPicker?: boolean
|
|
11
10
|
onClick: () => void
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export const EmojiPicker = ({
|
|
15
|
-
|
|
16
|
-
onClick,
|
|
17
|
-
}: EmojiPickerProps) => {
|
|
18
|
-
const { getThemeProperty } = useContext(WebchatContext)
|
|
13
|
+
export const EmojiPicker = ({ onClick }: EmojiPickerProps) => {
|
|
14
|
+
const { webchatState } = useContext(WebchatContext)
|
|
19
15
|
|
|
20
|
-
const CustomEmojiPicker =
|
|
21
|
-
WEBCHAT.CUSTOM_PROPERTIES.customEmojiPicker,
|
|
22
|
-
undefined
|
|
23
|
-
)
|
|
16
|
+
const CustomEmojiPicker = webchatState.theme.userInput?.emojiPicker?.custom
|
|
24
17
|
|
|
25
18
|
const isEmojiPickerEnabled = () => {
|
|
26
19
|
const hasCustomEmojiPicker = !!CustomEmojiPicker
|
|
27
20
|
return (
|
|
28
|
-
|
|
29
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableEmojiPicker,
|
|
30
|
-
enableEmojiPicker
|
|
31
|
-
) ?? hasCustomEmojiPicker
|
|
21
|
+
webchatState.theme.userInput?.emojiPicker?.enable ?? hasCustomEmojiPicker
|
|
32
22
|
)
|
|
33
23
|
}
|
|
34
24
|
const emojiPickerEnabled = isEmojiPickerEnabled()
|
|
@@ -15,9 +15,6 @@ import { UserInputContainer } from './styles'
|
|
|
15
15
|
import { Textarea } from './textarea'
|
|
16
16
|
|
|
17
17
|
interface InputPanelProps {
|
|
18
|
-
persistentMenu: any
|
|
19
|
-
enableEmojiPicker?: boolean
|
|
20
|
-
enableAttachments?: boolean
|
|
21
18
|
handleAttachment: (event: any) => void
|
|
22
19
|
textareaRef: React.MutableRefObject<HTMLTextAreaElement | undefined>
|
|
23
20
|
host: HTMLElement
|
|
@@ -25,9 +22,6 @@ interface InputPanelProps {
|
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
export const InputPanel = ({
|
|
28
|
-
persistentMenu,
|
|
29
|
-
enableEmojiPicker,
|
|
30
|
-
enableAttachments,
|
|
31
25
|
handleAttachment,
|
|
32
26
|
textareaRef,
|
|
33
27
|
host,
|
|
@@ -96,23 +90,18 @@ export const InputPanel = ({
|
|
|
96
90
|
/>
|
|
97
91
|
)}
|
|
98
92
|
|
|
99
|
-
<PersistentMenu onClick={handleMenu}
|
|
93
|
+
<PersistentMenu onClick={handleMenu} />
|
|
100
94
|
|
|
101
95
|
<Textarea
|
|
102
96
|
host={host}
|
|
103
|
-
persistentMenu={persistentMenu}
|
|
104
97
|
textareaRef={textareaRef}
|
|
105
98
|
sendChatEvent={sendChatEvent}
|
|
106
99
|
sendTextAreaText={sendTextAreaText}
|
|
107
100
|
/>
|
|
108
101
|
|
|
109
|
-
<EmojiPicker
|
|
110
|
-
enableEmojiPicker={enableEmojiPicker}
|
|
111
|
-
onClick={handleEmojiClick}
|
|
112
|
-
/>
|
|
102
|
+
<EmojiPicker onClick={handleEmojiClick} />
|
|
113
103
|
|
|
114
104
|
<Attachment
|
|
115
|
-
enableAttachments={enableAttachments}
|
|
116
105
|
onChange={handleAttachment}
|
|
117
106
|
accept={getFullMimeWhitelist().join(',')}
|
|
118
107
|
/>
|
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import LogoMenu from '../../assets/menuButton.svg'
|
|
4
|
-
import { ROLES
|
|
4
|
+
import { ROLES } from '../../constants'
|
|
5
5
|
import { WebchatContext } from '../../webchat/context'
|
|
6
6
|
import { Icon } from '../components/common'
|
|
7
7
|
import { ConditionalAnimation } from '../components/conditional-animation'
|
|
8
8
|
|
|
9
9
|
interface PersistentMenuProps {
|
|
10
|
-
persistentMenu: any
|
|
11
10
|
onClick: () => void
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export const PersistentMenu = ({
|
|
15
|
-
|
|
16
|
-
persistentMenu,
|
|
17
|
-
}: PersistentMenuProps) => {
|
|
18
|
-
const { getThemeProperty } = useContext(WebchatContext)
|
|
13
|
+
export const PersistentMenu = ({ onClick }: PersistentMenuProps) => {
|
|
14
|
+
const { webchatState } = useContext(WebchatContext)
|
|
19
15
|
|
|
20
|
-
const persistentMenuOptions =
|
|
21
|
-
WEBCHAT.CUSTOM_PROPERTIES.persistentMenu,
|
|
22
|
-
persistentMenu
|
|
23
|
-
)
|
|
16
|
+
const persistentMenuOptions = webchatState.theme.userInput?.persistentMenu
|
|
24
17
|
|
|
25
|
-
const CustomMenuButton =
|
|
26
|
-
WEBCHAT.CUSTOM_PROPERTIES.customMenuButton,
|
|
27
|
-
undefined
|
|
28
|
-
)
|
|
18
|
+
const CustomMenuButton = webchatState.theme.userInput?.menuButton?.custom
|
|
29
19
|
|
|
30
20
|
return (
|
|
31
21
|
<>
|