@reacteditor/core 0.0.1-alpha.0

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.
Files changed (52) hide show
  1. package/README.md +85 -0
  2. package/dist/Editor-GBV2O5RD.css +415 -0
  3. package/dist/Editor-IKMJILGR.mjs +204 -0
  4. package/dist/Render-EFT7YD2C.css +103 -0
  5. package/dist/Render-VDC7AEQK.mjs +55 -0
  6. package/dist/actions-BCDhqbeL.d.mts +849 -0
  7. package/dist/actions-BCDhqbeL.d.ts +849 -0
  8. package/dist/chunk-2YLS65V2.mjs +103 -0
  9. package/dist/chunk-6B2Q5R3C.mjs +53 -0
  10. package/dist/chunk-DXGQXXQG.mjs +63 -0
  11. package/dist/chunk-F7S5S6I2.mjs +114 -0
  12. package/dist/chunk-GAUBBDIR.mjs +463 -0
  13. package/dist/chunk-GUMYXUO3.mjs +33 -0
  14. package/dist/chunk-M6W7YEVX.mjs +95 -0
  15. package/dist/chunk-MFI3RDA4.mjs +11 -0
  16. package/dist/chunk-QNHSXCWU.mjs +8692 -0
  17. package/dist/chunk-SURZYH7D.mjs +1726 -0
  18. package/dist/chunk-V2OPYD42.mjs +708 -0
  19. package/dist/chunk-VD3EVRUF.mjs +476 -0
  20. package/dist/chunk-VOLQMQPK.mjs +146 -0
  21. package/dist/chunk-VUEM62JF.mjs +523 -0
  22. package/dist/chunk-Y2EFNT5P.mjs +108 -0
  23. package/dist/full-ELX6RALJ.css +311 -0
  24. package/dist/full-OBTPW7TC.mjs +93 -0
  25. package/dist/index-ComBHfdn.d.ts +117 -0
  26. package/dist/index-DVwiIwYU.d.mts +117 -0
  27. package/dist/index.css +3033 -0
  28. package/dist/index.d.mts +396 -0
  29. package/dist/index.d.ts +396 -0
  30. package/dist/index.js +14688 -0
  31. package/dist/index.mjs +87 -0
  32. package/dist/internal.d.mts +27 -0
  33. package/dist/internal.d.ts +27 -0
  34. package/dist/internal.js +931 -0
  35. package/dist/internal.mjs +13 -0
  36. package/dist/loaded-35WC23HJ.mjs +60 -0
  37. package/dist/loaded-TBSVRJPY.css +90 -0
  38. package/dist/loaded-ULSROV73.mjs +57 -0
  39. package/dist/loaded-YYRJPIWZ.mjs +57 -0
  40. package/dist/no-external.css +3031 -0
  41. package/dist/no-external.d.mts +21 -0
  42. package/dist/no-external.d.ts +21 -0
  43. package/dist/no-external.js +14688 -0
  44. package/dist/no-external.mjs +87 -0
  45. package/dist/rsc.css +103 -0
  46. package/dist/rsc.d.mts +27 -0
  47. package/dist/rsc.d.ts +27 -0
  48. package/dist/rsc.js +1493 -0
  49. package/dist/rsc.mjs +148 -0
  50. package/dist/walk-tree-BPIigVTF.d.mts +29 -0
  51. package/dist/walk-tree-BZq1CPCH.d.ts +29 -0
  52. package/package.json +139 -0
