@seamly/web-ui 20.8.0-beta.2 → 20.8.0-beta.4
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/build/dist/lib/index.debug.js +1 -1
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.js +12 -0
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +12 -0
- package/build/dist/lib/standalone.min.js +1 -1
- package/package.json +1 -1
- package/src/javascripts/ui/hooks/use-seamly-chat.js +14 -1
|
@@ -2037,7 +2037,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
2037
2037
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2038
2038
|
|
|
2039
2039
|
"use strict";
|
|
2040
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! domains/i18n/hooks */ \"./src/javascripts/domains/i18n/hooks.ts\");\n/* harmony import */ var domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var domains_store_slice__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! domains/store/slice */ \"./src/javascripts/domains/store/slice.ts\");\n/* harmony import */ var domains_visibility_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! domains/visibility/constants */ \"./src/javascripts/domains/visibility/constants.js\");\n/* harmony import */ var domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! domains/visibility/hooks */ \"./src/javascripts/domains/visibility/hooks.ts\");\n/* harmony import */ var domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! preact/hooks */ \"preact/hooks\");\n/* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(preact_hooks__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-redux */ \"./node_modules/react-redux/es/index.js\");\n/* harmony import */ var _domains_visibility_selectors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../domains/visibility/selectors */ \"./src/javascripts/domains/visibility/selectors.ts\");\n/* harmony import */ var _live_region_hooks__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./live-region-hooks */ \"./src/javascripts/ui/hooks/live-region-hooks.js\");\n/* harmony import */ var _seamly_api_hooks__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./seamly-api-hooks */ \"./src/javascripts/ui/hooks/seamly-api-hooks.js\");\n/* harmony import */ var _seamly_state_hooks__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./seamly-state-hooks */ \"./src/javascripts/ui/hooks/seamly-state-hooks.js\");\n/* harmony import */ var _use_seamly_commands__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./use-seamly-commands */ \"./src/javascripts/ui/hooks/use-seamly-commands.js\");\n\n\n\n\n\n\n\n\n\n\n\n\nconst useSeamlyChat = () => {\n const {\n t\n } = (0,domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_0__.useI18n)();\n const {\n isInline,\n isWindow\n } = (0,_seamly_state_hooks__WEBPACK_IMPORTED_MODULE_9__.useSeamlyLayoutMode)();\n const {\n isOpen,\n isVisible,\n setVisibility\n } = (0,domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3__.useVisibility)();\n const showInlineView = (0,react_redux__WEBPACK_IMPORTED_MODULE_5__.useSelector)(_domains_visibility_selectors__WEBPACK_IMPORTED_MODULE_6__.selectShowInlineView);\n const dispatch = (0,react_redux__WEBPACK_IMPORTED_MODULE_5__.useDispatch)();\n const spinnerTimeout = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useRef)(null);\n const {\n start,\n connect,\n apiConfigReady,\n apiConnected\n } = (0,_use_seamly_commands__WEBPACK_IMPORTED_MODULE_10__[\"default\"])();\n const hasConversation = (0,_seamly_api_hooks__WEBPACK_IMPORTED_MODULE_8__.useSeamlyHasConversation)();\n const prevIsOpen = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useRef)(null);\n const prevIsVisible = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useRef)(null);\n const startCalled = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useRef)(false);\n const {\n sendAssertive\n } = (0,_live_region_hooks__WEBPACK_IMPORTED_MODULE_7__.useLiveRegion)();\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n if (isVisible) {\n // Wait for the live containers to stabilise in the DOM before injecting\n // the message or some screen readers will swallow it.\n setTimeout(() => {\n sendAssertive(t('window.srTexts.onLoad'));\n }, 500);\n }\n }, [isVisible, sendAssertive, t]);\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n if (isVisible !== prevIsVisible.current) {\n prevIsOpen.current = isOpen;\n prevIsVisible.current = isVisible;\n return;\n }\n\n if (prevIsOpen.current !== null) {\n if (isOpen) {\n sendAssertive(t('window.srTexts.onOpen'));\n } else {\n sendAssertive(t('window.srTexts.onClose'));\n }\n }\n\n prevIsOpen.current = isOpen;\n prevIsVisible.current = isVisible;\n }, [isOpen, isVisible, sendAssertive, t]);\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n // This delays the start of the loading inidicator we set when we initialise\n // the application. This is done to only avoid BSOD on initial load if DCX is slow.\n spinnerTimeout.current = setTimeout(() => {\n dispatch((0,domains_store_slice__WEBPACK_IMPORTED_MODULE_1__.setIsLoading)(true));\n }, 500);\n return () => {\n clearTimeout(spinnerTimeout.current);\n };\n }, [dispatch]);\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n // This is needed to reset the ref to allow connect and start to happen again.\n // Mostly due to Interrupt situations and a reset being called.\n if (!apiConfigReady || !apiConnected) {\n startCalled.current = false;\n }\n }, [apiConfigReady, apiConnected]);\n const connectAndStart = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useCallback)(async () => {\n // We don't connect if we are already connected to the api to avoid multiple in-flight connection processes.\n if (!apiConnected) {\n await connect();\n } // We only start a conversation when the chat interface is either 'open' or if using the inline view if it's 'open' or 'minimized'.\n\n\n if (isOpen || isVisible && isInline) {\n start();\n startCalled.current = true;\n }\n }, [apiConnected, connect, isInline, isOpen, isVisible, start]);\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n // We dont't connect or start when the apiConfig is not ready yet.\n // We also keep track of whether start has been called to avoid multiple in-flight connection processes.\n // We check if the window view is not open and no conversation is started yet.\n // Lastly we check if the inline view is not scrolled in to view.\n if (!apiConfigReady || startCalled.current || isWindow && !isOpen && !hasConversation() || isInline && !showInlineView) {\n return;\n }\n\n if (hasConversation() && isOpen) {\n // We deactivate the extra startup loading spinner when a conversation is available\n // We also stop setting the loading indicator in the first place to avoid a flash.\n clearTimeout(spinnerTimeout.current);\n dispatch((0,domains_store_slice__WEBPACK_IMPORTED_MODULE_1__.setIsLoading)(false));\n }\n\n connectAndStart();\n }, [apiConfigReady, connectAndStart, dispatch, hasConversation, isInline, isOpen, isWindow, showInlineView]);\n\n const openChat = () => {\n setVisibility(domains_visibility_constants__WEBPACK_IMPORTED_MODULE_2__.visibilityStates.open);\n };\n\n const closeChat = () => {\n setVisibility(domains_visibility_constants__WEBPACK_IMPORTED_MODULE_2__.visibilityStates.minimized);\n };\n\n return {\n openChat,\n closeChat\n };\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useSeamlyChat);\n\n//# sourceURL=webpack://@seamly/web-ui/./src/javascripts/ui/hooks/use-seamly-chat.js?");
|
|
2040
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! domains/i18n/hooks */ \"./src/javascripts/domains/i18n/hooks.ts\");\n/* harmony import */ var domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var domains_store_slice__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! domains/store/slice */ \"./src/javascripts/domains/store/slice.ts\");\n/* harmony import */ var domains_visibility_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! domains/visibility/constants */ \"./src/javascripts/domains/visibility/constants.js\");\n/* harmony import */ var domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! domains/visibility/hooks */ \"./src/javascripts/domains/visibility/hooks.ts\");\n/* harmony import */ var domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! preact/hooks */ \"preact/hooks\");\n/* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(preact_hooks__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-redux */ \"./node_modules/react-redux/es/index.js\");\n/* harmony import */ var _domains_visibility_selectors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../domains/visibility/selectors */ \"./src/javascripts/domains/visibility/selectors.ts\");\n/* harmony import */ var _live_region_hooks__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./live-region-hooks */ \"./src/javascripts/ui/hooks/live-region-hooks.js\");\n/* harmony import */ var _seamly_api_hooks__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./seamly-api-hooks */ \"./src/javascripts/ui/hooks/seamly-api-hooks.js\");\n/* harmony import */ var _seamly_state_hooks__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./seamly-state-hooks */ \"./src/javascripts/ui/hooks/seamly-state-hooks.js\");\n/* harmony import */ var _use_seamly_commands__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./use-seamly-commands */ \"./src/javascripts/ui/hooks/use-seamly-commands.js\");\n\n\n\n\n\n\n\n\n\n\n\n\nconst useSeamlyChat = () => {\n const events = (0,_seamly_state_hooks__WEBPACK_IMPORTED_MODULE_9__.useEvents)();\n const {\n t\n } = (0,domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_0__.useI18n)();\n const {\n isInline,\n isWindow\n } = (0,_seamly_state_hooks__WEBPACK_IMPORTED_MODULE_9__.useSeamlyLayoutMode)();\n const {\n isOpen,\n isVisible,\n setVisibility\n } = (0,domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3__.useVisibility)();\n const showInlineView = (0,react_redux__WEBPACK_IMPORTED_MODULE_5__.useSelector)(_domains_visibility_selectors__WEBPACK_IMPORTED_MODULE_6__.selectShowInlineView);\n const dispatch = (0,react_redux__WEBPACK_IMPORTED_MODULE_5__.useDispatch)();\n const spinnerTimeout = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useRef)(null);\n const {\n start,\n connect,\n apiConfigReady,\n apiConnected\n } = (0,_use_seamly_commands__WEBPACK_IMPORTED_MODULE_10__[\"default\"])();\n const hasConversation = (0,_seamly_api_hooks__WEBPACK_IMPORTED_MODULE_8__.useSeamlyHasConversation)();\n const prevIsOpen = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useRef)(null);\n const prevIsVisible = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useRef)(null);\n const startCalled = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useRef)(false);\n const {\n sendAssertive\n } = (0,_live_region_hooks__WEBPACK_IMPORTED_MODULE_7__.useLiveRegion)();\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n if (isVisible) {\n // Wait for the live containers to stabilise in the DOM before injecting\n // the message or some screen readers will swallow it.\n setTimeout(() => {\n sendAssertive(t('window.srTexts.onLoad'));\n }, 500);\n }\n }, [isVisible, sendAssertive, t]);\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n if (isVisible !== prevIsVisible.current) {\n prevIsOpen.current = isOpen;\n prevIsVisible.current = isVisible;\n return;\n }\n\n if (prevIsOpen.current !== null) {\n if (isOpen) {\n sendAssertive(t('window.srTexts.onOpen'));\n } else {\n sendAssertive(t('window.srTexts.onClose'));\n }\n }\n\n prevIsOpen.current = isOpen;\n prevIsVisible.current = isVisible;\n }, [isOpen, isVisible, sendAssertive, t]);\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n // This delays the start of the loading inidicator we set when we initialise\n // the application. This is done to only avoid BSOD on initial load if DCX is slow.\n spinnerTimeout.current = setTimeout(() => {\n dispatch((0,domains_store_slice__WEBPACK_IMPORTED_MODULE_1__.setIsLoading)(true));\n }, 500);\n return () => {\n clearTimeout(spinnerTimeout.current);\n };\n }, [dispatch]);\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n if (events.length) {\n spinnerTimeout.current = setTimeout(() => {\n dispatch((0,domains_store_slice__WEBPACK_IMPORTED_MODULE_1__.setIsLoading)(false));\n }, 5000);\n }\n\n return () => {\n clearTimeout(spinnerTimeout.current);\n };\n }, [events, dispatch]);\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n // This is needed to reset the ref to allow connect and start to happen again.\n // Mostly due to Interrupt situations and a reset being called.\n if (!apiConfigReady || !apiConnected) {\n startCalled.current = false;\n }\n }, [apiConfigReady, apiConnected]);\n const connectAndStart = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useCallback)(async () => {\n // We don't connect if we are already connected to the api to avoid multiple in-flight connection processes.\n if (!apiConnected) {\n await connect();\n } // We only start a conversation when the chat interface is either 'open' or if using the inline view if it's 'open' or 'minimized'.\n\n\n if (isOpen || isVisible && isInline) {\n start();\n startCalled.current = true;\n }\n }, [apiConnected, connect, isInline, isOpen, isVisible, start]);\n (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n // We dont't connect or start when the apiConfig is not ready yet.\n // We also keep track of whether start has been called to avoid multiple in-flight connection processes.\n // We check if the window view is not open and no conversation is started yet.\n // Lastly we check if the inline view is not scrolled in to view.\n if (!apiConfigReady || startCalled.current || isWindow && !isOpen && !hasConversation() || isInline && !showInlineView) {\n return;\n }\n\n if (hasConversation() && isOpen) {\n // We deactivate the extra startup loading spinner when a conversation is available\n // We also stop setting the loading indicator in the first place to avoid a flash.\n clearTimeout(spinnerTimeout.current);\n dispatch((0,domains_store_slice__WEBPACK_IMPORTED_MODULE_1__.setIsLoading)(false));\n }\n\n connectAndStart();\n }, [apiConfigReady, connectAndStart, dispatch, hasConversation, isInline, isOpen, isWindow, showInlineView]);\n\n const openChat = () => {\n setVisibility(domains_visibility_constants__WEBPACK_IMPORTED_MODULE_2__.visibilityStates.open);\n };\n\n const closeChat = () => {\n setVisibility(domains_visibility_constants__WEBPACK_IMPORTED_MODULE_2__.visibilityStates.minimized);\n };\n\n return {\n openChat,\n closeChat\n };\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useSeamlyChat);\n\n//# sourceURL=webpack://@seamly/web-ui/./src/javascripts/ui/hooks/use-seamly-chat.js?");
|
|
2041
2041
|
|
|
2042
2042
|
/***/ }),
|
|
2043
2043
|
|