@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,164 @@
1
+ import { useTranslation } from "react-i18next";
2
+ import { PuckComponent } from "@puckeditor/core";
3
+ import { DayOfWeekNames, HoursType } from "@yext/pages-components";
4
+ import "@yext/pages-components/style.css";
5
+ import { EntityField } from "../../editor/EntityField.tsx";
6
+ import { HoursTableAtom } from "../atoms/hoursTable.tsx";
7
+ import { resolveComponentData } from "../../utils/resolveComponentData.tsx";
8
+ import { useDocument } from "../../hooks/useDocument.tsx";
9
+ import { YextEntityField } from "../../editor/YextEntityFieldSelector.tsx";
10
+ import { msg, pt } from "../../utils/i18n/platform.ts";
11
+ import { Body } from "../atoms/body.tsx";
12
+ import { YextComponentConfig, YextFields } from "../../fields/fields.ts";
13
+
14
+ /** Props for the HoursTable component. */
15
+ export interface HoursTableProps {
16
+ data: {
17
+ /** The hours data to display in the table. */
18
+ hours: YextEntityField<HoursType>;
19
+ };
20
+ styles: {
21
+ /**
22
+ * The day of week to display at the top of the table.
23
+ * If set to "today", the current day will dynamically be at the top.
24
+ */
25
+ startOfWeek: keyof DayOfWeekNames | "today";
26
+ /** If true, consecutive days that have the same hours will be collapsed into one row. */
27
+ collapseDays: boolean;
28
+ /** Shows the showAdditionalHoursText subfield from the hours field, if present */
29
+ showAdditionalHoursText: boolean;
30
+ /** Alignment of the text in the hours table */
31
+ alignment: "items-start" | "items-center";
32
+ };
33
+ }
34
+
35
+ // HoursTable data field used in HoursTable and CoreInfoSection
36
+ export const HoursTableDataField: YextFields<HoursTableProps["data"]>["hours"] =
37
+ {
38
+ type: "entityField",
39
+ label: msg("fields.hours", "Hours"),
40
+ filter: {
41
+ types: ["type.hours"],
42
+ },
43
+ };
44
+
45
+ type HoursTableStyleFieldProps = Omit<HoursTableProps["styles"], "alignment">;
46
+
47
+ // HoursTable style fields used in HoursTable and CoreInfoSection
48
+ export const HoursTableStyleFields: YextFields<HoursTableStyleFieldProps> = {
49
+ startOfWeek: {
50
+ type: "basicSelector",
51
+ label: msg("fields.startOfTheWeek", "Start of the Week"),
52
+ options: "HOURS_OPTIONS",
53
+ },
54
+ collapseDays: {
55
+ label: msg("fields.collapseDays", "Collapse Days"),
56
+ type: "radio",
57
+ options: [
58
+ { label: msg("fields.options.yes", "Yes"), value: true },
59
+ { label: msg("fields.options.no", "No"), value: false },
60
+ ],
61
+ },
62
+ showAdditionalHoursText: {
63
+ label: msg(
64
+ "fields.options.showAdditionalHoursText",
65
+ "Show Additional Hours Text"
66
+ ),
67
+ type: "radio",
68
+ options: [
69
+ { label: msg("fields.options.yes", "Yes"), value: true },
70
+ { label: msg("fields.options.no", "No"), value: false },
71
+ ],
72
+ },
73
+ };
74
+
75
+ export const hoursTableFields: YextFields<HoursTableProps> = {
76
+ data: {
77
+ type: "object",
78
+ label: msg("fields.data", "Data"),
79
+ objectFields: {
80
+ hours: HoursTableDataField,
81
+ },
82
+ },
83
+ styles: {
84
+ type: "object",
85
+ label: msg("fields.styles", "Styles"),
86
+ objectFields: {
87
+ ...HoursTableStyleFields,
88
+ alignment: {
89
+ label: msg("fields.contentAlignment", "Content Alignment"),
90
+ type: "radio",
91
+ options: [
92
+ { label: msg("fields.options.left", "Left"), value: "items-start" },
93
+ {
94
+ label: msg("fields.options.center", "Center"),
95
+ value: "items-center",
96
+ },
97
+ ],
98
+ },
99
+ },
100
+ },
101
+ };
102
+
103
+ const VisualEditorHoursTable: PuckComponent<HoursTableProps> = (props) => {
104
+ const { data, styles, puck } = props;
105
+ const { i18n } = useTranslation();
106
+ const streamDocument = useDocument();
107
+ const comingSoon = !!streamDocument.comingSoon;
108
+ const hours = resolveComponentData(data.hours, i18n.language, streamDocument);
109
+
110
+ const { additionalHoursText } = streamDocument as {
111
+ additionalHoursText: string;
112
+ };
113
+
114
+ return hours || comingSoon ? (
115
+ <div className={`flex flex-col ${styles.alignment}`}>
116
+ <EntityField
117
+ displayName={pt("hours", "Hours")}
118
+ fieldId="hours"
119
+ constantValueEnabled={data.hours.constantValueEnabled}
120
+ >
121
+ <HoursTableAtom
122
+ hours={hours ?? {}}
123
+ comingSoon={comingSoon}
124
+ startOfWeek={styles.startOfWeek}
125
+ collapseDays={styles.collapseDays}
126
+ />
127
+ </EntityField>
128
+ {additionalHoursText && styles.showAdditionalHoursText && (
129
+ <EntityField
130
+ displayName={pt("hoursText", "Hours Text")}
131
+ fieldId="additionalHoursText"
132
+ >
133
+ <Body variant="sm" className="mt-4">
134
+ {additionalHoursText}
135
+ </Body>
136
+ </EntityField>
137
+ )}
138
+ </div>
139
+ ) : puck.isEditing ? (
140
+ <div className="h-24" />
141
+ ) : (
142
+ <></>
143
+ );
144
+ };
145
+
146
+ export const HoursTable: YextComponentConfig<HoursTableProps> = {
147
+ fields: hoursTableFields,
148
+ defaultProps: {
149
+ data: {
150
+ hours: {
151
+ field: "hours",
152
+ constantValue: {},
153
+ },
154
+ },
155
+ styles: {
156
+ startOfWeek: "today",
157
+ collapseDays: false,
158
+ showAdditionalHoursText: true,
159
+ alignment: "items-center",
160
+ },
161
+ },
162
+ label: msg("components.hoursTable", "Hours Table"),
163
+ render: (props) => <VisualEditorHoursTable {...props} />,
164
+ };
@@ -0,0 +1,205 @@
1
+ import { useTranslation } from "react-i18next";
2
+ import { Coordinate } from "@yext/pages-components";
3
+ import { EntityField } from "../../editor/EntityField.tsx";
4
+ import { resolveComponentData } from "../../utils/resolveComponentData.tsx";
5
+ import { useDocument } from "../../hooks/useDocument.tsx";
6
+ import { YextEntityField } from "../../editor/YextEntityFieldSelector.tsx";
7
+ import { type BasicSelectorField } from "../../fields/BasicSelectorField.tsx";
8
+ import { msg, pt } from "../../utils/i18n/platform.ts";
9
+ import { themeManagerCn } from "../../utils/cn.ts";
10
+ import { Body } from "../atoms/body.tsx";
11
+ import { PuckComponent } from "@puckeditor/core";
12
+ import { StreamDocument } from "../../utils/types/StreamDocument.ts";
13
+ import mapboxLogo from "../assets/mapbox-logo-black.svg";
14
+ import { Map } from "lucide-react";
15
+ import { getThemeValue } from "../../utils/getThemeValue.ts";
16
+ import { YextComponentConfig, YextFields } from "../../fields/fields.ts";
17
+
18
+ export type MapboxStaticProps = {
19
+ coordinate: YextEntityField<Coordinate>;
20
+ mapStyle: string;
21
+ height?: string;
22
+ zoom?: number;
23
+ };
24
+
25
+ export const mapboxStaticMapStyleOptions = [
26
+ { value: "streets-v12", label: msg("fields.options.default", "Default") },
27
+ {
28
+ value: "satellite-streets-v12",
29
+ label: msg("fields.options.satellite", "Satellite"),
30
+ },
31
+ { value: "light-v11", label: msg("fields.options.light", "Light") },
32
+ { value: "dark-v11", label: msg("fields.options.dark", "Dark") },
33
+ {
34
+ value: "navigation-day-v1",
35
+ label: msg("fields.options.navigationDay", "Navigation (Day)"),
36
+ },
37
+ {
38
+ value: "navigation-night-v1",
39
+ label: msg("fields.options.navigationNight", "Navigation (Night)"),
40
+ },
41
+ ];
42
+
43
+ export const mapStyleField: BasicSelectorField = {
44
+ label: msg("fields.mapStyle", "Map Style"),
45
+ type: "basicSelector",
46
+ options: mapboxStaticMapStyleOptions,
47
+ };
48
+
49
+ const mapboxFields: YextFields<MapboxStaticProps> = {
50
+ coordinate: {
51
+ type: "entityField",
52
+ label: msg("fields.coordinates", "Coordinates"),
53
+ filter: { types: ["type.coordinate"] },
54
+ },
55
+ mapStyle: mapStyleField,
56
+ };
57
+
58
+ const getPrimaryColor = (streamDocument: StreamDocument) => {
59
+ return (
60
+ getThemeValue("--colors-palette-primary", streamDocument)
61
+ ?.replace("#", "")
62
+ ?.trim() ?? "000000"
63
+ );
64
+ };
65
+
66
+ export const MapboxStaticMapComponent: PuckComponent<MapboxStaticProps> = ({
67
+ coordinate: coordinateField,
68
+ height = "300px",
69
+ zoom = 14,
70
+ mapStyle = "light-v11",
71
+ puck,
72
+ }) => {
73
+ const { t, i18n } = useTranslation();
74
+ const streamDocument = useDocument<any>();
75
+
76
+ const coordinate = resolveComponentData<Coordinate>(
77
+ coordinateField,
78
+ i18n.language,
79
+ streamDocument
80
+ );
81
+
82
+ // If we are in the layout editor, use the non-URL-restricted Mapbox API key
83
+ const iframe =
84
+ typeof document === "undefined"
85
+ ? undefined
86
+ : (document.getElementById("preview-frame") as HTMLIFrameElement);
87
+ let mapboxApiKey = streamDocument._env?.YEXT_MAPBOX_API_KEY;
88
+ if (
89
+ iframe?.contentDocument &&
90
+ streamDocument._env?.YEXT_EDIT_LAYOUT_MODE_MAPBOX_API_KEY
91
+ ) {
92
+ mapboxApiKey = streamDocument._env.YEXT_EDIT_LAYOUT_MODE_MAPBOX_API_KEY;
93
+ }
94
+
95
+ // Show empty state in editor mode when API key is missing
96
+ if (!mapboxApiKey) {
97
+ if (puck?.isEditing) {
98
+ return (
99
+ <div
100
+ className={themeManagerCn(
101
+ "relative h-[300px] w-full bg-gray-100 rounded-lg border border-gray-200 flex flex-col items-center justify-center py-8 gap-2.5"
102
+ )}
103
+ >
104
+ <Map className="w-12 h-12 text-gray-400" />
105
+ <div className="flex flex-col items-center gap-0">
106
+ <Body variant="base" className="text-gray-500 font-medium">
107
+ {pt(
108
+ "staticMapEmptyStateSectionHidden",
109
+ "Section hidden for all locations"
110
+ )}
111
+ </Body>
112
+ <Body variant="base" className="text-gray-500 font-normal">
113
+ {pt(
114
+ "staticMapEmptyStateMissingApiKey",
115
+ "Failed to load YEXT_MAPBOX_API_KEY. Please check your site's advanced configuration."
116
+ )}
117
+ </Body>
118
+ </div>
119
+ </div>
120
+ );
121
+ }
122
+ console.warn("YEXT_MAPBOX_API_KEY is required for MapboxStaticMap");
123
+ return <></>;
124
+ }
125
+
126
+ if (!coordinate) {
127
+ console.warn(`${coordinateField.field} is not present in the stream`);
128
+ return <></>;
129
+ }
130
+
131
+ const marker = `pin-l+${getPrimaryColor(streamDocument)}(${coordinate.longitude},${coordinate.latitude})`;
132
+
133
+ const staticImageSizes = {
134
+ large: "1280x720",
135
+ medium: "960x540",
136
+ small: "412x412",
137
+ } as const;
138
+
139
+ type StaticImageSize = keyof typeof staticImageSizes;
140
+
141
+ const getMapboxStaticImageUrl = (size: StaticImageSize) => {
142
+ return `https://api.mapbox.com/styles/v1/mapbox/${mapStyle}/static/${marker}/${coordinate.longitude},${coordinate.latitude},${zoom}/${staticImageSizes[size]}?access_token=${mapboxApiKey}&logo=false&attribution=false`;
143
+ };
144
+
145
+ return (
146
+ <EntityField
147
+ displayName={pt("coordinate", "Coordinate")}
148
+ fieldId={coordinateField.field}
149
+ constantValueEnabled={coordinateField.constantValueEnabled}
150
+ className="w-full"
151
+ >
152
+ <div className="relative w-full overflow-hidden" style={{ height }}>
153
+ <picture>
154
+ <source
155
+ media="(max-width: 412px)"
156
+ className="components h-full w-full object-cover"
157
+ srcSet={getMapboxStaticImageUrl("small")}
158
+ />
159
+ <source
160
+ media="(max-width: 960px)"
161
+ className="components h-full w-full object-cover"
162
+ srcSet={getMapboxStaticImageUrl("medium")}
163
+ />
164
+ <img
165
+ loading="lazy"
166
+ src={getMapboxStaticImageUrl("large")}
167
+ className="components h-full w-full object-cover"
168
+ alt={t("map", "Map")}
169
+ />
170
+ </picture>
171
+ {/* Mapbox requires attribution when using their static maps, https://docs.mapbox.com/help/dive-deeper/attribution/#static--print */}
172
+ <span className="absolute bottom-0 right-0 bg-gray-400/50 text-[8px] text-black">
173
+ © <a href="https://www.mapbox.com/about/maps">Mapbox</a>©{" "}
174
+ <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>
175
+ </span>
176
+ <span className="absolute bottom-0 left-0">
177
+ <a href="https://www.mapbox.com/">
178
+ <img
179
+ loading="lazy"
180
+ src={mapboxLogo}
181
+ alt="Mapbox"
182
+ className="w-10"
183
+ />
184
+ </a>
185
+ </span>
186
+ </div>
187
+ </EntityField>
188
+ );
189
+ };
190
+
191
+ export const MapboxStaticMap: YextComponentConfig<MapboxStaticProps> = {
192
+ label: msg("components.mapboxStaticMap", "Mapbox Static Map"),
193
+ fields: mapboxFields,
194
+ defaultProps: {
195
+ coordinate: {
196
+ field: "yextDisplayCoordinate",
197
+ constantValue: {
198
+ latitude: 0,
199
+ longitude: 0,
200
+ },
201
+ },
202
+ mapStyle: "streets-v12",
203
+ },
204
+ render: (props) => <MapboxStaticMapComponent {...props} />,
205
+ };
@@ -0,0 +1,155 @@
1
+ import { useTranslation } from "react-i18next";
2
+ import { useDocument } from "../../hooks/useDocument.tsx";
3
+ import { resolveComponentData } from "../../utils/resolveComponentData.tsx";
4
+ import { EntityField } from "../../editor/EntityField.tsx";
5
+ import { YextEntityField } from "../../editor/YextEntityFieldSelector.tsx";
6
+ import { PhoneAtom } from "../atoms/phone.tsx";
7
+ import { msg, pt } from "../../utils/i18n/platform.ts";
8
+ import { TranslatableString } from "../../types/types.ts";
9
+ import {
10
+ ThemeColor,
11
+ ThemeOptions,
12
+ backgroundColors,
13
+ } from "../../utils/themeConfigOptions.ts";
14
+ import { resolveDataFromParent } from "../../editor/ParentData.tsx";
15
+ import { YextComponentConfig, YextFields } from "../../fields/fields.ts";
16
+
17
+ /** The props for the Phone component */
18
+ export interface PhoneProps {
19
+ data: {
20
+ /** The phone number data to display */
21
+ number: YextEntityField<string>;
22
+ /** The text to display before the phone number */
23
+ label: TranslatableString;
24
+ };
25
+
26
+ styles: {
27
+ /** Whether to format the phone number like a domestic or international number */
28
+ phoneFormat: "domestic" | "international";
29
+ /** Whether to make the phone number a clickable link */
30
+ includePhoneHyperlink: boolean;
31
+ /** Whether to include the phone icon, defaults to true */
32
+ includeIcon?: boolean;
33
+ /** The color applied to both the phone icon background and the phone link. */
34
+ color?: ThemeColor;
35
+ };
36
+
37
+ /** @internal */
38
+ parentData?: {
39
+ field: string;
40
+ phoneNumber?: string;
41
+ };
42
+ }
43
+
44
+ // Phone field definitions used in Phone and CoreInfoSection
45
+ export const PhoneDataFields: YextFields<PhoneProps["data"]> = {
46
+ number: {
47
+ type: "entityField",
48
+ label: msg("fields.phoneNumber", "Phone Number"),
49
+ filter: {
50
+ types: ["type.phone"],
51
+ },
52
+ },
53
+ label: {
54
+ type: "translatableString",
55
+ label: msg("fields.label", "Label"),
56
+ filter: { types: ["type.string"] },
57
+ },
58
+ };
59
+
60
+ // Phone style definitions used in Phone and CoreInfoSection
61
+ export const PhoneStyleFields: YextFields<PhoneProps["styles"]> = {
62
+ phoneFormat: {
63
+ label: msg("fields.phoneFormat", "Phone Format"),
64
+ type: "radio",
65
+ options: ThemeOptions.PHONE_OPTIONS,
66
+ },
67
+ // By adding `<boolean>`, we make the type explicit.
68
+ includePhoneHyperlink: {
69
+ label: msg("fields.includePhoneHyperlink", "Include Phone Hyperlink"),
70
+ type: "radio",
71
+ options: [
72
+ { label: msg("fields.options.yes", "Yes"), value: true },
73
+ { label: msg("fields.options.no", "No"), value: false },
74
+ ],
75
+ },
76
+ includeIcon: {
77
+ label: msg("fields.showIcon", "Show Icon"),
78
+ type: "radio",
79
+ options: ThemeOptions.SHOW_HIDE,
80
+ },
81
+ color: {
82
+ type: "basicSelector",
83
+ label: msg("fields.color", "Color"),
84
+ options: "SITE_COLOR",
85
+ },
86
+ };
87
+
88
+ export const defaultPhoneDataProps: PhoneProps["data"] = {
89
+ number: {
90
+ field: "mainPhone",
91
+ constantValue: "",
92
+ },
93
+ label: { defaultValue: "Phone" },
94
+ };
95
+
96
+ export const PhoneFields: YextFields<PhoneProps> = {
97
+ data: {
98
+ type: "object",
99
+ label: msg("fields.data", "Data"),
100
+ objectFields: PhoneDataFields,
101
+ },
102
+ styles: {
103
+ type: "object",
104
+ label: msg("fields.styles", "Styles"),
105
+ objectFields: PhoneStyleFields,
106
+ },
107
+ };
108
+
109
+ const PhoneComponent = ({ data, styles, parentData }: PhoneProps) => {
110
+ const { i18n } = useTranslation();
111
+ const streamDocument = useDocument();
112
+ const resolvedPhone =
113
+ parentData?.phoneNumber ??
114
+ resolveComponentData(data.number, i18n.language, streamDocument);
115
+
116
+ if (!resolvedPhone) {
117
+ return;
118
+ }
119
+
120
+ return (
121
+ <EntityField
122
+ displayName={
123
+ parentData ? parentData.field : pt("fields.phoneNumber", "Phone Number")
124
+ }
125
+ fieldId={data.number.field}
126
+ constantValueEnabled={!parentData && data.number.constantValueEnabled}
127
+ >
128
+ <PhoneAtom
129
+ backgroundColor={styles.color ?? backgroundColors.background2.value}
130
+ eventName={`phone`}
131
+ format={styles.phoneFormat}
132
+ label={resolveComponentData(data.label, i18n.language, streamDocument)}
133
+ phoneNumber={resolvedPhone}
134
+ includeHyperlink={styles.includePhoneHyperlink}
135
+ includeIcon={styles.includeIcon ?? true}
136
+ linkColor={styles.color}
137
+ />
138
+ </EntityField>
139
+ );
140
+ };
141
+
142
+ export const Phone: YextComponentConfig<PhoneProps> = {
143
+ label: msg("components.phone", "Phone"),
144
+ fields: PhoneFields,
145
+ defaultProps: {
146
+ data: defaultPhoneDataProps,
147
+ styles: {
148
+ phoneFormat: "domestic",
149
+ includePhoneHyperlink: true,
150
+ includeIcon: true,
151
+ },
152
+ },
153
+ resolveFields: (data) => resolveDataFromParent(PhoneFields, data),
154
+ render: (props) => <PhoneComponent {...props} />,
155
+ };
@@ -0,0 +1,168 @@
1
+ import * as React from "react";
2
+ import { EntityField } from "../../../editor/EntityField.tsx";
3
+ import { pt } from "../../../utils/i18n/platform.ts";
4
+ import { themeManagerCn } from "../../../utils/cn.ts";
5
+ import { AssetImageType } from "../../../types/images.ts";
6
+ import { ImagePlus } from "lucide-react";
7
+ import { Button } from "../../../internal/puck/ui/button.tsx";
8
+ import {
9
+ TARGET_ORIGINS,
10
+ useSendMessageToParent,
11
+ useReceiveMessage,
12
+ } from "../../../internal/hooks/useMessage.ts";
13
+ import { type ImagePayload } from "../../../fields/ImageField.tsx";
14
+
15
+ let pendingEmptyImageSession:
16
+ { messageId: string; apply: (payload: ImagePayload) => void } | undefined;
17
+
18
+ interface EmptyImageStateProps {
19
+ isEmpty: boolean;
20
+ isEditing: boolean;
21
+ constantValueEnabled: boolean;
22
+ constantValue: AssetImageType | undefined;
23
+ fieldId: string;
24
+ containerStyle?: React.CSSProperties;
25
+ containerClassName?: string;
26
+ fullHeight?: boolean;
27
+ dragRef?: React.Ref<HTMLDivElement>;
28
+ hasParentData?: boolean;
29
+ onImageSelected?: (imageData: AssetImageType) => void;
30
+ }
31
+
32
+ export const EmptyImageState: React.FC<EmptyImageStateProps> = ({
33
+ isEmpty,
34
+ isEditing,
35
+ constantValueEnabled,
36
+ constantValue,
37
+ fieldId,
38
+ containerStyle,
39
+ containerClassName,
40
+ dragRef,
41
+ hasParentData = false,
42
+ onImageSelected,
43
+ }) => {
44
+ const { sendToParent: openImageAssetSelector } = useSendMessageToParent(
45
+ "constantValueEditorOpened",
46
+ TARGET_ORIGINS
47
+ );
48
+
49
+ // Listen for image selection response
50
+ useReceiveMessage(
51
+ "constantValueEditorClosed",
52
+ TARGET_ORIGINS,
53
+ (_, payload) => {
54
+ const imagePayload = payload as ImagePayload;
55
+ if (pendingEmptyImageSession?.messageId === imagePayload?.id) {
56
+ const { apply } = pendingEmptyImageSession;
57
+ pendingEmptyImageSession = undefined;
58
+ apply(imagePayload);
59
+ }
60
+ }
61
+ );
62
+
63
+ const handleImageSelection = React.useCallback(() => {
64
+ if (!hasParentData && constantValueEnabled && isEditing) {
65
+ if (window.location.href.includes("http://localhost:5173")) {
66
+ const userInput = prompt("Enter Image URL:");
67
+ if (!userInput) {
68
+ return;
69
+ }
70
+ if (onImageSelected) {
71
+ onImageSelected({
72
+ url: userInput,
73
+ height: 1,
74
+ width: 1,
75
+ alternateText: "",
76
+ } as AssetImageType);
77
+ }
78
+ } else {
79
+ const messageId = `ImageAsset-${Date.now()}`;
80
+ pendingEmptyImageSession = {
81
+ messageId,
82
+ apply: (imagePayload) => {
83
+ if (!onImageSelected) {
84
+ return;
85
+ }
86
+
87
+ const imageData =
88
+ imagePayload.value.transformedImage ??
89
+ imagePayload.value.originalImage;
90
+ if (!imageData) {
91
+ return;
92
+ }
93
+
94
+ onImageSelected({
95
+ alternateText: imagePayload.value.altText
96
+ ? {
97
+ [imagePayload.locale]: imagePayload.value.altText,
98
+ hasLocalizedValue: "true",
99
+ }
100
+ : "",
101
+ url: imageData.url,
102
+ height: imageData.dimension?.height ?? 0,
103
+ width: imageData.dimension?.width ?? 0,
104
+ assetImage: imagePayload.value,
105
+ } as AssetImageType);
106
+ },
107
+ };
108
+ openImageAssetSelector({
109
+ payload: {
110
+ type: "ImageAsset",
111
+ value: constantValue,
112
+ id: messageId,
113
+ },
114
+ });
115
+ }
116
+ }
117
+ }, [
118
+ hasParentData,
119
+ constantValueEnabled,
120
+ isEditing,
121
+ constantValue,
122
+ openImageAssetSelector,
123
+ onImageSelected,
124
+ fieldId,
125
+ ]);
126
+
127
+ if (!isEmpty || !isEditing) {
128
+ return null;
129
+ }
130
+
131
+ return (
132
+ <>
133
+ <EntityField
134
+ displayName={pt("fields.image", "Image")}
135
+ fieldId={fieldId}
136
+ constantValueEnabled={!hasParentData && constantValueEnabled}
137
+ fullHeight={false}
138
+ ref={dragRef}
139
+ >
140
+ <div className="w-full relative">
141
+ <div
142
+ className={themeManagerCn(
143
+ containerClassName ||
144
+ "max-w-full rounded-image-borderRadius w-full",
145
+ "border-2 border-dashed border-gray-300 flex items-center justify-center bg-gray-50 hover:bg-gray-100 transition-colors overflow-hidden relative"
146
+ )}
147
+ style={containerStyle}
148
+ >
149
+ <Button
150
+ variant="ghost"
151
+ size="icon"
152
+ className="text-gray-400 hover:text-gray-600 hover:bg-transparent"
153
+ onClick={(e) => {
154
+ e.stopPropagation();
155
+ e.preventDefault();
156
+ handleImageSelection();
157
+ }}
158
+ type="button"
159
+ aria-label={pt("addImage", "Add Image")}
160
+ >
161
+ <ImagePlus size={24} className="stroke-2" />
162
+ </Button>
163
+ </div>
164
+ </div>
165
+ </EntityField>
166
+ </>
167
+ );
168
+ };