@@ -0,0 +1,849 @@
1
+ import { ReactElement, CSSProperties, ReactNode, ElementType, Ref, JSX } from 'react';
2
+ import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
3
+ import { BlockquoteOptions } from '@tiptap/extension-blockquote';
4
+ import { BoldOptions } from '@tiptap/extension-bold';
5
+ import { CodeOptions } from '@tiptap/extension-code';
6
+ import { CodeBlockOptions } from '@tiptap/extension-code-block';
7
+ import { HardBreakOptions } from '@tiptap/extension-hard-break';
8
+ import { HeadingOptions } from '@tiptap/extension-heading';
9
+ import { HorizontalRuleOptions } from '@tiptap/extension-horizontal-rule';
10
+ import { ItalicOptions } from '@tiptap/extension-italic';
11
+ import { LinkOptions } from '@tiptap/extension-link';
12
+ import { BulletListOptions, ListItemOptions, ListKeymapOptions, OrderedListOptions } from '@tiptap/extension-list';
13
+ import { ParagraphOptions } from '@tiptap/extension-paragraph';
14
+ import { StrikeOptions } from '@tiptap/extension-strike';
15
+ import { TextAlignOptions } from '@tiptap/extension-text-align';
16
+ import { UnderlineOptions } from '@tiptap/extension-underline';
17
+
18
+ type ItemSelector = {
19
+ index: number;
20
+ zone?: string;
21
+ };
22
+
23
+ declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
24
+ isAlignLeft?: undefined;
25
+ canAlignLeft?: undefined;
26
+ isAlignCenter?: undefined;
27
+ canAlignCenter?: undefined;
28
+ isAlignRight?: undefined;
29
+ canAlignRight?: undefined;
30
+ isAlignJustify?: undefined;
31
+ canAlignJustify?: undefined;
32
+ isBold?: undefined;
33
+ canBold?: undefined;
34
+ isItalic?: undefined;
35
+ canItalic?: undefined;
36
+ isUnderline?: undefined;
37
+ canUnderline?: undefined;
38
+ isStrike?: undefined;
39
+ canStrike?: undefined;
40
+ isInlineCode?: undefined;
41
+ canInlineCode?: undefined;
42
+ isBulletList?: undefined;
43
+ canBulletList?: undefined;
44
+ isOrderedList?: undefined;
45
+ canOrderedList?: undefined;
46
+ isCodeBlock?: undefined;
47
+ canCodeBlock?: undefined;
48
+ isBlockquote?: undefined;
49
+ canBlockquote?: undefined;
50
+ canHorizontalRule?: undefined;
51
+ } | {
52
+ isAlignLeft: boolean;
53
+ canAlignLeft: boolean;
54
+ isAlignCenter: boolean;
55
+ canAlignCenter: boolean;
56
+ isAlignRight: boolean;
57
+ canAlignRight: boolean;
58
+ isAlignJustify: boolean;
59
+ canAlignJustify: boolean;
60
+ isBold: boolean;
61
+ canBold: boolean;
62
+ isItalic: boolean;
63
+ canItalic: boolean;
64
+ isUnderline: boolean;
65
+ canUnderline: boolean;
66
+ isStrike: boolean;
67
+ canStrike: boolean;
68
+ isInlineCode: boolean;
69
+ canInlineCode: boolean;
70
+ isBulletList: boolean;
71
+ canBulletList: boolean;
72
+ isOrderedList: boolean;
73
+ canOrderedList: boolean;
74
+ isCodeBlock: boolean;
75
+ canCodeBlock: boolean;
76
+ isBlockquote: boolean;
77
+ canBlockquote: boolean;
78
+ canHorizontalRule: boolean;
79
+ };
80
+
81
+ type RichTextSelector = (ctx: EditorStateSnapshot, readOnly: boolean) => Partial<Record<string, boolean>>;
82
+ type DefaultEditorState = ReturnType<typeof defaultEditorState>;
83
+ type EditorState<Selector extends RichTextSelector = RichTextSelector> = DefaultEditorState & ReturnType<Selector> & Record<string, boolean | undefined>;
84
+
85
+ interface EditorRichTextOptions {
86
+ /**
87
+ * If set to false, the blockquote extension will not be registered
88
+ * @example blockquote: false
89
+ */
90
+ blockquote: Partial<BlockquoteOptions> | false;
91
+ /**
92
+ * If set to false, the bold extension will not be registered
93
+ * @example bold: false
94
+ */
95
+ bold: Partial<BoldOptions> | false;
96
+ /**
97
+ * If set to false, the bulletList extension will not be registered
98
+ * @example bulletList: false
99
+ */
100
+ bulletList: Partial<BulletListOptions> | false;
101
+ /**
102
+ * If set to false, the code extension will not be registered
103
+ * @example code: false
104
+ */
105
+ code: Partial<CodeOptions> | false;
106
+ /**
107
+ * If set to false, the codeBlock extension will not be registered
108
+ * @example codeBlock: false
109
+ */
110
+ codeBlock: Partial<CodeBlockOptions> | false;
111
+ /**
112
+ * If set to false, the document extension will not be registered
113
+ * @example document: false
114
+ */
115
+ document: false;
116
+ /**
117
+ * If set to false, the hardBreak extension will not be registered
118
+ * @example hardBreak: false
119
+ */
120
+ hardBreak: Partial<HardBreakOptions> | false;
121
+ /**
122
+ * If set to false, the heading extension will not be registered
123
+ * @example heading: false
124
+ */
125
+ heading: Partial<HeadingOptions> | false;
126
+ /**
127
+ * If set to false, the horizontalRule extension will not be registered
128
+ * @example horizontalRule: false
129
+ */
130
+ horizontalRule: Partial<HorizontalRuleOptions> | false;
131
+ /**
132
+ * If set to false, the italic extension will not be registered
133
+ * @example italic: false
134
+ */
135
+ italic: Partial<ItalicOptions> | false;
136
+ /**
137
+ * If set to false, the listItem extension will not be registered
138
+ * @example listItem: false
139
+ */
140
+ listItem: Partial<ListItemOptions> | false;
141
+ /**
142
+ * If set to false, the listItemKeymap extension will not be registered
143
+ * @example listKeymap: false
144
+ */
145
+ listKeymap: Partial<ListKeymapOptions> | false;
146
+ /**
147
+ * If set to false, the link extension will not be registered
148
+ * @example link: false
149
+ */
150
+ link: Partial<LinkOptions> | false;
151
+ /**
152
+ * If set to false, the orderedList extension will not be registered
153
+ * @example orderedList: false
154
+ */
155
+ orderedList: Partial<OrderedListOptions> | false;
156
+ /**
157
+ * If set to false, the paragraph extension will not be registered
158
+ * @example paragraph: false
159
+ */
160
+ paragraph: Partial<ParagraphOptions> | false;
161
+ /**
162
+ * If set to false, the strike extension will not be registered
163
+ * @example strike: false
164
+ */
165
+ strike: Partial<StrikeOptions> | false;
166
+ /**
167
+ * If set to false, the text extension will not be registered
168
+ * @example text: false
169
+ */
170
+ text: false;
171
+ /**
172
+ * If set to false, the textAlign extension will not be registered
173
+ * @example text: false
174
+ */
175
+ textAlign: Partial<TextAlignOptions> | false;
176
+ /**
177
+ * If set to false, the underline extension will not be registered
178
+ * @example underline: false
179
+ */
180
+ underline: Partial<UnderlineOptions> | false;
181
+ }
182
+
183
+ type FieldOption = {
184
+ label: string;
185
+ value: string | number | boolean | undefined | null | object;
186
+ };
187
+ type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
188
+ interface BaseField {
189
+ label?: string;
190
+ labelIcon?: ReactElement;
191
+ metadata?: FieldMetadata;
192
+ visible?: boolean;
193
+ }
194
+ interface TextField extends BaseField {
195
+ type: "text";
196
+ placeholder?: string;
197
+ contentEditable?: boolean;
198
+ }
199
+ interface NumberField extends BaseField {
200
+ type: "number";
201
+ placeholder?: string;
202
+ min?: number;
203
+ max?: number;
204
+ step?: number;
205
+ }
206
+ interface TextareaField extends BaseField {
207
+ type: "textarea";
208
+ placeholder?: string;
209
+ contentEditable?: boolean;
210
+ }
211
+ interface SelectField extends BaseField {
212
+ type: "select";
213
+ options: FieldOptions;
214
+ }
215
+ interface RadioField extends BaseField {
216
+ type: "radio";
217
+ options: FieldOptions;
218
+ }
219
+ interface RichtextField<UserSelector extends RichTextSelector = RichTextSelector> extends BaseField {
220
+ type: "richtext";
221
+ contentEditable?: boolean;
222
+ initialHeight?: CSSProperties["height"];
223
+ options?: Partial<EditorRichTextOptions>;
224
+ renderMenu?: (props: {
225
+ children: ReactNode;
226
+ editor: Editor | null;
227
+ editorState: EditorState<UserSelector> | null;
228
+ readOnly: boolean;
229
+ }) => ReactNode;
230
+ renderInlineMenu?: (props: {
231
+ children: ReactNode;
232
+ editor: Editor | null;
233
+ editorState: EditorState<UserSelector> | null;
234
+ readOnly: boolean;
235
+ }) => ReactNode;
236
+ tiptap?: {
237
+ selector?: UserSelector;
238
+ extensions?: Extensions;
239
+ };
240
+ }
241
+ interface ArrayField<Props extends {
242
+ [key: string]: any;
243
+ }[] = {
244
+ [key: string]: any;
245
+ }[], UserField extends {} = {}> extends BaseField {
246
+ type: "array";
247
+ arrayFields: {
248
+ [SubPropName in keyof Props[0]]: UserField extends {
249
+ type: PropertyKey;
250
+ } ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
251
+ };
252
+ defaultItemProps?: Props[0] | ((index: number) => Props[0]);
253
+ getItemSummary?: (item: Props[0], index?: number) => ReactNode;
254
+ max?: number;
255
+ min?: number;
256
+ }
257
+ interface ObjectField<Props extends any = {
258
+ [key: string]: any;
259
+ }, UserField extends {} = {}> extends BaseField {
260
+ type: "object";
261
+ objectFields: {
262
+ [SubPropName in keyof Props]: UserField extends {
263
+ type: PropertyKey;
264
+ } ? Field<Props[SubPropName]> | UserField : Field<Props[SubPropName]>;
265
+ };
266
+ }
267
+ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
268
+ name: string;
269
+ fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
270
+ mapProp?: (value: TableShape) => PropShape;
271
+ };
272
+ type NotUndefined<T> = T extends undefined ? never : T;
273
+ type ExternalFieldWithAdaptor<Props extends any = {
274
+ [key: string]: any;
275
+ }> = BaseField & {
276
+ type: "external";
277
+ placeholder?: string;
278
+ adaptor: Adaptor<any, any, Props>;
279
+ adaptorParams?: object;
280
+ getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
281
+ };
282
+ type CacheOpts = {
283
+ enabled?: boolean;
284
+ };
285
+ interface ExternalField<Props extends any = {
286
+ [key: string]: any;
287
+ }> extends BaseField {
288
+ type: "external";
289
+ cache?: CacheOpts;
290
+ placeholder?: string;
291
+ fetchList: (params: {
292
+ query: string;
293
+ filters: Record<string, any>;
294
+ }) => Promise<any[] | null>;
295
+ mapProp?: (value: any) => Props;
296
+ mapRow?: (value: any) => Record<string, string | number | ReactElement>;
297
+ getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
298
+ showSearch?: boolean;
299
+ renderFooter?: (props: {
300
+ items: any[];
301
+ }) => ReactElement;
302
+ initialQuery?: string;
303
+ filterFields?: Record<string, Field>;
304
+ initialFilters?: Record<string, any>;
305
+ }
306
+ type CustomFieldRender<Value extends any> = (props: {
307
+ field: CustomField<Value>;
308
+ name: string;
309
+ id: string;
310
+ value: Value;
311
+ onChange: (value: Value, uiState?: Partial<UiState>) => void;
312
+ readOnly?: boolean;
313
+ }) => ReactElement;
314
+ interface CustomField<Value extends any> extends BaseField {
315
+ type: "custom";
316
+ render: CustomFieldRender<Value>;
317
+ contentEditable?: boolean;
318
+ key?: string;
319
+ }
320
+ interface SlotField extends BaseField {
321
+ type: "slot";
322
+ allow?: string[];
323
+ disallow?: string[];
324
+ }
325
+ type Field<ValueType = any, UserField extends {} = {}> = TextField | RichtextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
326
+ [key: string]: any;
327
+ }[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
328
+ type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
329
+ [PropName in keyof Omit<ComponentProps, "editMode">]: UserField extends {
330
+ type: PropertyKey;
331
+ } ? Field<ComponentProps[PropName], UserField> | UserField : Field<ComponentProps[PropName]>;
332
+ };
333
+ type FieldProps<F = Field<any>, ValueType = any> = {
334
+ field: F;
335
+ value: ValueType;
336
+ id?: string;
337
+ onChange: (value: ValueType, uiState?: Partial<UiState>) => void;
338
+ readOnly?: boolean;
339
+ };
340
+
341
+ type DropZoneProps = {
342
+ zone: string;
343
+ allow?: string[];
344
+ disallow?: string[];
345
+ style?: CSSProperties;
346
+ minEmptyHeight?: CSSProperties["minHeight"] | number;
347
+ className?: string;
348
+ collisionAxis?: DragAxis;
349
+ as?: ElementType;
350
+ ref?: Ref<any>;
351
+ };
352
+
353
+ type EditorContext = {
354
+ renderDropZone: (props: DropZoneProps) => React.ReactNode;
355
+ metadata: Metadata;
356
+ isEditing: boolean;
357
+ dragRef: ((element: Element | null) => void) | null;
358
+ };
359
+ type DefaultRootFieldProps = {
360
+ title?: string;
361
+ };
362
+ type DefaultRootRenderProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = WithEditorProps<WithChildren<Props>>;
363
+ type DefaultRootProps = DefaultRootRenderProps;
364
+ type DefaultComponentProps = {
365
+ [key: string]: any;
366
+ };
367
+
368
+ type WithId<Props> = Props & {
369
+ id: string;
370
+ };
371
+ type WithEditorProps<Props> = Props & {
372
+ editor: EditorContext;
373
+ editMode?: boolean;
374
+ };
375
+ type AsFieldProps<Props> = Omit<Props, "children" | "editor" | "editMode">;
376
+ type WithChildren<Props> = Props & {
377
+ children: ReactNode;
378
+ };
379
+ type UserGenerics<UserConfig extends Config = Config, UserParams extends ExtractConfigParams<UserConfig> = ExtractConfigParams<UserConfig>, UserData extends Data<UserParams["props"], UserParams["rootProps"]> | Data = Data<UserParams["props"], UserParams["rootProps"]>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserPublicAppState extends AppState<UserData> = AppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
380
+ UserConfig: UserConfig;
381
+ UserParams: UserParams;
382
+ UserProps: UserParams["props"];
383
+ UserRootProps: UserParams["rootProps"] & DefaultRootFieldProps;
384
+ UserData: UserData;
385
+ UserAppState: UserAppState;
386
+ UserPublicAppState: UserPublicAppState;
387
+ UserComponentData: UserComponentData;
388
+ UserField: UserParams["field"];
389
+ };
390
+ type ExtractField<UserField extends {
391
+ type: PropertyKey;
392
+ }, T extends UserField["type"]> = Extract<UserField, {
393
+ type: T;
394
+ }>;
395
+
396
+ type SlotComponent = (props?: Omit<DropZoneProps, "zone">) => ReactNode;
397
+ type EditorComponent<Props> = (props: WithId<WithEditorProps<{
398
+ [K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
399
+ }>>) => JSX.Element;
400
+ type ResolveDataTrigger = "insert" | "replace" | "load" | "force" | "move";
401
+ type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
402
+ props?: Partial<Props>;
403
+ };
404
+ interface ComponentConfigExtensions {
405
+ }
406
+ type ComponentConfigInternal<RenderProps extends DefaultComponentProps, FieldProps extends DefaultComponentProps, DataShape = Omit<ComponentData<FieldProps>, "type">, // NB this doesn't include AllProps, so types will not contain deep slot types. To fix, we require a breaking change.
407
+ UserField extends BaseField = {}> = {
408
+ render: EditorComponent<RenderProps>;
409
+ label?: string;
410
+ icon?: ReactNode;
411
+ category?: string;
412
+ defaultProps?: FieldProps;
413
+ fields?: Fields<FieldProps, UserField>;
414
+ permissions?: Partial<Permissions>;
415
+ inline?: boolean;
416
+ /**
417
+ * When true, every instance of this component type renders from the shared
418
+ * `globalData[type].props` instead of its own props. The `children` slot is
419
+ * always extrinsic (supplied by the instance / parent), matching React
420
+ * conventions and enabling the "AppShell wraps a page" pattern. Marking a
421
+ * component global is a developer decision that has data-migration
422
+ * implications; it is not editable from the UI.
423
+ */
424
+ global?: boolean;
425
+ resolveFields?: (data: DataShape, params: {
426
+ changed: Partial<Record<keyof FieldProps, boolean> & {
427
+ id: string;
428
+ }>;
429
+ fields: Fields<FieldProps>;
430
+ lastFields: Fields<FieldProps>;
431
+ lastData: DataShape | null;
432
+ metadata: ComponentMetadata;
433
+ appState: AppState;
434
+ parent: ComponentData | null;
435
+ }) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
436
+ resolveData?: (data: DataShape, params: {
437
+ changed: Partial<Record<keyof FieldProps, boolean> & {
438
+ id: string;
439
+ }>;
440
+ lastData: DataShape | null;
441
+ metadata: ComponentMetadata;
442
+ trigger: ResolveDataTrigger;
443
+ parent: ComponentData | null;
444
+ }) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
445
+ resolvePermissions?: (data: DataShape, params: {
446
+ changed: Partial<Record<keyof FieldProps, boolean> & {
447
+ id: string;
448
+ }>;
449
+ lastPermissions: Partial<Permissions>;
450
+ permissions: Partial<Permissions>;
451
+ appState: AppState;
452
+ lastData: DataShape | null;
453
+ parent: ComponentData | null;
454
+ }) => Promise<Partial<Permissions>> | Partial<Permissions>;
455
+ metadata?: ComponentMetadata;
456
+ } & ComponentConfigExtensions;
457
+ type ComponentConfig<RenderPropsOrParams extends LeftOrExactRight<RenderPropsOrParams, DefaultComponentProps, ComponentConfigParams> = DefaultComponentProps, FieldProps extends DefaultComponentProps = RenderPropsOrParams extends {
458
+ props: any;
459
+ } ? RenderPropsOrParams["props"] : RenderPropsOrParams, DataShape = Omit<ComponentData<FieldProps>, "type">> = RenderPropsOrParams extends ComponentConfigParams<infer ParamsRenderProps, never> ? ComponentConfigInternal<ParamsRenderProps, FieldProps, DataShape, {}> : RenderPropsOrParams extends ComponentConfigParams<infer ParamsRenderProps, infer ParamsFields> ? ComponentConfigInternal<ParamsRenderProps, FieldProps, DataShape, ParamsFields[keyof ParamsFields] & BaseField> : ComponentConfigInternal<RenderPropsOrParams, FieldProps, DataShape>;
460
+ type RootConfigInternal<RootProps extends DefaultComponentProps = DefaultComponentProps, UserField extends BaseField = {}> = Partial<ComponentConfigInternal<WithChildren<RootProps>, AsFieldProps<RootProps>, RootData<AsFieldProps<RootProps>>, UserField>>;
461
+ type RootConfig<RootPropsOrParams extends LeftOrExactRight<RootPropsOrParams, DefaultComponentProps, ComponentConfigParams> = DefaultComponentProps> = RootPropsOrParams extends ComponentConfigParams<infer Props, never> ? Partial<RootConfigInternal<WithChildren<Props>, {}>> : RootPropsOrParams extends ComponentConfigParams<infer Props, infer UserFields> ? Partial<RootConfigInternal<WithChildren<Props>, UserFields[keyof UserFields] & BaseField>> : Partial<RootConfigInternal<WithChildren<RootPropsOrParams>>>;
462
+ type Category<ComponentName> = {
463
+ components?: ComponentName[];
464
+ title?: string;
465
+ visible?: boolean;
466
+ defaultExpanded?: boolean;
467
+ };
468
+ type ConfigInternal<Props extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultComponentProps, CategoryName extends string = string, UserField extends {} = {}> = {
469
+ categories?: Record<CategoryName, Category<keyof Props>> & {
470
+ other?: Category<keyof Props>;
471
+ };
472
+ components: {
473
+ [ComponentName in keyof Props]: Omit<ComponentConfigInternal<Props[ComponentName], Props[ComponentName], Omit<ComponentData<Props[ComponentName]>, "type">, UserField>, "type">;
474
+ };
475
+ root?: RootConfigInternal<RootProps, UserField>;
476
+ };
477
+ type DefaultComponents = Record<string, any>;
478
+ type Config<PropsOrParams extends LeftOrExactRight<PropsOrParams, DefaultComponents, ConfigParams> = DefaultComponents | ConfigParams, RootProps extends DefaultComponentProps = any, CategoryName extends string = string> = PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, never> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number]> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, infer ParamFields> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], ParamFields[keyof ParamFields] & BaseField> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, any> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], {}> : ConfigInternal<PropsOrParams, RootProps, CategoryName>;
479
+ type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends ConfigInternal<infer PropsOrParams, infer RootProps, infer CategoryName, infer UserField> ? {
480
+ props: PropsOrParams;
481
+ rootProps: RootProps & DefaultRootFieldProps;
482
+ categoryNames: CategoryName;
483
+ field: UserField extends {
484
+ type: string;
485
+ } ? UserField : Field;
486
+ } : never;
487
+ type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
488
+ components?: Components;
489
+ root?: RootProps;
490
+ categories?: CategoryNames;
491
+ fields?: AssertHasValue<UserFields>;
492
+ };
493
+ type ComponentConfigParams<Props extends DefaultComponentProps = DefaultComponentProps, UserFields extends FieldsExtension = never> = {
494
+ props: Props;
495
+ fields?: AssertHasValue<UserFields>;
496
+ };
497
+
498
+ type BaseData<Props extends {
499
+ [key: string]: any;
500
+ } = {
501
+ [key: string]: any;
502
+ }> = {
503
+ readOnly?: Partial<Record<keyof Props, boolean>>;
504
+ };
505
+ type RootDataWithProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = BaseData<Props> & {
506
+ props: Props;
507
+ };
508
+ type RootDataWithoutProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = Props;
509
+ type RootData<Props extends DefaultComponentProps = DefaultRootFieldProps> = Partial<RootDataWithProps<AsFieldProps<Props>>> & Partial<RootDataWithoutProps<Props>>;
510
+ type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps, Name = string, Components extends Record<string, DefaultComponentProps> = Record<string, DefaultComponentProps>> = {
511
+ type: Name;
512
+ props: WithDeepSlots<WithId<Props>, Content<Components>>;
513
+ } & BaseData<Props>;
514
+ type ComponentDataOptionalId<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
515
+ type: Name;
516
+ props: Props & {
517
+ id?: string;
518
+ };
519
+ } & BaseData<Props>;
520
+ type MappedItem = ComponentData;
521
+ type ComponentDataMap<Components extends DefaultComponents = DefaultComponents> = {
522
+ [K in keyof Components]: ComponentData<Components[K], K extends string ? K : never, Components>;
523
+ }[keyof Components];
524
+ type Content<PropsMap extends {
525
+ [key: string]: DefaultComponentProps;
526
+ } = {
527
+ [key: string]: DefaultComponentProps;
528
+ }> = ComponentDataMap<PropsMap>[];
529
+ type Data<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = {
530
+ root: WithDeepSlots<RootData<RootProps>, Content<Components>>;
531
+ content: Content<Components>;
532
+ zones?: Record<string, Content<Components>>;
533
+ };
534
+ type Metadata = {
535
+ [key: string]: any;
536
+ };
537
+ interface EditorMetadata extends Metadata {
538
+ }
539
+ interface ComponentMetadata extends EditorMetadata {
540
+ }
541
+ interface FieldMetadata extends Metadata {
542
+ }
543
+
544
+ type ItemWithId = {
545
+ _arrayId: string;
546
+ _originalIndex: number;
547
+ _currentIndex: number;
548
+ };
549
+ type ArrayState = {
550
+ items: ItemWithId[];
551
+ openId: string;
552
+ };
553
+ type UiState = {
554
+ leftSideBarVisible: boolean;
555
+ rightSideBarVisible: boolean;
556
+ leftSideBarWidth?: number | null;
557
+ rightSideBarWidth?: number | null;
558
+ mobilePanelExpanded?: boolean;
559
+ itemSelector: ItemSelector | null;
560
+ arrayState: Record<string, ArrayState | undefined>;
561
+ previewMode: "interactive" | "edit";
562
+ componentList: Record<string, {
563
+ components?: string[];
564
+ title?: string;
565
+ visible?: boolean;
566
+ expanded?: boolean;
567
+ }>;
568
+ isDragging: boolean;
569
+ viewports: {
570
+ current: {
571
+ width: number | "100%";
572
+ height: number | "auto";
573
+ };
574
+ controlsVisible: boolean;
575
+ options: Viewport[];
576
+ };
577
+ field: {
578
+ focus?: string | null;
579
+ metadata?: Record<string, any>;
580
+ };
581
+ plugin: {
582
+ current: string | null;
583
+ };
584
+ };
585
+ type AppState<UserData extends Data = Data> = {
586
+ data: UserData;
587
+ ui: UiState;
588
+ };
589
+
590
+ type ZoneType = "root" | "dropzone" | "slot";
591
+ type EditorNodeData = {
592
+ data: ComponentData;
593
+ flatData: ComponentData;
594
+ parentId: string | null;
595
+ zone: string;
596
+ path: string[];
597
+ };
598
+ type EditorZoneData = {
599
+ contentIds: string[];
600
+ type: ZoneType;
601
+ };
602
+ type NodeIndex = Record<string, EditorNodeData>;
603
+ type ZoneIndex = Record<string, EditorZoneData>;
604
+ type PrivateAppState<UserData extends Data = Data> = AppState<UserData> & {
605
+ indexes: {
606
+ nodes: NodeIndex;
607
+ zones: ZoneIndex;
608
+ };
609
+ };
610
+ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined;
611
+ /**
612
+ * Recursively walk T and replace Slots with SlotComponents
613
+ */
614
+ type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
615
+ [K in keyof T]: WithDeepSlots<T[K], SlotType>;
616
+ } : T;
617
+ type FieldsExtension = {
618
+ [Type in string]: {
619
+ type: Type;
620
+ };
621
+ };
622
+ type Exact<T, Target> = Record<Exclude<keyof T, keyof Target>, never>;
623
+ type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<Union, Right> : Left) | (Right & Exact<Union, Right>);
624
+ type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
625
+ never
626
+ ] ? False : True;
627
+ type RenderFunc<Props extends {
628
+ [key: string]: any;
629
+ } = {
630
+ children: ReactNode;
631
+ }> = (props: Props) => ReactElement;
632
+ type PluginInternal = Plugin & {
633
+ mobileOnly?: boolean;
634
+ desktopOnly?: boolean;
635
+ };
636
+
637
+ type MapFnParams<ThisField = Field> = {
638
+ value: any;
639
+ parentId: string;
640
+ propName: string;
641
+ field: ThisField;
642
+ propPath: string;
643
+ };
644
+
645
+ type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
646
+ isReadOnly: boolean;
647
+ componentId: string;
648
+ };
649
+ type FieldTransformFn<T> = (params: FieldTransformFnParams<T>) => any;
650
+ type FieldTransforms<UserConfig extends Config = Config<{
651
+ fields: {};
652
+ }>, // Setting fields: {} helps TS choose default field types
653
+ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
654
+ type: string;
655
+ } = Field | G["UserField"]> = Partial<{
656
+ [Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
657
+ }>;
658
+
659
+ declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "editor", "preview"];
660
+ type OverrideKey = (typeof overrideKeys)[number];
661
+ type OverridesGeneric<Shape extends {
662
+ [key in OverrideKey]: any;
663
+ }> = Shape;
664
+ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
665
+ fieldTypes: Partial<FieldRenderFunctions<UserConfig>>;
666
+ header: RenderFunc<{
667
+ actions: ReactNode;
668
+ children: ReactNode;
669
+ }>;
670
+ actionBar: RenderFunc<{
671
+ label?: string;
672
+ children: ReactNode;
673
+ parentAction: ReactNode;
674
+ }>;
675
+ headerActions: RenderFunc<{
676
+ children: ReactNode;
677
+ }>;
678
+ preview: RenderFunc;
679
+ fields: RenderFunc<{
680
+ children: ReactNode;
681
+ isLoading: boolean;
682
+ itemSelector?: ItemSelector | null;
683
+ }>;
684
+ fieldLabel: RenderFunc<{
685
+ children?: ReactNode;
686
+ icon?: ReactNode;
687
+ label: string;
688
+ el?: "label" | "div";
689
+ readOnly?: boolean;
690
+ className?: string;
691
+ }>;
692
+ components: RenderFunc;
693
+ componentItem: RenderFunc<{
694
+ children: ReactNode;
695
+ name: string;
696
+ }>;
697
+ drawer: RenderFunc;
698
+ drawerItem: RenderFunc<{
699
+ children: ReactNode;
700
+ name: string;
701
+ }>;
702
+ iframe: RenderFunc<{
703
+ children: ReactNode;
704
+ document?: Document;
705
+ }>;
706
+ outline: RenderFunc;
707
+ componentOverlay: RenderFunc<{
708
+ children: ReactNode;
709
+ hover: boolean;
710
+ isSelected: boolean;
711
+ componentId: string;
712
+ componentType: string;
713
+ }>;
714
+ editor: RenderFunc;
715
+ }>;
716
+ type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
717
+ type: string;
718
+ } = Field | G["UserField"]> = Omit<{
719
+ [Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
720
+ children: ReactNode;
721
+ name: string;
722
+ }>;
723
+ }, "custom">;
724
+
725
+ type Direction = "left" | "right" | "up" | "down" | null;
726
+ type DragAxis = "dynamic" | "y" | "x";
727
+
728
+ type iconTypes = "Smartphone" | "Monitor" | "Tablet";
729
+ type Viewport = {
730
+ width: number | "100%";
731
+ height?: number | "auto";
732
+ label?: string;
733
+ icon?: iconTypes | ReactNode;
734
+ };
735
+ type Viewports = Viewport[];
736
+
737
+ type Permissions = {
738
+ drag: boolean;
739
+ duplicate: boolean;
740
+ delete: boolean;
741
+ edit: boolean;
742
+ insert: boolean;
743
+ } & Record<string, boolean>;
744
+ type IframeConfig = {
745
+ enabled?: boolean;
746
+ waitForStyles?: boolean;
747
+ };
748
+ type OnAction<UserData extends Data = Data> = (action: EditorAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
749
+ type Plugin<UserConfig extends Config = Config> = {
750
+ name?: string;
751
+ label?: string;
752
+ icon?: ReactNode;
753
+ render?: () => ReactElement;
754
+ overrides?: Partial<Overrides<UserConfig>>;
755
+ fieldTransforms?: FieldTransforms<UserConfig>;
756
+ mobilePanelHeight?: "toggle" | "min-content";
757
+ };
758
+ type History<D = any> = {
759
+ state: D;
760
+ id?: string;
761
+ };
762
+ type InitialHistoryAppend<AS = Partial<AppState>> = {
763
+ histories: History<AS>[];
764
+ index?: number;
765
+ appendData?: true;
766
+ };
767
+ type InitialHistoryNoAppend<AS = Partial<AppState>> = {
768
+ histories: [History<AS>, ...History<AS>[]];
769
+ index?: number;
770
+ appendData?: false;
771
+ };
772
+ type InitialHistory<AS = Partial<AppState>> = InitialHistoryAppend<AS> | InitialHistoryNoAppend<AS>;
773
+ type Slot<Props extends {
774
+ [key: string]: DefaultComponentProps;
775
+ } = {
776
+ [key: string]: DefaultComponentProps;
777
+ }> = {
778
+ [K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
779
+ }[keyof Props][];
780
+ type WithSlotProps<Target extends Record<string, any>, Components extends DefaultComponents = DefaultComponents, SlotType extends Content<Components> = Content<Components>> = WithDeepSlots<Target, SlotType>;
781
+ type RichText = string | ReactNode;
782
+
783
+ type InsertAction = {
784
+ type: "insert";
785
+ componentType: string;
786
+ destinationIndex: number;
787
+ destinationZone: string;
788
+ id?: string;
789
+ };
790
+ type DuplicateAction = {
791
+ type: "duplicate";
792
+ sourceIndex: number;
793
+ sourceZone: string;
794
+ };
795
+ type ReplaceAction<UserData extends Data = Data> = {
796
+ type: "replace";
797
+ destinationIndex: number;
798
+ destinationZone: string;
799
+ data: ComponentData;
800
+ ui?: Partial<AppState<UserData>["ui"]>;
801
+ };
802
+ type ReplaceRootAction<UserData extends Data = Data> = {
803
+ type: "replaceRoot";
804
+ root: RootData;
805
+ ui?: Partial<AppState<UserData>["ui"]>;
806
+ };
807
+ type ReorderAction = {
808
+ type: "reorder";
809
+ sourceIndex: number;
810
+ destinationIndex: number;
811
+ destinationZone: string;
812
+ };
813
+ type MoveAction = {
814
+ type: "move";
815
+ sourceIndex: number;
816
+ sourceZone: string;
817
+ destinationIndex: number;
818
+ destinationZone: string;
819
+ };
820
+ type RemoveAction = {
821
+ type: "remove";
822
+ index: number;
823
+ zone: string;
824
+ };
825
+ type SetUiAction = {
826
+ type: "setUi";
827
+ ui: Partial<UiState> | ((previous: UiState) => Partial<UiState>);
828
+ };
829
+ type SetDataAction = {
830
+ type: "setData";
831
+ data: Partial<Data> | ((previous: Data) => Partial<Data>);
832
+ };
833
+ type SetAction<UserData extends Data = Data> = {
834
+ type: "set";
835
+ state: Partial<PrivateAppState<UserData>> | ((previous: PrivateAppState<UserData>) => Partial<PrivateAppState<UserData>>);
836
+ };
837
+ type RegisterZoneAction = {
838
+ type: "registerZone";
839
+ zone: string;
840
+ };
841
+ type UnregisterZoneAction = {
842
+ type: "unregisterZone";
843
+ zone: string;
844
+ };
845
+ type EditorAction = {
846
+ recordHistory?: boolean;
847
+ } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
848
+
849
+ export { type EditorComponent as $, type AppState as A, type BaseData as B, type Config as C, type Data as D, type EditorAction as E, type Fields as F, type ComponentConfigExtensions as G, type History as H, type IframeConfig as I, type ComponentConfigParams as J, type ComponentDataMap as K, type ComponentDataOptionalId as L, type Metadata as M, type ComponentMetadata as N, type OnAction as O, type PrivateAppState as P, type ConfigParams as Q, type RootData as R, type CustomField as S, type CustomFieldRender as T, type UserGenerics as U, type Viewports as V, type WithId as W, type DefaultRootProps as X, type DefaultRootRenderProps as Y, type Direction as Z, type DragAxis as _, type Content as a, type EditorContext as a0, type EditorMetadata as a1, type ExternalField as a2, type ExternalFieldWithAdaptor as a3, type ExtractConfigParams as a4, type ExtractField as a5, type FieldMetadata as a6, type FieldRenderFunctions as a7, type FieldTransformFn as a8, type FieldTransformFnParams as a9, type ItemWithId as aa, type MappedItem as ab, type NumberField as ac, type ObjectField as ad, type OverrideKey as ae, type RadioField as af, type RichText as ag, type RootConfig as ah, type RootDataWithoutProps as ai, type SelectField as aj, type Slot as ak, type SlotComponent as al, type SlotField as am, type TextField as an, type TextareaField as ao, type Viewport as ap, type WithChildren as aq, type WithEditorProps as ar, type WithSlotProps as as, overrideKeys as at, type ComponentData as b, type DefaultComponents as c, type DefaultComponentProps as d, type DefaultRootFieldProps as e, type Permissions as f, type RootDataWithProps as g, type ResolveDataTrigger as h, type Plugin as i, type Overrides as j, type UiState as k, type ComponentConfig as l, type FieldTransforms as m, type RichtextField as n, type Field as o, type FieldProps as p, type DropZoneProps as q, type InitialHistory as r, type ItemSelector as s, type PluginInternal as t, type Adaptor as u, type ArrayField as v, type ArrayState as w, type AsFieldProps as x, type BaseField as y, type CacheOpts as z };