@yext/visual-editor 0.0.13 → 0.0.15

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