@xapp/chat-widget 1.27.0 → 1.27.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/dist/index.js CHANGED
@@ -44,6 +44,25 @@ var ChatConfigContext = React.createContext(null);
44
44
  function useWidgetEnv() {
45
45
  var ctx = React.useContext(ChatConfigContext);
46
46
  return ctx === null || ctx === void 0 ? void 0 : ctx.env;
47
+ }
48
+ function useConnectionInfo(env) {
49
+ var connection = React.useMemo(function () {
50
+ if (env === null || env === void 0 ? void 0 : env.connection) {
51
+ return env.connection;
52
+ }
53
+ return {
54
+ serverUrl: env === null || env === void 0 ? void 0 : env.serverUrl,
55
+ accountKey: env === null || env === void 0 ? void 0 : env.accountKey,
56
+ type: (env === null || env === void 0 ? void 0 : env.direct) ? "direct" : "websocket"
57
+ };
58
+ }, [env]);
59
+ var nonce = reactRedux.useSelector(function (state) { return state.connection.nonce; });
60
+ return React.useMemo(function () { return ({
61
+ accountKey: connection.accountKey,
62
+ serverUrl: connection.serverUrl,
63
+ type: connection.type,
64
+ nonce: nonce
65
+ }); }, [connection.accountKey, connection.serverUrl, connection.type, nonce]);
47
66
  }
48
67
 
49
68
  /*! *****************************************************************************
@@ -8568,7 +8587,7 @@ var SuggestionsItem = function (props) {
8568
8587
  var canUse = data.type !== "FAQ";
8569
8588
  return (React__default["default"].createElement("div", { className: "xappw-suggestions-item " + (props.current ? "xappw-suggestions-item--current" : ""), onClick: handleClick, onMouseEnter: handleHover },
8570
8589
  React__default["default"].createElement("div", { className: "xappw-suggestions-item__texts" }, formats.map(function (format, index) { return (React__default["default"].createElement("span", { className: "xappw-suggestions-item__text xappw-suggestions-item__text--" + format.type, key: index }, suggestion.substring(format.start, format.end))); })),
8571
- React__default["default"].createElement(IconButton, { className: "xappw-suggestions-item__use " + (!canUse ? "xappw-suggestions-item__use--disabled" : ""), onClick: handleUse, icon: LeftDownArrowIcon })));
8590
+ canUse && React__default["default"].createElement(IconButton, { className: "xappw-suggestions-item__use", onClick: handleUse, icon: LeftDownArrowIcon })));
8572
8591
  };
8573
8592
 
8574
8593
  function getLabel(type) {
@@ -9300,25 +9319,6 @@ function getCtaStyle(style) {
9300
9319
  return union(getBackgroundStyle(style.background), getTextStyle(style.text));
9301
9320
  }
9302
9321
 
9303
- function useConnectionInfo(env) {
9304
- var connection = React.useMemo(function () {
9305
- if (env === null || env === void 0 ? void 0 : env.connection) {
9306
- return env.connection;
9307
- }
9308
- return {
9309
- serverUrl: env === null || env === void 0 ? void 0 : env.serverUrl,
9310
- accountKey: env === null || env === void 0 ? void 0 : env.accountKey,
9311
- type: (env === null || env === void 0 ? void 0 : env.direct) ? "direct" : "websocket"
9312
- };
9313
- }, [env]);
9314
- var nonce = reactRedux.useSelector(function (state) { return state.connection.nonce; });
9315
- return React.useMemo(function () { return ({
9316
- accountKey: connection.accountKey,
9317
- serverUrl: connection.serverUrl,
9318
- type: connection.type,
9319
- nonce: nonce
9320
- }); }, [connection.accountKey, connection.serverUrl, connection.type, nonce]);
9321
- }
9322
9322
  var ChatWidgetWrapper = function (props) {
9323
9323
  var rawConfig = props.config;
9324
9324
  var connection = useConnectionInfo(rawConfig);
@@ -9692,11 +9692,11 @@ function createChatStore(config) {
9692
9692
  }
9693
9693
 
9694
9694
  var ChatWidgetContainer = function (props) {
9695
- var _a, _b;
9695
+ var _a;
9696
9696
  var messageMiddleware = useStandardMiddleware();
9697
- var connection = (_a = props.config) === null || _a === void 0 ? void 0 : _a.connection;
9697
+ var connection = useConnectionInfo(props.config);
9698
9698
  var chatStore = React.useMemo(function () { return createChatStore(connection); }, [connection]);
9699
- if ((_b = props.config) === null || _b === void 0 ? void 0 : _b.disabled) {
9699
+ if ((_a = props.config) === null || _a === void 0 ? void 0 : _a.disabled) {
9700
9700
  return React__default["default"].createElement(React__default["default"].Fragment, null);
9701
9701
  }
9702
9702
  var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware });