@puckeditor/core 0.23.0 → 0.24.0-canary.03e660bb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/{Editor-44C53YAG.mjs → Editor-7KNCA6HK.mjs} +9 -9
- package/dist/{Render-DQXAYUBI.mjs → Render-H3USS5FU.mjs} +2 -2
- package/dist/{actions-DA1J5F56.d.mts → actions-BEt6vA0O.d.mts} +78 -20
- package/dist/{actions-DA1J5F56.d.ts → actions-BEt6vA0O.d.ts} +78 -20
- package/dist/{chunk-YQWFSBOU.mjs → chunk-3GJJSXCL.mjs} +138 -50
- package/dist/{chunk-55V3NZVF.mjs → chunk-DQGTW26I.mjs} +1678 -1064
- package/dist/{chunk-NJTGWYYH.mjs → chunk-EPCBCOJF.mjs} +1 -1
- package/dist/{chunk-4P4VZS4P.mjs → chunk-I4C7LRQ7.mjs} +1 -1
- package/dist/{chunk-GNR2HNTB.mjs → chunk-J6CJWYPQ.mjs} +8 -8
- package/dist/{chunk-WF6I3XOL.mjs → chunk-NZHU34KT.mjs} +4 -4
- package/dist/{chunk-Y2EFNT5P.mjs → chunk-OT7NKYY4.mjs} +2 -2
- package/dist/{chunk-K2LNXU54.mjs → chunk-SBDTCWI2.mjs} +109 -76
- package/dist/{chunk-67Y7M4OJ.mjs → chunk-VCJQYLHO.mjs} +1 -1
- package/dist/{chunk-ZRAERXB4.mjs → chunk-XMN55NON.mjs} +3 -2
- package/dist/{chunk-2CNEFIQP.mjs → chunk-ZOLLDKZQ.mjs} +4 -1
- package/dist/{full-7ZJV44EE.mjs → full-FCIISNOL.mjs} +7 -7
- package/dist/{index-DIZKfHDN.d.ts → index-BjizoAHc.d.ts} +1 -1
- package/dist/{index-n9eR_SWx.d.mts → index-Cw7CQGG8.d.mts} +1 -1
- package/dist/index.css +217 -51
- package/dist/index.d.mts +50 -9
- package/dist/index.d.ts +50 -9
- package/dist/index.js +2227 -1485
- package/dist/index.mjs +16 -10
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/{loaded-36WRJPBT.mjs → loaded-6K36DBBN.mjs} +4 -4
- package/dist/{loaded-SMPR6KZF.mjs → loaded-GZTG57BI.mjs} +4 -4
- package/dist/{loaded-JKA25A3T.mjs → loaded-SBKSTOMK.mjs} +4 -4
- package/dist/no-external.css +217 -51
- package/dist/no-external.d.mts +4 -4
- package/dist/no-external.d.ts +4 -4
- package/dist/no-external.js +2227 -1485
- package/dist/no-external.mjs +16 -10
- package/dist/rsc.d.mts +4 -3
- package/dist/rsc.d.ts +4 -3
- package/dist/rsc.js +194 -71
- package/dist/rsc.mjs +51 -21
- package/dist/{walk-tree-DbY5zG2K.d.ts → walk-tree-COvy_ERJ.d.ts} +1 -1
- package/dist/{walk-tree-DHP1pWEM.d.mts → walk-tree-CrM-tWuf.d.mts} +1 -1
- package/package.json +34 -33
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) The Puck Contributors.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PuckRichText
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZOLLDKZQ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
EditorInner,
|
|
6
6
|
LoadedRichTextMenu
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NZHU34KT.mjs";
|
|
8
8
|
import "./chunk-H635BA2V.mjs";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-J6CJWYPQ.mjs";
|
|
10
|
+
import "./chunk-VCJQYLHO.mjs";
|
|
11
|
+
import "./chunk-I4C7LRQ7.mjs";
|
|
12
|
+
import "./chunk-EPCBCOJF.mjs";
|
|
13
13
|
import {
|
|
14
14
|
useAppStore,
|
|
15
15
|
useAppStoreApi
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-SBDTCWI2.mjs";
|
|
17
17
|
import "./chunk-Z2MS6UIF.mjs";
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-XMN55NON.mjs";
|
|
19
|
+
import "./chunk-OT7NKYY4.mjs";
|
|
20
20
|
import "./chunk-H65MT2JK.mjs";
|
|
21
21
|
import {
|
|
22
22
|
__spreadProps,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PuckRichText
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZOLLDKZQ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
styles_module_default
|
|
6
6
|
} from "./chunk-H635BA2V.mjs";
|
|
7
7
|
import {
|
|
8
8
|
get_class_name_factory_default
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OT7NKYY4.mjs";
|
|
10
10
|
import {
|
|
11
11
|
init_react_import
|
|
12
12
|
} from "./chunk-M6W7YEVX.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ElementType, CSSProperties, Ref, ComponentPropsWithoutRef, ReactElement, ReactNode, JSX } from 'react';
|
|
2
2
|
import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
|
|
3
3
|
import { BlockquoteOptions } from '@tiptap/extension-blockquote';
|
|
4
4
|
import { BoldOptions } from '@tiptap/extension-bold';
|
|
@@ -20,6 +20,62 @@ type ItemSelector = {
|
|
|
20
20
|
zone?: string;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Props consumed by Puck internally that are shared between DropZones and slots.
|
|
25
|
+
*/
|
|
26
|
+
type DropZoneSharedProps<ComponentType extends ElementType = "div"> = {
|
|
27
|
+
allow?: string[];
|
|
28
|
+
disallow?: string[];
|
|
29
|
+
style?: CSSProperties;
|
|
30
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
31
|
+
className?: string;
|
|
32
|
+
collisionAxis?: DragAxis;
|
|
33
|
+
ref?: Ref<any>;
|
|
34
|
+
as?: ComponentType;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* All props consumed by Puck for a DropZone component. `zone` lives here only.
|
|
38
|
+
*
|
|
39
|
+
* On slots `zone` is injected internally, so slots use {@link SlotProps} instead.
|
|
40
|
+
*/
|
|
41
|
+
type DropZoneOwnProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & {
|
|
42
|
+
zone: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Unsupported additional props that are never forwarded to `as`.
|
|
46
|
+
*
|
|
47
|
+
* Omitted from the public types AND stripped at runtime.
|
|
48
|
+
*/
|
|
49
|
+
type NonForwardableProps = {
|
|
50
|
+
children?: unknown;
|
|
51
|
+
dangerouslySetInnerHTML?: unknown;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Keys internally consumed by Puck and never forwarded to `as`.
|
|
55
|
+
*/
|
|
56
|
+
type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata" | "fieldTransforms";
|
|
57
|
+
/**
|
|
58
|
+
* Additional props forwarded to the element or component provided via `as`,
|
|
59
|
+
* typed against it.
|
|
60
|
+
*
|
|
61
|
+
* Puck-internal/unsupported props are stripped so they don't leak onto the DOM.
|
|
62
|
+
*/
|
|
63
|
+
type ForwardedProps<ComponentType extends ElementType> = Omit<ComponentPropsWithoutRef<ComponentType>, ConsumedPropKey | keyof NonForwardableProps>;
|
|
64
|
+
/**
|
|
65
|
+
* Props for a `DropZone` component.
|
|
66
|
+
*
|
|
67
|
+
* Any additional props not consumed by Puck are forwarded to the element or
|
|
68
|
+
* component provided via `as` (defaulting to a `div`), typed against it.
|
|
69
|
+
*/
|
|
70
|
+
type DropZoneProps<ComponentType extends ElementType = "div"> = DropZoneOwnProps<ComponentType> & ForwardedProps<ComponentType>;
|
|
71
|
+
/**
|
|
72
|
+
* Props for a `slot` render component.
|
|
73
|
+
*
|
|
74
|
+
* Any additional props not consumed by Puck are forwarded to the element or
|
|
75
|
+
* component provided via `as` (defaulting to a `div`), typed against it.
|
|
76
|
+
*/
|
|
77
|
+
type SlotProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & ForwardedProps<ComponentType>;
|
|
78
|
+
|
|
23
79
|
declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
|
|
24
80
|
isAlignLeft?: undefined;
|
|
25
81
|
canAlignLeft?: undefined;
|
|
@@ -216,6 +272,10 @@ interface RadioField extends BaseField {
|
|
|
216
272
|
type: "radio";
|
|
217
273
|
options: FieldOptions;
|
|
218
274
|
}
|
|
275
|
+
interface CheckboxField extends BaseField {
|
|
276
|
+
type: "checkbox";
|
|
277
|
+
options: FieldOptions;
|
|
278
|
+
}
|
|
219
279
|
interface RichtextField<UserSelector extends RichTextSelector = RichTextSelector> extends BaseField {
|
|
220
280
|
type: "richtext";
|
|
221
281
|
contentEditable?: boolean;
|
|
@@ -258,6 +318,7 @@ interface ObjectField<Props extends any = {
|
|
|
258
318
|
[key: string]: any;
|
|
259
319
|
}, UserField extends {} = {}> extends BaseField {
|
|
260
320
|
type: "object";
|
|
321
|
+
expandable?: boolean;
|
|
261
322
|
objectFields: {
|
|
262
323
|
[SubPropName in keyof Props]: UserField extends {
|
|
263
324
|
type: PropertyKey;
|
|
@@ -322,7 +383,7 @@ interface SlotField extends BaseField {
|
|
|
322
383
|
allow?: string[];
|
|
323
384
|
disallow?: string[];
|
|
324
385
|
}
|
|
325
|
-
type Field<ValueType = any, UserField extends {} = {}> = TextField | RichtextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
386
|
+
type Field<ValueType = any, UserField extends {} = {}> = TextField | RichtextField | NumberField | TextareaField | SelectField | RadioField | CheckboxField | ArrayField<ValueType extends {
|
|
326
387
|
[key: string]: any;
|
|
327
388
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
328
389
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
|
|
@@ -338,20 +399,11 @@ type FieldProps<F = Field<any>, ValueType = any> = {
|
|
|
338
399
|
readOnly?: boolean;
|
|
339
400
|
};
|
|
340
401
|
|
|
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
402
|
type PuckContext = {
|
|
354
|
-
|
|
403
|
+
/**
|
|
404
|
+
* @deprecated Use {@link https://puckeditor.com/docs/api-reference/fields/slot Slots} instead.
|
|
405
|
+
*/
|
|
406
|
+
renderDropZone: <ComponentType extends ElementType = "div">(props: DropZoneProps<ComponentType>) => React.ReactNode;
|
|
355
407
|
metadata: Metadata;
|
|
356
408
|
isEditing: boolean;
|
|
357
409
|
dragRef: ((element: Element | null) => void) | null;
|
|
@@ -399,7 +451,7 @@ type ExtractField<UserField extends {
|
|
|
399
451
|
type: T;
|
|
400
452
|
}>;
|
|
401
453
|
|
|
402
|
-
type SlotComponent = (props?:
|
|
454
|
+
type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
|
|
403
455
|
type PuckComponent<Props> = (props: WithId<WithPuckProps<{
|
|
404
456
|
[K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
|
|
405
457
|
}>>) => JSX.Element;
|
|
@@ -415,6 +467,9 @@ UserField extends BaseField = {}> = {
|
|
|
415
467
|
label?: string;
|
|
416
468
|
defaultProps?: FieldProps;
|
|
417
469
|
fields?: Fields<FieldProps, UserField>;
|
|
470
|
+
renderFields?: RenderFunc<{
|
|
471
|
+
fields: Partial<Record<keyof FieldProps, ReactNode>>;
|
|
472
|
+
}>;
|
|
418
473
|
permissions?: Partial<Permissions>;
|
|
419
474
|
inline?: boolean;
|
|
420
475
|
resolveFields?: (data: DataShape, params: {
|
|
@@ -572,6 +627,7 @@ type UiState = {
|
|
|
572
627
|
controlsVisible: boolean;
|
|
573
628
|
options: Viewport[];
|
|
574
629
|
};
|
|
630
|
+
expandedFieldGroups: Record<string, boolean>;
|
|
575
631
|
field: {
|
|
576
632
|
focus?: string | null;
|
|
577
633
|
metadata?: Record<string, any>;
|
|
@@ -678,10 +734,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
678
734
|
children: ReactNode;
|
|
679
735
|
isLoading: boolean;
|
|
680
736
|
itemSelector?: ItemSelector | null;
|
|
737
|
+
fields: Partial<Record<string, ReactNode>>;
|
|
681
738
|
}>;
|
|
682
739
|
fieldLabel: RenderFunc<{
|
|
683
740
|
children?: ReactNode;
|
|
684
741
|
icon?: ReactNode;
|
|
742
|
+
endIcon?: ReactNode;
|
|
685
743
|
label: string;
|
|
686
744
|
el?: "label" | "div";
|
|
687
745
|
readOnly?: boolean;
|
|
@@ -713,12 +771,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
713
771
|
}>;
|
|
714
772
|
type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
|
|
715
773
|
type: string;
|
|
716
|
-
} = Field | G["UserField"]> =
|
|
774
|
+
} = Field | G["UserField"]> = {
|
|
717
775
|
[Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
|
|
718
776
|
children: ReactNode;
|
|
719
777
|
name: string;
|
|
720
|
-
}
|
|
721
|
-
}
|
|
778
|
+
}> | null;
|
|
779
|
+
};
|
|
722
780
|
|
|
723
781
|
type Direction = "left" | "right" | "up" | "down" | null;
|
|
724
782
|
type DragAxis = "dynamic" | "y" | "x";
|
|
@@ -858,4 +916,4 @@ type PuckAction = {
|
|
|
858
916
|
recordHistory?: boolean;
|
|
859
917
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
860
918
|
|
|
861
|
-
export { type
|
|
919
|
+
export { type OnAction as $, type Adaptor as A, type BaseData as B, type CacheOpts as C, type Data as D, type DragAxis as E, type DropZoneProps as F, type ExternalField as G, type ExternalFieldWithAdaptor as H, type ExtractConfigParams as I, type ExtractField as J, type Field as K, type FieldMetadata as L, type FieldProps as M, type FieldRenderFunctions as N, type FieldTransformFn as O, type FieldTransformFnParams as P, type FieldTransforms as Q, type Fields as R, type History as S, type IframeConfig as T, type InitialHistory as U, type ItemSelector as V, type ItemWithId as W, type MappedItem as X, type Metadata as Y, type NumberField as Z, type ObjectField as _, type AppState as a, type OverrideKey as a0, type Overrides as a1, type Permissions as a2, type Plugin as a3, type PluginInternal as a4, type PrivateAppState as a5, type PuckAction as a6, type PuckComponent as a7, type PuckContext as a8, type PuckMetadata as a9, type RadioField as aa, type ResolveDataTrigger as ab, type RichText as ac, type RichtextField as ad, type RootConfig as ae, type RootData as af, type RootDataWithProps as ag, type RootDataWithoutProps as ah, type SelectField as ai, type Slot as aj, type SlotComponent as ak, type SlotField as al, type TextField as am, type TextareaField as an, type UiState as ao, type UserGenerics as ap, type Viewport as aq, type Viewports as ar, type WithChildren as as, type WithDefaultRootFieldProps as at, type WithId as au, type WithPuckProps as av, type WithSlotProps as aw, overrideKeys as ax, type ArrayField as b, type ArrayState as c, type AsFieldProps as d, type BaseField as e, type CheckboxField as f, type ComponentConfig as g, type ComponentConfigExtensions as h, type ComponentConfigParams as i, type ComponentData as j, type ComponentDataMap as k, type ComponentDataOptionalId as l, type ComponentMetadata as m, type Config as n, type ConfigParams as o, type Content as p, type CustomField as q, type CustomFieldRender as r, type DefaultComponentProps as s, type DefaultComponents as t, type DefaultRootFieldProps as u, type DefaultRootProps as v, type DefaultRootRenderProps as w, type Direction as x, type DndBehavior as y, type DndConfig as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ElementType, CSSProperties, Ref, ComponentPropsWithoutRef, ReactElement, ReactNode, JSX } from 'react';
|
|
2
2
|
import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
|
|
3
3
|
import { BlockquoteOptions } from '@tiptap/extension-blockquote';
|
|
4
4
|
import { BoldOptions } from '@tiptap/extension-bold';
|
|
@@ -20,6 +20,62 @@ type ItemSelector = {
|
|
|
20
20
|
zone?: string;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Props consumed by Puck internally that are shared between DropZones and slots.
|
|
25
|
+
*/
|
|
26
|
+
type DropZoneSharedProps<ComponentType extends ElementType = "div"> = {
|
|
27
|
+
allow?: string[];
|
|
28
|
+
disallow?: string[];
|
|
29
|
+
style?: CSSProperties;
|
|
30
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
31
|
+
className?: string;
|
|
32
|
+
collisionAxis?: DragAxis;
|
|
33
|
+
ref?: Ref<any>;
|
|
34
|
+
as?: ComponentType;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* All props consumed by Puck for a DropZone component. `zone` lives here only.
|
|
38
|
+
*
|
|
39
|
+
* On slots `zone` is injected internally, so slots use {@link SlotProps} instead.
|
|
40
|
+
*/
|
|
41
|
+
type DropZoneOwnProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & {
|
|
42
|
+
zone: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Unsupported additional props that are never forwarded to `as`.
|
|
46
|
+
*
|
|
47
|
+
* Omitted from the public types AND stripped at runtime.
|
|
48
|
+
*/
|
|
49
|
+
type NonForwardableProps = {
|
|
50
|
+
children?: unknown;
|
|
51
|
+
dangerouslySetInnerHTML?: unknown;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Keys internally consumed by Puck and never forwarded to `as`.
|
|
55
|
+
*/
|
|
56
|
+
type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata" | "fieldTransforms";
|
|
57
|
+
/**
|
|
58
|
+
* Additional props forwarded to the element or component provided via `as`,
|
|
59
|
+
* typed against it.
|
|
60
|
+
*
|
|
61
|
+
* Puck-internal/unsupported props are stripped so they don't leak onto the DOM.
|
|
62
|
+
*/
|
|
63
|
+
type ForwardedProps<ComponentType extends ElementType> = Omit<ComponentPropsWithoutRef<ComponentType>, ConsumedPropKey | keyof NonForwardableProps>;
|
|
64
|
+
/**
|
|
65
|
+
* Props for a `DropZone` component.
|
|
66
|
+
*
|
|
67
|
+
* Any additional props not consumed by Puck are forwarded to the element or
|
|
68
|
+
* component provided via `as` (defaulting to a `div`), typed against it.
|
|
69
|
+
*/
|
|
70
|
+
type DropZoneProps<ComponentType extends ElementType = "div"> = DropZoneOwnProps<ComponentType> & ForwardedProps<ComponentType>;
|
|
71
|
+
/**
|
|
72
|
+
* Props for a `slot` render component.
|
|
73
|
+
*
|
|
74
|
+
* Any additional props not consumed by Puck are forwarded to the element or
|
|
75
|
+
* component provided via `as` (defaulting to a `div`), typed against it.
|
|
76
|
+
*/
|
|
77
|
+
type SlotProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & ForwardedProps<ComponentType>;
|
|
78
|
+
|
|
23
79
|
declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
|
|
24
80
|
isAlignLeft?: undefined;
|
|
25
81
|
canAlignLeft?: undefined;
|
|
@@ -216,6 +272,10 @@ interface RadioField extends BaseField {
|
|
|
216
272
|
type: "radio";
|
|
217
273
|
options: FieldOptions;
|
|
218
274
|
}
|
|
275
|
+
interface CheckboxField extends BaseField {
|
|
276
|
+
type: "checkbox";
|
|
277
|
+
options: FieldOptions;
|
|
278
|
+
}
|
|
219
279
|
interface RichtextField<UserSelector extends RichTextSelector = RichTextSelector> extends BaseField {
|
|
220
280
|
type: "richtext";
|
|
221
281
|
contentEditable?: boolean;
|
|
@@ -258,6 +318,7 @@ interface ObjectField<Props extends any = {
|
|
|
258
318
|
[key: string]: any;
|
|
259
319
|
}, UserField extends {} = {}> extends BaseField {
|
|
260
320
|
type: "object";
|
|
321
|
+
expandable?: boolean;
|
|
261
322
|
objectFields: {
|
|
262
323
|
[SubPropName in keyof Props]: UserField extends {
|
|
263
324
|
type: PropertyKey;
|
|
@@ -322,7 +383,7 @@ interface SlotField extends BaseField {
|
|
|
322
383
|
allow?: string[];
|
|
323
384
|
disallow?: string[];
|
|
324
385
|
}
|
|
325
|
-
type Field<ValueType = any, UserField extends {} = {}> = TextField | RichtextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
386
|
+
type Field<ValueType = any, UserField extends {} = {}> = TextField | RichtextField | NumberField | TextareaField | SelectField | RadioField | CheckboxField | ArrayField<ValueType extends {
|
|
326
387
|
[key: string]: any;
|
|
327
388
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
328
389
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
|
|
@@ -338,20 +399,11 @@ type FieldProps<F = Field<any>, ValueType = any> = {
|
|
|
338
399
|
readOnly?: boolean;
|
|
339
400
|
};
|
|
340
401
|
|
|
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
402
|
type PuckContext = {
|
|
354
|
-
|
|
403
|
+
/**
|
|
404
|
+
* @deprecated Use {@link https://puckeditor.com/docs/api-reference/fields/slot Slots} instead.
|
|
405
|
+
*/
|
|
406
|
+
renderDropZone: <ComponentType extends ElementType = "div">(props: DropZoneProps<ComponentType>) => React.ReactNode;
|
|
355
407
|
metadata: Metadata;
|
|
356
408
|
isEditing: boolean;
|
|
357
409
|
dragRef: ((element: Element | null) => void) | null;
|
|
@@ -399,7 +451,7 @@ type ExtractField<UserField extends {
|
|
|
399
451
|
type: T;
|
|
400
452
|
}>;
|
|
401
453
|
|
|
402
|
-
type SlotComponent = (props?:
|
|
454
|
+
type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
|
|
403
455
|
type PuckComponent<Props> = (props: WithId<WithPuckProps<{
|
|
404
456
|
[K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
|
|
405
457
|
}>>) => JSX.Element;
|
|
@@ -415,6 +467,9 @@ UserField extends BaseField = {}> = {
|
|
|
415
467
|
label?: string;
|
|
416
468
|
defaultProps?: FieldProps;
|
|
417
469
|
fields?: Fields<FieldProps, UserField>;
|
|
470
|
+
renderFields?: RenderFunc<{
|
|
471
|
+
fields: Partial<Record<keyof FieldProps, ReactNode>>;
|
|
472
|
+
}>;
|
|
418
473
|
permissions?: Partial<Permissions>;
|
|
419
474
|
inline?: boolean;
|
|
420
475
|
resolveFields?: (data: DataShape, params: {
|
|
@@ -572,6 +627,7 @@ type UiState = {
|
|
|
572
627
|
controlsVisible: boolean;
|
|
573
628
|
options: Viewport[];
|
|
574
629
|
};
|
|
630
|
+
expandedFieldGroups: Record<string, boolean>;
|
|
575
631
|
field: {
|
|
576
632
|
focus?: string | null;
|
|
577
633
|
metadata?: Record<string, any>;
|
|
@@ -678,10 +734,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
678
734
|
children: ReactNode;
|
|
679
735
|
isLoading: boolean;
|
|
680
736
|
itemSelector?: ItemSelector | null;
|
|
737
|
+
fields: Partial<Record<string, ReactNode>>;
|
|
681
738
|
}>;
|
|
682
739
|
fieldLabel: RenderFunc<{
|
|
683
740
|
children?: ReactNode;
|
|
684
741
|
icon?: ReactNode;
|
|
742
|
+
endIcon?: ReactNode;
|
|
685
743
|
label: string;
|
|
686
744
|
el?: "label" | "div";
|
|
687
745
|
readOnly?: boolean;
|
|
@@ -713,12 +771,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
713
771
|
}>;
|
|
714
772
|
type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
|
|
715
773
|
type: string;
|
|
716
|
-
} = Field | G["UserField"]> =
|
|
774
|
+
} = Field | G["UserField"]> = {
|
|
717
775
|
[Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
|
|
718
776
|
children: ReactNode;
|
|
719
777
|
name: string;
|
|
720
|
-
}
|
|
721
|
-
}
|
|
778
|
+
}> | null;
|
|
779
|
+
};
|
|
722
780
|
|
|
723
781
|
type Direction = "left" | "right" | "up" | "down" | null;
|
|
724
782
|
type DragAxis = "dynamic" | "y" | "x";
|
|
@@ -858,4 +916,4 @@ type PuckAction = {
|
|
|
858
916
|
recordHistory?: boolean;
|
|
859
917
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
860
918
|
|
|
861
|
-
export { type
|
|
919
|
+
export { type OnAction as $, type Adaptor as A, type BaseData as B, type CacheOpts as C, type Data as D, type DragAxis as E, type DropZoneProps as F, type ExternalField as G, type ExternalFieldWithAdaptor as H, type ExtractConfigParams as I, type ExtractField as J, type Field as K, type FieldMetadata as L, type FieldProps as M, type FieldRenderFunctions as N, type FieldTransformFn as O, type FieldTransformFnParams as P, type FieldTransforms as Q, type Fields as R, type History as S, type IframeConfig as T, type InitialHistory as U, type ItemSelector as V, type ItemWithId as W, type MappedItem as X, type Metadata as Y, type NumberField as Z, type ObjectField as _, type AppState as a, type OverrideKey as a0, type Overrides as a1, type Permissions as a2, type Plugin as a3, type PluginInternal as a4, type PrivateAppState as a5, type PuckAction as a6, type PuckComponent as a7, type PuckContext as a8, type PuckMetadata as a9, type RadioField as aa, type ResolveDataTrigger as ab, type RichText as ac, type RichtextField as ad, type RootConfig as ae, type RootData as af, type RootDataWithProps as ag, type RootDataWithoutProps as ah, type SelectField as ai, type Slot as aj, type SlotComponent as ak, type SlotField as al, type TextField as am, type TextareaField as an, type UiState as ao, type UserGenerics as ap, type Viewport as aq, type Viewports as ar, type WithChildren as as, type WithDefaultRootFieldProps as at, type WithId as au, type WithPuckProps as av, type WithSlotProps as aw, overrideKeys as ax, type ArrayField as b, type ArrayState as c, type AsFieldProps as d, type BaseField as e, type CheckboxField as f, type ComponentConfig as g, type ComponentConfigExtensions as h, type ComponentConfigParams as i, type ComponentData as j, type ComponentDataMap as k, type ComponentDataOptionalId as l, type ComponentMetadata as m, type Config as n, type ConfigParams as o, type Content as p, type CustomField as q, type CustomFieldRender as r, type DefaultComponentProps as s, type DefaultComponents as t, type DefaultRootFieldProps as u, type DefaultRootProps as v, type DefaultRootRenderProps as w, type Direction as x, type DndBehavior as y, type DndConfig as z };
|