@botpress/webchat 2.4.0-beta.1 → 2.4.0-beta.3
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/.eslintrc.cjs +1 -1
- package/.storybook/main.ts +25 -0
- package/.storybook/preview.tsx +112 -0
- package/.turbo/turbo-build.log +9 -15
- package/dist/adapters/target.d.ts +1 -0
- package/dist/adapters/webchat.d.ts +1 -1
- package/dist/components/Composer/Composer.d.ts +2 -2
- package/dist/components/Message/Message.d.ts +1 -1
- package/dist/components/MessageList/MessageList.d.ts +3 -2
- package/dist/components/Webchat.d.ts +2 -1
- package/dist/components/renderers/Audio/Audio.d.ts +1 -1
- package/dist/components/renderers/Carousel/Carousel.d.ts +1 -1
- package/dist/components/renderers/File/File.d.ts +1 -1
- package/dist/components/renderers/Image/Image.d.ts +1 -1
- package/dist/components/renderers/Location/Location.d.ts +1 -1
- package/dist/components/renderers/Video/Video.d.ts +1 -1
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/useWebchatClient.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7424 -7386
- package/dist/index.umd.cjs +84 -84
- package/dist/providers/StylesheetProvider.d.ts +4 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/stores/index.d.ts +2 -1
- package/dist/stores/messageHistoryStore.d.ts +20 -0
- package/dist/stores/userStore.d.ts +31 -0
- package/dist/stories/Messages/Audio.stories.d.ts +6 -0
- package/dist/stories/Messages/Bloc.stories.d.ts +6 -0
- package/dist/stories/Messages/Card.stories.d.ts +6 -0
- package/dist/stories/Messages/Carousel.stories.d.ts +6 -0
- package/dist/stories/Messages/Choice.stories.d.ts +6 -0
- package/dist/stories/Messages/Dropdown.stories.d.ts +6 -0
- package/dist/stories/Messages/File.stories.d.ts +6 -0
- package/dist/stories/Messages/Image.stories.d.ts +6 -0
- package/dist/stories/Messages/Location.stories.d.ts +6 -0
- package/dist/stories/Messages/Text.stories.d.ts +6 -0
- package/dist/stories/Messages/Video.stories.d.ts +6 -0
- package/dist/style.css +1 -1
- package/dist/types/block-type.d.ts +1 -1
- package/package.json +19 -3
- package/dist/hooks/useConversationId.d.ts +0 -4
- package/dist/hooks/useUserCredentials.d.ts +0 -5
- package/dist/stores/offlineStore.d.ts +0 -31
package/.eslintrc.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @type {import("eslint").Linter.Config} */
|
|
2
2
|
module.exports = {
|
|
3
3
|
root: true,
|
|
4
|
-
extends: ["@repo/eslint-config/react-internal.js"],
|
|
4
|
+
extends: ["@repo/eslint-config/react-internal.js", "plugin:storybook/recommended"],
|
|
5
5
|
parser: "@typescript-eslint/parser",
|
|
6
6
|
ignorePatterns: ["dist", "node_modules", "storybook-static", ".turbo", "turbo/*"],
|
|
7
7
|
parserOptions: {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { join, dirname } from 'path'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This function is used to resolve the absolute path of a package.
|
|
5
|
+
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
|
|
6
|
+
*/
|
|
7
|
+
function getAbsolutePath(value) {
|
|
8
|
+
return dirname(require.resolve(join(value, 'package.json')))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** @type { import('@storybook/react-vite').StorybookConfig } */
|
|
12
|
+
const config = {
|
|
13
|
+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
|
14
|
+
addons: [
|
|
15
|
+
getAbsolutePath('@storybook/addon-onboarding'),
|
|
16
|
+
getAbsolutePath('@storybook/addon-essentials'),
|
|
17
|
+
getAbsolutePath('@chromatic-com/storybook'),
|
|
18
|
+
getAbsolutePath('@storybook/addon-interactions'),
|
|
19
|
+
],
|
|
20
|
+
framework: {
|
|
21
|
+
name: getAbsolutePath('@storybook/react-vite'),
|
|
22
|
+
options: {},
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
export default config
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// import '../src/index.css' // This has to be imported as early as possible
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import type { Preview } from '@storybook/react'
|
|
4
|
+
import { StylesheetProvider } from '../src/providers'
|
|
5
|
+
import { Container } from '../src/components'
|
|
6
|
+
|
|
7
|
+
const radiusMap = {
|
|
8
|
+
none: 0,
|
|
9
|
+
sm: 0.5,
|
|
10
|
+
md: 1,
|
|
11
|
+
lg: 2,
|
|
12
|
+
xl: 4,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const colorMap = {
|
|
16
|
+
red: '#dc2626',
|
|
17
|
+
orange: '#ea580c',
|
|
18
|
+
amber: '#d97706',
|
|
19
|
+
yellow: '#eab308',
|
|
20
|
+
lime: '#a3e635',
|
|
21
|
+
green: '#22c55e',
|
|
22
|
+
emerald: '#10b981',
|
|
23
|
+
teal: '#14b8a6',
|
|
24
|
+
cyan: '#06b6d4',
|
|
25
|
+
sky: '#0ea5e9',
|
|
26
|
+
blue: '#3b82f6',
|
|
27
|
+
indigo: '#6366f1',
|
|
28
|
+
violet: '#8b5cf6',
|
|
29
|
+
purple: '#9333ea',
|
|
30
|
+
fuchsia: '#d946ef',
|
|
31
|
+
pink: '#ec4899',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @type { import('@storybook/react').Preview } */
|
|
35
|
+
const preview: Preview = {
|
|
36
|
+
initialGlobals: {
|
|
37
|
+
themeMode: 'light',
|
|
38
|
+
fontFamily: 'inter',
|
|
39
|
+
radius: 'md',
|
|
40
|
+
variant: 'solid',
|
|
41
|
+
color: 'blue',
|
|
42
|
+
},
|
|
43
|
+
globalTypes: {
|
|
44
|
+
themeMode: {
|
|
45
|
+
toolbar: {
|
|
46
|
+
dynamicTitle: true,
|
|
47
|
+
title: 'Theme',
|
|
48
|
+
icon: 'mirror',
|
|
49
|
+
items: ['light', 'dark'],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
fontFamily: {
|
|
53
|
+
toolbar: {
|
|
54
|
+
title: 'Font Family',
|
|
55
|
+
dynamicTitle: true,
|
|
56
|
+
icon: 'edit',
|
|
57
|
+
items: ['rubik', 'inter', 'ibm', 'fira'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
radius: {
|
|
61
|
+
toolbar: {
|
|
62
|
+
title: 'Radius',
|
|
63
|
+
dynamicTitle: true,
|
|
64
|
+
icon: 'button',
|
|
65
|
+
items: Object.keys(radiusMap),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
variant: {
|
|
69
|
+
toolbar: {
|
|
70
|
+
title: 'Variant',
|
|
71
|
+
dynamicTitle: true,
|
|
72
|
+
icon: 'expandalt',
|
|
73
|
+
items: ['solid', 'soft'],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
color: {
|
|
77
|
+
toolbar: {
|
|
78
|
+
title: 'Color',
|
|
79
|
+
dynamicTitle: true,
|
|
80
|
+
icon: 'paintbrush',
|
|
81
|
+
items: Object.keys(colorMap),
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
parameters: {
|
|
86
|
+
controls: {
|
|
87
|
+
matchers: {
|
|
88
|
+
color: /(background|color)$/i,
|
|
89
|
+
date: /Date$/i,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
decorators: [
|
|
94
|
+
(Story, context) => {
|
|
95
|
+
const { themeMode, variant, radius, fontFamily, color } = context.globals
|
|
96
|
+
return (
|
|
97
|
+
// TODO: These css hacks should not be required
|
|
98
|
+
<Container
|
|
99
|
+
className="bpReset bpContainer"
|
|
100
|
+
style={{ width: '400px', border: 'none', backgroundColor: 'transparent' }}
|
|
101
|
+
>
|
|
102
|
+
<StylesheetProvider
|
|
103
|
+
{...{ themeMode, variant, fontFamily, radius: radiusMap[radius], color: colorMap[color] }}
|
|
104
|
+
/>
|
|
105
|
+
<Story />
|
|
106
|
+
</Container>
|
|
107
|
+
)
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default preview
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/webchat@2.4.0-beta.
|
|
2
|
+
> @botpress/webchat@2.4.0-beta.3 build /home/runner/work/genisys/genisys/packages/webchat-components
|
|
3
3
|
> vite build
|
|
4
4
|
|
|
5
5
|
[36mvite v5.4.8 [32mbuilding for production...[36m[39m
|
|
6
6
|
transforming...
|
|
7
|
-
[1m[33m[plugin:vite:resolve][39m[22m [33m[plugin vite:resolve] Module "crypto" has been externalized for browser compatibility, imported by "/home/runner/work/genisys/genisys/node_modules/.pnpm/@bpinternal+webchat-http-client@0.2.
|
|
8
|
-
[
|
|
9
|
-
1 | @import './resets.css';
|
|
10
|
-
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
11
|
-
2 | @import './theme.css';
|
|
12
|
-
| ^^^^^^
|
|
13
|
-
3 | @import '../components/index.css'[39m
|
|
14
|
-
[32m✓[39m 3103 modules transformed.
|
|
7
|
+
[1m[33m[plugin:vite:resolve][39m[22m [33m[plugin vite:resolve] Module "crypto" has been externalized for browser compatibility, imported by "/home/runner/work/genisys/genisys/node_modules/.pnpm/@bpinternal+webchat-http-client@0.2.3/node_modules/@bpinternal/webchat-http-client/dist/index.mjs". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.[39m
|
|
8
|
+
[32m✓[39m 3105 modules transformed.
|
|
15
9
|
rendering chunks...
|
|
16
10
|
|
|
17
11
|
[vite:dts] Start generate declaration files...
|
|
18
12
|
computing gzip size...
|
|
19
|
-
[2mdist/[22m[35mstyle.css [39m[1m[2m
|
|
20
|
-
[2mdist/[22m[36mindex.js [39m[1m[33m1,
|
|
21
|
-
[vite:dts] Declaration files built in
|
|
13
|
+
[2mdist/[22m[35mstyle.css [39m[1m[2m 32.56 kB[22m[1m[22m[2m │ gzip: 6.24 kB[22m
|
|
14
|
+
[2mdist/[22m[36mindex.js [39m[1m[33m1,024.28 kB[39m[22m[2m │ gzip: 267.68 kB[22m
|
|
15
|
+
[vite:dts] Declaration files built in 10856ms.
|
|
22
16
|
|
|
23
|
-
[2mdist/[22m[35mstyle.css [39m[1m[2m
|
|
24
|
-
[2mdist/[22m[36mindex.umd.cjs [39m[1m[
|
|
25
|
-
[32m✓ built in
|
|
17
|
+
[2mdist/[22m[35mstyle.css [39m[1m[2m 32.56 kB[22m[1m[22m[2m │ gzip: 6.24 kB[22m
|
|
18
|
+
[2mdist/[22m[36mindex.umd.cjs [39m[1m[33m702.08 kB[39m[22m[2m │ gzip: 223.03 kB[22m
|
|
19
|
+
[32m✓ built in 19.52s[39m
|
|
@@ -7,8 +7,8 @@ type Props = ComponentProps<'div'> & {
|
|
|
7
7
|
isReadOnly?: boolean;
|
|
8
8
|
allowFileUpload?: boolean;
|
|
9
9
|
connected?: boolean;
|
|
10
|
-
sendMessage
|
|
11
|
-
uploadFile
|
|
10
|
+
sendMessage?: (payload: Message) => void;
|
|
11
|
+
uploadFile?: (file: File) => Promise<{
|
|
12
12
|
fileUrl: string;
|
|
13
13
|
name: string;
|
|
14
14
|
type: FileType;
|
|
@@ -4,7 +4,7 @@ import type { Message as WebchatMessage } from '../../adapters/webchat';
|
|
|
4
4
|
export declare const Message: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<{
|
|
5
5
|
children?: ReactNode;
|
|
6
6
|
renderers?: Partial<Renderers>;
|
|
7
|
-
sendMessage
|
|
7
|
+
sendMessage?: (payload: WebchatMessage) => void;
|
|
8
8
|
isReadOnly?: boolean;
|
|
9
9
|
} & import("../..").MessageObject<import("../../adapters/target").Message> & {
|
|
10
10
|
direction: import("../..").MessageDirection;
|
|
@@ -9,7 +9,8 @@ type MessageListProps = {
|
|
|
9
9
|
botAvatar?: string;
|
|
10
10
|
botDescription?: string;
|
|
11
11
|
botName?: string;
|
|
12
|
-
sendMessage
|
|
12
|
+
sendMessage?: (payload: WebchatMessage) => void;
|
|
13
|
+
showMarquee?: boolean;
|
|
13
14
|
};
|
|
14
|
-
export declare const MessageList: import("react").MemoExoticComponent<({ className, messages, isTyping, headerMessage, renderers, botAvatar, botDescription, botName, sendMessage, ...props }: ComponentProps<"ul"> & MessageListProps) => import("react/jsx-runtime").JSX.Element>;
|
|
15
|
+
export declare const MessageList: import("react").MemoExoticComponent<({ className, messages, isTyping, headerMessage, renderers, botAvatar, botDescription, botName, sendMessage, showMarquee, ...props }: ComponentProps<"ul"> & MessageListProps) => import("react/jsx-runtime").JSX.Element>;
|
|
15
16
|
export {};
|
|
@@ -11,6 +11,7 @@ export type Props = {
|
|
|
11
11
|
isTyping?: boolean;
|
|
12
12
|
lastTypingHeartbeat?: Date | null;
|
|
13
13
|
allowFileUpload?: boolean;
|
|
14
|
+
clientId?: string;
|
|
14
15
|
closeWindow?: () => void;
|
|
15
16
|
restartConversation?: () => void;
|
|
16
17
|
user: {
|
|
@@ -25,4 +26,4 @@ export type Props = {
|
|
|
25
26
|
type: FileType;
|
|
26
27
|
}>;
|
|
27
28
|
};
|
|
28
|
-
export declare const Webchat: ({ connected, configuration, closeWindow, isTyping, messages, user, sendMessage, uploadFile, isLoading, renderers, isReadOnly, disableComposer, restartConversation, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare const Webchat: ({ connected, configuration, closeWindow, isTyping, messages, user, sendMessage, uploadFile, isLoading, renderers, isReadOnly, disableComposer, restartConversation, allowFileUpload, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const Audio: import("react").ForwardRefExoticComponent<import("../../../adapters/target").AudioMessage & Pick<import("../../..").RichMessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
|
|
2
2
|
messageId: string;
|
|
3
|
-
sendMessage
|
|
3
|
+
sendMessage?: (payload: import("../../../adapters/webchat").Message) => void;
|
|
4
4
|
metadata?: Record<string, any>;
|
|
5
5
|
isReadOnly?: boolean;
|
|
6
6
|
} & import("react").RefAttributes<HTMLAudioElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const Carousel: import("react").ForwardRefExoticComponent<import("../../../adapters/target").CarouselMessage & Pick<import("../../..").RichMessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
|
|
2
2
|
messageId: string;
|
|
3
|
-
sendMessage
|
|
3
|
+
sendMessage?: (payload: import("../../../adapters/webchat").Message) => void;
|
|
4
4
|
metadata?: Record<string, any>;
|
|
5
5
|
isReadOnly?: boolean;
|
|
6
6
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const File: import("react").ForwardRefExoticComponent<import("../../../adapters/target").FileMessage & Pick<import("../../..").RichMessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
|
|
2
2
|
messageId: string;
|
|
3
|
-
sendMessage
|
|
3
|
+
sendMessage?: (payload: import("../../../adapters/webchat").Message) => void;
|
|
4
4
|
metadata?: Record<string, any>;
|
|
5
5
|
isReadOnly?: boolean;
|
|
6
6
|
} & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const Image: import("react").ForwardRefExoticComponent<import("../../../adapters/target").ImageMessage & Pick<import("../../..").RichMessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
|
|
2
2
|
messageId: string;
|
|
3
|
-
sendMessage
|
|
3
|
+
sendMessage?: (payload: import("../../../adapters/webchat").Message) => void;
|
|
4
4
|
metadata?: Record<string, any>;
|
|
5
5
|
isReadOnly?: boolean;
|
|
6
6
|
} & import("react").RefAttributes<HTMLImageElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const Location: import("react").ForwardRefExoticComponent<import("../../../adapters/target").LocationMessage & Pick<import("../../..").RichMessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
|
|
2
2
|
messageId: string;
|
|
3
|
-
sendMessage
|
|
3
|
+
sendMessage?: (payload: import("../../../adapters/webchat").Message) => void;
|
|
4
4
|
metadata?: Record<string, any>;
|
|
5
5
|
isReadOnly?: boolean;
|
|
6
6
|
} & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const Video: import("react").ForwardRefExoticComponent<import("../../../adapters/target").VideoMessage & Pick<import("../../..").RichMessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
|
|
2
2
|
messageId: string;
|
|
3
|
-
sendMessage
|
|
3
|
+
sendMessage?: (payload: import("../../../adapters/webchat").Message) => void;
|
|
4
4
|
metadata?: Record<string, any>;
|
|
5
5
|
isReadOnly?: boolean;
|
|
6
6
|
} & import("react").RefAttributes<HTMLVideoElement>>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ type Props = {
|
|
|
10
10
|
clientId: string;
|
|
11
11
|
apiUrl?: string;
|
|
12
12
|
sseTimeout?: number;
|
|
13
|
+
storageKey?: string;
|
|
13
14
|
};
|
|
14
15
|
type ScopedClient = {
|
|
15
16
|
sendMessage: (payload: WebchatMessage) => Promise<void>;
|
|
@@ -43,5 +44,5 @@ export type UseWebchatClientReturn = {
|
|
|
43
44
|
user: undefined;
|
|
44
45
|
isTyping: undefined;
|
|
45
46
|
};
|
|
46
|
-
export declare function useWebchatClient({ apiUrl, clientId, ...props }: Props): UseWebchatClientReturn;
|
|
47
|
+
export declare function useWebchatClient({ apiUrl, clientId, storageKey, ...props }: Props): UseWebchatClientReturn;
|
|
47
48
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ export { webchatClasses } from './styles';
|
|
|
12
12
|
export { type WebchatClient, type WebchatEvents, getClient, type Client } from './client';
|
|
13
13
|
export { useClient, useWebchatClient, type UseWebchatClientReturn } from './hooks';
|
|
14
14
|
export { generateThemeStylesheet } from './utils';
|
|
15
|
-
export { useWebchatStore,
|
|
15
|
+
export { useWebchatStore, getUseUserStore } from './stores';
|