@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.
@@ -34333,6 +34333,282 @@ const DeprecatedToggleButton = ({
34333
34333
  };
34334
34334
 
34335
34335
  /* harmony default export */ var toggle_button = (DeprecatedToggleButton);
34336
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/components/faq/faq.js
34337
+
34338
+
34339
+
34340
+
34341
+
34342
+
34343
+
34344
+
34345
+
34346
+
34347
+ const faq_excluded = ["categories"];
34348
+
34349
+ function faq_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
34350
+
34351
+ function faq_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; for_each_default()(_context = faq_ownKeys(Object(source), true)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context2; for_each_default()(_context2 = faq_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
34352
+
34353
+
34354
+
34355
+
34356
+
34357
+
34358
+
34359
+
34360
+
34361
+
34362
+
34363
+
34364
+
34365
+
34366
+
34367
+
34368
+
34369
+
34370
+
34371
+
34372
+
34373
+
34374
+
34375
+ const Faq = () => {
34376
+ const {
34377
+ t
34378
+ } = useI18n();
34379
+ const {
34380
+ sendAction,
34381
+ addMessageBubble
34382
+ } = use_seamly_commands();
34383
+ const sectionId = useGeneratedId();
34384
+ const focusSkiplinkTarget = useSkiplinkTargetFocusing();
34385
+ const {
34386
+ sendPolite
34387
+ } = useLiveRegion();
34388
+ const {
34389
+ hasInterrupt
34390
+ } = useInterrupt();
34391
+ const {
34392
+ hasCountdown,
34393
+ endCountdown
34394
+ } = use_seamly_idle_detach_countdown();
34395
+ const {
34396
+ hasPrompt,
34397
+ continueChat
34398
+ } = use_seamly_resume_conversation_prompt();
34399
+ const lastFaqEventPayload = useSeamlyServiceData('suggestion');
34400
+ const [eventBody] = useTranslatedEventData({
34401
+ payload: lastFaqEventPayload
34402
+ });
34403
+ const faqs = hooks_module_A(() => {
34404
+ const newFaqs = lastFaqEventPayload && !hasInterrupt ? eventBody : [];
34405
+ const itemBaseClass = `faqs__item`;
34406
+ return map_default()(newFaqs).call(newFaqs, _ref => {
34407
+ let {
34408
+ categories = []
34409
+ } = _ref,
34410
+ faqRest = _objectWithoutProperties(_ref, faq_excluded);
34411
+
34412
+ return faq_objectSpread(faq_objectSpread({}, faqRest), {}, {
34413
+ categories,
34414
+ classNames: [itemBaseClass, ...map_default()(categories).call(categories, cat => `faqs__item--${String(cat).toLowerCase().replace(/[^a-z0-9_\\-]/, '')}`)]
34415
+ });
34416
+ });
34417
+ }, [lastFaqEventPayload, hasInterrupt, eventBody]);
34418
+ const prevFaqs = hooks_module_s(null);
34419
+ const prevHasFaqs = hooks_module_s(false);
34420
+ const {
34421
+ isInline
34422
+ } = useSeamlyLayoutMode();
34423
+ const hasResponded = useUserHasResponded();
34424
+ const hideForWindow = !isInline && hasResponded;
34425
+ const prevHideForWindow = hooks_module_s(hideForWindow);
34426
+ const hasFaqs = !!faqs.length;
34427
+ const showFaqContainer = hasFaqs && !hideForWindow;
34428
+ const previousRenderedFaqList = hooks_module_s([]);
34429
+ const renderedFaqList = hasFaqs ? faqs : previousRenderedFaqList.current;
34430
+ previousRenderedFaqList.current = renderedFaqList;
34431
+ const containerRef = hooks_module_s(null);
34432
+ hooks_module_y(() => {
34433
+ if (prevFaqs.current !== faqs && !hideForWindow) {
34434
+ if (hasFaqs) {
34435
+ const politeText = prevHasFaqs.current ? t('faq.srUpdatedText') : t('faq.srAvailableText');
34436
+
34437
+ set_timeout_default()(() => {
34438
+ sendPolite(politeText);
34439
+ }, 30);
34440
+ } else if (prevHasFaqs.current) {
34441
+ sendPolite(t('faq.srUnavailableText'));
34442
+ }
34443
+
34444
+ prevFaqs.current = faqs;
34445
+ }
34446
+
34447
+ if (!prevHideForWindow.current && hideForWindow) {
34448
+ runIfElementContainsOrHasFocus(containerRef.current, focusSkiplinkTarget);
34449
+ sendPolite(t('faq.srUnavailableText'));
34450
+ } else if (!hasFaqs && prevHasFaqs.current) {
34451
+ runIfElementContainsOrHasFocus(containerRef.current, focusSkiplinkTarget);
34452
+ }
34453
+
34454
+ prevHasFaqs.current = hasFaqs;
34455
+ prevHideForWindow.current = hideForWindow;
34456
+ }, [hasFaqs, faqs, hideForWindow, focusSkiplinkTarget, sendPolite, t]);
34457
+
34458
+ const onFaqClickHandler = ({
34459
+ id,
34460
+ question
34461
+ }) => {
34462
+ if (hasCountdown) {
34463
+ endCountdown(true);
34464
+ }
34465
+
34466
+ if (hasPrompt) {
34467
+ continueChat();
34468
+ }
34469
+
34470
+ sendAction({
34471
+ type: actionTypes.custom,
34472
+ originMessage: lastFaqEventPayload.id,
34473
+ body: {
34474
+ type: 'faqclick',
34475
+ body: {
34476
+ faqId: id,
34477
+ faqQuestion: question
34478
+ }
34479
+ }
34480
+ });
34481
+ addMessageBubble(question);
34482
+ focusSkiplinkTarget();
34483
+ };
34484
+
34485
+ const headingText = t('faq.headingText');
34486
+ const ContainerElement = headingText ? 'section' : 'div';
34487
+ return jsxRuntime_module_e(in_out_transition, {
34488
+ isActive: showFaqContainer,
34489
+ transitionStartState: transitionStartStates.notRendered,
34490
+ children: jsxRuntime_module_e(ContainerElement, {
34491
+ className: css_className('faqs'),
34492
+ "aria-labelledby": headingText ? sectionId : null,
34493
+ ref: containerRef,
34494
+ children: [headingText && jsxRuntime_module_e("h2", {
34495
+ id: sectionId,
34496
+ className: css_className('faqs__heading'),
34497
+ children: headingText
34498
+ }), !!renderedFaqList.length && jsxRuntime_module_e("ul", {
34499
+ className: css_className('faqs__list'),
34500
+ children: map_default()(renderedFaqList).call(renderedFaqList, faq => jsxRuntime_module_e("li", {
34501
+ className: css_className(faq.classNames),
34502
+ children: jsxRuntime_module_e("button", {
34503
+ type: "button",
34504
+ onClick: () => {
34505
+ onFaqClickHandler(faq);
34506
+ },
34507
+ className: css_className('button', 'button--secondary'),
34508
+ children: [jsxRuntime_module_e(icon, {
34509
+ name: "chevronRight",
34510
+ size: "8"
34511
+ }), faq.question]
34512
+ })
34513
+ }, faq.id.toString()))
34514
+ })]
34515
+ })
34516
+ });
34517
+ };
34518
+
34519
+ /* harmony default export */ var faq = (Faq);
34520
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/deprecated-app-frame.js
34521
+
34522
+
34523
+
34524
+
34525
+
34526
+
34527
+
34528
+
34529
+
34530
+
34531
+
34532
+ const DeprecatedAppFrame = ({
34533
+ children
34534
+ }) => {
34535
+ const [, setSeamlyContainerElement] = useSeamlyContainerElement();
34536
+ const {
34537
+ isOpen,
34538
+ isVisible,
34539
+ setVisibility
34540
+ } = useVisibility();
34541
+ const {
34542
+ zIndex,
34543
+ showFaq,
34544
+ layoutMode
34545
+ } = useConfig();
34546
+ const {
34547
+ isModal,
34548
+ isInline
34549
+ } = useSeamlyLayoutMode();
34550
+ const appContainerClassNames = useSeamlyAppContainerClassNames();
34551
+ const userResponded = useUserHasResponded();
34552
+ const {
34553
+ locale
34554
+ } = useI18n();
34555
+ const containerElementRef = F(container => {
34556
+ setSeamlyContainerElement(container);
34557
+ }, [setSeamlyContainerElement]);
34558
+ const blockLang = hooks_module_A(() => {
34559
+ if (locale) {
34560
+ const htmlElementLang = document.querySelector('html').getAttribute('lang');
34561
+
34562
+ if (htmlElementLang !== locale) {
34563
+ return locale;
34564
+ }
34565
+ }
34566
+
34567
+ return undefined;
34568
+ }, [locale]);
34569
+ const classNames = ['app', 'app--deprecated', ...appContainerClassNames];
34570
+
34571
+ if (!isOpen && layoutMode === 'window') {
34572
+ classNames.push('app--collapsed');
34573
+ }
34574
+
34575
+ if (userResponded) {
34576
+ classNames.push('app--user-responded');
34577
+ }
34578
+
34579
+ classNames.push(`app--layout-${layoutMode}`);
34580
+
34581
+ const onKeyDownHandler = e => {
34582
+ if (e.code && e.code === 'Escape' || e.keyCode === 27) if (!isInline && isOpen) {
34583
+ setVisibility(visibilityStates.minimized);
34584
+ }
34585
+ };
34586
+
34587
+ const onClickHandler = e => {
34588
+ if (isModal) {
34589
+ e.stopPropagation();
34590
+ }
34591
+ };
34592
+
34593
+ return isVisible && jsxRuntime_module_e("section", {
34594
+ className: css_className(classNames),
34595
+ onKeyDown: onKeyDownHandler,
34596
+ onClick: onClickHandler,
34597
+ lang: blockLang,
34598
+ tabIndex: "-1",
34599
+ ref: containerElementRef,
34600
+ style: {
34601
+ zIndex
34602
+ },
34603
+ "data-nosnippet": true,
34604
+ children: [jsxRuntime_module_e("div", {
34605
+ className: css_className('app-wrapper'),
34606
+ children: children
34607
+ }), showFaq && jsxRuntime_module_e(faq, {})]
34608
+ });
34609
+ };
34610
+
34611
+ /* harmony default export */ var deprecated_app_frame = (DeprecatedAppFrame);
34336
34612
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/view/deprecated-view.js
34337
34613
 
34338
34614
 
@@ -34346,16 +34622,19 @@ const DeprecatedToggleButton = ({
34346
34622
 
34347
34623
 
34348
34624
 
34625
+
34349
34626
  const DeprecatedView = () => {
34350
34627
  const {
34351
34628
  isVisible
34352
34629
  } = useVisibility();
34353
34630
  const {
34354
- closeChat
34631
+ closeChat,
34632
+ openChat
34355
34633
  } = use_seamly_chat();
34356
- return isVisible && jsxRuntime_module_e(app_frame, {
34357
- isDeprecated: true,
34358
- children: [jsxRuntime_module_e(header, {
34634
+ return isVisible && jsxRuntime_module_e(deprecated_app_frame, {
34635
+ children: [jsxRuntime_module_e(toggle_button, {
34636
+ onOpenChat: openChat
34637
+ }), jsxRuntime_module_e(header, {
34359
34638
  onCloseChat: closeChat,
34360
34639
  children: jsxRuntime_module_e(agent_info, {})
34361
34640
  }), jsxRuntime_module_e(chat_frame, {