@measured/puck 0.14.0-canary.d944288 → 0.14.0-canary.dd9be54
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -0
- package/dist/{Config-Bgx_Bij_.d.ts → Config-shqT_YTp.d.ts} +16 -23
- package/dist/index.css +32 -15
- package/dist/index.d.ts +53 -48
- package/dist/index.js +144 -91
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +4 -1
- package/package.json +2 -2
package/README.md
CHANGED
@@ -15,6 +15,9 @@ The visual editor for React.
|
|
15
15
|
<a aria-label="Join the community on Discord" href="https://discord.gg/D9e4E3MQVZ">
|
16
16
|
<img alt="" src="https://img.shields.io/badge/Join%20the%20Discord-blueviolet.svg?style=for-the-badge&logo=Discord&labelColor=000000&logoWidth=20">
|
17
17
|
</a>
|
18
|
+
<a aria-label="Join the community on Discord" href="https://discord.gg/D9e4E3MQVZ">
|
19
|
+
<img alt="" src="https://img.shields.io/badge/repo-awesome--puck-fc60a8.svg?style=for-the-badge&labelColor=000000&logoWidth=20">
|
20
|
+
</a>
|
18
21
|
</p>
|
19
22
|
|
20
23
|
## Demo
|
@@ -96,6 +99,13 @@ Available recipes include:
|
|
96
99
|
- [**next**](https://github.com/measuredco/puck/tree/main/recipes/next): Next.js 13 app example, using App Router and static page generation
|
97
100
|
- [**remix**](https://github.com/measuredco/puck/tree/main/recipes/remix): Remix Run v2 app example, using dynamic routes at root-level
|
98
101
|
|
102
|
+
|
103
|
+
## Community
|
104
|
+
|
105
|
+
* [Discord server](https://discord.gg/D9e4E3MQVZ) for discussions
|
106
|
+
* [awesome-puck](https://github.com/measuredco/awesome-puck) community repo for plugins, custom fields & more
|
107
|
+
|
108
|
+
|
99
109
|
## Hire the Puck team
|
100
110
|
|
101
111
|
Puck is developed and maintained by **Measured**, a small group of industry veterans with decades of experience helping companies solve hard UI problems. We offer consultancy and development services for scale-ups, SMEs and enterprises.
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { CSSProperties, ReactNode, ReactElement } from 'react';
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
3
2
|
|
4
3
|
type ItemSelector = {
|
5
4
|
index: number;
|
@@ -12,7 +11,6 @@ type DropZoneProps = {
|
|
12
11
|
disallow?: string[];
|
13
12
|
style?: CSSProperties;
|
14
13
|
};
|
15
|
-
declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
|
16
14
|
|
17
15
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
18
16
|
type Viewport = {
|
@@ -147,20 +145,26 @@ type Content<Props extends {
|
|
147
145
|
} = {
|
148
146
|
[key: string]: any;
|
149
147
|
}> = ComponentData<Props>[];
|
150
|
-
type PuckComponent<Props
|
148
|
+
type PuckComponent<Props> = (props: WithPuckProps<Props & {
|
151
149
|
puck: PuckContext;
|
152
150
|
}>) => JSX.Element;
|
153
151
|
type PuckContext = {
|
154
|
-
renderDropZone:
|
152
|
+
renderDropZone: React.FC<DropZoneProps>;
|
155
153
|
};
|
156
|
-
type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps, DataShape = ComponentData<ComponentProps>> = {
|
154
|
+
type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps, DataShape = Omit<ComponentData<ComponentProps>, "type">> = {
|
157
155
|
render: PuckComponent<ComponentProps>;
|
158
156
|
label?: string;
|
159
157
|
defaultProps?: DefaultProps;
|
160
158
|
fields?: Fields<ComponentProps>;
|
161
159
|
resolveData?: (data: DataShape, params: {
|
162
160
|
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
163
|
-
}) => Promise<
|
161
|
+
}) => Promise<{
|
162
|
+
props?: Partial<ComponentProps>;
|
163
|
+
readOnly?: Partial<Record<keyof ComponentProps, boolean>>;
|
164
|
+
}> | {
|
165
|
+
props?: Partial<ComponentProps>;
|
166
|
+
readOnly?: Partial<Record<keyof ComponentProps, boolean>>;
|
167
|
+
};
|
164
168
|
};
|
165
169
|
type Category<ComponentName> = {
|
166
170
|
components?: ComponentName[];
|
@@ -168,22 +172,18 @@ type Category<ComponentName> = {
|
|
168
172
|
visible?: boolean;
|
169
173
|
defaultExpanded?: boolean;
|
170
174
|
};
|
171
|
-
type Config<Props extends {
|
172
|
-
[key: string]: any;
|
173
|
-
} = {
|
174
|
-
[key: string]: any;
|
175
|
-
}, RootProps extends DefaultRootProps = DefaultRootProps, CategoryName extends string = any> = {
|
175
|
+
type Config<Props extends Record<string, any> = Record<string, any>, RootProps extends DefaultRootProps = DefaultRootProps, CategoryName extends string = string> = {
|
176
176
|
categories?: Record<CategoryName, Category<keyof Props>> & {
|
177
|
-
other?: Category<Props>;
|
177
|
+
other?: Category<keyof Props>;
|
178
178
|
};
|
179
179
|
components: {
|
180
180
|
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
181
181
|
};
|
182
182
|
root?: Partial<ComponentConfig<RootProps & {
|
183
|
-
children
|
183
|
+
children?: ReactNode;
|
184
184
|
}, Partial<RootProps & {
|
185
|
-
children
|
186
|
-
}>, RootDataWithProps
|
185
|
+
children?: ReactNode;
|
186
|
+
}>, RootDataWithProps>>;
|
187
187
|
};
|
188
188
|
type BaseData<Props extends {
|
189
189
|
[key: string]: any;
|
@@ -201,13 +201,6 @@ type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = {
|
|
201
201
|
};
|
202
202
|
type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
|
203
203
|
type RootData<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
|
204
|
-
type ComponentDataWithOptionalProps<Props extends {
|
205
|
-
[key: string]: any;
|
206
|
-
} = {
|
207
|
-
[key: string]: any;
|
208
|
-
}> = Omit<ComponentData, "props"> & {
|
209
|
-
props: Partial<WithPuckProps<Props>>;
|
210
|
-
};
|
211
204
|
type MappedItem = ComponentData;
|
212
205
|
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
213
206
|
root: RootData<RootProps>;
|
@@ -248,4 +241,4 @@ type AppState = {
|
|
248
241
|
ui: UiState;
|
249
242
|
};
|
250
243
|
|
251
|
-
export {
|
244
|
+
export type { AppState as A, BaseField as B, Config as C, Data as D, ExternalFieldWithAdaptor as E, Field as F, ItemSelector as I, MappedItem as M, NumberField as N, ObjectField as O, PuckComponent as P, RootDataWithProps as R, SelectField as S, TextField as T, UiState as U, Viewports as V, DefaultRootProps as a, DropZoneProps as b, DefaultComponentProps as c, RootData as d, ComponentData as e, TextareaField as f, RadioField as g, ArrayField as h, Adaptor as i, ExternalField as j, CustomField as k, Fields as l, Content as m, PuckContext as n, ComponentConfig as o, BaseData as p, RootDataWithoutProps as q, ItemWithId as r, ArrayState as s };
|
package/dist/index.css
CHANGED
@@ -977,22 +977,24 @@ textarea.styles_Input-input {
|
|
977
977
|
}
|
978
978
|
.styles_ArrayField--isDraggingFrom {
|
979
979
|
background-color: var(--puck-color-azure-11);
|
980
|
+
overflow: hidden;
|
980
981
|
}
|
981
982
|
.styles_ArrayField-addButton {
|
982
983
|
background-color: var(--puck-color-white);
|
983
984
|
border: none;
|
984
|
-
border-radius:
|
985
|
+
border-radius: 3px;
|
985
986
|
display: flex;
|
986
987
|
color: var(--puck-color-azure-05);
|
987
988
|
justify-content: center;
|
988
989
|
cursor: pointer;
|
989
990
|
width: 100%;
|
990
991
|
margin: 0;
|
991
|
-
padding:
|
992
|
+
padding: 14px;
|
992
993
|
text-align: left;
|
993
994
|
transition: background-color 50ms ease-in;
|
994
995
|
}
|
995
996
|
.styles_ArrayField--hasItems > .styles_ArrayField-addButton {
|
997
|
+
border-top: 1px solid var(--puck-color-grey-09);
|
996
998
|
border-top-left-radius: 0;
|
997
999
|
border-top-right-radius: 0;
|
998
1000
|
}
|
@@ -1014,20 +1016,28 @@ textarea.styles_Input-input {
|
|
1014
1016
|
transition: none;
|
1015
1017
|
}
|
1016
1018
|
.styles_ArrayFieldItem {
|
1017
|
-
|
1018
|
-
border-top-
|
1019
|
-
border-top-right-radius: 4px;
|
1019
|
+
border-top-left-radius: 3px;
|
1020
|
+
border-top-right-radius: 3px;
|
1020
1021
|
display: block;
|
1021
|
-
|
1022
|
+
position: relative;
|
1022
1023
|
}
|
1023
|
-
.
|
1024
|
-
|
1025
|
-
|
1024
|
+
.styles_ArrayFieldItem:not(.styles_ArrayFieldItem--isDragging):not(:first-of-type)::before {
|
1025
|
+
background-color: var(--puck-color-grey-09);
|
1026
|
+
position: absolute;
|
1027
|
+
width: 100%;
|
1028
|
+
height: 1px;
|
1029
|
+
content: "";
|
1030
|
+
z-index: 1;
|
1031
|
+
top: -1px;
|
1032
|
+
}
|
1033
|
+
.styles_ArrayFieldItem--isExpanded::before {
|
1034
|
+
display: none;
|
1026
1035
|
}
|
1027
1036
|
.styles_ArrayFieldItem--isExpanded {
|
1028
1037
|
border-bottom: 0;
|
1029
1038
|
outline-offset: 0px !important;
|
1030
1039
|
outline: 1px solid var(--puck-color-azure-07) !important;
|
1040
|
+
z-index: 2;
|
1031
1041
|
}
|
1032
1042
|
.styles_ArrayFieldItem--isDragging {
|
1033
1043
|
box-shadow: color-mix(in srgb, var(--puck-color-grey-06) 25%, transparent) 0 3px 6px 0;
|
@@ -1040,6 +1050,7 @@ textarea.styles_Input-input {
|
|
1040
1050
|
border-top-right-radius: 0;
|
1041
1051
|
}
|
1042
1052
|
.styles_ArrayFieldItem-summary {
|
1053
|
+
background: var(--puck-color-white);
|
1043
1054
|
color: var(--puck-color-grey-04);
|
1044
1055
|
cursor: pointer;
|
1045
1056
|
display: flex;
|
@@ -1049,17 +1060,22 @@ textarea.styles_Input-input {
|
|
1049
1060
|
font-size: var(--puck-font-size-xxs);
|
1050
1061
|
list-style: none;
|
1051
1062
|
padding: 12px 15px;
|
1063
|
+
padding-bottom: 13px;
|
1052
1064
|
position: relative;
|
1053
1065
|
overflow: hidden;
|
1054
1066
|
transition: background-color 50ms ease-in;
|
1055
1067
|
}
|
1056
|
-
.styles_ArrayFieldItem--readOnly > .styles_ArrayFieldItem-summary {
|
1057
|
-
background-color: var(--puck-color-grey-12);
|
1058
|
-
color: var(--puck-color-grey-06);
|
1059
|
-
}
|
1060
1068
|
.styles_ArrayFieldItem:first-of-type > .styles_ArrayFieldItem-summary {
|
1061
|
-
border-top-left-radius:
|
1062
|
-
border-top-right-radius:
|
1069
|
+
border-top-left-radius: 3px;
|
1070
|
+
border-top-right-radius: 3px;
|
1071
|
+
}
|
1072
|
+
.styles_ArrayField--addDisabled > .styles_ArrayFieldItem:last-of-type:not(.styles_ArrayFieldItem--isExpanded) > .styles_ArrayFieldItem-summary {
|
1073
|
+
border-bottom-left-radius: 3px;
|
1074
|
+
border-bottom-right-radius: 3px;
|
1075
|
+
}
|
1076
|
+
.styles_ArrayField--addDisabled > .styles_ArrayFieldItem--isExpanded:last-of-type {
|
1077
|
+
border-bottom-left-radius: 3px;
|
1078
|
+
border-bottom-right-radius: 3px;
|
1063
1079
|
}
|
1064
1080
|
.styles_ArrayFieldItem-summary:focus-visible {
|
1065
1081
|
outline: 2px solid var(--puck-color-azure-05);
|
@@ -1082,6 +1098,7 @@ textarea.styles_Input-input {
|
|
1082
1098
|
transition: none;
|
1083
1099
|
}
|
1084
1100
|
.styles_ArrayFieldItem-body {
|
1101
|
+
background: var(--puck-color-white);
|
1085
1102
|
display: none;
|
1086
1103
|
}
|
1087
1104
|
.styles_ArrayFieldItem--isExpanded > .styles_ArrayFieldItem-body {
|
package/dist/index.d.ts
CHANGED
@@ -1,47 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
1
|
+
import { U as UiState, D as Data, A as AppState, C as Config, a as DefaultRootProps, I as ItemSelector, b as DropZoneProps, F as Field, V as Viewports, c as DefaultComponentProps, M as MappedItem, R as RootDataWithProps, d as RootData, e as ComponentData } from './Config-shqT_YTp.js';
|
2
|
+
export { i as Adaptor, h as ArrayField, s as ArrayState, p as BaseData, B as BaseField, o as ComponentConfig, m as Content, k as CustomField, j as ExternalField, E as ExternalFieldWithAdaptor, l as Fields, r as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, n as PuckContext, g as RadioField, q as RootDataWithoutProps, S as SelectField, T as TextField, f as TextareaField } from './Config-shqT_YTp.js';
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
4
|
import * as react from 'react';
|
5
|
-
import { ReactNode,
|
5
|
+
import { ReactNode, ReactElement, CSSProperties, SyntheticEvent } from 'react';
|
6
6
|
import { DragStart, DragUpdate } from '@measured/dnd';
|
7
7
|
|
8
|
-
type PathData = Record<string, {
|
9
|
-
path: string[];
|
10
|
-
label: string;
|
11
|
-
}>;
|
12
|
-
type DropZoneContext<UserConfig extends Config<any, any, any> = Config<any, any, any>> = {
|
13
|
-
data: Data;
|
14
|
-
config: UserConfig;
|
15
|
-
componentState?: Record<string, any>;
|
16
|
-
itemSelector?: ItemSelector | null;
|
17
|
-
setItemSelector?: (newIndex: ItemSelector | null) => void;
|
18
|
-
dispatch?: (action: PuckAction) => void;
|
19
|
-
areaId?: string;
|
20
|
-
draggedItem?: DragStart & Partial<DragUpdate>;
|
21
|
-
placeholderStyle?: CSSProperties;
|
22
|
-
hoveringArea?: string | null;
|
23
|
-
setHoveringArea?: (area: string | null) => void;
|
24
|
-
hoveringZone?: string | null;
|
25
|
-
setHoveringZone?: (zone: string | null) => void;
|
26
|
-
hoveringComponent?: string | null;
|
27
|
-
setHoveringComponent?: (id: string | null) => void;
|
28
|
-
registerZoneArea?: (areaId: string) => void;
|
29
|
-
areasWithZones?: Record<string, boolean>;
|
30
|
-
registerZone?: (zoneCompound: string) => void;
|
31
|
-
unregisterZone?: (zoneCompound: string) => void;
|
32
|
-
activeZones?: Record<string, boolean>;
|
33
|
-
pathData?: PathData;
|
34
|
-
registerPath?: (selector: ItemSelector) => void;
|
35
|
-
mode?: "edit" | "render";
|
36
|
-
zoneWillDrag?: string;
|
37
|
-
setZoneWillDrag?: (zone: string) => void;
|
38
|
-
} | null;
|
39
|
-
declare const dropZoneContext: react.Context<DropZoneContext<Config<any, any, any>>>;
|
40
|
-
declare const DropZoneProvider: ({ children, value, }: {
|
41
|
-
children: ReactNode;
|
42
|
-
value: DropZoneContext;
|
43
|
-
}) => react_jsx_runtime.JSX.Element;
|
44
|
-
|
45
8
|
type InsertAction = {
|
46
9
|
type: "insert";
|
47
10
|
componentType: string;
|
@@ -106,7 +69,7 @@ declare const Button: ({ children, href, onClick, variant, type, disabled, tabIn
|
|
106
69
|
href?: string | undefined;
|
107
70
|
onClick?: ((e: any) => void | Promise<void>) | undefined;
|
108
71
|
variant?: "primary" | "secondary" | undefined;
|
109
|
-
type?: "
|
72
|
+
type?: "button" | "submit" | "reset" | undefined;
|
110
73
|
disabled?: boolean | undefined;
|
111
74
|
tabIndex?: number | undefined;
|
112
75
|
newTab?: boolean | undefined;
|
@@ -120,7 +83,7 @@ declare const Drawer: {
|
|
120
83
|
({ children, droppableId, direction, }: {
|
121
84
|
children: ReactNode;
|
122
85
|
droppableId?: string | undefined;
|
123
|
-
direction?: "
|
86
|
+
direction?: "vertical" | "horizontal" | undefined;
|
124
87
|
}): react_jsx_runtime.JSX.Element;
|
125
88
|
Item: ({ name, children, id, label, index, }: {
|
126
89
|
name: string;
|
@@ -134,12 +97,51 @@ declare const Drawer: {
|
|
134
97
|
}) => react_jsx_runtime.JSX.Element;
|
135
98
|
};
|
136
99
|
|
100
|
+
type PathData = Record<string, {
|
101
|
+
path: string[];
|
102
|
+
label: string;
|
103
|
+
}>;
|
104
|
+
type DropZoneContext<UserConfig extends Config = Config> = {
|
105
|
+
data: Data;
|
106
|
+
config: UserConfig;
|
107
|
+
componentState?: Record<string, any>;
|
108
|
+
itemSelector?: ItemSelector | null;
|
109
|
+
setItemSelector?: (newIndex: ItemSelector | null) => void;
|
110
|
+
dispatch?: (action: PuckAction) => void;
|
111
|
+
areaId?: string;
|
112
|
+
draggedItem?: DragStart & Partial<DragUpdate>;
|
113
|
+
placeholderStyle?: CSSProperties;
|
114
|
+
hoveringArea?: string | null;
|
115
|
+
setHoveringArea?: (area: string | null) => void;
|
116
|
+
hoveringZone?: string | null;
|
117
|
+
setHoveringZone?: (zone: string | null) => void;
|
118
|
+
hoveringComponent?: string | null;
|
119
|
+
setHoveringComponent?: (id: string | null) => void;
|
120
|
+
registerZoneArea?: (areaId: string) => void;
|
121
|
+
areasWithZones?: Record<string, boolean>;
|
122
|
+
registerZone?: (zoneCompound: string) => void;
|
123
|
+
unregisterZone?: (zoneCompound: string) => void;
|
124
|
+
activeZones?: Record<string, boolean>;
|
125
|
+
pathData?: PathData;
|
126
|
+
registerPath?: (selector: ItemSelector) => void;
|
127
|
+
mode?: "edit" | "render";
|
128
|
+
zoneWillDrag?: string;
|
129
|
+
setZoneWillDrag?: (zone: string) => void;
|
130
|
+
} | null;
|
131
|
+
declare const dropZoneContext: react.Context<DropZoneContext<Config<Record<string, any>, DefaultRootProps, string>>>;
|
132
|
+
declare const DropZoneProvider: ({ children, value, }: {
|
133
|
+
children: ReactNode;
|
134
|
+
value: DropZoneContext;
|
135
|
+
}) => react_jsx_runtime.JSX.Element;
|
136
|
+
|
137
|
+
declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
|
138
|
+
|
137
139
|
declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
|
138
140
|
children: ReactNode;
|
139
141
|
href?: string | undefined;
|
140
142
|
onClick?: ((e: SyntheticEvent) => void | Promise<void>) | undefined;
|
141
143
|
variant?: "primary" | "secondary" | undefined;
|
142
|
-
type?: "
|
144
|
+
type?: "button" | "submit" | "reset" | undefined;
|
143
145
|
disabled?: boolean | undefined;
|
144
146
|
tabIndex?: number | undefined;
|
145
147
|
newTab?: boolean | undefined;
|
@@ -227,7 +229,7 @@ type IframeConfig = {
|
|
227
229
|
enabled?: boolean;
|
228
230
|
};
|
229
231
|
|
230
|
-
declare function Puck<UserConfig extends Config
|
232
|
+
declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, }: {
|
231
233
|
children?: ReactNode;
|
232
234
|
config: UserConfig;
|
233
235
|
data: Data;
|
@@ -259,7 +261,7 @@ declare namespace Puck {
|
|
259
261
|
}) => react_jsx_runtime.JSX.Element;
|
260
262
|
}
|
261
263
|
|
262
|
-
declare function Render<UserConfig extends Config
|
264
|
+
declare function Render<UserConfig extends Config = Config>({ config, data, }: {
|
263
265
|
config: UserConfig;
|
264
266
|
data: Data;
|
265
267
|
}): react_jsx_runtime.JSX.Element;
|
@@ -277,7 +279,7 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
277
279
|
}>;
|
278
280
|
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Data, propTransforms: PropTransform<Props, RootProps>): Data;
|
279
281
|
|
280
|
-
declare
|
282
|
+
declare function resolveAllData(data: Data, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
|
281
283
|
root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
|
282
284
|
content: any[];
|
283
285
|
zones: Record<string, MappedItem[]>;
|
@@ -308,9 +310,12 @@ type PuckHistory = {
|
|
308
310
|
|
309
311
|
declare const usePuck: () => {
|
310
312
|
appState: AppState;
|
311
|
-
config: Config<
|
313
|
+
config: Config<Record<string, any>, DefaultRootProps, string>;
|
312
314
|
dispatch: (action: PuckAction) => void;
|
313
315
|
history: Partial<PuckHistory>;
|
316
|
+
selectedItem: ComponentData<DefaultComponentProps & {
|
317
|
+
id: string;
|
318
|
+
}> | null;
|
314
319
|
};
|
315
320
|
|
316
|
-
export { AppState, Button, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZoneProvider, Field, FieldLabel, IconButton, MappedItem, Puck, type PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
|
321
|
+
export { AppState, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, IconButton, MappedItem, Puck, type PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
|
package/dist/index.js
CHANGED
@@ -8085,7 +8085,7 @@ var require_react_dom_development = __commonJS({
|
|
8085
8085
|
var HostPortal = 4;
|
8086
8086
|
var HostComponent = 5;
|
8087
8087
|
var HostText = 6;
|
8088
|
-
var
|
8088
|
+
var Fragment17 = 7;
|
8089
8089
|
var Mode = 8;
|
8090
8090
|
var ContextConsumer = 9;
|
8091
8091
|
var ContextProvider = 10;
|
@@ -9241,7 +9241,7 @@ var require_react_dom_development = __commonJS({
|
|
9241
9241
|
return "DehydratedFragment";
|
9242
9242
|
case ForwardRef:
|
9243
9243
|
return getWrappedName$1(type, type.render, "ForwardRef");
|
9244
|
-
case
|
9244
|
+
case Fragment17:
|
9245
9245
|
return "Fragment";
|
9246
9246
|
case HostComponent:
|
9247
9247
|
return type;
|
@@ -18912,7 +18912,7 @@ var require_react_dom_development = __commonJS({
|
|
18912
18912
|
}
|
18913
18913
|
}
|
18914
18914
|
function updateFragment2(returnFiber, current2, fragment, lanes, key) {
|
18915
|
-
if (current2 === null || current2.tag !==
|
18915
|
+
if (current2 === null || current2.tag !== Fragment17) {
|
18916
18916
|
var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
|
18917
18917
|
created.return = returnFiber;
|
18918
18918
|
return created;
|
@@ -19315,7 +19315,7 @@ var require_react_dom_development = __commonJS({
|
|
19315
19315
|
if (child.key === key) {
|
19316
19316
|
var elementType = element.type;
|
19317
19317
|
if (elementType === REACT_FRAGMENT_TYPE) {
|
19318
|
-
if (child.tag ===
|
19318
|
+
if (child.tag === Fragment17) {
|
19319
19319
|
deleteRemainingChildren(returnFiber, child.sibling);
|
19320
19320
|
var existing = useFiber(child, element.props.children);
|
19321
19321
|
existing.return = returnFiber;
|
@@ -23490,7 +23490,7 @@ var require_react_dom_development = __commonJS({
|
|
23490
23490
|
var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
23491
23491
|
return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
|
23492
23492
|
}
|
23493
|
-
case
|
23493
|
+
case Fragment17:
|
23494
23494
|
return updateFragment(current2, workInProgress2, renderLanes2);
|
23495
23495
|
case Mode:
|
23496
23496
|
return updateMode(current2, workInProgress2, renderLanes2);
|
@@ -23763,7 +23763,7 @@ var require_react_dom_development = __commonJS({
|
|
23763
23763
|
case SimpleMemoComponent:
|
23764
23764
|
case FunctionComponent:
|
23765
23765
|
case ForwardRef:
|
23766
|
-
case
|
23766
|
+
case Fragment17:
|
23767
23767
|
case Mode:
|
23768
23768
|
case Profiler:
|
23769
23769
|
case ContextConsumer:
|
@@ -28022,7 +28022,7 @@ var require_react_dom_development = __commonJS({
|
|
28022
28022
|
return fiber;
|
28023
28023
|
}
|
28024
28024
|
function createFiberFromFragment(elements, mode, lanes, key) {
|
28025
|
-
var fiber = createFiber(
|
28025
|
+
var fiber = createFiber(Fragment17, elements, key, mode);
|
28026
28026
|
fiber.lanes = lanes;
|
28027
28027
|
return fiber;
|
28028
28028
|
}
|
@@ -29911,6 +29911,18 @@ var useModifierHeld = (modifier) => {
|
|
29911
29911
|
return modifierHeld;
|
29912
29912
|
};
|
29913
29913
|
|
29914
|
+
// lib/is-ios.ts
|
29915
|
+
init_react_import();
|
29916
|
+
var isIos = () => [
|
29917
|
+
"iPad Simulator",
|
29918
|
+
"iPhone Simulator",
|
29919
|
+
"iPod Simulator",
|
29920
|
+
"iPad",
|
29921
|
+
"iPhone",
|
29922
|
+
"iPod"
|
29923
|
+
].includes(navigator.platform) || // iPad on iOS 13 detection
|
29924
|
+
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
29925
|
+
|
29914
29926
|
// components/DraggableComponent/index.tsx
|
29915
29927
|
var import_react_spinners2 = require("react-spinners");
|
29916
29928
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
@@ -29946,60 +29958,76 @@ var DraggableComponent = ({
|
|
29946
29958
|
const { status } = useAppContext();
|
29947
29959
|
const El = status !== "LOADING" ? import_dnd3.Draggable : DefaultDraggable;
|
29948
29960
|
(0, import_react7.useEffect)(onMount, []);
|
29949
|
-
|
29950
|
-
|
29951
|
-
|
29952
|
-
|
29953
|
-
}
|
29954
|
-
|
29955
|
-
|
29956
|
-
|
29957
|
-
|
29958
|
-
|
29959
|
-
|
29960
|
-
|
29961
|
-
|
29962
|
-
|
29963
|
-
|
29964
|
-
|
29965
|
-
|
29966
|
-
|
29967
|
-
|
29968
|
-
|
29969
|
-
|
29970
|
-
|
29971
|
-
|
29972
|
-
|
29973
|
-
|
29974
|
-
|
29975
|
-
{
|
29976
|
-
|
29977
|
-
|
29978
|
-
|
29979
|
-
|
29980
|
-
|
29961
|
+
const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0, import_react7.useState)(false);
|
29962
|
+
(0, import_react7.useEffect)(() => {
|
29963
|
+
if (isIos()) {
|
29964
|
+
setDisableSecondaryAnimation(true);
|
29965
|
+
}
|
29966
|
+
}, []);
|
29967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
29968
|
+
El,
|
29969
|
+
{
|
29970
|
+
draggableId: id,
|
29971
|
+
index,
|
29972
|
+
isDragDisabled,
|
29973
|
+
disableSecondaryAnimation,
|
29974
|
+
children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
29975
|
+
"div",
|
29976
|
+
__spreadProps(__spreadValues(__spreadValues({
|
29977
|
+
ref: provided.innerRef
|
29978
|
+
}, provided.draggableProps), provided.dragHandleProps), {
|
29979
|
+
className: getClassName4({
|
29980
|
+
isSelected,
|
29981
|
+
isModifierHeld,
|
29982
|
+
isDragging: snapshot.isDragging,
|
29983
|
+
isLocked,
|
29984
|
+
forceHover,
|
29985
|
+
indicativeHover
|
29986
|
+
}),
|
29987
|
+
style: __spreadProps(__spreadValues(__spreadValues({}, style), provided.draggableProps.style), {
|
29988
|
+
cursor: isModifierHeld ? "initial" : "grab"
|
29989
|
+
}),
|
29990
|
+
onMouseOver,
|
29991
|
+
onMouseOut,
|
29992
|
+
onMouseDown,
|
29993
|
+
onMouseUp,
|
29994
|
+
onClick,
|
29995
|
+
children: [
|
29996
|
+
debug,
|
29997
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_spinners2.ClipLoader, { "aria-label": "loading", size: 16, color: "inherit" }) }),
|
29998
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
29981
29999
|
"div",
|
29982
30000
|
{
|
29983
|
-
className: getClassName4("
|
30001
|
+
className: getClassName4("actionsOverlay"),
|
29984
30002
|
style: {
|
29985
|
-
|
29986
|
-
top: actionsTop / zoomConfig.zoom,
|
29987
|
-
right: actionsRight / zoomConfig.zoom
|
30003
|
+
top: actionsOverlayTop / zoomConfig.zoom
|
29988
30004
|
},
|
29989
|
-
children:
|
29990
|
-
|
29991
|
-
|
29992
|
-
|
29993
|
-
|
30005
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
30006
|
+
"div",
|
30007
|
+
{
|
30008
|
+
className: getClassName4("actions"),
|
30009
|
+
style: {
|
30010
|
+
transform: `scale(${1 / zoomConfig.zoom}`,
|
30011
|
+
top: actionsTop / zoomConfig.zoom,
|
30012
|
+
right: actionsRight / zoomConfig.zoom
|
30013
|
+
},
|
30014
|
+
children: [
|
30015
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("actionsLabel"), children: label }),
|
30016
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: getClassName4("action"), onClick: onDuplicate, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 }) }),
|
30017
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: getClassName4("action"), onClick: onDelete, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 }) })
|
30018
|
+
]
|
30019
|
+
}
|
30020
|
+
)
|
29994
30021
|
}
|
29995
|
-
)
|
29996
|
-
|
29997
|
-
|
29998
|
-
|
29999
|
-
|
30000
|
-
|
30001
|
-
}
|
30002
|
-
|
30022
|
+
),
|
30023
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("overlay") }),
|
30024
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName4("contents"), children })
|
30025
|
+
]
|
30026
|
+
})
|
30027
|
+
)
|
30028
|
+
},
|
30029
|
+
id
|
30030
|
+
);
|
30003
30031
|
};
|
30004
30032
|
|
30005
30033
|
// components/DropZone/styles.module.css
|
@@ -30545,7 +30573,7 @@ var usePlaceholderStyle = () => {
|
|
30545
30573
|
const droppableId = (draggedItem.destination || draggedItem.source).droppableId;
|
30546
30574
|
const domQuery = `[${queryAttr}='${draggableId}']`;
|
30547
30575
|
const frame = getFrame();
|
30548
|
-
const draggedDOM = frame == null ? void 0 : frame.querySelector(domQuery);
|
30576
|
+
const draggedDOM = document.querySelector(domQuery) || (frame == null ? void 0 : frame.querySelector(domQuery));
|
30549
30577
|
if (!draggedDOM) {
|
30550
30578
|
return;
|
30551
30579
|
}
|
@@ -31442,7 +31470,7 @@ var styles_default10 = {
|
|
31442
31470
|
"ArrayFieldItem--isDragging": "styles_ArrayFieldItem--isDragging",
|
31443
31471
|
"ArrayFieldItem--isExpanded": "styles_ArrayFieldItem--isExpanded",
|
31444
31472
|
"ArrayFieldItem-summary": "styles_ArrayFieldItem-summary",
|
31445
|
-
"
|
31473
|
+
"ArrayField--addDisabled": "styles_ArrayField--addDisabled",
|
31446
31474
|
"ArrayFieldItem-body": "styles_ArrayFieldItem-body",
|
31447
31475
|
"ArrayFieldItem-fieldset": "styles_ArrayFieldItem-fieldset",
|
31448
31476
|
"ArrayFieldItem-rhs": "styles_ArrayFieldItem-rhs",
|
@@ -31528,12 +31556,15 @@ var ArrayField = ({
|
|
31528
31556
|
[arrayState]
|
31529
31557
|
);
|
31530
31558
|
(0, import_react14.useEffect)(() => {
|
31531
|
-
|
31559
|
+
if (arrayState.items.length > 0) {
|
31560
|
+
setUi(mapArrayStateToUi(arrayState));
|
31561
|
+
}
|
31532
31562
|
}, []);
|
31533
31563
|
const [hovering, setHovering] = (0, import_react14.useState)(false);
|
31534
31564
|
if (field.type !== "array" || !field.arrayFields) {
|
31535
31565
|
return null;
|
31536
31566
|
}
|
31567
|
+
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
31537
31568
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
31538
31569
|
FieldLabelInternal,
|
31539
31570
|
{
|
@@ -31575,7 +31606,8 @@ var ArrayField = ({
|
|
31575
31606
|
ref: provided.innerRef,
|
31576
31607
|
className: getClassName10({
|
31577
31608
|
isDraggingFrom: !!snapshot.draggingFromThisWith,
|
31578
|
-
hasItems: Array.isArray(value) && value.length > 0
|
31609
|
+
hasItems: Array.isArray(value) && value.length > 0,
|
31610
|
+
addDisabled
|
31579
31611
|
}),
|
31580
31612
|
onMouseOver: (e) => {
|
31581
31613
|
e.stopPropagation();
|
@@ -31688,12 +31720,11 @@ var ArrayField = ({
|
|
31688
31720
|
);
|
31689
31721
|
}),
|
31690
31722
|
provided.placeholder,
|
31691
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
31723
|
+
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
31692
31724
|
"button",
|
31693
31725
|
{
|
31694
31726
|
type: "button",
|
31695
31727
|
className: getClassName10("addButton"),
|
31696
|
-
disabled: field.max !== void 0 && localState.arrayState.items.length >= field.max,
|
31697
31728
|
onClick: () => {
|
31698
31729
|
const existingValue = value || [];
|
31699
31730
|
const newValue = [
|
@@ -31885,7 +31916,7 @@ var ExternalInput = ({
|
|
31885
31916
|
const search = (0, import_react16.useCallback)(
|
31886
31917
|
(query, filters2) => __async(void 0, null, function* () {
|
31887
31918
|
setIsLoading(true);
|
31888
|
-
const cacheKey = `${id}-${
|
31919
|
+
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
31889
31920
|
const listData = dataCache[cacheKey] || (yield field.fetchList({ query, filters: filters2 }));
|
31890
31921
|
if (listData) {
|
31891
31922
|
setData(listData);
|
@@ -32729,7 +32760,12 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32729
32760
|
const Page = (0, import_react22.useCallback)(
|
32730
32761
|
(pageProps) => {
|
32731
32762
|
var _a, _b;
|
32732
|
-
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadProps(__spreadValues({
|
32763
|
+
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadProps(__spreadValues({
|
32764
|
+
id: "puck-root"
|
32765
|
+
}, pageProps), {
|
32766
|
+
editMode: true,
|
32767
|
+
puck: { renderDropZone: DropZone }
|
32768
|
+
})) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: pageProps.children });
|
32733
32769
|
},
|
32734
32770
|
[config.root]
|
32735
32771
|
);
|
@@ -33928,7 +33964,10 @@ Puck.Preview = Preview;
|
|
33928
33964
|
// components/Render/index.tsx
|
33929
33965
|
init_react_import();
|
33930
33966
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
33931
|
-
function Render({
|
33967
|
+
function Render({
|
33968
|
+
config,
|
33969
|
+
data
|
33970
|
+
}) {
|
33932
33971
|
var _a;
|
33933
33972
|
const rootProps = data.root.props || data.root;
|
33934
33973
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
@@ -34007,37 +34046,51 @@ function transformProps(data, propTransforms) {
|
|
34007
34046
|
|
34008
34047
|
// lib/resolve-all-data.ts
|
34009
34048
|
init_react_import();
|
34010
|
-
|
34011
|
-
|
34012
|
-
|
34013
|
-
|
34014
|
-
|
34015
|
-
|
34016
|
-
|
34017
|
-
|
34018
|
-
|
34019
|
-
|
34020
|
-
|
34021
|
-
|
34022
|
-
|
34023
|
-
|
34024
|
-
|
34025
|
-
|
34026
|
-
|
34027
|
-
|
34028
|
-
|
34029
|
-
|
34030
|
-
|
34031
|
-
|
34032
|
-
|
34049
|
+
function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
34050
|
+
return __async(this, null, function* () {
|
34051
|
+
const dynamicRoot = yield resolveRootData(data, config);
|
34052
|
+
const { zones = {} } = data;
|
34053
|
+
const zoneKeys = Object.keys(zones);
|
34054
|
+
const resolvedZones = {};
|
34055
|
+
for (let i = 0; i < zoneKeys.length; i++) {
|
34056
|
+
const zoneKey = zoneKeys[i];
|
34057
|
+
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
34058
|
+
zones[zoneKey],
|
34059
|
+
config,
|
34060
|
+
onResolveStart,
|
34061
|
+
onResolveEnd
|
34062
|
+
);
|
34063
|
+
}
|
34064
|
+
return __spreadProps(__spreadValues({}, data), {
|
34065
|
+
root: dynamicRoot,
|
34066
|
+
content: yield resolveAllComponentData(
|
34067
|
+
data.content,
|
34068
|
+
config,
|
34069
|
+
onResolveStart,
|
34070
|
+
onResolveEnd
|
34071
|
+
),
|
34072
|
+
zones: resolvedZones
|
34073
|
+
});
|
34033
34074
|
});
|
34034
|
-
}
|
34075
|
+
}
|
34035
34076
|
|
34036
34077
|
// lib/use-puck.ts
|
34037
34078
|
init_react_import();
|
34038
34079
|
var usePuck = () => {
|
34039
|
-
const {
|
34040
|
-
|
34080
|
+
const {
|
34081
|
+
state: appState,
|
34082
|
+
config,
|
34083
|
+
history,
|
34084
|
+
dispatch,
|
34085
|
+
selectedItem
|
34086
|
+
} = useAppContext();
|
34087
|
+
return {
|
34088
|
+
appState,
|
34089
|
+
config,
|
34090
|
+
dispatch,
|
34091
|
+
history,
|
34092
|
+
selectedItem: selectedItem || null
|
34093
|
+
};
|
34041
34094
|
};
|
34042
34095
|
// Annotate the CommonJS export names for ESM import in node:
|
34043
34096
|
0 && (module.exports = {
|
package/dist/rsc.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
-
import { C as Config, D as Data } from './Config-
|
2
|
+
import { C as Config, D as Data } from './Config-shqT_YTp.js';
|
3
3
|
import 'react';
|
4
4
|
|
5
|
-
declare function Render<UserConfig extends Config
|
5
|
+
declare function Render<UserConfig extends Config = Config>({ config, data, }: {
|
6
6
|
config: UserConfig;
|
7
7
|
data: Data;
|
8
8
|
}): react_jsx_runtime.JSX.Element;
|
package/dist/rsc.js
CHANGED
@@ -109,7 +109,10 @@ function DropZoneRender({
|
|
109
109
|
return null;
|
110
110
|
}) });
|
111
111
|
}
|
112
|
-
function Render({
|
112
|
+
function Render({
|
113
|
+
config,
|
114
|
+
data
|
115
|
+
}) {
|
113
116
|
var _a;
|
114
117
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
115
118
|
const rootProps = data.root.props || data.root;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck",
|
3
|
-
"version": "0.14.0-canary.
|
3
|
+
"version": "0.14.0-canary.dd9be54",
|
4
4
|
"author": "Measured Corporation Ltd <hello@measured.co>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -60,7 +60,7 @@
|
|
60
60
|
},
|
61
61
|
"dependencies": {
|
62
62
|
"@measured/auto-frame-component": "0.1.1",
|
63
|
-
"@measured/dnd": "16.6.0-canary.
|
63
|
+
"@measured/dnd": "16.6.0-canary.c7c88e8",
|
64
64
|
"deep-diff": "^1.0.2",
|
65
65
|
"react-hotkeys-hook": "^4.4.1",
|
66
66
|
"react-spinners": "^0.13.8",
|