@measured/puck 0.21.0-canary.8416d520 → 0.21.0-canary.89038d0c

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-F2LSS6SE.css +403 -0
  2. package/dist/Editor-O447AVCX.mjs +204 -0
  3. package/dist/Render-OFE6QLI2.mjs +55 -0
  4. package/dist/Render-QEMDIDQC.css +101 -0
  5. package/dist/{walk-tree-Butv5UdJ.d.mts → actions-ONhOkrvf.d.mts} +215 -53
  6. package/dist/{walk-tree-Butv5UdJ.d.ts → actions-ONhOkrvf.d.ts} +215 -53
  7. package/dist/chunk-2Q4PACDA.mjs +111 -0
  8. package/dist/chunk-62AAYNXG.mjs +63 -0
  9. package/dist/chunk-BSDEIOEK.mjs +706 -0
  10. package/dist/chunk-CSSRLPHM.mjs +11 -0
  11. package/dist/chunk-DAQLMM2T.mjs +1722 -0
  12. package/dist/chunk-M6W7YEVX.mjs +95 -0
  13. package/dist/chunk-NLUHDYVR.mjs +416 -0
  14. package/dist/chunk-PLXSMBAA.mjs +53 -0
  15. package/dist/chunk-QAWJTCV5.mjs +33 -0
  16. package/dist/chunk-QBGM4ELA.mjs +528 -0
  17. package/dist/chunk-T3WX7XJ6.mjs +132 -0
  18. package/dist/chunk-V5I7CVLT.mjs +103 -0
  19. package/dist/chunk-Y2EFNT5P.mjs +108 -0
  20. package/dist/chunk-Y656T6AQ.mjs +419 -0
  21. package/dist/{chunk-N52WGXS5.mjs → chunk-Z476VA6G.mjs} +5902 -8105
  22. package/dist/full-2GJTAAZE.css +301 -0
  23. package/dist/full-BEMDJKDS.mjs +93 -0
  24. package/dist/index-BEoNHRI1.d.ts +116 -0
  25. package/dist/index-DfxZ7tZF.d.mts +116 -0
  26. package/dist/index.css +636 -759
  27. package/dist/index.d.mts +95 -124
  28. package/dist/index.d.ts +95 -124
  29. package/dist/index.js +8125 -5331
  30. package/dist/index.mjs +28 -15
  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-JU3A7Y4L.mjs +57 -0
  36. package/dist/loaded-N3FYGF2Y.mjs +57 -0
  37. package/dist/loaded-OBY7OMS6.mjs +60 -0
  38. package/dist/loaded-RVWBFK7L.css +87 -0
  39. package/dist/no-external.css +636 -759
  40. package/dist/no-external.d.mts +19 -2
  41. package/dist/no-external.d.ts +19 -2
  42. package/dist/no-external.js +8125 -5331
  43. package/dist/no-external.mjs +28 -15
  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 -26
  48. package/dist/rsc.mjs +18 -9
  49. package/dist/walk-tree-CdriEzFJ.d.mts +29 -0
  50. package/dist/walk-tree-DHbAZ4wF.d.ts +29 -0
  51. package/package.json +31 -4
  52. package/dist/chunk-FY5AZKYD.mjs +0 -967
@@ -1,10 +1,185 @@
1
- import { ReactElement, CSSProperties, ReactNode, JSX } from 'react';
1
+ import { ReactElement, CSSProperties, ReactNode, ElementType, 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,9 +343,10 @@ 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;
349
+ as?: ElementType;
152
350
  };
153
351
 
154
352
  type PuckContext = {
@@ -239,6 +437,7 @@ UserField extends BaseField = {}> = {
239
437
  permissions: Partial<Permissions>;
240
438
  appState: AppState;
241
439
  lastData: DataShape | null;
440
+ parent: ComponentData | null;
242
441
  }) => Promise<Partial<Permissions>> | Partial<Permissions>;
243
442
  metadata?: ComponentMetadata;
244
443
  } & ComponentConfigExtensions;
