@puckeditor/core 0.24.0-canary.148f3cdd → 0.24.0-canary.2f5dc0a0
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/README.md +1 -34
- package/dist/{Editor-T7TKW6NT.css → Editor-CSDMK75G.css} +24 -16
- package/dist/{Editor-QKVNUOPH.mjs → Editor-LJSLIQQP.mjs} +8 -8
- package/dist/{Render-KIF7JWS4.mjs → Render-H3USS5FU.mjs} +1 -1
- package/dist/{actions-DzP_zhsF.d.ts → actions-D_nE8NdE.d.mts} +21 -4
- package/dist/{actions-DzP_zhsF.d.mts → actions-D_nE8NdE.d.ts} +21 -4
- package/dist/{chunk-XAJK3MOG.mjs → chunk-3GJJSXCL.mjs} +84 -51
- package/dist/{chunk-CKY5CKSU.mjs → chunk-5L3MP6BU.mjs} +7 -7
- package/dist/{chunk-XTIXX7I3.mjs → chunk-FWBFOZBF.mjs} +185 -135
- package/dist/{chunk-ELZ5SBY3.mjs → chunk-HCKVNDLU.mjs} +2425 -1374
- package/dist/{chunk-PJDBGMYG.mjs → chunk-M6VGZJMS.mjs} +1 -1
- package/dist/{chunk-EHTFXUBU.mjs → chunk-OGTX6PQW.mjs} +1 -1
- package/dist/{chunk-PFNS3HDM.mjs → chunk-UIJZMSVU.mjs} +3 -3
- package/dist/{chunk-ZRAERXB4.mjs → chunk-XMN55NON.mjs} +3 -2
- package/dist/{chunk-NBTE2AWP.mjs → chunk-ZO7CHPM6.mjs} +1 -1
- package/dist/{chunk-2CNEFIQP.mjs → chunk-ZOLLDKZQ.mjs} +4 -1
- package/dist/{full-AAZK6KLI.css → full-F3CBWTKQ.css} +24 -16
- package/dist/{full-3BPAMA2C.mjs → full-H4FZ3HN3.mjs} +6 -6
- package/dist/{index-Cv-eVWCd.d.ts → index-BSR01WBw.d.mts} +2 -1
- package/dist/{index-poi3aTIz.d.mts → index-GchMd1Kw.d.ts} +2 -1
- package/dist/index.css +328 -96
- package/dist/index.d.mts +59 -8
- package/dist/index.d.ts +59 -8
- package/dist/index.js +5235 -4095
- package/dist/index.mjs +17 -9
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/{loaded-OZ2F7R6I.mjs → loaded-P5HN7RJY.mjs} +3 -3
- package/dist/{loaded-TUHXN2Y2.mjs → loaded-PFIA543C.mjs} +3 -3
- package/dist/{loaded-CA3Q7UHH.css → loaded-UDM5EYPG.css} +24 -16
- package/dist/{loaded-IRK2RWX3.mjs → loaded-WFQRY2XL.mjs} +3 -3
- package/dist/no-external.css +328 -96
- package/dist/no-external.d.mts +4 -4
- package/dist/no-external.d.ts +4 -4
- package/dist/no-external.js +5235 -4095
- package/dist/no-external.mjs +17 -9
- package/dist/rsc.d.mts +4 -3
- package/dist/rsc.d.ts +4 -3
- package/dist/rsc.js +137 -68
- package/dist/rsc.mjs +50 -20
- package/dist/{walk-tree-iWDqHBcM.d.mts → walk-tree-CTTFe0Gt.d.mts} +1 -1
- package/dist/{walk-tree-Bu3IHwm_.d.ts → walk-tree-YaheG6K6.d.ts} +1 -1
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -82,34 +82,6 @@ export function Page() {
|
|
|
82
82
|
}
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
## CLI
|
|
86
|
-
|
|
87
|
-
Set up Puck and Puck Cloud in a new or existing Next.js, React Router, TanStack Start, vinext, Vite or Astro app, or a Hono or Express server. Built for coding agents, friendly for humans:
|
|
88
|
-
|
|
89
|
-
```sh
|
|
90
|
-
npx @puckeditor/cli init
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
See the [CLI docs](https://puckeditor.com/docs/cli) for agent usage.
|
|
94
|
-
|
|
95
|
-
## For agents
|
|
96
|
-
|
|
97
|
-
Puck is built to be set up and used by coding agents as well as people. The CLI sets up Puck without prompting, and ships with the docs for its release, so agents can read the docs for the version a project uses:
|
|
98
|
-
|
|
99
|
-
```sh
|
|
100
|
-
npx @puckeditor/cli init --yes --json
|
|
101
|
-
npx @puckeditor/cli docs find "dynamic fields"
|
|
102
|
-
npx @puckeditor/cli docs cat api-reference/fields/text
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Agents with skill support can install the [Puck skill](https://github.com/puckeditor/skills):
|
|
106
|
-
|
|
107
|
-
```sh
|
|
108
|
-
npx skills add puckeditor/skills --skill puck
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
The latest docs are indexed at [llms.txt](https://puckeditor.com/llms.txt), and any page is available as markdown by adding `.md` to its URL.
|
|
112
|
-
|
|
113
85
|
## Recipes
|
|
114
86
|
|
|
115
87
|
Use `create-puck-app` to quickly spin up a a pre-configured app based on our provided [recipes](https://github.com/puckeditor/puck/tree/main/recipes):
|
|
@@ -121,12 +93,7 @@ npx create-puck-app my-app
|
|
|
121
93
|
Available recipes include:
|
|
122
94
|
|
|
123
95
|
- [**next**](https://github.com/puckeditor/puck/tree/main/recipes/next): Next.js example, using App Router and static page generation
|
|
124
|
-
- [**react-router**](https://github.com/puckeditor/puck/tree/main/recipes/react-router): React Router
|
|
125
|
-
- [**tanstack-start**](https://github.com/puckeditor/puck/tree/main/recipes/tanstack-start): [TanStack Start](https://tanstack.com/start) example, using a splat route and server functions to create pages at any level
|
|
126
|
-
- [**hono**](https://github.com/puckeditor/puck/tree/main/recipes/hono) and [**express**](https://github.com/puckeditor/puck/tree/main/recipes/express): Hono and Express servers exposing a pages API, and Puck AI in the `-ai` variants, for an editor in another app
|
|
127
|
-
- [**astro**](https://github.com/puckeditor/puck/tree/main/recipes/astro): Astro example, rendering Puck pages on the server with the Node adapter
|
|
128
|
-
- [**vite**](https://github.com/puckeditor/puck/tree/main/recipes/vite): Vite React app example, with a small Hono server for pages
|
|
129
|
-
- [**vinext**](https://github.com/puckeditor/puck/tree/main/recipes/vinext): [vinext](https://github.com/cloudflare/vinext) example, running the Next.js App Router on Vite
|
|
96
|
+
- [**react-router**](https://github.com/puckeditor/puck/tree/main/recipes/react-router): React Router v7 app example, using dynamic routes to create pages at any level
|
|
130
97
|
|
|
131
98
|
## Community
|
|
132
99
|
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css/#css-module-data */
|
|
102
|
-
.
|
|
102
|
+
._ActionBar_gr1cb_1 {
|
|
103
103
|
align-items: center;
|
|
104
104
|
cursor: default;
|
|
105
105
|
display: flex;
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
font-family: var(--puck-font-family);
|
|
115
115
|
min-height: 26px;
|
|
116
116
|
}
|
|
117
|
-
._ActionBar-
|
|
117
|
+
._ActionBar-label_gr1cb_17 {
|
|
118
118
|
color: var(--puck-actionbar-color-text, var(--puck-color-text-inverse));
|
|
119
119
|
font-size: var(--puck-actionbar-font-size, var(--puck-font-size-xxxs));
|
|
120
120
|
opacity: var(--puck-actionbar-opacity-text, var(--puck-opacity-text-inverse));
|
|
@@ -126,13 +126,13 @@
|
|
|
126
126
|
text-overflow: ellipsis;
|
|
127
127
|
white-space: nowrap;
|
|
128
128
|
}
|
|
129
|
-
.
|
|
129
|
+
._ActionBarAction_gr1cb_30 + ._ActionBar-label_gr1cb_17 {
|
|
130
130
|
padding-inline-start: 0;
|
|
131
131
|
}
|
|
132
|
-
._ActionBar-
|
|
132
|
+
._ActionBar-label_gr1cb_17 + ._ActionBarAction_gr1cb_30 {
|
|
133
133
|
margin-inline-start: calc(var(--puck-space-1) * -1);
|
|
134
134
|
}
|
|
135
|
-
._ActionBar-
|
|
135
|
+
._ActionBar-group_gr1cb_38 {
|
|
136
136
|
align-items: center;
|
|
137
137
|
border-inline-start: var(--puck-border-width-hairline) solid var(--puck-actionbar-color-separator, var(--puck-color-border-inverse));
|
|
138
138
|
display: flex;
|
|
@@ -140,13 +140,13 @@
|
|
|
140
140
|
padding-inline-start: var(--puck-space-1);
|
|
141
141
|
padding-inline-end: var(--puck-space-1);
|
|
142
142
|
}
|
|
143
|
-
._ActionBar-
|
|
143
|
+
._ActionBar-group_gr1cb_38:first-of-type {
|
|
144
144
|
border-inline-start: 0;
|
|
145
145
|
}
|
|
146
|
-
._ActionBar-
|
|
146
|
+
._ActionBar-group_gr1cb_38:empty {
|
|
147
147
|
display: none;
|
|
148
148
|
}
|
|
149
|
-
.
|
|
149
|
+
._ActionBarAction_gr1cb_30 {
|
|
150
150
|
background: transparent;
|
|
151
151
|
border: none;
|
|
152
152
|
color: var(--puck-actionbar-color-text, var(--puck-color-text-inverse));
|
|
@@ -162,35 +162,43 @@
|
|
|
162
162
|
opacity: var(--puck-actionbar-opacity-text, var(--puck-opacity-text-inverse));
|
|
163
163
|
transition: color var(--puck-duration-fast) var(--puck-ease-exit), opacity var(--puck-duration-fast) var(--puck-ease-exit);
|
|
164
164
|
}
|
|
165
|
-
._ActionBarAction--
|
|
165
|
+
._ActionBarAction--disabled_gr1cb_74 {
|
|
166
166
|
cursor: auto;
|
|
167
167
|
color: var( --puck-actionbar-color-action-disabled, var(--puck-color-text-inverse) );
|
|
168
168
|
opacity: var(--puck-actionbar-opacity-action-disabled, 0.54);
|
|
169
169
|
}
|
|
170
|
-
.
|
|
170
|
+
._ActionBarAction--grab_gr1cb_83 {
|
|
171
|
+
cursor: grab;
|
|
172
|
+
touch-action: none;
|
|
173
|
+
}
|
|
174
|
+
._ActionBarAction-icon_gr1cb_88 {
|
|
175
|
+
height: var(--puck-actionbar-action-size, var(--puck-icon-size-s));
|
|
176
|
+
width: var(--puck-actionbar-action-size, var(--puck-icon-size-s));
|
|
177
|
+
}
|
|
178
|
+
._ActionBarAction_gr1cb_30 svg {
|
|
171
179
|
max-width: none !important;
|
|
172
180
|
}
|
|
173
|
-
.
|
|
181
|
+
._ActionBarAction_gr1cb_30:focus-visible {
|
|
174
182
|
outline: var(--puck-border-width-focus) solid var(--puck-color-focus-ring);
|
|
175
183
|
outline-offset: calc(var(--puck-border-width-focus) * -1);
|
|
176
184
|
}
|
|
177
185
|
@media (hover: hover) and (pointer: fine) {
|
|
178
|
-
.
|
|
186
|
+
._ActionBarAction_gr1cb_30:hover:not(._ActionBarAction--disabled_gr1cb_74) {
|
|
179
187
|
color: var( --puck-actionbar-color-action-hover, var(--puck-color-interactive-inverse-hover) );
|
|
180
188
|
opacity: 1;
|
|
181
189
|
transition: none;
|
|
182
190
|
}
|
|
183
191
|
}
|
|
184
|
-
.
|
|
185
|
-
._ActionBarAction--
|
|
192
|
+
._ActionBarAction_gr1cb_30:active:not(._ActionBarAction--disabled_gr1cb_74),
|
|
193
|
+
._ActionBarAction--active_gr1cb_114 {
|
|
186
194
|
color: var( --puck-actionbar-color-action-active, var(--puck-color-interactive-inverse-active) );
|
|
187
195
|
opacity: 1;
|
|
188
196
|
transition: none;
|
|
189
197
|
}
|
|
190
|
-
._ActionBar-
|
|
198
|
+
._ActionBar-group_gr1cb_38 * {
|
|
191
199
|
margin: 0;
|
|
192
200
|
}
|
|
193
|
-
._ActionBar-
|
|
201
|
+
._ActionBar-separator_gr1cb_127 {
|
|
194
202
|
background: var( --puck-actionbar-color-separator, var(--puck-color-border-inverse) );
|
|
195
203
|
margin-inline: var(--puck-space-1);
|
|
196
204
|
width: var( --puck-border-width-hairline );
|
|
@@ -1,21 +1,21 @@
|
|
|
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-UIJZMSVU.mjs";
|
|
8
8
|
import "./chunk-H635BA2V.mjs";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-5L3MP6BU.mjs";
|
|
10
|
+
import "./chunk-OGTX6PQW.mjs";
|
|
11
|
+
import "./chunk-ZO7CHPM6.mjs";
|
|
12
|
+
import "./chunk-M6VGZJMS.mjs";
|
|
13
13
|
import {
|
|
14
14
|
useAppStore,
|
|
15
15
|
useAppStoreApi
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FWBFOZBF.mjs";
|
|
17
17
|
import "./chunk-Z2MS6UIF.mjs";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-XMN55NON.mjs";
|
|
19
19
|
import "./chunk-OT7NKYY4.mjs";
|
|
20
20
|
import "./chunk-H65MT2JK.mjs";
|
|
21
21
|
import {
|
|
@@ -53,7 +53,7 @@ type NonForwardableProps = {
|
|
|
53
53
|
/**
|
|
54
54
|
* Keys internally consumed by Puck and never forwarded to `as`.
|
|
55
55
|
*/
|
|
56
|
-
type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata";
|
|
56
|
+
type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata" | "fieldTransforms";
|
|
57
57
|
/**
|
|
58
58
|
* Additional props forwarded to the element or component provided via `as`,
|
|
59
59
|
* typed against it.
|
|
@@ -272,6 +272,10 @@ interface RadioField extends BaseField {
|
|
|
272
272
|
type: "radio";
|
|
273
273
|
options: FieldOptions;
|
|
274
274
|
}
|
|
275
|
+
interface CheckboxField extends BaseField {
|
|
276
|
+
type: "checkbox";
|
|
277
|
+
options: FieldOptions;
|
|
278
|
+
}
|
|
275
279
|
interface RichtextField<UserSelector extends RichTextSelector = RichTextSelector> extends BaseField {
|
|
276
280
|
type: "richtext";
|
|
277
281
|
contentEditable?: boolean;
|
|
@@ -314,6 +318,7 @@ interface ObjectField<Props extends any = {
|
|
|
314
318
|
[key: string]: any;
|
|
315
319
|
}, UserField extends {} = {}> extends BaseField {
|
|
316
320
|
type: "object";
|
|
321
|
+
expandable?: boolean;
|
|
317
322
|
objectFields: {
|
|
318
323
|
[SubPropName in keyof Props]: UserField extends {
|
|
319
324
|
type: PropertyKey;
|
|
@@ -378,7 +383,7 @@ interface SlotField extends BaseField {
|
|
|
378
383
|
allow?: string[];
|
|
379
384
|
disallow?: string[];
|
|
380
385
|
}
|
|
381
|
-
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 {
|
|
382
387
|
[key: string]: any;
|
|
383
388
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
384
389
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
|
|
@@ -462,6 +467,9 @@ UserField extends BaseField = {}> = {
|
|
|
462
467
|
label?: string;
|
|
463
468
|
defaultProps?: FieldProps;
|
|
464
469
|
fields?: Fields<FieldProps, UserField>;
|
|
470
|
+
renderFields?: RenderFunc<{
|
|
471
|
+
fields: Partial<Record<keyof FieldProps, ReactNode>>;
|
|
472
|
+
}>;
|
|
465
473
|
permissions?: Partial<Permissions>;
|
|
466
474
|
inline?: boolean;
|
|
467
475
|
resolveFields?: (data: DataShape, params: {
|
|
@@ -619,10 +627,13 @@ type UiState = {
|
|
|
619
627
|
controlsVisible: boolean;
|
|
620
628
|
options: Viewport[];
|
|
621
629
|
};
|
|
630
|
+
expandedFieldGroups: Record<string, boolean>;
|
|
622
631
|
field: {
|
|
623
632
|
focus?: string | null;
|
|
624
633
|
metadata?: Record<string, any>;
|
|
625
634
|
};
|
|
635
|
+
/** The selected field tab. Shows the first available tab when `null`. */
|
|
636
|
+
fieldTab?: string | number | null;
|
|
626
637
|
plugin: {
|
|
627
638
|
current: string | null;
|
|
628
639
|
};
|
|
@@ -716,6 +727,8 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
716
727
|
label?: string;
|
|
717
728
|
children: ReactNode;
|
|
718
729
|
parentAction: ReactNode;
|
|
730
|
+
dragHandle?: ReactNode;
|
|
731
|
+
dragHandleRef?: (element: Element | null) => void;
|
|
719
732
|
}>;
|
|
720
733
|
headerActions: RenderFunc<{
|
|
721
734
|
children: ReactNode;
|
|
@@ -725,10 +738,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
725
738
|
children: ReactNode;
|
|
726
739
|
isLoading: boolean;
|
|
727
740
|
itemSelector?: ItemSelector | null;
|
|
741
|
+
fields: Partial<Record<string, ReactNode>>;
|
|
728
742
|
}>;
|
|
729
743
|
fieldLabel: RenderFunc<{
|
|
730
744
|
children?: ReactNode;
|
|
731
745
|
icon?: ReactNode;
|
|
746
|
+
endIcon?: ReactNode;
|
|
732
747
|
label: string;
|
|
733
748
|
el?: "label" | "div";
|
|
734
749
|
readOnly?: boolean;
|
|
@@ -795,9 +810,11 @@ type DndBehavior = "auto" | "fluid" | "static";
|
|
|
795
810
|
type DndConfig = {
|
|
796
811
|
disableAutoScroll?: boolean;
|
|
797
812
|
disableOutlineDrag?: boolean;
|
|
813
|
+
enableDragHandle?: boolean;
|
|
798
814
|
/**
|
|
799
815
|
* - `auto` (default): fluid drags within a slot, switching to a static
|
|
800
|
-
* line placeholder when dragging between slots
|
|
816
|
+
* line placeholder when dragging between slots, inserting a new item,
|
|
817
|
+
* or dragging from the action bar drag handle
|
|
801
818
|
* - `fluid`: always animate sibling items during a drag
|
|
802
819
|
* - `static`: always show a line placeholder during a drag, only
|
|
803
820
|
* animating sibling items on drop
|
|
@@ -905,4 +922,4 @@ type PuckAction = {
|
|
|
905
922
|
recordHistory?: boolean;
|
|
906
923
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
907
924
|
|
|
908
|
-
export { type
|
|
925
|
+
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 };
|
|
@@ -53,7 +53,7 @@ type NonForwardableProps = {
|
|
|
53
53
|
/**
|
|
54
54
|
* Keys internally consumed by Puck and never forwarded to `as`.
|
|
55
55
|
*/
|
|
56
|
-
type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata";
|
|
56
|
+
type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata" | "fieldTransforms";
|
|
57
57
|
/**
|
|
58
58
|
* Additional props forwarded to the element or component provided via `as`,
|
|
59
59
|
* typed against it.
|
|
@@ -272,6 +272,10 @@ interface RadioField extends BaseField {
|
|
|
272
272
|
type: "radio";
|
|
273
273
|
options: FieldOptions;
|
|
274
274
|
}
|
|
275
|
+
interface CheckboxField extends BaseField {
|
|
276
|
+
type: "checkbox";
|
|
277
|
+
options: FieldOptions;
|
|
278
|
+
}
|
|
275
279
|
interface RichtextField<UserSelector extends RichTextSelector = RichTextSelector> extends BaseField {
|
|
276
280
|
type: "richtext";
|
|
277
281
|
contentEditable?: boolean;
|
|
@@ -314,6 +318,7 @@ interface ObjectField<Props extends any = {
|
|
|
314
318
|
[key: string]: any;
|
|
315
319
|
}, UserField extends {} = {}> extends BaseField {
|
|
316
320
|
type: "object";
|
|
321
|
+
expandable?: boolean;
|
|
317
322
|
objectFields: {
|
|
318
323
|
[SubPropName in keyof Props]: UserField extends {
|
|
319
324
|
type: PropertyKey;
|
|
@@ -378,7 +383,7 @@ interface SlotField extends BaseField {
|
|
|
378
383
|
allow?: string[];
|
|
379
384
|
disallow?: string[];
|
|
380
385
|
}
|
|
381
|
-
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 {
|
|
382
387
|
[key: string]: any;
|
|
383
388
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
384
389
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
|
|
@@ -462,6 +467,9 @@ UserField extends BaseField = {}> = {
|
|
|
462
467
|
label?: string;
|
|
463
468
|
defaultProps?: FieldProps;
|
|
464
469
|
fields?: Fields<FieldProps, UserField>;
|
|
470
|
+
renderFields?: RenderFunc<{
|
|
471
|
+
fields: Partial<Record<keyof FieldProps, ReactNode>>;
|
|
472
|
+
}>;
|
|
465
473
|
permissions?: Partial<Permissions>;
|
|
466
474
|
inline?: boolean;
|
|
467
475
|
resolveFields?: (data: DataShape, params: {
|
|
@@ -619,10 +627,13 @@ type UiState = {
|
|
|
619
627
|
controlsVisible: boolean;
|
|
620
628
|
options: Viewport[];
|
|
621
629
|
};
|
|
630
|
+
expandedFieldGroups: Record<string, boolean>;
|
|
622
631
|
field: {
|
|
623
632
|
focus?: string | null;
|
|
624
633
|
metadata?: Record<string, any>;
|
|
625
634
|
};
|
|
635
|
+
/** The selected field tab. Shows the first available tab when `null`. */
|
|
636
|
+
fieldTab?: string | number | null;
|
|
626
637
|
plugin: {
|
|
627
638
|
current: string | null;
|
|
628
639
|
};
|
|
@@ -716,6 +727,8 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
716
727
|
label?: string;
|
|
717
728
|
children: ReactNode;
|
|
718
729
|
parentAction: ReactNode;
|
|
730
|
+
dragHandle?: ReactNode;
|
|
731
|
+
dragHandleRef?: (element: Element | null) => void;
|
|
719
732
|
}>;
|
|
720
733
|
headerActions: RenderFunc<{
|
|
721
734
|
children: ReactNode;
|
|
@@ -725,10 +738,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
|
|
725
738
|
children: ReactNode;
|
|
726
739
|
isLoading: boolean;
|
|
727
740
|
itemSelector?: ItemSelector | null;
|
|
741
|
+
fields: Partial<Record<string, ReactNode>>;
|
|
728
742
|
}>;
|
|
729
743
|
fieldLabel: RenderFunc<{
|
|
730
744
|
children?: ReactNode;
|
|
731
745
|
icon?: ReactNode;
|
|
746
|
+
endIcon?: ReactNode;
|
|
732
747
|
label: string;
|
|
733
748
|
el?: "label" | "div";
|
|
734
749
|
readOnly?: boolean;
|
|
@@ -795,9 +810,11 @@ type DndBehavior = "auto" | "fluid" | "static";
|
|
|
795
810
|
type DndConfig = {
|
|
796
811
|
disableAutoScroll?: boolean;
|
|
797
812
|
disableOutlineDrag?: boolean;
|
|
813
|
+
enableDragHandle?: boolean;
|
|
798
814
|
/**
|
|
799
815
|
* - `auto` (default): fluid drags within a slot, switching to a static
|
|
800
|
-
* line placeholder when dragging between slots
|
|
816
|
+
* line placeholder when dragging between slots, inserting a new item,
|
|
817
|
+
* or dragging from the action bar drag handle
|
|
801
818
|
* - `fluid`: always animate sibling items during a drag
|
|
802
819
|
* - `static`: always show a line placeholder during a drag, only
|
|
803
820
|
* animating sibling items on drop
|
|
@@ -905,4 +922,4 @@ type PuckAction = {
|
|
|
905
922
|
recordHistory?: boolean;
|
|
906
923
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
907
924
|
|
|
908
|
-
export { type
|
|
925
|
+
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 };
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
defaultAppState,
|
|
6
6
|
resolveComponentData
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XMN55NON.mjs";
|
|
8
8
|
import {
|
|
9
9
|
get_class_name_factory_default
|
|
10
10
|
} from "./chunk-OT7NKYY4.mjs";
|
|
@@ -225,16 +225,12 @@ function resolveAllData(_0, _1) {
|
|
|
225
225
|
"force",
|
|
226
226
|
parent,
|
|
227
227
|
root,
|
|
228
|
-
cacheStore
|
|
228
|
+
cacheStore,
|
|
229
|
+
// Slot children resolve through resolveNode, not a second walk of
|
|
230
|
+
// the resolved tree, so each resolveData runs once.
|
|
231
|
+
(child, resolvedParent) => resolveNode(child, resolvedParent, root)
|
|
229
232
|
)).node;
|
|
230
233
|
const resolvedAsComponent = toComponent(resolved);
|
|
231
|
-
const resolvedDeepPromise = mapFields(
|
|
232
|
-
resolved,
|
|
233
|
-
{
|
|
234
|
-
slot: ({ value }) => processContent(value, resolvedAsComponent, root)
|
|
235
|
-
},
|
|
236
|
-
config
|
|
237
|
-
);
|
|
238
234
|
let resolveZonePromises = [];
|
|
239
235
|
if (zonesByComponent[resolvedAsComponent.props.id]) {
|
|
240
236
|
resolveZonePromises = zonesByComponent[resolvedAsComponent.props.id].map(
|
|
@@ -247,10 +243,9 @@ function resolveAllData(_0, _1) {
|
|
|
247
243
|
})
|
|
248
244
|
);
|
|
249
245
|
}
|
|
250
|
-
const resolvedDeep = yield resolvedDeepPromise;
|
|
251
246
|
yield Promise.all(resolveZonePromises);
|
|
252
|
-
onResolveEnd == null ? void 0 : onResolveEnd(
|
|
253
|
-
return
|
|
247
|
+
onResolveEnd == null ? void 0 : onResolveEnd(resolvedAsComponent);
|
|
248
|
+
return resolved;
|
|
254
249
|
});
|
|
255
250
|
const processContent = (content, parent, root) => __async(null, null, function* () {
|
|
256
251
|
return Promise.all(content.map((item) => resolveNode(item, parent, root)));
|
|
@@ -281,7 +276,8 @@ var CONSUMED_PROP_KEYS = {
|
|
|
281
276
|
as: true,
|
|
282
277
|
content: true,
|
|
283
278
|
config: true,
|
|
284
|
-
metadata: true
|
|
279
|
+
metadata: true,
|
|
280
|
+
fieldTransforms: true
|
|
285
281
|
};
|
|
286
282
|
var NON_FORWARDABLE_PROP_KEYS = {
|
|
287
283
|
children: true,
|
|
@@ -317,23 +313,7 @@ var getDropZoneProps = (allProps) => {
|
|
|
317
313
|
};
|
|
318
314
|
};
|
|
319
315
|
|
|
320
|
-
// lib/
|
|
321
|
-
init_react_import();
|
|
322
|
-
var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
|
|
323
|
-
slot: ({ value: content, propName, field, isReadOnly }) => {
|
|
324
|
-
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
325
|
-
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
326
|
-
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
327
|
-
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
328
|
-
}, dzProps), {
|
|
329
|
-
zone: propName,
|
|
330
|
-
content
|
|
331
|
-
}));
|
|
332
|
-
return Slot;
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
// lib/use-slots.tsx
|
|
316
|
+
// lib/props/render/use-render-props.tsx
|
|
337
317
|
init_react_import();
|
|
338
318
|
|
|
339
319
|
// lib/field-transforms/use-field-transforms.tsx
|
|
@@ -377,16 +357,21 @@ function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
|
|
|
377
357
|
return mergedProps;
|
|
378
358
|
}
|
|
379
359
|
|
|
380
|
-
// lib/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
360
|
+
// lib/field-transforms/default-transforms/slot-transform.tsx
|
|
361
|
+
init_react_import();
|
|
362
|
+
var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
|
|
363
|
+
slot: ({ value: content, propName, field, isReadOnly }) => {
|
|
364
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
365
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
366
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
367
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
368
|
+
}, dzProps), {
|
|
369
|
+
zone: propName,
|
|
370
|
+
content
|
|
371
|
+
}));
|
|
372
|
+
return Slot;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
390
375
|
|
|
391
376
|
// components/RichTextEditor/lib/use-richtext-props.tsx
|
|
392
377
|
init_react_import();
|
|
@@ -427,15 +412,18 @@ var mapDeep = (source, path, render) => {
|
|
|
427
412
|
// components/RichTextEditor/lib/use-richtext-props.tsx
|
|
428
413
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
429
414
|
var RichTextRender = lazy(
|
|
430
|
-
() => import("./Render-
|
|
415
|
+
() => import("./Render-H3USS5FU.mjs").then((m) => ({
|
|
431
416
|
default: m.RichTextRender
|
|
432
417
|
}))
|
|
433
418
|
);
|
|
434
|
-
function useRichtextProps(fields, props) {
|
|
419
|
+
function useRichtextProps(fields, props, fieldTransforms) {
|
|
435
420
|
const findAllRichtextKeys = (fields2, path = []) => {
|
|
436
421
|
if (!fields2) return [];
|
|
437
422
|
const result = [];
|
|
438
423
|
for (const [key, field] of Object.entries(fields2)) {
|
|
424
|
+
if (fieldTransforms == null ? void 0 : fieldTransforms[field.type]) {
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
439
427
|
const currentPath = [...path, key];
|
|
440
428
|
if (field.type === "richtext") {
|
|
441
429
|
result.push({
|
|
@@ -452,7 +440,10 @@ function useRichtextProps(fields, props) {
|
|
|
452
440
|
}
|
|
453
441
|
return result;
|
|
454
442
|
};
|
|
455
|
-
const richtextKeys = useMemo2(
|
|
443
|
+
const richtextKeys = useMemo2(
|
|
444
|
+
() => findAllRichtextKeys(fields),
|
|
445
|
+
[fields, fieldTransforms]
|
|
446
|
+
);
|
|
456
447
|
const richtextProps = useMemo2(() => {
|
|
457
448
|
if (!(richtextKeys == null ? void 0 : richtextKeys.length)) return {};
|
|
458
449
|
let result = __spreadValues({}, props);
|
|
@@ -471,6 +462,28 @@ function useRichtextProps(fields, props) {
|
|
|
471
462
|
return richtextProps;
|
|
472
463
|
}
|
|
473
464
|
|
|
465
|
+
// lib/props/render/use-render-props.tsx
|
|
466
|
+
var EMPTY_FIELD_CONFIG = {};
|
|
467
|
+
function useRenderProps(config, component, renderSlot, fieldTransforms) {
|
|
468
|
+
var _a, _b;
|
|
469
|
+
const transformedProps = useFieldTransforms(
|
|
470
|
+
config,
|
|
471
|
+
component,
|
|
472
|
+
__spreadValues(__spreadValues({}, getSlotTransform(renderSlot)), fieldTransforms),
|
|
473
|
+
void 0,
|
|
474
|
+
true
|
|
475
|
+
);
|
|
476
|
+
const isRoot = !("type" in component) || component.type === "root";
|
|
477
|
+
const componentFields = isRoot ? (_a = config.root) == null ? void 0 : _a.fields : ((_b = config.components[component.type]) == null ? void 0 : _b.fields) || EMPTY_FIELD_CONFIG;
|
|
478
|
+
const richtextProps = useRichtextProps(
|
|
479
|
+
componentFields,
|
|
480
|
+
transformedProps,
|
|
481
|
+
fieldTransforms
|
|
482
|
+
);
|
|
483
|
+
return __spreadValues(__spreadValues({}, transformedProps), richtextProps);
|
|
484
|
+
}
|
|
485
|
+
var use_render_props_default = useRenderProps;
|
|
486
|
+
|
|
474
487
|
// components/SlotRender/server.tsx
|
|
475
488
|
init_react_import();
|
|
476
489
|
import { forwardRef } from "react";
|
|
@@ -479,14 +492,26 @@ var SlotRenderPure = (props) => /* @__PURE__ */ jsx3(SlotRender, __spreadValues(
|
|
|
479
492
|
var Item = ({
|
|
480
493
|
config,
|
|
481
494
|
item,
|
|
482
|
-
metadata
|
|
495
|
+
metadata,
|
|
496
|
+
fieldTransforms
|
|
483
497
|
}) => {
|
|
484
498
|
const Component = config.components[item.type];
|
|
485
|
-
const props =
|
|
486
|
-
|
|
499
|
+
const props = use_render_props_default(
|
|
500
|
+
config,
|
|
501
|
+
item,
|
|
502
|
+
(slotProps) => /* @__PURE__ */ jsx3(
|
|
503
|
+
SlotRenderPure,
|
|
504
|
+
__spreadProps(__spreadValues({}, slotProps), {
|
|
505
|
+
config,
|
|
506
|
+
metadata,
|
|
507
|
+
fieldTransforms
|
|
508
|
+
})
|
|
509
|
+
),
|
|
510
|
+
fieldTransforms
|
|
511
|
+
);
|
|
487
512
|
return /* @__PURE__ */ jsx3(
|
|
488
513
|
Component.render,
|
|
489
|
-
__spreadProps(__spreadValues(
|
|
514
|
+
__spreadProps(__spreadValues({}, props), {
|
|
490
515
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
491
516
|
metadata: metadata || {}
|
|
492
517
|
})
|
|
@@ -496,7 +521,15 @@ var Item = ({
|
|
|
496
521
|
var SlotRender = forwardRef(
|
|
497
522
|
function SlotRenderInternal(allProps, ref) {
|
|
498
523
|
const {
|
|
499
|
-
props: {
|
|
524
|
+
props: {
|
|
525
|
+
className,
|
|
526
|
+
style,
|
|
527
|
+
content,
|
|
528
|
+
config,
|
|
529
|
+
metadata,
|
|
530
|
+
as,
|
|
531
|
+
fieldTransforms
|
|
532
|
+
},
|
|
500
533
|
forwardableProps
|
|
501
534
|
} = getDropZoneProps(allProps);
|
|
502
535
|
const El = as != null ? as : "div";
|
|
@@ -509,7 +542,8 @@ var SlotRender = forwardRef(
|
|
|
509
542
|
{
|
|
510
543
|
config,
|
|
511
544
|
item,
|
|
512
|
-
metadata
|
|
545
|
+
metadata,
|
|
546
|
+
fieldTransforms
|
|
513
547
|
},
|
|
514
548
|
item.props.id
|
|
515
549
|
);
|
|
@@ -521,9 +555,8 @@ export {
|
|
|
521
555
|
getDropZoneProps,
|
|
522
556
|
buildMappers,
|
|
523
557
|
getSlotTransform,
|
|
524
|
-
useSlots,
|
|
525
558
|
RichTextRenderFallback,
|
|
526
|
-
|
|
559
|
+
use_render_props_default,
|
|
527
560
|
SlotRenderPure,
|
|
528
561
|
SlotRender,
|
|
529
562
|
migrate,
|