@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.
Files changed (234) hide show
  1. package/dist/SectionLibraryVisualEditorProvider-DN65KSX7.js +119824 -0
  2. package/dist/SectionLibraryVisualEditorProvider.css +1 -0
  3. package/dist/cli/assets/directory-locator-source/components/contentBlocks/Address.tsx +251 -0
  4. package/dist/cli/assets/directory-locator-source/components/contentBlocks/HeadingText.tsx +147 -0
  5. package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursStatus.tsx +157 -0
  6. package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursTable.tsx +164 -0
  7. package/dist/cli/assets/directory-locator-source/components/contentBlocks/MapboxStaticMap.tsx +205 -0
  8. package/dist/cli/assets/directory-locator-source/components/contentBlocks/Phone.tsx +155 -0
  9. package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/EmptyImageState.tsx +168 -0
  10. package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/Image.tsx +275 -0
  11. package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/styling.ts +66 -0
  12. package/dist/cli/assets/directory-locator-source/components/contentBlocks/index.ts +13 -0
  13. package/dist/cli/assets/directory-locator-source/components/sections/Breadcrumbs.tsx +298 -0
  14. package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.test.tsx +872 -0
  15. package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.tsx +298 -0
  16. package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryCard.tsx +507 -0
  17. package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryWrapper.tsx +499 -0
  18. package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.test.tsx +226 -0
  19. package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.tsx +98 -0
  20. package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.test.tsx +147 -0
  21. package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.tsx +691 -0
  22. package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.test.tsx +1551 -0
  23. package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.tsx +541 -0
  24. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorFields.test.ts +43 -0
  25. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorResultCard.tsx +1594 -0
  26. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorWrapper.tsx +1157 -0
  27. package/dist/cli/assets/directory-locator-source/components/sections/locator/Map.tsx +304 -0
  28. package/dist/cli/assets/directory-locator-source/components/sections/locator/MapPinIcon.tsx +160 -0
  29. package/dist/cli/assets/directory-locator-source/components/sections/locator/Results.tsx +267 -0
  30. package/dist/cli/assets/directory-locator-source/sectionLibrarySupport.ts +277 -0
  31. package/dist/cli/yextve.js +16992 -0
  32. package/dist/createYextFieldTransforms-CrIkiJ_X.d.ts +2157 -0
  33. package/dist/index.d.ts +534 -6352
  34. package/dist/locales/page/cs/visual-editor.json +85 -0
  35. package/dist/locales/page/da/visual-editor.json +73 -0
  36. package/dist/locales/page/de/visual-editor.json +73 -0
  37. package/dist/locales/page/en/visual-editor.json +73 -0
  38. package/dist/locales/page/en-GB/visual-editor.json +73 -0
  39. package/dist/locales/page/es/visual-editor.json +79 -0
  40. package/dist/locales/page/et/visual-editor.json +73 -0
  41. package/dist/locales/page/fi/visual-editor.json +73 -0
  42. package/dist/locales/page/fr/visual-editor.json +79 -0
  43. package/dist/locales/page/hr/visual-editor.json +79 -0
  44. package/dist/locales/page/hu/visual-editor.json +73 -0
  45. package/dist/locales/page/it/visual-editor.json +79 -0
  46. package/dist/locales/page/ja/visual-editor.json +73 -0
  47. package/dist/locales/page/lt/visual-editor.json +85 -0
  48. package/dist/locales/page/lv/visual-editor.json +77 -0
  49. package/dist/locales/page/nb/visual-editor.json +73 -0
  50. package/dist/locales/page/nl/visual-editor.json +73 -0
  51. package/dist/locales/page/pl/visual-editor.json +85 -0
  52. package/dist/locales/page/pt/visual-editor.json +79 -0
  53. package/dist/locales/page/ro/visual-editor.json +79 -0
  54. package/dist/locales/page/sk/visual-editor.json +85 -0
  55. package/dist/locales/page/sv/visual-editor.json +73 -0
  56. package/dist/locales/page/tr/visual-editor.json +73 -0
  57. package/dist/locales/page/zh/visual-editor.json +73 -0
  58. package/dist/locales/page/zh-TW/visual-editor.json +73 -0
  59. package/dist/locales/platform/cs/visual-editor.json +651 -0
  60. package/dist/locales/platform/da/visual-editor.json +625 -0
  61. package/dist/locales/platform/de/visual-editor.json +625 -0
  62. package/dist/locales/platform/en/visual-editor.json +625 -0
  63. package/dist/locales/platform/en-GB/visual-editor.json +625 -0
  64. package/dist/locales/platform/es/visual-editor.json +638 -0
  65. package/dist/locales/platform/et/visual-editor.json +625 -0
  66. package/dist/locales/platform/fi/visual-editor.json +625 -0
  67. package/dist/locales/platform/fr/visual-editor.json +638 -0
  68. package/dist/locales/platform/hr/visual-editor.json +638 -0
  69. package/dist/locales/platform/hu/visual-editor.json +625 -0
  70. package/dist/locales/platform/it/visual-editor.json +638 -0
  71. package/dist/locales/platform/ja/visual-editor.json +625 -0
  72. package/dist/locales/platform/lt/visual-editor.json +651 -0
  73. package/dist/locales/platform/lv/visual-editor.json +633 -0
  74. package/dist/locales/platform/nb/visual-editor.json +625 -0
  75. package/dist/locales/platform/nl/visual-editor.json +625 -0
  76. package/dist/locales/platform/pl/visual-editor.json +651 -0
  77. package/dist/locales/platform/pt/visual-editor.json +638 -0
  78. package/dist/locales/platform/ro/visual-editor.json +638 -0
  79. package/dist/locales/platform/sk/visual-editor.json +651 -0
  80. package/dist/locales/platform/sv/visual-editor.json +625 -0
  81. package/dist/locales/platform/tr/visual-editor.json +625 -0
  82. package/dist/locales/platform/zh/visual-editor.json +625 -0
  83. package/dist/locales/platform/zh-TW/visual-editor.json +625 -0
  84. package/dist/plugin/internal/layoutGeneration/limits.d.ts +28 -0
  85. package/dist/plugin/internal/sectionLibraryValidation/builtInTranslationResources.d.ts +3 -0
  86. package/dist/plugin/internal/sectionLibraryValidation/stages/api/api.d.ts +7 -0
  87. package/dist/plugin/internal/sectionLibraryValidation/stages/api/libraryMetadata.d.ts +7 -0
  88. package/dist/plugin/internal/sectionLibraryValidation/stages/code/importRules.d.ts +13 -0
  89. package/dist/plugin/internal/sectionLibraryValidation/stages/code/validateCode.d.ts +10 -0
  90. package/dist/plugin/internal/sectionLibraryValidation/stages/code/xssRules.d.ts +7 -0
  91. package/dist/plugin/internal/sectionLibraryValidation/stages/structure/structure.d.ts +7 -0
  92. package/dist/plugin/internal/sectionLibraryValidation/types.d.ts +48 -0
  93. package/dist/plugin/internal/sectionLibraryValidation/validateSectionLibrary.d.ts +8 -0
  94. package/dist/plugin/internal/sectionLibraryValidation/validationError.d.ts +6 -0
  95. package/dist/plugin/plugin.js +7013 -5873
  96. package/dist/plugin/types/entityFields.d.ts +21 -0
  97. package/dist/plugin/types/generationPrompts.d.ts +19 -0
  98. package/dist/plugin/types/generationSettings.d.ts +12 -0
  99. package/dist/plugin/types/images.d.ts +62 -0
  100. package/dist/plugin/types/sectionLibrary.d.ts +101 -0
  101. package/dist/plugin/types/types.d.ts +204 -0
  102. package/dist/plugin/types/videos.d.ts +24 -0
  103. package/dist/plugin/utils/i18n/locales.d.ts +5 -0
  104. package/dist/plugin/utils/i18n/translationResources.d.ts +41 -0
  105. package/dist/plugin/utils/normalizeLocale.d.ts +8 -0
  106. package/dist/plugin/utils/plainText.d.ts +6 -0
  107. package/dist/plugin/vite-plugin/index.d.ts +2 -0
  108. package/dist/plugin/vite-plugin/layout-generation/generationLogger.d.ts +5 -0
  109. package/dist/plugin/vite-plugin/layout-generation/generationReports.d.ts +13 -0
  110. package/dist/plugin/vite-plugin/layout-generation/middleware.d.ts +14 -0
  111. package/dist/plugin/vite-plugin/layout-generation/modelProxy.d.ts +9 -0
  112. package/dist/plugin/vite-plugin/layout-generation/prompts.d.ts +17 -0
  113. package/dist/plugin/vite-plugin/layout-generation/settings.d.ts +3 -0
  114. package/dist/plugin/vite-plugin/local-editor/artifacts.d.ts +20 -0
  115. package/dist/plugin/vite-plugin/local-editor/config.d.ts +11 -0
  116. package/dist/plugin/vite-plugin/local-editor/data.d.ts +12 -0
  117. package/dist/plugin/vite-plugin/local-editor/entityFields.d.ts +13 -0
  118. package/dist/plugin/vite-plugin/local-editor/fixtureData.d.ts +12 -0
  119. package/dist/plugin/vite-plugin/local-editor/generatedFiles.d.ts +33 -0
  120. package/dist/plugin/vite-plugin/local-editor/server.d.ts +34 -0
  121. package/dist/plugin/vite-plugin/local-editor/types.d.ts +125 -0
  122. package/dist/plugin/vite-plugin/local-editor/utils.d.ts +16 -0
  123. package/dist/plugin/vite-plugin/plugin.d.ts +8 -0
  124. package/dist/plugin/vite-plugin/section-library/migrationRegistry.d.ts +6 -0
  125. package/dist/plugin/vite-plugin/section-library/sectionFrontmatter.d.ts +3 -0
  126. package/dist/plugin/vite-plugin/section-library/sectionLibraryGenerator.d.ts +21 -0
  127. package/dist/plugin/vite-plugin/section-library/sharedComponentRegistry.d.ts +16 -0
  128. package/dist/section-library-support.js +178 -0
  129. package/dist/sectionLibrarySupport.d.ts +703 -0
  130. package/dist/style.css +1 -1
  131. package/dist/visual-editor-6mKs9VUe.js +842 -0
  132. package/dist/visual-editor-BK6fTU7k.js +804 -0
  133. package/dist/visual-editor-BXYlpe7B.js +145 -0
  134. package/dist/visual-editor-BruRrJYN.js +804 -0
  135. package/dist/visual-editor-Bs3wAslG.js +804 -0
  136. package/dist/visual-editor-Bxy81Ezy.js +145 -0
  137. package/dist/visual-editor-C0vq2BRM.js +145 -0
  138. package/dist/visual-editor-C9TLeAzP.js +804 -0
  139. package/dist/visual-editor-CCgmYV5S.js +169 -0
  140. package/dist/visual-editor-CERViyTJ.js +145 -0
  141. package/dist/visual-editor-CHWtMtlu.js +823 -0
  142. package/dist/visual-editor-CcfUKpnd.js +804 -0
  143. package/dist/visual-editor-CjORnP1D.js +169 -0
  144. package/dist/visual-editor-ClC6hoz3.js +804 -0
  145. package/dist/visual-editor-CmomGJB8.js +157 -0
  146. package/dist/visual-editor-CtQwadxQ.js +842 -0
  147. package/dist/visual-editor-Cymg8ID2.js +169 -0
  148. package/dist/visual-editor-D2Hk1nhM.js +145 -0
  149. package/dist/visual-editor-D7VeTRK_.js +816 -0
  150. package/dist/visual-editor-D8MRFn5x.js +157 -0
  151. package/dist/visual-editor-DOXtCqRv.js +145 -0
  152. package/dist/visual-editor-DQEd3xwY.js +145 -0
  153. package/dist/visual-editor-DTE5kxrA.js +804 -0
  154. package/dist/visual-editor-DUngIOnE.js +157 -0
  155. package/dist/visual-editor-DeZVZYfd.js +169 -0
  156. package/dist/visual-editor-DfJMZpiP.js +145 -0
  157. package/dist/visual-editor-DgAsQK9D.js +145 -0
  158. package/dist/visual-editor-Dhi__-7_.js +145 -0
  159. package/dist/visual-editor-DjTEbi-1.js +842 -0
  160. package/dist/visual-editor-DjdqpJU-.js +145 -0
  161. package/dist/visual-editor-DkHhrFsX.js +804 -0
  162. package/dist/visual-editor-DtL-Zuv_.js +804 -0
  163. package/dist/visual-editor-Duishbsa.js +842 -0
  164. package/dist/visual-editor-DvuH3jyL.js +157 -0
  165. package/dist/visual-editor-LXMNWXry.js +823 -0
  166. package/dist/visual-editor-QpGupjY5.js +823 -0
  167. package/dist/visual-editor-TfVDfO5_.js +145 -0
  168. package/dist/visual-editor-W_ZDmMFn.js +145 -0
  169. package/dist/visual-editor-_TatCCAS.js +804 -0
  170. package/dist/visual-editor-b7ALusk8.js +145 -0
  171. package/dist/visual-editor-erGXf3kS.js +157 -0
  172. package/dist/visual-editor-gEaWoNRu.js +804 -0
  173. package/dist/visual-editor-gjpr-NAN.js +804 -0
  174. package/dist/visual-editor-qJW0uCiQ.js +804 -0
  175. package/dist/visual-editor-sOPDMkOR.js +823 -0
  176. package/dist/visual-editor-tPb7n5l8.js +823 -0
  177. package/dist/visual-editor-vomNdlNO.js +804 -0
  178. package/dist/visual-editor-xnDHZFuO.js +153 -0
  179. package/dist/visual-editor-yiWZqIH0.js +157 -0
  180. package/dist/visual-editor-zKhC7_0C.js +823 -0
  181. package/dist/visual-editor.css +1 -0
  182. package/dist/visual-editor.js +18578 -137536
  183. package/package.json +50 -26
  184. package/dist/editor.css +0 -1
  185. package/dist/visual-editor-6pnSx-yp.js +0 -223
  186. package/dist/visual-editor-9ZW3nq5u.js +0 -247
  187. package/dist/visual-editor-B1RXDqNi.js +0 -1063
  188. package/dist/visual-editor-BAahiZ1l.js +0 -223
  189. package/dist/visual-editor-BC2LjdoF.js +0 -223
  190. package/dist/visual-editor-BPnfBfk1.js +0 -1051
  191. package/dist/visual-editor-BQiE5eVW.js +0 -1051
  192. package/dist/visual-editor-BTv-6Pnk.js +0 -1051
  193. package/dist/visual-editor-BUWp03gX.js +0 -235
  194. package/dist/visual-editor-Bb3c6iGV.js +0 -223
  195. package/dist/visual-editor-BipczqTj.js +0 -1075
  196. package/dist/visual-editor-BlIUd_n_.js +0 -1051
  197. package/dist/visual-editor-BoPLXEu2.js +0 -223
  198. package/dist/visual-editor-Bzmpi_9a.js +0 -1063
  199. package/dist/visual-editor-C38IiBTR.js +0 -235
  200. package/dist/visual-editor-C9tacnim.js +0 -247
  201. package/dist/visual-editor-CVa3iu5h.js +0 -1051
  202. package/dist/visual-editor-CXTL8Ik0.js +0 -1051
  203. package/dist/visual-editor-CYeahjFX.js +0 -231
  204. package/dist/visual-editor-CZ2SM6Jc.js +0 -1063
  205. package/dist/visual-editor-CZDmQI-A.js +0 -1063
  206. package/dist/visual-editor-C_cHJ6BN.js +0 -1051
  207. package/dist/visual-editor-Cf3nFbw3.js +0 -235
  208. package/dist/visual-editor-CiR0metz.js +0 -1051
  209. package/dist/visual-editor-CoX_NnS-.js +0 -223
  210. package/dist/visual-editor-Cu8II23Y.js +0 -223
  211. package/dist/visual-editor-CvXFxocc.js +0 -1063
  212. package/dist/visual-editor-Cxu6nkib.js +0 -1051
  213. package/dist/visual-editor-D-3VVfjR.js +0 -223
  214. package/dist/visual-editor-D-ktbg7q.js +0 -223
  215. package/dist/visual-editor-D9G5eAAU.js +0 -1051
  216. package/dist/visual-editor-D9MrqEya.js +0 -223
  217. package/dist/visual-editor-DAKXBbjV.js +0 -1075
  218. package/dist/visual-editor-DBmJk7ZR.js +0 -235
  219. package/dist/visual-editor-DG-c2LU9.js +0 -1051
  220. package/dist/visual-editor-DI_Vk989.js +0 -1051
  221. package/dist/visual-editor-DOOYgnjP.js +0 -235
  222. package/dist/visual-editor-DRx3Ax_O.js +0 -1075
  223. package/dist/visual-editor-DZ66sria.js +0 -1051
  224. package/dist/visual-editor-DZTPhYcr.js +0 -247
  225. package/dist/visual-editor-DcH7WJVI.js +0 -223
  226. package/dist/visual-editor-DdYXgEbR.js +0 -1059
  227. package/dist/visual-editor-DeWzgcue.js +0 -1063
  228. package/dist/visual-editor-Dm5ZNn8C.js +0 -223
  229. package/dist/visual-editor-DqLCIWPQ.js +0 -1051
  230. package/dist/visual-editor-NoU28r5Y.js +0 -223
  231. package/dist/visual-editor-WjrJ9nPc.js +0 -235
  232. package/dist/visual-editor-_h-sdbID.js +0 -223
  233. package/dist/visual-editor-r4gSQqFM.js +0 -1075
  234. package/dist/visual-editor-ujQ29mao.js +0 -247
