@measured/puck 0.21.0-canary.dfecd012 → 0.21.0-canary.e1cbf777

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/dist/Editor-CYTATURR.mjs +204 -0
  2. package/dist/Editor-F2LSS6SE.css +403 -0
  3. package/dist/Render-OFE6QLI2.mjs +55 -0
  4. package/dist/Render-QEMDIDQC.css +101 -0
  5. package/dist/{walk-tree-BqwnaCVe.d.mts → actions-tsxxcX1z.d.mts} +229 -40
  6. package/dist/{walk-tree-BqwnaCVe.d.ts → actions-tsxxcX1z.d.ts} +229 -40
  7. package/dist/chunk-72SA22GI.mjs +134 -0
  8. package/dist/{chunk-5MWIJTZQ.mjs → chunk-BFXJG3MG.mjs} +6858 -7958
  9. package/dist/chunk-CSSRLPHM.mjs +11 -0
  10. package/dist/chunk-M4QBB3JM.mjs +111 -0
  11. package/dist/chunk-M6W7YEVX.mjs +95 -0
  12. package/dist/chunk-MLTVJA2A.mjs +63 -0
  13. package/dist/chunk-MVJKIFF6.mjs +419 -0
  14. package/dist/chunk-NLUHDYVR.mjs +416 -0
  15. package/dist/chunk-NOJQSXRU.mjs +33 -0
  16. package/dist/chunk-QBGM4ELA.mjs +528 -0
  17. package/dist/chunk-UNQOU2OI.mjs +53 -0
  18. package/dist/chunk-UUOBSXZR.mjs +1807 -0
  19. package/dist/chunk-V5I7CVLT.mjs +103 -0
  20. package/dist/chunk-V7333LON.mjs +708 -0
  21. package/dist/chunk-Y2EFNT5P.mjs +108 -0
  22. package/dist/full-2GJTAAZE.css +301 -0
  23. package/dist/full-GZ4L3XCF.mjs +93 -0
  24. package/dist/index-Ca6V6NQD.d.ts +118 -0
  25. package/dist/index-mQvUCH3C.d.mts +118 -0
  26. package/dist/index.css +1031 -385
  27. package/dist/index.d.mts +116 -114
  28. package/dist/index.d.ts +116 -114
  29. package/dist/index.js +12035 -7997
  30. package/dist/index.mjs +34 -12
  31. package/dist/internal.d.mts +27 -0
  32. package/dist/internal.d.ts +27 -0
  33. package/dist/internal.js +908 -0
  34. package/dist/internal.mjs +13 -0
  35. package/dist/loaded-2MNXXPJP.mjs +57 -0
  36. package/dist/loaded-6QT4HD2O.mjs +57 -0
  37. package/dist/loaded-RVWBFK7L.css +87 -0
  38. package/dist/loaded-ZVPBQVNE.mjs +60 -0
  39. package/dist/no-external.css +1120 -470
  40. package/dist/no-external.d.mts +19 -2
  41. package/dist/no-external.d.ts +19 -2
  42. package/dist/no-external.js +12038 -7997
  43. package/dist/no-external.mjs +36 -9
  44. package/dist/rsc.css +101 -0
  45. package/dist/rsc.d.mts +17 -2
  46. package/dist/rsc.d.ts +17 -2
  47. package/dist/rsc.js +411 -23
  48. package/dist/rsc.mjs +18 -9
  49. package/dist/walk-tree-Bh85NMeo.d.ts +29 -0
  50. package/dist/walk-tree-CDA3K5S3.d.mts +29 -0
  51. package/package.json +31 -4
  52. package/dist/chunk-JA7SEUEH.mjs +0 -966
@@ -1,10 +1,185 @@
1
- import { ReactElement, CSSProperties, ElementType, ReactNode, JSX } from 'react';
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';
2
17
 
3
18
  type ItemSelector = {
4
19
  index: number;
5
20
  zone?: string;
6
21
  };
