@yext/visual-editor 0.0.12 → 0.0.14

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/index.d.cts CHANGED
@@ -1,67 +1,59 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Config, Field } from '@measured/puck';
1
+ import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
3
2
  import * as React from 'react';
4
3
  import React__default from 'react';
4
+ import { VariantProps } from 'class-variance-authority';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import { Field, ComponentConfig, Config } from '@measured/puck';
7
+ import { AddressType, GetDirectionsConfig, DayOfWeekNames, ImageType } from '@yext/pages-components';
5
8
 
6
- type Style = {
7
- label: string;
8
- plugin: string;
9
- type: "number";
10
- default: string;
11
- } | {
12
- label: string;
13
- plugin: string;
14
- type: "select";
15
- default: string;
16
- options: StyleSelectOption[];
17
- } | {
18
- label: string;
19
- plugin: string;
20
- type: "color";
21
- default: string;
22
- };
23
- type StyleSelectOption = {
24
- label: string;
25
- value: string;
26
- };
27
- type ParentStyle = {
28
- label: string;
29
- styles: {
30
- [key: string]: Style | ParentStyle;
31
- };
32
- };
33
- type ThemeConfig = {
34
- [key: string]: {
35
- label: string;
36
- styles: {
37
- [key: string]: Style | ParentStyle;
38
- };
39
- };
40
- };
41
- type TailwindConfig = {
42
- [key: string]: {
43
- [key: string]: any;
44
- };
45
- };
46
- /**
47
- * Merges the developer-specified theming and the marketer-specified theming,
48
- * giving priority to the developer-specified theming.
49
- */
50
- declare const themeResolver: (deverloperTheming: TailwindConfig, marketerTheming: ThemeConfig) => TailwindConfig;
9
+ declare const bodyVariants: (props?: ({
10
+ fontWeight?: "default" | "thin" | "extralight" | "light" | "normal" | "medium" | "semibold" | "bold" | "extrabold" | "black" | null | undefined;
11
+ color?: "default" | "primary" | "secondary" | "accent" | "text" | "background" | null | undefined;
12
+ textTransform?: "none" | "uppercase" | "lowercase" | "capitalize" | null | undefined;
13
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
14
+ interface BodyProps extends Omit<React.HTMLAttributes<HTMLParagraphElement>, "color">, VariantProps<typeof bodyVariants> {
15
+ }
16
+ declare const Body: React.ForwardRefExoticComponent<BodyProps & React.RefAttributes<HTMLParagraphElement>>;
51
17
 
52
- interface EditorProps {
53
- document: any;
54
- componentRegistry: Map<string, Config<any>>;
55
- themeConfig?: ThemeConfig;
18
+ declare const buttonVariants: (props?: ({
19
+ variant?: "primary" | "secondary" | "link" | "outline" | null | undefined;
20
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
21
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
22
+ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
23
+ asChild?: boolean;
56
24
  }
57
- declare const Editor: ({ document, componentRegistry, themeConfig, }: EditorProps) => react_jsx_runtime.JSX.Element;
25
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
58
26
 
59
- type EntityFieldProps = {
60
- displayName?: string;
61
- fieldId?: string;
62
- children: React__default.ReactNode;
27
+ interface CTAProps extends React__default.ButtonHTMLAttributes<HTMLButtonElement> {
28
+ label?: string;
29
+ url?: string;
30
+ variant?: ButtonProps["variant"];
31
+ size?: ButtonProps["size"];
32
+ }
33
+ declare const CTA: {
34
+ ({ label, url, variant, size, className }: CTAProps): react_jsx_runtime.JSX.Element;
35
+ displayName: string;
63
36
  };
64
- declare const EntityField: ({ displayName, fieldId, children, }: EntityFieldProps) => react_jsx_runtime.JSX.Element;
37
+
38
+ declare const headingVariants: (props?: ({
39
+ weight?: "default" | "thin" | "extralight" | "light" | "normal" | "medium" | "semibold" | "bold" | "extrabold" | "black" | null | undefined;
40
+ color?: "default" | "primary" | "secondary" | "accent" | "text" | "background" | null | undefined;
41
+ transform?: "none" | "uppercase" | "lowercase" | "capitalize" | null | undefined;
42
+ level?: 1 | 2 | 3 | 4 | 5 | 6 | null | undefined;
43
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
44
+ type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
45
+ interface HeadingProps extends Omit<React.HTMLAttributes<HTMLHeadingElement>, "color">, VariantProps<typeof headingVariants> {
46
+ level?: HeadingLevel;
47
+ }
48
+ declare const Heading: React.ForwardRefExoticComponent<HeadingProps & React.RefAttributes<HTMLHeadingElement>>;
49
+
50
+ declare const sectionVariants: (props?: ({
51
+ padding?: "default" | "none" | "small" | "large" | null | undefined;
52
+ maxWidth?: "default" | "full" | "xl" | null | undefined;
53
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
54
+ interface SectionProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof sectionVariants> {
55
+ }
56
+ declare const Section: React.ForwardRefExoticComponent<SectionProps & React.RefAttributes<HTMLDivElement>>;
65
57
 
66
58
  type YextSchemaField = {
67
59
  name: string;
@@ -100,13 +92,14 @@ type DisallowList<T extends Record<string, any>> = {
100
92
  };
101
93
  type EntityFieldTypesFilter = {
102
94
  types: EntityFieldTypes[];
95
+ includeListsOnly?: boolean;
103
96
  };
104
97
  type RenderEntityFieldFilter<T extends Record<string, any>> = EntityFieldTypesFilter & EitherOrNeither<AllowList<T>, DisallowList<T>>;
105
- type EntityFieldTypes = "type.string" | "type.image" | "type.hours" | "type.address" | "type.phone" | `c_${string}`;
98
+ type EntityFieldTypes = "type.string" | "type.image" | "type.hours" | "type.address" | "type.phone" | "type.coordinate" | `c_${string}`;
106
99
 
107
- type YextEntityField = {
100
+ type YextEntityField<T> = {
108
101
  field: string;
109
- constantValue: string;
102
+ constantValue: T;
110
103
  constantValueEnabled?: boolean;
111
104
  };
112
105
  type RenderYextEntityFieldSelectorProps<T extends Record<string, any>> = {
@@ -116,12 +109,190 @@ type RenderYextEntityFieldSelectorProps<T extends Record<string, any>> = {
116
109
  /**
117
110
  * Allows the user to select an entity field from the document and set a constant value.
118
111
  */
119
- declare const YextEntityFieldSelector: <T extends Record<string, any>>(props: RenderYextEntityFieldSelectorProps<T>) => Field<YextEntityField>;
112
+ declare const YextEntityFieldSelector: <T extends Record<string, any>, U>(props: RenderYextEntityFieldSelectorProps<T>) => Field<YextEntityField<U>>;
113
+
114
+ type AddressProps = {
115
+ address: YextEntityField<AddressType>;
116
+ getDirectionsProvider: GetDirectionsConfig["provider"];
117
+ alignment: "items-start" | "items-center";
118
+ padding: VariantProps<typeof sectionVariants>["padding"];
119
+ };
120
+ declare const AddressComponent: ComponentConfig<AddressProps>;
121
+
122
+ interface BodyTextProps extends BodyProps {
123
+ text: YextEntityField<string>;
124
+ }
125
+ declare const BodyTextComponent: ComponentConfig<BodyTextProps>;
126
+
127
+ interface CTAWrapperProps extends CTAProps {
128
+ entityField: YextEntityField<CTAProps>;
129
+ }
130
+ declare const CTAWrapperComponent: ComponentConfig<CTAWrapperProps>;
131
+
132
+ declare const emailsVariants: (props?: ({
133
+ fontSize?: "default" | "medium" | "sm" | "lg" | "xl" | "xs" | "2xl" | "3xl" | "4xl" | "5xl" | null | undefined;
134
+ fontWeight?: "default" | "thin" | "extralight" | "light" | "normal" | "medium" | "semibold" | "bold" | "extrabold" | "black" | null | undefined;
135
+ color?: "default" | "primary" | "secondary" | "accent" | "text" | "background" | "foreground" | null | undefined;
136
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
137
+ interface EmailsProps extends VariantProps<typeof emailsVariants> {
138
+ list: YextEntityField<string[]>;
139
+ includeHyperlink: boolean;
140
+ listLength: number;
141
+ }
142
+ declare const EmailsComponent: ComponentConfig<EmailsProps>;
143
+
144
+ declare const flexContainerVariants: (props?: ({
145
+ direction?: "row" | "column" | null | undefined;
146
+ alignment?: "center" | "end" | "start" | "stretch" | null | undefined;
147
+ justification?: "center" | "end" | "start" | "spaceBetween" | "spaceAround" | null | undefined;
148
+ spacing?: "medium" | "small" | "large" | null | undefined;
149
+ wrap?: "wrap" | "nowrap" | null | undefined;
150
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
151
+ interface FlexContainerProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof flexContainerVariants> {
152
+ renderDropZone?: any;
153
+ }
154
+ declare const FlexContainerComponent: ComponentConfig<FlexContainerProps>;
155
+
156
+ declare const backgroundVariants: (props?: ({
157
+ backgroundColor?: "default" | "primary" | "secondary" | "accent" | "text" | "background" | null | undefined;
158
+ maxContentWidth?: "default" | "lg" | "xl" | "xxl" | null | undefined;
159
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
160
+ declare const gridSectionVariants: (props?: ({
161
+ horizontalSpacing?: "medium" | "small" | "large" | null | undefined;
162
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
163
+ declare const columnVariants: (props?: ({
164
+ verticalAlignment?: "center" | "end" | "start" | "spaceBetween" | null | undefined;
165
+ verticalSpacing?: "default" | "medium" | "small" | "large" | null | undefined;
166
+ padding?: "medium" | "none" | "small" | "large" | null | undefined;
167
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
168
+ interface ColumnProps extends VariantProps<typeof columnVariants> {
169
+ span?: number;
170
+ }
171
+ interface GridSectionProps extends React__default.HTMLAttributes<HTMLDivElement>, VariantProps<typeof gridSectionVariants>, VariantProps<typeof backgroundVariants> {
172
+ distribution: "auto" | "manual";
173
+ columns: ColumnProps[];
174
+ renderDropZone?: any;
175
+ }
176
+ declare const GridSectionComponent: ComponentConfig<GridSectionProps>;
177
+
178
+ interface HeadingTextProps extends HeadingProps {
179
+ text: YextEntityField<string>;
180
+ }
181
+ declare const HeadingTextComponent: ComponentConfig<HeadingTextProps>;
182
+
183
+ type HoursCardProps = {
184
+ startOfWeek: keyof DayOfWeekNames | "today";
185
+ collapseDays: boolean;
186
+ showAdditionalHoursText: boolean;
187
+ alignment: "items-start" | "items-center";
188
+ padding: VariantProps<typeof sectionVariants>["padding"];
189
+ };
190
+ declare const HoursCardComponent: ComponentConfig<HoursCardProps>;
191
+
192
+ interface HoursStatusProps {
193
+ hours: YextEntityField<any>;
194
+ className?: string;
195
+ showCurrentStatus?: boolean;
196
+ timeFormat?: "12h" | "24h";
197
+ dayOfWeekFormat?: "short" | "long";
198
+ showDayNames?: boolean;
199
+ }
200
+ declare const HoursStatusComponent: ComponentConfig<HoursStatusProps>;
201
+
202
+ declare const imageWrapperVariants: (props?: ({
203
+ size?: "medium" | "small" | "large" | "full" | null | undefined;
204
+ aspectRatio?: "video" | "auto" | "square" | "portrait" | null | undefined;
205
+ rounded?: "medium" | "none" | "small" | "large" | "full" | null | undefined;
206
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
207
+ interface ImageWrapperProps extends VariantProps<typeof imageWrapperVariants> {
208
+ image: YextEntityField<ImageType>;
209
+ }
210
+ declare const ImageWrapperComponent: ComponentConfig<ImageWrapperProps>;
120
211
 
121
- type ColorSelectorProps = {
212
+ declare const phoneVariants: (props?: ({
213
+ fontWeight?: "default" | "thin" | "extralight" | "light" | "normal" | "medium" | "semibold" | "bold" | "extrabold" | "black" | null | undefined;
214
+ color?: "default" | "primary" | "secondary" | "accent" | "text" | "background" | "foreground" | null | undefined;
215
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
216
+ interface PhoneProps extends VariantProps<typeof phoneVariants> {
217
+ phone: YextEntityField<string>;
218
+ textSize?: number;
219
+ }
220
+ declare const PhoneComponent: ComponentConfig<PhoneProps>;
221
+
222
+ declare const textListVariants: (props?: ({
223
+ fontWeight?: "default" | "thin" | "extralight" | "light" | "normal" | "medium" | "semibold" | "bold" | "extrabold" | "black" | null | undefined;
224
+ color?: "default" | "primary" | "secondary" | "accent" | "text" | "background" | null | undefined;
225
+ textTransform?: "none" | "uppercase" | "lowercase" | "capitalize" | null | undefined;
226
+ padding?: "default" | "none" | "small" | "large" | null | undefined;
227
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
228
+ interface TextListProps extends VariantProps<typeof textListVariants> {
229
+ list: YextEntityField<string[]>;
230
+ textSize?: number;
231
+ }
232
+ declare const TextListComponent: ComponentConfig<TextListProps>;
233
+
234
+ type CoreStyle = {
122
235
  label: string;
236
+ type: "number";
237
+ default: number;
238
+ } | {
239
+ label: string;
240
+ type: "select";
241
+ default: string;
242
+ options: StyleSelectOption[];
243
+ } | {
244
+ label: string;
245
+ type: "color";
246
+ default: string;
247
+ };
248
+ type Style = CoreStyle & {
249
+ plugin: string;
123
250
  };
124
- declare const ColorSelector: (props: ColorSelectorProps) => Field;
251
+ type StyleSelectOption = {
252
+ label: string;
253
+ value: string;
254
+ };
255
+ type StyleGroup = {
256
+ label: string;
257
+ plugin: string;
258
+ styles: {
259
+ [key: string]: CoreStyle;
260
+ };
261
+ };
262
+ type ThemeConfigSection = {
263
+ label: string;
264
+ styles: {
265
+ [key: string]: Style | StyleGroup;
266
+ };
267
+ };
268
+ type ThemeConfig = {
269
+ [key: string]: ThemeConfigSection;
270
+ };
271
+ type TailwindConfig = {
272
+ [key: string]: {
273
+ [key: string]: any;
274
+ };
275
+ };
276
+ /**
277
+ * Merges the developer-specified theming and the marketer-specified theming,
278
+ * giving priority to the developer-specified theming.
279
+ */
280
+ declare const themeResolver: (developerTheming: TailwindConfig, marketerTheming: ThemeConfig) => TailwindConfig;
281
+
282
+ type EditorProps = {
283
+ document: any;
284
+ componentRegistry: Map<string, Config<any>>;
285
+ themeConfig?: ThemeConfig;
286
+ };
287
+ declare const Editor: ({ document, componentRegistry, themeConfig, }: EditorProps) => react_jsx_runtime.JSX.Element;
288
+
289
+ type EntityFieldProps = {
290
+ displayName?: string;
291
+ fieldId?: string;
292
+ constantValueEnabled?: boolean;
293
+ children: React__default.ReactNode;
294
+ };
295
+ declare const EntityField: ({ displayName, fieldId, constantValueEnabled, children, }: EntityFieldProps) => string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React__default.ReactNode> | null | undefined;
125
296
 
126
297
  declare const usePlatformBridgeDocument: () => any;
127
298
 
@@ -137,6 +308,14 @@ type EntityFieldsProviderProps = {
137
308
  declare const EntityFieldsProvider: ({ entityFields, children, }: EntityFieldsProviderProps) => react_jsx_runtime.JSX.Element;
138
309
  declare const useEntityFields: () => YextSchemaField[];
139
310
 
311
+ declare const DocumentContext: React.Context<any>;
312
+ type DocumentProviderProps<T> = {
313
+ value: T;
314
+ children: React.ReactNode;
315
+ };
316
+ declare const DocumentProvider: <T>({ value, children, }: DocumentProviderProps<T>) => react_jsx_runtime.JSX.Element;
317
+ declare const useDocument: <T>() => T;
318
+
140
319
  type Document = {
141
320
  [key: string]: any;
142
321
  };
@@ -144,6 +323,6 @@ declare const applyTheme: (document: Document, themeConfig: ThemeConfig, base?:
144
323
 
145
324
  declare function resolveVisualEditorData(data: any, pageSet: string | undefined): string;
146
325
 
147
- declare const resolveYextEntityField: <T>(document: any, entityField: YextEntityField) => T | undefined;
326
+ declare const resolveYextEntityField: <T>(document: any, entityField: YextEntityField<T>) => T | undefined;
148
327
 
149
- export { ColorSelector, Editor, EntityField, EntityFieldsProvider, type RenderYextEntityFieldSelectorProps, type ThemeConfig, type YextEntityField, YextEntityFieldSelector, applyTheme, resolveVisualEditorData, resolveYextEntityField, themeResolver, useEntityFields, usePlatformBridgeDocument, usePlatformBridgeEntityFields };
328
+ export { AddressComponent, type AddressProps, Body, type BodyProps, BodyTextComponent, type BodyTextProps, Button, type ButtonProps, CTA, type CTAProps, CTAWrapperComponent, type CTAWrapperProps, DocumentContext, DocumentProvider, Editor, EmailsComponent, type EmailsProps, EntityField, EntityFieldsProvider, FlexContainerComponent, type FlexContainerProps, GridSectionComponent, type GridSectionProps, Heading, type HeadingProps, HeadingTextComponent, type HeadingTextProps, HoursCardComponent, type HoursCardProps, HoursStatusComponent, type HoursStatusProps, ImageWrapperComponent, type ImageWrapperProps, PhoneComponent, type PhoneProps, type RenderYextEntityFieldSelectorProps, Section, type SectionProps, TextListComponent, type TextListProps, type ThemeConfig, type YextEntityField, YextEntityFieldSelector, applyTheme, bodyVariants, buttonVariants, headingVariants, resolveVisualEditorData, resolveYextEntityField, sectionVariants, themeResolver, useDocument, useEntityFields, usePlatformBridgeDocument, usePlatformBridgeEntityFields };