@yext/visual-editor 1.4.11 → 2.0.0-beta.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/SectionLibraryVisualEditorProvider-67ng4X9e.js +108670 -0
- package/dist/SectionLibraryVisualEditorProvider.css +1 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/Address.tsx +251 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/HeadingText.tsx +147 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursStatus.tsx +157 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursTable.tsx +164 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/MapboxStaticMap.tsx +205 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/Phone.tsx +155 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/EmptyImageState.tsx +168 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/Image.tsx +275 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/styling.ts +66 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/index.ts +13 -0
- package/dist/cli/assets/directory-locator-source/components/sections/Breadcrumbs.tsx +298 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.test.tsx +872 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.tsx +260 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryCard.tsx +507 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryWrapper.tsx +491 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.test.tsx +226 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.tsx +98 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.test.tsx +147 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.tsx +691 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.test.tsx +1551 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.tsx +541 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorFields.test.ts +43 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorResultCard.tsx +1594 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorWrapper.tsx +1157 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Map.tsx +304 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/MapPinIcon.tsx +160 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Results.tsx +267 -0
- package/dist/cli/assets/directory-locator-source/sectionLibrarySupport.ts +245 -0
- package/dist/cli/yextve.js +16888 -0
- package/dist/index.d.ts +542 -6311
- package/dist/locales/page/cs/visual-editor.json +85 -0
- package/dist/locales/page/da/visual-editor.json +73 -0
- package/dist/locales/page/de/visual-editor.json +73 -0
- package/dist/locales/page/en/visual-editor.json +73 -0
- package/dist/locales/page/en-GB/visual-editor.json +73 -0
- package/dist/locales/page/es/visual-editor.json +79 -0
- package/dist/locales/page/et/visual-editor.json +73 -0
- package/dist/locales/page/fi/visual-editor.json +73 -0
- package/dist/locales/page/fr/visual-editor.json +79 -0
- package/dist/locales/page/hr/visual-editor.json +79 -0
- package/dist/locales/page/hu/visual-editor.json +73 -0
- package/dist/locales/page/it/visual-editor.json +79 -0
- package/dist/locales/page/ja/visual-editor.json +73 -0
- package/dist/locales/page/lt/visual-editor.json +85 -0
- package/dist/locales/page/lv/visual-editor.json +77 -0
- package/dist/locales/page/nb/visual-editor.json +73 -0
- package/dist/locales/page/nl/visual-editor.json +73 -0
- package/dist/locales/page/pl/visual-editor.json +85 -0
- package/dist/locales/page/pt/visual-editor.json +79 -0
- package/dist/locales/page/ro/visual-editor.json +79 -0
- package/dist/locales/page/sk/visual-editor.json +85 -0
- package/dist/locales/page/sv/visual-editor.json +73 -0
- package/dist/locales/page/tr/visual-editor.json +73 -0
- package/dist/locales/page/zh/visual-editor.json +73 -0
- package/dist/locales/page/zh-TW/visual-editor.json +73 -0
- package/dist/locales/platform/cs/visual-editor.json +531 -0
- package/dist/locales/platform/da/visual-editor.json +519 -0
- package/dist/locales/platform/de/visual-editor.json +519 -0
- package/dist/locales/platform/en/visual-editor.json +519 -0
- package/dist/locales/platform/en-GB/visual-editor.json +519 -0
- package/dist/locales/platform/es/visual-editor.json +525 -0
- package/dist/locales/platform/et/visual-editor.json +519 -0
- package/dist/locales/platform/fi/visual-editor.json +519 -0
- package/dist/locales/platform/fr/visual-editor.json +525 -0
- package/dist/locales/platform/hr/visual-editor.json +525 -0
- package/dist/locales/platform/hu/visual-editor.json +519 -0
- package/dist/locales/platform/it/visual-editor.json +525 -0
- package/dist/locales/platform/ja/visual-editor.json +519 -0
- package/dist/locales/platform/lt/visual-editor.json +531 -0
- package/dist/locales/platform/lv/visual-editor.json +523 -0
- package/dist/locales/platform/nb/visual-editor.json +519 -0
- package/dist/locales/platform/nl/visual-editor.json +519 -0
- package/dist/locales/platform/pl/visual-editor.json +531 -0
- package/dist/locales/platform/pt/visual-editor.json +525 -0
- package/dist/locales/platform/ro/visual-editor.json +525 -0
- package/dist/locales/platform/sk/visual-editor.json +531 -0
- package/dist/locales/platform/sv/visual-editor.json +519 -0
- package/dist/locales/platform/tr/visual-editor.json +519 -0
- package/dist/locales/platform/zh/visual-editor.json +519 -0
- package/dist/locales/platform/zh-TW/visual-editor.json +519 -0
- package/dist/locatorEntityTypes-s4dmT9l5.d.ts +1850 -0
- package/dist/plugin/internal/sectionLibraryValidation/builtInTranslationResources.d.ts +3 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/api/api.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/api/libraryMetadata.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/code/importRules.d.ts +13 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/code/validateCode.d.ts +10 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/code/xssRules.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/structure/structure.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/types.d.ts +48 -0
- package/dist/plugin/internal/sectionLibraryValidation/validateSectionLibrary.d.ts +8 -0
- package/dist/plugin/internal/sectionLibraryValidation/validationError.d.ts +6 -0
- package/dist/plugin/plugin.js +2233 -5786
- package/dist/plugin/types/entityFields.d.ts +21 -0
- package/dist/plugin/types/images.d.ts +62 -0
- package/dist/plugin/types/sectionLibrary.d.ts +94 -0
- package/dist/plugin/types/types.d.ts +204 -0
- package/dist/plugin/types/videos.d.ts +24 -0
- package/dist/plugin/utils/i18n/locales.d.ts +5 -0
- package/dist/plugin/utils/i18n/translationResources.d.ts +41 -0
- package/dist/plugin/utils/normalizeLocale.d.ts +8 -0
- package/dist/plugin/utils/plainText.d.ts +6 -0
- package/dist/plugin/vite-plugin/index.d.ts +2 -0
- package/dist/plugin/vite-plugin/local-editor/artifacts.d.ts +18 -0
- package/dist/plugin/vite-plugin/local-editor/config.d.ts +11 -0
- package/dist/plugin/vite-plugin/local-editor/data.d.ts +10 -0
- package/dist/plugin/vite-plugin/local-editor/entityFields.d.ts +13 -0
- package/dist/plugin/vite-plugin/local-editor/fixtureData.d.ts +12 -0
- package/dist/plugin/vite-plugin/local-editor/generatedFiles.d.ts +34 -0
- package/dist/plugin/vite-plugin/local-editor/server.d.ts +18 -0
- package/dist/plugin/vite-plugin/local-editor/types.d.ts +109 -0
- package/dist/plugin/vite-plugin/local-editor/utils.d.ts +16 -0
- package/dist/plugin/vite-plugin/plugin.d.ts +8 -0
- package/dist/plugin/vite-plugin/section-library/migrationRegistry.d.ts +6 -0
- package/dist/plugin/vite-plugin/section-library/sectionFrontmatter.d.ts +3 -0
- package/dist/plugin/vite-plugin/section-library/sectionLibraryGenerator.d.ts +21 -0
- package/dist/plugin/vite-plugin/section-library/sharedComponentRegistry.d.ts +16 -0
- package/dist/section-library-support.js +158 -0
- package/dist/sectionLibrarySupport.d.ts +282 -0
- package/dist/style.css +1 -1
- package/dist/visual-editor-9bLkRo2X.js +702 -0
- package/dist/visual-editor-B5f3AZF6.js +706 -0
- package/dist/visual-editor-BGZbJkMp.js +694 -0
- package/dist/visual-editor-BPVqHHz5.js +706 -0
- package/dist/visual-editor-BPvDMSb8.js +706 -0
- package/dist/visual-editor-BTT9n9b6.js +718 -0
- package/dist/visual-editor-BXSlgf31.js +694 -0
- package/dist/visual-editor-BXYlpe7B.js +145 -0
- package/dist/visual-editor-Bez9GftS.js +694 -0
- package/dist/visual-editor-Bk5QJccl.js +718 -0
- package/dist/visual-editor-BqtG2m0y.js +694 -0
- package/dist/visual-editor-Bxy81Ezy.js +145 -0
- package/dist/visual-editor-C00efXqJ.js +706 -0
- package/dist/visual-editor-C0vq2BRM.js +145 -0
- package/dist/visual-editor-CCgmYV5S.js +169 -0
- package/dist/visual-editor-CERViyTJ.js +145 -0
- package/dist/visual-editor-CZdmgAn0.js +706 -0
- package/dist/visual-editor-CcOCcCUQ.js +694 -0
- package/dist/visual-editor-CjORnP1D.js +169 -0
- package/dist/visual-editor-CmomGJB8.js +157 -0
- package/dist/visual-editor-Cymg8ID2.js +169 -0
- package/dist/visual-editor-D2Hk1nhM.js +145 -0
- package/dist/visual-editor-D2_8u6ZI.js +694 -0
- package/dist/visual-editor-D4vaqoBN.js +694 -0
- package/dist/visual-editor-D6n8EP_O.js +694 -0
- package/dist/visual-editor-D8MRFn5x.js +157 -0
- package/dist/visual-editor-DKG_E7X4.js +694 -0
- package/dist/visual-editor-DOXtCqRv.js +145 -0
- package/dist/visual-editor-DQEd3xwY.js +145 -0
- package/dist/visual-editor-DQq0_rUn.js +706 -0
- package/dist/visual-editor-DRXezaoB.js +694 -0
- package/dist/visual-editor-DUngIOnE.js +157 -0
- package/dist/visual-editor-DbgFzBNV.js +718 -0
- package/dist/visual-editor-DeZVZYfd.js +169 -0
- package/dist/visual-editor-DfJMZpiP.js +145 -0
- package/dist/visual-editor-DgAsQK9D.js +145 -0
- package/dist/visual-editor-Dhi__-7_.js +145 -0
- package/dist/visual-editor-DiLdoISr.js +718 -0
- package/dist/visual-editor-DjdqpJU-.js +145 -0
- package/dist/visual-editor-DnTPMRV4.js +694 -0
- package/dist/visual-editor-DvuH3jyL.js +157 -0
- package/dist/visual-editor-E0hASBXn.js +694 -0
- package/dist/visual-editor-TfVDfO5_.js +145 -0
- package/dist/visual-editor-W1OHU94y.js +694 -0
- package/dist/visual-editor-W_ZDmMFn.js +145 -0
- package/dist/visual-editor-b7ALusk8.js +145 -0
- package/dist/visual-editor-bauJ9beX.js +694 -0
- package/dist/visual-editor-erGXf3kS.js +157 -0
- package/dist/visual-editor-xnDHZFuO.js +153 -0
- package/dist/visual-editor-yiWZqIH0.js +157 -0
- package/dist/visual-editor.css +1 -0
- package/dist/visual-editor.js +15074 -137463
- package/package.json +46 -25
- package/dist/editor.css +0 -1
- package/dist/visual-editor-1QC8zZX_.js +0 -221
- package/dist/visual-editor-5C5XV5rL.js +0 -221
- package/dist/visual-editor-B8-FoFxc.js +0 -1049
- package/dist/visual-editor-BJgCpnYV.js +0 -1073
- package/dist/visual-editor-BKLiin5z.js +0 -1049
- package/dist/visual-editor-BWbqw_QE.js +0 -233
- package/dist/visual-editor-Bb6upvTE.js +0 -221
- package/dist/visual-editor-BcZCBLFh.js +0 -1049
- package/dist/visual-editor-BecDYKH8.js +0 -1049
- package/dist/visual-editor-BllAUu_T.js +0 -1073
- package/dist/visual-editor-BmaYFuCe.js +0 -233
- package/dist/visual-editor-BnPFkJlo.js +0 -221
- package/dist/visual-editor-BoIXa-xl.js +0 -245
- package/dist/visual-editor-BtDJICJp.js +0 -1073
- package/dist/visual-editor-BwxWyr_L.js +0 -221
- package/dist/visual-editor-Bz7BlR_j.js +0 -221
- package/dist/visual-editor-CC0RAmib.js +0 -1049
- package/dist/visual-editor-CDY9slY9.js +0 -1061
- package/dist/visual-editor-CFebs6R8.js +0 -1049
- package/dist/visual-editor-CNL0HyVh.js +0 -1049
- package/dist/visual-editor-CYnzwNwX.js +0 -229
- package/dist/visual-editor-CZH605TK.js +0 -233
- package/dist/visual-editor-Cada46ZF.js +0 -1049
- package/dist/visual-editor-CheComxC.js +0 -1061
- package/dist/visual-editor-CuA8h_Xv.js +0 -221
- package/dist/visual-editor-CuRmgs-p.js +0 -245
- package/dist/visual-editor-D9_YWQQY.js +0 -1073
- package/dist/visual-editor-D9w4wRG8.js +0 -245
- package/dist/visual-editor-D9xTiOC0.js +0 -221
- package/dist/visual-editor-DA7CixSl.js +0 -1061
- package/dist/visual-editor-DAnBQ9H_.js +0 -221
- package/dist/visual-editor-DF8RsMvq.js +0 -233
- package/dist/visual-editor-DLrKYx7j.js +0 -1061
- package/dist/visual-editor-DQJc_Xok.js +0 -233
- package/dist/visual-editor-DTZFGKm7.js +0 -221
- package/dist/visual-editor-DXebihTA.js +0 -233
- package/dist/visual-editor-DZ4U1fk-.js +0 -221
- package/dist/visual-editor-Dg7P-vDv.js +0 -1057
- package/dist/visual-editor-Dh2cuwWt.js +0 -1049
- package/dist/visual-editor-DpetyO9o.js +0 -1049
- package/dist/visual-editor-Duav2tXb.js +0 -1061
- package/dist/visual-editor-DvYsu_s9.js +0 -221
- package/dist/visual-editor-DwlX3nnZ.js +0 -221
- package/dist/visual-editor-Dz5s66Og.js +0 -221
- package/dist/visual-editor-E57fPJMD.js +0 -1049
- package/dist/visual-editor-Fy_uEJju.js +0 -1061
- package/dist/visual-editor-G8e2TllW.js +0 -1049
- package/dist/visual-editor-HkfpXRw7.js +0 -1049
- package/dist/visual-editor-ZKG4e_Ey.js +0 -1049
- package/dist/visual-editor-rZRnDwgU.js +0 -245
package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorResultCard.tsx
ADDED
|
@@ -0,0 +1,1594 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Trans, useTranslation } from "react-i18next";
|
|
3
|
+
import {
|
|
4
|
+
CardProps,
|
|
5
|
+
Coordinate,
|
|
6
|
+
useCardAnalyticsCallback,
|
|
7
|
+
} from "@yext/search-ui-react";
|
|
8
|
+
import { Background } from "../../atoms/background.tsx";
|
|
9
|
+
import {
|
|
10
|
+
backgroundColors,
|
|
11
|
+
ThemeColor,
|
|
12
|
+
HeadingLevel,
|
|
13
|
+
ThemeOptions,
|
|
14
|
+
} from "../../../utils/themeConfigOptions.ts";
|
|
15
|
+
import { Body, BodyProps } from "../../atoms/body.tsx";
|
|
16
|
+
import { CTA, CTAVariant } from "../../atoms/cta.tsx";
|
|
17
|
+
import { Heading } from "../../atoms/heading.tsx";
|
|
18
|
+
import { Image } from "../../atoms/image.tsx";
|
|
19
|
+
import { msg, pt } from "../../../utils/i18n/platform.ts";
|
|
20
|
+
import { PhoneAtom } from "../../atoms/phone.tsx";
|
|
21
|
+
import { useTemplateProps } from "../../../hooks/useDocument.tsx";
|
|
22
|
+
import { resolveComponentData } from "../../../utils/resolveComponentData.tsx";
|
|
23
|
+
import { HoursStatusAtom } from "../../atoms/hoursStatus.tsx";
|
|
24
|
+
import { HoursTableAtom } from "../../atoms/hoursTable.tsx";
|
|
25
|
+
import { type BasicSelectorField } from "../../../fields/BasicSelectorField.tsx";
|
|
26
|
+
import type {
|
|
27
|
+
YextCustomFieldRenderProps,
|
|
28
|
+
YextObjectField,
|
|
29
|
+
} from "../../../fields/fields.ts";
|
|
30
|
+
import {
|
|
31
|
+
buildLocatorDisplayOptions,
|
|
32
|
+
type ImageField,
|
|
33
|
+
} from "../../../fields/ImageField.tsx";
|
|
34
|
+
import { ConstantValueModeToggler } from "../../../fields/EntityFieldSelectorField.tsx";
|
|
35
|
+
import { type EmbeddedStringOption } from "../../../editor/EmbeddedFieldStringInput.tsx";
|
|
36
|
+
import { TranslatableString } from "../../../types/types.ts";
|
|
37
|
+
import { TranslatableAssetImage } from "../../../types/images.ts";
|
|
38
|
+
import {
|
|
39
|
+
Address,
|
|
40
|
+
AddressType,
|
|
41
|
+
getDirections,
|
|
42
|
+
HoursType,
|
|
43
|
+
ListingType,
|
|
44
|
+
} from "@yext/pages-components";
|
|
45
|
+
import {
|
|
46
|
+
HoursTableProps,
|
|
47
|
+
HoursTableStyleFields,
|
|
48
|
+
} from "../../contentBlocks/HoursTable.tsx";
|
|
49
|
+
import { getImageUrl } from "../../contentBlocks/image/Image.tsx";
|
|
50
|
+
import {
|
|
51
|
+
Accordion,
|
|
52
|
+
AccordionContent,
|
|
53
|
+
AccordionItem,
|
|
54
|
+
AccordionTrigger,
|
|
55
|
+
} from "../../atoms/accordion.js";
|
|
56
|
+
import {
|
|
57
|
+
FaAngleRight,
|
|
58
|
+
FaMapMarkerAlt,
|
|
59
|
+
FaRegClock,
|
|
60
|
+
FaRegEnvelope,
|
|
61
|
+
} from "react-icons/fa";
|
|
62
|
+
import { useTemplateMetadata } from "../../../internal/hooks/useMessageReceivers.ts";
|
|
63
|
+
import { FieldTypeData } from "../../../internal/types/templateMetadata.ts";
|
|
64
|
+
import {
|
|
65
|
+
formatDistance,
|
|
66
|
+
fromMeters,
|
|
67
|
+
getPreferredDistanceUnit,
|
|
68
|
+
} from "../../../utils/i18n/distance.ts";
|
|
69
|
+
import {
|
|
70
|
+
DEFAULT_ENTITY_TYPE,
|
|
71
|
+
LocatorEntityType,
|
|
72
|
+
} from "../../../utils/locatorEntityTypes.ts";
|
|
73
|
+
import { resolveLocatorResultUrl } from "../../../utils/urls/resolveLocatorResultUrl.ts";
|
|
74
|
+
import {
|
|
75
|
+
getBackgroundColorClasses,
|
|
76
|
+
getBackgroundColorStyle,
|
|
77
|
+
getTextColorClass,
|
|
78
|
+
getTextColorStyle,
|
|
79
|
+
} from "../../../utils/colors.ts";
|
|
80
|
+
import { themeManagerCn } from "../../../utils/cn.ts";
|
|
81
|
+
|
|
82
|
+
export interface LocatorResultCardProps {
|
|
83
|
+
/** The entity type this result card applies to. */
|
|
84
|
+
entityType: LocatorEntityType;
|
|
85
|
+
|
|
86
|
+
/** Settings for the main heading of the card */
|
|
87
|
+
primaryHeading: {
|
|
88
|
+
/**
|
|
89
|
+
* The field from the data to use for the primary heading
|
|
90
|
+
* @defaultValue "name"
|
|
91
|
+
*/
|
|
92
|
+
field?: string;
|
|
93
|
+
/** Static value for the primary heading */
|
|
94
|
+
constantValue?: TranslatableString;
|
|
95
|
+
/** Whether to use the static value for the primary heading */
|
|
96
|
+
constantValueEnabled?: boolean;
|
|
97
|
+
/** Static text to display when the selected boolean field is true */
|
|
98
|
+
trueDisplayText?: TranslatableString;
|
|
99
|
+
/** Static text to display when the selected boolean field is false */
|
|
100
|
+
falseDisplayText?: TranslatableString;
|
|
101
|
+
/** The heading level for the primary heading */
|
|
102
|
+
headingLevel: HeadingLevel;
|
|
103
|
+
/**
|
|
104
|
+
* The color applied to the primary heading text
|
|
105
|
+
* @defaultValue inherited from theme
|
|
106
|
+
*/
|
|
107
|
+
color?: ThemeColor;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/** Settings for the secondary heading of the card */
|
|
111
|
+
secondaryHeading: {
|
|
112
|
+
/** The field from the data to use for the secondary heading */
|
|
113
|
+
field?: string;
|
|
114
|
+
/** Static value for the secondary heading */
|
|
115
|
+
constantValue?: TranslatableString;
|
|
116
|
+
/** Whether to use the static value for the secondary heading */
|
|
117
|
+
constantValueEnabled?: boolean;
|
|
118
|
+
/** Static text to display when the selected boolean field is true */
|
|
119
|
+
trueDisplayText?: TranslatableString;
|
|
120
|
+
/** Static text to display when the selected boolean field is false */
|
|
121
|
+
falseDisplayText?: TranslatableString;
|
|
122
|
+
/** The variant for the secondary heading */
|
|
123
|
+
variant: BodyProps["variant"];
|
|
124
|
+
/** Whether the secondary heading is visible in live mode */
|
|
125
|
+
liveVisibility: boolean;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/** Settings for the tertiary heading of the card */
|
|
129
|
+
tertiaryHeading: {
|
|
130
|
+
/** The field from the data to use for the tertiary heading */
|
|
131
|
+
field?: string;
|
|
132
|
+
/** Static value for the tertiary heading */
|
|
133
|
+
constantValue?: TranslatableString;
|
|
134
|
+
/** Whether to use the static value for the tertiary heading */
|
|
135
|
+
constantValueEnabled?: boolean;
|
|
136
|
+
/** Static text to display when the selected boolean field is true */
|
|
137
|
+
trueDisplayText?: TranslatableString;
|
|
138
|
+
/** Static text to display when the selected boolean field is false */
|
|
139
|
+
falseDisplayText?: TranslatableString;
|
|
140
|
+
/** The variant for the tertiary heading */
|
|
141
|
+
variant: BodyProps["variant"];
|
|
142
|
+
/** Whether the tertiary heading is visible in live mode */
|
|
143
|
+
liveVisibility: boolean;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** Whether to show icons for certain fields */
|
|
147
|
+
icons: boolean;
|
|
148
|
+
|
|
149
|
+
/** The accent color used for icon backgrounds and contact/action links. */
|
|
150
|
+
accentColor?: ThemeColor;
|
|
151
|
+
|
|
152
|
+
/** Settings for the hours block */
|
|
153
|
+
hours: {
|
|
154
|
+
/** The field from the data to use for the hours */
|
|
155
|
+
field?: string;
|
|
156
|
+
/** Styles for the hours table */
|
|
157
|
+
table: Omit<HoursTableProps["styles"], "alignment">;
|
|
158
|
+
/** Whether the hours block is visible in live mode */
|
|
159
|
+
liveVisibility: boolean;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/** Settings for the address block */
|
|
163
|
+
address: {
|
|
164
|
+
/**
|
|
165
|
+
* Whether to include the region in the Address
|
|
166
|
+
* @defaultValue true
|
|
167
|
+
*/
|
|
168
|
+
showRegion?: boolean;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Whether to include the country in the Address
|
|
172
|
+
* @defaultValue false
|
|
173
|
+
*/
|
|
174
|
+
showCountry?: boolean;
|
|
175
|
+
|
|
176
|
+
/** Whether to show the "Get Directions" link */
|
|
177
|
+
showGetDirectionsLink: boolean;
|
|
178
|
+
|
|
179
|
+
/** Whether the address block is visible in live mode */
|
|
180
|
+
liveVisibility: boolean;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/** Settings for the phone block */
|
|
184
|
+
phone: {
|
|
185
|
+
/**
|
|
186
|
+
* The field from the data to use for the phone number
|
|
187
|
+
* @defaultValue "mainPhone"
|
|
188
|
+
*/
|
|
189
|
+
field?: string;
|
|
190
|
+
/**
|
|
191
|
+
* The format to use for the phone number
|
|
192
|
+
* @defaultValue "domestic"
|
|
193
|
+
*/
|
|
194
|
+
phoneFormat: "domestic" | "international";
|
|
195
|
+
/** Whether to include a hyperlink for the phone number */
|
|
196
|
+
includePhoneHyperlink: boolean;
|
|
197
|
+
/** Whether the phone block is visible in live mode */
|
|
198
|
+
liveVisibility: boolean;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/** Settings for the email block */
|
|
202
|
+
email: {
|
|
203
|
+
/**
|
|
204
|
+
* The field from the data to use for the email address
|
|
205
|
+
* @defaultValue "emails"
|
|
206
|
+
*/
|
|
207
|
+
field?: string;
|
|
208
|
+
/** Whether the email block is visible in live mode */
|
|
209
|
+
liveVisibility: boolean;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/** Settings for the services block */
|
|
213
|
+
services: {
|
|
214
|
+
/**The field from the data to use for the services
|
|
215
|
+
* @defaultValue "services"
|
|
216
|
+
*/
|
|
217
|
+
field?: string;
|
|
218
|
+
/** Whether the services block is visible in live mode */
|
|
219
|
+
liveVisibility: boolean;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/** Settings for the primary CTA */
|
|
223
|
+
primaryCTA: {
|
|
224
|
+
/** Label for the primary CTA */
|
|
225
|
+
label: TranslatableString;
|
|
226
|
+
/** Whether the primary CTA link should be normalized before rendering */
|
|
227
|
+
normalizeLink: boolean;
|
|
228
|
+
/** The variant for the primary CTA */
|
|
229
|
+
variant: CTAVariant;
|
|
230
|
+
/** Whether the primary CTA is visible in live mode */
|
|
231
|
+
liveVisibility: boolean;
|
|
232
|
+
/** Static URL to use for primary CTA when an entity page URL is not found */
|
|
233
|
+
link?: TranslatableString;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/** Settings for the secondary CTA */
|
|
237
|
+
secondaryCTA: {
|
|
238
|
+
/** Label for the secondary CTA */
|
|
239
|
+
label: TranslatableString;
|
|
240
|
+
/** Template for the secondary CTA link, which can contain entity field references */
|
|
241
|
+
link: TranslatableString;
|
|
242
|
+
/** Whether the secondary CTA link should be normalized before rendering */
|
|
243
|
+
normalizeLink: boolean;
|
|
244
|
+
/** The variant for the secondary CTA */
|
|
245
|
+
variant: CTAVariant;
|
|
246
|
+
/** Whether the secondary CTA is visible in live mode */
|
|
247
|
+
liveVisibility: boolean;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/** Settings for the image */
|
|
251
|
+
image: {
|
|
252
|
+
/** The field from the data to use for the image */
|
|
253
|
+
field?: string;
|
|
254
|
+
/** Static value for the image */
|
|
255
|
+
constantValue?: TranslatableAssetImage;
|
|
256
|
+
/** Whether to use the static value for the image */
|
|
257
|
+
constantValueEnabled?: boolean;
|
|
258
|
+
/** Whether the image block is visible in live mode */
|
|
259
|
+
liveVisibility: boolean;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export type DistanceDisplayOption =
|
|
264
|
+
"distanceFromUser" | "distanceFromSearch" | "bothDistances" | "hidden";
|
|
265
|
+
|
|
266
|
+
export const DEFAULT_LOCATOR_RESULT_CARD_PROPS: LocatorResultCardProps = {
|
|
267
|
+
entityType: DEFAULT_ENTITY_TYPE,
|
|
268
|
+
primaryHeading: {
|
|
269
|
+
field: "name",
|
|
270
|
+
constantValue: "",
|
|
271
|
+
constantValueEnabled: false,
|
|
272
|
+
headingLevel: 3,
|
|
273
|
+
},
|
|
274
|
+
secondaryHeading: {
|
|
275
|
+
field: "name",
|
|
276
|
+
constantValue: "",
|
|
277
|
+
constantValueEnabled: false,
|
|
278
|
+
variant: "base",
|
|
279
|
+
liveVisibility: false,
|
|
280
|
+
},
|
|
281
|
+
tertiaryHeading: {
|
|
282
|
+
field: "name",
|
|
283
|
+
constantValue: "",
|
|
284
|
+
constantValueEnabled: false,
|
|
285
|
+
variant: "base",
|
|
286
|
+
liveVisibility: false,
|
|
287
|
+
},
|
|
288
|
+
icons: true,
|
|
289
|
+
hours: {
|
|
290
|
+
field: "hours",
|
|
291
|
+
table: {
|
|
292
|
+
startOfWeek: "today",
|
|
293
|
+
collapseDays: false,
|
|
294
|
+
showAdditionalHoursText: false,
|
|
295
|
+
},
|
|
296
|
+
liveVisibility: true,
|
|
297
|
+
},
|
|
298
|
+
address: {
|
|
299
|
+
showRegion: true,
|
|
300
|
+
showCountry: false,
|
|
301
|
+
showGetDirectionsLink: true,
|
|
302
|
+
liveVisibility: true,
|
|
303
|
+
},
|
|
304
|
+
phone: {
|
|
305
|
+
field: "mainPhone",
|
|
306
|
+
phoneFormat: "domestic",
|
|
307
|
+
includePhoneHyperlink: true,
|
|
308
|
+
liveVisibility: true,
|
|
309
|
+
},
|
|
310
|
+
email: {
|
|
311
|
+
field: "emails",
|
|
312
|
+
liveVisibility: false,
|
|
313
|
+
},
|
|
314
|
+
services: {
|
|
315
|
+
field: "services",
|
|
316
|
+
liveVisibility: false,
|
|
317
|
+
},
|
|
318
|
+
primaryCTA: {
|
|
319
|
+
label: "Visit Page",
|
|
320
|
+
normalizeLink: true,
|
|
321
|
+
variant: "primary",
|
|
322
|
+
liveVisibility: true,
|
|
323
|
+
},
|
|
324
|
+
secondaryCTA: {
|
|
325
|
+
label: "Call to Action",
|
|
326
|
+
link: "#",
|
|
327
|
+
normalizeLink: true,
|
|
328
|
+
variant: "secondary",
|
|
329
|
+
liveVisibility: false,
|
|
330
|
+
},
|
|
331
|
+
image: {
|
|
332
|
+
field: "headshot",
|
|
333
|
+
constantValue: {
|
|
334
|
+
url: "",
|
|
335
|
+
height: 0,
|
|
336
|
+
width: 0,
|
|
337
|
+
},
|
|
338
|
+
constantValueEnabled: false,
|
|
339
|
+
liveVisibility: false,
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const LOCATOR_IMAGE_CONSTANT_CONFIG: ImageField = {
|
|
344
|
+
type: "image",
|
|
345
|
+
label: msg("fields.image", "Image"),
|
|
346
|
+
getAltTextOptions: (templateMetadata) =>
|
|
347
|
+
buildLocatorDisplayOptions(templateMetadata?.locatorDisplayFields),
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const getDisplayFieldOptions = (
|
|
351
|
+
fieldTypeId: string | string[]
|
|
352
|
+
): EmbeddedStringOption[] => {
|
|
353
|
+
// TODO: This breaks the rule of hooks, refactor the custom render path
|
|
354
|
+
const templateMetadata = useTemplateMetadata();
|
|
355
|
+
if (!templateMetadata?.locatorDisplayFields) {
|
|
356
|
+
return [];
|
|
357
|
+
}
|
|
358
|
+
const displayFields = templateMetadata.locatorDisplayFields;
|
|
359
|
+
const fieldTypeIds = Array.isArray(fieldTypeId) ? fieldTypeId : [fieldTypeId];
|
|
360
|
+
return Object.keys(templateMetadata.locatorDisplayFields)
|
|
361
|
+
.filter((key) => fieldTypeIds.includes(displayFields[key].field_type_id))
|
|
362
|
+
.map((key) => {
|
|
363
|
+
const fieldData: FieldTypeData = displayFields[key];
|
|
364
|
+
return {
|
|
365
|
+
label: fieldData.field_name,
|
|
366
|
+
value: key,
|
|
367
|
+
};
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
const DisplayFieldSelector = (
|
|
372
|
+
fieldTypeId: string | string[]
|
|
373
|
+
): BasicSelectorField => ({
|
|
374
|
+
type: "basicSelector",
|
|
375
|
+
label: msg("fields.field", "Field"),
|
|
376
|
+
options: () => getDisplayFieldOptions(fieldTypeId),
|
|
377
|
+
translateOptions: false,
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
export const LocatorResultCardFields: YextObjectField<LocatorResultCardProps> =
|
|
381
|
+
{
|
|
382
|
+
label: msg("fields.resultCard", "Result Card"),
|
|
383
|
+
type: "object",
|
|
384
|
+
objectFields: {
|
|
385
|
+
entityType: {
|
|
386
|
+
label: msg("fields.entityType", "Entity Type"),
|
|
387
|
+
type: "text",
|
|
388
|
+
visible: false,
|
|
389
|
+
},
|
|
390
|
+
primaryHeading: {
|
|
391
|
+
label: msg("fields.primaryHeading", "Primary Heading"),
|
|
392
|
+
type: "object",
|
|
393
|
+
objectFields: {
|
|
394
|
+
constantValueEnabled: {
|
|
395
|
+
type: "custom",
|
|
396
|
+
render: ({
|
|
397
|
+
value,
|
|
398
|
+
onChange,
|
|
399
|
+
}: YextCustomFieldRenderProps<boolean | undefined>) => (
|
|
400
|
+
<ConstantValueModeToggler
|
|
401
|
+
fieldTypeFilter={["type.string"]}
|
|
402
|
+
constantValueEnabled={value ?? false}
|
|
403
|
+
toggleConstantValueEnabled={(constantValueEnabled) =>
|
|
404
|
+
onChange(constantValueEnabled)
|
|
405
|
+
}
|
|
406
|
+
label={pt(msg("fields.primaryHeading", "Primary Heading"))}
|
|
407
|
+
showLocale={true}
|
|
408
|
+
/>
|
|
409
|
+
),
|
|
410
|
+
},
|
|
411
|
+
constantValue: {
|
|
412
|
+
type: "translatableString",
|
|
413
|
+
showApplyAllOption: false,
|
|
414
|
+
showFieldSelector: true,
|
|
415
|
+
getOptions: () => getDisplayFieldOptions(["type.string"]),
|
|
416
|
+
},
|
|
417
|
+
field: DisplayFieldSelector(["type.string", "type.boolean"]),
|
|
418
|
+
trueDisplayText: {
|
|
419
|
+
type: "translatableString",
|
|
420
|
+
label: msg("fields.whenTrue", "When true"),
|
|
421
|
+
showApplyAllOption: false,
|
|
422
|
+
showFieldSelector: false,
|
|
423
|
+
},
|
|
424
|
+
falseDisplayText: {
|
|
425
|
+
type: "translatableString",
|
|
426
|
+
label: msg("fields.whenFalse", "When false"),
|
|
427
|
+
showApplyAllOption: false,
|
|
428
|
+
showFieldSelector: false,
|
|
429
|
+
},
|
|
430
|
+
headingLevel: {
|
|
431
|
+
type: "basicSelector",
|
|
432
|
+
label: msg("fields.headingLevel", "Heading Level"),
|
|
433
|
+
options: "HEADING_LEVEL",
|
|
434
|
+
},
|
|
435
|
+
color: {
|
|
436
|
+
type: "basicSelector",
|
|
437
|
+
label: msg("fields.color", "Color"),
|
|
438
|
+
options: "SITE_COLOR",
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
secondaryHeading: {
|
|
443
|
+
label: msg("fields.secondaryHeading", "Secondary Heading"),
|
|
444
|
+
type: "object",
|
|
445
|
+
objectFields: {
|
|
446
|
+
constantValueEnabled: {
|
|
447
|
+
type: "custom",
|
|
448
|
+
render: ({
|
|
449
|
+
value,
|
|
450
|
+
onChange,
|
|
451
|
+
}: YextCustomFieldRenderProps<boolean | undefined>) => (
|
|
452
|
+
<ConstantValueModeToggler
|
|
453
|
+
fieldTypeFilter={["type.string"]}
|
|
454
|
+
constantValueEnabled={value ?? false}
|
|
455
|
+
toggleConstantValueEnabled={(constantValueEnabled) =>
|
|
456
|
+
onChange(constantValueEnabled)
|
|
457
|
+
}
|
|
458
|
+
label={pt(msg("fields.secondaryHeading", "Secondary Heading"))}
|
|
459
|
+
showLocale={true}
|
|
460
|
+
/>
|
|
461
|
+
),
|
|
462
|
+
},
|
|
463
|
+
constantValue: {
|
|
464
|
+
type: "translatableString",
|
|
465
|
+
showApplyAllOption: false,
|
|
466
|
+
showFieldSelector: true,
|
|
467
|
+
getOptions: () => getDisplayFieldOptions(["type.string"]),
|
|
468
|
+
},
|
|
469
|
+
field: DisplayFieldSelector(["type.string", "type.boolean"]),
|
|
470
|
+
trueDisplayText: {
|
|
471
|
+
type: "translatableString",
|
|
472
|
+
label: msg("fields.whenTrue", "When true"),
|
|
473
|
+
showApplyAllOption: false,
|
|
474
|
+
showFieldSelector: false,
|
|
475
|
+
},
|
|
476
|
+
falseDisplayText: {
|
|
477
|
+
type: "translatableString",
|
|
478
|
+
label: msg("fields.whenFalse", "When false"),
|
|
479
|
+
showApplyAllOption: false,
|
|
480
|
+
showFieldSelector: false,
|
|
481
|
+
},
|
|
482
|
+
variant: {
|
|
483
|
+
label: msg("fields.variant", "Variant"),
|
|
484
|
+
type: "radio",
|
|
485
|
+
options: ThemeOptions.BODY_VARIANT,
|
|
486
|
+
},
|
|
487
|
+
liveVisibility: {
|
|
488
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
489
|
+
type: "radio",
|
|
490
|
+
options: [
|
|
491
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
492
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
493
|
+
],
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
tertiaryHeading: {
|
|
498
|
+
label: msg("fields.tertiaryHeading", "Tertiary Heading"),
|
|
499
|
+
type: "object",
|
|
500
|
+
objectFields: {
|
|
501
|
+
constantValueEnabled: {
|
|
502
|
+
type: "custom",
|
|
503
|
+
render: ({
|
|
504
|
+
value,
|
|
505
|
+
onChange,
|
|
506
|
+
}: YextCustomFieldRenderProps<boolean | undefined>) => (
|
|
507
|
+
<ConstantValueModeToggler
|
|
508
|
+
fieldTypeFilter={["type.string"]}
|
|
509
|
+
constantValueEnabled={value ?? false}
|
|
510
|
+
toggleConstantValueEnabled={(constantValueEnabled) =>
|
|
511
|
+
onChange(constantValueEnabled)
|
|
512
|
+
}
|
|
513
|
+
label={pt(msg("fields.tertiaryHeading", "Tertiary Heading"))}
|
|
514
|
+
showLocale={true}
|
|
515
|
+
/>
|
|
516
|
+
),
|
|
517
|
+
},
|
|
518
|
+
constantValue: {
|
|
519
|
+
type: "translatableString",
|
|
520
|
+
showApplyAllOption: false,
|
|
521
|
+
showFieldSelector: true,
|
|
522
|
+
getOptions: () => getDisplayFieldOptions(["type.string"]),
|
|
523
|
+
},
|
|
524
|
+
field: DisplayFieldSelector(["type.string", "type.boolean"]),
|
|
525
|
+
trueDisplayText: {
|
|
526
|
+
type: "translatableString",
|
|
527
|
+
label: msg("fields.whenTrue", "When true"),
|
|
528
|
+
showApplyAllOption: false,
|
|
529
|
+
showFieldSelector: false,
|
|
530
|
+
},
|
|
531
|
+
falseDisplayText: {
|
|
532
|
+
type: "translatableString",
|
|
533
|
+
label: msg("fields.whenFalse", "When false"),
|
|
534
|
+
showApplyAllOption: false,
|
|
535
|
+
showFieldSelector: false,
|
|
536
|
+
},
|
|
537
|
+
variant: {
|
|
538
|
+
label: msg("fields.variant", "Variant"),
|
|
539
|
+
type: "radio",
|
|
540
|
+
options: ThemeOptions.BODY_VARIANT,
|
|
541
|
+
},
|
|
542
|
+
liveVisibility: {
|
|
543
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
544
|
+
type: "radio",
|
|
545
|
+
options: [
|
|
546
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
547
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
548
|
+
],
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
icons: {
|
|
553
|
+
label: msg("fields.icons", "Icons"),
|
|
554
|
+
type: "radio",
|
|
555
|
+
options: [
|
|
556
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
557
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
558
|
+
],
|
|
559
|
+
},
|
|
560
|
+
accentColor: {
|
|
561
|
+
type: "basicSelector",
|
|
562
|
+
label: msg("fields.accentColor", "Accent Color"),
|
|
563
|
+
options: "SITE_COLOR",
|
|
564
|
+
},
|
|
565
|
+
hours: {
|
|
566
|
+
label: msg("fields.hours", "Hours"),
|
|
567
|
+
type: "object",
|
|
568
|
+
objectFields: {
|
|
569
|
+
field: DisplayFieldSelector("type.hours"),
|
|
570
|
+
table: {
|
|
571
|
+
type: "object",
|
|
572
|
+
label: msg("fields.hoursColumn", "Hours Column"),
|
|
573
|
+
objectFields: HoursTableStyleFields,
|
|
574
|
+
},
|
|
575
|
+
liveVisibility: {
|
|
576
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
577
|
+
type: "radio",
|
|
578
|
+
options: [
|
|
579
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
580
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
581
|
+
],
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
},
|
|
585
|
+
address: {
|
|
586
|
+
label: msg("fields.address", "Address"),
|
|
587
|
+
type: "object",
|
|
588
|
+
objectFields: {
|
|
589
|
+
showRegion: {
|
|
590
|
+
label: msg("fields.showRegion", "Show Region"),
|
|
591
|
+
type: "radio",
|
|
592
|
+
options: [
|
|
593
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
594
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
595
|
+
],
|
|
596
|
+
},
|
|
597
|
+
showCountry: {
|
|
598
|
+
label: msg("fields.showCountry", "Show Country"),
|
|
599
|
+
type: "radio",
|
|
600
|
+
options: [
|
|
601
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
602
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
603
|
+
],
|
|
604
|
+
},
|
|
605
|
+
showGetDirectionsLink: {
|
|
606
|
+
label: msg(
|
|
607
|
+
"fields.showGetDirectionsLink",
|
|
608
|
+
"Show Get Directions Link"
|
|
609
|
+
),
|
|
610
|
+
type: "radio",
|
|
611
|
+
options: [
|
|
612
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
613
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
614
|
+
],
|
|
615
|
+
},
|
|
616
|
+
liveVisibility: {
|
|
617
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
618
|
+
type: "radio",
|
|
619
|
+
options: [
|
|
620
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
621
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
622
|
+
],
|
|
623
|
+
},
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
phone: {
|
|
627
|
+
label: msg("fields.phone", "Phone"),
|
|
628
|
+
type: "object",
|
|
629
|
+
objectFields: {
|
|
630
|
+
field: DisplayFieldSelector("type.phone"),
|
|
631
|
+
phoneFormat: {
|
|
632
|
+
label: msg("fields.phoneFormat", "Phone Format"),
|
|
633
|
+
type: "radio",
|
|
634
|
+
options: [
|
|
635
|
+
{
|
|
636
|
+
label: msg("fields.options.domestic", "Domestic"),
|
|
637
|
+
value: "domestic",
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
label: msg("fields.options.international", "International"),
|
|
641
|
+
value: "international",
|
|
642
|
+
},
|
|
643
|
+
],
|
|
644
|
+
},
|
|
645
|
+
includePhoneHyperlink: {
|
|
646
|
+
label: msg(
|
|
647
|
+
"fields.includePhoneHyperlink",
|
|
648
|
+
"Include Phone Hyperlink"
|
|
649
|
+
),
|
|
650
|
+
type: "radio",
|
|
651
|
+
options: [
|
|
652
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
653
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
654
|
+
],
|
|
655
|
+
},
|
|
656
|
+
liveVisibility: {
|
|
657
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
658
|
+
type: "radio",
|
|
659
|
+
options: [
|
|
660
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
661
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
662
|
+
],
|
|
663
|
+
},
|
|
664
|
+
},
|
|
665
|
+
},
|
|
666
|
+
email: {
|
|
667
|
+
label: msg("fields.email", "Email"),
|
|
668
|
+
type: "object",
|
|
669
|
+
objectFields: {
|
|
670
|
+
field: DisplayFieldSelector("type.string"),
|
|
671
|
+
liveVisibility: {
|
|
672
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
673
|
+
type: "radio",
|
|
674
|
+
options: [
|
|
675
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
676
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
677
|
+
],
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
},
|
|
681
|
+
services: {
|
|
682
|
+
label: msg("fields.services", "Services"),
|
|
683
|
+
type: "object",
|
|
684
|
+
objectFields: {
|
|
685
|
+
field: DisplayFieldSelector("type.string"),
|
|
686
|
+
liveVisibility: {
|
|
687
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
688
|
+
type: "radio",
|
|
689
|
+
options: [
|
|
690
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
691
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
692
|
+
],
|
|
693
|
+
},
|
|
694
|
+
},
|
|
695
|
+
},
|
|
696
|
+
primaryCTA: {
|
|
697
|
+
label: msg("fields.primaryCTA", "Primary CTA"),
|
|
698
|
+
type: "object",
|
|
699
|
+
objectFields: {
|
|
700
|
+
label: {
|
|
701
|
+
type: "translatableString",
|
|
702
|
+
label: msg("fields.label", "Label"),
|
|
703
|
+
showApplyAllOption: false,
|
|
704
|
+
showFieldSelector: true,
|
|
705
|
+
getOptions: () => getDisplayFieldOptions("type.string"),
|
|
706
|
+
},
|
|
707
|
+
variant: {
|
|
708
|
+
label: msg("fields.ctaVariant", "CTA Variant"),
|
|
709
|
+
type: "radio",
|
|
710
|
+
options: ThemeOptions.CTA_VARIANT,
|
|
711
|
+
},
|
|
712
|
+
liveVisibility: {
|
|
713
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
714
|
+
type: "radio",
|
|
715
|
+
options: [
|
|
716
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
717
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
718
|
+
],
|
|
719
|
+
},
|
|
720
|
+
link: {
|
|
721
|
+
type: "translatableString",
|
|
722
|
+
label: msg("fields.link", "Link"),
|
|
723
|
+
showApplyAllOption: false,
|
|
724
|
+
showFieldSelector: true,
|
|
725
|
+
getOptions: () => getDisplayFieldOptions("type.string"),
|
|
726
|
+
},
|
|
727
|
+
normalizeLink: {
|
|
728
|
+
label: msg("fields.normalizeLink", "Normalize Link"),
|
|
729
|
+
type: "radio",
|
|
730
|
+
options: [
|
|
731
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
732
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
733
|
+
],
|
|
734
|
+
},
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
secondaryCTA: {
|
|
738
|
+
label: msg("fields.secondaryCTA", "Secondary CTA"),
|
|
739
|
+
type: "object",
|
|
740
|
+
objectFields: {
|
|
741
|
+
label: {
|
|
742
|
+
type: "translatableString",
|
|
743
|
+
label: msg("fields.label", "Label"),
|
|
744
|
+
showApplyAllOption: false,
|
|
745
|
+
showFieldSelector: true,
|
|
746
|
+
getOptions: () => getDisplayFieldOptions("type.string"),
|
|
747
|
+
},
|
|
748
|
+
link: {
|
|
749
|
+
type: "translatableString",
|
|
750
|
+
label: msg("fields.link", "Link"),
|
|
751
|
+
showApplyAllOption: false,
|
|
752
|
+
showFieldSelector: true,
|
|
753
|
+
getOptions: () => getDisplayFieldOptions("type.string"),
|
|
754
|
+
},
|
|
755
|
+
normalizeLink: {
|
|
756
|
+
label: msg("fields.normalizeLink", "Normalize Link"),
|
|
757
|
+
type: "radio",
|
|
758
|
+
options: [
|
|
759
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
760
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
761
|
+
],
|
|
762
|
+
},
|
|
763
|
+
variant: {
|
|
764
|
+
label: msg("fields.ctaVariant", "CTA Variant"),
|
|
765
|
+
type: "radio",
|
|
766
|
+
options: ThemeOptions.CTA_VARIANT,
|
|
767
|
+
},
|
|
768
|
+
liveVisibility: {
|
|
769
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
770
|
+
type: "radio",
|
|
771
|
+
options: [
|
|
772
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
773
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
774
|
+
],
|
|
775
|
+
},
|
|
776
|
+
},
|
|
777
|
+
},
|
|
778
|
+
image: {
|
|
779
|
+
label: msg("fields.image", "Image"),
|
|
780
|
+
type: "object",
|
|
781
|
+
objectFields: {
|
|
782
|
+
constantValueEnabled: {
|
|
783
|
+
type: "custom",
|
|
784
|
+
render: ({
|
|
785
|
+
value,
|
|
786
|
+
onChange,
|
|
787
|
+
}: YextCustomFieldRenderProps<boolean | undefined>) => (
|
|
788
|
+
<ConstantValueModeToggler
|
|
789
|
+
fieldTypeFilter={["type.image"]}
|
|
790
|
+
constantValueEnabled={value ?? false}
|
|
791
|
+
toggleConstantValueEnabled={(constantValueEnabled) =>
|
|
792
|
+
onChange(constantValueEnabled)
|
|
793
|
+
}
|
|
794
|
+
label={msg("fields.image", "Image")}
|
|
795
|
+
showLocale={true}
|
|
796
|
+
/>
|
|
797
|
+
),
|
|
798
|
+
},
|
|
799
|
+
constantValue: LOCATOR_IMAGE_CONSTANT_CONFIG,
|
|
800
|
+
field: DisplayFieldSelector("type.image"),
|
|
801
|
+
liveVisibility: {
|
|
802
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
803
|
+
type: "radio",
|
|
804
|
+
options: [
|
|
805
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
806
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
807
|
+
],
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
},
|
|
811
|
+
},
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
export interface Location {
|
|
815
|
+
address: AddressType;
|
|
816
|
+
hours?: HoursType;
|
|
817
|
+
additionalHoursText?: string;
|
|
818
|
+
id: string;
|
|
819
|
+
mainPhone?: string;
|
|
820
|
+
name: string;
|
|
821
|
+
neighborhood?: string;
|
|
822
|
+
slug?: string;
|
|
823
|
+
timezone: string;
|
|
824
|
+
yextDisplayCoordinate?: Coordinate;
|
|
825
|
+
ref_listings?: ListingType[];
|
|
826
|
+
[key: string]: any; // Allow any other fields
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
export const LocatorResultCard = React.memo(
|
|
830
|
+
({
|
|
831
|
+
result,
|
|
832
|
+
resultCardProps: props,
|
|
833
|
+
distanceDisplay = "distanceFromUser",
|
|
834
|
+
searchLocationName,
|
|
835
|
+
isSelected,
|
|
836
|
+
}: {
|
|
837
|
+
result: CardProps<Location>["result"];
|
|
838
|
+
resultCardProps: LocatorResultCardProps;
|
|
839
|
+
distanceDisplay?: DistanceDisplayOption;
|
|
840
|
+
searchLocationName?: string;
|
|
841
|
+
isSelected?: boolean;
|
|
842
|
+
}): React.JSX.Element => {
|
|
843
|
+
const { t, i18n } = useTranslation();
|
|
844
|
+
|
|
845
|
+
const location = result.rawData;
|
|
846
|
+
const resolvedAccentBackgroundColor =
|
|
847
|
+
props.accentColor ?? backgroundColors.background2.value;
|
|
848
|
+
const resolvedAccentLinkColor =
|
|
849
|
+
props.accentColor ?? backgroundColors.background6.value;
|
|
850
|
+
const distance =
|
|
851
|
+
distanceDisplay === "distanceFromUser"
|
|
852
|
+
? result.distance
|
|
853
|
+
: distanceDisplay === "distanceFromSearch"
|
|
854
|
+
? result.distanceFromFilter
|
|
855
|
+
: undefined;
|
|
856
|
+
|
|
857
|
+
const unit = getPreferredDistanceUnit(i18n.language);
|
|
858
|
+
const unitLabel = unit === "mile" ? "mi" : "km"; // Abbreviations do not need translation
|
|
859
|
+
const displayDistance =
|
|
860
|
+
typeof distance === "number"
|
|
861
|
+
? `${formatDistance(fromMeters(distance, unit), i18n.language)} ${unitLabel}`
|
|
862
|
+
: undefined;
|
|
863
|
+
const searchDistance =
|
|
864
|
+
typeof result.distanceFromFilter === "number"
|
|
865
|
+
? `${formatDistance(
|
|
866
|
+
fromMeters(result.distanceFromFilter, unit),
|
|
867
|
+
i18n.language
|
|
868
|
+
)} ${unitLabel}`
|
|
869
|
+
: undefined;
|
|
870
|
+
const userDistance =
|
|
871
|
+
typeof result.distance === "number"
|
|
872
|
+
? `${formatDistance(fromMeters(result.distance, unit), i18n.language)} ${unitLabel}`
|
|
873
|
+
: undefined;
|
|
874
|
+
const displayDistanceContent =
|
|
875
|
+
distanceDisplay === "bothDistances" ? (
|
|
876
|
+
<>
|
|
877
|
+
{searchDistance && (
|
|
878
|
+
<Body variant="sm">
|
|
879
|
+
{searchLocationName ? (
|
|
880
|
+
<Trans
|
|
881
|
+
i18nKey="distanceLineFromSearchLocation"
|
|
882
|
+
values={{
|
|
883
|
+
distance: searchDistance,
|
|
884
|
+
searchLocation: searchLocationName,
|
|
885
|
+
}}
|
|
886
|
+
components={{
|
|
887
|
+
strong: <strong style={{ fontWeight: "bolder" }} />,
|
|
888
|
+
}}
|
|
889
|
+
defaults="<strong>{{distance}}</strong> from {{searchLocation}}"
|
|
890
|
+
/>
|
|
891
|
+
) : (
|
|
892
|
+
<Trans
|
|
893
|
+
i18nKey="distanceLineFromSearch"
|
|
894
|
+
values={{ distance: searchDistance }}
|
|
895
|
+
components={{
|
|
896
|
+
strong: <strong style={{ fontWeight: "bolder" }} />,
|
|
897
|
+
}}
|
|
898
|
+
defaults="<strong>{{distance}}</strong> from search"
|
|
899
|
+
/>
|
|
900
|
+
)}
|
|
901
|
+
</Body>
|
|
902
|
+
)}
|
|
903
|
+
{userDistance && (
|
|
904
|
+
<Body variant="sm">
|
|
905
|
+
<Trans
|
|
906
|
+
i18nKey="distanceLineFromYou"
|
|
907
|
+
values={{ distance: userDistance }}
|
|
908
|
+
components={{
|
|
909
|
+
strong: <strong style={{ fontWeight: "bolder" }} />,
|
|
910
|
+
}}
|
|
911
|
+
defaults="<strong>{{distance}}</strong> from you"
|
|
912
|
+
/>
|
|
913
|
+
</Body>
|
|
914
|
+
)}
|
|
915
|
+
</>
|
|
916
|
+
) : (
|
|
917
|
+
displayDistance
|
|
918
|
+
);
|
|
919
|
+
const showDistance =
|
|
920
|
+
distanceDisplay === "bothDistances"
|
|
921
|
+
? searchDistance !== undefined || userDistance !== undefined
|
|
922
|
+
: displayDistance !== undefined;
|
|
923
|
+
|
|
924
|
+
const handleGetDirectionsClick = useCardAnalyticsCallback(
|
|
925
|
+
result,
|
|
926
|
+
"DRIVING_DIRECTIONS"
|
|
927
|
+
);
|
|
928
|
+
const handleSecondaryCTAClick = useCardAnalyticsCallback(
|
|
929
|
+
result,
|
|
930
|
+
"CTA_CLICK"
|
|
931
|
+
);
|
|
932
|
+
const handlePhoneNumberClick = useCardAnalyticsCallback(
|
|
933
|
+
result,
|
|
934
|
+
"TAP_TO_CALL"
|
|
935
|
+
);
|
|
936
|
+
|
|
937
|
+
const getDirectionsLink: string | undefined = (() => {
|
|
938
|
+
const listings = location.ref_listings ?? [];
|
|
939
|
+
const listingsLink = getDirections(
|
|
940
|
+
undefined,
|
|
941
|
+
listings,
|
|
942
|
+
undefined,
|
|
943
|
+
{ provider: "google" },
|
|
944
|
+
undefined
|
|
945
|
+
);
|
|
946
|
+
const coordinateLink = getDirections(
|
|
947
|
+
undefined,
|
|
948
|
+
undefined,
|
|
949
|
+
undefined,
|
|
950
|
+
{ provider: "google" },
|
|
951
|
+
location.yextDisplayCoordinate
|
|
952
|
+
);
|
|
953
|
+
|
|
954
|
+
return listingsLink || coordinateLink;
|
|
955
|
+
})();
|
|
956
|
+
|
|
957
|
+
return (
|
|
958
|
+
<Background
|
|
959
|
+
background={backgroundColors.background1.value}
|
|
960
|
+
className="container flex flex-row border-b border-gray-300 p-4 md:p-6 lg:p-8 gap-4"
|
|
961
|
+
style={isSelected ? { backgroundColor: "#F9F9F9" } : undefined}
|
|
962
|
+
>
|
|
963
|
+
<div className="flex flex-wrap gap-4 w-full">
|
|
964
|
+
<div className="w-full flex flex-col gap-4">
|
|
965
|
+
{/** Heading section */}
|
|
966
|
+
<div className="flex flex-row justify-between items-start gap-6">
|
|
967
|
+
<div className="flex flex-row items-start gap-6 flex-1 min-w-0">
|
|
968
|
+
<ImageSection image={props.image} location={location} />
|
|
969
|
+
<div className="flex flex-row items-center gap-4 min-w-0">
|
|
970
|
+
<Background
|
|
971
|
+
background={
|
|
972
|
+
props?.primaryHeading?.color ??
|
|
973
|
+
backgroundColors.background6.value
|
|
974
|
+
}
|
|
975
|
+
className="flex-shrink-0 w-6 h-6 rounded-full font-bold hidden md:flex items-center justify-center text-body-sm-fontSize"
|
|
976
|
+
>
|
|
977
|
+
{result.index}
|
|
978
|
+
</Background>
|
|
979
|
+
<HeadingTextSection
|
|
980
|
+
primaryHeading={props.primaryHeading}
|
|
981
|
+
secondaryHeading={props.secondaryHeading}
|
|
982
|
+
tertiaryHeading={props.tertiaryHeading}
|
|
983
|
+
location={location}
|
|
984
|
+
/>
|
|
985
|
+
</div>
|
|
986
|
+
</div>
|
|
987
|
+
{showDistance && (
|
|
988
|
+
<div
|
|
989
|
+
className={
|
|
990
|
+
"font-body-fontFamily font-body-sm-fontWeight text-body-sm-fontSize rounded-full hidden lg:flex flex-col items-end text-right min-w-fit"
|
|
991
|
+
}
|
|
992
|
+
>
|
|
993
|
+
{displayDistanceContent}
|
|
994
|
+
</div>
|
|
995
|
+
)}
|
|
996
|
+
</div>
|
|
997
|
+
|
|
998
|
+
<div className="flex flex-col gap-4 md:pl-10">
|
|
999
|
+
<HoursSection
|
|
1000
|
+
location={location}
|
|
1001
|
+
result={result}
|
|
1002
|
+
hoursProps={props.hours}
|
|
1003
|
+
showIcons={props.icons}
|
|
1004
|
+
accentColor={resolvedAccentBackgroundColor}
|
|
1005
|
+
/>
|
|
1006
|
+
|
|
1007
|
+
{/** Core Info section */}
|
|
1008
|
+
<div className="flex flex-col lg:flex-row gap-4">
|
|
1009
|
+
{/** Contact Section */}
|
|
1010
|
+
<div className="flex flex-col gap-4 lg:w-[280px]">
|
|
1011
|
+
{location.address && props.address.liveVisibility && (
|
|
1012
|
+
<div className="flex flex-row items-start gap-2">
|
|
1013
|
+
{props.icons && (
|
|
1014
|
+
<CardIcon
|
|
1015
|
+
backgroundColor={resolvedAccentBackgroundColor}
|
|
1016
|
+
>
|
|
1017
|
+
<FaMapMarkerAlt className="w-4 h-4" />
|
|
1018
|
+
</CardIcon>
|
|
1019
|
+
)}
|
|
1020
|
+
<div className="flex flex-col gap-1 w-full">
|
|
1021
|
+
<div className="font-body-fontFamily font-body-fontWeight text-body-fontSize gap-4">
|
|
1022
|
+
<Address
|
|
1023
|
+
address={location.address}
|
|
1024
|
+
showRegion={props.address.showRegion}
|
|
1025
|
+
showCountry={props.address.showCountry}
|
|
1026
|
+
/>
|
|
1027
|
+
</div>
|
|
1028
|
+
{getDirectionsLink &&
|
|
1029
|
+
props.address.showGetDirectionsLink && (
|
|
1030
|
+
<a
|
|
1031
|
+
href={getDirectionsLink}
|
|
1032
|
+
onClick={handleGetDirectionsClick}
|
|
1033
|
+
aria-label={t("getDirectionsForLocation", {
|
|
1034
|
+
address: location.address.line1,
|
|
1035
|
+
defaultValue: "Get Directions for {{address}}",
|
|
1036
|
+
})}
|
|
1037
|
+
className={themeManagerCn(
|
|
1038
|
+
"components h-fit items-center w-fit underline gap-2 decoration-0 hover:no-underline font-link-fontFamily text-link-fontSize tracking-link-letterSpacing flex font-bold",
|
|
1039
|
+
getTextColorClass(resolvedAccentLinkColor)
|
|
1040
|
+
)}
|
|
1041
|
+
style={getTextColorStyle(resolvedAccentLinkColor)}
|
|
1042
|
+
>
|
|
1043
|
+
{t("getDirections", "Get Directions")}
|
|
1044
|
+
<FaAngleRight size={"12px"} />
|
|
1045
|
+
</a>
|
|
1046
|
+
)}
|
|
1047
|
+
</div>
|
|
1048
|
+
</div>
|
|
1049
|
+
)}
|
|
1050
|
+
<PhoneSection
|
|
1051
|
+
phone={props.phone}
|
|
1052
|
+
handlePhoneNumberClick={handlePhoneNumberClick}
|
|
1053
|
+
location={location}
|
|
1054
|
+
icons={props.icons}
|
|
1055
|
+
backgroundColor={resolvedAccentBackgroundColor}
|
|
1056
|
+
linkColor={resolvedAccentLinkColor}
|
|
1057
|
+
/>
|
|
1058
|
+
<EmailSection
|
|
1059
|
+
email={props.email}
|
|
1060
|
+
location={location}
|
|
1061
|
+
icons={props.icons}
|
|
1062
|
+
index={result.index}
|
|
1063
|
+
iconBackgroundColor={resolvedAccentBackgroundColor}
|
|
1064
|
+
linkColor={resolvedAccentLinkColor}
|
|
1065
|
+
/>
|
|
1066
|
+
</div>
|
|
1067
|
+
{/** Secondary Info Section */}
|
|
1068
|
+
<div className="flex flex-col gap-4 lg:w-[240px]">
|
|
1069
|
+
<ServicesSection
|
|
1070
|
+
services={props.services}
|
|
1071
|
+
location={location}
|
|
1072
|
+
/>
|
|
1073
|
+
</div>
|
|
1074
|
+
</div>
|
|
1075
|
+
</div>
|
|
1076
|
+
</div>
|
|
1077
|
+
{showDistance && (
|
|
1078
|
+
<div
|
|
1079
|
+
className={`
|
|
1080
|
+
font-body-fontFamily font-body-sm-fontWeight text-body-sm-fontSize flex flex-col items-start text-left lg:hidden md:ml-10 py-1 w-fit max-w-full break-words
|
|
1081
|
+
${distanceDisplay === "bothDistances" ? "rounded-md px-3" : "rounded-full px-2"}
|
|
1082
|
+
${getBackgroundColorClasses(backgroundColors.background2.value)}`}
|
|
1083
|
+
>
|
|
1084
|
+
{displayDistanceContent}
|
|
1085
|
+
</div>
|
|
1086
|
+
)}
|
|
1087
|
+
{/** CTA section */}
|
|
1088
|
+
<div className="flex flex-col lg:flex-row gap-2 lg:gap-4 w-full md:pl-10 items-center md:items-stretch lg:items-center">
|
|
1089
|
+
<PrimaryCTA
|
|
1090
|
+
primaryCTA={props.primaryCTA}
|
|
1091
|
+
primaryHeading={props.primaryHeading}
|
|
1092
|
+
result={result}
|
|
1093
|
+
/>
|
|
1094
|
+
{props.secondaryCTA.liveVisibility && (
|
|
1095
|
+
<CTA
|
|
1096
|
+
link={resolveComponentData(
|
|
1097
|
+
props.secondaryCTA.link,
|
|
1098
|
+
i18n.language,
|
|
1099
|
+
location
|
|
1100
|
+
)}
|
|
1101
|
+
label={
|
|
1102
|
+
resolveComponentData(
|
|
1103
|
+
props.secondaryCTA.label,
|
|
1104
|
+
i18n.language,
|
|
1105
|
+
location
|
|
1106
|
+
) || t("callToAction", "Call to Action")
|
|
1107
|
+
}
|
|
1108
|
+
variant={props.secondaryCTA.variant}
|
|
1109
|
+
normalizeLink={props.secondaryCTA.normalizeLink}
|
|
1110
|
+
onClick={handleSecondaryCTAClick}
|
|
1111
|
+
className="basis-full sm:w-auto justify-center"
|
|
1112
|
+
/>
|
|
1113
|
+
)}
|
|
1114
|
+
</div>
|
|
1115
|
+
</div>
|
|
1116
|
+
</Background>
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1120
|
+
|
|
1121
|
+
const PrimaryCTA = (props: {
|
|
1122
|
+
primaryCTA: LocatorResultCardProps["primaryCTA"];
|
|
1123
|
+
primaryHeading: LocatorResultCardProps["primaryHeading"];
|
|
1124
|
+
result: CardProps<Location>["result"];
|
|
1125
|
+
}) => {
|
|
1126
|
+
const { primaryCTA, primaryHeading, result } = props;
|
|
1127
|
+
const location = result.rawData;
|
|
1128
|
+
const { document: streamDocument, relativePrefixToRoot } = useTemplateProps();
|
|
1129
|
+
const { t, i18n } = useTranslation();
|
|
1130
|
+
|
|
1131
|
+
const primaryHeadingText = resolveText({
|
|
1132
|
+
config: primaryHeading,
|
|
1133
|
+
location,
|
|
1134
|
+
language: i18n.language,
|
|
1135
|
+
fieldId: primaryHeading.field,
|
|
1136
|
+
fallback: location.name,
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
// Always uses the entity page link if one exists. If not, tries to resolve URL from the static
|
|
1140
|
+
// template in the Link prop, and if that also fails, doesn't render at all.
|
|
1141
|
+
let resolvedUrl = resolveLocatorResultUrl(
|
|
1142
|
+
location,
|
|
1143
|
+
streamDocument,
|
|
1144
|
+
relativePrefixToRoot
|
|
1145
|
+
);
|
|
1146
|
+
if (resolvedUrl === undefined && primaryCTA?.link) {
|
|
1147
|
+
resolvedUrl = resolveComponentData(
|
|
1148
|
+
primaryCTA.link,
|
|
1149
|
+
i18n.language,
|
|
1150
|
+
location
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
const showPrimaryCta = primaryCTA.liveVisibility && resolvedUrl;
|
|
1155
|
+
|
|
1156
|
+
const handlePrimaryCtaClick = useCardAnalyticsCallback(
|
|
1157
|
+
result,
|
|
1158
|
+
"VIEW_WEBSITE"
|
|
1159
|
+
);
|
|
1160
|
+
|
|
1161
|
+
return (
|
|
1162
|
+
showPrimaryCta && (
|
|
1163
|
+
<CTA
|
|
1164
|
+
link={resolvedUrl}
|
|
1165
|
+
label={
|
|
1166
|
+
resolveComponentData(
|
|
1167
|
+
props.primaryCTA.label,
|
|
1168
|
+
i18n.language,
|
|
1169
|
+
location
|
|
1170
|
+
) || t("visitPage", "Visit Page")
|
|
1171
|
+
}
|
|
1172
|
+
ariaLabel={t("visitPageForName", {
|
|
1173
|
+
name: primaryHeadingText,
|
|
1174
|
+
defaultValue: "Visit Page for {{name}}",
|
|
1175
|
+
})}
|
|
1176
|
+
variant={primaryCTA.variant}
|
|
1177
|
+
normalizeLink={primaryCTA.normalizeLink}
|
|
1178
|
+
onClick={handlePrimaryCtaClick}
|
|
1179
|
+
className="basis-full sm:w-auto justify-center"
|
|
1180
|
+
/>
|
|
1181
|
+
)
|
|
1182
|
+
);
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
const CardIcon: React.FC<{
|
|
1186
|
+
children: React.ReactNode;
|
|
1187
|
+
backgroundColor?: ThemeColor;
|
|
1188
|
+
}> = ({ children, backgroundColor }) => {
|
|
1189
|
+
return (
|
|
1190
|
+
<div
|
|
1191
|
+
className={`h-10 w-10 flex justify-center rounded-full items-center ${getBackgroundColorClasses(
|
|
1192
|
+
backgroundColor ?? backgroundColors.background2.value
|
|
1193
|
+
)}`}
|
|
1194
|
+
style={getBackgroundColorStyle(
|
|
1195
|
+
backgroundColor ?? backgroundColors.background2.value
|
|
1196
|
+
)}
|
|
1197
|
+
>
|
|
1198
|
+
{children}
|
|
1199
|
+
</div>
|
|
1200
|
+
);
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
const ImageSection = (props: {
|
|
1204
|
+
image: LocatorResultCardProps["image"];
|
|
1205
|
+
location: Location;
|
|
1206
|
+
}) => {
|
|
1207
|
+
const { image, location } = props;
|
|
1208
|
+
const { i18n } = useTranslation();
|
|
1209
|
+
|
|
1210
|
+
if (image.constantValueEnabled) {
|
|
1211
|
+
const resolvedImage = image.constantValue
|
|
1212
|
+
? resolveComponentData(image.constantValue, i18n.language, location)
|
|
1213
|
+
: undefined;
|
|
1214
|
+
const imageUrl = getImageUrl(resolvedImage, i18n.language);
|
|
1215
|
+
const showImageSection =
|
|
1216
|
+
!!imageUrl && image.liveVisibility && !!resolvedImage;
|
|
1217
|
+
return (
|
|
1218
|
+
showImageSection && (
|
|
1219
|
+
<Image
|
|
1220
|
+
image={resolvedImage}
|
|
1221
|
+
streamDocumentOverride={location}
|
|
1222
|
+
className="w-12 h-12 md:w-16 md:h-16 lg:w-20 lg:h-20 object-cover rounded-image-borderRadius min-w-fit"
|
|
1223
|
+
/>
|
|
1224
|
+
)
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
const imageRecord = parseRecordFromLocation(location, image.field);
|
|
1229
|
+
const imageData = {
|
|
1230
|
+
url: imageRecord?.url,
|
|
1231
|
+
alternateText: imageRecord?.alternateText || location.name,
|
|
1232
|
+
// these will probably get overridden by CSS but providing defaults for safety
|
|
1233
|
+
height: imageRecord?.height ?? 80,
|
|
1234
|
+
width: imageRecord?.width ?? 80,
|
|
1235
|
+
};
|
|
1236
|
+
const showImageSection = imageRecord && image.liveVisibility;
|
|
1237
|
+
|
|
1238
|
+
return (
|
|
1239
|
+
showImageSection && (
|
|
1240
|
+
<Image
|
|
1241
|
+
image={imageData}
|
|
1242
|
+
streamDocumentOverride={location}
|
|
1243
|
+
className="w-12 h-12 md:w-16 md:h-16 lg:w-20 lg:h-20 object-cover rounded-image-borderRadius min-w-fit"
|
|
1244
|
+
/>
|
|
1245
|
+
)
|
|
1246
|
+
);
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1249
|
+
const HeadingTextSection = (props: {
|
|
1250
|
+
primaryHeading: LocatorResultCardProps["primaryHeading"];
|
|
1251
|
+
secondaryHeading: LocatorResultCardProps["secondaryHeading"];
|
|
1252
|
+
tertiaryHeading: LocatorResultCardProps["tertiaryHeading"];
|
|
1253
|
+
location: Location;
|
|
1254
|
+
}) => {
|
|
1255
|
+
const { primaryHeading, secondaryHeading, tertiaryHeading, location } = props;
|
|
1256
|
+
const { i18n } = useTranslation();
|
|
1257
|
+
|
|
1258
|
+
const primaryHeadingText = resolveText({
|
|
1259
|
+
config: primaryHeading,
|
|
1260
|
+
location,
|
|
1261
|
+
language: i18n.language,
|
|
1262
|
+
fieldId: primaryHeading.field,
|
|
1263
|
+
fallback: location.name,
|
|
1264
|
+
});
|
|
1265
|
+
|
|
1266
|
+
const secondaryHeadingText = resolveText({
|
|
1267
|
+
config: secondaryHeading,
|
|
1268
|
+
location,
|
|
1269
|
+
language: i18n.language,
|
|
1270
|
+
fieldId: secondaryHeading.field,
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
const tertiaryHeadingText = resolveText({
|
|
1274
|
+
config: tertiaryHeading,
|
|
1275
|
+
location,
|
|
1276
|
+
language: i18n.language,
|
|
1277
|
+
fieldId: tertiaryHeading.field,
|
|
1278
|
+
});
|
|
1279
|
+
|
|
1280
|
+
return (
|
|
1281
|
+
<div className="flex flex-col gap-2 flex-1 min-w-0">
|
|
1282
|
+
<Heading
|
|
1283
|
+
color={primaryHeading?.color}
|
|
1284
|
+
className={`font-bold ${primaryHeading?.color ? "" : "text-palette-primary-dark"}`}
|
|
1285
|
+
level={primaryHeading.headingLevel}
|
|
1286
|
+
>
|
|
1287
|
+
{primaryHeadingText}
|
|
1288
|
+
</Heading>
|
|
1289
|
+
{secondaryHeadingText && secondaryHeading.liveVisibility && (
|
|
1290
|
+
<Body variant={secondaryHeading.variant} className="font-bold">
|
|
1291
|
+
{secondaryHeadingText}
|
|
1292
|
+
</Body>
|
|
1293
|
+
)}
|
|
1294
|
+
{tertiaryHeadingText && tertiaryHeading.liveVisibility && (
|
|
1295
|
+
<Body variant={tertiaryHeading.variant}>{tertiaryHeadingText}</Body>
|
|
1296
|
+
)}
|
|
1297
|
+
</div>
|
|
1298
|
+
);
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1301
|
+
const HoursSection = (props: {
|
|
1302
|
+
location: Location;
|
|
1303
|
+
result: CardProps<Location>["result"];
|
|
1304
|
+
hoursProps: LocatorResultCardProps["hours"];
|
|
1305
|
+
showIcons: boolean;
|
|
1306
|
+
accentColor?: ThemeColor;
|
|
1307
|
+
}) => {
|
|
1308
|
+
const { location, result, hoursProps, showIcons, accentColor } = props;
|
|
1309
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
1310
|
+
const triggerId = React.useId();
|
|
1311
|
+
const contentId = React.useId();
|
|
1312
|
+
|
|
1313
|
+
const hoursData = parseHoursFromLocation(location, hoursProps.field);
|
|
1314
|
+
const comingSoon = location["comingSoon"];
|
|
1315
|
+
const showHoursSection =
|
|
1316
|
+
(hoursData || comingSoon) && hoursProps.liveVisibility;
|
|
1317
|
+
const hoursStatusRow = (
|
|
1318
|
+
<div className="flex flex-row items-center gap-2">
|
|
1319
|
+
{showIcons && (
|
|
1320
|
+
<CardIcon backgroundColor={accentColor}>
|
|
1321
|
+
<FaRegClock className="w-4 h-4" />
|
|
1322
|
+
</CardIcon>
|
|
1323
|
+
)}
|
|
1324
|
+
<HoursStatusAtom
|
|
1325
|
+
hours={hoursData ?? {}}
|
|
1326
|
+
comingSoon={comingSoon}
|
|
1327
|
+
timezone={location.timezone}
|
|
1328
|
+
className="text-body-fontSize mb-0"
|
|
1329
|
+
showDayNames={false}
|
|
1330
|
+
boldCurrentStatus={true}
|
|
1331
|
+
/>
|
|
1332
|
+
</div>
|
|
1333
|
+
);
|
|
1334
|
+
|
|
1335
|
+
return (
|
|
1336
|
+
showHoursSection && (
|
|
1337
|
+
<div className="font-body-fontFamily text-body-fontSize gap-8">
|
|
1338
|
+
{comingSoon ? (
|
|
1339
|
+
hoursStatusRow
|
|
1340
|
+
) : (
|
|
1341
|
+
<Accordion>
|
|
1342
|
+
<AccordionItem
|
|
1343
|
+
key={`result-${result.index}-hours`}
|
|
1344
|
+
className="py-0"
|
|
1345
|
+
onToggle={(event) => setIsExpanded(event.currentTarget.open)}
|
|
1346
|
+
>
|
|
1347
|
+
<AccordionTrigger
|
|
1348
|
+
id={triggerId}
|
|
1349
|
+
aria-controls={contentId}
|
|
1350
|
+
aria-expanded={isExpanded}
|
|
1351
|
+
className="justify-start"
|
|
1352
|
+
role="button"
|
|
1353
|
+
>
|
|
1354
|
+
{hoursStatusRow}
|
|
1355
|
+
</AccordionTrigger>
|
|
1356
|
+
<AccordionContent
|
|
1357
|
+
id={contentId}
|
|
1358
|
+
aria-labelledby={triggerId}
|
|
1359
|
+
role="region"
|
|
1360
|
+
>
|
|
1361
|
+
<div className="flex flex-col gap-2">
|
|
1362
|
+
<HoursTableAtom
|
|
1363
|
+
hours={hoursData ?? {}}
|
|
1364
|
+
comingSoon={comingSoon}
|
|
1365
|
+
startOfWeek={hoursProps.table.startOfWeek}
|
|
1366
|
+
collapseDays={hoursProps.table.collapseDays}
|
|
1367
|
+
className="[&_.HoursTable-row]:w-fit"
|
|
1368
|
+
/>
|
|
1369
|
+
{location.additionalHoursText &&
|
|
1370
|
+
hoursProps.table.showAdditionalHoursText && (
|
|
1371
|
+
<div className="text-body-sm-fontSize">
|
|
1372
|
+
{location.additionalHoursText}
|
|
1373
|
+
</div>
|
|
1374
|
+
)}
|
|
1375
|
+
</div>
|
|
1376
|
+
</AccordionContent>
|
|
1377
|
+
</AccordionItem>
|
|
1378
|
+
</Accordion>
|
|
1379
|
+
)}
|
|
1380
|
+
</div>
|
|
1381
|
+
)
|
|
1382
|
+
);
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
const PhoneSection = (props: {
|
|
1386
|
+
phone: LocatorResultCardProps["phone"];
|
|
1387
|
+
handlePhoneNumberClick: () => void;
|
|
1388
|
+
location: Location;
|
|
1389
|
+
icons: boolean;
|
|
1390
|
+
index?: number;
|
|
1391
|
+
backgroundColor: ThemeColor;
|
|
1392
|
+
linkColor: ThemeColor;
|
|
1393
|
+
}) => {
|
|
1394
|
+
const {
|
|
1395
|
+
phone,
|
|
1396
|
+
handlePhoneNumberClick,
|
|
1397
|
+
location,
|
|
1398
|
+
icons,
|
|
1399
|
+
index,
|
|
1400
|
+
backgroundColor,
|
|
1401
|
+
linkColor,
|
|
1402
|
+
} = props;
|
|
1403
|
+
const { t } = useTranslation();
|
|
1404
|
+
|
|
1405
|
+
const phoneNumber = parseStringFromLocation(location, phone.field);
|
|
1406
|
+
const showPhoneNumber = phone.field && phone.liveVisibility && phoneNumber;
|
|
1407
|
+
return (
|
|
1408
|
+
showPhoneNumber && (
|
|
1409
|
+
<PhoneAtom
|
|
1410
|
+
backgroundColor={backgroundColor}
|
|
1411
|
+
eventName={`phone${index}`}
|
|
1412
|
+
label={t("phone", "Phone")}
|
|
1413
|
+
format={phone.phoneFormat}
|
|
1414
|
+
phoneNumber={phoneNumber}
|
|
1415
|
+
includeHyperlink={phone.includePhoneHyperlink}
|
|
1416
|
+
includeIcon={icons}
|
|
1417
|
+
linkColor={linkColor}
|
|
1418
|
+
onClick={handlePhoneNumberClick}
|
|
1419
|
+
/>
|
|
1420
|
+
)
|
|
1421
|
+
);
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
const EmailSection = (props: {
|
|
1425
|
+
email: LocatorResultCardProps["email"];
|
|
1426
|
+
location: Location;
|
|
1427
|
+
icons: boolean;
|
|
1428
|
+
index?: number;
|
|
1429
|
+
iconBackgroundColor: ThemeColor;
|
|
1430
|
+
linkColor: ThemeColor;
|
|
1431
|
+
}) => {
|
|
1432
|
+
const { email, location, index, icons, iconBackgroundColor, linkColor } =
|
|
1433
|
+
props;
|
|
1434
|
+
|
|
1435
|
+
const emailAddresses = parseArrayFromLocation(location, email.field);
|
|
1436
|
+
const showEmailSection =
|
|
1437
|
+
email.liveVisibility &&
|
|
1438
|
+
emailAddresses &&
|
|
1439
|
+
emailAddresses.length > 0 &&
|
|
1440
|
+
typeof emailAddresses[0] === "string";
|
|
1441
|
+
return (
|
|
1442
|
+
showEmailSection && (
|
|
1443
|
+
<div className="flex flex-row items-center gap-2">
|
|
1444
|
+
{icons && (
|
|
1445
|
+
<CardIcon backgroundColor={iconBackgroundColor}>
|
|
1446
|
+
<FaRegEnvelope className="w-4 h-4" />
|
|
1447
|
+
</CardIcon>
|
|
1448
|
+
)}
|
|
1449
|
+
<CTA
|
|
1450
|
+
eventName={`email${index}`}
|
|
1451
|
+
link={emailAddresses[0]}
|
|
1452
|
+
label={emailAddresses[0]}
|
|
1453
|
+
linkType="EMAIL"
|
|
1454
|
+
normalizeLink={false}
|
|
1455
|
+
variant="link"
|
|
1456
|
+
color={linkColor}
|
|
1457
|
+
/>
|
|
1458
|
+
</div>
|
|
1459
|
+
)
|
|
1460
|
+
);
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
const ServicesSection = (props: {
|
|
1464
|
+
services: LocatorResultCardProps["services"];
|
|
1465
|
+
location: Location;
|
|
1466
|
+
}) => {
|
|
1467
|
+
const { services, location } = props;
|
|
1468
|
+
const { t } = useTranslation();
|
|
1469
|
+
|
|
1470
|
+
const servicesList = parseArrayFromLocation(location, services.field);
|
|
1471
|
+
const showServicesSection =
|
|
1472
|
+
services.liveVisibility &&
|
|
1473
|
+
servicesList &&
|
|
1474
|
+
servicesList.length > 0 &&
|
|
1475
|
+
servicesList.every((service) => typeof service === "string");
|
|
1476
|
+
return (
|
|
1477
|
+
showServicesSection && (
|
|
1478
|
+
<div className="flex flex-col gap-2">
|
|
1479
|
+
<Body variant="base" className="font-bold">
|
|
1480
|
+
{t("services", "Services")}
|
|
1481
|
+
</Body>
|
|
1482
|
+
<Body variant="base">{servicesList.join(", ")}</Body>
|
|
1483
|
+
</div>
|
|
1484
|
+
)
|
|
1485
|
+
);
|
|
1486
|
+
};
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
* Resolves the text for a text element based on the constant value, field value, and fallback.
|
|
1490
|
+
*/
|
|
1491
|
+
const resolveText = (params: {
|
|
1492
|
+
config: {
|
|
1493
|
+
constantValue?: TranslatableString;
|
|
1494
|
+
constantValueEnabled?: boolean;
|
|
1495
|
+
trueDisplayText?: TranslatableString;
|
|
1496
|
+
falseDisplayText?: TranslatableString;
|
|
1497
|
+
};
|
|
1498
|
+
location: Location;
|
|
1499
|
+
language: string;
|
|
1500
|
+
fieldId: string | undefined;
|
|
1501
|
+
fallback?: string;
|
|
1502
|
+
}): string | undefined => {
|
|
1503
|
+
const { config, location, language, fieldId, fallback } = params;
|
|
1504
|
+
|
|
1505
|
+
const resolvedConstantValue =
|
|
1506
|
+
config.constantValueEnabled && config.constantValue
|
|
1507
|
+
? resolveComponentData(config.constantValue, language, location)
|
|
1508
|
+
: undefined;
|
|
1509
|
+
if (typeof resolvedConstantValue === "string") {
|
|
1510
|
+
return resolvedConstantValue || fallback;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
let resolvedText: string | undefined;
|
|
1514
|
+
const projectedValue = resolveProjectedField(location, fieldId);
|
|
1515
|
+
if (typeof projectedValue === "boolean") {
|
|
1516
|
+
const resolvedTrueDisplayText = config.trueDisplayText
|
|
1517
|
+
? resolveComponentData(config.trueDisplayText, language, location)
|
|
1518
|
+
: undefined;
|
|
1519
|
+
const resolvedFalseDisplayText = config.falseDisplayText
|
|
1520
|
+
? resolveComponentData(config.falseDisplayText, language, location)
|
|
1521
|
+
: undefined;
|
|
1522
|
+
resolvedText = projectedValue
|
|
1523
|
+
? resolvedTrueDisplayText
|
|
1524
|
+
: resolvedFalseDisplayText;
|
|
1525
|
+
} else {
|
|
1526
|
+
resolvedText = parseStringFromLocation(location, fieldId);
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
return resolvedText ?? fallback;
|
|
1530
|
+
};
|
|
1531
|
+
|
|
1532
|
+
/** Parses a string from the given location using the provided field ID. */
|
|
1533
|
+
const parseStringFromLocation = (
|
|
1534
|
+
location: Location,
|
|
1535
|
+
fieldId: string | undefined
|
|
1536
|
+
): string | undefined => {
|
|
1537
|
+
const value = resolveProjectedField(location, fieldId);
|
|
1538
|
+
if (value === undefined || value === null) {
|
|
1539
|
+
return undefined;
|
|
1540
|
+
}
|
|
1541
|
+
return String(value);
|
|
1542
|
+
};
|
|
1543
|
+
|
|
1544
|
+
/** Parses an array from the given location using the provided field ID. */
|
|
1545
|
+
const parseArrayFromLocation = (
|
|
1546
|
+
location: Location,
|
|
1547
|
+
fieldId: string | undefined
|
|
1548
|
+
): Array<any> | undefined => {
|
|
1549
|
+
const fieldValue = resolveProjectedField(location, fieldId);
|
|
1550
|
+
if (Array.isArray(fieldValue)) {
|
|
1551
|
+
return fieldValue;
|
|
1552
|
+
}
|
|
1553
|
+
return undefined;
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
/** Parses a record with string keys from the given location using the provided field ID. */
|
|
1557
|
+
const parseRecordFromLocation = (
|
|
1558
|
+
location: Location,
|
|
1559
|
+
fieldId: string | undefined
|
|
1560
|
+
): Record<string, any> | undefined => {
|
|
1561
|
+
return resolveProjectedField(location, fieldId);
|
|
1562
|
+
};
|
|
1563
|
+
|
|
1564
|
+
/** Parses an hours object from the given location using the provided hours field ID. */
|
|
1565
|
+
const parseHoursFromLocation = (
|
|
1566
|
+
location: Location,
|
|
1567
|
+
hoursFieldId: string | undefined
|
|
1568
|
+
): HoursType | undefined => {
|
|
1569
|
+
return resolveProjectedField(location, hoursFieldId) as HoursType;
|
|
1570
|
+
};
|
|
1571
|
+
|
|
1572
|
+
/**
|
|
1573
|
+
* Dereferences a projected field ID that uses "." as its separator. Returns the value of the
|
|
1574
|
+
* root field.
|
|
1575
|
+
*/
|
|
1576
|
+
const resolveProjectedField = (
|
|
1577
|
+
object: Record<string, any>,
|
|
1578
|
+
projectFieldId: string | undefined
|
|
1579
|
+
): any => {
|
|
1580
|
+
if (!projectFieldId) {
|
|
1581
|
+
return undefined;
|
|
1582
|
+
}
|
|
1583
|
+
// We can get away with this simple implementation for now since we know exactly what fields
|
|
1584
|
+
// can be in the locator response
|
|
1585
|
+
let current = object;
|
|
1586
|
+
for (const fieldId of projectFieldId.split(".")) {
|
|
1587
|
+
if (!current?.hasOwnProperty(fieldId)) {
|
|
1588
|
+
return undefined;
|
|
1589
|
+
}
|
|
1590
|
+
current = current[fieldId];
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
return current;
|
|
1594
|
+
};
|