@yext/visual-editor 1.4.14 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SectionLibraryVisualEditorProvider-DN65KSX7.js +119824 -0
- package/dist/SectionLibraryVisualEditorProvider.css +1 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/Address.tsx +251 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/HeadingText.tsx +147 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursStatus.tsx +157 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursTable.tsx +164 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/MapboxStaticMap.tsx +205 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/Phone.tsx +155 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/EmptyImageState.tsx +168 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/Image.tsx +275 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/styling.ts +66 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/index.ts +13 -0
- package/dist/cli/assets/directory-locator-source/components/sections/Breadcrumbs.tsx +298 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.test.tsx +872 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.tsx +298 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryCard.tsx +507 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryWrapper.tsx +499 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.test.tsx +226 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.tsx +98 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.test.tsx +147 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.tsx +691 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.test.tsx +1551 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.tsx +541 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorFields.test.ts +43 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorResultCard.tsx +1594 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorWrapper.tsx +1157 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Map.tsx +304 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/MapPinIcon.tsx +160 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Results.tsx +267 -0
- package/dist/cli/assets/directory-locator-source/sectionLibrarySupport.ts +277 -0
- package/dist/cli/yextve.js +16992 -0
- package/dist/createYextFieldTransforms-CrIkiJ_X.d.ts +2157 -0
- package/dist/index.d.ts +534 -6352
- package/dist/locales/page/cs/visual-editor.json +85 -0
- package/dist/locales/page/da/visual-editor.json +73 -0
- package/dist/locales/page/de/visual-editor.json +73 -0
- package/dist/locales/page/en/visual-editor.json +73 -0
- package/dist/locales/page/en-GB/visual-editor.json +73 -0
- package/dist/locales/page/es/visual-editor.json +79 -0
- package/dist/locales/page/et/visual-editor.json +73 -0
- package/dist/locales/page/fi/visual-editor.json +73 -0
- package/dist/locales/page/fr/visual-editor.json +79 -0
- package/dist/locales/page/hr/visual-editor.json +79 -0
- package/dist/locales/page/hu/visual-editor.json +73 -0
- package/dist/locales/page/it/visual-editor.json +79 -0
- package/dist/locales/page/ja/visual-editor.json +73 -0
- package/dist/locales/page/lt/visual-editor.json +85 -0
- package/dist/locales/page/lv/visual-editor.json +77 -0
- package/dist/locales/page/nb/visual-editor.json +73 -0
- package/dist/locales/page/nl/visual-editor.json +73 -0
- package/dist/locales/page/pl/visual-editor.json +85 -0
- package/dist/locales/page/pt/visual-editor.json +79 -0
- package/dist/locales/page/ro/visual-editor.json +79 -0
- package/dist/locales/page/sk/visual-editor.json +85 -0
- package/dist/locales/page/sv/visual-editor.json +73 -0
- package/dist/locales/page/tr/visual-editor.json +73 -0
- package/dist/locales/page/zh/visual-editor.json +73 -0
- package/dist/locales/page/zh-TW/visual-editor.json +73 -0
- package/dist/locales/platform/cs/visual-editor.json +651 -0
- package/dist/locales/platform/da/visual-editor.json +625 -0
- package/dist/locales/platform/de/visual-editor.json +625 -0
- package/dist/locales/platform/en/visual-editor.json +625 -0
- package/dist/locales/platform/en-GB/visual-editor.json +625 -0
- package/dist/locales/platform/es/visual-editor.json +638 -0
- package/dist/locales/platform/et/visual-editor.json +625 -0
- package/dist/locales/platform/fi/visual-editor.json +625 -0
- package/dist/locales/platform/fr/visual-editor.json +638 -0
- package/dist/locales/platform/hr/visual-editor.json +638 -0
- package/dist/locales/platform/hu/visual-editor.json +625 -0
- package/dist/locales/platform/it/visual-editor.json +638 -0
- package/dist/locales/platform/ja/visual-editor.json +625 -0
- package/dist/locales/platform/lt/visual-editor.json +651 -0
- package/dist/locales/platform/lv/visual-editor.json +633 -0
- package/dist/locales/platform/nb/visual-editor.json +625 -0
- package/dist/locales/platform/nl/visual-editor.json +625 -0
- package/dist/locales/platform/pl/visual-editor.json +651 -0
- package/dist/locales/platform/pt/visual-editor.json +638 -0
- package/dist/locales/platform/ro/visual-editor.json +638 -0
- package/dist/locales/platform/sk/visual-editor.json +651 -0
- package/dist/locales/platform/sv/visual-editor.json +625 -0
- package/dist/locales/platform/tr/visual-editor.json +625 -0
- package/dist/locales/platform/zh/visual-editor.json +625 -0
- package/dist/locales/platform/zh-TW/visual-editor.json +625 -0
- package/dist/plugin/internal/layoutGeneration/limits.d.ts +28 -0
- package/dist/plugin/internal/sectionLibraryValidation/builtInTranslationResources.d.ts +3 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/api/api.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/api/libraryMetadata.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/code/importRules.d.ts +13 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/code/validateCode.d.ts +10 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/code/xssRules.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/structure/structure.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/types.d.ts +48 -0
- package/dist/plugin/internal/sectionLibraryValidation/validateSectionLibrary.d.ts +8 -0
- package/dist/plugin/internal/sectionLibraryValidation/validationError.d.ts +6 -0
- package/dist/plugin/plugin.js +7013 -5873
- package/dist/plugin/types/entityFields.d.ts +21 -0
- package/dist/plugin/types/generationPrompts.d.ts +19 -0
- package/dist/plugin/types/generationSettings.d.ts +12 -0
- package/dist/plugin/types/images.d.ts +62 -0
- package/dist/plugin/types/sectionLibrary.d.ts +101 -0
- package/dist/plugin/types/types.d.ts +204 -0
- package/dist/plugin/types/videos.d.ts +24 -0
- package/dist/plugin/utils/i18n/locales.d.ts +5 -0
- package/dist/plugin/utils/i18n/translationResources.d.ts +41 -0
- package/dist/plugin/utils/normalizeLocale.d.ts +8 -0
- package/dist/plugin/utils/plainText.d.ts +6 -0
- package/dist/plugin/vite-plugin/index.d.ts +2 -0
- package/dist/plugin/vite-plugin/layout-generation/generationLogger.d.ts +5 -0
- package/dist/plugin/vite-plugin/layout-generation/generationReports.d.ts +13 -0
- package/dist/plugin/vite-plugin/layout-generation/middleware.d.ts +14 -0
- package/dist/plugin/vite-plugin/layout-generation/modelProxy.d.ts +9 -0
- package/dist/plugin/vite-plugin/layout-generation/prompts.d.ts +17 -0
- package/dist/plugin/vite-plugin/layout-generation/settings.d.ts +3 -0
- package/dist/plugin/vite-plugin/local-editor/artifacts.d.ts +20 -0
- package/dist/plugin/vite-plugin/local-editor/config.d.ts +11 -0
- package/dist/plugin/vite-plugin/local-editor/data.d.ts +12 -0
- package/dist/plugin/vite-plugin/local-editor/entityFields.d.ts +13 -0
- package/dist/plugin/vite-plugin/local-editor/fixtureData.d.ts +12 -0
- package/dist/plugin/vite-plugin/local-editor/generatedFiles.d.ts +33 -0
- package/dist/plugin/vite-plugin/local-editor/server.d.ts +34 -0
- package/dist/plugin/vite-plugin/local-editor/types.d.ts +125 -0
- package/dist/plugin/vite-plugin/local-editor/utils.d.ts +16 -0
- package/dist/plugin/vite-plugin/plugin.d.ts +8 -0
- package/dist/plugin/vite-plugin/section-library/migrationRegistry.d.ts +6 -0
- package/dist/plugin/vite-plugin/section-library/sectionFrontmatter.d.ts +3 -0
- package/dist/plugin/vite-plugin/section-library/sectionLibraryGenerator.d.ts +21 -0
- package/dist/plugin/vite-plugin/section-library/sharedComponentRegistry.d.ts +16 -0
- package/dist/section-library-support.js +178 -0
- package/dist/sectionLibrarySupport.d.ts +703 -0
- package/dist/style.css +1 -1
- package/dist/visual-editor-6mKs9VUe.js +842 -0
- package/dist/visual-editor-BK6fTU7k.js +804 -0
- package/dist/visual-editor-BXYlpe7B.js +145 -0
- package/dist/visual-editor-BruRrJYN.js +804 -0
- package/dist/visual-editor-Bs3wAslG.js +804 -0
- package/dist/visual-editor-Bxy81Ezy.js +145 -0
- package/dist/visual-editor-C0vq2BRM.js +145 -0
- package/dist/visual-editor-C9TLeAzP.js +804 -0
- package/dist/visual-editor-CCgmYV5S.js +169 -0
- package/dist/visual-editor-CERViyTJ.js +145 -0
- package/dist/visual-editor-CHWtMtlu.js +823 -0
- package/dist/visual-editor-CcfUKpnd.js +804 -0
- package/dist/visual-editor-CjORnP1D.js +169 -0
- package/dist/visual-editor-ClC6hoz3.js +804 -0
- package/dist/visual-editor-CmomGJB8.js +157 -0
- package/dist/visual-editor-CtQwadxQ.js +842 -0
- package/dist/visual-editor-Cymg8ID2.js +169 -0
- package/dist/visual-editor-D2Hk1nhM.js +145 -0
- package/dist/visual-editor-D7VeTRK_.js +816 -0
- package/dist/visual-editor-D8MRFn5x.js +157 -0
- package/dist/visual-editor-DOXtCqRv.js +145 -0
- package/dist/visual-editor-DQEd3xwY.js +145 -0
- package/dist/visual-editor-DTE5kxrA.js +804 -0
- package/dist/visual-editor-DUngIOnE.js +157 -0
- package/dist/visual-editor-DeZVZYfd.js +169 -0
- package/dist/visual-editor-DfJMZpiP.js +145 -0
- package/dist/visual-editor-DgAsQK9D.js +145 -0
- package/dist/visual-editor-Dhi__-7_.js +145 -0
- package/dist/visual-editor-DjTEbi-1.js +842 -0
- package/dist/visual-editor-DjdqpJU-.js +145 -0
- package/dist/visual-editor-DkHhrFsX.js +804 -0
- package/dist/visual-editor-DtL-Zuv_.js +804 -0
- package/dist/visual-editor-Duishbsa.js +842 -0
- package/dist/visual-editor-DvuH3jyL.js +157 -0
- package/dist/visual-editor-LXMNWXry.js +823 -0
- package/dist/visual-editor-QpGupjY5.js +823 -0
- package/dist/visual-editor-TfVDfO5_.js +145 -0
- package/dist/visual-editor-W_ZDmMFn.js +145 -0
- package/dist/visual-editor-_TatCCAS.js +804 -0
- package/dist/visual-editor-b7ALusk8.js +145 -0
- package/dist/visual-editor-erGXf3kS.js +157 -0
- package/dist/visual-editor-gEaWoNRu.js +804 -0
- package/dist/visual-editor-gjpr-NAN.js +804 -0
- package/dist/visual-editor-qJW0uCiQ.js +804 -0
- package/dist/visual-editor-sOPDMkOR.js +823 -0
- package/dist/visual-editor-tPb7n5l8.js +823 -0
- package/dist/visual-editor-vomNdlNO.js +804 -0
- package/dist/visual-editor-xnDHZFuO.js +153 -0
- package/dist/visual-editor-yiWZqIH0.js +157 -0
- package/dist/visual-editor-zKhC7_0C.js +823 -0
- package/dist/visual-editor.css +1 -0
- package/dist/visual-editor.js +18578 -137536
- package/package.json +50 -26
- package/dist/editor.css +0 -1
- package/dist/visual-editor-6pnSx-yp.js +0 -223
- package/dist/visual-editor-9ZW3nq5u.js +0 -247
- package/dist/visual-editor-B1RXDqNi.js +0 -1063
- package/dist/visual-editor-BAahiZ1l.js +0 -223
- package/dist/visual-editor-BC2LjdoF.js +0 -223
- package/dist/visual-editor-BPnfBfk1.js +0 -1051
- package/dist/visual-editor-BQiE5eVW.js +0 -1051
- package/dist/visual-editor-BTv-6Pnk.js +0 -1051
- package/dist/visual-editor-BUWp03gX.js +0 -235
- package/dist/visual-editor-Bb3c6iGV.js +0 -223
- package/dist/visual-editor-BipczqTj.js +0 -1075
- package/dist/visual-editor-BlIUd_n_.js +0 -1051
- package/dist/visual-editor-BoPLXEu2.js +0 -223
- package/dist/visual-editor-Bzmpi_9a.js +0 -1063
- package/dist/visual-editor-C38IiBTR.js +0 -235
- package/dist/visual-editor-C9tacnim.js +0 -247
- package/dist/visual-editor-CVa3iu5h.js +0 -1051
- package/dist/visual-editor-CXTL8Ik0.js +0 -1051
- package/dist/visual-editor-CYeahjFX.js +0 -231
- package/dist/visual-editor-CZ2SM6Jc.js +0 -1063
- package/dist/visual-editor-CZDmQI-A.js +0 -1063
- package/dist/visual-editor-C_cHJ6BN.js +0 -1051
- package/dist/visual-editor-Cf3nFbw3.js +0 -235
- package/dist/visual-editor-CiR0metz.js +0 -1051
- package/dist/visual-editor-CoX_NnS-.js +0 -223
- package/dist/visual-editor-Cu8II23Y.js +0 -223
- package/dist/visual-editor-CvXFxocc.js +0 -1063
- package/dist/visual-editor-Cxu6nkib.js +0 -1051
- package/dist/visual-editor-D-3VVfjR.js +0 -223
- package/dist/visual-editor-D-ktbg7q.js +0 -223
- package/dist/visual-editor-D9G5eAAU.js +0 -1051
- package/dist/visual-editor-D9MrqEya.js +0 -223
- package/dist/visual-editor-DAKXBbjV.js +0 -1075
- package/dist/visual-editor-DBmJk7ZR.js +0 -235
- package/dist/visual-editor-DG-c2LU9.js +0 -1051
- package/dist/visual-editor-DI_Vk989.js +0 -1051
- package/dist/visual-editor-DOOYgnjP.js +0 -235
- package/dist/visual-editor-DRx3Ax_O.js +0 -1075
- package/dist/visual-editor-DZ66sria.js +0 -1051
- package/dist/visual-editor-DZTPhYcr.js +0 -247
- package/dist/visual-editor-DcH7WJVI.js +0 -223
- package/dist/visual-editor-DdYXgEbR.js +0 -1059
- package/dist/visual-editor-DeWzgcue.js +0 -1063
- package/dist/visual-editor-Dm5ZNn8C.js +0 -223
- package/dist/visual-editor-DqLCIWPQ.js +0 -1051
- package/dist/visual-editor-NoU28r5Y.js +0 -223
- package/dist/visual-editor-WjrJ9nPc.js +0 -235
- package/dist/visual-editor-_h-sdbID.js +0 -223
- package/dist/visual-editor-r4gSQqFM.js +0 -1075
- package/dist/visual-editor-ujQ29mao.js +0 -247
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { PuckComponent, setDeep } from "@puckeditor/core";
|
|
2
|
+
import { ComplexImageType, ImageType } from "@yext/pages-components";
|
|
3
|
+
import {
|
|
4
|
+
AssetImageType,
|
|
5
|
+
isLocalizedAssetImage,
|
|
6
|
+
resolveLocalizedAssetImage,
|
|
7
|
+
TranslatableAssetImage,
|
|
8
|
+
} from "../../../types/images.ts";
|
|
9
|
+
import { EntityField } from "../../../editor/EntityField.tsx";
|
|
10
|
+
import {
|
|
11
|
+
Image,
|
|
12
|
+
ImgSizesByBreakpoint,
|
|
13
|
+
imgSizesHelper,
|
|
14
|
+
} from "../../atoms/image.tsx";
|
|
15
|
+
import { MaybeLink } from "../../atoms/maybeLink.tsx";
|
|
16
|
+
import { TranslatableString } from "../../../types/types.ts";
|
|
17
|
+
import { YextEntityField } from "../../../editor/YextEntityFieldSelector.tsx";
|
|
18
|
+
import { msg, pt } from "../../../utils/i18n/platform.ts";
|
|
19
|
+
import { resolveComponentData } from "../../../utils/resolveComponentData.tsx";
|
|
20
|
+
import { resolveDataFromParent } from "../../../editor/ParentData.tsx";
|
|
21
|
+
import { useDocument } from "../../../hooks/useDocument.tsx";
|
|
22
|
+
import * as React from "react";
|
|
23
|
+
import { useTranslation } from "react-i18next";
|
|
24
|
+
import { EmptyImageState } from "./EmptyImageState.tsx";
|
|
25
|
+
import { ImageStylingFields, ImageStylingProps } from "./styling.ts";
|
|
26
|
+
import { YextComponentConfig, YextFields } from "../../../fields/fields.ts";
|
|
27
|
+
|
|
28
|
+
const PLACEHOLDER_IMAGE_URL = "https://placehold.co/640x360";
|
|
29
|
+
const DEFAULT_LINK = "#";
|
|
30
|
+
const LINK_REGEX_VALIDATION = /^(https?:\/\/[^\s]+|\/[^\s]*|#[^\s]*)$/;
|
|
31
|
+
|
|
32
|
+
export interface ImageWrapperProps {
|
|
33
|
+
data: {
|
|
34
|
+
/** The image to display. */
|
|
35
|
+
image: YextEntityField<
|
|
36
|
+
ImageType | ComplexImageType | TranslatableAssetImage
|
|
37
|
+
>;
|
|
38
|
+
link?: TranslatableString;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** Size and aspect ratio of the image. */
|
|
42
|
+
styles: ImageStylingProps;
|
|
43
|
+
|
|
44
|
+
/** @internal Controlled data from the parent section. */
|
|
45
|
+
parentData?: {
|
|
46
|
+
field: string;
|
|
47
|
+
image: ImageType | ComplexImageType | TranslatableAssetImage | undefined;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Additional CSS classes to apply to the image. */
|
|
51
|
+
className?: string;
|
|
52
|
+
|
|
53
|
+
sizes?: ImgSizesByBreakpoint;
|
|
54
|
+
|
|
55
|
+
hideWidthProp?: boolean;
|
|
56
|
+
|
|
57
|
+
/** @internal If true, shows the imageConstrain prop. */
|
|
58
|
+
showImageConstrain?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const ImageWrapperFields: YextFields<ImageWrapperProps> = {
|
|
62
|
+
data: {
|
|
63
|
+
type: "object",
|
|
64
|
+
label: msg("fields.data", "Data"),
|
|
65
|
+
objectFields: {
|
|
66
|
+
image: {
|
|
67
|
+
type: "entityField",
|
|
68
|
+
label: msg("fields.options.image", "Image"),
|
|
69
|
+
filter: {
|
|
70
|
+
types: ["type.image"],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
link: {
|
|
74
|
+
type: "translatableString",
|
|
75
|
+
label: msg("fields.link", "Link"),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
styles: {
|
|
80
|
+
type: "object",
|
|
81
|
+
label: msg("fields.styles", "Styles"),
|
|
82
|
+
objectFields: {
|
|
83
|
+
...ImageStylingFields,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
showImageConstrain: {
|
|
87
|
+
label: msg("fields.showImageConstrain", "Show Image Constrain"),
|
|
88
|
+
type: "radio",
|
|
89
|
+
options: [
|
|
90
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
91
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
92
|
+
],
|
|
93
|
+
visible: false,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const getImageUrl = (
|
|
98
|
+
image: ImageType | ComplexImageType | TranslatableAssetImage | undefined,
|
|
99
|
+
locale: string
|
|
100
|
+
): string | undefined => {
|
|
101
|
+
if (!image) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (isLocalizedAssetImage(image)) {
|
|
106
|
+
return resolveLocalizedAssetImage(image, locale)?.url;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if ("image" in image) {
|
|
110
|
+
return image.image?.url;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return image.url;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const ImageWrapperComponent: PuckComponent<ImageWrapperProps> = (props) => {
|
|
117
|
+
const {
|
|
118
|
+
data,
|
|
119
|
+
styles,
|
|
120
|
+
parentData,
|
|
121
|
+
className,
|
|
122
|
+
puck,
|
|
123
|
+
sizes = {
|
|
124
|
+
base: styles.width ? `min(100vw, width)` : "100vw",
|
|
125
|
+
md: styles.width
|
|
126
|
+
? `min(width, calc((maxWidth - 32px) / 2))`
|
|
127
|
+
: "maxWidth / 2",
|
|
128
|
+
},
|
|
129
|
+
hideWidthProp,
|
|
130
|
+
showImageConstrain = false,
|
|
131
|
+
} = props;
|
|
132
|
+
const { i18n } = useTranslation();
|
|
133
|
+
const streamDocument = useDocument();
|
|
134
|
+
const resolvedImage = React.useMemo(() => {
|
|
135
|
+
return parentData
|
|
136
|
+
? parentData?.image
|
|
137
|
+
: resolveComponentData(data.image, i18n.language, streamDocument);
|
|
138
|
+
}, [parentData, data.image, i18n.language, streamDocument]);
|
|
139
|
+
|
|
140
|
+
const imageUrl = getImageUrl(resolvedImage, i18n.language);
|
|
141
|
+
const isEmpty =
|
|
142
|
+
!resolvedImage ||
|
|
143
|
+
!imageUrl ||
|
|
144
|
+
(typeof imageUrl === "string" && imageUrl.trim() === "");
|
|
145
|
+
|
|
146
|
+
const inputLink = resolveComponentData(
|
|
147
|
+
data.link ?? { defaultValue: DEFAULT_LINK },
|
|
148
|
+
i18n.language,
|
|
149
|
+
streamDocument
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const resolvedLink =
|
|
153
|
+
typeof inputLink === "string" &&
|
|
154
|
+
LINK_REGEX_VALIDATION.test(inputLink.trim()) &&
|
|
155
|
+
inputLink.trim() !== DEFAULT_LINK
|
|
156
|
+
? inputLink.trim()
|
|
157
|
+
: undefined;
|
|
158
|
+
|
|
159
|
+
if (isEmpty) {
|
|
160
|
+
return (
|
|
161
|
+
<EmptyImageState
|
|
162
|
+
isEmpty={isEmpty}
|
|
163
|
+
isEditing={puck.isEditing ?? false}
|
|
164
|
+
constantValueEnabled={data.image.constantValueEnabled ?? false}
|
|
165
|
+
constantValue={data.image.constantValue as AssetImageType | undefined}
|
|
166
|
+
fieldId={parentData ? parentData.field : data.image.field}
|
|
167
|
+
containerStyle={{
|
|
168
|
+
...(hideWidthProp
|
|
169
|
+
? {}
|
|
170
|
+
: styles.width
|
|
171
|
+
? { width: `${styles.width}px` }
|
|
172
|
+
: {}),
|
|
173
|
+
...(styles.aspectRatio ? { aspectRatio: styles.aspectRatio } : {}),
|
|
174
|
+
}}
|
|
175
|
+
containerClassName={
|
|
176
|
+
className || "max-w-full rounded-image-borderRadius w-full h-full"
|
|
177
|
+
}
|
|
178
|
+
fullHeight
|
|
179
|
+
dragRef={puck.dragRef ?? undefined}
|
|
180
|
+
hasParentData={!!parentData}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const transformedSizes = imgSizesHelper(sizes, `${styles.width}px`);
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<EntityField
|
|
189
|
+
displayName={pt("fields.image", "Image")}
|
|
190
|
+
fieldId={parentData ? parentData.field : data.image.field}
|
|
191
|
+
constantValueEnabled={!parentData && data.image.constantValueEnabled}
|
|
192
|
+
fullHeight
|
|
193
|
+
ref={puck.dragRef}
|
|
194
|
+
>
|
|
195
|
+
<div className="w-full">
|
|
196
|
+
<MaybeLink
|
|
197
|
+
className="w-auto"
|
|
198
|
+
eventName="logoLink"
|
|
199
|
+
href={resolvedLink}
|
|
200
|
+
alwaysHideCaret={true}
|
|
201
|
+
>
|
|
202
|
+
<Image
|
|
203
|
+
image={resolvedImage}
|
|
204
|
+
aspectRatio={styles.aspectRatio}
|
|
205
|
+
imageFillType={styles.imageFillType}
|
|
206
|
+
width={
|
|
207
|
+
hideWidthProp ||
|
|
208
|
+
(showImageConstrain && styles.imageConstrain === "fill")
|
|
209
|
+
? undefined
|
|
210
|
+
: styles.width
|
|
211
|
+
}
|
|
212
|
+
className={
|
|
213
|
+
className || "max-w-full rounded-image-borderRadius w-full"
|
|
214
|
+
}
|
|
215
|
+
sizes={transformedSizes}
|
|
216
|
+
/>
|
|
217
|
+
</MaybeLink>
|
|
218
|
+
</div>
|
|
219
|
+
</EntityField>
|
|
220
|
+
);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export const imageDefaultProps = {
|
|
224
|
+
data: {
|
|
225
|
+
image: {
|
|
226
|
+
field: "",
|
|
227
|
+
constantValue: {
|
|
228
|
+
url: PLACEHOLDER_IMAGE_URL,
|
|
229
|
+
height: 360,
|
|
230
|
+
width: 640,
|
|
231
|
+
},
|
|
232
|
+
constantValueEnabled: true,
|
|
233
|
+
},
|
|
234
|
+
link: { defaultValue: DEFAULT_LINK },
|
|
235
|
+
},
|
|
236
|
+
styles: {
|
|
237
|
+
aspectRatio: 1.78,
|
|
238
|
+
imageFillType: "fill" as const,
|
|
239
|
+
width: 640,
|
|
240
|
+
},
|
|
241
|
+
allowWidthProp: true,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export const ImageWrapper: YextComponentConfig<ImageWrapperProps> = {
|
|
245
|
+
label: msg("components.image", "Image"),
|
|
246
|
+
inline: true,
|
|
247
|
+
fields: ImageWrapperFields,
|
|
248
|
+
defaultProps: imageDefaultProps,
|
|
249
|
+
resolveFields: (data, params) => {
|
|
250
|
+
let fields = resolveDataFromParent(ImageWrapperFields, data);
|
|
251
|
+
const parentType = params.parent?.type;
|
|
252
|
+
|
|
253
|
+
if (
|
|
254
|
+
data.props.hideWidthProp ||
|
|
255
|
+
data.props.styles.imageConstrain === "fill"
|
|
256
|
+
) {
|
|
257
|
+
fields = setDeep(fields, "styles.objectFields.width.visible", false);
|
|
258
|
+
} else {
|
|
259
|
+
fields = setDeep(fields, "styles.objectFields.width.visible", true);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
fields = setDeep(
|
|
263
|
+
fields,
|
|
264
|
+
"styles.objectFields.imageConstrain.visible",
|
|
265
|
+
!!data.props.showImageConstrain
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
if (parentType !== "PrimaryHeaderSlot") {
|
|
269
|
+
return setDeep(fields, "data.objectFields.link.visible", false);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return fields;
|
|
273
|
+
},
|
|
274
|
+
render: (props) => <ImageWrapperComponent {...props} />,
|
|
275
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { YextFields } from "../../../fields/fields.ts";
|
|
2
|
+
import { ImageFillType } from "../../../types/images.ts";
|
|
3
|
+
import { msg } from "../../../utils/i18n/platform.ts";
|
|
4
|
+
|
|
5
|
+
/** Props for displaying an image */
|
|
6
|
+
export interface ImageStylingProps {
|
|
7
|
+
/** The aspect ratio of the image */
|
|
8
|
+
aspectRatio: number;
|
|
9
|
+
width?: number;
|
|
10
|
+
imageConstrain?: "fill" | "fixed";
|
|
11
|
+
imageFillType?: ImageFillType;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ImageStylingFields: YextFields<ImageStylingProps> = {
|
|
15
|
+
imageConstrain: {
|
|
16
|
+
label: msg("fields.imageConstrain", "Image Constrain"),
|
|
17
|
+
type: "radio",
|
|
18
|
+
options: [
|
|
19
|
+
{
|
|
20
|
+
label: msg("fields.options.fillContainer", "Fill Container"),
|
|
21
|
+
value: "fill",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: msg("fields.options.fixedWidth", "Fixed Width"),
|
|
25
|
+
value: "fixed",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
visible: false,
|
|
29
|
+
},
|
|
30
|
+
imageFillType: {
|
|
31
|
+
type: "basicSelector",
|
|
32
|
+
label: msg("fields.imageFillType", "Image Fill Type"),
|
|
33
|
+
options: [
|
|
34
|
+
{ label: msg("fields.options.fill", "Fill"), value: "fill" },
|
|
35
|
+
{ label: msg("fields.options.fit", "Fit"), value: "fit" },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
width: {
|
|
39
|
+
type: "number",
|
|
40
|
+
label: msg("fields.options.width", "Width"),
|
|
41
|
+
min: 0,
|
|
42
|
+
},
|
|
43
|
+
aspectRatio: {
|
|
44
|
+
type: "basicSelector",
|
|
45
|
+
label: msg("fields.options.aspectRatio", "Aspect Ratio"),
|
|
46
|
+
options: [
|
|
47
|
+
{ label: "1:1", value: 1 },
|
|
48
|
+
{ label: "5:4", value: 1.25 },
|
|
49
|
+
{ label: "4:3", value: 1.33 },
|
|
50
|
+
{ label: "3:2", value: 1.5 },
|
|
51
|
+
{ label: "5:3", value: 1.67 },
|
|
52
|
+
{ label: "16:9", value: 1.78 },
|
|
53
|
+
{ label: "2:1", value: 2 },
|
|
54
|
+
{ label: "3:1", value: 3 },
|
|
55
|
+
{ label: "4:1", value: 4 },
|
|
56
|
+
{ label: "4:5", value: 0.8 },
|
|
57
|
+
{ label: "3:4", value: 0.75 },
|
|
58
|
+
{ label: "2:3", value: 0.67 },
|
|
59
|
+
{ label: "3:5", value: 0.6 },
|
|
60
|
+
{ label: "9:16", value: 0.56 },
|
|
61
|
+
{ label: "1:2", value: 0.5 },
|
|
62
|
+
{ label: "1:3", value: 0.33 },
|
|
63
|
+
{ label: "1:4", value: 0.25 },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Address, type AddressProps } from "./Address.tsx";
|
|
2
|
+
export { HeadingText, type HeadingTextProps } from "./HeadingText.tsx";
|
|
3
|
+
export { HoursStatus, type HoursStatusProps } from "./HoursStatus.tsx";
|
|
4
|
+
export { HoursTable, type HoursTableProps } from "./HoursTable.tsx";
|
|
5
|
+
export { ImageWrapper, type ImageWrapperProps } from "./image/Image.tsx";
|
|
6
|
+
export {
|
|
7
|
+
mapboxStaticMapStyleOptions,
|
|
8
|
+
mapStyleField,
|
|
9
|
+
MapboxStaticMapComponent,
|
|
10
|
+
MapboxStaticMap,
|
|
11
|
+
type MapboxStaticProps,
|
|
12
|
+
} from "./MapboxStaticMap.tsx";
|
|
13
|
+
export { Phone, type PhoneProps } from "./Phone.tsx";
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { useTranslation } from "react-i18next";
|
|
2
|
+
import { useTemplateProps } from "../../hooks/useDocument.tsx";
|
|
3
|
+
import { MaybeLink } from "../atoms/maybeLink.tsx";
|
|
4
|
+
import { PageSection } from "../atoms/pageSection.tsx";
|
|
5
|
+
import { VisibilityWrapper } from "../atoms/visibilityWrapper.tsx";
|
|
6
|
+
import { msg } from "../../utils/i18n/platform.ts";
|
|
7
|
+
import { TranslatableString } from "../../types/types.ts";
|
|
8
|
+
import {
|
|
9
|
+
ThemeColor,
|
|
10
|
+
backgroundColors,
|
|
11
|
+
ThemeOptions,
|
|
12
|
+
} from "../../utils/themeConfigOptions.ts";
|
|
13
|
+
import { resolveComponentData } from "../../utils/resolveComponentData.tsx";
|
|
14
|
+
import { setDeep } from "@puckeditor/core";
|
|
15
|
+
import { AnalyticsScopeProvider } from "@yext/pages-components";
|
|
16
|
+
import { ComponentErrorBoundary } from "../../internal/components/ComponentErrorBoundary.tsx";
|
|
17
|
+
import { resolveBreadcrumbs } from "../../utils/urls/resolveBreadcrumbs.ts";
|
|
18
|
+
import { YextEntityField } from "../../editor/YextEntityFieldSelector.tsx";
|
|
19
|
+
import {
|
|
20
|
+
toPuckFields,
|
|
21
|
+
YextComponentConfig,
|
|
22
|
+
YextFields,
|
|
23
|
+
} from "../../fields/fields.ts";
|
|
24
|
+
|
|
25
|
+
export interface BreadcrumbsData {
|
|
26
|
+
/**
|
|
27
|
+
* The display label for the first link in the breadcrumb trail (the top-level directory page).
|
|
28
|
+
* @defaultValue "Directory Root"
|
|
29
|
+
*/
|
|
30
|
+
directoryRoot: TranslatableString;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The display label for the last link in the breadcrumb trail (the current page).
|
|
34
|
+
* @defaultValue Name
|
|
35
|
+
*/
|
|
36
|
+
currentPage: YextEntityField<TranslatableString>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface BreadcrumbsStyles {
|
|
40
|
+
/**
|
|
41
|
+
* The background color of the section.
|
|
42
|
+
* @defaultValue Background Color 1
|
|
43
|
+
*/
|
|
44
|
+
backgroundColor?: ThemeColor;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The link color of breadcrumbs.
|
|
48
|
+
*/
|
|
49
|
+
linkColor?: ThemeColor;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether to show the current page's link in the breadcrumb trail (last link).
|
|
53
|
+
* @defaultValue true
|
|
54
|
+
*/
|
|
55
|
+
showCurrentPage: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @public Defines the complete set of properties for the BreadcrumbsSection component.
|
|
60
|
+
*/
|
|
61
|
+
export interface BreadcrumbsSectionProps {
|
|
62
|
+
/**
|
|
63
|
+
* This object contains the content used by the component.
|
|
64
|
+
* @propCategory Data Props
|
|
65
|
+
*/
|
|
66
|
+
data: BreadcrumbsData;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* This object contains properties for customizing the component's appearance.
|
|
70
|
+
* @propCategory Style Props
|
|
71
|
+
*/
|
|
72
|
+
styles: BreadcrumbsStyles;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
analytics: {
|
|
78
|
+
scope?: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* If 'true', the component is visible on the live page; if 'false', it's hidden.
|
|
83
|
+
* @defaultValue true
|
|
84
|
+
*/
|
|
85
|
+
liveVisibility: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const breadcrumbsSectionFields: YextFields<BreadcrumbsSectionProps> = {
|
|
89
|
+
data: {
|
|
90
|
+
type: "object",
|
|
91
|
+
label: msg("fields.data", "Data"),
|
|
92
|
+
objectFields: {
|
|
93
|
+
directoryRoot: {
|
|
94
|
+
type: "translatableString",
|
|
95
|
+
label: msg(
|
|
96
|
+
"fields.directoryRootLinkLabel",
|
|
97
|
+
"Directory Root Link Label"
|
|
98
|
+
),
|
|
99
|
+
filter: { types: ["type.string"] },
|
|
100
|
+
},
|
|
101
|
+
currentPage: {
|
|
102
|
+
type: "entityField",
|
|
103
|
+
label: msg("fields.currentPageLinkLabel", "Current Page Link Label"),
|
|
104
|
+
filter: { types: ["type.string"] },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
styles: {
|
|
109
|
+
type: "object",
|
|
110
|
+
label: msg("fields.styles", "Styles"),
|
|
111
|
+
objectFields: {
|
|
112
|
+
backgroundColor: {
|
|
113
|
+
type: "basicSelector",
|
|
114
|
+
label: msg("fields.backgroundColor", "Background Color"),
|
|
115
|
+
options: "BACKGROUND_COLOR",
|
|
116
|
+
},
|
|
117
|
+
linkColor: {
|
|
118
|
+
type: "basicSelector",
|
|
119
|
+
label: msg("fields.linkColor", "Link Color"),
|
|
120
|
+
options: "SITE_COLOR",
|
|
121
|
+
},
|
|
122
|
+
showCurrentPage: {
|
|
123
|
+
label: msg(
|
|
124
|
+
"fields.showCurrentPagesLinkLabel",
|
|
125
|
+
"Show Current Page's Link Label"
|
|
126
|
+
),
|
|
127
|
+
type: "radio",
|
|
128
|
+
options: ThemeOptions.SHOW_HIDE,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
analytics: {
|
|
133
|
+
type: "object",
|
|
134
|
+
label: msg("fields.analytics", "Analytics"),
|
|
135
|
+
visible: false,
|
|
136
|
+
objectFields: {
|
|
137
|
+
scope: {
|
|
138
|
+
label: msg("fields.scope", "Scope"),
|
|
139
|
+
type: "text",
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
liveVisibility: {
|
|
144
|
+
label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
|
|
145
|
+
type: "radio",
|
|
146
|
+
options: [
|
|
147
|
+
{ label: msg("fields.options.show", "Show"), value: true },
|
|
148
|
+
{ label: msg("fields.options.hide", "Hide"), value: false },
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// BreadcrumbsComponent renders breadcrumbs for DM related pages.
|
|
154
|
+
// If there are no dm_directoryParents nor dm_directoryChildren,
|
|
155
|
+
// then displays nothing. In the case of a root DM page, there are
|
|
156
|
+
// no dm_directoryParents but there are dm_directoryChildren so
|
|
157
|
+
// that root entity's name will be in the breadcrumbs.
|
|
158
|
+
export const BreadcrumbsComponent = ({
|
|
159
|
+
data,
|
|
160
|
+
styles,
|
|
161
|
+
}: BreadcrumbsSectionProps) => {
|
|
162
|
+
const { t, i18n } = useTranslation();
|
|
163
|
+
const separator = "/";
|
|
164
|
+
const { document: streamDocument, relativePrefixToRoot } = useTemplateProps();
|
|
165
|
+
const breadcrumbs = resolveBreadcrumbs(streamDocument);
|
|
166
|
+
const directoryRoot = resolveComponentData(
|
|
167
|
+
data.directoryRoot,
|
|
168
|
+
i18n.language,
|
|
169
|
+
streamDocument
|
|
170
|
+
);
|
|
171
|
+
const currentPage = resolveComponentData(
|
|
172
|
+
data.currentPage,
|
|
173
|
+
i18n.language,
|
|
174
|
+
streamDocument
|
|
175
|
+
);
|
|
176
|
+
const breadcrumbsToRender = breadcrumbs
|
|
177
|
+
.map((breadcrumb, index) => ({ ...breadcrumb, index }))
|
|
178
|
+
.filter(
|
|
179
|
+
({ index }) => styles.showCurrentPage || index < breadcrumbs.length - 1
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
if (!breadcrumbsToRender.length) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<PageSection
|
|
188
|
+
as={"nav"}
|
|
189
|
+
verticalPadding="sm"
|
|
190
|
+
aria-label={t("breadcrumb", "Breadcrumb")}
|
|
191
|
+
background={styles?.backgroundColor}
|
|
192
|
+
>
|
|
193
|
+
<ol className="inline p-0 m-0 list-none">
|
|
194
|
+
{breadcrumbsToRender.map(({ name, slug, index }) => {
|
|
195
|
+
const isRoot = index === 0;
|
|
196
|
+
const isCurrentPage = index === breadcrumbs.length - 1;
|
|
197
|
+
// Root pages have a single breadcrumb, so the first and last crumb are the same item.
|
|
198
|
+
const isRootPage = isRoot && isCurrentPage;
|
|
199
|
+
const href = relativePrefixToRoot
|
|
200
|
+
? relativePrefixToRoot + slug
|
|
201
|
+
: slug;
|
|
202
|
+
let label = name;
|
|
203
|
+
if (isCurrentPage && currentPage) {
|
|
204
|
+
label = currentPage;
|
|
205
|
+
}
|
|
206
|
+
if ((isRootPage || isRoot) && directoryRoot) {
|
|
207
|
+
label = directoryRoot;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<li key={index} className="contents whitespace-normal break-words">
|
|
212
|
+
{!isRoot && (
|
|
213
|
+
<span className="mx-2" aria-hidden>
|
|
214
|
+
{separator}
|
|
215
|
+
</span>
|
|
216
|
+
)}
|
|
217
|
+
|
|
218
|
+
{/* encourage the browser to break after a full breadcrumb, if necessary */}
|
|
219
|
+
<wbr />
|
|
220
|
+
|
|
221
|
+
<MaybeLink
|
|
222
|
+
eventName={`link${index}`}
|
|
223
|
+
href={isCurrentPage ? "" : href}
|
|
224
|
+
className="inline text-body-sm-fontSize font-link-fontWeight font-link-fontFamily whitespace-normal break-words"
|
|
225
|
+
color={styles?.linkColor}
|
|
226
|
+
alwaysHideCaret
|
|
227
|
+
>
|
|
228
|
+
{label}
|
|
229
|
+
</MaybeLink>
|
|
230
|
+
</li>
|
|
231
|
+
);
|
|
232
|
+
})}
|
|
233
|
+
</ol>
|
|
234
|
+
</PageSection>
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* The Breadcrumbs component automatically generates and displays a navigational hierarchy based on a page's position within a Yext directory structure. It renders a list of links showing the path from the main directory root to the current page, helping users understand their location on the site.
|
|
240
|
+
* Available on Location templates.
|
|
241
|
+
*/
|
|
242
|
+
export const BreadcrumbsSection: YextComponentConfig<BreadcrumbsSectionProps> =
|
|
243
|
+
{
|
|
244
|
+
label: msg("components.breadcrumbs", "Breadcrumbs"),
|
|
245
|
+
fields: breadcrumbsSectionFields,
|
|
246
|
+
resolveFields: (_data, params) => {
|
|
247
|
+
const streamDocument = params.metadata?.streamDocument;
|
|
248
|
+
if (!streamDocument) {
|
|
249
|
+
return toPuckFields<BreadcrumbsSectionProps>(breadcrumbsSectionFields);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// On root pages there is only one breadcrumb, so "currentPage" duplicates "directoryRoot".
|
|
253
|
+
const breadcrumbCount = resolveBreadcrumbs(streamDocument).length;
|
|
254
|
+
return setDeep(
|
|
255
|
+
toPuckFields<BreadcrumbsSectionProps>(breadcrumbsSectionFields),
|
|
256
|
+
"data.objectFields.currentPage.visible",
|
|
257
|
+
breadcrumbCount !== 1
|
|
258
|
+
);
|
|
259
|
+
},
|
|
260
|
+
defaultProps: {
|
|
261
|
+
data: {
|
|
262
|
+
directoryRoot: { defaultValue: "Directory Root" },
|
|
263
|
+
currentPage: {
|
|
264
|
+
constantValue: { defaultValue: "[[name]]" },
|
|
265
|
+
field: "name",
|
|
266
|
+
constantValueEnabled: false,
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
styles: {
|
|
270
|
+
backgroundColor: backgroundColors.background1.value,
|
|
271
|
+
showCurrentPage: true,
|
|
272
|
+
},
|
|
273
|
+
analytics: {
|
|
274
|
+
scope: "breadcrumbs",
|
|
275
|
+
},
|
|
276
|
+
liveVisibility: true,
|
|
277
|
+
},
|
|
278
|
+
render: (props) => {
|
|
279
|
+
return (
|
|
280
|
+
<ComponentErrorBoundary
|
|
281
|
+
isEditing={props.puck.isEditing}
|
|
282
|
+
resetKeys={[props]}
|
|
283
|
+
>
|
|
284
|
+
<AnalyticsScopeProvider
|
|
285
|
+
name={props?.analytics?.scope ?? "breadcrumbs"}
|
|
286
|
+
>
|
|
287
|
+
<VisibilityWrapper
|
|
288
|
+
liveVisibility={props.liveVisibility}
|
|
289
|
+
isEditing={props.puck.isEditing}
|
|
290
|
+
iconSize="md"
|
|
291
|
+
>
|
|
292
|
+
<BreadcrumbsComponent {...props} />
|
|
293
|
+
</VisibilityWrapper>
|
|
294
|
+
</AnalyticsScopeProvider>
|
|
295
|
+
</ComponentErrorBoundary>
|
|
296
|
+
);
|
|
297
|
+
},
|
|
298
|
+
};
|