@meetelise/chat 1.34.7 → 1.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/MyPubnub.d.ts +116 -0
- package/dist/src/WebComponent/FeeCalculator/components/addons/addon-item-matrix-qty-selector/addon-item-matrix-qty-selector-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/addons/addon-item-matrix-qty-selector/addon-item-matrix-qty-selector.d.ts +28 -0
- package/dist/src/WebComponent/FeeCalculator/components/addons/addon-item-qty-selector/addon-item-qty-selector-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/addons/addon-item-qty-selector/addon-item-qty-selector.d.ts +18 -0
- package/dist/src/WebComponent/FeeCalculator/components/addons/common-addon-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/addons/rentable-item-qty-selector/rentable-item-qty-selector-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/addons/rentable-item-qty-selector/rentable-item-qty-selector.d.ts +22 -0
- package/dist/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout.d.ts +46 -0
- package/dist/src/WebComponent/FeeCalculator/components/fee-card/fee-card-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/fee-card/fee-card.d.ts +21 -0
- package/dist/src/WebComponent/FeeCalculator/components/fee-item/fee-item-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/fee-item/fee-item.d.ts +13 -0
- package/dist/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector.d.ts +34 -0
- package/dist/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card.d.ts +18 -0
- package/dist/src/WebComponent/FeeCalculator/components/incentive-banner/incentive-banner-styles.d.ts +1 -0
- package/dist/src/WebComponent/FeeCalculator/components/incentive-banner/incentive-banner.d.ts +8 -0
- package/dist/src/WebComponent/FeeCalculator/components/incentive-banner/index.d.ts +1 -0
- package/dist/src/WebComponent/FeeCalculator/components/index.d.ts +5 -0
- package/dist/src/WebComponent/FeeCalculator/components/promo-card/promo-card-styles.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/components/promo-card/promo-card.d.ts +13 -0
- package/dist/src/WebComponent/FeeCalculator/constants.d.ts +3 -0
- package/dist/src/WebComponent/FeeCalculator/fee-calculator-styles.d.ts +1 -0
- package/dist/src/WebComponent/FeeCalculator/fee-calculator.d.ts +55 -0
- package/dist/src/WebComponent/FeeCalculator/index.d.ts +2 -0
- package/dist/src/WebComponent/FeeCalculator/model/building-fee-view.d.ts +41 -0
- package/dist/src/WebComponent/FeeCalculator/model/building-fee.d.ts +82 -0
- package/dist/src/WebComponent/FeeCalculator/model/desired-addon.d.ts +5 -0
- package/dist/src/WebComponent/FeeCalculator/model/desired-rentable-item.d.ts +4 -0
- package/dist/src/WebComponent/FeeCalculator/model/index.d.ts +13 -0
- package/dist/src/WebComponent/FeeCalculator/model/item-combination.d.ts +6 -0
- package/dist/src/WebComponent/FeeCalculator/model/item-quantity.d.ts +4 -0
- package/dist/src/WebComponent/FeeCalculator/model/pricing-matrix.d.ts +18 -0
- package/dist/src/WebComponent/FeeCalculator/model/pricing-rule.d.ts +8 -0
- package/dist/src/WebComponent/FeeCalculator/model/rent-frequency.d.ts +1 -0
- package/dist/src/WebComponent/FeeCalculator/model/rentable-item-summary.d.ts +9 -0
- package/dist/src/WebComponent/FeeCalculator/model/rentable-item.d.ts +9 -0
- package/dist/src/WebComponent/FeeCalculator/model/transaction-category.d.ts +23 -0
- package/dist/src/WebComponent/FeeCalculator/model/unit-fee-bundle.d.ts +31 -0
- package/dist/src/WebComponent/LeadSourceClient.d.ts +46 -0
- package/dist/src/WebComponent/OfficeHours.d.ts +21 -0
- package/dist/src/WebComponent/Scheduler/date-picker.d.ts +28 -0
- package/dist/src/WebComponent/Scheduler/time-picker.d.ts +16 -0
- package/dist/src/WebComponent/Scheduler/tour-scheduler.d.ts +102 -0
- package/dist/src/WebComponent/Scheduler/tour-type-option.d.ts +13 -0
- package/dist/src/WebComponent/Scheduler/tourSchedulerStyles.d.ts +1 -0
- package/dist/src/WebComponent/actions/InputStyles.d.ts +1 -0
- package/dist/src/WebComponent/actions/action-confirm-button.d.ts +13 -0
- package/dist/src/WebComponent/actions/call-us-window.d.ts +37 -0
- package/dist/src/WebComponent/actions/collapse-expand-button.d.ts +8 -0
- package/dist/src/WebComponent/actions/details-window.d.ts +14 -0
- package/dist/src/WebComponent/actions/email-us-window.d.ts +46 -0
- package/dist/src/WebComponent/actions/formatPhoneNumber.d.ts +17 -0
- package/dist/src/WebComponent/actions/minimize-expand-button.d.ts +8 -0
- package/dist/src/WebComponent/chat-additional-actions.d.ts +28 -0
- package/dist/src/WebComponent/health-chat.d.ts +47 -0
- package/dist/src/WebComponent/healthchat-styles.d.ts +1 -0
- package/dist/src/WebComponent/icons/ApplyOutlineIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/BookTourOutlineIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/CalculatorOutlineIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/ChatOutlineIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/ChevronLeftIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/ChevronRightIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/ContactResidentIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/DollarOutlineIcon.d.ts +7 -0
- package/dist/src/WebComponent/icons/EmailOutlineIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/HeyThereEmojiIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/PhoneOutlineIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/SendMessageIcon.d.ts +3 -0
- package/dist/src/WebComponent/icons/TourSelfGuidedIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/TourVirtuallyIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/TourWithAgentIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/XOutlineIcon.d.ts +2 -0
- package/dist/src/WebComponent/index.d.ts +2 -0
- package/dist/src/WebComponent/launcher/Launcher.d.ts +99 -0
- package/dist/src/WebComponent/launcher/launcherStyles.d.ts +1 -0
- package/dist/src/WebComponent/launcher/mobile-launcher.d.ts +27 -0
- package/dist/src/WebComponent/launcher/typeEmojiStyles.d.ts +1 -0
- package/dist/src/WebComponent/launcher/typeMiniStyles.d.ts +1 -0
- package/dist/src/WebComponent/launcher/typeMobileStyles.d.ts +1 -0
- package/dist/src/WebComponent/leasing-chat-styles.d.ts +1 -0
- package/dist/src/WebComponent/loaders/index.d.ts +4 -0
- package/dist/src/WebComponent/loaders/mega-loader.d.ts +7 -0
- package/dist/src/WebComponent/loaders/skeleton-card.d.ts +12 -0
- package/dist/src/WebComponent/loaders/skeleton-loader-styles.d.ts +3 -0
- package/dist/src/WebComponent/loaders/skeleton-loader.d.ts +13 -0
- package/dist/src/WebComponent/me-chat.d.ts +91 -0
- package/dist/src/WebComponent/me-select.d.ts +24 -0
- package/dist/src/WebComponent/mini-loader.d.ts +5 -0
- package/dist/src/WebComponent/pubnub-chat-styles.d.ts +1 -0
- package/dist/src/WebComponent/pubnub-chat.d.ts +48 -0
- package/dist/src/WebComponent/pubnub-media.d.ts +14 -0
- package/dist/src/WebComponent/pubnub-message-styles.d.ts +1 -0
- package/dist/src/WebComponent/pubnub-message.d.ts +39 -0
- package/dist/src/WebComponent/simple-launcher/simple-launcher-styles.d.ts +1 -0
- package/dist/src/WebComponent/simple-launcher/simple-launcher.d.ts +12 -0
- package/dist/src/WebComponent/utilities-chat.d.ts +47 -0
- package/dist/src/WebComponent/utilities-styles.d.ts +1 -0
- package/dist/src/WebComponent/utils.d.ts +31 -0
- package/dist/src/analytics.d.ts +64 -0
- package/dist/src/disclaimers.d.ts +16 -0
- package/dist/src/fetchBuildingABTestType.d.ts +8 -0
- package/dist/src/fetchBuildingInfo.d.ts +58 -0
- package/dist/src/fetchBuildingWebchatView.d.ts +124 -0
- package/dist/src/fetchFeatureFlag.d.ts +14 -0
- package/dist/src/fetchLeadSources.d.ts +4 -0
- package/dist/src/fetchPhoneNumberFromSource.d.ts +6 -0
- package/dist/src/getAvailabilities.d.ts +46 -0
- package/dist/src/getBuildingPhoneNumber.d.ts +1 -0
- package/dist/src/getShouldAllowScheduling.d.ts +1 -0
- package/dist/src/getShouldShowWebchat.d.ts +3 -0
- package/dist/src/getTimezoneString.d.ts +1 -0
- package/dist/src/globals.d.ts +2 -0
- package/dist/src/gtm.d.ts +6 -0
- package/dist/src/handleChatId.d.ts +11 -0
- package/dist/src/insertDNIIntoWebsite.d.ts +5 -0
- package/dist/src/insertLeadSourceIntoSchedulerLinks.d.ts +4 -0
- package/dist/src/main/MEChat.d.ts +74 -0
- package/dist/src/main/utils.d.ts +2 -0
- package/dist/src/postLeadSources.d.ts +3 -0
- package/dist/src/rentgrata.d.ts +4 -0
- package/dist/src/replaceSelectButtonsWithNewLink.d.ts +5 -0
- package/dist/src/services/fees/calculateQuote.d.ts +14 -0
- package/dist/src/services/fees/fetchBuildingFeesV2.d.ts +10 -0
- package/dist/src/services/fees/fetchBuildingUnits.d.ts +29 -0
- package/dist/src/services/fees/utils.d.ts +1 -0
- package/dist/src/svgIcons.d.ts +5 -0
- package/dist/src/themes.d.ts +5 -0
- package/dist/src/types/incentive-v2.d.ts +23 -0
- package/dist/src/types/rest-sdk.types.d.ts +11 -0
- package/dist/src/types/webchat-no-show-reason.d.ts +1 -0
- package/dist/src/utils/getWidgetOverrides.d.ts +39 -0
- package/dist/src/utils/queryParamBuilder.d.ts +8 -0
- package/dist/src/utils.d.ts +13 -0
- package/package.json +1 -1
- package/public/dist/index.js +41 -41
- package/src/MyPubnub.ts +792 -0
- package/src/WebComponent/FeeCalculator/components/addons/addon-item-matrix-qty-selector/addon-item-matrix-qty-selector-styles.ts +35 -0
- package/src/WebComponent/FeeCalculator/components/addons/addon-item-matrix-qty-selector/addon-item-matrix-qty-selector.ts +206 -0
- package/src/WebComponent/FeeCalculator/components/addons/addon-item-qty-selector/addon-item-qty-selector-styles.ts +6 -0
- package/src/WebComponent/FeeCalculator/components/addons/addon-item-qty-selector/addon-item-qty-selector.ts +101 -0
- package/src/WebComponent/FeeCalculator/components/addons/common-addon-styles.ts +82 -0
- package/src/WebComponent/FeeCalculator/components/addons/rentable-item-qty-selector/rentable-item-qty-selector-styles.ts +9 -0
- package/src/WebComponent/FeeCalculator/components/addons/rentable-item-qty-selector/rentable-item-qty-selector.ts +124 -0
- package/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout-styles.ts +142 -0
- package/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout.ts +243 -0
- package/src/WebComponent/FeeCalculator/components/fee-card/fee-card-styles.ts +65 -0
- package/src/WebComponent/FeeCalculator/components/fee-card/fee-card.ts +91 -0
- package/src/WebComponent/FeeCalculator/components/fee-item/fee-item-styles.ts +44 -0
- package/src/WebComponent/FeeCalculator/components/fee-item/fee-item.ts +38 -0
- package/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles.ts +151 -0
- package/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector.ts +248 -0
- package/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles.ts +82 -0
- package/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card.ts +76 -0
- package/src/WebComponent/FeeCalculator/components/incentive-banner/incentive-banner-styles.ts +40 -0
- package/src/WebComponent/FeeCalculator/components/incentive-banner/incentive-banner.ts +43 -0
- package/src/WebComponent/FeeCalculator/components/incentive-banner/index.ts +1 -0
- package/src/WebComponent/FeeCalculator/components/index.ts +5 -0
- package/src/WebComponent/FeeCalculator/components/promo-card/promo-card-styles.ts +39 -0
- package/src/WebComponent/FeeCalculator/components/promo-card/promo-card.ts +39 -0
- package/src/WebComponent/FeeCalculator/constants.ts +5 -0
- package/src/WebComponent/FeeCalculator/fee-calculator-styles.ts +310 -0
- package/src/WebComponent/FeeCalculator/fee-calculator.ts +341 -0
- package/src/WebComponent/FeeCalculator/index.ts +4 -0
- package/src/WebComponent/FeeCalculator/model/building-fee-view.ts +84 -0
- package/src/WebComponent/FeeCalculator/model/building-fee.ts +126 -0
- package/src/WebComponent/FeeCalculator/model/desired-addon.ts +6 -0
- package/src/WebComponent/FeeCalculator/model/desired-rentable-item.ts +4 -0
- package/src/WebComponent/FeeCalculator/model/index.ts +13 -0
- package/src/WebComponent/FeeCalculator/model/item-combination.ts +16 -0
- package/src/WebComponent/FeeCalculator/model/item-quantity.ts +4 -0
- package/src/WebComponent/FeeCalculator/model/pricing-matrix.ts +45 -0
- package/src/WebComponent/FeeCalculator/model/pricing-rule.ts +9 -0
- package/src/WebComponent/FeeCalculator/model/rent-frequency.ts +1 -0
- package/src/WebComponent/FeeCalculator/model/rentable-item-summary.ts +10 -0
- package/src/WebComponent/FeeCalculator/model/rentable-item.ts +10 -0
- package/src/WebComponent/FeeCalculator/model/transaction-category.ts +23 -0
- package/src/WebComponent/FeeCalculator/model/unit-fee-bundle.ts +54 -0
- package/src/WebComponent/LeadSourceClient.ts +332 -0
- package/src/WebComponent/MEChat.css +5 -0
- package/src/WebComponent/OfficeHours.ts +73 -0
- package/src/WebComponent/Scheduler/date-picker.ts +405 -0
- package/src/WebComponent/Scheduler/time-picker.ts +195 -0
- package/src/WebComponent/Scheduler/tour-scheduler.ts +1430 -0
- package/src/WebComponent/Scheduler/tour-type-option.ts +112 -0
- package/src/WebComponent/Scheduler/tourSchedulerStyles.ts +418 -0
- package/src/WebComponent/actions/InputStyles.ts +57 -0
- package/src/WebComponent/actions/action-confirm-button.ts +125 -0
- package/src/WebComponent/actions/call-us-window.ts +467 -0
- package/src/WebComponent/actions/collapse-expand-button.ts +65 -0
- package/src/WebComponent/actions/details-window.ts +150 -0
- package/src/WebComponent/actions/email-us-window.ts +556 -0
- package/src/WebComponent/actions/formatPhoneNumber.ts +72 -0
- package/src/WebComponent/actions/minimize-expand-button.ts +93 -0
- package/src/WebComponent/chat-additional-actions.ts +135 -0
- package/src/WebComponent/health-chat.ts +270 -0
- package/src/WebComponent/healthchat-styles.ts +119 -0
- package/src/WebComponent/icons/ApplyOutlineIcon.ts +22 -0
- package/src/WebComponent/icons/BookTourOutlineIcon.ts +13 -0
- package/src/WebComponent/icons/CalculatorOutlineIcon.ts +22 -0
- package/src/WebComponent/icons/ChatOutlineIcon.ts +10 -0
- package/src/WebComponent/icons/ChevronLeftIcon.ts +7 -0
- package/src/WebComponent/icons/ChevronRightIcon.ts +7 -0
- package/src/WebComponent/icons/ContactResidentIcon.ts +9 -0
- package/src/WebComponent/icons/DollarOutlineIcon.ts +26 -0
- package/src/WebComponent/icons/EmailOutlineIcon.ts +7 -0
- package/src/WebComponent/icons/HeyThereEmojiIcon.ts +12 -0
- package/src/WebComponent/icons/PhoneOutlineIcon.ts +7 -0
- package/src/WebComponent/icons/SendMessageIcon.ts +17 -0
- package/src/WebComponent/icons/TourSelfGuidedIcon.ts +17 -0
- package/src/WebComponent/icons/TourVirtuallyIcon.ts +17 -0
- package/src/WebComponent/icons/TourWithAgentIcon.ts +17 -0
- package/src/WebComponent/icons/XOutlineIcon.ts +8 -0
- package/src/WebComponent/index.ts +2 -0
- package/src/WebComponent/launcher/Launcher.ts +1284 -0
- package/src/WebComponent/launcher/launcherStyles.ts +500 -0
- package/src/WebComponent/launcher/mobile-launcher.ts +162 -0
- package/src/WebComponent/launcher/typeEmojiStyles.ts +161 -0
- package/src/WebComponent/launcher/typeMiniStyles.ts +60 -0
- package/src/WebComponent/launcher/typeMobileStyles.ts +50 -0
- package/src/WebComponent/leasing-chat-styles.ts +114 -0
- package/src/WebComponent/loaders/index.ts +7 -0
- package/src/WebComponent/loaders/mega-loader.ts +36 -0
- package/src/WebComponent/loaders/skeleton-card.ts +31 -0
- package/src/WebComponent/loaders/skeleton-loader-styles.ts +112 -0
- package/src/WebComponent/loaders/skeleton-loader.ts +34 -0
- package/src/WebComponent/me-chat.ts +1264 -0
- package/src/WebComponent/me-select.ts +322 -0
- package/src/WebComponent/mini-loader.ts +28 -0
- package/src/WebComponent/pubnub-chat-styles.ts +204 -0
- package/src/WebComponent/pubnub-chat.ts +771 -0
- package/src/WebComponent/pubnub-media.ts +208 -0
- package/src/WebComponent/pubnub-message-styles.ts +54 -0
- package/src/WebComponent/pubnub-message.ts +431 -0
- package/src/WebComponent/simple-launcher/simple-launcher-styles.ts +34 -0
- package/src/WebComponent/simple-launcher/simple-launcher.ts +100 -0
- package/src/WebComponent/utilities-chat.ts +270 -0
- package/src/WebComponent/utilities-styles.ts +110 -0
- package/src/WebComponent/utils.ts +82 -0
- package/src/analytics.ts +217 -0
- package/src/assetUrls.ts +6 -0
- package/src/disclaimers.ts +301 -0
- package/src/fetchBuildingABTestType.ts +21 -0
- package/src/fetchBuildingInfo.ts +88 -0
- package/src/fetchBuildingWebchatView.ts +176 -0
- package/src/fetchFeatureFlag.ts +250 -0
- package/src/fetchLeadSources.ts +98 -0
- package/src/fetchPhoneNumberFromSource.ts +31 -0
- package/src/fetchWebchatPreferences.ts +54 -0
- package/src/getAvailabilities.ts +189 -0
- package/src/getBuildingPhoneNumber.ts +26 -0
- package/src/getShouldAllowScheduling.ts +16 -0
- package/src/getShouldShowWebchat.ts +114 -0
- package/src/getTimezoneString.ts +40 -0
- package/src/globals.ts +3 -0
- package/src/gtm.ts +17 -0
- package/src/handleChatId.ts +101 -0
- package/src/insertDNIIntoWebsite.ts +146 -0
- package/src/insertLeadSourceIntoSchedulerLinks.ts +71 -0
- package/src/main/MEChat.test.ts +110 -0
- package/src/main/MEChat.ts +404 -0
- package/src/main/utils.ts +70 -0
- package/src/postLeadSources.ts +44 -0
- package/src/rentgrata.ts +74 -0
- package/src/replaceSelectButtonsWithNewLink.ts +91 -0
- package/src/services/fees/calculateQuote.ts +74 -0
- package/src/services/fees/fetchBuildingFees.ts +50 -0
- package/src/services/fees/fetchBuildingFeesV2.ts +56 -0
- package/src/services/fees/fetchBuildingFloorplans.ts +74 -0
- package/src/services/fees/fetchBuildingUnits.ts +86 -0
- package/src/services/fees/utils.ts +4 -0
- package/src/svgIcons.ts +14 -0
- package/src/themes.ts +65 -0
- package/src/types/incentive-v2.ts +24 -0
- package/src/types/rest-sdk.types.ts +13 -0
- package/src/types/webchat-no-show-reason.ts +6 -0
- package/src/utils/getWidgetOverrides.ts +91 -0
- package/src/utils/queryParamBuilder.ts +28 -0
- package/src/utils.ts +121 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const ALLOW_OVERRIDE_DOMAINS = [
|
|
2
|
+
"app.meetelise.com",
|
|
3
|
+
"staging.eliseai.com",
|
|
4
|
+
"localhost",
|
|
5
|
+
];
|
|
6
|
+
|
|
7
|
+
const WIDGET_MAP = {
|
|
8
|
+
calculator: {
|
|
9
|
+
desktop: "calcDesktop",
|
|
10
|
+
mobile: "calcMobile",
|
|
11
|
+
},
|
|
12
|
+
email: {
|
|
13
|
+
desktop: "emailDesktop",
|
|
14
|
+
mobile: "emailMobile",
|
|
15
|
+
},
|
|
16
|
+
call: {
|
|
17
|
+
desktop: "callDesktop",
|
|
18
|
+
mobile: "callMobile",
|
|
19
|
+
},
|
|
20
|
+
text: {
|
|
21
|
+
desktop: "textDesktop",
|
|
22
|
+
mobile: "textMobile",
|
|
23
|
+
},
|
|
24
|
+
sst: {
|
|
25
|
+
desktop: "sstDesktop",
|
|
26
|
+
mobile: "sstMobile",
|
|
27
|
+
},
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
type WidgetType = keyof typeof WIDGET_MAP;
|
|
31
|
+
type WidgetOverrides = Partial<Record<WidgetType, boolean>>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Parse widget overrides from URL parameters.
|
|
35
|
+
*
|
|
36
|
+
* e.g.
|
|
37
|
+
* http://importantwebsite.com?widgets=calculator:true,email:false
|
|
38
|
+
*/
|
|
39
|
+
export const parseWidgetOverrides = (
|
|
40
|
+
widgetParam: string | null
|
|
41
|
+
): WidgetOverrides => {
|
|
42
|
+
if (!widgetParam) return {};
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
return widgetParam.split(",").reduce((acc, override) => {
|
|
46
|
+
const [widget, value] = override.split(":");
|
|
47
|
+
if (widget && value && widget in WIDGET_MAP) {
|
|
48
|
+
acc[widget as WidgetType] = value.toLowerCase() === "true";
|
|
49
|
+
}
|
|
50
|
+
return acc;
|
|
51
|
+
}, {} as WidgetOverrides);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.warn("Error parsing widget overrides:", error);
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type WidgetConfig = {
|
|
60
|
+
[key: string]: boolean | null;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get widget overrides from URL parameters and apply them to the enabled widgets configuration
|
|
65
|
+
*/
|
|
66
|
+
export const getWidgetOverrides = <T extends WidgetConfig>(
|
|
67
|
+
currentConfig: T
|
|
68
|
+
): T => {
|
|
69
|
+
const currentDomain = window.location.hostname;
|
|
70
|
+
if (!ALLOW_OVERRIDE_DOMAINS.includes(currentDomain)) return currentConfig;
|
|
71
|
+
|
|
72
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
73
|
+
const overrides = parseWidgetOverrides(urlParams.get("widgets"));
|
|
74
|
+
|
|
75
|
+
if (Object.keys(overrides).length === 0) return currentConfig;
|
|
76
|
+
|
|
77
|
+
const newConfig = { ...currentConfig } as T;
|
|
78
|
+
|
|
79
|
+
Object.entries(overrides).forEach(([widget, enabled]) => {
|
|
80
|
+
const properties = WIDGET_MAP[widget as WidgetType];
|
|
81
|
+
if (properties) {
|
|
82
|
+
(newConfig[properties.desktop] as boolean) = enabled;
|
|
83
|
+
(newConfig[properties.mobile] as boolean) = enabled;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line no-console
|
|
88
|
+
console.info("Applied widget overrides:", overrides);
|
|
89
|
+
|
|
90
|
+
return newConfig;
|
|
91
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class QueryParamBuilder {
|
|
2
|
+
private params: URLSearchParams;
|
|
3
|
+
|
|
4
|
+
constructor() {
|
|
5
|
+
this.params = new URLSearchParams();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
addSingle(key: string, value?: string): QueryParamBuilder {
|
|
9
|
+
if (!value) return this;
|
|
10
|
+
this.params.append(key, value);
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
addArray(key: string, values?: string[]): QueryParamBuilder {
|
|
15
|
+
if (!values) return this;
|
|
16
|
+
values.forEach((value) => {
|
|
17
|
+
if (!value) return;
|
|
18
|
+
this.params.append(`${key}[]`, value);
|
|
19
|
+
});
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
build(): string {
|
|
24
|
+
return this.params.toString() ? `?${this.params.toString()}` : "";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default QueryParamBuilder;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import camelCase from "lodash/camelCase";
|
|
2
|
+
import snakeCase from "lodash/snakeCase";
|
|
3
|
+
import isArray from "lodash/isArray";
|
|
4
|
+
import isObject from "lodash/isObject";
|
|
5
|
+
import transform from "lodash/transform";
|
|
6
|
+
import addHours from "date-fns/addHours";
|
|
7
|
+
import isBefore from "date-fns/isBefore";
|
|
8
|
+
import { BASE_DOMAIN } from "./globals";
|
|
9
|
+
|
|
10
|
+
export const camelize = <T>(
|
|
11
|
+
snakeCasedObject: Record<string, unknown>,
|
|
12
|
+
keysToExclude?: (string | number | symbol)[]
|
|
13
|
+
): T =>
|
|
14
|
+
transform(
|
|
15
|
+
snakeCasedObject,
|
|
16
|
+
(acc: Record<string, unknown>, value, key, target) => {
|
|
17
|
+
const camelKey = keysToExclude?.includes(key)
|
|
18
|
+
? key
|
|
19
|
+
: isArray(target)
|
|
20
|
+
? key
|
|
21
|
+
: camelCase(String(key));
|
|
22
|
+
|
|
23
|
+
acc[camelKey] = isObject(value)
|
|
24
|
+
? camelize(value as Record<string, unknown>, keysToExclude)
|
|
25
|
+
: value;
|
|
26
|
+
}
|
|
27
|
+
) as T;
|
|
28
|
+
|
|
29
|
+
export const snakify = <T>(
|
|
30
|
+
snakeCasedObject: Record<string, unknown>,
|
|
31
|
+
keysToExclude?: (string | number | symbol)[]
|
|
32
|
+
): T =>
|
|
33
|
+
transform(
|
|
34
|
+
snakeCasedObject,
|
|
35
|
+
(acc: Record<string, unknown>, value, key, target) => {
|
|
36
|
+
const snakeKey = keysToExclude?.includes(key)
|
|
37
|
+
? key
|
|
38
|
+
: isArray(target)
|
|
39
|
+
? key
|
|
40
|
+
: snakeCase(String(key));
|
|
41
|
+
|
|
42
|
+
acc[snakeKey] = isObject(value)
|
|
43
|
+
? snakify(value as Record<string, unknown>, keysToExclude)
|
|
44
|
+
: value;
|
|
45
|
+
}
|
|
46
|
+
) as T;
|
|
47
|
+
|
|
48
|
+
export const isMobile = (): boolean =>
|
|
49
|
+
window.matchMedia("(max-width: 767px)").matches ||
|
|
50
|
+
window.matchMedia("(max-height: 400px)").matches;
|
|
51
|
+
|
|
52
|
+
export const isTimestampExpired = (
|
|
53
|
+
timestamp: Date,
|
|
54
|
+
ttlHours: number
|
|
55
|
+
): boolean => {
|
|
56
|
+
const expirationDate = addHours(timestamp, ttlHours);
|
|
57
|
+
return isBefore(expirationDate, Date.now());
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const getCookieValue = (name: string): string | null => {
|
|
61
|
+
try {
|
|
62
|
+
const cookies = document.cookie.split("; ");
|
|
63
|
+
const cookiePair = cookies
|
|
64
|
+
.map((cookie) => cookie.split("="))
|
|
65
|
+
.find(([cookieName]) => cookieName === name);
|
|
66
|
+
|
|
67
|
+
return cookiePair ? decodeURIComponent(cookiePair[1]) : null;
|
|
68
|
+
} catch (e) {
|
|
69
|
+
// For debugging purposes if something happens on a client website
|
|
70
|
+
// eslint-disable-next-line no-console
|
|
71
|
+
console.warn(`Error getting cookie value for name=${name}`, e);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const isValidPhoneNumber = (phoneNumber: string): boolean => {
|
|
77
|
+
const phoneNumberRegex = /^\([2-9][0-8][0-9]\) [2-9][0-9][0-9]-[0-9]{4}$/;
|
|
78
|
+
return phoneNumberRegex.test(phoneNumber);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const isContainingEmail = (message: string): boolean => {
|
|
82
|
+
try {
|
|
83
|
+
const emailRegex = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b/;
|
|
84
|
+
return emailRegex.test(message);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
// eslint-disable-next-line no-console
|
|
87
|
+
console.warn(`Error checking if message contains email`, e);
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* FooBarBizzBazz -> Foo Bar Bizz Bazz
|
|
94
|
+
*/
|
|
95
|
+
export const sentenceTitleCase = (str: string): string => {
|
|
96
|
+
const spaced = str.replace(/([A-Z])/g, " $1").trim();
|
|
97
|
+
return spaced
|
|
98
|
+
.split(" ")
|
|
99
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
100
|
+
.join(" ");
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const formatCurrency = (
|
|
104
|
+
amount: number,
|
|
105
|
+
maximumFractionDigits = 0
|
|
106
|
+
): string => {
|
|
107
|
+
return Intl.NumberFormat("en-US", {
|
|
108
|
+
style: "currency",
|
|
109
|
+
currency: "USD",
|
|
110
|
+
minimumFractionDigits: 0,
|
|
111
|
+
maximumFractionDigits,
|
|
112
|
+
}).format(amount ?? 0);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const isTestEnv = (): boolean => {
|
|
116
|
+
const href = location.href;
|
|
117
|
+
if (href.startsWith(BASE_DOMAIN + "/settings/widgets")) return true;
|
|
118
|
+
if (href.startsWith(BASE_DOMAIN + "/demo")) return true;
|
|
119
|
+
if (href.startsWith("http://localhost")) return true;
|
|
120
|
+
return false;
|
|
121
|
+
};
|