@qualified-salesforce/web 0.0.1-oidc-bootstrap
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/41842993ec71d6628e4949e9a22b146b.svg +3 -0
- package/7271f3433ed82fc7f56adcd9e30275f4.svg +17 -0
- package/LICENSE.txt +82 -0
- package/components/helpers/entriesStringValidations.js +69 -0
- package/components/helpers/languages.js +32 -0
- package/components/shared/assertUnreachable.js +5 -0
- package/components/shared/controls/imageCropperHelpers.js +43 -0
- package/components/shared/meetingLoadingProgressSpec.js +116 -0
- package/constants.generated.js +9883 -0
- package/css/widget/multimodal_v2/host.split-css.css +162 -0
- package/css/widget/multimodal_v2/index.split-css.panda.css +5240 -0
- package/css/widget/widget.split-css.css +100 -0
- package/fonts/inter/Inter-Black.woff +0 -0
- package/fonts/inter/Inter-Black.woff2 +0 -0
- package/fonts/inter/Inter-BlackItalic.woff +0 -0
- package/fonts/inter/Inter-BlackItalic.woff2 +0 -0
- package/fonts/inter/Inter-Bold.woff +0 -0
- package/fonts/inter/Inter-Bold.woff2 +0 -0
- package/fonts/inter/Inter-BoldItalic.woff +0 -0
- package/fonts/inter/Inter-BoldItalic.woff2 +0 -0
- package/fonts/inter/Inter-ExtraBold.woff +0 -0
- package/fonts/inter/Inter-ExtraBold.woff2 +0 -0
- package/fonts/inter/Inter-ExtraBoldItalic.woff +0 -0
- package/fonts/inter/Inter-ExtraBoldItalic.woff2 +0 -0
- package/fonts/inter/Inter-ExtraLight.woff +0 -0
- package/fonts/inter/Inter-ExtraLight.woff2 +0 -0
- package/fonts/inter/Inter-ExtraLightItalic.woff +0 -0
- package/fonts/inter/Inter-ExtraLightItalic.woff2 +0 -0
- package/fonts/inter/Inter-Italic.woff +0 -0
- package/fonts/inter/Inter-Italic.woff2 +0 -0
- package/fonts/inter/Inter-Light.woff +0 -0
- package/fonts/inter/Inter-Light.woff2 +0 -0
- package/fonts/inter/Inter-LightItalic.woff +0 -0
- package/fonts/inter/Inter-LightItalic.woff2 +0 -0
- package/fonts/inter/Inter-Medium.woff +0 -0
- package/fonts/inter/Inter-Medium.woff2 +0 -0
- package/fonts/inter/Inter-MediumItalic.woff +0 -0
- package/fonts/inter/Inter-MediumItalic.woff2 +0 -0
- package/fonts/inter/Inter-Regular.woff +0 -0
- package/fonts/inter/Inter-Regular.woff2 +0 -0
- package/fonts/inter/Inter-SemiBold.woff +0 -0
- package/fonts/inter/Inter-SemiBold.woff2 +0 -0
- package/fonts/inter/Inter-SemiBoldItalic.woff +0 -0
- package/fonts/inter/Inter-SemiBoldItalic.woff2 +0 -0
- package/fonts/inter/Inter-Thin.woff +0 -0
- package/fonts/inter/Inter-Thin.woff2 +0 -0
- package/fonts/inter/Inter-ThinItalic.woff +0 -0
- package/fonts/inter/Inter-ThinItalic.woff2 +0 -0
- package/fonts/inter/Inter-italic.var.woff2 +0 -0
- package/fonts/inter/Inter-roman.var.woff2 +0 -0
- package/images/close.js +63 -0
- package/images/logo.js +22 -0
- package/js/4101.js +19721 -0
- package/js/daily-esm.js +9948 -0
- package/js/date-fns.js +427 -0
- package/js/multimodal_v2.js +1653 -0
- package/js/runtime.js +109 -0
- package/media/Inter-Black.796be8d8bf.woff2 +0 -0
- package/media/Inter-Black.b254104c56.woff +0 -0
- package/media/Inter-BlackItalic.70306b0eae.woff +0 -0
- package/media/Inter-BlackItalic.752f1e0aaa.woff2 +0 -0
- package/media/Inter-Bold.579e0f95ca.woff2 +0 -0
- package/media/Inter-Bold.b1234477a5.woff +0 -0
- package/media/Inter-BoldItalic.3d0d804323.woff +0 -0
- package/media/Inter-BoldItalic.828a494e04.woff2 +0 -0
- package/media/Inter-ExtraBold.208a9e6c99.woff +0 -0
- package/media/Inter-ExtraBold.d65f028165.woff2 +0 -0
- package/media/Inter-ExtraBoldItalic.30429962ec.woff +0 -0
- package/media/Inter-ExtraBoldItalic.8c7eac5ce3.woff2 +0 -0
- package/media/Inter-ExtraLight.15c082a57d.woff +0 -0
- package/media/Inter-ExtraLight.6824177d1e.woff2 +0 -0
- package/media/Inter-ExtraLightItalic.05138dddf3.woff2 +0 -0
- package/media/Inter-ExtraLightItalic.3beee54f59.woff +0 -0
- package/media/Inter-Italic.9beab78452.woff +0 -0
- package/media/Inter-Italic.d593a8df79.woff2 +0 -0
- package/media/Inter-Light.27083fa637.woff2 +0 -0
- package/media/Inter-Light.91dfddd842.woff +0 -0
- package/media/Inter-LightItalic.0a783b89b3.woff2 +0 -0
- package/media/Inter-LightItalic.f8ccf2813f.woff +0 -0
- package/media/Inter-Medium.dc792b508e.woff2 +0 -0
- package/media/Inter-Medium.ec7dd2d9d8.woff +0 -0
- package/media/Inter-MediumItalic.17301e5b40.woff +0 -0
- package/media/Inter-MediumItalic.84d3493a9f.woff2 +0 -0
- package/media/Inter-Regular.f1f0c35b32.woff2 +0 -0
- package/media/Inter-Regular.f356e84aa0.woff +0 -0
- package/media/Inter-SemiBold.55027e4724.woff +0 -0
- package/media/Inter-SemiBold.fcb100c760.woff2 +0 -0
- package/media/Inter-SemiBoldItalic.ab9105ed3b.woff +0 -0
- package/media/Inter-SemiBoldItalic.d90f295d0c.woff2 +0 -0
- package/media/Inter-Thin.16325d9b0f.woff +0 -0
- package/media/Inter-Thin.dafaa44d99.woff2 +0 -0
- package/media/Inter-ThinItalic.4fc662b3cf.woff2 +0 -0
- package/media/Inter-ThinItalic.d3d8994788.woff +0 -0
- package/media/Inter-italic.var.958a0b9742.woff2 +0 -0
- package/media/Inter-roman.var.b2129c009c.woff2 +0 -0
- package/package.json +20 -0
- package/packs/widget/api/docking/docking_host.js +97 -0
- package/packs/widget/api/docking/index.js +294 -0
- package/packs/widget/api/docking/shared.js +164 -0
- package/packs/widget/api/docking/viewport_lock.js +488 -0
- package/packs/widget/api/docking/viewport_resize.js +1203 -0
- package/packs/widget/esm/fonts/Inter-Black.796be8d8bf.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-Black.b254104c56.woff +0 -0
- package/packs/widget/esm/fonts/Inter-BlackItalic.70306b0eae.woff +0 -0
- package/packs/widget/esm/fonts/Inter-BlackItalic.752f1e0aaa.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-Bold.579e0f95ca.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-Bold.b1234477a5.woff +0 -0
- package/packs/widget/esm/fonts/Inter-BoldItalic.3d0d804323.woff +0 -0
- package/packs/widget/esm/fonts/Inter-BoldItalic.828a494e04.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-ExtraBold.208a9e6c99.woff +0 -0
- package/packs/widget/esm/fonts/Inter-ExtraBold.d65f028165.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-ExtraBoldItalic.30429962ec.woff +0 -0
- package/packs/widget/esm/fonts/Inter-ExtraBoldItalic.8c7eac5ce3.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-ExtraLight.15c082a57d.woff +0 -0
- package/packs/widget/esm/fonts/Inter-ExtraLight.6824177d1e.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-ExtraLightItalic.05138dddf3.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-ExtraLightItalic.3beee54f59.woff +0 -0
- package/packs/widget/esm/fonts/Inter-Italic.9beab78452.woff +0 -0
- package/packs/widget/esm/fonts/Inter-Italic.d593a8df79.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-Light.27083fa637.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-Light.91dfddd842.woff +0 -0
- package/packs/widget/esm/fonts/Inter-LightItalic.0a783b89b3.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-LightItalic.f8ccf2813f.woff +0 -0
- package/packs/widget/esm/fonts/Inter-Medium.dc792b508e.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-Medium.ec7dd2d9d8.woff +0 -0
- package/packs/widget/esm/fonts/Inter-MediumItalic.17301e5b40.woff +0 -0
- package/packs/widget/esm/fonts/Inter-MediumItalic.84d3493a9f.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-Regular.f1f0c35b32.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-Regular.f356e84aa0.woff +0 -0
- package/packs/widget/esm/fonts/Inter-SemiBold.55027e4724.woff +0 -0
- package/packs/widget/esm/fonts/Inter-SemiBold.fcb100c760.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-SemiBoldItalic.ab9105ed3b.woff +0 -0
- package/packs/widget/esm/fonts/Inter-SemiBoldItalic.d90f295d0c.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-Thin.16325d9b0f.woff +0 -0
- package/packs/widget/esm/fonts/Inter-Thin.dafaa44d99.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-ThinItalic.4fc662b3cf.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-ThinItalic.d3d8994788.woff +0 -0
- package/packs/widget/esm/fonts/Inter-italic.var.958a0b9742.woff2 +0 -0
- package/packs/widget/esm/fonts/Inter-roman.var.b2129c009c.woff2 +0 -0
- package/packs/widget/esm/index.js +183 -0
- package/packs/widget/esm/qualified.css +5502 -0
- package/routes/app/offers/scripts/OfferMainScript.js +154 -0
- package/routes/app/offers/scripts/constants.js +71 -0
- package/routes/app/offers/scripts/main/ButtonManager.js +65 -0
- package/routes/app/offers/scripts/main/FormManager.js +325 -0
- package/routes/app/offers/scripts/main/MainContext.js +19 -0
- package/routes/app/offers/scripts/main/OfferManager.js +91 -0
- package/routes/app/offers/scripts/main/TriggerManager.js +125 -0
- package/routes/app/offers/scripts/rendering/ContentManager.js +53 -0
- package/routes/app/offers/scripts/rendering/LocationManager.js +83 -0
- package/routes/app/offers/scripts/rendering/RenderedOffer.js +188 -0
- package/routes/app/offers/scripts/rendering/Renderer.js +69 -0
- package/routes/app/offers/scripts/rendering/RenderingInitializer.js +62 -0
- package/routes/app/offers/scripts/rendering/animations/AnimationManager.js +31 -0
- package/routes/app/offers/scripts/rendering/animations/AnimationManagerFooter.js +81 -0
- package/routes/app/offers/scripts/rendering/animations/AnimationManagerHeader.js +81 -0
- package/routes/app/offers/scripts/rendering/animations/AnimationManagerModal.js +117 -0
- package/routes/app/offers/scripts/rendering/animations/AnimationManagerSidebar.js +75 -0
- package/routes/app/offers/scripts/rendering/animations/AnimationResult.js +43 -0
- package/routes/app/offers/scripts/rendering/animations/Animator.js +78 -0
- package/routes/app/offers/scripts/rendering/animations/BaseAnimationManager.js +25 -0
- package/routes/app/offers/scripts/rendering/lib/BaseComponent.js +106 -0
- package/routes/app/offers/scripts/rendering/lib/FormComponent.js +134 -0
- package/routes/app/offers/scripts/rendering/lib/OfferComponent.js +144 -0
- package/routes/app/offers/scripts/rendering/lib/ScrollbarWidth.js +27 -0
- package/routes/app/offers/scripts/rendering/lib/decorators.js +20 -0
- package/routes/app/offers/scripts/rendering/locations/CSSVarsManager.js +66 -0
- package/routes/app/offers/scripts/rendering/locations/ElementResizeObserver.js +49 -0
- package/routes/app/offers/scripts/rendering/locations/footer.js +53 -0
- package/routes/app/offers/scripts/rendering/locations/header/AsyncBatchProcessor.js +70 -0
- package/routes/app/offers/scripts/rendering/locations/header/CSSTransitionObserver.js +182 -0
- package/routes/app/offers/scripts/rendering/locations/header/ElementStyleChangeObserver.js +138 -0
- package/routes/app/offers/scripts/rendering/locations/header/ExternalStyleManager.js +110 -0
- package/routes/app/offers/scripts/rendering/locations/header/Header.js +353 -0
- package/routes/app/offers/scripts/rendering/locations/header/InlineStyleManager.js +105 -0
- package/routes/app/offers/scripts/rendering/locations/header/MatchingElementsObserver.js +107 -0
- package/routes/app/offers/scripts/rendering/locations/header/NewElementsObserver.js +129 -0
- package/routes/app/offers/scripts/rendering/locations/header/RuleWrapper.js +46 -0
- package/routes/app/offers/scripts/rendering/locations/header/SelectorObservable.js +23 -0
- package/routes/app/offers/scripts/rendering/locations/header/SelectorObserver.js +61 -0
- package/routes/app/offers/scripts/rendering/locations/header/ShiftedElementsManager.js +45 -0
- package/routes/app/offers/scripts/rendering/locations/header/StyleElementManager.js +37 -0
- package/routes/app/offers/scripts/rendering/locations/header/StyleElementWrapper.js +62 -0
- package/routes/app/offers/scripts/rendering/locations/header/StyleSelectorObserver/ObservedSelectorValue.js +45 -0
- package/routes/app/offers/scripts/rendering/locations/header/StyleSelectorObserver/ObservedSelectors.js +62 -0
- package/routes/app/offers/scripts/rendering/locations/header/StyleSelectorObserver/StyleSelectorObserver.js +294 -0
- package/routes/app/offers/scripts/rendering/locations/header/StyleSelectorObserver/constants.js +21 -0
- package/routes/app/offers/scripts/rendering/locations/header/WindowResizeObserver.js +43 -0
- package/routes/app/offers/scripts/rendering/locations/header/utils.js +25 -0
- package/routes/app/offers/scripts/rendering/locations/popup.js +66 -0
- package/routes/app/offers/scripts/rendering/locations/sidebar.js +21 -0
- package/routes/app/offers/scripts/rendering/variations/ButtonBanner.js +105 -0
- package/routes/app/offers/scripts/rendering/variations/ButtonModal.js +114 -0
- package/routes/app/offers/scripts/rendering/variations/FormBanner.js +214 -0
- package/routes/app/offers/scripts/rendering/variations/FormModal.js +325 -0
- package/routes/app/offers/scripts/rendering/variations/LinkBanner.js +105 -0
- package/routes/app/offers/scripts/rendering/variations/components/Body.js +29 -0
- package/routes/app/offers/scripts/rendering/variations/components/Button.js +128 -0
- package/routes/app/offers/scripts/rendering/variations/components/DismissButton.js +39 -0
- package/routes/app/offers/scripts/rendering/variations/components/ForegroundImageBanner.js +110 -0
- package/routes/app/offers/scripts/rendering/variations/components/ForegroundImageModal.js +128 -0
- package/routes/app/offers/scripts/rendering/variations/components/Headline.js +94 -0
- package/routes/app/offers/scripts/rendering/variations/components/MultiFieldForm.js +302 -0
- package/routes/app/offers/scripts/rendering/variations/components/Tooltip.js +74 -0
- package/routes/app/offers/scripts/rendering/variations/icons.js +15 -0
- package/routes/app/offers/scripts/utils.js +115 -0
- package/routes/app/offers/utils/HTMLUtils.js +10 -0
- package/routes/app/offers/utils/createTypeGuard.js +32 -0
- package/routes/app/offers/utils/promise-utils.js +22 -0
- package/routes/app/websiteBuilder/stores/storeHelpers.js +18 -0
- package/sounds/message-initial.mp3 +0 -0
- package/sounds/message-received.mp3 +0 -0
- package/sounds/message-sent.mp3 +0 -0
- package/src/arrays.js +15 -0
- package/src/audio.js +106 -0
- package/src/bounded-set.js +16 -0
- package/src/bounding_box_observer.js +129 -0
- package/src/decorators.js +29 -0
- package/src/dom.js +128 -0
- package/src/dom_roots.js +26 -0
- package/src/embedded_forms/EmbeddedForm.js +638 -0
- package/src/embedded_forms/QualifiedEmbeddedForm.js +51 -0
- package/src/embedded_forms/QualifiedFormField.js +137 -0
- package/src/embedded_forms/utils.js +17 -0
- package/src/graphql-types.js +1686 -0
- package/src/iframes.js +86 -0
- package/src/localstorage.js +43 -0
- package/src/mirror/Shipper.js +133 -0
- package/src/mirror/constants.generated.js +13 -0
- package/src/mirror/constants.js +238 -0
- package/src/mirror/shipper/ChangeQueue.js +155 -0
- package/src/mirror/shipper/DOMSerializer.js +392 -0
- package/src/mirror/shipper/observers.js +441 -0
- package/src/mirror/shipper/utils.js +98 -0
- package/src/mixins/disposable.js +125 -0
- package/src/mixins/injectable.js +37 -0
- package/src/personalizations/personalization-manager.js +110 -0
- package/src/personalizations/strategies/node-freezing-strategy.js +174 -0
- package/src/personalizations/utils.js +187 -0
- package/src/promises.js +107 -0
- package/src/proxy.js +144 -0
- package/src/qualified_root.js +35 -0
- package/src/query_params.js +55 -0
- package/src/shadow-dom-helper.js +63 -0
- package/src/singleton_host.js +39 -0
- package/src/smart_website/trigger.js +49 -0
- package/src/smart_website/utils.js +149 -0
- package/src/string.js +53 -0
- package/src/timezone.js +57 -0
- package/src/timing.js +49 -0
- package/src/type-utils.js +76 -0
- package/src/url-utils.js +102 -0
- package/src/url.js +50 -0
- package/src/utils.js +72 -0
- package/src/validation.js.js +29 -0
- package/src/validation_ts.js +6 -0
- package/vendor/actioncable/adapters.js +6 -0
- package/vendor/actioncable/connection.js +204 -0
- package/vendor/actioncable/connection_monitor.js +129 -0
- package/vendor/actioncable/consumer.js +91 -0
- package/vendor/actioncable/index.js +34 -0
- package/vendor/actioncable/internal.js +22 -0
- package/vendor/actioncable/logger.js +28 -0
- package/vendor/actioncable/subscription.js +93 -0
- package/vendor/actioncable/subscriptions.js +89 -0
- package/vendor/open-telemetry-idgenerator.js +43 -0
- package/widget/analytics/facebook_tracker.js +8 -0
- package/widget/analytics/google_analytics_tracker.js +83 -0
- package/widget/analytics/google_tag_manager_tracker.js +22 -0
- package/widget/analytics.js +58 -0
- package/widget/api_handler/api_handler.js +730 -0
- package/widget/api_handler/base_api_handler.js +249 -0
- package/widget/booker_intent_tracker.js +391 -0
- package/widget/booker_outcome_tracker.js +329 -0
- package/widget/capture_widget_exceptions.js +150 -0
- package/widget/channel.js +282 -0
- package/widget/composite_experience_adapter.js +101 -0
- package/widget/constants.generated.js +350 -0
- package/widget/constants.js +21 -0
- package/widget/container.js +193 -0
- package/widget/content_activity_emitter.js +36 -0
- package/widget/data360_visitor.js +67 -0
- package/widget/date_provider.js +11 -0
- package/widget/debug_mode_state.js +175 -0
- package/widget/dummy_module.js +9 -0
- package/widget/eloqua_visitor.js +17 -0
- package/widget/form_cta_booker_intent.js +246 -0
- package/widget/hubspot_visitor.js +39 -0
- package/widget/inline_meeting_booker_page.js +90 -0
- package/widget/local_state/abstract_local_state.js +38 -0
- package/widget/local_state/debug_state/abstract_debug_flow.js +29 -0
- package/widget/local_state/debug_state/custom_form_flow.js +14 -0
- package/widget/local_state/debug_state/hubspot_form_flow.js +19 -0
- package/widget/local_state/debug_state/hubspot_v4_form_flow.js +19 -0
- package/widget/local_state/debug_state/marketo_form_flow.js +20 -0
- package/widget/local_state/debug_state/pardot_form_flow.js +18 -0
- package/widget/local_state/debug_state.js +362 -0
- package/widget/local_state/trace_state.js +20 -0
- package/widget/location_provider.js +9 -0
- package/widget/marketo_visitor.js +39 -0
- package/widget/meetings/tracing/buttons_forms_triggering_tracer.js +124 -0
- package/widget/meetings/tracing/spans/button_spans.js +18 -0
- package/widget/meetings/tracing/spans/form_spans.js +11 -0
- package/widget/multimodal_v2/assets_preloader.js +97 -0
- package/widget/multimodal_v2/components/AppLayout.js +93 -0
- package/widget/multimodal_v2/components/CursorOverlay.js +93 -0
- package/widget/multimodal_v2/components/PointerRectOverlay.js +74 -0
- package/widget/multimodal_v2/components/app/Artifact.js +109 -0
- package/widget/multimodal_v2/components/app/Background.js +27 -0
- package/widget/multimodal_v2/components/app/CalendarLoadingContent.js +255 -0
- package/widget/multimodal_v2/components/app/Chat.js +39 -0
- package/widget/multimodal_v2/components/app/CookieConsentModal.js +149 -0
- package/widget/multimodal_v2/components/app/Foreground.js +48 -0
- package/widget/multimodal_v2/components/app/HiddenInput.js +41 -0
- package/widget/multimodal_v2/components/app/Input.js +72 -0
- package/widget/multimodal_v2/components/app/LightboxExperience.js +769 -0
- package/widget/multimodal_v2/components/app/LoadingOverlay.js +97 -0
- package/widget/multimodal_v2/components/app/Main.js +985 -0
- package/widget/multimodal_v2/components/app/MessengerButton.js +160 -0
- package/widget/multimodal_v2/components/app/Multimodal.js +17 -0
- package/widget/multimodal_v2/components/app/OverlayControls.js +79 -0
- package/widget/multimodal_v2/components/app/Preview.js +32 -0
- package/widget/multimodal_v2/components/app/PrivacyDisclosure.js +57 -0
- package/widget/multimodal_v2/components/app/RotateDeviceOverlay.js +70 -0
- package/widget/multimodal_v2/components/app/Toolbar.js +156 -0
- package/widget/multimodal_v2/components/chat/ChatComposer.js +129 -0
- package/widget/multimodal_v2/components/chat/ChatInputForm.js +398 -0
- package/widget/multimodal_v2/components/chat/ColdStartQuestions.js +354 -0
- package/widget/multimodal_v2/components/chat/ComposerErrorBanner.js +62 -0
- package/widget/multimodal_v2/components/chat/PostCallSurvey.js +359 -0
- package/widget/multimodal_v2/components/chat/preview/FieldRequestRenderer.js +41 -0
- package/widget/multimodal_v2/components/chat/preview/PreviewMessageRenderer.js +60 -0
- package/widget/multimodal_v2/components/chat/preview/SharedOfferRenderer.js +143 -0
- package/widget/multimodal_v2/components/chat/preview/TextRenderer.js +27 -0
- package/widget/multimodal_v2/components/chat/preview/TimelinePreview.js +254 -0
- package/widget/multimodal_v2/components/chat/timeline/CalendarEventOfferRenderer.js +103 -0
- package/widget/multimodal_v2/components/chat/timeline/CalendarEventPickRenderer.js +148 -0
- package/widget/multimodal_v2/components/chat/timeline/FieldEntryRenderer.js +84 -0
- package/widget/multimodal_v2/components/chat/timeline/FieldRequestRenderer.js +56 -0
- package/widget/multimodal_v2/components/chat/timeline/InlinePrivacyDisclosure.js +66 -0
- package/widget/multimodal_v2/components/chat/timeline/LinkPreviewCard.js +70 -0
- package/widget/multimodal_v2/components/chat/timeline/MessageEntry.js +88 -0
- package/widget/multimodal_v2/components/chat/timeline/PresentContentRenderer.js +30 -0
- package/widget/multimodal_v2/components/chat/timeline/PresentDeckRenderer.js +279 -0
- package/widget/multimodal_v2/components/chat/timeline/PresentVideoRenderer.js +131 -0
- package/widget/multimodal_v2/components/chat/timeline/ShareContentRenderer.js +59 -0
- package/widget/multimodal_v2/components/chat/timeline/SharedOfferRenderer.js +131 -0
- package/widget/multimodal_v2/components/chat/timeline/SystemRenderer.js +82 -0
- package/widget/multimodal_v2/components/chat/timeline/TextRenderer.js +66 -0
- package/widget/multimodal_v2/components/chat/timeline/Timeline.js +158 -0
- package/widget/multimodal_v2/components/debug/DebugMultimodalPanel.js +327 -0
- package/widget/multimodal_v2/components/decks/index.js +160 -0
- package/widget/multimodal_v2/components/field_request/BooleanField.js +77 -0
- package/widget/multimodal_v2/components/field_request/FieldComponents.js +69 -0
- package/widget/multimodal_v2/components/field_request/Form.js +87 -0
- package/widget/multimodal_v2/components/field_request/MultiPicklistField.js +240 -0
- package/widget/multimodal_v2/components/field_request/PicklistField.js +166 -0
- package/widget/multimodal_v2/components/field_request/SingleLineInputField.js +69 -0
- package/widget/multimodal_v2/components/field_request/TextField.js +37 -0
- package/widget/multimodal_v2/components/field_request/index.js +170 -0
- package/widget/multimodal_v2/components/helpers/AutoScroll.js +37 -0
- package/widget/multimodal_v2/components/helpers/ErrorBoundary.js +53 -0
- package/widget/multimodal_v2/components/helpers/FocusTrapDialog.js +26 -0
- package/widget/multimodal_v2/components/helpers/ImpressionTracker.js +94 -0
- package/widget/multimodal_v2/components/helpers/ListRenderer.js +37 -0
- package/widget/multimodal_v2/components/helpers/Localization.js +76 -0
- package/widget/multimodal_v2/components/helpers/Persisted.js +166 -0
- package/widget/multimodal_v2/components/helpers/RichText.js +358 -0
- package/widget/multimodal_v2/components/helpers/ScreenReaderHeading.js +17 -0
- package/widget/multimodal_v2/components/helpers/Thumbnail.js +190 -0
- package/widget/multimodal_v2/components/helpers/VisuallyHidden.js +41 -0
- package/widget/multimodal_v2/components/helpers/content_click_payloads.js +58 -0
- package/widget/multimodal_v2/components/helpers/useDraggable.js +103 -0
- package/widget/multimodal_v2/components/helpers/useTextOverflow.js +44 -0
- package/widget/multimodal_v2/components/lightbox_gather/index.js +741 -0
- package/widget/multimodal_v2/components/meetings/ArtifactEntryPoint.js +252 -0
- package/widget/multimodal_v2/components/meetings/MeetingAdditionalAttendees.js +325 -0
- package/widget/multimodal_v2/components/meetings/MeetingBookerEntry.js +100 -0
- package/widget/multimodal_v2/components/meetings/MeetingDetailsCard.js +99 -0
- package/widget/multimodal_v2/components/meetings/MeetingErrorBanner.js +62 -0
- package/widget/multimodal_v2/components/meetings/MeetingOfferEmailStep.js +239 -0
- package/widget/multimodal_v2/components/meetings/MeetingOfferFooter.js +104 -0
- package/widget/multimodal_v2/components/meetings/MeetingOfferSelectionStep.js +60 -0
- package/widget/multimodal_v2/components/meetings/MeetingRepHeader.js +222 -0
- package/widget/multimodal_v2/components/meetings/MeetingStepShell.js +92 -0
- package/widget/multimodal_v2/components/meetings/MeetingSummaryRail.js +515 -0
- package/widget/multimodal_v2/components/meetings/MeetingTimeSelector.js +603 -0
- package/widget/multimodal_v2/components/meetings/MonthDatePicker.js +422 -0
- package/widget/multimodal_v2/components/meetings/NavigationButtons.js +76 -0
- package/widget/multimodal_v2/components/meetings/TimeSlotHeader.js +357 -0
- package/widget/multimodal_v2/components/meetings/WeekViewHeader.js +20 -0
- package/widget/multimodal_v2/components/meetings/constants.js +7 -0
- package/widget/multimodal_v2/components/meetings/index.js +47 -0
- package/widget/multimodal_v2/components/meetings/utils.js +328 -0
- package/widget/multimodal_v2/components/multimodal/Audio.js +28 -0
- package/widget/multimodal_v2/components/multimodal/Controls.js +188 -0
- package/widget/multimodal_v2/components/multimodal/LiveVideo.js +63 -0
- package/widget/multimodal_v2/components/multimodal/MultiModalComponent.js +424 -0
- package/widget/multimodal_v2/components/multimodal/MultimodalAvatar.js +36 -0
- package/widget/multimodal_v2/components/multimodal/OrbAvatar.js +326 -0
- package/widget/multimodal_v2/components/multimodal/Status.js +220 -0
- package/widget/multimodal_v2/components/multimodal/VideoAvatar.js +24 -0
- package/widget/multimodal_v2/components/multimodal/VideoPreview.js +114 -0
- package/widget/multimodal_v2/components/multimodal/useAudioLevelMonitoring.js +96 -0
- package/widget/multimodal_v2/components/multimodal/useMultimodal.js +434 -0
- package/widget/multimodal_v2/components/presentations/index.js +372 -0
- package/widget/multimodal_v2/components/shared/Avatar.js +92 -0
- package/widget/multimodal_v2/components/shared/AvatarGroup.js +135 -0
- package/widget/multimodal_v2/components/shared/Button.js +245 -0
- package/widget/multimodal_v2/components/shared/ButtonGroup.js +133 -0
- package/widget/multimodal_v2/components/shared/ComposerForm.js +98 -0
- package/widget/multimodal_v2/components/shared/SpeakingIndicator.js +239 -0
- package/widget/multimodal_v2/components/shared/ThinkingAnimation.js +165 -0
- package/widget/multimodal_v2/components/shared/Tooltip.js +266 -0
- package/widget/multimodal_v2/components/shared/controls/Dropdown.js +79 -0
- package/widget/multimodal_v2/components/shared/controls/PillToggle.js +142 -0
- package/widget/multimodal_v2/components/shared/controls/TextArea.js +114 -0
- package/widget/multimodal_v2/components/shared/toolCallLabels.js +12 -0
- package/widget/multimodal_v2/components/slides/SlidesThumbnail.js +47 -0
- package/widget/multimodal_v2/components/slides/index.js +61 -0
- package/widget/multimodal_v2/constants.js +88 -0
- package/widget/multimodal_v2/host.split-css.js +2 -0
- package/widget/multimodal_v2/host.string.js +96 -0
- package/widget/multimodal_v2/images/icons.js +582 -0
- package/widget/multimodal_v2/images/posters/piper_low_res.jpg +0 -0
- package/widget/multimodal_v2/index.js +23 -0
- package/widget/multimodal_v2/index.panda.js +28 -0
- package/widget/multimodal_v2/index.split-css.panda.js +2 -0
- package/widget/multimodal_v2/inline_meeting_booker.js +182 -0
- package/widget/multimodal_v2/locales/cs.js +196 -0
- package/widget/multimodal_v2/locales/da.js +196 -0
- package/widget/multimodal_v2/locales/de.js +196 -0
- package/widget/multimodal_v2/locales/en.js +196 -0
- package/widget/multimodal_v2/locales/en_AU.js +197 -0
- package/widget/multimodal_v2/locales/en_GB.js +197 -0
- package/widget/multimodal_v2/locales/es.js +197 -0
- package/widget/multimodal_v2/locales/es_LA.js +196 -0
- package/widget/multimodal_v2/locales/fi.js +196 -0
- package/widget/multimodal_v2/locales/fr.js +197 -0
- package/widget/multimodal_v2/locales/fr_CA.js +196 -0
- package/widget/multimodal_v2/locales/id.js +196 -0
- package/widget/multimodal_v2/locales/index.js +48 -0
- package/widget/multimodal_v2/locales/it.js +196 -0
- package/widget/multimodal_v2/locales/ja.js +196 -0
- package/widget/multimodal_v2/locales/ko.js +196 -0
- package/widget/multimodal_v2/locales/nb.js +196 -0
- package/widget/multimodal_v2/locales/nl.js +196 -0
- package/widget/multimodal_v2/locales/pl.js +196 -0
- package/widget/multimodal_v2/locales/pt_BR.js +196 -0
- package/widget/multimodal_v2/locales/ru.js +196 -0
- package/widget/multimodal_v2/locales/sv.js +196 -0
- package/widget/multimodal_v2/locales/th.js +196 -0
- package/widget/multimodal_v2/locales/tr.js +196 -0
- package/widget/multimodal_v2/locales/vi.js +196 -0
- package/widget/multimodal_v2/locales/zh_CN.js +196 -0
- package/widget/multimodal_v2/locales/zh_TW.js +196 -0
- package/widget/multimodal_v2/multimodal.js +633 -0
- package/widget/multimodal_v2/multimodal_channel.js +195 -0
- package/widget/multimodal_v2/signals/active_conversation_signal.js +33 -0
- package/widget/multimodal_v2/signals/allowed_conversation_mode_signal.js +38 -0
- package/widget/multimodal_v2/signals/artifact_signal.js +22 -0
- package/widget/multimodal_v2/signals/layout_signal.js +98 -0
- package/widget/multimodal_v2/signals/messages_signal.js +207 -0
- package/widget/multimodal_v2/signals/ui_state_signal.js +128 -0
- package/widget/multimodal_v2/stable_bundle_src.js +44 -0
- package/widget/multimodal_v2/stores/ai_conversation_store.js +221 -0
- package/widget/multimodal_v2/stores/artifact_store.js +205 -0
- package/widget/multimodal_v2/stores/base_store.js +16 -0
- package/widget/multimodal_v2/stores/call_store.js +770 -0
- package/widget/multimodal_v2/stores/call_ui_adapter.js +225 -0
- package/widget/multimodal_v2/stores/debug_multimodal_scenario_store.js +471 -0
- package/widget/multimodal_v2/stores/decks_store.js +285 -0
- package/widget/multimodal_v2/stores/device_store.js +63 -0
- package/widget/multimodal_v2/stores/docking_store.js +62 -0
- package/widget/multimodal_v2/stores/field_request_store.js +326 -0
- package/widget/multimodal_v2/stores/meeting_store.js +477 -0
- package/widget/multimodal_v2/stores/participant_store.js +73 -0
- package/widget/multimodal_v2/stores/post_call_survey_store.js +160 -0
- package/widget/multimodal_v2/stores/pounce_tracking_store.js +163 -0
- package/widget/multimodal_v2/stores/pounce_tracking_store_v2.js +511 -0
- package/widget/multimodal_v2/stores/presentations_store.js +111 -0
- package/widget/multimodal_v2/stores/root_store.js +1919 -0
- package/widget/multimodal_v2/stores/screen_share_store.js +217 -0
- package/widget/multimodal_v2/stores/slides_store.js +21 -0
- package/widget/multimodal_v2/stores/translation_store.js +185 -0
- package/widget/multimodal_v2/stores/ui_store.js +496 -0
- package/widget/multimodal_v2/stores/waiting_store.js +159 -0
- package/widget/multimodal_v2/stores/website_navigation_store.js +767 -0
- package/widget/multimodal_v2/styled-system/css/conditions.js +34 -0
- package/widget/multimodal_v2/styled-system/css/css.js +48 -0
- package/widget/multimodal_v2/styled-system/css/cva.js +96 -0
- package/widget/multimodal_v2/styled-system/css/cx.js +13 -0
- package/widget/multimodal_v2/styled-system/css/index.js +15 -0
- package/widget/multimodal_v2/styled-system/css/sva.js +69 -0
- package/widget/multimodal_v2/styled-system/helpers.js +384 -0
- package/widget/multimodal_v2/styled-system/jsx/create-style-context.js +96 -0
- package/widget/multimodal_v2/styled-system/jsx/factory-helper.js +19 -0
- package/widget/multimodal_v2/styled-system/jsx/factory.js +111 -0
- package/widget/multimodal_v2/styled-system/jsx/index.js +12 -0
- package/widget/multimodal_v2/styled-system/jsx/is-valid-prop.js +22 -0
- package/widget/multimodal_v2/types.js +105 -0
- package/widget/multimodal_v2/utils/auto_scroller.js +157 -0
- package/widget/multimodal_v2/utils/flip_animation.js +124 -0
- package/widget/multimodal_v2/utils/focus_gate.js +237 -0
- package/widget/multimodal_v2/utils/locale.js +16 -0
- package/widget/multimodal_v2/utils/media_queries.js +30 -0
- package/widget/multimodal_v2/utils/multimodal_cache.js +19 -0
- package/widget/multimodal_v2/utils/mutation_effect.js +14 -0
- package/widget/multimodal_v2/utils/navigation_interceptor.js +205 -0
- package/widget/multimodal_v2/utils/navigation_strategies/dom_swap.js +393 -0
- package/widget/multimodal_v2/utils/navigation_strategies/index.js +12 -0
- package/widget/multimodal_v2/utils/navigation_strategies/lwr.js +61 -0
- package/widget/multimodal_v2/utils/navigation_strategies/navigation_utils.js +46 -0
- package/widget/multimodal_v2/utils/navigation_strategies/next_js.js +24 -0
- package/widget/multimodal_v2/utils/navigation_strategies/wouter_v3.js +15 -0
- package/widget/multimodal_v2/utils/objects_map.js +38 -0
- package/widget/multimodal_v2/utils/perceived_voice_turn_tracker.js +345 -0
- package/widget/multimodal_v2/utils/sanitize_html.js +132 -0
- package/widget/multimodal_v2/utils/signals.js +97 -0
- package/widget/multimodal_v2/utils/slide_zoom.js +114 -0
- package/widget/multimodal_v2/utils/theme_styles.js +137 -0
- package/widget/multimodal_v2/utils/url_observer.js +52 -0
- package/widget/multimodal_v2/utils/voice_onset_detector.js +127 -0
- package/widget/page_mirror.js +89 -0
- package/widget/page_view_activity_emitter.js +71 -0
- package/widget/pardot_visitor.js +137 -0
- package/widget/personalization_observer.js +96 -0
- package/widget/personalizations_config.js +160 -0
- package/widget/qualified_form/constants.js +23 -0
- package/widget/qualified_form/phone_utils.js +38 -0
- package/widget/qualified_form/qualified_form_action.js +91 -0
- package/widget/qualified_form/qualified_form_action_orchestrator.js +21 -0
- package/widget/qualified_form/qualified_form_api.js +471 -0
- package/widget/scroll_disabler.js +109 -0
- package/widget/server-logger.js +156 -0
- package/widget/smart_website_config.js +112 -0
- package/widget/telemetry/context.js +75 -0
- package/widget/telemetry/index.js +16 -0
- package/widget/telemetry/messenger_uptime.js +80 -0
- package/widget/telemetry/metrics.js +120 -0
- package/widget/telemetry/span.js +82 -0
- package/widget/telemetry/telemetry.js +180 -0
- package/widget/telemetry/tracer.js +41 -0
- package/widget/telemetry/tracing_store.js +310 -0
- package/widget/tracker.js +916 -0
- package/widget/utils/native_globals.js +129 -0
- package/widget/v1_adapter.js +50 -0
- package/widget/v2_adapter.js +368 -0
- package/widget/visitor/base_visitor_state.js +11 -0
- package/widget/visitor/cookie_visitor_state.js +128 -0
- package/widget/visitor/in_memory_visitor_state.js +29 -0
- package/widget/visitor/visitor_state.js +384 -0
- package/widget/visitor.js +356 -0
- package/widget/widget/linked_widget_v2.js +227 -0
- package/widget/widget/page_mirror_factory.js +22 -0
- package/widget/widget/sentry.js +130 -0
- package/widget/widget/widget.js +1698 -0
- package/widget/widget.split-css.js +2 -0
- package/widget/widget_bootstrap.js +97 -0
- package/widget/widget_object.js +73 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { HEADER_HEIGHT_CSS_VARIABLE, DEFAULT_OFFERS_Z_INDEX, HEADER_INCLUDE_ELEMENT_DATA_ATTRIBUTE, HOST_LOCATION_ATTRIBUTE, HEADER_IGNORE_ELEMENT_DATA_ATTRIBUTE } from "../../../constants.js";
|
|
2
|
+
import { getHostId, toHTMLElement } from "../../../utils.js";
|
|
3
|
+
import { CSSVarsManager } from "../CSSVarsManager.js";
|
|
4
|
+
import { ElementResizeObserver } from "../ElementResizeObserver.js";
|
|
5
|
+
import { ElementStyleChangeObserver } from "./ElementStyleChangeObserver.js";
|
|
6
|
+
import { ExternalStyleManager } from "./ExternalStyleManager.js";
|
|
7
|
+
import { MatchingElementsObserver } from "./MatchingElementsObserver.js";
|
|
8
|
+
import { SelectorObserver } from "./SelectorObserver.js";
|
|
9
|
+
import { StyleElementManager } from "./StyleElementManager.js";
|
|
10
|
+
import { StyleSelectorObserver } from "./StyleSelectorObserver/StyleSelectorObserver.js";
|
|
11
|
+
import { InlineStyleManager } from "./InlineStyleManager.js";
|
|
12
|
+
import { ShiftedElementsManager } from "./ShiftedElementsManager.js";
|
|
13
|
+
import { SelectorObservable } from "./SelectorObservable.js";
|
|
14
|
+
|
|
15
|
+
/* eslint-disable rulesdir/css-units */ /* eslint-disable rulesdir/enforce-comment */ /* eslint-disable no-continue */
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const SHIFTED_ELEMENT_DATA_ATTRIBUTE = "qualified-offer-header-shifted-element";
|
|
29
|
+
class Header {
|
|
30
|
+
static get ignoredSelectors() {
|
|
31
|
+
return this._ignoredSelectors;
|
|
32
|
+
}
|
|
33
|
+
static get includedSelectors() {
|
|
34
|
+
return this._includedSelectors;
|
|
35
|
+
}
|
|
36
|
+
static async setup(config) {
|
|
37
|
+
if (this.isInitialized) return;
|
|
38
|
+
if ("registerProperty" in window.CSS) {
|
|
39
|
+
// This is needed for the animations to work with the custom property
|
|
40
|
+
window.CSS.registerProperty({
|
|
41
|
+
name: HEADER_HEIGHT_CSS_VARIABLE,
|
|
42
|
+
syntax: "<length>",
|
|
43
|
+
inherits: true,
|
|
44
|
+
initialValue: "0px"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (config) {
|
|
48
|
+
StyleSelectorObserver.setConfig(config);
|
|
49
|
+
ElementStyleChangeObserver.setConfig(config);
|
|
50
|
+
}
|
|
51
|
+
if (config == null ? void 0 : config.excludedSelectors) {
|
|
52
|
+
this._ignoredSelectors += ",:is(" + config.excludedSelectors + ")";
|
|
53
|
+
}
|
|
54
|
+
if (config == null ? void 0 : config.includedSelectors) {
|
|
55
|
+
this._includedSelectors += ",:is(" + config.includedSelectors + ")";
|
|
56
|
+
}
|
|
57
|
+
await StyleSelectorObserver.getInstance().load();
|
|
58
|
+
this.isInitialized = true;
|
|
59
|
+
}
|
|
60
|
+
createHost(id) {
|
|
61
|
+
// Style is inline because the host is directly inserted into the DOM. (no shadow root)
|
|
62
|
+
const hostId = getHostId(id);
|
|
63
|
+
const html = /* html */ '\n <div id="' + hostId + '" style="position:fixed;left:0;top:0;width:100%;height:fit-content;z-index:' + DEFAULT_OFFERS_Z_INDEX + '"></div>\n ';
|
|
64
|
+
return toHTMLElement(html);
|
|
65
|
+
}
|
|
66
|
+
insertHost(host) {
|
|
67
|
+
this.initialize();
|
|
68
|
+
this.shiftedElementsManager.init();
|
|
69
|
+
this.insertHostInWebsite(host);
|
|
70
|
+
this.initHtmlOffsetStyles();
|
|
71
|
+
this.inlineStyleManager.init();
|
|
72
|
+
this.externalStyleManager.init();
|
|
73
|
+
this.prepareInitialShiftedElements();
|
|
74
|
+
this.styles.get("externalStylesOffset").init();
|
|
75
|
+
}
|
|
76
|
+
afterInsertAnimation(host) {
|
|
77
|
+
// Restore initial shifted elements
|
|
78
|
+
this.restoreInitialShiftedElements == null ? void 0 : this.restoreInitialShiftedElements.call(this);
|
|
79
|
+
// Ensure stylesheets are enabled
|
|
80
|
+
this.updateHeaderHeight(host);
|
|
81
|
+
// Init observers
|
|
82
|
+
this.selectorObserver.init();
|
|
83
|
+
this.matchingElementsObserver.init({
|
|
84
|
+
initialElements: this.shiftedElementsManager.elements
|
|
85
|
+
});
|
|
86
|
+
this.hostResizeObserver.init(host);
|
|
87
|
+
}
|
|
88
|
+
beforeRemoveAnimation() {
|
|
89
|
+
// Dispose observers
|
|
90
|
+
this.selectorObserver.dispose();
|
|
91
|
+
this.matchingElementsObserver.dispose();
|
|
92
|
+
this.hostResizeObserver.dispose();
|
|
93
|
+
// Disable transitions for the shifted elements
|
|
94
|
+
this.prepareExitShiftedElements();
|
|
95
|
+
}
|
|
96
|
+
removeHost(host) {
|
|
97
|
+
host.remove();
|
|
98
|
+
this.shiftedElementsManager.dispose();
|
|
99
|
+
this.externalStyleManager.dispose();
|
|
100
|
+
this.inlineStyleManager.dispose();
|
|
101
|
+
this.styles.dispose();
|
|
102
|
+
this.cssVars.dispose();
|
|
103
|
+
// Restore transitions for the shifted elements
|
|
104
|
+
this.restoreExitShiftedElements == null ? void 0 : this.restoreExitShiftedElements.call(this);
|
|
105
|
+
}
|
|
106
|
+
initialize() {
|
|
107
|
+
if (this.isInitialized) return;
|
|
108
|
+
this.selectorObserver = this.createSelectorObserver();
|
|
109
|
+
this.matchingElementsObserver = new MatchingElementsObserver(this.selectorObserver, this.handleMatchingElements);
|
|
110
|
+
this.hostResizeObserver = new ElementResizeObserver(this.updateHeaderHeight, "height", (/* inlined export .RESIZE_THROTTLE_MS */250));
|
|
111
|
+
this.externalStyleManager = new ExternalStyleManager({
|
|
112
|
+
property: "top",
|
|
113
|
+
styleElement: this.styles.get("externalStylesOffset"),
|
|
114
|
+
offsetCssValue: "var(" + HEADER_HEIGHT_CSS_VARIABLE + ", 0px)",
|
|
115
|
+
dataAttribute: SHIFTED_ELEMENT_DATA_ATTRIBUTE
|
|
116
|
+
});
|
|
117
|
+
this.inlineStyleManager = new InlineStyleManager({
|
|
118
|
+
property: "top",
|
|
119
|
+
offsetCssValue: "var(" + HEADER_HEIGHT_CSS_VARIABLE + ", 0px)"
|
|
120
|
+
});
|
|
121
|
+
this.shiftedElementsManager = new ShiftedElementsManager({
|
|
122
|
+
dataAttribute: SHIFTED_ELEMENT_DATA_ATTRIBUTE
|
|
123
|
+
});
|
|
124
|
+
this.isInitialized = true;
|
|
125
|
+
}
|
|
126
|
+
insertHostInWebsite(host) {
|
|
127
|
+
document.body.insertBefore(host, document.body.firstElementChild);
|
|
128
|
+
}
|
|
129
|
+
initHtmlOffsetStyles() {
|
|
130
|
+
const { marginTop, minHeight } = window.getComputedStyle(document.documentElement);
|
|
131
|
+
this.styles.get("htmlOffset").init({
|
|
132
|
+
rules: [
|
|
133
|
+
/* css */ "html {\n " + // If the min height is 100% we don't want to set the height of the html element
|
|
134
|
+
// because it will break the layout of the website
|
|
135
|
+
(minHeight === "100%" ? "" : "height: calc(100dvh - " + marginTop + " - var(" + HEADER_HEIGHT_CSS_VARIABLE + ")) !important;") + "\n margin-top: calc(" + marginTop + " + var(" + HEADER_HEIGHT_CSS_VARIABLE + ")) !important;\n top: 0 !important;\n position: relative !important;\n overflow-y: visible !important;\n }"
|
|
136
|
+
]
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
prepareInitialShiftedElements() {
|
|
140
|
+
// TODO: Watch for race conditions in case the SelectorObserver is not ready in time (event with lazy loading)
|
|
141
|
+
const { restoreTransitions } = this.handleMatchingElements({
|
|
142
|
+
added: document.querySelectorAll(this.selectorObserver.current.value),
|
|
143
|
+
removed: [],
|
|
144
|
+
changed: []
|
|
145
|
+
}, {
|
|
146
|
+
shouldRestoreTransitions: false
|
|
147
|
+
});
|
|
148
|
+
this.restoreInitialShiftedElements = ()=>{
|
|
149
|
+
restoreTransitions();
|
|
150
|
+
this.restoreInitialShiftedElements = null;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
prepareExitShiftedElements() {
|
|
154
|
+
var _this_shiftedElementsManager_elements;
|
|
155
|
+
if (!((_this_shiftedElementsManager_elements = this.shiftedElementsManager.elements) == null ? void 0 : _this_shiftedElementsManager_elements.size)) return;
|
|
156
|
+
const map = new Map();
|
|
157
|
+
for (const element of this.shiftedElementsManager.elements){
|
|
158
|
+
const { transition } = window.getComputedStyle(element);
|
|
159
|
+
map.set(element, {
|
|
160
|
+
transition
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const restoreTransitions = this.disableTransitions([
|
|
164
|
+
map
|
|
165
|
+
]);
|
|
166
|
+
this.restoreExitShiftedElements = ()=>{
|
|
167
|
+
restoreTransitions();
|
|
168
|
+
this.restoreExitShiftedElements = null;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
processMatchingElements(elements) {
|
|
172
|
+
const added = new Map();
|
|
173
|
+
const changed = new Map();
|
|
174
|
+
const removed = new Map();
|
|
175
|
+
for (const element of elements.added){
|
|
176
|
+
if (this.shiftedElementsManager.has(element)) continue;
|
|
177
|
+
const { position, transition } = window.getComputedStyle(element);
|
|
178
|
+
if (!this.shouldShiftElement(element, position)) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
added.set(element, {
|
|
182
|
+
position,
|
|
183
|
+
transition
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
for (const element of elements.changed){
|
|
187
|
+
const { position, transition } = window.getComputedStyle(element);
|
|
188
|
+
if (!this.shouldShiftElement(element, position)) {
|
|
189
|
+
removed.set(element, {
|
|
190
|
+
position,
|
|
191
|
+
transition
|
|
192
|
+
});
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (!this.shiftedElementsManager.has(element)) {
|
|
196
|
+
added.set(element, {
|
|
197
|
+
position,
|
|
198
|
+
transition
|
|
199
|
+
});
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
changed.set(element, {
|
|
203
|
+
position,
|
|
204
|
+
transition
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
for (const element of elements.removed){
|
|
208
|
+
if (!this.shiftedElementsManager.has(element)) continue;
|
|
209
|
+
const { position, transition } = window.getComputedStyle(element);
|
|
210
|
+
removed.set(element, {
|
|
211
|
+
position,
|
|
212
|
+
transition
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
added,
|
|
217
|
+
changed,
|
|
218
|
+
removed
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
addElement(element) {
|
|
222
|
+
this.shiftedElementsManager.add(element);
|
|
223
|
+
this.inlineStyleManager.add(element);
|
|
224
|
+
}
|
|
225
|
+
updateElement(element) {
|
|
226
|
+
this.inlineStyleManager.update(element);
|
|
227
|
+
}
|
|
228
|
+
removeElement(element) {
|
|
229
|
+
this.inlineStyleManager.remove(element);
|
|
230
|
+
this.shiftedElementsManager.remove(element);
|
|
231
|
+
}
|
|
232
|
+
// Selector matching is not enough to determine if an element should be shifted
|
|
233
|
+
// Since the element could be matched due to a media query that is not currently active
|
|
234
|
+
// We need to check the computed style of the element to determine if it should be shifted
|
|
235
|
+
shouldShiftElement(element, position) {
|
|
236
|
+
if (element.hasAttribute(HEADER_IGNORE_ELEMENT_DATA_ATTRIBUTE)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
if (element.hasAttribute(HEADER_INCLUDE_ELEMENT_DATA_ATTRIBUTE)) {
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
if (position !== "fixed" && position !== "sticky") {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
createSelectorObserver() {
|
|
248
|
+
return new SelectorObserver((selectors)=>{
|
|
249
|
+
const fixedRules = selectors.get("position:fixed").rules;
|
|
250
|
+
const stickyRules = selectors.get("position:sticky").rules;
|
|
251
|
+
return new SelectorObservable([
|
|
252
|
+
...fixedRules,
|
|
253
|
+
...stickyRules
|
|
254
|
+
], Header.includedSelectors, Header.ignoredSelectors);
|
|
255
|
+
}, [
|
|
256
|
+
"position:fixed",
|
|
257
|
+
"position:sticky"
|
|
258
|
+
]);
|
|
259
|
+
}
|
|
260
|
+
disableTransitions(elementsIterable) {
|
|
261
|
+
const map = new Map();
|
|
262
|
+
for (const elements of elementsIterable){
|
|
263
|
+
for (const [element, { transition }] of elements){
|
|
264
|
+
if (transition !== "none" && transition !== "") {
|
|
265
|
+
map.set(element, {
|
|
266
|
+
value: element.style.getPropertyValue("transition"),
|
|
267
|
+
priority: element.style.getPropertyPriority("transition")
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
for (const element of map.keys()){
|
|
273
|
+
element.style.setProperty("transition", "none", "important");
|
|
274
|
+
}
|
|
275
|
+
const restoreTransitions = ()=>{
|
|
276
|
+
for (const [element, { value, priority }] of map.entries()){
|
|
277
|
+
if (!value) {
|
|
278
|
+
element.style.removeProperty("transition");
|
|
279
|
+
} else {
|
|
280
|
+
element.style.setProperty("transition", value, priority);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
return restoreTransitions;
|
|
285
|
+
}
|
|
286
|
+
constructor(){
|
|
287
|
+
this.styles = StyleElementManager.get("header");
|
|
288
|
+
this.cssVars = CSSVarsManager.get("header");
|
|
289
|
+
this.isInitialized = false;
|
|
290
|
+
this.restoreInitialShiftedElements = null;
|
|
291
|
+
this.restoreExitShiftedElements = null;
|
|
292
|
+
this.updateHeaderHeight = (host)=>{
|
|
293
|
+
this.cssVars.set(HEADER_HEIGHT_CSS_VARIABLE, "" + host.offsetHeight + "px");
|
|
294
|
+
};
|
|
295
|
+
this.handleMatchingElements = (elements, param)=>{
|
|
296
|
+
let { shouldRestoreTransitions = true } = param === void 0 ? {} : param;
|
|
297
|
+
this.matchingElementsObserver.pauseChangeObserver();
|
|
298
|
+
const { added, changed, removed } = this.processMatchingElements(elements);
|
|
299
|
+
const restoreTransitions = this.disableTransitions([
|
|
300
|
+
added,
|
|
301
|
+
changed,
|
|
302
|
+
removed
|
|
303
|
+
]);
|
|
304
|
+
try {
|
|
305
|
+
for (const [element] of added){
|
|
306
|
+
this.addElement(element);
|
|
307
|
+
}
|
|
308
|
+
for (const [element] of changed){
|
|
309
|
+
this.updateElement(element);
|
|
310
|
+
}
|
|
311
|
+
for (const [element] of removed){
|
|
312
|
+
this.removeElement(element);
|
|
313
|
+
}
|
|
314
|
+
} finally{
|
|
315
|
+
if (shouldRestoreTransitions) {
|
|
316
|
+
restoreTransitions();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
this.matchingElementsObserver.resumeChangeObserver();
|
|
320
|
+
return {
|
|
321
|
+
restoreTransitions
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
Header.isInitialized = false;
|
|
327
|
+
Header._ignoredSelectors = [
|
|
328
|
+
// This is the data attribute for all the offer hosts
|
|
329
|
+
"[" + HOST_LOCATION_ATTRIBUTE + "]",
|
|
330
|
+
// We want to ignore all the elements that are used as dialogs
|
|
331
|
+
"dialog",
|
|
332
|
+
'[role="dialog"]',
|
|
333
|
+
// We want to ignore our widget/lightbox
|
|
334
|
+
"#q-messenger-frame",
|
|
335
|
+
// We want to ignore our multimodal widget
|
|
336
|
+
"#qualified-multimodal-host",
|
|
337
|
+
// We want to ignore the Docked skeleton
|
|
338
|
+
"#q-docked-skeleton",
|
|
339
|
+
// We want to ignore all the elements that includes the specified data attribute
|
|
340
|
+
"[" + HEADER_IGNORE_ELEMENT_DATA_ATTRIBUTE + "]"
|
|
341
|
+
].join(",");
|
|
342
|
+
Header._includedSelectors = [
|
|
343
|
+
// We want to include elements with fixed/sticky style attributes
|
|
344
|
+
'*[style*="position:fixed"]',
|
|
345
|
+
'*[style*="position: fixed"]',
|
|
346
|
+
'*[style*="position:sticky"]',
|
|
347
|
+
'*[style*="position: sticky"]',
|
|
348
|
+
// We want to include all the elements that includes the specified data attribute
|
|
349
|
+
"[" + HEADER_INCLUDE_ELEMENT_DATA_ATTRIBUTE + "]"
|
|
350
|
+
].join(",");
|
|
351
|
+
|
|
352
|
+
var Header_SHIFTED_ELEMENT_DATA_ATTRIBUTE = /* unused export */ undefined;
|
|
353
|
+
export { Header, Header_SHIFTED_ELEMENT_DATA_ATTRIBUTE as SHIFTED_ELEMENT_DATA_ATTRIBUTE };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/* eslint-disable no-continue */ // This CSS variable is not registered, it is only used to tell if we have already applied the offset
|
|
2
|
+
// The variable is used like this var(--qualified-offer-header-inline-style-offset, <value>) this is equivalent to
|
|
3
|
+
// Just using <value> but it allows us to tell if we have already applied the offset
|
|
4
|
+
const OFFSET_VAR_NAME = "--qualified-offer-header-inline-style-offset";
|
|
5
|
+
/**
|
|
6
|
+
* This manager is responsible for managing inline styles of shifted elements
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* We have the following element somewhere in the document:
|
|
11
|
+
*
|
|
12
|
+
* <div class="test-selector" style="top: 10px;">
|
|
13
|
+
* ...
|
|
14
|
+
* </div>
|
|
15
|
+
*
|
|
16
|
+
* We can now create an InlineStyleManager instance with the following options to offset the element:
|
|
17
|
+
*
|
|
18
|
+
* const manager = new InlineStyleManager({
|
|
19
|
+
* property: "top",
|
|
20
|
+
* offsetCssValue: "var(--shift-offset)",
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* The manager will now update the element's style to:
|
|
24
|
+
*
|
|
25
|
+
* <div class="test-selector" style="top: calc(10px + var(--shift-offset));">
|
|
26
|
+
* ...
|
|
27
|
+
* </div>
|
|
28
|
+
*
|
|
29
|
+
*/ class InlineStyleManager {
|
|
30
|
+
init() {
|
|
31
|
+
this.isDisposed = false;
|
|
32
|
+
this.elements.clear();
|
|
33
|
+
}
|
|
34
|
+
dispose() {
|
|
35
|
+
for (const [element, properties] of this.elements){
|
|
36
|
+
this.restoreElement(element, properties);
|
|
37
|
+
}
|
|
38
|
+
this.elements.clear();
|
|
39
|
+
this.isDisposed = true;
|
|
40
|
+
}
|
|
41
|
+
add(element) {
|
|
42
|
+
if (this.isDisposed || this.elements.has(element)) return;
|
|
43
|
+
const value = element.style.getPropertyValue(this.options.property);
|
|
44
|
+
if (!value) return;
|
|
45
|
+
const priority = element.style.getPropertyPriority(this.options.property);
|
|
46
|
+
this.elements.set(element, {
|
|
47
|
+
priority,
|
|
48
|
+
value
|
|
49
|
+
});
|
|
50
|
+
this.shiftElement(element, {
|
|
51
|
+
priority,
|
|
52
|
+
value
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
update(element) {
|
|
56
|
+
if (this.isDisposed) return;
|
|
57
|
+
if (!this.elements.has(element)) {
|
|
58
|
+
this.add(element);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const value = element.style.getPropertyValue(this.options.property);
|
|
62
|
+
if (!value) {
|
|
63
|
+
this.elements.delete(element);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (value.includes(OFFSET_VAR_NAME)) return;
|
|
67
|
+
const priority = element.style.getPropertyPriority(this.options.property);
|
|
68
|
+
this.elements.set(element, {
|
|
69
|
+
priority,
|
|
70
|
+
value
|
|
71
|
+
});
|
|
72
|
+
this.shiftElement(element, {
|
|
73
|
+
priority,
|
|
74
|
+
value
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
remove(element) {
|
|
78
|
+
if (this.isDisposed || !this.elements.has(element)) return;
|
|
79
|
+
const { priority, value } = this.elements.get(element);
|
|
80
|
+
this.elements.delete(element);
|
|
81
|
+
if (element.style.getPropertyValue(this.options.property).includes(OFFSET_VAR_NAME)) {
|
|
82
|
+
this.restoreElement(element, {
|
|
83
|
+
priority,
|
|
84
|
+
value
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
restoreElement(element, properties) {
|
|
89
|
+
const { value, priority } = properties;
|
|
90
|
+
element.style.setProperty(this.options.property, value, priority);
|
|
91
|
+
}
|
|
92
|
+
shiftElement(element, properties) {
|
|
93
|
+
const { value, priority } = properties;
|
|
94
|
+
element.style.setProperty(this.options.property, "calc(" + value + " + var(" + OFFSET_VAR_NAME + ", " + this.options.offsetCssValue + "))", priority);
|
|
95
|
+
}
|
|
96
|
+
// eslint-disable-next-line no-useless-constructor
|
|
97
|
+
constructor(options){
|
|
98
|
+
this.options = options;
|
|
99
|
+
this.isDisposed = true;
|
|
100
|
+
this.elements = new Map();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var InlineStyleManager_OFFSET_VAR_NAME = /* unused export */ undefined;
|
|
105
|
+
export { InlineStyleManager, InlineStyleManager_OFFSET_VAR_NAME as OFFSET_VAR_NAME };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import "../../../constants.js";
|
|
2
|
+
import { ElementStyleChangeObserver } from "./ElementStyleChangeObserver.js";
|
|
3
|
+
import { NewElementsObserver } from "./NewElementsObserver.js";
|
|
4
|
+
import { WindowResizeObserver } from "./WindowResizeObserver.js";
|
|
5
|
+
|
|
6
|
+
/* eslint-disable no-continue */
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Class used to keep track of all the elements that should (potentially) be shifted
|
|
12
|
+
* It uses multiple observers to keep track of the elements that are added, removed, and changed
|
|
13
|
+
*/ class MatchingElementsObserver {
|
|
14
|
+
init(param) {
|
|
15
|
+
let { initialElements } = param === void 0 ? {} : param;
|
|
16
|
+
this.isDisposed = false;
|
|
17
|
+
this.newElementsObserver.init();
|
|
18
|
+
this.elementStyleChangeObserver.init();
|
|
19
|
+
this.windowResizeObserver.init();
|
|
20
|
+
this.observedElements.clear();
|
|
21
|
+
if (initialElements) {
|
|
22
|
+
this.addElements(initialElements);
|
|
23
|
+
this.onUpdateElements();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
dispose() {
|
|
27
|
+
this.newElementsObserver.dispose();
|
|
28
|
+
this.elementStyleChangeObserver.dispose();
|
|
29
|
+
this.windowResizeObserver.dispose();
|
|
30
|
+
this.observedElements.clear();
|
|
31
|
+
this.isDisposed = true;
|
|
32
|
+
}
|
|
33
|
+
pauseChangeObserver() {
|
|
34
|
+
this.elementStyleChangeObserver.pause();
|
|
35
|
+
}
|
|
36
|
+
resumeChangeObserver() {
|
|
37
|
+
this.elementStyleChangeObserver.resume();
|
|
38
|
+
}
|
|
39
|
+
addElements(elements) {
|
|
40
|
+
for (const element of elements){
|
|
41
|
+
this.observedElements.add(element);
|
|
42
|
+
}
|
|
43
|
+
this.elementStyleChangeObserver.observe(elements);
|
|
44
|
+
}
|
|
45
|
+
removeElements(elements) {
|
|
46
|
+
for (const element of elements){
|
|
47
|
+
this.observedElements.delete(element);
|
|
48
|
+
}
|
|
49
|
+
this.elementStyleChangeObserver.unobserve(elements);
|
|
50
|
+
}
|
|
51
|
+
_callback(elements) {
|
|
52
|
+
if (this.isDisposed) return;
|
|
53
|
+
this.callback(elements);
|
|
54
|
+
}
|
|
55
|
+
constructor(selectorObserver, callback){
|
|
56
|
+
this.selectorObserver = selectorObserver;
|
|
57
|
+
this.callback = callback;
|
|
58
|
+
this.isDisposed = true;
|
|
59
|
+
this.observedElements = new Set();
|
|
60
|
+
this.onNewElements = (elements)=>{
|
|
61
|
+
if (this.isDisposed) return;
|
|
62
|
+
const added = [];
|
|
63
|
+
for (const element of elements){
|
|
64
|
+
if (this.observedElements.has(element) || !element.matches(this.selectorObserver.current.value)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
added.push(element);
|
|
68
|
+
}
|
|
69
|
+
if (added.length === 0) return;
|
|
70
|
+
this.addElements(added);
|
|
71
|
+
this._callback({
|
|
72
|
+
added,
|
|
73
|
+
removed: [],
|
|
74
|
+
changed: []
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
this.onUpdateElements = (elements)=>{
|
|
78
|
+
if (elements === void 0) elements = this.observedElements;
|
|
79
|
+
if (this.isDisposed) return;
|
|
80
|
+
const removed = [];
|
|
81
|
+
const changed = [];
|
|
82
|
+
const currentSelector = this.selectorObserver.current;
|
|
83
|
+
for (const element of elements){
|
|
84
|
+
if (!this.observedElements.has(element)) continue;
|
|
85
|
+
if (!element.matches(currentSelector.value)) {
|
|
86
|
+
removed.push(element);
|
|
87
|
+
} else {
|
|
88
|
+
changed.push(element);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (removed.length === 0 && changed.length === 0) return;
|
|
92
|
+
this.removeElements(removed);
|
|
93
|
+
this._callback({
|
|
94
|
+
added: [],
|
|
95
|
+
removed,
|
|
96
|
+
changed
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
this.newElementsObserver = new NewElementsObserver(selectorObserver, this.onNewElements);
|
|
100
|
+
this.elementStyleChangeObserver = new ElementStyleChangeObserver([
|
|
101
|
+
"position"
|
|
102
|
+
], this.onUpdateElements);
|
|
103
|
+
this.windowResizeObserver = new WindowResizeObserver(this.onUpdateElements, "width", (/* inlined export .RESIZE_THROTTLE_MS */250));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { MatchingElementsObserver };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { __webpack_require__ } from "../../../../../../../js/runtime.js";
|
|
2
|
+
import { AsyncBatchProcessor } from "./AsyncBatchProcessor.js";
|
|
3
|
+
import { RuleWrapper } from "./RuleWrapper.js";
|
|
4
|
+
import { StyleElementWrapper } from "./StyleElementWrapper.js";
|
|
5
|
+
import "../../../../../../../widget/utils/native_globals.js";
|
|
6
|
+
|
|
7
|
+
/* provided dependency */ var __nativeDocumentAddEventListener = __webpack_require__(68034).Qj;
|
|
8
|
+
/* provided dependency */ var __nativeDocumentRemoveEventListener = __webpack_require__(68034).LA;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A class that observes elements that match a given selector.
|
|
14
|
+
* It uses a CSS animation to detect when an element is added to the DOM
|
|
15
|
+
* and then calls a callback with the elements that match the selector.
|
|
16
|
+
* This is useful when we want to observe elements that are added to the DOM
|
|
17
|
+
* after the initial page load.
|
|
18
|
+
*
|
|
19
|
+
* Using the CSS animation is faster and less expensive
|
|
20
|
+
* than using a MutationObserver to observe the dom for a selector
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* const observer = new NewElementsObserver(selectorObserver, (elements) => {
|
|
25
|
+
* // Do something with the elements
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* Let's say we want to observe all the elements with the following rule and also all the elements with this selector .test
|
|
29
|
+
* The options will provide the following array [Rule, ".test"] where rule is the CSS rule below
|
|
30
|
+
*
|
|
31
|
+
* @media (max-width: 1000px) {
|
|
32
|
+
* .fixed-header {
|
|
33
|
+
* position: fixed;
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* The observer will generate the following style element:
|
|
38
|
+
*
|
|
39
|
+
* @keyframes qualified-offer-element-observer-animation-0 {}
|
|
40
|
+
*
|
|
41
|
+
* @media (max-width: 1000px) {
|
|
42
|
+
* .fixed-header::after { animation: qualified-offer-element-observer-animation-0 1ms; content: "" }
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* .test::after { animation: qualified-offer-element-observer-animation-0 1ms; content: "" }
|
|
46
|
+
*
|
|
47
|
+
* What this does is that it will fire an animation any time an element that matches the options
|
|
48
|
+
* The observer listens for that specific animation and then calls the callback with the elements that match the options
|
|
49
|
+
*/ class NewElementsObserver {
|
|
50
|
+
init() {
|
|
51
|
+
this.isDisposed = false;
|
|
52
|
+
this.selectorObserver.observe(this.onSelectorChange);
|
|
53
|
+
this.observe();
|
|
54
|
+
}
|
|
55
|
+
dispose() {
|
|
56
|
+
this.disconnect();
|
|
57
|
+
this.selectorObserver.unobserve(this.onSelectorChange);
|
|
58
|
+
this.isDisposed = true;
|
|
59
|
+
}
|
|
60
|
+
observe() {
|
|
61
|
+
__nativeDocumentAddEventListener("animationstart", this.eventHandler);
|
|
62
|
+
this.styleElement.init({
|
|
63
|
+
rules: this.getAllRules()
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
disconnect() {
|
|
67
|
+
__nativeDocumentRemoveEventListener("animationstart", this.eventHandler);
|
|
68
|
+
this.styleElement.dispose();
|
|
69
|
+
this.newElementsQueue.clearAndCancel();
|
|
70
|
+
}
|
|
71
|
+
getAllRules() {
|
|
72
|
+
const currentRules = [
|
|
73
|
+
this.selectorObserver.current.includedSelector,
|
|
74
|
+
...this.selectorObserver.current.rules
|
|
75
|
+
];
|
|
76
|
+
const ignoredSelector = ":is(" + this.selectorObserver.current.ignoredSelector + ")";
|
|
77
|
+
const rules = [
|
|
78
|
+
"@keyframes " + this.animationName + " {}"
|
|
79
|
+
];
|
|
80
|
+
for (const rule of currentRules){
|
|
81
|
+
rules.push(this.getRule(rule, ignoredSelector));
|
|
82
|
+
}
|
|
83
|
+
return rules;
|
|
84
|
+
}
|
|
85
|
+
getRule(selectorRule, ignoredSelector) {
|
|
86
|
+
const selector = this.getSelector(selectorRule, ignoredSelector);
|
|
87
|
+
const wrapper = this.getWrapper(selectorRule);
|
|
88
|
+
const cssText = this.getCssText(selector);
|
|
89
|
+
return RuleWrapper.wrap(wrapper, cssText);
|
|
90
|
+
}
|
|
91
|
+
getSelector(selectorRule, ignoredSelector) {
|
|
92
|
+
const selector = typeof selectorRule === "string" ? selectorRule : selectorRule.selector;
|
|
93
|
+
return ":is(" + selector + "):not(" + ignoredSelector + ")";
|
|
94
|
+
}
|
|
95
|
+
getWrapper(selectorRule) {
|
|
96
|
+
return typeof selectorRule === "string" ? undefined : selectorRule.wrapper;
|
|
97
|
+
}
|
|
98
|
+
getCssText(selector) {
|
|
99
|
+
return selector + " { animation: " + this.animationName + " 1ms; }";
|
|
100
|
+
}
|
|
101
|
+
constructor(selectorObserver, callback){
|
|
102
|
+
this.selectorObserver = selectorObserver;
|
|
103
|
+
this.callback = callback;
|
|
104
|
+
this.animationName = "qualified-offer-element-observer-animation-" + NewElementsObserver.id++;
|
|
105
|
+
this.isDisposed = true;
|
|
106
|
+
this.styleElement = new StyleElementWrapper();
|
|
107
|
+
this.onSelectorChange = ()=>{
|
|
108
|
+
// Flush the queue and re-observe
|
|
109
|
+
this.newElementsQueue.executeImmediately();
|
|
110
|
+
this.disconnect();
|
|
111
|
+
this.observe();
|
|
112
|
+
};
|
|
113
|
+
this.eventHandler = (event)=>{
|
|
114
|
+
if (event.animationName === this.animationName && event.target instanceof HTMLElement) {
|
|
115
|
+
this.newElementsQueue.addAndSchedule(event.target);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
this.processBatch = (elements)=>{
|
|
119
|
+
if (this.isDisposed || elements.length === 0) return;
|
|
120
|
+
this.callback([
|
|
121
|
+
...new Set(elements)
|
|
122
|
+
]);
|
|
123
|
+
};
|
|
124
|
+
this.newElementsQueue = new AsyncBatchProcessor(this.processBatch);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
NewElementsObserver.id = 0;
|
|
128
|
+
|
|
129
|
+
export { NewElementsObserver };
|