7
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 PuckRichTextOptions {
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
+
8
183
  type FieldOption = {
9
184
  label: string;
10
185
  value: string | number | boolean | undefined | null | object;
@@ -41,6 +216,28 @@ interface RadioField extends BaseField {
41
216
  type: "radio";
42
217
  options: FieldOptions;
43
218
  }
219
+ interface RichtextField<UserSelector extends RichTextSelector = RichTextSelector> extends BaseField {
220
+ type: "richtext";
221
+ contentEditable?: boolean;
222
+ initialHeight?: CSSProperties["height"];
223
+ options?: Partial<PuckRichTextOptions>;
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
+ }
44
241
  interface ArrayField<Props extends {
45
242
  [key: string]: any;
46
243
  }[] = {
@@ -53,7 +250,7 @@ interface ArrayField<Props extends {
53
250
  } ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
54
251
  };
55
252
  defaultItemProps?: Props[0] | ((index: number) => Props[0]);
56
- getItemSummary?: (item: Props[0], index?: number) => string;
253
+ getItemSummary?: (item: Props[0], index?: number) => ReactNode;
57
254
  max?: number;
58
255
  min?: number;
59
256
  }
@@ -80,7 +277,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
80
277
  placeholder?: string;
81
278
  adaptor: Adaptor<any, any, Props>;
82
279
  adaptorParams?: object;
83
- getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
280
+ getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
84
281
  };
85
282
  type CacheOpts = {
86
283
  enabled?: boolean;
@@ -97,7 +294,7 @@ interface ExternalField<Props extends any = {
97
294
  }) => Promise<any[] | null>;
98
295
  mapProp?: (value: any) => Props;
99
296
  mapRow?: (value: any) => Record<string, string | number | ReactElement>;
100
- getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
297
+ getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
101
298
  showSearch?: boolean;
