@yext/visual-editor 1.4.14 → 2.0.0-beta.10
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-DN65KSX7.js +119824 -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 +298 -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 +499 -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 +277 -0
- package/dist/cli/yextve.js +16992 -0
- package/dist/createYextFieldTransforms-CrIkiJ_X.d.ts +2157 -0
- package/dist/index.d.ts +534 -6352
- 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 +651 -0
- package/dist/locales/platform/da/visual-editor.json +625 -0
- package/dist/locales/platform/de/visual-editor.json +625 -0
- package/dist/locales/platform/en/visual-editor.json +625 -0
- package/dist/locales/platform/en-GB/visual-editor.json +625 -0
- package/dist/locales/platform/es/visual-editor.json +638 -0
- package/dist/locales/platform/et/visual-editor.json +625 -0
- package/dist/locales/platform/fi/visual-editor.json +625 -0
- package/dist/locales/platform/fr/visual-editor.json +638 -0
- package/dist/locales/platform/hr/visual-editor.json +638 -0
- package/dist/locales/platform/hu/visual-editor.json +625 -0
- package/dist/locales/platform/it/visual-editor.json +638 -0
- package/dist/locales/platform/ja/visual-editor.json +625 -0
- package/dist/locales/platform/lt/visual-editor.json +651 -0
- package/dist/locales/platform/lv/visual-editor.json +633 -0
- package/dist/locales/platform/nb/visual-editor.json +625 -0
- package/dist/locales/platform/nl/visual-editor.json +625 -0
- package/dist/locales/platform/pl/visual-editor.json +651 -0
- package/dist/locales/platform/pt/visual-editor.json +638 -0
- package/dist/locales/platform/ro/visual-editor.json +638 -0
- package/dist/locales/platform/sk/visual-editor.json +651 -0
- package/dist/locales/platform/sv/visual-editor.json +625 -0
- package/dist/locales/platform/tr/visual-editor.json +625 -0
- package/dist/locales/platform/zh/visual-editor.json +625 -0
- package/dist/locales/platform/zh-TW/visual-editor.json +625 -0
- package/dist/plugin/internal/layoutGeneration/limits.d.ts +28 -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 +7013 -5873
- package/dist/plugin/types/entityFields.d.ts +21 -0
- package/dist/plugin/types/generationPrompts.d.ts +19 -0
- package/dist/plugin/types/generationSettings.d.ts +12 -0
- package/dist/plugin/types/images.d.ts +62 -0
- package/dist/plugin/types/sectionLibrary.d.ts +101 -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/layout-generation/generationLogger.d.ts +5 -0
- package/dist/plugin/vite-plugin/layout-generation/generationReports.d.ts +13 -0
- package/dist/plugin/vite-plugin/layout-generation/middleware.d.ts +14 -0
- package/dist/plugin/vite-plugin/layout-generation/modelProxy.d.ts +9 -0
- package/dist/plugin/vite-plugin/layout-generation/prompts.d.ts +17 -0
- package/dist/plugin/vite-plugin/layout-generation/settings.d.ts +3 -0
- package/dist/plugin/vite-plugin/local-editor/artifacts.d.ts +20 -0
- package/dist/plugin/vite-plugin/local-editor/config.d.ts +11 -0
- package/dist/plugin/vite-plugin/local-editor/data.d.ts +12 -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 +33 -0
- package/dist/plugin/vite-plugin/local-editor/server.d.ts +34 -0
- package/dist/plugin/vite-plugin/local-editor/types.d.ts +125 -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 +178 -0
- package/dist/sectionLibrarySupport.d.ts +703 -0
- package/dist/style.css +1 -1
- package/dist/visual-editor-6mKs9VUe.js +842 -0
- package/dist/visual-editor-BK6fTU7k.js +804 -0
- package/dist/visual-editor-BXYlpe7B.js +145 -0
- package/dist/visual-editor-BruRrJYN.js +804 -0
- package/dist/visual-editor-Bs3wAslG.js +804 -0
- package/dist/visual-editor-Bxy81Ezy.js +145 -0
- package/dist/visual-editor-C0vq2BRM.js +145 -0
- package/dist/visual-editor-C9TLeAzP.js +804 -0
- package/dist/visual-editor-CCgmYV5S.js +169 -0
- package/dist/visual-editor-CERViyTJ.js +145 -0
- package/dist/visual-editor-CHWtMtlu.js +823 -0
- package/dist/visual-editor-CcfUKpnd.js +804 -0
- package/dist/visual-editor-CjORnP1D.js +169 -0
- package/dist/visual-editor-ClC6hoz3.js +804 -0
- package/dist/visual-editor-CmomGJB8.js +157 -0
- package/dist/visual-editor-CtQwadxQ.js +842 -0
- package/dist/visual-editor-Cymg8ID2.js +169 -0
- package/dist/visual-editor-D2Hk1nhM.js +145 -0
- package/dist/visual-editor-D7VeTRK_.js +816 -0
- package/dist/visual-editor-D8MRFn5x.js +157 -0
- package/dist/visual-editor-DOXtCqRv.js +145 -0
- package/dist/visual-editor-DQEd3xwY.js +145 -0
- package/dist/visual-editor-DTE5kxrA.js +804 -0
- package/dist/visual-editor-DUngIOnE.js +157 -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-DjTEbi-1.js +842 -0
- package/dist/visual-editor-DjdqpJU-.js +145 -0
- package/dist/visual-editor-DkHhrFsX.js +804 -0
- package/dist/visual-editor-DtL-Zuv_.js +804 -0
- package/dist/visual-editor-Duishbsa.js +842 -0
- package/dist/visual-editor-DvuH3jyL.js +157 -0
- package/dist/visual-editor-LXMNWXry.js +823 -0
- package/dist/visual-editor-QpGupjY5.js +823 -0
- package/dist/visual-editor-TfVDfO5_.js +145 -0
- package/dist/visual-editor-W_ZDmMFn.js +145 -0
- package/dist/visual-editor-_TatCCAS.js +804 -0
- package/dist/visual-editor-b7ALusk8.js +145 -0
- package/dist/visual-editor-erGXf3kS.js +157 -0
- package/dist/visual-editor-gEaWoNRu.js +804 -0
- package/dist/visual-editor-gjpr-NAN.js +804 -0
- package/dist/visual-editor-qJW0uCiQ.js +804 -0
- package/dist/visual-editor-sOPDMkOR.js +823 -0
- package/dist/visual-editor-tPb7n5l8.js +823 -0
- package/dist/visual-editor-vomNdlNO.js +804 -0
- package/dist/visual-editor-xnDHZFuO.js +153 -0
- package/dist/visual-editor-yiWZqIH0.js +157 -0
- package/dist/visual-editor-zKhC7_0C.js +823 -0
- package/dist/visual-editor.css +1 -0
- package/dist/visual-editor.js +18578 -137536
- package/package.json +50 -26
- package/dist/editor.css +0 -1
- package/dist/visual-editor-6pnSx-yp.js +0 -223
- package/dist/visual-editor-9ZW3nq5u.js +0 -247
- package/dist/visual-editor-B1RXDqNi.js +0 -1063
- package/dist/visual-editor-BAahiZ1l.js +0 -223
- package/dist/visual-editor-BC2LjdoF.js +0 -223
- package/dist/visual-editor-BPnfBfk1.js +0 -1051
- package/dist/visual-editor-BQiE5eVW.js +0 -1051
- package/dist/visual-editor-BTv-6Pnk.js +0 -1051
- package/dist/visual-editor-BUWp03gX.js +0 -235
- package/dist/visual-editor-Bb3c6iGV.js +0 -223
- package/dist/visual-editor-BipczqTj.js +0 -1075
- package/dist/visual-editor-BlIUd_n_.js +0 -1051
- package/dist/visual-editor-BoPLXEu2.js +0 -223
- package/dist/visual-editor-Bzmpi_9a.js +0 -1063
- package/dist/visual-editor-C38IiBTR.js +0 -235
- package/dist/visual-editor-C9tacnim.js +0 -247
- package/dist/visual-editor-CVa3iu5h.js +0 -1051
- package/dist/visual-editor-CXTL8Ik0.js +0 -1051
- package/dist/visual-editor-CYeahjFX.js +0 -231
- package/dist/visual-editor-CZ2SM6Jc.js +0 -1063
- package/dist/visual-editor-CZDmQI-A.js +0 -1063
- package/dist/visual-editor-C_cHJ6BN.js +0 -1051
- package/dist/visual-editor-Cf3nFbw3.js +0 -235
- package/dist/visual-editor-CiR0metz.js +0 -1051
- package/dist/visual-editor-CoX_NnS-.js +0 -223
- package/dist/visual-editor-Cu8II23Y.js +0 -223
- package/dist/visual-editor-CvXFxocc.js +0 -1063
- package/dist/visual-editor-Cxu6nkib.js +0 -1051
- package/dist/visual-editor-D-3VVfjR.js +0 -223
- package/dist/visual-editor-D-ktbg7q.js +0 -223
- package/dist/visual-editor-D9G5eAAU.js +0 -1051
- package/dist/visual-editor-D9MrqEya.js +0 -223
- package/dist/visual-editor-DAKXBbjV.js +0 -1075
- package/dist/visual-editor-DBmJk7ZR.js +0 -235
- package/dist/visual-editor-DG-c2LU9.js +0 -1051
- package/dist/visual-editor-DI_Vk989.js +0 -1051
- package/dist/visual-editor-DOOYgnjP.js +0 -235
- package/dist/visual-editor-DRx3Ax_O.js +0 -1075
- package/dist/visual-editor-DZ66sria.js +0 -1051
- package/dist/visual-editor-DZTPhYcr.js +0 -247
- package/dist/visual-editor-DcH7WJVI.js +0 -223
- package/dist/visual-editor-DdYXgEbR.js +0 -1059
- package/dist/visual-editor-DeWzgcue.js +0 -1063
- package/dist/visual-editor-Dm5ZNn8C.js +0 -223
- package/dist/visual-editor-DqLCIWPQ.js +0 -1051
- package/dist/visual-editor-NoU28r5Y.js +0 -223
- package/dist/visual-editor-WjrJ9nPc.js +0 -235
- package/dist/visual-editor-_h-sdbID.js +0 -223
- package/dist/visual-editor-r4gSQqFM.js +0 -1075
- package/dist/visual-editor-ujQ29mao.js +0 -247
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
import { FieldLabel, setDeep } from "@puckeditor/core";
|
|
2
|
+
import { type MultiSelectorValue } from "../../../fields/MultiSelectorField.tsx";
|
|
3
|
+
import { YextAutoField } from "../../../fields/YextAutoField.tsx";
|
|
4
|
+
import { TranslatableString } from "../../../types/types.ts";
|
|
5
|
+
import { msg, pt } from "../../../utils/i18n/platform.ts";
|
|
6
|
+
import { TranslatableAssetImage } from "../../../types/images.ts";
|
|
7
|
+
import {
|
|
8
|
+
backgroundColors,
|
|
9
|
+
ThemeColor,
|
|
10
|
+
} from "../../../utils/themeConfigOptions.ts";
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_ENTITY_TYPE,
|
|
13
|
+
getEntityTypeLabel,
|
|
14
|
+
getLocatorEntityTypeSourceMap,
|
|
15
|
+
isLocatorEntityType,
|
|
16
|
+
LocatorEntityType,
|
|
17
|
+
} from "../../../utils/locatorEntityTypes.ts";
|
|
18
|
+
import {
|
|
19
|
+
toPuckFields,
|
|
20
|
+
type YextCustomFieldRenderProps,
|
|
21
|
+
YextComponentConfig,
|
|
22
|
+
YextFields,
|
|
23
|
+
} from "../../../fields/fields.ts";
|
|
24
|
+
import { ImageStylingFields } from "../../contentBlocks/image/styling.ts";
|
|
25
|
+
import { getFacetFieldOptions, KEYWORDS_FIELD } from "./Filters.tsx";
|
|
26
|
+
import {
|
|
27
|
+
DEFAULT_LOCATOR_RESULT_CARD_PROPS,
|
|
28
|
+
DistanceDisplayOption,
|
|
29
|
+
LocatorResultCardProps,
|
|
30
|
+
} from "./LocatorResultCard.tsx";
|
|
31
|
+
import { ResultCardPropsField } from "./Results.tsx";
|
|
32
|
+
import { LocatorWrapper } from "./LocatorWrapper.tsx";
|
|
33
|
+
import {
|
|
34
|
+
DEFAULT_LOCATION_STYLE,
|
|
35
|
+
DEFAULT_MAKI_ICON_NAME,
|
|
36
|
+
DEFAULT_PIN_ICON_WIDTH,
|
|
37
|
+
LOCATOR_PIN_ICON_FIELD,
|
|
38
|
+
MAX_PIN_ICON_WIDTH,
|
|
39
|
+
makiIconOptions,
|
|
40
|
+
} from "./Map.tsx";
|
|
41
|
+
const DEFAULT_TITLE = "Find a Location";
|
|
42
|
+
const DEFAULT_DISTANCE_DISPLAY = "distanceFromUser";
|
|
43
|
+
|
|
44
|
+
export interface LocatorProps {
|
|
45
|
+
/**
|
|
46
|
+
* The visual theme for the map tiles, chosen from a predefined list of Mapbox styles.
|
|
47
|
+
* @defaultValue 'mapbox://styles/mapbox/streets-v12'
|
|
48
|
+
*/
|
|
49
|
+
mapStyle?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Props to customize the locator map pin styles.
|
|
53
|
+
* Controls map pin appearance depending on the result's entity type.
|
|
54
|
+
* The number of entries is locked to the locator entity types for the page set.
|
|
55
|
+
*/
|
|
56
|
+
locationStyles: Array<{
|
|
57
|
+
/** The entity type this style applies to. */
|
|
58
|
+
entityType: LocatorEntityType;
|
|
59
|
+
/** Whether to render an icon in the pin. */
|
|
60
|
+
pinIcon?: {
|
|
61
|
+
type: "none" | "icon" | "customImage";
|
|
62
|
+
/** Defaults to the first available Maki icon when type is 'icon'. */
|
|
63
|
+
iconName?: string;
|
|
64
|
+
/** Image rendered within the pin when type is 'customImage'. */
|
|
65
|
+
image?: TranslatableAssetImage;
|
|
66
|
+
/**
|
|
67
|
+
* Width of the custom image rendered within the pin.
|
|
68
|
+
* @defaultValue 14
|
|
69
|
+
* */
|
|
70
|
+
width?: number;
|
|
71
|
+
/** Aspect ratio of the custom image rendered within the pin. */
|
|
72
|
+
aspectRatio?: number;
|
|
73
|
+
};
|
|
74
|
+
/** The color applied to the pin. */
|
|
75
|
+
pinColor?: ThemeColor;
|
|
76
|
+
}>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Configuration for the filters available in the locator search experience.
|
|
80
|
+
*/
|
|
81
|
+
filters: {
|
|
82
|
+
/**
|
|
83
|
+
* If 'true', displays a button to filter for locations that are currently open.
|
|
84
|
+
* @defaultValue false
|
|
85
|
+
*/
|
|
86
|
+
openNowButton: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* If 'true', displays several distance options to filter searches to only locations within
|
|
89
|
+
* a certain radius.
|
|
90
|
+
* @defaultValue false
|
|
91
|
+
*/
|
|
92
|
+
showDistanceOptions: boolean;
|
|
93
|
+
/** Accent color for filter button and icons. */
|
|
94
|
+
accentColor?: ThemeColor;
|
|
95
|
+
/** Which fields are facetable in the search experience. */
|
|
96
|
+
facetFields?: MultiSelectorValue<string>;
|
|
97
|
+
/** The optional display name for the Keywords facet. */
|
|
98
|
+
keywordsDisplayName?: TranslatableString;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The starting location for the map.
|
|
103
|
+
*/
|
|
104
|
+
mapStartingLocation?: {
|
|
105
|
+
latitude: string;
|
|
106
|
+
longitude: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Configuration for the locator page heading.
|
|
110
|
+
* Allows customizing the title text and its color.
|
|
111
|
+
*/
|
|
112
|
+
pageHeading?: {
|
|
113
|
+
/** The title displayed at the top of the locator page. */
|
|
114
|
+
title: TranslatableString;
|
|
115
|
+
/**
|
|
116
|
+
* The color applied to the locator page title.
|
|
117
|
+
* @defaultValue inherited from theme
|
|
118
|
+
*/
|
|
119
|
+
color?: ThemeColor;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Props to customize the locator result card component.
|
|
123
|
+
* Controls which fields are displayed and their styling depending on the result's entity type.
|
|
124
|
+
* The number of entries is locked to the locator entity types for the page set.
|
|
125
|
+
*/
|
|
126
|
+
resultCard: Array<{
|
|
127
|
+
/** Props to customize the locator result card component. */
|
|
128
|
+
props: LocatorResultCardProps;
|
|
129
|
+
}>;
|
|
130
|
+
/** Controls which distance value to display on each locator result card. */
|
|
131
|
+
distanceDisplay?: DistanceDisplayOption;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const locatorFields: YextFields<LocatorProps> = {
|
|
135
|
+
mapStyle: {
|
|
136
|
+
type: "basicSelector",
|
|
137
|
+
label: msg("fields.mapStyle", "Map Style"),
|
|
138
|
+
options: [
|
|
139
|
+
{
|
|
140
|
+
label: msg("fields.options.default", "Default"),
|
|
141
|
+
value: "mapbox://styles/mapbox/streets-v12",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
label: msg("fields.options.satellite", "Satellite"),
|
|
145
|
+
value: "mapbox://styles/mapbox/satellite-streets-v12",
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
label: msg("fields.options.light", "Light"),
|
|
149
|
+
value: "mapbox://styles/mapbox/light-v11",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
label: msg("fields.options.dark", "Dark"),
|
|
153
|
+
value: "mapbox://styles/mapbox/dark-v11",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
label: msg("fields.options.navigationDay", "Navigation (Day)"),
|
|
157
|
+
value: "mapbox://styles/mapbox/navigation-day-v1",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
label: msg("fields.options.navigationNight", "Navigation (Night)"),
|
|
161
|
+
value: "mapbox://styles/mapbox/navigation-night-v1",
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
locationStyles: {
|
|
166
|
+
type: "array",
|
|
167
|
+
label: msg("fields.pinStyles", "Location styles"),
|
|
168
|
+
getItemSummary: (item: LocatorProps["locationStyles"][number]) =>
|
|
169
|
+
getEntityTypeLabel(item.entityType),
|
|
170
|
+
arrayFields: {
|
|
171
|
+
entityType: {
|
|
172
|
+
label: msg("fields.entityType", "Entity Type"),
|
|
173
|
+
type: "text",
|
|
174
|
+
visible: false,
|
|
175
|
+
},
|
|
176
|
+
pinIcon: {
|
|
177
|
+
type: "custom",
|
|
178
|
+
render: ({
|
|
179
|
+
value,
|
|
180
|
+
onChange,
|
|
181
|
+
}: YextCustomFieldRenderProps<
|
|
182
|
+
LocatorProps["locationStyles"][number]["pinIcon"]
|
|
183
|
+
>) => {
|
|
184
|
+
const selectedType = value?.type ?? "none";
|
|
185
|
+
return (
|
|
186
|
+
<div className="flex flex-col gap-3">
|
|
187
|
+
<YextAutoField
|
|
188
|
+
field={{
|
|
189
|
+
type: "basicSelector",
|
|
190
|
+
label: msg("fields.pinIcon", "Pin Icon"),
|
|
191
|
+
options: [
|
|
192
|
+
{
|
|
193
|
+
label: msg("fields.options.none", "None"),
|
|
194
|
+
value: "none",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
label: msg("fields.options.icon", "Icon"),
|
|
198
|
+
value: "icon",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
label: msg("fields.options.customImage", "Custom image"),
|
|
202
|
+
value: "customImage",
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
}}
|
|
206
|
+
value={selectedType}
|
|
207
|
+
onChange={(type) =>
|
|
208
|
+
onChange({
|
|
209
|
+
...value,
|
|
210
|
+
type,
|
|
211
|
+
iconName:
|
|
212
|
+
type === "icon"
|
|
213
|
+
? (value?.iconName ?? DEFAULT_MAKI_ICON_NAME)
|
|
214
|
+
: undefined,
|
|
215
|
+
})
|
|
216
|
+
}
|
|
217
|
+
/>
|
|
218
|
+
{selectedType === "icon" && (
|
|
219
|
+
<YextAutoField
|
|
220
|
+
field={{
|
|
221
|
+
type: "basicSelector",
|
|
222
|
+
label: msg("fields.icon", "Icon"),
|
|
223
|
+
options: makiIconOptions,
|
|
224
|
+
}}
|
|
225
|
+
value={value?.iconName}
|
|
226
|
+
onChange={(iconName) =>
|
|
227
|
+
onChange({ ...value, type: "icon", iconName })
|
|
228
|
+
}
|
|
229
|
+
/>
|
|
230
|
+
)}
|
|
231
|
+
{selectedType === "customImage" && (
|
|
232
|
+
<>
|
|
233
|
+
<YextAutoField
|
|
234
|
+
field={{
|
|
235
|
+
...LOCATOR_PIN_ICON_FIELD,
|
|
236
|
+
}}
|
|
237
|
+
value={value?.image}
|
|
238
|
+
onChange={(image) =>
|
|
239
|
+
onChange({ ...value, type: "customImage", image })
|
|
240
|
+
}
|
|
241
|
+
/>
|
|
242
|
+
<FieldLabel label={pt("fields.options.width", "Width")}>
|
|
243
|
+
<YextAutoField
|
|
244
|
+
field={{
|
|
245
|
+
type: "number",
|
|
246
|
+
min: 1,
|
|
247
|
+
max: MAX_PIN_ICON_WIDTH,
|
|
248
|
+
}}
|
|
249
|
+
value={value?.width ?? DEFAULT_PIN_ICON_WIDTH}
|
|
250
|
+
onChange={(width) =>
|
|
251
|
+
onChange({
|
|
252
|
+
...value,
|
|
253
|
+
type: "customImage",
|
|
254
|
+
width,
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
/>
|
|
258
|
+
</FieldLabel>
|
|
259
|
+
<YextAutoField
|
|
260
|
+
field={ImageStylingFields.aspectRatio}
|
|
261
|
+
value={value?.aspectRatio}
|
|
262
|
+
onChange={(aspectRatio) =>
|
|
263
|
+
onChange({
|
|
264
|
+
...value,
|
|
265
|
+
type: "customImage",
|
|
266
|
+
aspectRatio,
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
/>
|
|
270
|
+
</>
|
|
271
|
+
)}
|
|
272
|
+
</div>
|
|
273
|
+
);
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
pinColor: {
|
|
277
|
+
type: "basicSelector",
|
|
278
|
+
label: msg("fields.pinColor", "Pin Color"),
|
|
279
|
+
options: "BACKGROUND_COLOR",
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
defaultItemProps: {
|
|
283
|
+
entityType: DEFAULT_ENTITY_TYPE,
|
|
284
|
+
pinIcon: { type: "none" },
|
|
285
|
+
pinColor: backgroundColors.background6.value,
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
filters: {
|
|
289
|
+
label: msg("fields.filters", "Filters"),
|
|
290
|
+
type: "object",
|
|
291
|
+
objectFields: {
|
|
292
|
+
openNowButton: {
|
|
293
|
+
label: msg("fields.options.includeOpenNow", "Include Open Now Button"),
|
|
294
|
+
type: "radio",
|
|
295
|
+
options: [
|
|
296
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
297
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
showDistanceOptions: {
|
|
301
|
+
label: msg(
|
|
302
|
+
"fields.options.showDistanceOptions",
|
|
303
|
+
"Include Distance Options"
|
|
304
|
+
),
|
|
305
|
+
type: "radio",
|
|
306
|
+
options: [
|
|
307
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
308
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
309
|
+
],
|
|
310
|
+
},
|
|
311
|
+
accentColor: {
|
|
312
|
+
type: "basicSelector",
|
|
313
|
+
label: msg("fields.accentColor", "Accent Color"),
|
|
314
|
+
options: "SITE_COLOR",
|
|
315
|
+
},
|
|
316
|
+
facetFields: {
|
|
317
|
+
type: "multiSelector",
|
|
318
|
+
label: msg("fields.dynamicFilters", "Dynamic Filters"),
|
|
319
|
+
dropdownLabel: msg("fields.field", "Field"),
|
|
320
|
+
options: () => {
|
|
321
|
+
const entityTypeSourceMap = getLocatorEntityTypeSourceMap();
|
|
322
|
+
const entityTypes =
|
|
323
|
+
Object.keys(entityTypeSourceMap).filter(isLocatorEntityType);
|
|
324
|
+
return getFacetFieldOptions(entityTypes);
|
|
325
|
+
},
|
|
326
|
+
placeholderOptionLabel: msg(
|
|
327
|
+
"fields.options.selectAField",
|
|
328
|
+
"Select a field"
|
|
329
|
+
),
|
|
330
|
+
} as any, // TODO(SUMO-8378): remove 'as any' when puck fixes objectFields typing
|
|
331
|
+
keywordsDisplayName: {
|
|
332
|
+
type: "translatableString",
|
|
333
|
+
label: msg("fields.keywordsDisplayName", "Keywords Display Name"),
|
|
334
|
+
showFieldSelector: false,
|
|
335
|
+
visible: false,
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
mapStartingLocation: {
|
|
340
|
+
type: "object",
|
|
341
|
+
label: msg("fields.options.mapStartingLocation", "Map Starting Location"),
|
|
342
|
+
objectFields: {
|
|
343
|
+
latitude: {
|
|
344
|
+
label: msg("fields.latitude", "Latitude"),
|
|
345
|
+
type: "text",
|
|
346
|
+
},
|
|
347
|
+
longitude: {
|
|
348
|
+
label: msg("fields.longitude", "Longitude"),
|
|
349
|
+
type: "text",
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
pageHeading: {
|
|
354
|
+
type: "object",
|
|
355
|
+
label: msg("fields.pageHeading", "Page Heading"),
|
|
356
|
+
objectFields: {
|
|
357
|
+
title: {
|
|
358
|
+
type: "translatableString",
|
|
359
|
+
label: msg("fields.title", "Title"),
|
|
360
|
+
filter: { types: ["type.string"] },
|
|
361
|
+
},
|
|
362
|
+
color: {
|
|
363
|
+
type: "basicSelector",
|
|
364
|
+
label: msg("fields.color", "Color"),
|
|
365
|
+
options: "SITE_COLOR",
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
resultCard: {
|
|
370
|
+
type: "array",
|
|
371
|
+
label: msg("fields.resultCard", "Result Card"),
|
|
372
|
+
getItemSummary: (item: LocatorProps["resultCard"][number]) =>
|
|
373
|
+
getEntityTypeLabel(item.props.entityType),
|
|
374
|
+
arrayFields: {
|
|
375
|
+
props: {
|
|
376
|
+
type: "custom",
|
|
377
|
+
render: ({
|
|
378
|
+
value,
|
|
379
|
+
onChange,
|
|
380
|
+
}: YextCustomFieldRenderProps<
|
|
381
|
+
LocatorProps["resultCard"][number]["props"]
|
|
382
|
+
>) => <ResultCardPropsField value={value} onChange={onChange} />,
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
defaultItemProps: {
|
|
386
|
+
props: DEFAULT_LOCATOR_RESULT_CARD_PROPS,
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
distanceDisplay: {
|
|
390
|
+
type: "basicSelector",
|
|
391
|
+
label: msg("fields.distanceDisplay", "Distance Display"),
|
|
392
|
+
options: [
|
|
393
|
+
{
|
|
394
|
+
label: msg("fields.options.distanceFromUser", "Distance from User"),
|
|
395
|
+
value: "distanceFromUser",
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
label: msg("fields.options.distanceFromSearch", "Distance from Search"),
|
|
399
|
+
value: "distanceFromSearch",
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
label: msg("fields.options.bothDistances", "Both Distances"),
|
|
403
|
+
value: "bothDistances",
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
label: msg("fields.options.hidden", "Hidden"),
|
|
407
|
+
value: "hidden",
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Available on Locator templates.
|
|
415
|
+
*/
|
|
416
|
+
export const LocatorComponent: YextComponentConfig<LocatorProps> = {
|
|
417
|
+
fields: locatorFields,
|
|
418
|
+
/**
|
|
419
|
+
* Locks array lengths for `locationStyles` and `resultCard` to the current
|
|
420
|
+
* locator entity types so each entity type has exactly one entry.
|
|
421
|
+
*/
|
|
422
|
+
resolveFields: (data, params) => {
|
|
423
|
+
const entityDocument = params.metadata?.streamDocument;
|
|
424
|
+
const entityTypeSourceMap = entityDocument
|
|
425
|
+
? getLocatorEntityTypeSourceMap(entityDocument)
|
|
426
|
+
: { [DEFAULT_ENTITY_TYPE]: undefined };
|
|
427
|
+
const entityTypes = Object.keys(
|
|
428
|
+
entityTypeSourceMap
|
|
429
|
+
) as (keyof typeof entityTypeSourceMap)[];
|
|
430
|
+
const entityTypeCount = entityTypes.length;
|
|
431
|
+
|
|
432
|
+
let updatedFields: YextFields<LocatorProps> = { ...locatorFields };
|
|
433
|
+
updatedFields = setDeep(
|
|
434
|
+
updatedFields,
|
|
435
|
+
"locationStyles.min",
|
|
436
|
+
entityTypeCount
|
|
437
|
+
);
|
|
438
|
+
updatedFields = setDeep(
|
|
439
|
+
updatedFields,
|
|
440
|
+
"locationStyles.max",
|
|
441
|
+
entityTypeCount
|
|
442
|
+
);
|
|
443
|
+
updatedFields = setDeep(updatedFields, "resultCard.min", entityTypeCount);
|
|
444
|
+
updatedFields = setDeep(updatedFields, "resultCard.max", entityTypeCount);
|
|
445
|
+
updatedFields = setDeep(
|
|
446
|
+
updatedFields,
|
|
447
|
+
"filters.objectFields.keywordsDisplayName.visible",
|
|
448
|
+
data.props.filters?.facetFields?.selections.some(
|
|
449
|
+
(selection) => selection.value === KEYWORDS_FIELD
|
|
450
|
+
) ?? false
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
return toPuckFields<LocatorProps>(updatedFields);
|
|
454
|
+
},
|
|
455
|
+
defaultProps: {
|
|
456
|
+
locationStyles: [],
|
|
457
|
+
resultCard: [],
|
|
458
|
+
filters: {
|
|
459
|
+
openNowButton: false,
|
|
460
|
+
showDistanceOptions: false,
|
|
461
|
+
},
|
|
462
|
+
pageHeading: {
|
|
463
|
+
title: { defaultValue: DEFAULT_TITLE },
|
|
464
|
+
},
|
|
465
|
+
distanceDisplay: DEFAULT_DISTANCE_DISPLAY,
|
|
466
|
+
},
|
|
467
|
+
label: msg("components.locator", "Locator"),
|
|
468
|
+
/**
|
|
469
|
+
* Reconciles `props.locationStyles` and `props.resultCard` so
|
|
470
|
+
* each list has exactly one entry per current locator entity type.
|
|
471
|
+
* Missing or mismatched entries are rebuilt from existing
|
|
472
|
+
* values and backfilled with defaults.
|
|
473
|
+
*/
|
|
474
|
+
resolveData: (data, params) => {
|
|
475
|
+
const entityDocument = params.metadata?.streamDocument;
|
|
476
|
+
const entityTypeSourceMap = entityDocument
|
|
477
|
+
? getLocatorEntityTypeSourceMap(entityDocument)
|
|
478
|
+
: { [DEFAULT_ENTITY_TYPE]: undefined };
|
|
479
|
+
const entityTypes = Object.keys(
|
|
480
|
+
entityTypeSourceMap
|
|
481
|
+
) as (keyof typeof entityTypeSourceMap)[];
|
|
482
|
+
|
|
483
|
+
const previousLocationStyles = data.props.locationStyles ?? [];
|
|
484
|
+
const previousResultCard = data.props.resultCard ?? [];
|
|
485
|
+
const hasSameEntityTypes = (currentEntityTypes: string[]) =>
|
|
486
|
+
currentEntityTypes.length === entityTypes.length &&
|
|
487
|
+
entityTypes.every((entityType) =>
|
|
488
|
+
currentEntityTypes.includes(entityType)
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
const locationStylesByEntityType = new globalThis.Map(
|
|
492
|
+
previousLocationStyles
|
|
493
|
+
.filter((item) => !!item.entityType)
|
|
494
|
+
.map((item) => [item.entityType, item] as const)
|
|
495
|
+
);
|
|
496
|
+
const resultCardsByEntityType = new globalThis.Map(
|
|
497
|
+
previousResultCard
|
|
498
|
+
.filter((item) => !!item?.props?.entityType)
|
|
499
|
+
.map((item) => [item.props.entityType, item] as const)
|
|
500
|
+
);
|
|
501
|
+
|
|
502
|
+
const previousLocationStyleEntityTypes = previousLocationStyles.map(
|
|
503
|
+
(item) => item.entityType
|
|
504
|
+
);
|
|
505
|
+
const previousResultCardEntityTypes = previousResultCard.map(
|
|
506
|
+
(item) => item.props?.entityType
|
|
507
|
+
);
|
|
508
|
+
|
|
509
|
+
const shouldReconcileLocationStyles =
|
|
510
|
+
previousLocationStyles.length === 0 ||
|
|
511
|
+
!hasSameEntityTypes(previousLocationStyleEntityTypes);
|
|
512
|
+
const shouldReconcileResultCards =
|
|
513
|
+
previousResultCard.length === 0 ||
|
|
514
|
+
!hasSameEntityTypes(previousResultCardEntityTypes);
|
|
515
|
+
|
|
516
|
+
if (shouldReconcileLocationStyles) {
|
|
517
|
+
const newLocationStyles = entityTypes.map((entityType) => ({
|
|
518
|
+
...DEFAULT_LOCATION_STYLE,
|
|
519
|
+
...locationStylesByEntityType.get(entityType),
|
|
520
|
+
entityType,
|
|
521
|
+
}));
|
|
522
|
+
data = setDeep(data, "props.locationStyles", newLocationStyles);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (shouldReconcileResultCards) {
|
|
526
|
+
const newResultCards = entityTypes.map((entityType) => {
|
|
527
|
+
const existing = resultCardsByEntityType.get(entityType);
|
|
528
|
+
return {
|
|
529
|
+
props: {
|
|
530
|
+
...(existing?.props ?? DEFAULT_LOCATOR_RESULT_CARD_PROPS),
|
|
531
|
+
entityType,
|
|
532
|
+
},
|
|
533
|
+
};
|
|
534
|
+
});
|
|
535
|
+
data = setDeep(data, "props.resultCard", newResultCards);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return data;
|
|
539
|
+
},
|
|
540
|
+
render: (props) => <LocatorWrapper {...props} />,
|
|
541
|
+
};
|
package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorFields.test.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { LocatorComponent } from "./Locator.tsx";
|
|
3
|
+
|
|
4
|
+
const getKeywordsDisplayNameVisibility = (facetValues?: string[]) => {
|
|
5
|
+
const fields = LocatorComponent.resolveFields?.(
|
|
6
|
+
{
|
|
7
|
+
props: {
|
|
8
|
+
filters: {
|
|
9
|
+
facetFields: facetValues
|
|
10
|
+
? {
|
|
11
|
+
selections: facetValues.map((value) => ({ value })),
|
|
12
|
+
}
|
|
13
|
+
: undefined,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
} as any,
|
|
17
|
+
{ metadata: {} } as any
|
|
18
|
+
) as any;
|
|
19
|
+
|
|
20
|
+
return fields.filters.objectFields.keywordsDisplayName.visible;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe("Locator fields", () => {
|
|
24
|
+
it.each([
|
|
25
|
+
{
|
|
26
|
+
name: "shows the display name when Keywords is selected",
|
|
27
|
+
facetValues: ["keywords", "services"],
|
|
28
|
+
expected: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "hides the display name when another facet is selected",
|
|
32
|
+
facetValues: ["services"],
|
|
33
|
+
expected: false,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "hides the display name when no facets are selected",
|
|
37
|
+
facetValues: undefined,
|
|
38
|
+
expected: false,
|
|
39
|
+
},
|
|
40
|
+
])("$name", ({ facetValues, expected }) => {
|
|
41
|
+
expect(getKeywordsDisplayNameVisibility(facetValues)).toBe(expected);
|
|
42
|
+
});
|
|
43
|
+
});
|