@yext/visual-editor 0.0.8 → 0.0.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/README.md CHANGED
@@ -8,6 +8,7 @@ This library provides components necessary to set up a Pages repository that can
8
8
  | Hook |
9
9
  |------------------------------------------------------------------|
10
10
  | [usePlatformBridgeDocument](./src/hooks/README.md#usePlatformBridgeDocument) |
11
+ | [usePlatformBridgeEntityFields](./src/hooks/README.md#usePlatformBridgeEntityFields) |
11
12
 
12
13
  ## Components
13
14
 
@@ -15,9 +16,11 @@ This library provides components necessary to set up a Pages repository that can
15
16
  |-------------------------------------------------------|
16
17
  | [Editor](./src/components/README.md#editor) |
17
18
  | [EntityField](./src/components/README.md#entityfield) |
19
+ | [YextEntityFieldSelector](./src/components/README.md#YextEntityFieldSelector) |
18
20
 
19
21
  ## Utils
20
22
 
21
23
  | Function |
22
24
  |--------------------------------------------------------------------------|
23
25
  | [resolveVisualEditorData](./src/utils/README.md#resolvevisualeditordata) |
26
+ | [resolveYextEntityField](./src/utils/README.md#resolveYextEntityField) |
package/dist/index.d.cts CHANGED
@@ -1,13 +1,60 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Config, CustomField, ObjectField } from '@measured/puck';
2
+ import { Config, Field } from '@measured/puck';
3
3
  import * as React from 'react';
4
4
  import React__default from 'react';
5
5
 
6
+ type Style = {
7
+ label: string;
8
+ plugin: string;
9
+ type: "number";
10
+ default: number | 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;
51
+
6
52
  interface EditorProps {
7
53
  document: any;
8
54
  componentRegistry: Map<string, Config<any>>;
55
+ themeConfig?: ThemeConfig;
9
56
  }
10
- declare const Editor: ({ document, componentRegistry }: EditorProps) => react_jsx_runtime.JSX.Element;
57
+ declare const Editor: ({ document, componentRegistry, themeConfig, }: EditorProps) => react_jsx_runtime.JSX.Element;
11
58
 
12
59
  type EntityFieldProps = {
13
60
  displayName?: string;
@@ -16,37 +63,6 @@ type EntityFieldProps = {
16
63
  };
17
64
  declare const EntityField: ({ displayName, fieldId, children, }: EntityFieldProps) => react_jsx_runtime.JSX.Element;
18
65
 
19
- declare const usePlatformBridgeDocument: () => any;
20
-
21
- /**
22
- * Under the hood we receive a Stream for a template, but we expose
23
- * hooks with a more user-friendly name.
24
- */
25
- declare const usePlatformBridgeEntityFields: () => YextEntityFields;
26
- type EntityFieldsProviderProps = {
27
- entityFields: YextEntityFields;
28
- children: React.ReactNode;
29
- };
30
- declare const EntityFieldsProvider: ({ entityFields, children, }: EntityFieldsProviderProps) => react_jsx_runtime.JSX.Element;
31
- declare const useEntityFields: () => YextEntityFields;
32
- type YextEntityFields = {
33
- stream: YextStream;
34
- };
35
- type YextStream = {
36
- expression: {
37
- fields: YextEntityField[];
38
- };
39
- schema: YextSchema;
40
- };
41
- type YextEntityField = {
42
- name: string;
43
- children?: {
44
- fields: YextEntityField[];
45
- };
46
- };
47
- type YextSchema = {
48
- fields: YextSchemaField[];
49
- };
50
66
  type YextSchemaField = {
51
67
  name: string;
52
68
  definition: YextFieldDefinition;
@@ -56,10 +72,10 @@ type YextSchemaField = {
56
72
  };
57
73
  type YextFieldDefinition = {
58
74
  name: string;
59
- isList: boolean;
60
- registryId: string;
61
- typeName: string;
62
- typeRegistryId: string;
75
+ isList?: boolean;
76
+ registryId?: string;
77
+ typeName?: string;
78
+ typeRegistryId?: string;
63
79
  type: Record<string, string>;
64
80
  };
65
81
 
@@ -83,40 +99,50 @@ type DisallowList<T extends Record<string, any>> = {
83
99
  disallowList: ConfigFields<T>[number][];
84
100
  };
85
101
  type EntityFieldTypesFilter = {
86
- types?: EntityFieldTypes[];
87
- includeSubfields?: boolean;
102
+ types: EntityFieldTypes[];
88
103
  };
89
104
  type RenderEntityFieldFilter<T extends Record<string, any>> = EntityFieldTypesFilter & EitherOrNeither<AllowList<T>, DisallowList<T>>;
90
- type EntityFieldTypes = "type.string" | "type.image" | `c_${string}`;
91
-
92
- type RenderProps = Parameters<CustomField<any>["render"]>[0];
93
- type RenderEntityFields<T extends RenderProps, U extends Record<string, any>> = {
94
- renderProps: RenderProps;
95
- fieldName: keyof T["value"];
96
- objectFields?: ObjectField<any>["objectFields"];
97
- filter?: RenderEntityFieldFilter<U>;
98
- };
99
- declare const renderEntityFields: <T extends RenderProps, U extends Record<string, any>>(props: RenderEntityFields<T, U>) => react_jsx_runtime.JSX.Element;
105
+ type EntityFieldTypes = "type.string" | "type.image" | "type.hours" | "type.address" | "type.phone" | `c_${string}`;
100
106
 
101
- type EntityFieldType = {
102
- fieldName: string;
103
- staticValue: string;
107
+ type YextEntityField = {
108
+ field: string;
109
+ constantValue: string;
110
+ constantValueEnabled?: boolean;
104
111
  };
105
112
  type RenderYextEntityFieldSelectorProps<T extends Record<string, any>> = {
106
113
  label: string;
107
114
  filter: RenderEntityFieldFilter<T>;
108
115
  };
109
116
  /**
110
- * Allows the user to select an entity field from the document and set a static value.
117
+ * Allows the user to select an entity field from the document and set a constant value.
111
118
  */
112
- declare const YextEntityFieldSelector: <T extends Record<string, any>>(props: RenderYextEntityFieldSelectorProps<T>) => {
113
- type: string;
114
- label: string;
115
- render: ({ field, value, onChange }: RenderProps) => react_jsx_runtime.JSX.Element;
119
+ declare const YextEntityFieldSelector: <T extends Record<string, any>>(props: RenderYextEntityFieldSelectorProps<T>) => Field<YextEntityField>;
120
+
121
+ declare const usePlatformBridgeDocument: () => any;
122
+
123
+ /**
124
+ * Under the hood we receive a Stream for a template, but we expose
125
+ * hooks with a more user-friendly name.
126
+ */
127
+ declare const usePlatformBridgeEntityFields: () => YextSchemaField[];
128
+ type EntityFieldsProviderProps = {
129
+ entityFields: YextSchemaField[];
130
+ children: React.ReactNode;
131
+ };
132
+ declare const EntityFieldsProvider: ({ entityFields, children, }: EntityFieldsProviderProps) => react_jsx_runtime.JSX.Element;
133
+ declare const useEntityFields: () => YextSchemaField[];
134
+
135
+ type Document = {
136
+ c_theme?: CssVariableOverrides;
137
+ [key: string]: any;
138
+ };
139
+ type CssVariableOverrides = {
140
+ [key: string]: string;
116
141
  };
142
+ declare const applyTheme: (document: Document, base?: string) => string;
117
143
 
118
- declare function resolveVisualEditorData(data: any, templateName: string | undefined): string;
144
+ declare function resolveVisualEditorData(data: any, pageSet: string | undefined): string;
119
145
 
120
- declare const resolveYextEntityField: <T>(document: any, entityField: EntityFieldType) => T;
146
+ declare const resolveYextEntityField: <T>(document: any, entityField: YextEntityField) => T | undefined;
121
147
 
122
- export { Editor, EntityField, type EntityFieldType, EntityFieldsProvider, type RenderYextEntityFieldSelectorProps, type YextEntityField, YextEntityFieldSelector, type YextEntityFields, type YextFieldDefinition, type YextSchema, type YextSchemaField, type YextStream, renderEntityFields, resolveVisualEditorData, resolveYextEntityField, useEntityFields, usePlatformBridgeDocument, usePlatformBridgeEntityFields };
148
+ export { Editor, EntityField, EntityFieldsProvider, type RenderYextEntityFieldSelectorProps, type ThemeConfig, type YextEntityField, YextEntityFieldSelector, applyTheme, resolveVisualEditorData, resolveYextEntityField, themeResolver, useEntityFields, usePlatformBridgeDocument, usePlatformBridgeEntityFields };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,60 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Config, CustomField, ObjectField } from '@measured/puck';
2
+ import { Config, Field } from '@measured/puck';
3
3
  import * as React from 'react';
4
4
  import React__default from 'react';
5
5
 
6
+ type Style = {
7
+ label: string;
8
+ plugin: string;
9
+ type: "number";
10
+ default: number | 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;
51
+
6
52
  interface EditorProps {
7
53
  document: any;
8
54
  componentRegistry: Map<string, Config<any>>;
55
+ themeConfig?: ThemeConfig;
9
56
  }
10
- declare const Editor: ({ document, componentRegistry }: EditorProps) => react_jsx_runtime.JSX.Element;
57
+ declare const Editor: ({ document, componentRegistry, themeConfig, }: EditorProps) => react_jsx_runtime.JSX.Element;
11
58
 
12
59
  type EntityFieldProps = {
13
60
  displayName?: string;
@@ -16,37 +63,6 @@ type EntityFieldProps = {
16
63
  };
17
64
  declare const EntityField: ({ displayName, fieldId, children, }: EntityFieldProps) => react_jsx_runtime.JSX.Element;
18
65
 
19
- declare const usePlatformBridgeDocument: () => any;
20
-
21
- /**
22
- * Under the hood we receive a Stream for a template, but we expose
23
- * hooks with a more user-friendly name.
24
- */
25
- declare const usePlatformBridgeEntityFields: () => YextEntityFields;
26
- type EntityFieldsProviderProps = {
27
- entityFields: YextEntityFields;
28
- children: React.ReactNode;
29
- };
30
- declare const EntityFieldsProvider: ({ entityFields, children, }: EntityFieldsProviderProps) => react_jsx_runtime.JSX.Element;
31
- declare const useEntityFields: () => YextEntityFields;
32
- type YextEntityFields = {
33
- stream: YextStream;
34
- };
35
- type YextStream = {
36
- expression: {
37
- fields: YextEntityField[];
38
- };
39
- schema: YextSchema;
40
- };
41
- type YextEntityField = {
42
- name: string;
43
- children?: {
44
- fields: YextEntityField[];
45
- };
46
- };
47
- type YextSchema = {
48
- fields: YextSchemaField[];
49
- };
50
66
  type YextSchemaField = {
51
67
  name: string;
52
68
  definition: YextFieldDefinition;
@@ -56,10 +72,10 @@ type YextSchemaField = {
56
72
  };
57
73
  type YextFieldDefinition = {
58
74
  name: string;
59
- isList: boolean;
60
- registryId: string;
61
- typeName: string;
62
- typeRegistryId: string;
75
+ isList?: boolean;
76
+ registryId?: string;
77
+ typeName?: string;
78
+ typeRegistryId?: string;
63
79
  type: Record<string, string>;
64
80
  };
65
81
 
@@ -83,40 +99,50 @@ type DisallowList<T extends Record<string, any>> = {
83
99
  disallowList: ConfigFields<T>[number][];
84
100
  };
85
101
  type EntityFieldTypesFilter = {
86
- types?: EntityFieldTypes[];
87
- includeSubfields?: boolean;
102
+ types: EntityFieldTypes[];
88
103
  };
89
104
  type RenderEntityFieldFilter<T extends Record<string, any>> = EntityFieldTypesFilter & EitherOrNeither<AllowList<T>, DisallowList<T>>;
90
- type EntityFieldTypes = "type.string" | "type.image" | `c_${string}`;
91
-
92
- type RenderProps = Parameters<CustomField<any>["render"]>[0];
93
- type RenderEntityFields<T extends RenderProps, U extends Record<string, any>> = {
94
- renderProps: RenderProps;
95
- fieldName: keyof T["value"];
96
- objectFields?: ObjectField<any>["objectFields"];
97
- filter?: RenderEntityFieldFilter<U>;
98
- };
99
- declare const renderEntityFields: <T extends RenderProps, U extends Record<string, any>>(props: RenderEntityFields<T, U>) => react_jsx_runtime.JSX.Element;
105
+ type EntityFieldTypes = "type.string" | "type.image" | "type.hours" | "type.address" | "type.phone" | `c_${string}`;
100
106
 
101
- type EntityFieldType = {
102
- fieldName: string;
103
- staticValue: string;
107
+ type YextEntityField = {
108
+ field: string;
109
+ constantValue: string;
110
+ constantValueEnabled?: boolean;
104
111
  };
105
112
  type RenderYextEntityFieldSelectorProps<T extends Record<string, any>> = {
106
113
  label: string;
107
114
  filter: RenderEntityFieldFilter<T>;
108
115
  };
109
116
  /**
110
- * Allows the user to select an entity field from the document and set a static value.
117
+ * Allows the user to select an entity field from the document and set a constant value.
111
118
  */
112
- declare const YextEntityFieldSelector: <T extends Record<string, any>>(props: RenderYextEntityFieldSelectorProps<T>) => {
113
- type: string;
114
- label: string;
115
- render: ({ field, value, onChange }: RenderProps) => react_jsx_runtime.JSX.Element;
119
+ declare const YextEntityFieldSelector: <T extends Record<string, any>>(props: RenderYextEntityFieldSelectorProps<T>) => Field<YextEntityField>;
120
+
121
+ declare const usePlatformBridgeDocument: () => any;
122
+
123
+ /**
124
+ * Under the hood we receive a Stream for a template, but we expose
125
+ * hooks with a more user-friendly name.
126
+ */
127
+ declare const usePlatformBridgeEntityFields: () => YextSchemaField[];
128
+ type EntityFieldsProviderProps = {
129
+ entityFields: YextSchemaField[];
130
+ children: React.ReactNode;
131
+ };
132
+ declare const EntityFieldsProvider: ({ entityFields, children, }: EntityFieldsProviderProps) => react_jsx_runtime.JSX.Element;
133
+ declare const useEntityFields: () => YextSchemaField[];
134
+
135
+ type Document = {
136
+ c_theme?: CssVariableOverrides;
137
+ [key: string]: any;
138
+ };
139
+ type CssVariableOverrides = {
140
+ [key: string]: string;
116
141
  };
142
+ declare const applyTheme: (document: Document, base?: string) => string;
117
143
 
118
- declare function resolveVisualEditorData(data: any, templateName: string | undefined): string;
144
+ declare function resolveVisualEditorData(data: any, pageSet: string | undefined): string;
119
145
 
120
- declare const resolveYextEntityField: <T>(document: any, entityField: EntityFieldType) => T;
146
+ declare const resolveYextEntityField: <T>(document: any, entityField: YextEntityField) => T | undefined;
121
147
 
122
- export { Editor, EntityField, type EntityFieldType, EntityFieldsProvider, type RenderYextEntityFieldSelectorProps, type YextEntityField, YextEntityFieldSelector, type YextEntityFields, type YextFieldDefinition, type YextSchema, type YextSchemaField, type YextStream, renderEntityFields, resolveVisualEditorData, resolveYextEntityField, useEntityFields, usePlatformBridgeDocument, usePlatformBridgeEntityFields };
148
+ export { Editor, EntityField, EntityFieldsProvider, type RenderYextEntityFieldSelectorProps, type ThemeConfig, type YextEntityField, YextEntityFieldSelector, applyTheme, resolveVisualEditorData, resolveYextEntityField, themeResolver, useEntityFields, usePlatformBridgeDocument, usePlatformBridgeEntityFields };