102
299
  renderFooter?: (props: {
103
300
  items: any[];
@@ -125,7 +322,7 @@ interface SlotField extends BaseField {
125
322
  allow?: string[];
126
323
  disallow?: string[];
127
324
  }
128
- type Field<ValueType = any, UserField extends {} = {}> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
325
+ type Field<ValueType = any, UserField extends {} = {}> = TextField | RichtextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
129
326
  [key: string]: any;
130
327
  }[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
131
328
  type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
@@ -146,10 +343,11 @@ type DropZoneProps = {
146
343
  allow?: string[];
147
344
  disallow?: string[];
148
345
  style?: CSSProperties;
149
- minEmptyHeight?: number;
346
+ minEmptyHeight?: CSSProperties["minHeight"] | number;
150
347
  className?: string;
151
348
  collisionAxis?: DragAxis;
152
349
  as?: ElementType;
350
+ ref?: Ref<any>;
153
351
  };
154
352
 
155
353
  type PuckContext = {
@@ -240,6 +438,7 @@ UserField extends BaseField = {}> = {
240
438
  permissions: Partial<Permissions>;
241
439
  appState: AppState;
242
440
  lastData: DataShape | null;
441
+ parent: ComponentData | null;
243
442
  }) => Promise<Partial<Permissions>> | Partial<Permissions>;
244
443
  metadata?: ComponentMetadata;
245
444
  } & ComponentConfigExtensions;
@@ -333,6 +532,7 @@ interface FieldMetadata extends Metadata {
333
532
  type ItemWithId = {
334
533
  _arrayId: string;
335
534
  _originalIndex: number;
535
+ _currentIndex: number;
336
536
  };
337
537
  type ArrayState = {
338
538
  items: ItemWithId[];
@@ -343,6 +543,7 @@ type UiState = {
343
543
  rightSideBarVisible: boolean;
344
544
  leftSideBarWidth?: number | null;
345
545
  rightSideBarWidth?: number | null;
546
+ mobilePanelExpanded?: boolean;
346
547
  itemSelector: ItemSelector | null;
347
548
  arrayState: Record<string, ArrayState | undefined>;
348
549
  previewMode: "interactive" | "edit";
@@ -355,7 +556,7 @@ type UiState = {
355
556
  isDragging: boolean;
356
557
  viewports: {
357
558
  current: {
358
- width: number;
559
+ width: number | "100%";
359
560
  height: number | "auto";
360
561
  };
361
562
  controlsVisible: boolean;
@@ -363,6 +564,10 @@ type UiState = {
363
564
  };
364
565
  field: {
365
566
  focus?: string | null;
567
+ metadata?: Record<string, any>;
568
+ };
569
+ plugin: {
570
+ current: string | null;
366
571
  };
367
572
  };
368
573
  type AppState<UserData extends Data = Data> = {
@@ -407,6 +612,15 @@ type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<
407
612
  type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
408
613
  never
409
614
  ] ? False : True;
615
+ type RenderFunc<Props extends {
616
+ [key: string]: any;
617
+ } = {
618
+ children: ReactNode;
619
+ }> = (props: Props) => ReactElement;
620
+ type PluginInternal = Plugin & {
621
+ mobileOnly?: boolean;
622
+ desktopOnly?: boolean;
623
+ };
410
624
 
411
625
  type MapFnParams<ThisField = Field> = {
412
626
  value: any;
@@ -430,11 +644,6 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
430
644
  [Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
431
645
  }>;
432
646
 
433
- type RenderFunc<Props extends {
434
- [key: string]: any;
435
- } = {
436
- children: ReactNode;
437
- }> = (props: Props) => ReactElement;
438
647
  declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
439
648
  type OverrideKey = (typeof overrideKeys)[number];
440
649
  type OverridesGeneric<Shape extends {
@@ -506,7 +715,7 @@ type DragAxis = "dynamic" | "y" | "x";
506
715
 
507
716
  type iconTypes = "Smartphone" | "Monitor" | "Tablet";
508
717
  type Viewport = {
509
- width: number;
718
+ width: number | "100%";
510
719
  height?: number | "auto";
511
720
  label?: string;
512
721
  icon?: iconTypes | ReactNode;
@@ -526,8 +735,13 @@ type IframeConfig = {
526
735
  };
527
736
  type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
528
737
  type Plugin<UserConfig extends Config = Config> = {
738
+ name?: string;
739
+ label?: string;
740
+ icon?: ReactNode;
741
+ render?: () => ReactElement;
529
742
  overrides?: Partial<Overrides<UserConfig>>;
530
743
  fieldTransforms?: FieldTransforms<UserConfig>;
744
+ mobilePanelHeight?: "toggle" | "min-content";
531
745
  };
532
746
  type History<D = any> = {
533
747
  state: D;
@@ -552,6 +766,7 @@ type Slot<Props extends {
552
766
  [K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
553
767
  }[keyof Props][];
554
768
  type WithSlotProps<Target extends Record<string, any>, Components extends DefaultComponents = DefaultComponents, SlotType extends Content<Components> = Content<Components>> = WithDeepSlots<Target, SlotType>;
769
+ type RichText = string | ReactNode;
555
770
 
556
771
  type InsertAction = {
557
772
  type: "insert";
@@ -619,30 +834,4 @@ type PuckAction = {
619
834
  recordHistory?: boolean;
620
835
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
621
836
 
622
- type MigrationOptions<UserConfig extends Config> = {
623
- migrateDynamicZonesForComponent?: {
624
- [ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
625
- };
626
- };
627
- declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
628
-
629
- type PropTransform<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
630
- [ComponentName in keyof Components]: (props: Components[ComponentName] & {
631
- [key: string]: any;
632
- }) => Components[ComponentName];
633
- } & {
634
- root: (props: RootProps & {
635
- [key: string]: any;
636
- }) => RootProps;
637
- }>;
638
- declare function transformProps<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Components, RootProps>, config?: Config): Data;
639
-
640
- declare function resolveAllData<Components extends DefaultComponents = DefaultComponents, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Components, RootProps>>;
641
-
642
- type WalkTreeOptions = {
643
- parentId: string;
644
- propName: string;
645
- };
646
- declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
647
-
648
- export { type MappedItem as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type ComponentConfigExtensions as J, type RootConfig as K, type DefaultComponents as L, type Metadata as M, type ExtractConfigParams as N, type Overrides as O, type Permissions as P, type ConfigParams as Q, type RootDataWithProps as R, type Slot as S, type ComponentConfigParams as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type BaseData as X, type RootDataWithoutProps as Y, type RootData as Z, type ComponentDataOptionalId as _, type ComponentData as a, type ComponentDataMap as a0, type Content as a1, type PuckMetadata as a2, type ComponentMetadata as a3, type FieldMetadata as a4, type BaseField as a5, type TextField as a6, type NumberField as a7, type TextareaField as a8, type SelectField as a9, type RadioField as aa, type ArrayField as ab, type ObjectField as ac, type Adaptor as ad, type ExternalFieldWithAdaptor as ae, type CacheOpts as af, type ExternalField as ag, type CustomFieldRender as ah, type CustomField as ai, type SlotField as aj, type PuckContext as ak, type DefaultRootFieldProps as al, type DefaultRootRenderProps as am, type DefaultRootProps as an, type DefaultComponentProps as ao, type WithId as ap, type WithPuckProps as aq, type AsFieldProps as ar, type WithChildren as as, type ExtractField as at, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
837
+ export { type ComponentConfigParams as $, type AppState as A, type FieldTransformFnParams as B, type Config as C, type Data as D, type FieldTransformFn as E, type Fields as F, overrideKeys as G, type History as H, type IframeConfig as I, type OverrideKey as J, type FieldRenderFunctions as K, type ItemWithId as L, type Metadata as M, type ArrayState as N, type OnAction as O, type PrivateAppState as P, type SlotComponent as Q, type RootData as R, type Slot as S, type PuckComponent as T, type UserGenerics as U, type Viewports as V, type WithId as W, type ComponentConfigExtensions as X, type RootConfig as Y, type ExtractConfigParams as Z, type ConfigParams as _, type PuckAction as a, type BaseData as a0, type RootDataWithoutProps as a1, type ComponentDataOptionalId as a2, type MappedItem as a3, type ComponentDataMap as a4, type PuckMetadata as a5, type ComponentMetadata as a6, type FieldMetadata as a7, type BaseField as a8, type TextField as a9, type NumberField as aa, type TextareaField as ab, type SelectField as ac, type RadioField as ad, type ArrayField as ae, type ObjectField as af, type Adaptor as ag, type ExternalFieldWithAdaptor as ah, type CacheOpts as ai, type ExternalField as aj, type CustomFieldRender as ak, type CustomField as al, type SlotField as am, type PuckContext as an, type DefaultRootRenderProps as ao, type DefaultRootProps as ap, type WithPuckProps as aq, type AsFieldProps as ar, type WithChildren as as, type ExtractField as at, type Content as b, type ComponentData as c, type DefaultComponents as d, type DefaultComponentProps as e, type DefaultRootFieldProps as f, type Permissions as g, type RootDataWithProps as h, type ResolveDataTrigger as i, type Plugin as j, type Overrides as k, type UiState as l, type ComponentConfig as m, type FieldTransforms as n, type RichtextField as o, type Field as p, type FieldProps as q, type DropZoneProps as r, type InitialHistory as s, type ItemSelector as t, type PluginInternal as u, type WithSlotProps as v, type RichText as w, type Direction as x, type DragAxis as y, type Viewport as z };
@@ -0,0 +1,134 @@
1
+ import {
2
+ mapFields
3
+ } from "./chunk-NLUHDYVR.mjs";
4
+ import {
5
+ __async,
6
+ __spreadProps,
7
+ __spreadValues,
8
+ init_react_import
9
+ } from "./chunk-M6W7YEVX.mjs";
10
+
11
+ // components/ViewportControls/default-viewports.ts
12
+ init_react_import();
13
+ var defaultViewports = [
14
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
15
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
16
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" },
17
+ { width: "100%", height: "auto", icon: "FullWidth", label: "Full-width" }
18
+ ];
19
+
20
+ // lib/resolve-component-data.ts
21
+ init_react_import();
22
+
23
+ // lib/get-changed.ts
24
+ init_react_import();
25
+ import { deepEqual } from "fast-equals";
26
+ var getChanged = (newItem, oldItem) => {
27
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
28
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
29
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
30
+ return __spreadProps(__spreadValues({}, acc), {
31
+ [item]: !deepEqual(oldItemProps[item], newItemProps[item])
32
+ });
33
+ }, {}) : {};
34
+ };
35
+
36
+ // lib/resolve-component-data.ts
37
+ import { deepEqual as deepEqual2 } from "fast-equals";
38
+ var cache = { lastChange: {} };
39
+ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
40
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
41
+ const resolvedItem = __spreadValues({}, item);
42
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
43
+ const id = "id" in item.props ? item.props.id : "root";
44
+ if (shouldRunResolver) {
45
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
46
+ if (trigger !== "force" && item && deepEqual2(item, oldItem)) {
47
+ return { node: resolved, didChange: false };
48
+ }
49
+ const changed = getChanged(item, oldItem);
50
+ if (onResolveStart) {
51
+ onResolveStart(item);
52
+ }
53
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
54
+ changed,
55
+ lastData: oldItem,
56
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
57
+ trigger
58
+ });
59
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
60
+ if (Object.keys(readOnly).length) {
61
+ resolvedItem.readOnly = readOnly;
62
+ }
63
+ }
64
+ let itemWithResolvedChildren = yield mapFields(
65
+ resolvedItem,
66
+ {
67
+ slot: (_02) => __async(null, [_02], function* ({ value }) {
68
+ const content = value;
69
+ return yield Promise.all(
70
+ content.map(
71
+ (childItem) => __async(null, null, function* () {
72
+ return (yield resolveComponentData(
73
+ childItem,
74
+ config,
75
+ metadata,
76
+ onResolveStart,
77
+ onResolveEnd,
78
+ trigger
79
+ )).node;
80
+ })
81
+ )
82
+ );
83
+ })
84
+ },
85
+ config
86
+ );
87
+ if (shouldRunResolver && onResolveEnd) {
88
+ onResolveEnd(resolvedItem);
89
+ }
90
+ cache.lastChange[id] = {
91
+ item,
92
+ resolved: itemWithResolvedChildren
93
+ };
94
+ return {
95
+ node: itemWithResolvedChildren,
96
+ didChange: !deepEqual2(item, itemWithResolvedChildren)
97
+ };
98
+ });
99
+
100
+ // store/default-app-state.ts
101
+ init_react_import();
102
+ var defaultAppState = {
103
+ data: { content: [], root: {}, zones: {} },
104
+ ui: {
105
+ leftSideBarVisible: true,
106
+ rightSideBarVisible: true,
107
+ arrayState: {},
108
+ itemSelector: null,
109
+ componentList: {},
110
+ isDragging: false,
111
+ previewMode: "edit",
112
+ viewports: {
113
+ current: {
114
+ width: defaultViewports[0].width,
115
+ height: defaultViewports[0].height || "auto"
116
+ },
117
+ options: [],
118
+ controlsVisible: true
119
+ },
120
+ field: { focus: null },
121
+ plugin: { current: null }
122
+ },
123
+ indexes: {
124
+ nodes: {},
125
+ zones: {}
126
+ }
127
+ };
128
+
129
+ export {
130
+ defaultViewports,
131
+ getChanged,
132
+ resolveComponentData,
133
+ defaultAppState
134
+ };