@puckeditor/core 0.23.0-canary.fb9392de → 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-V2RQPQAL.mjs → Editor-7KNCA6HK.mjs} +11 -11
- package/dist/{Editor-ZZW3KF2T.css → Editor-T7TKW6NT.css} +7 -7
- package/dist/{Render-DQXAYUBI.mjs → Render-H3USS5FU.mjs} +2 -2
- package/dist/{actions-Csn3gOP8.d.ts → actions-BEt6vA0O.d.mts} +101 -22
- package/dist/{actions-Csn3gOP8.d.mts → actions-BEt6vA0O.d.ts} +101 -22
- package/dist/{chunk-FKYOVZNF.mjs → chunk-3GJJSXCL.mjs} +154 -69
- package/dist/{chunk-D6RLJXOY.mjs → chunk-DQGTW26I.mjs} +4354 -1753
- package/dist/{chunk-EQADD6J2.mjs → chunk-EPCBCOJF.mjs} +1 -1
- package/dist/{chunk-74HKFKJU.mjs → chunk-H65MT2JK.mjs} +8 -5
- package/dist/{chunk-X4NMPUXH.mjs → chunk-I4C7LRQ7.mjs} +1 -1
- package/dist/{chunk-OI2LQGRV.mjs → chunk-J6CJWYPQ.mjs} +8 -8
- package/dist/{chunk-WABMBXFK.mjs → chunk-NZHU34KT.mjs} +4 -4
- package/dist/{chunk-Y2EFNT5P.mjs → chunk-OT7NKYY4.mjs} +2 -2
- package/dist/{chunk-2KHLVDRT.mjs → chunk-SBDTCWI2.mjs} +139 -83
- package/dist/{chunk-G3YMTKUD.mjs → chunk-VCJQYLHO.mjs} +1 -1
- package/dist/{chunk-GR7NLT4T.mjs → chunk-XMN55NON.mjs} +5 -3
- package/dist/{chunk-HRNJ42TO.mjs → chunk-Z2MS6UIF.mjs} +42 -19
- package/dist/{chunk-2CNEFIQP.mjs → chunk-ZOLLDKZQ.mjs} +4 -1
- package/dist/{full-S3QQ2IBQ.css → full-AAZK6KLI.css} +7 -7
- package/dist/{full-GSJGH3OO.mjs → full-FCIISNOL.mjs} +9 -9
- package/dist/{index-t7c1w81O.d.ts → index-BjizoAHc.d.ts} +8 -3
- package/dist/{index-De5Tn61v.d.mts → index-Cw7CQGG8.d.mts} +8 -3
- package/dist/index.css +560 -180
- package/dist/index.d.mts +56 -13
- package/dist/index.d.ts +56 -13
- package/dist/index.js +4992 -2173
- package/dist/index.mjs +18 -12
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +48 -23
- package/dist/internal.mjs +2 -2
- package/dist/{loaded-QAIOZVXW.mjs → loaded-6K36DBBN.mjs} +6 -6
- package/dist/{loaded-FVWRAJR3.css → loaded-CA3Q7UHH.css} +7 -7
- package/dist/{loaded-A7IXFU7M.mjs → loaded-GZTG57BI.mjs} +6 -6
- package/dist/{loaded-7EVGM4NA.mjs → loaded-SBKSTOMK.mjs} +6 -6
- package/dist/no-external.css +560 -180
- package/dist/no-external.d.mts +4 -4
- package/dist/no-external.d.ts +4 -4
- package/dist/no-external.js +4992 -2173
- package/dist/no-external.mjs +18 -12
- package/dist/rsc.d.mts +4 -3
- package/dist/rsc.d.ts +4 -3
- package/dist/rsc.js +218 -94
- package/dist/rsc.mjs +52 -22
- package/dist/{walk-tree-CWrsBHHe.d.ts → walk-tree-COvy_ERJ.d.ts} +1 -1
- package/dist/{walk-tree-BrW9VQ_t.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,23 +1,23 @@
|
|
|
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-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-SBDTCWI2.mjs";
|
|
17
|
+
import "./chunk-Z2MS6UIF.mjs";
|
|
18
|
+
import "./chunk-XMN55NON.mjs";
|
|
19
|
+
import "./chunk-OT7NKYY4.mjs";
|
|
20
|
+
import "./chunk-H65MT2JK.mjs";
|
|
21
21
|
import {
|
|
22
22
|
__spreadProps,
|
|
23
23
|
__spreadValues,
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css/#css-module-data */
|
|
44
|
-
.
|
|
44
|
+
._IconButton_1pxxt_1 {
|
|
45
45
|
align-items: center;
|
|
46
46
|
background: var(--puck-iconbutton-color-bg, transparent);
|
|
47
47
|
border: none;
|
|
@@ -53,26 +53,26 @@
|
|
|
53
53
|
padding: var(--puck-iconbutton-space, var(--puck-space-1));
|
|
54
54
|
transition: background-color var(--puck-duration-fast) var(--puck-ease-exit), color var(--puck-duration-fast) var(--puck-ease-exit);
|
|
55
55
|
}
|
|
56
|
-
._IconButton--
|
|
56
|
+
._IconButton--active_1pxxt_15 {
|
|
57
57
|
color: var( --puck-iconbutton-color-icon-active, var(--puck-color-interactive) );
|
|
58
58
|
}
|
|
59
|
-
.
|
|
59
|
+
._IconButton_1pxxt_1:focus-visible {
|
|
60
60
|
outline: var(--puck-border-width-focus) solid var(--puck-color-focus-ring);
|
|
61
61
|
outline-offset: calc(var(--puck-border-width-focus) * -1);
|
|
62
62
|
}
|
|
63
63
|
@media (hover: hover) and (pointer: fine) {
|
|
64
|
-
.
|
|
65
|
-
background: var( --puck-iconbutton-color-bg-hover, var(--puck-color-interactive-neutral-hover) );
|
|
64
|
+
._IconButton_1pxxt_1:hover:not(._IconButton--disabled_1pxxt_28) {
|
|
65
|
+
background: var( --_puck-iconbutton-color-bg-hover, var( --puck-iconbutton-color-bg-hover, var(--puck-color-interactive-neutral-hover) ) );
|
|
66
66
|
color: var( --puck-iconbutton-color-icon-hover, var(--puck-color-interactive) );
|
|
67
67
|
cursor: pointer;
|
|
68
68
|
transition: none;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
.
|
|
71
|
+
._IconButton_1pxxt_1:active {
|
|
72
72
|
background: var( --puck-iconbutton-color-bg-active, var(--puck-color-interactive-soft) );
|
|
73
73
|
transition: none;
|
|
74
74
|
}
|
|
75
|
-
._IconButton--
|
|
75
|
+
._IconButton--disabled_1pxxt_28 {
|
|
76
76
|
color: var( --puck-iconbutton-color-icon-disabled, var(--puck-color-text-subtle) );
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -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;
|
|
@@ -359,6 +411,12 @@ type PuckContext = {
|
|
|
359
411
|
type DefaultRootFieldProps = {
|
|
360
412
|
title?: string;
|
|
361
413
|
};
|
|
414
|
+
/**
|
|
415
|
+
* Merge the default root field props into user-provided root props, letting
|
|
416
|
+
* the user's props take precedence. Using a plain intersection would turn an
|
|
417
|
+
* overridden `title` (e.g. `number`) into `never` (`number & string`).
|
|
418
|
+
*/
|
|
419
|
+
type WithDefaultRootFieldProps<RootProps> = RootProps & Omit<DefaultRootFieldProps, keyof RootProps>;
|
|
362
420
|
type DefaultRootRenderProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = WithPuckProps<WithChildren<Props>>;
|
|
363
421
|
type DefaultRootProps = DefaultRootRenderProps;
|
|
364
422
|
type DefaultComponentProps = {
|
|
@@ -380,7 +438,7 @@ type UserGenerics<UserConfig extends Config = Config, UserParams extends Extract
|
|
|
380
438
|
UserConfig: UserConfig;
|
|
381
439
|
UserParams: UserParams;
|
|
382
440
|
UserProps: UserParams["props"];
|
|
383
|
-
UserRootProps: UserParams["rootProps"]
|
|
441
|
+
UserRootProps: WithDefaultRootFieldProps<UserParams["rootProps"]>;
|
|
384
442
|
UserData: UserData;
|
|
385
443
|
UserAppState: UserAppState;
|
|
386
444
|
UserPublicAppState: UserPublicAppState;
|
|
@@ -393,7 +451,7 @@ type ExtractField<UserField extends {
|
|
|
393
451
|
type: T;
|
|
394
452
|
}>;
|
|
395
453
|
|
|
396
|
-
type SlotComponent = (props?:
|
|
454
|
+
type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
|
|
397
455
|
type PuckComponent<Props> = (props: WithId<WithPuckProps<{
|
|
398
456
|
[K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
|
|
399
457
|
}>>) => JSX.Element;
|
|
@@ -409,6 +467,9 @@ UserField extends BaseField = {}> = {
|
|
|
409
467
|
label?: string;
|
|
410
468
|
defaultProps?: FieldProps;
|
|
411
469
|
fields?: Fields<FieldProps, UserField>;
|
|
470
|
+
renderFields?: RenderFunc<{
|
|
471
|
+
fields: Partial<Record<keyof FieldProps, ReactNode>>;
|
|
472
|
+
}>;
|
|
412
473
|
permissions?: Partial<Permissions>;
|
|
413
474
|
inline?: boolean;
|
|
414
475
|
resolveFields?: (data: DataShape, params: {
|
|
@@ -468,7 +529,7 @@ type DefaultComponents = Record<string, any>;
|
|
|
468
529
|
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>;
|
|
469
530
|
type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends ConfigInternal<infer PropsOrParams, infer RootProps, infer CategoryName, infer UserField> ? {
|
|
470
531
|
props: PropsOrParams;
|
|
471
|
-
rootProps: RootProps
|
|
532
|
+
rootProps: WithDefaultRootFieldProps<RootProps>;
|
|
472
533
|
categoryNames: CategoryName;
|
|
473
534
|
field: UserField extends {
|
|
474
535
|
type: string;
|
|
@@ -556,6 +617,8 @@ type UiState = {
|
|
|
556
617
|
expanded?: boolean;
|
|
557
618
|
}>;
|
|
558
619
|
isDragging: boolean;
|
|
620
|
+
/** Outline items whose children are shown, keyed by item id */
|
|
621
|
+
itemExpanded?: Record<string, boolean>;
|
|
559
622
|
viewports: {
|
|
560
623
|
current: {
|
|
561
624
|
width: number | "100%";
|
|
@@ -564,6 +627,7 @@ type UiState = {
|
|
|
564
627
|
controlsVisible: boolean;
|
|
565
628
|
options: Viewport[];
|
|
566
629
|
};
|
|
630
|
+
expandedFieldGroups: Record<string, boolean>;
|
|
567
631
|
field: {
|
|
568
632
|
focus?: string | null;
|
|
569
633
|
metadata?: Record<string, any>;
|
|
@@ -670,10 +734,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
670
734
|
children: ReactNode;
|
|
671
735
|
isLoading: boolean;
|
|
672
736
|
itemSelector?: ItemSelector | null;
|
|
737
|
+
fields: Partial<Record<string, ReactNode>>;
|
|
673
738
|
}>;
|
|
674
739
|
fieldLabel: RenderFunc<{
|
|
675
740
|
children?: ReactNode;
|
|
676
741
|
icon?: ReactNode;
|
|
742
|
+
endIcon?: ReactNode;
|
|
677
743
|
label: string;
|
|
678
744
|
el?: "label" | "div";
|
|
679
745
|
readOnly?: boolean;
|
|
@@ -705,12 +771,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
705
771
|
}>;
|
|
706
772
|
type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
|
|
707
773
|
type: string;
|
|
708
|
-
} = Field | G["UserField"]> =
|
|
774
|
+
} = Field | G["UserField"]> = {
|
|
709
775
|
[Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
|
|
710
776
|
children: ReactNode;
|
|
711
777
|
name: string;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
778
|
+
}> | null;
|
|
779
|
+
};
|
|
714
780
|
|
|
715
781
|
type Direction = "left" | "right" | "up" | "down" | null;
|
|
716
782
|
type DragAxis = "dynamic" | "y" | "x";
|
|
@@ -736,6 +802,19 @@ type IframeConfig = {
|
|
|
736
802
|
waitForStyles?: boolean;
|
|
737
803
|
syncHostStyles?: boolean;
|
|
738
804
|
};
|
|
805
|
+
type DndBehavior = "auto" | "fluid" | "static";
|
|
806
|
+
type DndConfig = {
|
|
807
|
+
disableAutoScroll?: boolean;
|
|
808
|
+
disableOutlineDrag?: boolean;
|
|
809
|
+
/**
|
|
810
|
+
* - `auto` (default): fluid drags within a slot, switching to a static
|
|
811
|
+
* line placeholder when dragging between slots or inserting a new item
|
|
812
|
+
* - `fluid`: always animate sibling items during a drag
|
|
813
|
+
* - `static`: always show a line placeholder during a drag, only
|
|
814
|
+
* animating sibling items on drop
|
|
815
|
+
*/
|
|
816
|
+
behavior?: DndBehavior;
|
|
817
|
+
};
|
|
739
818
|
type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
|
|
740
819
|
type Plugin<UserConfig extends Config = Config> = {
|
|
741
820
|
name?: string;
|
|
@@ -837,4 +916,4 @@ type PuckAction = {
|
|
|
837
916
|
recordHistory?: boolean;
|
|
838
917
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
839
918
|
|
|
840
|
-
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;
|
|
@@ -359,6 +411,12 @@ type PuckContext = {
|
|
|
359
411
|
type DefaultRootFieldProps = {
|
|
360
412
|
title?: string;
|
|
361
413
|
};
|
|
414
|
+
/**
|
|
415
|
+
* Merge the default root field props into user-provided root props, letting
|
|
416
|
+
* the user's props take precedence. Using a plain intersection would turn an
|
|
417
|
+
* overridden `title` (e.g. `number`) into `never` (`number & string`).
|
|
418
|
+
*/
|
|
419
|
+
type WithDefaultRootFieldProps<RootProps> = RootProps & Omit<DefaultRootFieldProps, keyof RootProps>;
|
|
362
420
|
type DefaultRootRenderProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = WithPuckProps<WithChildren<Props>>;
|
|
363
421
|
type DefaultRootProps = DefaultRootRenderProps;
|
|
364
422
|
type DefaultComponentProps = {
|
|
@@ -380,7 +438,7 @@ type UserGenerics<UserConfig extends Config = Config, UserParams extends Extract
|
|
|
380
438
|
UserConfig: UserConfig;
|
|
381
439
|
UserParams: UserParams;
|
|
382
440
|
UserProps: UserParams["props"];
|
|
383
|
-
UserRootProps: UserParams["rootProps"]
|
|
441
|
+
UserRootProps: WithDefaultRootFieldProps<UserParams["rootProps"]>;
|
|
384
442
|
UserData: UserData;
|
|
385
443
|
UserAppState: UserAppState;
|
|
386
444
|
UserPublicAppState: UserPublicAppState;
|
|
@@ -393,7 +451,7 @@ type ExtractField<UserField extends {
|
|
|
393
451
|
type: T;
|
|
394
452
|
}>;
|
|
395
453
|
|
|
396
|
-
type SlotComponent = (props?:
|
|
454
|
+
type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
|
|
397
455
|
type PuckComponent<Props> = (props: WithId<WithPuckProps<{
|
|
398
456
|
[K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
|
|
399
457
|
}>>) => JSX.Element;
|
|
@@ -409,6 +467,9 @@ UserField extends BaseField = {}> = {
|
|
|
409
467
|
label?: string;
|
|
410
468
|
defaultProps?: FieldProps;
|
|
411
469
|
fields?: Fields<FieldProps, UserField>;
|
|
470
|
+
renderFields?: RenderFunc<{
|
|
471
|
+
fields: Partial<Record<keyof FieldProps, ReactNode>>;
|
|
472
|
+
}>;
|
|
412
473
|
permissions?: Partial<Permissions>;
|
|
413
474
|
inline?: boolean;
|
|
414
475
|
resolveFields?: (data: DataShape, params: {
|
|
@@ -468,7 +529,7 @@ type DefaultComponents = Record<string, any>;
|
|
|
468
529
|
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>;
|
|
469
530
|
type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends ConfigInternal<infer PropsOrParams, infer RootProps, infer CategoryName, infer UserField> ? {
|
|
470
531
|
props: PropsOrParams;
|
|
471
|
-
rootProps: RootProps
|
|
532
|
+
rootProps: WithDefaultRootFieldProps<RootProps>;
|
|
472
533
|
categoryNames: CategoryName;
|
|
473
534
|
field: UserField extends {
|
|
474
535
|
type: string;
|
|
@@ -556,6 +617,8 @@ type UiState = {
|
|
|
556
617
|
expanded?: boolean;
|
|
557
618
|
}>;
|
|
558
619
|
isDragging: boolean;
|
|
620
|
+
/** Outline items whose children are shown, keyed by item id */
|
|
621
|
+
itemExpanded?: Record<string, boolean>;
|
|
559
622
|
viewports: {
|
|
560
623
|
current: {
|
|
561
624
|
width: number | "100%";
|
|
@@ -564,6 +627,7 @@ type UiState = {
|
|
|
564
627
|
controlsVisible: boolean;
|
|
565
628
|
options: Viewport[];
|
|
566
629
|
};
|
|
630
|
+
expandedFieldGroups: Record<string, boolean>;
|
|
567
631
|
field: {
|
|
568
632
|
focus?: string | null;
|
|
569
633
|
metadata?: Record<string, any>;
|
|
@@ -670,10 +734,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
670
734
|
children: ReactNode;
|
|
671
735
|
isLoading: boolean;
|
|
672
736
|
itemSelector?: ItemSelector | null;
|
|
737
|
+
fields: Partial<Record<string, ReactNode>>;
|
|
673
738
|
}>;
|
|
674
739
|
fieldLabel: RenderFunc<{
|
|
675
740
|
children?: ReactNode;
|
|
676
741
|
icon?: ReactNode;
|
|
742
|
+
endIcon?: ReactNode;
|
|
677
743
|
label: string;
|
|
678
744
|
el?: "label" | "div";
|
|
679
745
|
readOnly?: boolean;
|
|
@@ -705,12 +771,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
705
771
|
}>;
|
|
706
772
|
type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
|
|
707
773
|
type: string;
|
|
708
|
-
} = Field | G["UserField"]> =
|
|
774
|
+
} = Field | G["UserField"]> = {
|
|
709
775
|
[Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
|
|
710
776
|
children: ReactNode;
|
|
711
777
|
name: string;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
778
|
+
}> | null;
|
|
779
|
+
};
|
|
714
780
|
|
|
715
781
|
type Direction = "left" | "right" | "up" | "down" | null;
|
|
716
782
|
type DragAxis = "dynamic" | "y" | "x";
|
|
@@ -736,6 +802,19 @@ type IframeConfig = {
|
|
|
736
802
|
waitForStyles?: boolean;
|
|
737
803
|
syncHostStyles?: boolean;
|
|
738
804
|
};
|
|
805
|
+
type DndBehavior = "auto" | "fluid" | "static";
|
|
806
|
+
type DndConfig = {
|
|
807
|
+
disableAutoScroll?: boolean;
|
|
808
|
+
disableOutlineDrag?: boolean;
|
|
809
|
+
/**
|
|
810
|
+
* - `auto` (default): fluid drags within a slot, switching to a static
|
|
811
|
+
* line placeholder when dragging between slots or inserting a new item
|
|
812
|
+
* - `fluid`: always animate sibling items during a drag
|
|
813
|
+
* - `static`: always show a line placeholder during a drag, only
|
|
814
|
+
* animating sibling items on drop
|
|
815
|
+
*/
|
|
816
|
+
behavior?: DndBehavior;
|
|
817
|
+
};
|
|
739
818
|
type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
|
|
740
819
|
type Plugin<UserConfig extends Config = Config> = {
|
|
741
820
|
name?: string;
|
|
@@ -837,4 +916,4 @@ type PuckAction = {
|
|
|
837
916
|
recordHistory?: boolean;
|
|
838
917
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
839
918
|
|
|
840
|
-
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 };
|