Skip to content

Commit 715e83e

Browse files
committed
fix: made some changes to fix custom elements not being sized correctly
BREAKING CHANGE: Classnames and styles are now injected by default when using WebChatCustomElement.
1 parent 16008a6 commit 715e83e

File tree

6 files changed

+10
-266
lines changed

6 files changed

+10
-266
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ The primary utility provided by this library is the `WebChatContainer` functiona
1414
- [Using WebChatContainer](#using-webchatcontainer)
1515
- [WebChatCustomElement](#webchatcustomelement)
1616
- [API](#api)
17-
- [withWebChat](#withWebChat)
1817
- [Additional resources](#additional-resources)
1918
- [License](#license)
2019

@@ -200,10 +199,6 @@ function App() {
200199
}
201200
```
202201

203-
## withWebChat
204-
205-
The [withWebChat](WITH_WEB_CHAT.MD) function is an older function that is used for loading web chat. It is now deprecated in favor of using the `WebChatContainer` component instead.
206-
207202
## Additional resources
208203
- [IBM watsonx Assistant](https://www.ibm.com/cloud/watson-assistant)
209204
- [IBM watsonx Assistant web chat feature documentation](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-deploy-web-chat)

WITH_WEB_CHAT.MD

Lines changed: 0 additions & 243 deletions
This file was deleted.

package-lock.json

Lines changed: 6 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"test": "jest"
2323
},
2424
"dependencies": {
25-
"semver-compare": "^1.0.0"
25+
"compare-versions": "^6.1.1"
2626
},
2727
"peerDependencies": {
2828
"react": ">= 16.8.0",
@@ -44,7 +44,6 @@
4444
"@types/proper-url-join": "^2.1.1",
4545
"@types/react": "^16.14.17",
4646
"@types/react-dom": "^16.9.14",
47-
"@types/semver-compare": "^1.0.3",
4847
"@typescript-eslint/eslint-plugin": "^7.16.0",
4948
"@typescript-eslint/parser": "^7.16.0",
5049
"babel-core": "^6.26.3",

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ export default {
2929
},
3030
],
3131
plugins: [typescript()],
32-
external: ['react', 'react-dom'],
32+
external: ['react', 'react-dom', 'compare-versions'],
3333
};

src/WebChatContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
*
1313
*/
1414

15+
import { compareVersions } from 'compare-versions';
1516
import React, { ReactNode, useEffect, useState, MutableRefObject, useRef, Dispatch, SetStateAction } from 'react';
16-
import semverCompare from 'semver-compare';
1717
import { UserDefinedResponsePortalsContainer } from './UserDefinedResponsePortalsContainer';
1818
import { WebChatConfig } from './types/WebChatConfig';
1919
import { WebChatInstance } from './types/WebChatInstance';
@@ -254,7 +254,7 @@ function addUserDefinedResponseHandler(
254254

255255
// In web chat 8.2.0, the "customResponse" event was renamed to "userDefinedResponse".
256256
const webChatVersion = webChatInstance.getWidgetVersion();
257-
const eventName = semverCompare(webChatVersion, '8.2.0') >= 0 ? 'userDefinedResponse' : 'customResponse';
257+
const eventName = compareVersions(webChatVersion, '8.2.0') >= 0 ? 'userDefinedResponse' : 'customResponse';
258258

259259
webChatInstance.on({ type: eventName, handler: userDefinedResponseHandler });
260260
webChatInstance.on({ type: 'restartConversation', handler: restartHandler });

0 commit comments

Comments
 (0)