@yext/visual-editor 1.4.10 → 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 +556 -6260
- 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 +15059 -136530
- package/package.json +45 -24
- package/dist/editor.css +0 -1
- package/dist/visual-editor--AAsqhQc.js +0 -231
- package/dist/visual-editor-32on_5DY.js +0 -243
- package/dist/visual-editor-49W0_Daf.js +0 -1002
- package/dist/visual-editor-8Lal-QZf.js +0 -219
- package/dist/visual-editor-B02CmTCX.js +0 -1002
- package/dist/visual-editor-BB0a_4dr.js +0 -243
- package/dist/visual-editor-BQa0UK-c.js +0 -1002
- package/dist/visual-editor-BRG83zQG.js +0 -1010
- package/dist/visual-editor-BVBPuEsB.js +0 -219
- package/dist/visual-editor-BcCzbooi.js +0 -243
- package/dist/visual-editor-BiemHMaD.js +0 -1014
- package/dist/visual-editor-Bkj-BZ8U.js +0 -1002
- package/dist/visual-editor-Bm_9l-r1.js +0 -1014
- package/dist/visual-editor-BsyZIlAm.js +0 -1002
- package/dist/visual-editor-BuUXmEr4.js +0 -1002
- package/dist/visual-editor-BxUYaP8B.js +0 -219
- package/dist/visual-editor-By1sH42E.js +0 -219
- package/dist/visual-editor-By9M5eN4.js +0 -231
- package/dist/visual-editor-C-MDqVaH.js +0 -219
- package/dist/visual-editor-C37Hro7w.js +0 -1026
- package/dist/visual-editor-C9I9pWeQ.js +0 -1014
- package/dist/visual-editor-CQOcLK3A.js +0 -1002
- package/dist/visual-editor-CSIc6-rm.js +0 -219
- package/dist/visual-editor-CaTT6blQ.js +0 -227
- package/dist/visual-editor-Cw95D-E7.js +0 -1014
- package/dist/visual-editor-CwW9rVaZ.js +0 -1002
- package/dist/visual-editor-CzC6S5LB.js +0 -1014
- package/dist/visual-editor-DAuNRkq8.js +0 -1026
- package/dist/visual-editor-DE8qwWp0.js +0 -1002
- package/dist/visual-editor-DEmVxnyc.js +0 -1014
- package/dist/visual-editor-DFQml8X8.js +0 -219
- package/dist/visual-editor-DHbDTZwW.js +0 -231
- package/dist/visual-editor-DR14jsjF.js +0 -219
- package/dist/visual-editor-DiO1-u9c.js +0 -243
- package/dist/visual-editor-Dk9cgdJp.js +0 -231
- package/dist/visual-editor-DlohF7nV.js +0 -219
- package/dist/visual-editor-DrbkrTPj.js +0 -231
- package/dist/visual-editor-Dwy8xGNv.js +0 -1002
- package/dist/visual-editor-Dz0yJDfm.js +0 -1026
- package/dist/visual-editor-InSI7qrX.js +0 -1026
- package/dist/visual-editor-KBcW6ZCw.js +0 -1002
- package/dist/visual-editor-Kgxgyjx4.js +0 -231
- package/dist/visual-editor-S4ACDl-Z.js +0 -1002
- package/dist/visual-editor-VLIdGBGJ.js +0 -1002
- package/dist/visual-editor-d-hTp0p2.js +0 -219
- package/dist/visual-editor-hqdcvtls.js +0 -219
- package/dist/visual-editor-llBar-sw.js +0 -1002
- package/dist/visual-editor-pb5PwMmE.js +0 -219
- package/dist/visual-editor-wSWVK8SW.js +0 -219
- package/dist/visual-editor-z-YqfQf7.js +0 -219
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { setDeep } from "@puckeditor/core";
|
|
2
|
+
import { CardProps } from "@yext/search-ui-react";
|
|
3
|
+
import { Result } from "@yext/search-headless-react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { YextAutoField } from "../../../fields/YextAutoField.tsx";
|
|
7
|
+
import { useDocument } from "../../../hooks/useDocument.tsx";
|
|
8
|
+
import { useTemplateMetadata } from "../../../internal/hooks/useMessageReceivers.ts";
|
|
9
|
+
import { getPreferredDistanceUnit } from "../../../utils/i18n/distance.ts";
|
|
10
|
+
import { getLocatorEntityTypeSourceMap } from "../../../utils/locatorEntityTypes.ts";
|
|
11
|
+
import { LocatorConfig } from "../../../utils/types/StreamDocument.ts";
|
|
12
|
+
import { Body } from "../../atoms/body.tsx";
|
|
13
|
+
import { Button } from "../../atoms/button.tsx";
|
|
14
|
+
import {
|
|
15
|
+
DEFAULT_LOCATOR_RESULT_CARD_PROPS,
|
|
16
|
+
Location,
|
|
17
|
+
LocatorResultCardFields,
|
|
18
|
+
LocatorResultCardProps,
|
|
19
|
+
} from "./LocatorResultCard.tsx";
|
|
20
|
+
|
|
21
|
+
export const RESULTS_LIMIT = 20;
|
|
22
|
+
export type SearchState = "not started" | "loading" | "complete";
|
|
23
|
+
|
|
24
|
+
const BOOLEAN_SUPPORTED_FIELDS = [
|
|
25
|
+
"primaryHeading",
|
|
26
|
+
"secondaryHeading",
|
|
27
|
+
"tertiaryHeading",
|
|
28
|
+
] as const;
|
|
29
|
+
|
|
30
|
+
const getLocatorConfigFromPageSet = (pageSet?: string): LocatorConfig => {
|
|
31
|
+
if (!pageSet) {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(pageSet)?.typeConfig?.locatorConfig ?? {};
|
|
37
|
+
} catch {
|
|
38
|
+
console.error("Failed to parse locator config from page set");
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const translateDistanceUnit = (
|
|
44
|
+
t: (key: string, options?: Record<string, unknown>) => string,
|
|
45
|
+
unit: "mile" | "kilometer",
|
|
46
|
+
count: number
|
|
47
|
+
) => {
|
|
48
|
+
if (unit === "mile") {
|
|
49
|
+
return t("mile", { count, defaultValue: "mile" });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return t("kilometer", { count, defaultValue: "kilometer" });
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
interface MobileLocatorResultsSectionProps {
|
|
56
|
+
CardComponent: React.ComponentType<CardProps<Location>>;
|
|
57
|
+
results: Result<Location>[];
|
|
58
|
+
hasMoreResults: boolean;
|
|
59
|
+
handleShowMoreResults: () => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const ResultCardPropsField = ({
|
|
63
|
+
value,
|
|
64
|
+
onChange,
|
|
65
|
+
}: {
|
|
66
|
+
value?: LocatorResultCardProps;
|
|
67
|
+
onChange: (value: LocatorResultCardProps) => void;
|
|
68
|
+
}) => {
|
|
69
|
+
const streamDocument = useDocument();
|
|
70
|
+
const templateMetadata = useTemplateMetadata();
|
|
71
|
+
const entityTypeSourceMap = getLocatorEntityTypeSourceMap();
|
|
72
|
+
const entityTypeScopes = React.useMemo(() => {
|
|
73
|
+
const locatorConfig = getLocatorConfigFromPageSet(streamDocument?._pageset);
|
|
74
|
+
return locatorConfig.entityTypeScope ?? [];
|
|
75
|
+
}, [streamDocument]);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Builds the field schema for the result card editor, including:
|
|
79
|
+
* - Conditionally removing the primary CTA section when entity scope is not attached to a page set.
|
|
80
|
+
* - Toggling constant value vs. field selector visibility per section.
|
|
81
|
+
*/
|
|
82
|
+
const resultCardFields = React.useMemo(() => {
|
|
83
|
+
if (!value?.entityType) {
|
|
84
|
+
return LocatorResultCardFields;
|
|
85
|
+
}
|
|
86
|
+
let fields = LocatorResultCardFields;
|
|
87
|
+
const entityTypeHasSourcePageSet = !!entityTypeSourceMap[value.entityType];
|
|
88
|
+
const scopeExistsForEntityType =
|
|
89
|
+
entityTypeScopes.find(
|
|
90
|
+
(scope) => scope.entityType === value.entityType
|
|
91
|
+
) !== undefined;
|
|
92
|
+
|
|
93
|
+
fields = setDeep(
|
|
94
|
+
fields,
|
|
95
|
+
`objectFields.primaryCTA.objectFields.link.visible`,
|
|
96
|
+
!entityTypeHasSourcePageSet && scopeExistsForEntityType
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// For each section, show either the field selector or the constant value editor.
|
|
100
|
+
BOOLEAN_SUPPORTED_FIELDS.forEach((key) => {
|
|
101
|
+
const headingConfig = value[key];
|
|
102
|
+
const constantValueEnabled = headingConfig?.constantValueEnabled ?? false;
|
|
103
|
+
const field = headingConfig?.field;
|
|
104
|
+
const fieldTypeId = field
|
|
105
|
+
? templateMetadata?.locatorDisplayFields?.[field]?.field_type_id
|
|
106
|
+
: undefined;
|
|
107
|
+
const booleanFieldSelected =
|
|
108
|
+
!constantValueEnabled && fieldTypeId === "type.boolean";
|
|
109
|
+
|
|
110
|
+
fields = setDeep(
|
|
111
|
+
fields,
|
|
112
|
+
`objectFields.${key}.objectFields.field.visible`,
|
|
113
|
+
!constantValueEnabled
|
|
114
|
+
);
|
|
115
|
+
fields = setDeep(
|
|
116
|
+
fields,
|
|
117
|
+
`objectFields.${key}.objectFields.constantValue.visible`,
|
|
118
|
+
constantValueEnabled
|
|
119
|
+
);
|
|
120
|
+
fields = setDeep(
|
|
121
|
+
fields,
|
|
122
|
+
`objectFields.${key}.objectFields.trueDisplayText.visible`,
|
|
123
|
+
!constantValueEnabled && booleanFieldSelected
|
|
124
|
+
);
|
|
125
|
+
fields = setDeep(
|
|
126
|
+
fields,
|
|
127
|
+
`objectFields.${key}.objectFields.falseDisplayText.visible`,
|
|
128
|
+
booleanFieldSelected
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const imageConstantValueEnabled =
|
|
133
|
+
value.image?.constantValueEnabled ?? false;
|
|
134
|
+
fields = setDeep(
|
|
135
|
+
fields,
|
|
136
|
+
"objectFields.image.objectFields.field.visible",
|
|
137
|
+
!imageConstantValueEnabled
|
|
138
|
+
);
|
|
139
|
+
fields = setDeep(
|
|
140
|
+
fields,
|
|
141
|
+
"objectFields.image.objectFields.constantValue.visible",
|
|
142
|
+
imageConstantValueEnabled
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
return fields;
|
|
146
|
+
}, [entityTypeSourceMap, entityTypeScopes, templateMetadata, value]);
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<YextAutoField
|
|
150
|
+
field={resultCardFields}
|
|
151
|
+
value={value ?? DEFAULT_LOCATOR_RESULT_CARD_PROPS}
|
|
152
|
+
onChange={onChange}
|
|
153
|
+
/>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export const MobileLocatorResultsSection = ({
|
|
158
|
+
CardComponent,
|
|
159
|
+
results,
|
|
160
|
+
hasMoreResults,
|
|
161
|
+
handleShowMoreResults,
|
|
162
|
+
}: MobileLocatorResultsSectionProps) => {
|
|
163
|
+
const { t } = useTranslation();
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<>
|
|
167
|
+
{results.length > 0 && (
|
|
168
|
+
<div>
|
|
169
|
+
{results.map((result, position) => (
|
|
170
|
+
<div
|
|
171
|
+
key={
|
|
172
|
+
result.rawData?.id ??
|
|
173
|
+
result.id ??
|
|
174
|
+
`${result.index ?? "result"}-${position}`
|
|
175
|
+
}
|
|
176
|
+
>
|
|
177
|
+
<CardComponent result={result} />
|
|
178
|
+
</div>
|
|
179
|
+
))}
|
|
180
|
+
</div>
|
|
181
|
+
)}
|
|
182
|
+
{hasMoreResults && (
|
|
183
|
+
// Mobile replaces numbered pagination with incremental loading.
|
|
184
|
+
<div className="px-8 py-4">
|
|
185
|
+
<Button
|
|
186
|
+
className="w-full justify-center"
|
|
187
|
+
onClick={handleShowMoreResults}
|
|
188
|
+
>
|
|
189
|
+
{t("showMoreLocations", "Show more locations")}
|
|
190
|
+
</Button>
|
|
191
|
+
</div>
|
|
192
|
+
)}
|
|
193
|
+
</>
|
|
194
|
+
);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
interface ResultsCountSummaryProps {
|
|
198
|
+
searchState: SearchState;
|
|
199
|
+
resultCount: number;
|
|
200
|
+
selectedDistanceOption: number | null;
|
|
201
|
+
filterDisplayName?: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export const ResultsCountSummary = ({
|
|
205
|
+
searchState,
|
|
206
|
+
resultCount,
|
|
207
|
+
selectedDistanceOption,
|
|
208
|
+
filterDisplayName,
|
|
209
|
+
}: ResultsCountSummaryProps) => {
|
|
210
|
+
const { t, i18n } = useTranslation();
|
|
211
|
+
|
|
212
|
+
if (resultCount === 0) {
|
|
213
|
+
if (searchState === "not started") {
|
|
214
|
+
return (
|
|
215
|
+
<Body>
|
|
216
|
+
{t(
|
|
217
|
+
"useOurLocatorToFindALocationNearYou",
|
|
218
|
+
"Use our locator to find a location near you"
|
|
219
|
+
)}
|
|
220
|
+
</Body>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (searchState === "complete") {
|
|
225
|
+
return (
|
|
226
|
+
<Body>
|
|
227
|
+
{t("noResultsFoundForThisArea", "No results found for this area")}
|
|
228
|
+
</Body>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return <div />;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (filterDisplayName) {
|
|
236
|
+
if (selectedDistanceOption) {
|
|
237
|
+
const unit = getPreferredDistanceUnit(i18n.language);
|
|
238
|
+
return (
|
|
239
|
+
<Body>
|
|
240
|
+
{t("locationsWithinDistanceOf", {
|
|
241
|
+
count: resultCount,
|
|
242
|
+
distance: selectedDistanceOption,
|
|
243
|
+
unit: translateDistanceUnit(t, unit, selectedDistanceOption),
|
|
244
|
+
name: filterDisplayName,
|
|
245
|
+
})}
|
|
246
|
+
</Body>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<Body>
|
|
252
|
+
{t("locationsNear", {
|
|
253
|
+
count: resultCount,
|
|
254
|
+
name: filterDisplayName,
|
|
255
|
+
})}
|
|
256
|
+
</Body>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<Body>
|
|
262
|
+
{t("locationWithCount", {
|
|
263
|
+
count: resultCount,
|
|
264
|
+
})}
|
|
265
|
+
</Body>
|
|
266
|
+
);
|
|
267
|
+
};
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
// Public API for code copied into a Section Library.
|
|
2
|
+
export {
|
|
3
|
+
Background,
|
|
4
|
+
type BackgroundProps,
|
|
5
|
+
} from "./components/atoms/background.tsx";
|
|
6
|
+
export { Body, type BodyProps } from "./components/atoms/body.tsx";
|
|
7
|
+
export {
|
|
8
|
+
Button,
|
|
9
|
+
buttonVariants,
|
|
10
|
+
type ButtonProps,
|
|
11
|
+
} from "./components/atoms/button.tsx";
|
|
12
|
+
export {
|
|
13
|
+
CTA,
|
|
14
|
+
isCtaVariantWithColor,
|
|
15
|
+
type CTAProps,
|
|
16
|
+
type CTAVariant,
|
|
17
|
+
} from "./components/atoms/cta.tsx";
|
|
18
|
+
export {
|
|
19
|
+
Heading,
|
|
20
|
+
headingVariants,
|
|
21
|
+
type HeadingProps,
|
|
22
|
+
} from "./components/atoms/heading.tsx";
|
|
23
|
+
export {
|
|
24
|
+
getImageAltText,
|
|
25
|
+
Image,
|
|
26
|
+
imgSizesHelper,
|
|
27
|
+
type ImageProps,
|
|
28
|
+
type ImgSizesByBreakpoint,
|
|
29
|
+
} from "./components/atoms/image.tsx";
|
|
30
|
+
export {
|
|
31
|
+
MaybeLink,
|
|
32
|
+
type MaybeLinkProps,
|
|
33
|
+
} from "./components/atoms/maybeLink.tsx";
|
|
34
|
+
export {
|
|
35
|
+
PageSection,
|
|
36
|
+
type PageSectionProps,
|
|
37
|
+
} from "./components/atoms/pageSection.tsx";
|
|
38
|
+
export {
|
|
39
|
+
formatPhoneNumber,
|
|
40
|
+
PhoneAtom,
|
|
41
|
+
type PhoneAtomProps,
|
|
42
|
+
} from "./components/atoms/phone.tsx";
|
|
43
|
+
export {
|
|
44
|
+
HoursStatusAtom,
|
|
45
|
+
type HoursStatusAtomProps,
|
|
46
|
+
} from "./components/atoms/hoursStatus.tsx";
|
|
47
|
+
export {
|
|
48
|
+
HoursTableAtom,
|
|
49
|
+
type HoursTableAtomProps,
|
|
50
|
+
} from "./components/atoms/hoursTable.tsx";
|
|
51
|
+
export { VisibilityWrapper } from "./components/atoms/visibilityWrapper.tsx";
|
|
52
|
+
export {
|
|
53
|
+
Accordion,
|
|
54
|
+
AccordionContent,
|
|
55
|
+
AccordionItem,
|
|
56
|
+
AccordionTrigger,
|
|
57
|
+
} from "./components/atoms/accordion.tsx";
|
|
58
|
+
export {
|
|
59
|
+
DropdownMenu,
|
|
60
|
+
DropdownMenuContent,
|
|
61
|
+
DropdownMenuItem,
|
|
62
|
+
DropdownMenuTrigger,
|
|
63
|
+
} from "./components/atoms/dropdown.tsx";
|
|
64
|
+
export {
|
|
65
|
+
TimestampAtom,
|
|
66
|
+
TimestampOption,
|
|
67
|
+
type TimestampAtomProps,
|
|
68
|
+
} from "./components/atoms/timestamp.tsx";
|
|
69
|
+
export { VideoAtom, type VideoAtomProps } from "./components/atoms/video.tsx";
|
|
70
|
+
export { MapPinIcon } from "./components/sections/locator/MapPinIcon.tsx";
|
|
71
|
+
export {
|
|
72
|
+
EmbeddedFieldStringInputFromEntity,
|
|
73
|
+
EmbeddedFieldStringInputFromOptions,
|
|
74
|
+
type EmbeddedStringOption,
|
|
75
|
+
} from "./editor/EmbeddedFieldStringInput.tsx";
|
|
76
|
+
export {
|
|
77
|
+
EntityField,
|
|
78
|
+
EntityTooltipsProvider,
|
|
79
|
+
useEntityTooltips,
|
|
80
|
+
} from "./editor/EntityField.tsx";
|
|
81
|
+
export { resolveDataFromParent } from "./editor/ParentData.tsx";
|
|
82
|
+
export {
|
|
83
|
+
YextEntityFieldSelector,
|
|
84
|
+
type RenderYextEntityFieldSelectorProps,
|
|
85
|
+
type YextEntityField,
|
|
86
|
+
} from "./editor/YextEntityFieldSelector.tsx";
|
|
87
|
+
export { ConstantValueModeToggler } from "./fields/EntityFieldSelectorField.tsx";
|
|
88
|
+
export {
|
|
89
|
+
buildLocatorDisplayOptions,
|
|
90
|
+
type ImageField,
|
|
91
|
+
type ImagePayload,
|
|
92
|
+
} from "./fields/ImageField.tsx";
|
|
93
|
+
export { type BasicSelectorField } from "./fields/BasicSelectorField.tsx";
|
|
94
|
+
export {
|
|
95
|
+
type MultiSelectorOption,
|
|
96
|
+
type MultiSelectorValue,
|
|
97
|
+
} from "./fields/MultiSelectorField.tsx";
|
|
98
|
+
export { type YextCTAField } from "./fields/CTASelectorField.tsx";
|
|
99
|
+
export {
|
|
100
|
+
toPuckFields,
|
|
101
|
+
type YextArrayField,
|
|
102
|
+
type YextComponentConfig,
|
|
103
|
+
type YextCustomFieldRenderProps,
|
|
104
|
+
type YextFieldDefinition,
|
|
105
|
+
type YextFieldMap,
|
|
106
|
+
type YextFields,
|
|
107
|
+
type YextObjectField,
|
|
108
|
+
type YextPuckField,
|
|
109
|
+
} from "./fields/fields.ts";
|
|
110
|
+
export { YextAutoField } from "./fields/YextAutoField.tsx";
|
|
111
|
+
export { BackgroundProvider, useBackground } from "./hooks/useBackground.tsx";
|
|
112
|
+
export {
|
|
113
|
+
CardContextProvider,
|
|
114
|
+
useCardContext,
|
|
115
|
+
useParentCardStyles,
|
|
116
|
+
} from "./hooks/useCardContext.tsx";
|
|
117
|
+
export {
|
|
118
|
+
TemplatePropsContext,
|
|
119
|
+
useDocument,
|
|
120
|
+
useTemplateProps,
|
|
121
|
+
} from "./hooks/useDocument.tsx";
|
|
122
|
+
export { gatherSlotStyles, useGetCardSlots } from "./hooks/useGetCardSlots.tsx";
|
|
123
|
+
export { usePreviewWindow } from "./hooks/usePreviewWindow.ts";
|
|
124
|
+
export {
|
|
125
|
+
getViewport,
|
|
126
|
+
useWindowWidth,
|
|
127
|
+
VIEWPORT_BREAKPOINTS,
|
|
128
|
+
} from "./hooks/useViewport.ts";
|
|
129
|
+
export { Button as EditorButton } from "./internal/puck/ui/button.tsx";
|
|
130
|
+
export { linkTypeOptions } from "./internal/puck/constant-value-fields/CallToAction.tsx";
|
|
131
|
+
export { pt, msg, type MsgString } from "./utils/i18n/platform.ts";
|
|
132
|
+
export {
|
|
133
|
+
formatDistance,
|
|
134
|
+
fromMeters,
|
|
135
|
+
getPreferredDistanceUnit,
|
|
136
|
+
toKilometers,
|
|
137
|
+
toMeters,
|
|
138
|
+
toMiles,
|
|
139
|
+
} from "./utils/i18n/distance.ts";
|
|
140
|
+
export {
|
|
141
|
+
isDirectoryGrid,
|
|
142
|
+
sortAlphabetically,
|
|
143
|
+
} from "./utils/directory/utils.ts";
|
|
144
|
+
export {
|
|
145
|
+
getPageMetadata,
|
|
146
|
+
resolveDirectoryRootProps,
|
|
147
|
+
type RootConfig,
|
|
148
|
+
} from "./utils/getPageMetadata.ts";
|
|
149
|
+
export {
|
|
150
|
+
getEntityTypeLabel,
|
|
151
|
+
getLocatorEntityTypeSourceMap,
|
|
152
|
+
isLocatorEntityType,
|
|
153
|
+
type LocatorEntityType,
|
|
154
|
+
} from "./utils/locatorEntityTypes.ts";
|
|
155
|
+
export { DEFAULT_ENTITY_TYPE } from "./utils/locatorEntityTypes.ts";
|
|
156
|
+
export { getRandomPlaceholderImageObject } from "./utils/imagePlaceholders.ts";
|
|
157
|
+
export {
|
|
158
|
+
isNonNormalizableLinkType,
|
|
159
|
+
normalizeLink,
|
|
160
|
+
} from "./utils/normalizeLink.ts";
|
|
161
|
+
export {
|
|
162
|
+
resolveComponentData,
|
|
163
|
+
getDisplayValue,
|
|
164
|
+
} from "./utils/resolveComponentData.tsx";
|
|
165
|
+
export {
|
|
166
|
+
findField,
|
|
167
|
+
resolveField,
|
|
168
|
+
type FieldResolution,
|
|
169
|
+
} from "./utils/resolveYextEntityField.ts";
|
|
170
|
+
export {
|
|
171
|
+
createSearchAnalyticsConfig,
|
|
172
|
+
createSearchHeadlessConfig,
|
|
173
|
+
} from "./utils/searchHeadlessConfig.ts";
|
|
174
|
+
export {
|
|
175
|
+
backgroundColors,
|
|
176
|
+
ThemeOptions,
|
|
177
|
+
type HeadingLevel,
|
|
178
|
+
type ThemeColor,
|
|
179
|
+
} from "./utils/themeConfigOptions.ts";
|
|
180
|
+
export { getThemeValue } from "./utils/getThemeValue.ts";
|
|
181
|
+
export { themeManagerCn } from "./utils/cn.ts";
|
|
182
|
+
export {
|
|
183
|
+
getBackgroundColorClasses,
|
|
184
|
+
getBackgroundColorStyle,
|
|
185
|
+
getTextColorClass,
|
|
186
|
+
getTextColorStyle,
|
|
187
|
+
getThemeColorCssValue,
|
|
188
|
+
isColorContrastWcagCompliant,
|
|
189
|
+
hexToRGB,
|
|
190
|
+
} from "./utils/colors.ts";
|
|
191
|
+
export { getValueFromQueryString } from "./utils/urlQueryString.tsx";
|
|
192
|
+
export { normalizeSlug } from "./utils/slugifier.ts";
|
|
193
|
+
export { deepMerge } from "./utils/themeResolver.ts";
|
|
194
|
+
export { bindSlots } from "./utils/cardSlots/bindSlots.ts";
|
|
195
|
+
export { type SlotMappedCardWrapperType } from "./utils/cardSlots/cardWrapperHelpers.ts";
|
|
196
|
+
export { forwardHeadingLevel } from "./utils/cardSlots/forwardHeadingLevel.ts";
|
|
197
|
+
export { syncLinkedSlotMappedCards } from "./utils/cardSlots/slotMappedCards.ts";
|
|
198
|
+
export { syncParentStyles } from "./utils/cardSlots/syncParentStyles.ts";
|
|
199
|
+
export { createSlottedItemSource } from "./utils/itemSource/createSlottedItemSource.ts";
|
|
200
|
+
export { resolveBreadcrumbs } from "./utils/urls/resolveBreadcrumbs.ts";
|
|
201
|
+
export { resolveDirectoryListChildren } from "./utils/urls/resolveDirectoryListChildren.ts";
|
|
202
|
+
export { resolveLocatorResultUrl } from "./utils/urls/resolveLocatorResultUrl.ts";
|
|
203
|
+
export {
|
|
204
|
+
resolveUrlTemplate,
|
|
205
|
+
resolveUrlTemplateOfChild,
|
|
206
|
+
mergeMeta,
|
|
207
|
+
} from "./utils/urls/resolveUrlTemplate.ts";
|
|
208
|
+
export {
|
|
209
|
+
type LocatorConfig,
|
|
210
|
+
type StreamDocument,
|
|
211
|
+
} from "./utils/types/StreamDocument.ts";
|
|
212
|
+
export {
|
|
213
|
+
type AssetImageType,
|
|
214
|
+
type ImageFillType,
|
|
215
|
+
type TranslatableAssetImage,
|
|
216
|
+
isLocalizedAssetImage,
|
|
217
|
+
resolveLocalizedAssetImage,
|
|
218
|
+
} from "./types/images.ts";
|
|
219
|
+
export { type AssetVideo } from "./types/videos.ts";
|
|
220
|
+
export {
|
|
221
|
+
type PresetImageType,
|
|
222
|
+
type TranslatableString,
|
|
223
|
+
FOOD_DELIVERY_SERVICES,
|
|
224
|
+
} from "./types/types.ts";
|
|
225
|
+
export { getCTAType } from "./internal/utils/ctaFieldUtils.ts";
|
|
226
|
+
export {
|
|
227
|
+
TARGET_ORIGINS,
|
|
228
|
+
useReceiveMessage,
|
|
229
|
+
useSendMessageToParent,
|
|
230
|
+
} from "./internal/hooks/useMessage.ts";
|
|
231
|
+
export { useTemplateMetadata } from "./internal/hooks/useMessageReceivers.ts";
|
|
232
|
+
export { type FieldTypeData } from "./internal/types/templateMetadata.ts";
|
|
233
|
+
export {
|
|
234
|
+
Tooltip,
|
|
235
|
+
TooltipArrow,
|
|
236
|
+
TooltipContent,
|
|
237
|
+
TooltipProvider,
|
|
238
|
+
TooltipTrigger,
|
|
239
|
+
} from "./internal/puck/ui/Tooltip.tsx";
|
|
240
|
+
export { ComponentErrorBoundary } from "./internal/components/ComponentErrorBoundary.tsx";
|
|
241
|
+
export { SectionLibraryVisualEditorProvider } from "./utils/SectionLibraryVisualEditorProvider.tsx";
|
|
242
|
+
export { loadTranslationDictionary } from "./utils/i18n/translationResources.ts";
|
|
243
|
+
export { isVisualEditorTestEnv } from "./components/testing/utils.ts";
|
|
244
|
+
export { fetchLocalesToPathsForEntity } from "./utils/api/fetchLocalesToPathsForEntity.ts";
|
|
245
|
+
export { presetImageIcons } from "./utils/presetImageIcons.tsx";
|