@measured/puck-plugin-heading-analyzer 0.16.0-canary.a43914d → 0.16.0-canary.acdb11d

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.
@@ -0,0 +1,229 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+
3
+ type ItemSelector = {
4
+ index: number;
5
+ zone?: string;
6
+ };
7
+
8
+ type FieldOption = {
9
+ label: string;
10
+ value: string | number | boolean;
11
+ };
12
+ type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
13
+ type BaseField = {
14
+ label?: string;
15
+ };
16
+ type TextField = BaseField & {
17
+ type: "text";
18
+ };
19
+ type NumberField = BaseField & {
20
+ type: "number";
21
+ min?: number;
22
+ max?: number;
23
+ };
24
+ type TextareaField = BaseField & {
25
+ type: "textarea";
26
+ };
27
+ type SelectField = BaseField & {
28
+ type: "select";
29
+ options: FieldOptions;
30
+ };
31
+ type RadioField = BaseField & {
32
+ type: "radio";
33
+ options: FieldOptions;
34
+ };
35
+ type ArrayField<Props extends {
36
+ [key: string]: any;
37
+ } = {
38
+ [key: string]: any;
39
+ }> = BaseField & {
40
+ type: "array";
41
+ arrayFields: {
42
+ [SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
43
+ };
44
+ defaultItemProps?: Props[0];
45
+ getItemSummary?: (item: Props[0], index?: number) => string;
46
+ max?: number;
47
+ min?: number;
48
+ };
49
+ type ObjectField<Props extends {
50
+ [key: string]: any;
51
+ } = {
52
+ [key: string]: any;
53
+ }> = BaseField & {
54
+ type: "object";
55
+ objectFields: Props extends any[] ? never : {
56
+ [SubPropName in keyof Props]: Field<Props[SubPropName]>;
57
+ };
58
+ };
59
+ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
60
+ name: string;
61
+ fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
62
+ mapProp?: (value: TableShape) => PropShape;
63
+ };
64
+ type ExternalFieldWithAdaptor<Props extends {
65
+ [key: string]: any;
66
+ } = {
67
+ [key: string]: any;
68
+ }> = BaseField & {
69
+ type: "external";
70
+ placeholder?: string;
71
+ adaptor: Adaptor<any, any, Props>;
72
+ adaptorParams?: object;
73
+ getItemSummary: (item: Props, index?: number) => string;
74
+ };
75
+ type ExternalField<Props extends {
76
+ [key: string]: any;
77
+ } = {
78
+ [key: string]: any;
79
+ }> = BaseField & {
80
+ type: "external";
81
+ placeholder?: string;
82
+ fetchList: (params: {
83
+ query: string;
84
+ filters: Record<string, any>;
85
+ }) => Promise<any[] | null>;
86
+ mapProp?: (value: any) => Props;
87
+ mapRow?: (value: any) => Record<string, string | number>;
88
+ getItemSummary?: (item: Props, index?: number) => string;
89
+ showSearch?: boolean;
90
+ initialQuery?: string;
91
+ filterFields?: Record<string, Field>;
92
+ initialFilters?: Record<string, any>;
93
+ };
94
+ type CustomField<Props extends any = {}> = BaseField & {
95
+ type: "custom";
96
+ render: (props: {
97
+ field: CustomField<Props>;
98
+ name: string;
99
+ id: string;
100
+ value: Props;
101
+ onChange: (value: Props) => void;
102
+ readOnly?: boolean;
103
+ }) => ReactElement;
104
+ };
105
+ type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
106
+ [key: string]: any;
107
+ } ? Props : any> | ObjectField<Props extends {
108
+ [key: string]: any;
109
+ } ? Props : any> | ExternalField<Props extends {
110
+ [key: string]: any;
111
+ } ? Props : any> | ExternalFieldWithAdaptor<Props extends {
112
+ [key: string]: any;
113
+ } ? Props : any> | CustomField<Props>;
114
+ type FieldProps<ValueType = any, F = Field<any>> = {
115
+ field: F;
116
+ value: ValueType;
117
+ id?: string;
118
+ onChange: (value: ValueType, uiState?: Partial<UiState>) => void;
119
+ readOnly?: boolean;
120
+ };
121
+
122
+ type ItemWithId = {
123
+ _arrayId: string;
124
+ _originalIndex: number;
125
+ };
126
+ type ArrayState = {
127
+ items: ItemWithId[];
128
+ openId: string;
129
+ };
130
+ type UiState = {
131
+ leftSideBarVisible: boolean;
132
+ rightSideBarVisible: boolean;
133
+ itemSelector: ItemSelector | null;
134
+ arrayState: Record<string, ArrayState | undefined>;
135
+ componentList: Record<string, {
136
+ components?: string[];
137
+ title?: string;
138
+ visible?: boolean;
139
+ expanded?: boolean;
140
+ }>;
141
+ isDragging: boolean;
142
+ viewports: {
143
+ current: {
144
+ width: number;
145
+ height: number | "auto";
146
+ };
147
+ controlsVisible: boolean;
148
+ options: Viewport[];
149
+ };
150
+ };
151
+
152
+ type RenderFunc<Props extends {
153
+ [key: string]: any;
154
+ } = {
155
+ children: ReactNode;
156
+ }> = (props: Props) => ReactElement;
157
+ declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
158
+ type OverrideKey = (typeof overrideKeys)[number];
159
+ type OverridesGeneric<Shape extends {
160
+ [key in OverrideKey]: any;
161
+ }> = Shape;
162
+ type Overrides = OverridesGeneric<{
163
+ fieldTypes: Partial<FieldRenderFunctions>;
164
+ header: RenderFunc<{
165
+ actions: ReactNode;
166
+ children: ReactNode;
167
+ }>;
168
+ actionBar: RenderFunc<{
169
+ label?: string;
170
+ children: ReactNode;
171
+ }>;
172
+ headerActions: RenderFunc<{
173
+ children: ReactNode;
174
+ }>;
175
+ preview: RenderFunc;
176
+ fields: RenderFunc<{
177
+ children: ReactNode;
178
+ isLoading: boolean;
179
+ itemSelector?: ItemSelector | null;
180
+ }>;
181
+ fieldLabel: RenderFunc<{
182
+ children?: ReactNode;
183
+ icon?: ReactNode;
184
+ label: string;
185
+ el?: "label" | "div";
186
+ readOnly?: boolean;
187
+ className?: string;
188
+ }>;
189
+ components: RenderFunc;
190
+ componentItem: RenderFunc<{
191
+ children: ReactNode;
192
+ name: string;
193
+ }>;
194
+ iframe: RenderFunc<{
195
+ children: ReactNode;
196
+ document?: Document;
197
+ }>;
198
+ outline: RenderFunc;
199
+ puck: RenderFunc;
200
+ }>;
201
+ type FieldRenderFunctions = Omit<{
202
+ [Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
203
+ type: Type;
204
+ }>> & {
205
+ children: ReactNode;
206
+ name: string;
207
+ }>;
208
+ }, "custom"> & {
209
+ [key: string]: React.FunctionComponent<FieldProps<any> & {
210
+ children: ReactNode;
211
+ name: string;
212
+ }>;
213
+ };
214
+
215
+ type iconTypes = "Smartphone" | "Monitor" | "Tablet";
216
+ type Viewport = {
217
+ width: number;
218
+ height?: number | "auto";
219
+ label?: string;
220
+ icon?: iconTypes | ReactNode;
221
+ };
222
+
223
+ type Plugin = {
224
+ overrides: Partial<Overrides>;
225
+ };
226
+
227
+ declare const headingAnalyzer: Plugin;
228
+
229
+ export { headingAnalyzer as default };
package/dist/index.d.ts CHANGED
@@ -1,48 +1,10 @@
1
- import { ReactNode, ReactElement } from 'react';
1
+ import { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  type ItemSelector = {
4
4
  index: number;
5
5
  zone?: string;
6
6
  };
7
7
 
8
- type iconTypes = "Smartphone" | "Monitor" | "Tablet";
9
- type Viewport = {
10
- width: number;
11
- height?: number | "auto";
12
- label?: string;
13
- icon?: iconTypes | ReactNode;
14
- };
15
-
16
- type ItemWithId = {
17
- _arrayId: string;
18
- _originalIndex: number;
19
- };
20
- type ArrayState = {
21
- items: ItemWithId[];
22
- openId: string;
23
- };
24
- type UiState = {
25
- leftSideBarVisible: boolean;
26
- rightSideBarVisible: boolean;
27
- itemSelector: ItemSelector | null;
28
- arrayState: Record<string, ArrayState | undefined>;
29
- componentList: Record<string, {
30
- components?: string[];
31
- title?: string;
32
- visible?: boolean;
33
- expanded?: boolean;
34
- }>;
35
- isDragging: boolean;
36
- viewports: {
37
- current: {
38
- width: number;
39
- height: number | "auto";
40
- };
41
- controlsVisible: boolean;
42
- options: Viewport[];
43
- };
44
- };
45
-
46
8
  type FieldOption = {
47
9
  label: string;
48
10
  value: string | number | boolean;
@@ -157,6 +119,36 @@ type FieldProps<ValueType = any, F = Field<any>> = {
157
119
  readOnly?: boolean;
158
120
  };
159
121
 
122
+ type ItemWithId = {
123
+ _arrayId: string;
124
+ _originalIndex: number;
125
+ };
126
+ type ArrayState = {
127
+ items: ItemWithId[];
128
+ openId: string;
129
+ };
130
+ type UiState = {
131
+ leftSideBarVisible: boolean;
132
+ rightSideBarVisible: boolean;
133
+ itemSelector: ItemSelector | null;
134
+ arrayState: Record<string, ArrayState | undefined>;
135
+ componentList: Record<string, {
136
+ components?: string[];
137
+ title?: string;
138
+ visible?: boolean;
139
+ expanded?: boolean;
140
+ }>;
141
+ isDragging: boolean;
142
+ viewports: {
143
+ current: {
144
+ width: number;
145
+ height: number | "auto";
146
+ };
147
+ controlsVisible: boolean;
148
+ options: Viewport[];
149
+ };
150
+ };
151
+
160
152
  type RenderFunc<Props extends {
161
153
  [key: string]: any;
162
154
  } = {
@@ -199,6 +191,10 @@ type Overrides = OverridesGeneric<{
199
191
  children: ReactNode;
200
192
  name: string;
201
193
  }>;
194
+ iframe: RenderFunc<{
195
+ children: ReactNode;
196
+ document?: Document;
197
+ }>;
202
198
  outline: RenderFunc;
203
199
  puck: RenderFunc;
204
200
  }>;
@@ -216,6 +212,14 @@ type FieldRenderFunctions = Omit<{
216
212
  }>;
217
213
  };
218
214
 
215
+ type iconTypes = "Smartphone" | "Monitor" | "Tablet";
216
+ type Viewport = {
217
+ width: number;
218
+ height?: number | "auto";
219
+ label?: string;
220
+ icon?: iconTypes | ReactNode;
221
+ };
222
+
219
223
  type Plugin = {
220
224
  overrides: Partial<Overrides>;
221
225
  };