@@ -332,7 +531,6 @@ interface FieldMetadata extends Metadata {
332
531
  type ItemWithId = {
333
532
  _arrayId: string;
334
533
  _originalIndex: number;
335
- _currentIndex: number;
336
534
  };
337
535
  type ArrayState = {
338
536
  items: ItemWithId[];
@@ -343,7 +541,6 @@ type UiState = {
343
541
  rightSideBarVisible: boolean;
344
542
  leftSideBarWidth?: number | null;
345
543
  rightSideBarWidth?: number | null;
346
- mobilePanelExpanded?: boolean;
347
544
  itemSelector: ItemSelector | null;
348
545
  arrayState: Record<string, ArrayState | undefined>;
349
546
  previewMode: "interactive" | "edit";
@@ -356,7 +553,7 @@ type UiState = {
356
553
  isDragging: boolean;
357
554
  viewports: {
358
555
  current: {
359
- width: number | "100%";
556
+ width: number;
360
557
  height: number | "auto";
361
558
  };
362
559
  controlsVisible: boolean;
@@ -364,9 +561,7 @@ type UiState = {
364
561
  };
365
562
  field: {
366
563
  focus?: string | null;
367
- };
368
- plugin: {
369
- current: string | null;
564
+ metadata?: Record<string, any>;
370
565
  };
371
566
  };
372
567
  type AppState<UserData extends Data = Data> = {
@@ -411,14 +606,6 @@ type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<
411
606
  type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
412
607
  never
413
608
  ] ? False : True;
414
- type RenderFunc<Props extends {
415
- [key: string]: any;
416
- } = {
417
- children: ReactNode;
418
- }> = (props: Props) => ReactElement;
419
- type PluginInternal = Plugin & {
420
- mobileOnly?: boolean;
421
- };
422
609
 
423
610
  type MapFnParams<ThisField = Field> = {
424
611
  value: any;
@@ -442,6 +629,11 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
442
629
  [Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
443
630
  }>;
444
631
 
632
+ type RenderFunc<Props extends {
633
+ [key: string]: any;
634
+ } = {
635
+ children: ReactNode;
636
+ }> = (props: Props) => ReactElement;
445
637
  declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
446
638
  type OverrideKey = (typeof overrideKeys)[number];
447
639
  type OverridesGeneric<Shape extends {
@@ -513,7 +705,7 @@ type DragAxis = "dynamic" | "y" | "x";
513
705
 
514
706
  type iconTypes = "Smartphone" | "Monitor" | "Tablet";
515
707
  type Viewport = {
516
- width: number | "100%";
708
+ width: number;
517
709
  height?: number | "auto";
518
710
  label?: string;
519
711
  icon?: iconTypes | ReactNode;
@@ -533,13 +725,8 @@ type IframeConfig = {
533
725
  };
534
726
  type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
535
727
  type Plugin<UserConfig extends Config = Config> = {
536
- name?: string;
537
- label?: string;
538
- icon?: ReactNode;
539
- render?: () => ReactElement;
540
728
  overrides?: Partial<Overrides<UserConfig>>;
541
729
  fieldTransforms?: FieldTransforms<UserConfig>;
542
- mobilePanelHeight?: "toggle" | "min-content";
543
730
  };
544
731
  type History<D = any> = {
545
732
  state: D;
@@ -564,6 +751,7 @@ type Slot<Props extends {
564
751
  [K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
565
752
  }[keyof Props][];
566
753
  type WithSlotProps<Target extends Record<string, any>, Components extends DefaultComponents = DefaultComponents, SlotType extends Content<Components> = Content<Components>> = WithDeepSlots<Target, SlotType>;
754
+ type RichText = string | ReactNode;
567
755
 
568
756
  type InsertAction = {
569
757
  type: "insert";
@@ -631,30 +819,4 @@ type PuckAction = {
631
819
  recordHistory?: boolean;
632
820
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
633
821
 
634
- type MigrationOptions<UserConfig extends Config> = {
635
- migrateDynamicZonesForComponent?: {
636
- [ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
637
- };
638
- };
639
- declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
640
-
641
- type PropTransform<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
642
- [ComponentName in keyof Components]: (props: Components[ComponentName] & {
643
- [key: string]: any;
644
- }) => Components[ComponentName];
645
- } & {
646
- root: (props: RootProps & {
647
- [key: string]: any;
648
- }) => RootProps;
649
- }>;
650
- declare function transformProps<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Components, RootProps>, config?: Config): Data;
651
-
652
- 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>>;
653
-
654
- type WalkTreeOptions = {
655
- parentId: string;
656
- propName: string;
657
- };
658
- 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;
659
-
660
- export { type ComponentDataOptionalId as $, type AppState as A, type ItemWithId as B, type Config as C, type DropZoneProps as D, type ArrayState as E, type Fields as F, type SlotComponent as G, type History as H, type IframeConfig as I, type PuckComponent as J, type ComponentConfigExtensions as K, type RootConfig as L, type Metadata as M, type DefaultComponents as N, type Overrides as O, type Permissions as P, type ExtractConfigParams as Q, type RootDataWithProps as R, type Slot as S, type ConfigParams as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentConfigParams as X, type BaseData as Y, type RootDataWithoutProps as Z, type RootData as _, type ComponentData as a, type MappedItem as a0, type ComponentDataMap as a1, type Content as a2, type PuckMetadata as a3, type ComponentMetadata as a4, type FieldMetadata as a5, type BaseField as a6, type TextField as a7, type NumberField as a8, type TextareaField as a9, type SelectField as aa, type RadioField as ab, type ArrayField as ac, type ObjectField as ad, type Adaptor as ae, type ExternalFieldWithAdaptor as af, type CacheOpts as ag, type ExternalField as ah, type CustomFieldRender as ai, type CustomField as aj, type SlotField as ak, type PuckContext as al, type DefaultRootFieldProps as am, type DefaultRootRenderProps as an, type DefaultRootProps as ao, type DefaultComponentProps as ap, type WithId as aq, type WithPuckProps as ar, type AsFieldProps as as, type WithChildren as at, type ExtractField as au, 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 PluginInternal as o, type Direction as p, type DragAxis as q, resolveAllData as r, type Viewport as s, transformProps as t, type FieldTransformFnParams as u, type FieldTransformFn as v, walkTree as w, overrideKeys as x, type OverrideKey as y, type FieldRenderFunctions as z };
822
+ export { type BaseData as $, type AppState as A, type FieldTransformFn as B, type Config as C, type Data as D, overrideKeys as E, type Fields as F, type OverrideKey as G, type History as H, type IframeConfig as I, type FieldRenderFunctions as J, type ItemWithId as K, type ArrayState as L, type Metadata as M, type SlotComponent as N, type OnAction as O, type PrivateAppState as P, type PuckComponent as Q, type RootData as R, type Slot as S, type ComponentConfigExtensions as T, type UserGenerics as U, type Viewports as V, type WithId as W, type RootConfig as X, type ExtractConfigParams as Y, type ConfigParams as Z, type ComponentConfigParams as _, type PuckAction as a, type RootDataWithoutProps as a0, type ComponentDataOptionalId as a1, type MappedItem as a2, type ComponentDataMap as a3, type PuckMetadata as a4, type ComponentMetadata as a5, type FieldMetadata as a6, type BaseField as a7, type TextField as a8, type NumberField as a9, type TextareaField as aa, type SelectField as ab, type RadioField as ac, type ArrayField as ad, type ObjectField as ae, type Adaptor as af, type ExternalFieldWithAdaptor as ag, type CacheOpts as ah, type ExternalField as ai, type CustomFieldRender as aj, type CustomField as ak, type SlotField as al, type PuckContext as am, type DefaultRootRenderProps as an, type DefaultRootProps as ao, type WithPuckProps as ap, type AsFieldProps as aq, type WithChildren as ar, type ExtractField as as, 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 WithSlotProps as u, type RichText as v, type Direction as w, type DragAxis as x, type Viewport as y, type FieldTransformFnParams as z };
@@ -0,0 +1,111 @@
1
+ import {
2
+ styles_module_default
3
+ } from "./chunk-CSSRLPHM.mjs";
4
+ import {
5
+ LoadedRichTextMenuInner
6
+ } from "./chunk-BSDEIOEK.mjs";
7
+ import {
8
+ useAppStore,
9
+ useAppStoreApi
10
+ } from "./chunk-DAQLMM2T.mjs";
11
+ import {
12
+ get_class_name_factory_default
13
+ } from "./chunk-Y2EFNT5P.mjs";
14
+ import {
15
+ __spreadValues,
16
+ init_react_import
17
+ } from "./chunk-M6W7YEVX.mjs";
18
+
19
+ // components/RichTextEditor/components/EditorInner.tsx
20
+ init_react_import();
21
+ import {
22
+ memo,
23
+ useCallback
24
+ } from "react";
25
+ import { jsx, jsxs } from "react/jsx-runtime";
26
+ var getClassName = get_class_name_factory_default("RichTextEditor", styles_module_default);
27
+ var EditorInner = memo(
28
+ ({
29
+ children,
30
+ menu,
31
+ readOnly = false,
32
+ field,
33
+ inline = false,
34
+ editor,
35
+ id
36
+ }) => {
37
+ const { initialHeight } = field;
38
+ const isActive = useAppStore(
39
+ (s) => {
40
+ var _a;
41
+ return ((_a = s.currentRichText) == null ? void 0 : _a.id) === id && inline === s.currentRichText.inline;
42
+ }
43
+ );
44
+ const appStoreApi = useAppStoreApi();
45
+ const handleHotkeyCapture = useCallback(
46
+ (event) => {
47
+ var _a, _b;
48
+ if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "i") {
49
+ event.stopPropagation();
50
+ event.preventDefault();
51
+ (_b = editor == null ? void 0 : (_a = editor.commands).toggleItalic) == null ? void 0 : _b.call(_a);
52
+ }
53
+ },
54
+ [editor]
55
+ );
56
+ const handleBlur = useCallback(
57
+ (e) => {
58
+ var _a, _b;
59
+ const targetInMenu = !!((_b = (_a = e.relatedTarget) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(
60
+ _a,
61
+ "[data-puck-rte-menu]"
62
+ ));
63
+ if (e.relatedTarget && !targetInMenu) {
64
+ appStoreApi.setState({
65
+ currentRichText: null
66
+ });
67
+ } else {
68
+ e.stopPropagation();
69
+ }
70
+ },
71
+ [appStoreApi]
72
+ );
73
+ return /* @__PURE__ */ jsxs(
74
+ "div",
75
+ {
76
+ className: getClassName({
77
+ editor: !inline,
78
+ inline,
79
+ isActive,
80
+ disabled: readOnly
81
+ }),
82
+ style: inline ? {} : { height: initialHeight != null ? initialHeight : 192, overflowY: "auto" },
83
+ onKeyDownCapture: handleHotkeyCapture,
84
+ onBlur: handleBlur,
85
+ children: [
86
+ !inline && /* @__PURE__ */ jsx("div", { className: getClassName("menu"), children: menu }),
87
+ children
88
+ ]
89
+ }
90
+ );
91
+ }
92
+ );
93
+ EditorInner.displayName = "EditorInner";
94
+
95
+ // components/RichTextMenu/index.tsx
96
+ init_react_import();
97
+ import { lazy, Suspense } from "react";
98
+ import { jsx as jsx2 } from "react/jsx-runtime";
99
+ var LoadedRichTextMenuFull = lazy(
100
+ () => import("./full-BEMDJKDS.mjs").then((m) => ({
101
+ default: m.LoadedRichTextMenuFull
102
+ }))
103
+ );
104
+ var LoadedRichTextMenu = (props) => {
105
+ return /* @__PURE__ */ jsx2(Suspense, { fallback: /* @__PURE__ */ jsx2(LoadedRichTextMenuInner, __spreadValues({}, props)), children: /* @__PURE__ */ jsx2(LoadedRichTextMenuFull, __spreadValues({}, props)) });
106
+ };
107
+
108
+ export {
109
+ EditorInner,
110
+ LoadedRichTextMenu
111
+ };
@@ -0,0 +1,63 @@
1
+ import {
2
+ Heading1,
3
+ Heading2,
4
+ Heading3,
5
+ Heading4,
6
+ Heading5,
7
+ Heading6
8
+ } from "./chunk-DAQLMM2T.mjs";
9
+ import {
10
+ init_react_import
11
+ } from "./chunk-M6W7YEVX.mjs";
12
+
13
+ // components/RichTextMenu/controls/HeadingSelect/use-options.ts
14
+ init_react_import();
15
+ import { useMemo } from "react";
16
+ var optionNodes = {
17
+ h1: { label: "Heading 1", icon: Heading1 },
18
+ h2: { label: "Heading 2", icon: Heading2 },
19
+ h3: { label: "Heading 3", icon: Heading3 },
20
+ h4: { label: "Heading 4", icon: Heading4 },
21
+ h5: { label: "Heading 5", icon: Heading5 },
22
+ h6: { label: "Heading 6", icon: Heading6 }
23
+ };
24
+ var useHeadingOptions = (fieldOptions) => {
25
+ var _a;
26
+ let blockOptions = [];
27
+ if ((fieldOptions == null ? void 0 : fieldOptions.heading) !== false) {
28
+ if (!((_a = fieldOptions == null ? void 0 : fieldOptions.heading) == null ? void 0 : _a.levels)) {
29
+ blockOptions = ["h1", "h2", "h3", "h4", "h5", "h6"];
30
+ } else {
31
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(1)) {
32
+ blockOptions.push("h1");
33
+ }
34
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(2)) {
35
+ blockOptions.push("h2");
36
+ }
37
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(3)) {
38
+ blockOptions.push("h3");
39
+ }
40
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(4)) {
41
+ blockOptions.push("h4");
42
+ }
43
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(5)) {
44
+ blockOptions.push("h5");
45
+ }
46
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(6)) {
47
+ blockOptions.push("h6");
48
+ }
49
+ }
50
+ }
51
+ return useMemo(
52
+ () => blockOptions.map((item) => ({
53
+ value: item,
54
+ label: optionNodes[item].label,
55
+ icon: optionNodes[item].icon
56
+ })),
57
+ [blockOptions]
58
+ );
59
+ };
60
+
61
+ export {
62
+ useHeadingOptions
63
+ };