Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions packages/visual-editor/src/components/Locator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -802,13 +802,9 @@ const LocatorInternal = ({

const CardComponent = React.useCallback(
(result: CardProps<Location>) => (
<LocatorResultCard
{...result}
puck={puck}
resultCardProps={resultCardProps}
/>
<LocatorResultCard {...result} resultCardProps={resultCardProps} />
),
[puck, resultCardProps]
[resultCardProps]
);

const [userLocationRetrieved, setUserLocationRetrieved] =
Expand Down
11 changes: 4 additions & 7 deletions packages/visual-editor/src/components/LocatorResultCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { Field, PuckContext } from "@measured/puck";
import { Field } from "@measured/puck";
import {
CardProps,
Coordinate,
Expand All @@ -21,7 +21,6 @@ import {
useTemplateProps,
resolveComponentData,
resolveUrlTemplateOfChild,
mergeMeta,
HoursStatusAtom,
HoursTableAtom,
YextField,
Expand Down Expand Up @@ -591,11 +590,9 @@ export const LocatorResultCard = React.memo(
({
result,
resultCardProps: props,
puck,
}: {
result: CardProps<Location>["result"];
resultCardProps: LocatorResultCardProps;
puck: PuckContext;
}): React.JSX.Element => {
const { document: streamDocument, relativePrefixToRoot } =
useTemplateProps();
Expand Down Expand Up @@ -629,9 +626,9 @@ export const LocatorResultCard = React.memo(
);

const resolvedUrl = resolveUrlTemplateOfChild(
mergeMeta(location, streamDocument),
relativePrefixToRoot,
puck.metadata?.resolveUrlTemplate
location,
streamDocument,
relativePrefixToRoot
);

const getDirectionsLink: string | undefined = (() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/src/components/atoms/body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Body = React.forwardRef<HTMLParagraphElement, BodyProps>(
className
)}
style={{
// @ts-expect-error ts(2322) the css variable here resolves to a valid enum value
// @ts-ignore: the css variable here resolves to a valid enum value
textTransform: `var(--textTransform-body-textTransform)`,
...style,
}}
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/src/components/atoms/cta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export const CTA = (props: CTAProps) => {
onClick={onClick}
// textTransform has to be applied via styles because there is no custom tailwind utility
style={{
// @ts-expect-error ts(2322) the css variable here resolves to a valid enum value
// @ts-ignore: the css variable here resolves to a valid enum value
textTransform: buttonVariant?.toLowerCase().includes("link")
? "var(--textTransform-link-textTransform)"
: "var(--textTransform-button-textTransform)",
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/src/components/atoms/heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(
className
)}
style={{
// @ts-expect-error ts(2322) the css variable here resolves to a valid enum value
// @ts-ignore: the css variable here resolves to a valid enum value
textTransform: `var(--textTransform-h${level}-textTransform)`,
...dynamicStyle,
...style,
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/src/components/atoms/toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Toggle({
<TogglePrimitive.Root
data-slot="toggle"
style={{
// @ts-expect-error ts(2322) the css variable here resolves to a valid enum value
// @ts-ignore: the css variable here resolves to a valid enum value
textTransform: "var(--textTransform-button-textTransform)",
}}
className={themeManagerCn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Body,
} from "@yext/visual-editor";
import { ComponentConfig, Field, Fields, PuckComponent } from "@measured/puck";
import { StreamDocument } from "../../utils/applyTheme";
import { StreamDocument } from "../../utils/types/StreamDocument.ts";
import mapboxLogo from "../assets/mapbox-logo-black.svg";
import { Map } from "lucide-react";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import {
deepMerge,
} from "@yext/visual-editor";
import { Address } from "@yext/pages-components";
import { mergeMeta } from "../../utils/mergeMeta";
import { resolveUrlTemplateOfChild } from "../../utils/resolveUrlTemplate";
import { useCardContext } from "../../hooks/useCardContext";
import { useGetCardSlots } from "../../hooks/useGetCardSlots";
import React from "react";
import { resolveUrlTemplateOfChild } from "../../utils/urls/resolveUrlTemplate";

export const defaultDirectoryCardSlotData = (
id: string,
Expand Down Expand Up @@ -162,9 +161,9 @@ const DirectoryCardComponent: PuckComponent<DirectoryCardProps> = (props) => {

const resolvedUrl = parentData
? resolveUrlTemplateOfChild(
mergeMeta(parentData.profile, streamDocument),
relativePrefixToRoot,
puck.metadata?.resolveUrlTemplate
parentData.profile,
streamDocument,
relativePrefixToRoot
)
: undefined;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LOCAL_BUSINESS_ENTITY_TYPES } from "../../utils/schema/defaultSchemas.ts";
import { Migration } from "../../utils/migrate";
import { StreamDocument } from "../../utils/applyTheme.ts";
import { StreamDocument } from "../../utils/types/StreamDocument.ts";

export const schemaUpdates: Migration = {
root: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StreamDocument } from "../../utils/applyTheme.ts";
import { StreamDocument } from "../../utils/types/StreamDocument.ts";
import { Migration } from "../../utils/migrate.ts";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import {
HeadingLevel,
HoursStatusAtom,
MaybeLink,
mergeMeta,
PhoneAtom,
resolvePageSetUrlTemplate,
useTemplateProps,
} from "@yext/visual-editor";
import { NearbyLocationCardsWrapperProps } from "./NearbyLocationsCardsWrapper";
import {
mergeMeta,
resolveUrlTemplate,
} from "../../../utils/urls/resolveUrlTemplate";

/** A single card for the Nearby Locations Section */
type NearbyLocationCardProps = {
Expand Down Expand Up @@ -46,7 +48,7 @@ type NearbyLocationCardProps = {
export const NearbyLocationCard: React.FC<NearbyLocationCardProps> = (
props
) => {
const { locationData, styles, cardNumber, puck, sectionHeadingLevel } = props;
const { locationData, styles, cardNumber, sectionHeadingLevel } = props;

if (!locationData) {
return <></>;
Expand All @@ -56,10 +58,9 @@ export const NearbyLocationCard: React.FC<NearbyLocationCardProps> = (

const { document: streamDocument, relativePrefixToRoot } = useTemplateProps();

const resolvedUrl = resolvePageSetUrlTemplate(
const resolvedUrl = resolveUrlTemplate(
mergeMeta(locationData, streamDocument),
relativePrefixToRoot,
puck.metadata?.resolveUrlTemplate
relativePrefixToRoot ?? ""
);

return (
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion packages/visual-editor/src/docs/ai/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Fields,
ComponentData,
Slot,
PuckContext,
} from "@measured/puck";
import {
ImageType,
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/src/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
i18nPlatformInstance,
loadPlatformTranslations,
} from "../utils/i18n/platform.ts";
import { StreamDocument } from "../utils/applyTheme.ts";
import { StreamDocument } from "../utils/types/StreamDocument.ts";
import {
createDefaultThemeConfig,
defaultThemeConfig,
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/src/hooks/useDocument.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { StreamDocument } from "../utils/applyTheme";
import { StreamDocument } from "../utils/types/StreamDocument.ts";

const TemplatePropsContext = React.createContext<any | undefined>(undefined);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useLayoutMessageReceivers } from "../hooks/layout/useMessageReceivers.t
import { LoadingScreen } from "../puck/components/LoadingScreen.tsx";
import { ThemeData, ThemeHistory } from "../types/themeData.ts";
import { ThemeConfig } from "../../utils/themeResolver.ts";
import { StreamDocument, updateThemeInEditor } from "../../utils/applyTheme.ts";
import { updateThemeInEditor } from "../../utils/applyTheme.ts";
import { useThemeLocalStorage } from "../hooks/theme/useLocalStorage.ts";
import { useCommonMessageSenders } from "../hooks/useMessageSenders.ts";
import { useProgress } from "../hooks/useProgress.ts";
Expand All @@ -26,6 +26,7 @@ import { Metadata } from "../../editor/Editor.tsx";
import { useErrorContext } from "../../contexts/ErrorContext.tsx";
import { toast } from "sonner";
import { pt } from "../../utils/i18n/platform.ts";
import { StreamDocument } from "../../utils/types/StreamDocument";

const devLogger = new DevLogger();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { useCommonMessageSenders } from "../useMessageSenders.ts";
import { migrationRegistry } from "../../../components/migrations/migrationRegistry.ts";
import { migrate } from "../../../utils/migrate.ts";
import { resolveSchemaJson } from "../../../utils/schema/resolveSchema.ts";
import { type StreamDocument } from "../../../utils/types/StreamDocument.ts";
import {
resolvePageSetUrlTemplate,
resolveUrlTemplate,
resolveUrlTemplateOfChild,
} from "../../../utils/resolveUrlTemplate.ts";
import { type StreamDocument } from "../../../utils/applyTheme.ts";
} from "../../../utils/urls/resolveUrlTemplate.ts";

const devLogger = new DevLogger();

Expand Down Expand Up @@ -82,9 +82,9 @@ export const useLayoutMessageReceivers = (
streamDocument?.meta?.entityType?.id === "locator" ||
streamDocument?.meta?.entityType?.id?.startsWith("dm_")
) {
path = resolveUrlTemplateOfChild(streamDocument, "");
path = resolveUrlTemplateOfChild({}, streamDocument, "");
} else {
path = resolvePageSetUrlTemplate(streamDocument, "");
path = resolveUrlTemplate(streamDocument, "");
}

// Find the relativePrefixToRoot for the page being rendered in the editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ThemeData } from "../types/themeData.ts";
import { migrate } from "../../utils/migrate.ts";
import { migrationRegistry } from "../../components/migrations/migrationRegistry.ts";
import { filterComponentsFromConfig } from "../../utils/filterComponents.ts";
import { StreamDocument } from "../../utils/applyTheme.ts";
import { StreamDocument } from "../../utils/types/StreamDocument.ts";

const devLogger = new DevLogger();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { mergeMeta } from "../mergeMeta.ts";
import { StreamDocument } from "../applyTheme.ts";
import { StreamDocument } from "../types/StreamDocument.ts";
import { normalizeLocale } from "../normalizeLocale.ts";
import { resolvePageSetUrlTemplate } from "../resolveUrlTemplate.ts";
import { mergeMeta, resolveUrlTemplate } from "../urls/resolveUrlTemplate.ts";

const V_PARAM = "20250407";

Expand Down Expand Up @@ -44,8 +43,7 @@ export const fetchLocalesToPathsForEntity = async ({
// Merge profile with streamDocument metadata
const mergedDocument = mergeMeta(profile, streamDocument);

// Use resolvePageSetUrlTemplate to get the URL based on the current page set template
const resolvedUrl = resolvePageSetUrlTemplate(mergedDocument, "");
const resolvedUrl = resolveUrlTemplate(mergedDocument, "");
localeToPath[normalizeLocale(profile.meta.locale)] = resolvedUrl;
} catch (e) {
console.warn(
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/src/utils/applyCertifiedFacts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StreamDocument } from "./applyTheme.ts";
import { StreamDocument } from "./types/StreamDocument.ts";

/**
* Applies the brand certified facts script to the head of the page.
Expand Down
3 changes: 2 additions & 1 deletion packages/visual-editor/src/utils/applyTheme.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect } from "vitest";
import { applyTheme, StreamDocument } from "./applyTheme.ts";
import { applyTheme } from "./applyTheme.ts";
import { ThemeConfig } from "./themeResolver.ts";
import { StreamDocument } from "./types/StreamDocument";

describe("buildCssOverridesStyle", () => {
it("should generate correct CSS with one override in c_theme", () => {
Expand Down
22 changes: 1 addition & 21 deletions packages/visual-editor/src/utils/applyTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,7 @@ import {
import { ThemeConfig } from "./themeResolver.ts";
import { getContrastingColor } from "./colors.ts";
import fontFallbackTransformations from "./fonts/fontFallbackTransformations.json";

export type StreamDocument = {
[key: string]: any;
locale?: string;
meta?: {
locale?: string;
entityType?: {
id?: string;
};
};
__certified_facts?: any;
__?: {
layout?: string;
theme?: string;
codeTemplate?: string;
name?: string;
visualEditorConfig?: string;
isPrimaryLocale?: boolean;
entityPageSetUrlTemplates?: string;
};
};
import { StreamDocument } from "./types/StreamDocument.ts";

export const THEME_STYLE_TAG_ID = "visual-editor-theme";
export const PUCK_PREVIEW_IFRAME_ID = "preview-frame";
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/src/utils/getPageMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setDeep } from "@measured/puck";
import { StreamDocument } from "./applyTheme.ts";
import { StreamDocument } from "./types/StreamDocument.ts";
import { resolveComponentData } from "./resolveComponentData.tsx";

export type RootConfig = {
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/src/utils/i18n/components.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import i18next from "i18next";
import { initReactI18next } from "react-i18next";
import { getTranslations } from "./getTranslations";
import { StreamDocument } from "../applyTheme";
import { StreamDocument } from "../types/StreamDocument";
import { normalizeLocalesInObject } from "../normalizeLocale";

const NAMESPACE = "visual-editor";
Expand Down
12 changes: 6 additions & 6 deletions packages/visual-editor/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { fetchLocalesToPathsForEntity } from "./api/fetchLocalesToPathsForEntity
export { applyAnalytics, getAnalyticsScopeHash } from "./applyAnalytics.ts";
export { applyHeaderScript } from "./applyHeaderScript.ts";
export { applyCertifiedFacts } from "./applyCertifiedFacts.ts";
export { applyTheme, type StreamDocument } from "./applyTheme.ts";
export { applyTheme } from "./applyTheme.ts";
export { getCanonicalUrl } from "./canonicalUrl.ts";
export { themeManagerCn, themeManagerTwMergeConfiguration } from "./cn.ts";
export { filterComponentsFromConfig } from "./filterComponents.ts";
Expand All @@ -17,10 +17,6 @@ export {
} from "./migrate.ts";
export { resolveComponentData } from "./resolveComponentData.tsx";
export { resolveYextEntityField } from "./resolveYextEntityField.ts";
export {
resolveUrlTemplateOfChild,
resolvePageSetUrlTemplate,
} from "./resolveUrlTemplate.ts";
export {
createSearchAnalyticsConfig,
createSearchHeadlessConfig,
Expand All @@ -35,6 +31,11 @@ export {
VisualEditorComponentsContentPath,
} from "./themeConfigOptions.ts";
export { type ThemeConfig, themeResolver, deepMerge } from "./themeResolver.ts";
export { type StreamDocument } from "./types/StreamDocument.ts";
export {
resolveUrlTemplate,
resolveUrlTemplateOfChild,
} from "./urls/resolveUrlTemplate.ts";
export { VisualEditorProvider } from "./VisualEditorProvider.tsx";
export {
constructFontSelectOptions,
Expand All @@ -44,4 +45,3 @@ export {
type FontRegistry,
} from "./fonts/visualEditorFonts.ts";
export { withPropOverrides } from "./withPropOverrides.ts";
export { mergeMeta } from "./mergeMeta.ts";
Loading
Loading