@seamly/web-ui 20.0.0-beta.2 → 20.0.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.
@@ -322,6 +322,10 @@
322
322
  !*** ./src/javascripts/domains/redux/context.js ***!
323
323
  \**************************************************/
324
324
 
325
+ /*!**************************************************!*\
326
+ !*** ./src/javascripts/ui/components/faq/faq.js ***!
327
+ \**************************************************/
328
+
325
329
  /*!**************************************************!*\
326
330
  !*** ./src/javascripts/ui/hooks/seamly-hooks.js ***!
327
331
  \**************************************************/
@@ -846,6 +850,10 @@
846
850
  !*** ./src/javascripts/ui/components/conversation/event-divider.js ***!
847
851
  \*********************************************************************/
848
852
 
853
+ /*!**********************************************************************!*\
854
+ !*** ./src/javascripts/ui/components/layout/deprecated-app-frame.js ***!
855
+ \**********************************************************************/
856
+
849
857
  /*!**********************************************************************!*\
850
858
  !*** ./src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js ***!
851
859
  \**********************************************************************/
@@ -12281,12 +12281,12 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
12281
12281
  return [...events, suggestionsEvent];
12282
12282
  });
12283
12283
  const selectEvents = createSelector(selectEventsWithSuggestion, selectConfig, (events, config) => {
12284
- var _config$messages$time, _config$messages;
12284
+ var _config$messages;
12285
12285
 
12286
12286
  const {
12287
12287
  enabled,
12288
12288
  threshold
12289
- } = (_config$messages$time = config === null || config === void 0 ? void 0 : (_config$messages = config.messages) === null || _config$messages === void 0 ? void 0 : _config$messages.timeIndicator) !== null && _config$messages$time !== void 0 ? _config$messages$time : {};
12289
+ } = (config === null || config === void 0 ? void 0 : (_config$messages = config.messages) === null || _config$messages === void 0 ? void 0 : _config$messages.timeIndicator) ?? {};
12290
12290
 
12291
12291
  if (!enabled) {
12292
12292
  return events;
@@ -15366,8 +15366,8 @@ function validate(values, schema = {}) {
15366
15366
  validations = [validations];
15367
15367
  }
15368
15368
 
15369
- for (let i = 0; (_ref = i < ((_validations = validations) === null || _validations === void 0 ? void 0 : _validations.length)) !== null && _ref !== void 0 ? _ref : 0; i++) {
15370
- var _ref, _validations;
15369
+ for (let i = 0; i < ((_validations = validations) === null || _validations === void 0 ? void 0 : _validations.length) ?? 0; i++) {
15370
+ var _validations;
15371
15371
 
15372
15372
  if (!validations[i].fn(values[key], validations[i].compareValue)) {
15373
15373
  errors[key] = validations[i].errorText;
@@ -15680,9 +15680,7 @@ function updateFormControl(state, formId, name, controlState) {
15680
15680
  formId,
15681
15681
  persistData
15682
15682
  }) => {
15683
- var _state$formId2;
15684
-
15685
- const formState = persistData ? (_state$formId2 = state[formId]) !== null && _state$formId2 !== void 0 ? _state$formId2 : forms_reducer_objectSpread(forms_reducer_objectSpread({}, initialFormState), {}, {
15683
+ const formState = persistData ? state[formId] ?? forms_reducer_objectSpread(forms_reducer_objectSpread({}, initialFormState), {}, {
15686
15684
  persistData
15687
15685
  }) : forms_reducer_objectSpread(forms_reducer_objectSpread({}, initialFormState), {}, {
15688
15686
  persistData
@@ -16928,13 +16926,13 @@ const timeFormatOptions = {
16928
16926
  minute: 'numeric'
16929
16927
  };
16930
16928
  const useFormattedDate = date => {
16931
- var _config$context$local, _config$context;
16929
+ var _config$context;
16932
16930
 
16933
16931
  const {
16934
16932
  t
16935
16933
  } = useI18n();
16936
16934
  const config = useConfig();
16937
- const locale = (_config$context$local = config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale) !== null && _config$context$local !== void 0 ? _config$context$local : [];
16935
+ const locale = (config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale) ?? [];
16938
16936
  const eventDate = new Date(date);
16939
16937
  const currentDate = new Date();
16940
16938
  const midnight = new Date(currentDate);
@@ -24363,8 +24361,6 @@ class API {
24363
24361
  config = {},
24364
24362
  context = {}
24365
24363
  }) {
24366
- var _config$sendEnvironme;
24367
-
24368
24364
  this.store = objectStore(`${namespace}.connection${context.locale ? '.' + context.locale : ''}`, config.storageProvider || store);
24369
24365
  this.connectionInfo = {
24370
24366
  apiKey: config.key,
@@ -24372,7 +24368,7 @@ class API {
24372
24368
  secure: config.secure !== false ? config.secure || true : false
24373
24369
  };
24374
24370
  this.config = {
24375
- sendEnvironment: (_config$sendEnvironme = config.sendEnvironment) !== null && _config$sendEnvironme !== void 0 ? _config$sendEnvironme : true,
24371
+ sendEnvironment: config.sendEnvironment ?? true,
24376
24372
  context
24377
24373
  };
24378
24374
  this.connected = false;
@@ -25230,7 +25226,7 @@ const AgentInfo = () => {
25230
25226
  className: css_className('agent-info__body'),
25231
25227
  children: [(0,jsx_runtime_namespaceObject.jsx)("p", {
25232
25228
  className: css_className('agent-info__heading'),
25233
- children: title !== null && title !== void 0 ? title : t('header.title')
25229
+ children: title ?? t('header.title')
25234
25230
  }), (0,jsx_runtime_namespaceObject.jsx)("p", {
25235
25231
  className: css_className('agent-info__text'),
25236
25232
  children: displaySubtitle
@@ -25372,6 +25368,275 @@ const DeprecatedToggleButton = ({
25372
25368
  };
25373
25369
 
25374
25370
  /* harmony default export */ const toggle_button = (DeprecatedToggleButton);
25371
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/components/faq/faq.js
25372
+ const faq_excluded = ["categories"];
25373
+
25374
+ function faq_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
25375
+
25376
+ function faq_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { faq_ownKeys(Object(source), true).forEach(function (key) { faq_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { faq_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
25377
+
25378
+ function faq_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25379
+
25380
+ function faq_objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = faq_objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
25381
+
25382
+ function faq_objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
25383
+
25384
+
25385
+
25386
+
25387
+
25388
+
25389
+
25390
+
25391
+
25392
+
25393
+
25394
+
25395
+
25396
+
25397
+
25398
+
25399
+
25400
+
25401
+
25402
+
25403
+
25404
+ const Faq = () => {
25405
+ const {
25406
+ t
25407
+ } = useI18n();
25408
+ const {
25409
+ sendAction,
25410
+ addMessageBubble
25411
+ } = use_seamly_commands();
25412
+ const sectionId = useGeneratedId();
25413
+ const focusSkiplinkTarget = useSkiplinkTargetFocusing();
25414
+ const {
25415
+ sendPolite
25416
+ } = useLiveRegion();
25417
+ const {
25418
+ hasInterrupt
25419
+ } = useInterrupt();
25420
+ const {
25421
+ hasCountdown,
25422
+ endCountdown
25423
+ } = use_seamly_idle_detach_countdown();
25424
+ const {
25425
+ hasPrompt,
25426
+ continueChat
25427
+ } = use_seamly_resume_conversation_prompt();
25428
+ const lastFaqEventPayload = useSeamlyServiceData('suggestion');
25429
+ const [eventBody] = useTranslatedEventData({
25430
+ payload: lastFaqEventPayload
25431
+ });
25432
+ const faqs = (0,hooks_namespaceObject.useMemo)(() => {
25433
+ const newFaqs = lastFaqEventPayload && !hasInterrupt ? eventBody : [];
25434
+ const itemBaseClass = `faqs__item`;
25435
+ return newFaqs.map(_ref => {
25436
+ let {
25437
+ categories = []
25438
+ } = _ref,
25439
+ faqRest = faq_objectWithoutProperties(_ref, faq_excluded);
25440
+
25441
+ return faq_objectSpread(faq_objectSpread({}, faqRest), {}, {
25442
+ categories,
25443
+ classNames: [itemBaseClass, ...categories.map(cat => `faqs__item--${String(cat).toLowerCase().replace(/[^a-z0-9_\\-]/, '')}`)]
25444
+ });
25445
+ });
25446
+ }, [lastFaqEventPayload, hasInterrupt, eventBody]);
25447
+ const prevFaqs = (0,hooks_namespaceObject.useRef)(null);
25448
+ const prevHasFaqs = (0,hooks_namespaceObject.useRef)(false);
25449
+ const {
25450
+ isInline
25451
+ } = useSeamlyLayoutMode();
25452
+ const hasResponded = useUserHasResponded();
25453
+ const hideForWindow = !isInline && hasResponded;
25454
+ const prevHideForWindow = (0,hooks_namespaceObject.useRef)(hideForWindow);
25455
+ const hasFaqs = !!faqs.length;
25456
+ const showFaqContainer = hasFaqs && !hideForWindow;
25457
+ const previousRenderedFaqList = (0,hooks_namespaceObject.useRef)([]);
25458
+ const renderedFaqList = hasFaqs ? faqs : previousRenderedFaqList.current;
25459
+ previousRenderedFaqList.current = renderedFaqList;
25460
+ const containerRef = (0,hooks_namespaceObject.useRef)(null);
25461
+ (0,hooks_namespaceObject.useEffect)(() => {
25462
+ if (prevFaqs.current !== faqs && !hideForWindow) {
25463
+ if (hasFaqs) {
25464
+ const politeText = prevHasFaqs.current ? t('faq.srUpdatedText') : t('faq.srAvailableText');
25465
+ setTimeout(() => {
25466
+ sendPolite(politeText);
25467
+ }, 30);
25468
+ } else if (prevHasFaqs.current) {
25469
+ sendPolite(t('faq.srUnavailableText'));
25470
+ }
25471
+
25472
+ prevFaqs.current = faqs;
25473
+ }
25474
+
25475
+ if (!prevHideForWindow.current && hideForWindow) {
25476
+ runIfElementContainsOrHasFocus(containerRef.current, focusSkiplinkTarget);
25477
+ sendPolite(t('faq.srUnavailableText'));
25478
+ } else if (!hasFaqs && prevHasFaqs.current) {
25479
+ runIfElementContainsOrHasFocus(containerRef.current, focusSkiplinkTarget);
25480
+ }
25481
+
25482
+ prevHasFaqs.current = hasFaqs;
25483
+ prevHideForWindow.current = hideForWindow;
25484
+ }, [hasFaqs, faqs, hideForWindow, focusSkiplinkTarget, sendPolite, t]);
25485
+
25486
+ const onFaqClickHandler = ({
25487
+ id,
25488
+ question
25489
+ }) => {
25490
+ if (hasCountdown) {
25491
+ endCountdown(true);
25492
+ }
25493
+
25494
+ if (hasPrompt) {
25495
+ continueChat();
25496
+ }
25497
+
25498
+ sendAction({
25499
+ type: actionTypes.custom,
25500
+ originMessage: lastFaqEventPayload.id,
25501
+ body: {
25502
+ type: 'faqclick',
25503
+ body: {
25504
+ faqId: id,
25505
+ faqQuestion: question
25506
+ }
25507
+ }
25508
+ });
25509
+ addMessageBubble(question);
25510
+ focusSkiplinkTarget();
25511
+ };
25512
+
25513
+ const headingText = t('faq.headingText');
25514
+ const ContainerElement = headingText ? 'section' : 'div';
25515
+ return (0,jsx_runtime_namespaceObject.jsx)(in_out_transition, {
25516
+ isActive: showFaqContainer,
25517
+ transitionStartState: transitionStartStates.notRendered,
25518
+ children: (0,jsx_runtime_namespaceObject.jsxs)(ContainerElement, {
25519
+ className: css_className('faqs'),
25520
+ "aria-labelledby": headingText ? sectionId : null,
25521
+ ref: containerRef,
25522
+ children: [headingText && (0,jsx_runtime_namespaceObject.jsx)("h2", {
25523
+ id: sectionId,
25524
+ className: css_className('faqs__heading'),
25525
+ children: headingText
25526
+ }), !!renderedFaqList.length && (0,jsx_runtime_namespaceObject.jsx)("ul", {
25527
+ className: css_className('faqs__list'),
25528
+ children: renderedFaqList.map(faq => (0,jsx_runtime_namespaceObject.jsx)("li", {
25529
+ className: css_className(faq.classNames),
25530
+ children: (0,jsx_runtime_namespaceObject.jsxs)("button", {
25531
+ type: "button",
25532
+ onClick: () => {
25533
+ onFaqClickHandler(faq);
25534
+ },
25535
+ className: css_className('button', 'button--secondary'),
25536
+ children: [(0,jsx_runtime_namespaceObject.jsx)(icon, {
25537
+ name: "chevronRight",
25538
+ size: "8"
25539
+ }), faq.question]
25540
+ })
25541
+ }, faq.id.toString()))
25542
+ })]
25543
+ })
25544
+ });
25545
+ };
25546
+
25547
+ /* harmony default export */ const faq = (Faq);
25548
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/deprecated-app-frame.js
25549
+
25550
+
25551
+
25552
+
25553
+
25554
+
25555
+
25556
+
25557
+
25558
+
25559
+
25560
+ const DeprecatedAppFrame = ({
25561
+ children
25562
+ }) => {
25563
+ const [, setSeamlyContainerElement] = useSeamlyContainerElement();
25564
+ const {
25565
+ isOpen,
25566
+ isVisible,
25567
+ setVisibility
25568
+ } = useVisibility();
25569
+ const {
25570
+ zIndex,
25571
+ showFaq,
25572
+ layoutMode
25573
+ } = useConfig();
25574
+ const {
25575
+ isModal,
25576
+ isInline
25577
+ } = useSeamlyLayoutMode();
25578
+ const appContainerClassNames = useSeamlyAppContainerClassNames();
25579
+ const userResponded = useUserHasResponded();
25580
+ const {
25581
+ locale
25582
+ } = useI18n();
25583
+ const containerElementRef = (0,hooks_namespaceObject.useCallback)(container => {
25584
+ setSeamlyContainerElement(container);
25585
+ }, [setSeamlyContainerElement]);
25586
+ const blockLang = (0,hooks_namespaceObject.useMemo)(() => {
25587
+ if (locale) {
25588
+ const htmlElementLang = document.querySelector('html').getAttribute('lang');
25589
+
25590
+ if (htmlElementLang !== locale) {
25591
+ return locale;
25592
+ }
25593
+ }
25594
+
25595
+ return undefined;
25596
+ }, [locale]);
25597
+ const classNames = ['app', 'app--deprecated', ...appContainerClassNames];
25598
+
25599
+ if (!isOpen && layoutMode === 'window') {
25600
+ classNames.push('app--collapsed');
25601
+ }
25602
+
25603
+ if (userResponded) {
25604
+ classNames.push('app--user-responded');
25605
+ }
25606
+
25607
+ classNames.push(`app--layout-${layoutMode}`);
25608
+
25609
+ const onKeyDownHandler = e => {
25610
+ if (e.code && e.code === 'Escape' || e.keyCode === 27) if (!isInline && isOpen) {
25611
+ setVisibility(visibilityStates.minimized);
25612
+ }
25613
+ };
25614
+
25615
+ const onClickHandler = e => {
25616
+ if (isModal) {
25617
+ e.stopPropagation();
25618
+ }
25619
+ };
25620
+
25621
+ return isVisible && (0,jsx_runtime_namespaceObject.jsxs)("section", {
25622
+ className: css_className(classNames),
25623
+ onKeyDown: onKeyDownHandler,
25624
+ onClick: onClickHandler,
25625
+ lang: blockLang,
25626
+ tabIndex: "-1",
25627
+ ref: containerElementRef,
25628
+ style: {
25629
+ zIndex
25630
+ },
25631
+ "data-nosnippet": true,
25632
+ children: [(0,jsx_runtime_namespaceObject.jsx)("div", {
25633
+ className: css_className('app-wrapper'),
25634
+ children: children
25635
+ }), showFaq && (0,jsx_runtime_namespaceObject.jsx)(faq, {})]
25636
+ });
25637
+ };
25638
+
25639
+ /* harmony default export */ const deprecated_app_frame = (DeprecatedAppFrame);
25375
25640
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/view/deprecated-view.js
25376
25641
 
25377
25642
 
@@ -25385,16 +25650,19 @@ const DeprecatedToggleButton = ({
25385
25650
 
25386
25651
 
25387
25652
 
25653
+
25388
25654
  const DeprecatedView = () => {
25389
25655
  const {
25390
25656
  isVisible
25391
25657
  } = useVisibility();
25392
25658
  const {
25393
- closeChat
25659
+ closeChat,
25660
+ openChat
25394
25661
  } = use_seamly_chat();
25395
- return isVisible && (0,jsx_runtime_namespaceObject.jsxs)(app_frame, {
25396
- isDeprecated: true,
25397
- children: [(0,jsx_runtime_namespaceObject.jsx)(header, {
25662
+ return isVisible && (0,jsx_runtime_namespaceObject.jsxs)(deprecated_app_frame, {
25663
+ children: [(0,jsx_runtime_namespaceObject.jsx)(toggle_button, {
25664
+ onOpenChat: openChat
25665
+ }), (0,jsx_runtime_namespaceObject.jsx)(header, {
25398
25666
  onCloseChat: closeChat,
25399
25667
  children: (0,jsx_runtime_namespaceObject.jsx)(agent_info, {})
25400
25668
  }), (0,jsx_runtime_namespaceObject.jsxs)(chat_frame, {