@@ -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,277 @@
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 FieldGenerationMetadata,
102
+ type YextArrayField,
103
+ type YextComponentConfig,
104
+ type YextTransformedProps,
105
+ type ResolvedComprehensiveCTAValue,
106
+ type YextCustomFieldRenderProps,
107
+ type YextFieldDefinition,
108
+ type YextFieldMap,
109
+ type YextFields,
110
+ type YextObjectField,
111
+ type YextPuckField,
112
+ } from "./fields/fields.ts";
113
+ export { YextAutoField } from "./fields/YextAutoField.tsx";
114
+ export { MaybeRTF } from "./components/helpers/maybeRTF.tsx";
115
+ export { createYextFieldTransforms } from "./fields/fieldTransforms/index.ts";
116
+ export { BackgroundProvider, useBackground } from "./hooks/useBackground.tsx";
117
+ export {
118
+ CardContextProvider,
119
+ useCardContext,
120
+ useParentCardStyles,
121
+ } from "./hooks/useCardContext.tsx";
122
+ export {
123
+ TemplatePropsContext,
124
+ useDocument,
125
+ useTemplateProps,
126
+ } from "./hooks/useDocument.tsx";
127
+ export { gatherSlotStyles, useGetCardSlots } from "./hooks/useGetCardSlots.tsx";
128
+ export { usePreviewWindow } from "./hooks/usePreviewWindow.ts";
129
+ export {
130
+ getViewport,
131
+ useWindowWidth,
132
+ VIEWPORT_BREAKPOINTS,
133
+ } from "./hooks/useViewport.ts";
134
+ export { Button as EditorButton } from "./internal/puck/ui/button.tsx";
135
+ export { linkTypeOptions } from "./internal/puck/constant-value-fields/CallToAction.tsx";
136
+ export { pt, msg, type MsgString } from "./utils/i18n/platform.ts";
137
+ export {
138
+ formatDistance,
139
+ fromMeters,
140
+ getPreferredDistanceUnit,
141
+ toKilometers,
142
+ toMeters,
143
+ toMiles,
144
+ } from "./utils/i18n/distance.ts";
145
+ export {
146
+ isDirectoryGrid,
147
+ sortAlphabetically,
148
+ } from "./utils/directory/utils.ts";
149
+ export {
150
+ getPageMetadata,
151
+ resolveDirectoryRootProps,
152
+ type RootConfig,
153
+ } from "./utils/getPageMetadata.ts";
154
+ export {
155
+ LOCATOR_ENTITY_TYPES,
156
+ getEntityTypeLabel,
157
+ getLocatorEntityTypeSourceMap,
158
+ isLocatorEntityType,
159
+ type LocatorEntityType,
160
+ } from "./utils/locatorEntityTypes.ts";
161
+ export { DEFAULT_ENTITY_TYPE } from "./utils/locatorEntityTypes.ts";
162
+ export { getRandomPlaceholderImageObject } from "./utils/imagePlaceholders.ts";
163
+ export {
164
+ isNonNormalizableLinkType,
165
+ normalizeLink,
166
+ } from "./utils/normalizeLink.ts";
167
+ export {
168
+ resolveComponentData,
169
+ getDisplayValue,
170
+ } from "./utils/resolveComponentData.tsx";
171
+ export {
172
+ findField,
173
+ resolveField,
174
+ type FieldResolution,
175
+ } from "./utils/resolveYextEntityField.ts";
176
+ export {
177
+ createSearchAnalyticsConfig,
178
+ createSearchHeadlessConfig,
179
+ } from "./utils/searchHeadlessConfig.ts";
180
+ export {
181
+ backgroundColors,
182
+ ThemeOptions,
183
+ type HeadingLevel,
184
+ type ThemeColor,
185
+ } from "./utils/themeConfigOptions.ts";
186
+ export { getThemeValue } from "./utils/getThemeValue.ts";
187
+ export { themeManagerCn } from "./utils/cn.ts";
188
+ export {
189
+ getBackgroundColorClasses,
190
+ getBackgroundColorStyle,
191
+ getTextColorClass,
192
+ getTextColorStyle,
193
+ getThemeColorCssValue,
194
+ isColorContrastWcagCompliant,
195
+ hexToRGB,
196
+ } from "./utils/colors.ts";
197
+ export { getValueFromQueryString } from "./utils/urlQueryString.tsx";
198
+ export { normalizeSlug } from "./utils/slugifier.ts";
199
+ export { deepMerge } from "./utils/themeResolver.ts";
200
+ export { bindSlots } from "./utils/cardSlots/bindSlots.ts";
201
+ export { type SlotMappedCardWrapperType } from "./utils/cardSlots/cardWrapperHelpers.ts";
202
+ export { forwardHeadingLevel } from "./utils/cardSlots/forwardHeadingLevel.ts";
203
+ export { syncLinkedSlotMappedCards } from "./utils/cardSlots/slotMappedCards.ts";
204
+ export { syncParentStyles } from "./utils/cardSlots/syncParentStyles.ts";
205
+ export { createSlottedItemSource } from "./utils/itemSource/createSlottedItemSource.ts";
206
+ export { resolveBreadcrumbs } from "./utils/urls/resolveBreadcrumbs.ts";
207
+ export { resolveDirectoryListChildren } from "./utils/urls/resolveDirectoryListChildren.ts";
208
+ export { resolveLocatorResultUrl } from "./utils/urls/resolveLocatorResultUrl.ts";
209
+ export {
210
+ resolveUrlTemplate,
211
+ resolveUrlTemplateOfChild,
212
+ mergeMeta,
213
+ } from "./utils/urls/resolveUrlTemplate.ts";
214
+ export {
215
+ type LocatorConfig,
216
+ type StreamDocument,
217
+ } from "./utils/types/StreamDocument.ts";
218
+ export {
219
+ type AssetImageType,
220
+ type ImageFillType,
221
+ type TranslatableAssetImage,
222
+ isLocalizedAssetImage,
223
+ resolveLocalizedAssetImage,
224
+ } from "./types/images.ts";
225
+ export { type AssetVideo } from "./types/videos.ts";
226
+ export {
227
+ type PresetImageType,
228
+ type TranslatableString,
229
+ FOOD_DELIVERY_SERVICES,
230
+ } from "./types/types.ts";
231
+ export { getCTAType } from "./internal/utils/ctaFieldUtils.ts";
232
+ export {
233
+ TARGET_ORIGINS,
234
+ useReceiveMessage,
235
+ useSendMessageToParent,
236
+ } from "./internal/hooks/useMessage.ts";
237
+ export { useTemplateMetadata } from "./internal/hooks/useMessageReceivers.ts";
238
+ export { type FieldTypeData } from "./internal/types/templateMetadata.ts";
239
+ export {
240
+ Tooltip,
241
+ TooltipArrow,
242
+ TooltipContent,
243
+ TooltipProvider,
244
+ TooltipTrigger,
245
+ } from "./internal/puck/ui/Tooltip.tsx";
246
+ export { ComponentErrorBoundary } from "./internal/components/ComponentErrorBoundary.tsx";
247
+ export { SectionLibraryVisualEditorProvider } from "./utils/SectionLibraryVisualEditorProvider.tsx";
248
+ export { loadTranslationDictionary } from "./utils/i18n/translationResources.ts";
249
+ export { isVisualEditorTestEnv } from "./components/testing/utils.ts";
250
+ export { fetchLocalesToPathsForEntity } from "./utils/api/fetchLocalesToPathsForEntity.ts";
251
+ export { presetImageIcons } from "./utils/presetImageIcons.tsx";
252
+ export {
253
+ createPuckGenerationCatalog,
254
+ withGenerationCatalog,
255
+ } from "./utils/createPuckGenerationCatalog.ts";
256
+ export type { LayoutGenerationMetadata as ComponentGenerationMetadata } from "./fields/fields.ts";
257
+ export {
258
+ inferFieldZodSchema,
259
+ widthZodSchema,
260
+ } from "./utils/layoutGenerationSchemas/inferFieldZodSchema.ts";
261
+ export { resolveCanonicalSelectorGroups } from "./utils/selectorOptions.ts";
262
+ export {
263
+ translatableStringZodSchema,
264
+ richTextZodSchema,
265
+ translatableRichTextZodSchema,
266
+ assetImageZodSchema,
267
+ imageZodSchema,
268
+ entityFieldZodSchema,
269
+ enhancedCtaZodSchema,
270
+ ctaSelectorZodSchema,
271
+ comprehensiveCtaZodSchema,
272
+ hoursZodSchema,
273
+ } from "./utils/layoutGenerationSchemas/yextFieldSchemas.ts";
274
+ export {
275
+ backgroundColorZodSchema,
276
+ siteColorZodSchema,
277
+ } from "./utils/layoutGenerationSchemas/colorFieldSchemas.ts";