@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.
Files changed (225) hide show
  1. package/dist/SectionLibraryVisualEditorProvider-67ng4X9e.js +108670 -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 +260 -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 +491 -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 +245 -0
  31. package/dist/cli/yextve.js +16888 -0
  32. package/dist/index.d.ts +556 -6260
  33. package/dist/locales/page/cs/visual-editor.json +85 -0
  34. package/dist/locales/page/da/visual-editor.json +73 -0
  35. package/dist/locales/page/de/visual-editor.json +73 -0
  36. package/dist/locales/page/en/visual-editor.json +73 -0
  37. package/dist/locales/page/en-GB/visual-editor.json +73 -0
  38. package/dist/locales/page/es/visual-editor.json +79 -0
  39. package/dist/locales/page/et/visual-editor.json +73 -0
  40. package/dist/locales/page/fi/visual-editor.json +73 -0
  41. package/dist/locales/page/fr/visual-editor.json +79 -0
  42. package/dist/locales/page/hr/visual-editor.json +79 -0
  43. package/dist/locales/page/hu/visual-editor.json +73 -0
  44. package/dist/locales/page/it/visual-editor.json +79 -0
  45. package/dist/locales/page/ja/visual-editor.json +73 -0
  46. package/dist/locales/page/lt/visual-editor.json +85 -0
  47. package/dist/locales/page/lv/visual-editor.json +77 -0
  48. package/dist/locales/page/nb/visual-editor.json +73 -0
  49. package/dist/locales/page/nl/visual-editor.json +73 -0
  50. package/dist/locales/page/pl/visual-editor.json +85 -0
  51. package/dist/locales/page/pt/visual-editor.json +79 -0
  52. package/dist/locales/page/ro/visual-editor.json +79 -0
  53. package/dist/locales/page/sk/visual-editor.json +85 -0
  54. package/dist/locales/page/sv/visual-editor.json +73 -0
  55. package/dist/locales/page/tr/visual-editor.json +73 -0
  56. package/dist/locales/page/zh/visual-editor.json +73 -0
  57. package/dist/locales/page/zh-TW/visual-editor.json +73 -0
  58. package/dist/locales/platform/cs/visual-editor.json +531 -0
  59. package/dist/locales/platform/da/visual-editor.json +519 -0
  60. package/dist/locales/platform/de/visual-editor.json +519 -0
  61. package/dist/locales/platform/en/visual-editor.json +519 -0
  62. package/dist/locales/platform/en-GB/visual-editor.json +519 -0
  63. package/dist/locales/platform/es/visual-editor.json +525 -0
  64. package/dist/locales/platform/et/visual-editor.json +519 -0
  65. package/dist/locales/platform/fi/visual-editor.json +519 -0
  66. package/dist/locales/platform/fr/visual-editor.json +525 -0
  67. package/dist/locales/platform/hr/visual-editor.json +525 -0
  68. package/dist/locales/platform/hu/visual-editor.json +519 -0
  69. package/dist/locales/platform/it/visual-editor.json +525 -0
  70. package/dist/locales/platform/ja/visual-editor.json +519 -0
  71. package/dist/locales/platform/lt/visual-editor.json +531 -0
  72. package/dist/locales/platform/lv/visual-editor.json +523 -0
  73. package/dist/locales/platform/nb/visual-editor.json +519 -0
  74. package/dist/locales/platform/nl/visual-editor.json +519 -0
  75. package/dist/locales/platform/pl/visual-editor.json +531 -0
  76. package/dist/locales/platform/pt/visual-editor.json +525 -0
  77. package/dist/locales/platform/ro/visual-editor.json +525 -0
  78. package/dist/locales/platform/sk/visual-editor.json +531 -0
  79. package/dist/locales/platform/sv/visual-editor.json +519 -0
  80. package/dist/locales/platform/tr/visual-editor.json +519 -0
  81. package/dist/locales/platform/zh/visual-editor.json +519 -0
  82. package/dist/locales/platform/zh-TW/visual-editor.json +519 -0
  83. package/dist/locatorEntityTypes-s4dmT9l5.d.ts +1850 -0
  84. package/dist/plugin/internal/sectionLibraryValidation/builtInTranslationResources.d.ts +3 -0
  85. package/dist/plugin/internal/sectionLibraryValidation/stages/api/api.d.ts +7 -0
  86. package/dist/plugin/internal/sectionLibraryValidation/stages/api/libraryMetadata.d.ts +7 -0
  87. package/dist/plugin/internal/sectionLibraryValidation/stages/code/importRules.d.ts +13 -0
  88. package/dist/plugin/internal/sectionLibraryValidation/stages/code/validateCode.d.ts +10 -0
  89. package/dist/plugin/internal/sectionLibraryValidation/stages/code/xssRules.d.ts +7 -0
  90. package/dist/plugin/internal/sectionLibraryValidation/stages/structure/structure.d.ts +7 -0
  91. package/dist/plugin/internal/sectionLibraryValidation/types.d.ts +48 -0
  92. package/dist/plugin/internal/sectionLibraryValidation/validateSectionLibrary.d.ts +8 -0
  93. package/dist/plugin/internal/sectionLibraryValidation/validationError.d.ts +6 -0
  94. package/dist/plugin/plugin.js +2233 -5786
  95. package/dist/plugin/types/entityFields.d.ts +21 -0
  96. package/dist/plugin/types/images.d.ts +62 -0
  97. package/dist/plugin/types/sectionLibrary.d.ts +94 -0
  98. package/dist/plugin/types/types.d.ts +204 -0
  99. package/dist/plugin/types/videos.d.ts +24 -0
  100. package/dist/plugin/utils/i18n/locales.d.ts +5 -0
  101. package/dist/plugin/utils/i18n/translationResources.d.ts +41 -0
  102. package/dist/plugin/utils/normalizeLocale.d.ts +8 -0
  103. package/dist/plugin/utils/plainText.d.ts +6 -0
  104. package/dist/plugin/vite-plugin/index.d.ts +2 -0
  105. package/dist/plugin/vite-plugin/local-editor/artifacts.d.ts +18 -0
  106. package/dist/plugin/vite-plugin/local-editor/config.d.ts +11 -0
  107. package/dist/plugin/vite-plugin/local-editor/data.d.ts +10 -0
  108. package/dist/plugin/vite-plugin/local-editor/entityFields.d.ts +13 -0
  109. package/dist/plugin/vite-plugin/local-editor/fixtureData.d.ts +12 -0
  110. package/dist/plugin/vite-plugin/local-editor/generatedFiles.d.ts +34 -0
  111. package/dist/plugin/vite-plugin/local-editor/server.d.ts +18 -0
  112. package/dist/plugin/vite-plugin/local-editor/types.d.ts +109 -0
  113. package/dist/plugin/vite-plugin/local-editor/utils.d.ts +16 -0
  114. package/dist/plugin/vite-plugin/plugin.d.ts +8 -0
  115. package/dist/plugin/vite-plugin/section-library/migrationRegistry.d.ts +6 -0
  116. package/dist/plugin/vite-plugin/section-library/sectionFrontmatter.d.ts +3 -0
  117. package/dist/plugin/vite-plugin/section-library/sectionLibraryGenerator.d.ts +21 -0
  118. package/dist/plugin/vite-plugin/section-library/sharedComponentRegistry.d.ts +16 -0
  119. package/dist/section-library-support.js +158 -0
  120. package/dist/sectionLibrarySupport.d.ts +282 -0
  121. package/dist/style.css +1 -1
  122. package/dist/visual-editor-9bLkRo2X.js +702 -0
  123. package/dist/visual-editor-B5f3AZF6.js +706 -0
  124. package/dist/visual-editor-BGZbJkMp.js +694 -0
  125. package/dist/visual-editor-BPVqHHz5.js +706 -0
  126. package/dist/visual-editor-BPvDMSb8.js +706 -0
  127. package/dist/visual-editor-BTT9n9b6.js +718 -0
  128. package/dist/visual-editor-BXSlgf31.js +694 -0
  129. package/dist/visual-editor-BXYlpe7B.js +145 -0
  130. package/dist/visual-editor-Bez9GftS.js +694 -0
  131. package/dist/visual-editor-Bk5QJccl.js +718 -0
  132. package/dist/visual-editor-BqtG2m0y.js +694 -0
  133. package/dist/visual-editor-Bxy81Ezy.js +145 -0
  134. package/dist/visual-editor-C00efXqJ.js +706 -0
  135. package/dist/visual-editor-C0vq2BRM.js +145 -0
  136. package/dist/visual-editor-CCgmYV5S.js +169 -0
  137. package/dist/visual-editor-CERViyTJ.js +145 -0
  138. package/dist/visual-editor-CZdmgAn0.js +706 -0
  139. package/dist/visual-editor-CcOCcCUQ.js +694 -0
  140. package/dist/visual-editor-CjORnP1D.js +169 -0
  141. package/dist/visual-editor-CmomGJB8.js +157 -0
  142. package/dist/visual-editor-Cymg8ID2.js +169 -0
  143. package/dist/visual-editor-D2Hk1nhM.js +145 -0
  144. package/dist/visual-editor-D2_8u6ZI.js +694 -0
  145. package/dist/visual-editor-D4vaqoBN.js +694 -0
  146. package/dist/visual-editor-D6n8EP_O.js +694 -0
  147. package/dist/visual-editor-D8MRFn5x.js +157 -0
  148. package/dist/visual-editor-DKG_E7X4.js +694 -0
  149. package/dist/visual-editor-DOXtCqRv.js +145 -0
  150. package/dist/visual-editor-DQEd3xwY.js +145 -0
  151. package/dist/visual-editor-DQq0_rUn.js +706 -0
  152. package/dist/visual-editor-DRXezaoB.js +694 -0
  153. package/dist/visual-editor-DUngIOnE.js +157 -0
  154. package/dist/visual-editor-DbgFzBNV.js +718 -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-DiLdoISr.js +718 -0
  160. package/dist/visual-editor-DjdqpJU-.js +145 -0
  161. package/dist/visual-editor-DnTPMRV4.js +694 -0
  162. package/dist/visual-editor-DvuH3jyL.js +157 -0
  163. package/dist/visual-editor-E0hASBXn.js +694 -0
  164. package/dist/visual-editor-TfVDfO5_.js +145 -0
  165. package/dist/visual-editor-W1OHU94y.js +694 -0
  166. package/dist/visual-editor-W_ZDmMFn.js +145 -0
  167. package/dist/visual-editor-b7ALusk8.js +145 -0
  168. package/dist/visual-editor-bauJ9beX.js +694 -0
  169. package/dist/visual-editor-erGXf3kS.js +157 -0
  170. package/dist/visual-editor-xnDHZFuO.js +153 -0
  171. package/dist/visual-editor-yiWZqIH0.js +157 -0
  172. package/dist/visual-editor.css +1 -0
  173. package/dist/visual-editor.js +15059 -136530
  174. package/package.json +45 -24
  175. package/dist/editor.css +0 -1
  176. package/dist/visual-editor--AAsqhQc.js +0 -231
  177. package/dist/visual-editor-32on_5DY.js +0 -243
  178. package/dist/visual-editor-49W0_Daf.js +0 -1002
  179. package/dist/visual-editor-8Lal-QZf.js +0 -219
  180. package/dist/visual-editor-B02CmTCX.js +0 -1002
  181. package/dist/visual-editor-BB0a_4dr.js +0 -243
  182. package/dist/visual-editor-BQa0UK-c.js +0 -1002
  183. package/dist/visual-editor-BRG83zQG.js +0 -1010
  184. package/dist/visual-editor-BVBPuEsB.js +0 -219
  185. package/dist/visual-editor-BcCzbooi.js +0 -243
  186. package/dist/visual-editor-BiemHMaD.js +0 -1014
  187. package/dist/visual-editor-Bkj-BZ8U.js +0 -1002
  188. package/dist/visual-editor-Bm_9l-r1.js +0 -1014
  189. package/dist/visual-editor-BsyZIlAm.js +0 -1002
  190. package/dist/visual-editor-BuUXmEr4.js +0 -1002
  191. package/dist/visual-editor-BxUYaP8B.js +0 -219
  192. package/dist/visual-editor-By1sH42E.js +0 -219
  193. package/dist/visual-editor-By9M5eN4.js +0 -231
  194. package/dist/visual-editor-C-MDqVaH.js +0 -219
  195. package/dist/visual-editor-C37Hro7w.js +0 -1026
  196. package/dist/visual-editor-C9I9pWeQ.js +0 -1014
  197. package/dist/visual-editor-CQOcLK3A.js +0 -1002
  198. package/dist/visual-editor-CSIc6-rm.js +0 -219
  199. package/dist/visual-editor-CaTT6blQ.js +0 -227
  200. package/dist/visual-editor-Cw95D-E7.js +0 -1014
  201. package/dist/visual-editor-CwW9rVaZ.js +0 -1002
  202. package/dist/visual-editor-CzC6S5LB.js +0 -1014
  203. package/dist/visual-editor-DAuNRkq8.js +0 -1026
  204. package/dist/visual-editor-DE8qwWp0.js +0 -1002
  205. package/dist/visual-editor-DEmVxnyc.js +0 -1014
  206. package/dist/visual-editor-DFQml8X8.js +0 -219
  207. package/dist/visual-editor-DHbDTZwW.js +0 -231
  208. package/dist/visual-editor-DR14jsjF.js +0 -219
  209. package/dist/visual-editor-DiO1-u9c.js +0 -243
  210. package/dist/visual-editor-Dk9cgdJp.js +0 -231
  211. package/dist/visual-editor-DlohF7nV.js +0 -219
  212. package/dist/visual-editor-DrbkrTPj.js +0 -231
  213. package/dist/visual-editor-Dwy8xGNv.js +0 -1002
  214. package/dist/visual-editor-Dz0yJDfm.js +0 -1026
  215. package/dist/visual-editor-InSI7qrX.js +0 -1026
  216. package/dist/visual-editor-KBcW6ZCw.js +0 -1002
  217. package/dist/visual-editor-Kgxgyjx4.js +0 -231
  218. package/dist/visual-editor-S4ACDl-Z.js +0 -1002
  219. package/dist/visual-editor-VLIdGBGJ.js +0 -1002
  220. package/dist/visual-editor-d-hTp0p2.js +0 -219
  221. package/dist/visual-editor-hqdcvtls.js +0 -219
  222. package/dist/visual-editor-llBar-sw.js +0 -1002
  223. package/dist/visual-editor-pb5PwMmE.js +0 -219
  224. package/dist/visual-editor-wSWVK8SW.js +0 -219
  225. 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";