@measured/puck 0.16.0-canary.39d63e0 → 0.16.0-canary.464aa1e
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/actions-CBAJO1CV.d.mts +425 -0
- package/dist/actions-CBAJO1CV.d.ts +425 -0
- package/dist/chunk-LM7YWFFF.mjs +114 -0
- package/dist/index.css +56 -29
- package/dist/index.d.mts +245 -0
- package/dist/index.d.ts +42 -178
- package/dist/index.js +566 -28810
- package/dist/index.mjs +5923 -0
- package/dist/rsc.d.mts +10 -0
- package/dist/rsc.d.ts +1 -1
- package/dist/rsc.js +3 -2
- package/dist/rsc.mjs +80 -0
- package/package.json +14 -6
- package/dist/Config-B7UadvMA.d.ts +0 -268
package/dist/rsc.d.mts
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
+
import { C as Config, D as Data } from './actions-CBAJO1CV.mjs';
|
3
|
+
import 'react';
|
4
|
+
|
5
|
+
declare function Render<UserConfig extends Config = Config>({ config, data, }: {
|
6
|
+
config: UserConfig;
|
7
|
+
data: Data;
|
8
|
+
}): react_jsx_runtime.JSX.Element;
|
9
|
+
|
10
|
+
export { Render };
|
package/dist/rsc.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
-
import { C as Config, D as Data } from './
|
2
|
+
import { C as Config, D as Data } from './actions-CBAJO1CV.js';
|
3
3
|
import 'react';
|
4
4
|
|
5
5
|
declare function Render<UserConfig extends Config = Config>({ config, data, }: {
|
package/dist/rsc.js
CHANGED
@@ -62,8 +62,9 @@ var setupZone = (data, zoneKey) => {
|
|
62
62
|
if (zoneKey === rootDroppableId) {
|
63
63
|
return data;
|
64
64
|
}
|
65
|
-
const newData = __spreadValues({}, data)
|
66
|
-
|
65
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
66
|
+
zones: data.zones || {}
|
67
|
+
});
|
67
68
|
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
68
69
|
return newData;
|
69
70
|
};
|
package/dist/rsc.mjs
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
import {
|
2
|
+
__spreadProps,
|
3
|
+
__spreadValues,
|
4
|
+
init_react_import,
|
5
|
+
rootDroppableId,
|
6
|
+
setupZone
|
7
|
+
} from "./chunk-LM7YWFFF.mjs";
|
8
|
+
|
9
|
+
// rsc.tsx
|
10
|
+
init_react_import();
|
11
|
+
|
12
|
+
// components/ServerRender/index.tsx
|
13
|
+
init_react_import();
|
14
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
15
|
+
function DropZoneRender({
|
16
|
+
zone,
|
17
|
+
data,
|
18
|
+
areaId = "root",
|
19
|
+
config
|
20
|
+
}) {
|
21
|
+
let zoneCompound = rootDroppableId;
|
22
|
+
let content = (data == null ? void 0 : data.content) || [];
|
23
|
+
if (!data || !config) {
|
24
|
+
return null;
|
25
|
+
}
|
26
|
+
if (areaId && zone && zone !== rootDroppableId) {
|
27
|
+
zoneCompound = `${areaId}:${zone}`;
|
28
|
+
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
29
|
+
}
|
30
|
+
return /* @__PURE__ */ jsx(Fragment, { children: content.map((item) => {
|
31
|
+
const Component = config.components[item.type];
|
32
|
+
if (Component) {
|
33
|
+
return /* @__PURE__ */ jsx(
|
34
|
+
Component.render,
|
35
|
+
__spreadProps(__spreadValues({}, item.props), {
|
36
|
+
puck: {
|
37
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ jsx(
|
38
|
+
DropZoneRender,
|
39
|
+
{
|
40
|
+
zone: zone2,
|
41
|
+
data,
|
42
|
+
areaId: item.props.id,
|
43
|
+
config
|
44
|
+
}
|
45
|
+
)
|
46
|
+
}
|
47
|
+
}),
|
48
|
+
item.props.id
|
49
|
+
);
|
50
|
+
}
|
51
|
+
return null;
|
52
|
+
}) });
|
53
|
+
}
|
54
|
+
function Render({
|
55
|
+
config,
|
56
|
+
data
|
57
|
+
}) {
|
58
|
+
var _a;
|
59
|
+
if ((_a = config.root) == null ? void 0 : _a.render) {
|
60
|
+
const rootProps = data.root.props || data.root;
|
61
|
+
const title = rootProps.title || "";
|
62
|
+
return /* @__PURE__ */ jsx(
|
63
|
+
config.root.render,
|
64
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
65
|
+
puck: {
|
66
|
+
renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(DropZoneRender, { zone, data, config }),
|
67
|
+
isEditing: false
|
68
|
+
},
|
69
|
+
title,
|
70
|
+
editMode: false,
|
71
|
+
id: "puck-root",
|
72
|
+
children: /* @__PURE__ */ jsx(DropZoneRender, { config, data, zone: rootDroppableId })
|
73
|
+
})
|
74
|
+
);
|
75
|
+
}
|
76
|
+
return /* @__PURE__ */ jsx(DropZoneRender, { config, data, zone: rootDroppableId });
|
77
|
+
}
|
78
|
+
export {
|
79
|
+
Render
|
80
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck",
|
3
|
-
"version": "0.16.0-canary.
|
3
|
+
"version": "0.16.0-canary.464aa1e",
|
4
4
|
"author": "Measured Corporation Ltd <hello@measured.co>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -10,12 +10,19 @@
|
|
10
10
|
"types": "./dist/index.d.ts",
|
11
11
|
"exports": {
|
12
12
|
".": {
|
13
|
-
"
|
14
|
-
|
15
|
-
|
13
|
+
"react-server": {
|
14
|
+
"import": "./dist/rsc.mjs",
|
15
|
+
"require": "./dist/rsc.js",
|
16
|
+
"types": "./dist/rsc.d.ts"
|
17
|
+
},
|
18
|
+
"default": {
|
19
|
+
"import": "./dist/index.mjs",
|
20
|
+
"require": "./dist/index.js",
|
21
|
+
"types": "./dist/index.d.ts"
|
22
|
+
}
|
16
23
|
},
|
17
24
|
"./rsc": {
|
18
|
-
"import": "./dist/rsc.
|
25
|
+
"import": "./dist/rsc.mjs",
|
19
26
|
"require": "./dist/rsc.js",
|
20
27
|
"types": "./dist/rsc.d.ts"
|
21
28
|
},
|
@@ -44,9 +51,11 @@
|
|
44
51
|
"@testing-library/react": "^14.0.0",
|
45
52
|
"@types/deep-diff": "^1.0.3",
|
46
53
|
"@types/jest": "^29.5.4",
|
54
|
+
"@types/object-hash": "^3.0.6",
|
47
55
|
"@types/react": "^18.2.0",
|
48
56
|
"@types/react-dom": "^18.2.0",
|
49
57
|
"@types/ua-parser-js": "^0.7.39",
|
58
|
+
"@types/uuid": "^10.0.0",
|
50
59
|
"css-box-model": "^1.2.1",
|
51
60
|
"eslint": "^7.32.0",
|
52
61
|
"eslint-config-custom": "*",
|
@@ -63,7 +72,6 @@
|
|
63
72
|
"@measured/dnd": "16.6.0-canary.4cba1d1",
|
64
73
|
"deep-diff": "^1.0.2",
|
65
74
|
"object-hash": "^3.0.0",
|
66
|
-
"react-frame-component": "^5.2.6",
|
67
75
|
"react-hotkeys-hook": "^4.4.1",
|
68
76
|
"ua-parser-js": "^1.0.37",
|
69
77
|
"use-debounce": "^9.0.4",
|
@@ -1,268 +0,0 @@
|
|
1
|
-
import { CSSProperties, ReactNode, ReactElement } from 'react';
|
2
|
-
|
3
|
-
type ItemSelector = {
|
4
|
-
index: number;
|
5
|
-
zone?: string;
|
6
|
-
};
|
7
|
-
|
8
|
-
type DropZoneProps = {
|
9
|
-
zone: string;
|
10
|
-
allow?: string[];
|
11
|
-
disallow?: string[];
|
12
|
-
style?: CSSProperties;
|
13
|
-
};
|
14
|
-
|
15
|
-
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
16
|
-
type Viewport = {
|
17
|
-
width: number;
|
18
|
-
height?: number | "auto";
|
19
|
-
label?: string;
|
20
|
-
icon?: iconTypes | ReactNode;
|
21
|
-
};
|
22
|
-
type Viewports = Viewport[];
|
23
|
-
|
24
|
-
type FieldOption = {
|
25
|
-
label: string;
|
26
|
-
value: string | number | boolean;
|
27
|
-
};
|
28
|
-
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
29
|
-
type BaseField = {
|
30
|
-
label?: string;
|
31
|
-
};
|
32
|
-
type TextField = BaseField & {
|
33
|
-
type: "text";
|
34
|
-
};
|
35
|
-
type NumberField = BaseField & {
|
36
|
-
type: "number";
|
37
|
-
min?: number;
|
38
|
-
max?: number;
|
39
|
-
};
|
40
|
-
type TextareaField = BaseField & {
|
41
|
-
type: "textarea";
|
42
|
-
};
|
43
|
-
type SelectField = BaseField & {
|
44
|
-
type: "select";
|
45
|
-
options: FieldOptions;
|
46
|
-
};
|
47
|
-
type RadioField = BaseField & {
|
48
|
-
type: "radio";
|
49
|
-
options: FieldOptions;
|
50
|
-
};
|
51
|
-
type ArrayField<Props extends {
|
52
|
-
[key: string]: any;
|
53
|
-
} = {
|
54
|
-
[key: string]: any;
|
55
|
-
}> = BaseField & {
|
56
|
-
type: "array";
|
57
|
-
arrayFields: {
|
58
|
-
[SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
|
59
|
-
};
|
60
|
-
defaultItemProps?: Props[0];
|
61
|
-
getItemSummary?: (item: Props[0], index?: number) => string;
|
62
|
-
max?: number;
|
63
|
-
min?: number;
|
64
|
-
};
|
65
|
-
type ObjectField<Props extends {
|
66
|
-
[key: string]: any;
|
67
|
-
} = {
|
68
|
-
[key: string]: any;
|
69
|
-
}> = BaseField & {
|
70
|
-
type: "object";
|
71
|
-
objectFields: Props extends any[] ? never : {
|
72
|
-
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
73
|
-
};
|
74
|
-
};
|
75
|
-
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
76
|
-
name: string;
|
77
|
-
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
78
|
-
mapProp?: (value: TableShape) => PropShape;
|
79
|
-
};
|
80
|
-
type ExternalFieldWithAdaptor<Props extends {
|
81
|
-
[key: string]: any;
|
82
|
-
} = {
|
83
|
-
[key: string]: any;
|
84
|
-
}> = BaseField & {
|
85
|
-
type: "external";
|
86
|
-
placeholder?: string;
|
87
|
-
adaptor: Adaptor<any, any, Props>;
|
88
|
-
adaptorParams?: object;
|
89
|
-
getItemSummary: (item: Props, index?: number) => string;
|
90
|
-
};
|
91
|
-
type ExternalField<Props extends {
|
92
|
-
[key: string]: any;
|
93
|
-
} = {
|
94
|
-
[key: string]: any;
|
95
|
-
}> = BaseField & {
|
96
|
-
type: "external";
|
97
|
-
placeholder?: string;
|
98
|
-
fetchList: (params: {
|
99
|
-
query: string;
|
100
|
-
filters: Record<string, any>;
|
101
|
-
}) => Promise<any[] | null>;
|
102
|
-
mapProp?: (value: any) => Props;
|
103
|
-
mapRow?: (value: any) => Record<string, string | number>;
|
104
|
-
getItemSummary?: (item: Props, index?: number) => string;
|
105
|
-
showSearch?: boolean;
|
106
|
-
initialQuery?: string;
|
107
|
-
filterFields?: Record<string, Field>;
|
108
|
-
initialFilters?: Record<string, any>;
|
109
|
-
};
|
110
|
-
type CustomField<Props extends any = {}> = BaseField & {
|
111
|
-
type: "custom";
|
112
|
-
render: (props: {
|
113
|
-
field: CustomField<Props>;
|
114
|
-
name: string;
|
115
|
-
id: string;
|
116
|
-
value: Props;
|
117
|
-
onChange: (value: Props) => void;
|
118
|
-
readOnly?: boolean;
|
119
|
-
}) => ReactElement;
|
120
|
-
};
|
121
|
-
type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
|
122
|
-
[key: string]: any;
|
123
|
-
} ? Props : any> | ObjectField<Props extends {
|
124
|
-
[key: string]: any;
|
125
|
-
} ? Props : any> | ExternalField<Props extends {
|
126
|
-
[key: string]: any;
|
127
|
-
} ? Props : any> | ExternalFieldWithAdaptor<Props extends {
|
128
|
-
[key: string]: any;
|
129
|
-
} ? Props : any> | CustomField<Props>;
|
130
|
-
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
131
|
-
[PropName in keyof Omit<Required<ComponentProps>, "children" | "editMode">]: Field<ComponentProps[PropName]>;
|
132
|
-
};
|
133
|
-
type FieldProps<ValueType = any, F = Field<any>> = {
|
134
|
-
field: F;
|
135
|
-
value: ValueType;
|
136
|
-
id?: string;
|
137
|
-
onChange: (value: ValueType, uiState?: Partial<UiState>) => void;
|
138
|
-
readOnly?: boolean;
|
139
|
-
};
|
140
|
-
|
141
|
-
type WithPuckProps<Props> = Props & {
|
142
|
-
id: string;
|
143
|
-
};
|
144
|
-
type DefaultRootProps = {
|
145
|
-
title?: string;
|
146
|
-
[key: string]: any;
|
147
|
-
};
|
148
|
-
type DefaultComponentProps = {
|
149
|
-
[key: string]: any;
|
150
|
-
editMode?: boolean;
|
151
|
-
};
|
152
|
-
type Content<Props extends {
|
153
|
-
[key: string]: any;
|
154
|
-
} = {
|
155
|
-
[key: string]: any;
|
156
|
-
}> = ComponentData<Props>[];
|
157
|
-
type PuckComponent<Props> = (props: WithPuckProps<Props & {
|
158
|
-
puck: PuckContext;
|
159
|
-
}>) => JSX.Element;
|
160
|
-
type PuckContext = {
|
161
|
-
renderDropZone: React.FC<DropZoneProps>;
|
162
|
-
isEditing: boolean;
|
163
|
-
};
|
164
|
-
type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps, DataShape = Omit<ComponentData<ComponentProps>, "type">> = {
|
165
|
-
render: PuckComponent<ComponentProps>;
|
166
|
-
label?: string;
|
167
|
-
defaultProps?: DefaultProps;
|
168
|
-
fields?: Fields<ComponentProps>;
|
169
|
-
permissions?: Partial<Permissions>;
|
170
|
-
resolveFields?: (data: DataShape, params: {
|
171
|
-
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
172
|
-
fields: Fields<ComponentProps>;
|
173
|
-
lastFields: Fields<ComponentProps>;
|
174
|
-
lastData: DataShape;
|
175
|
-
appState: AppState;
|
176
|
-
}) => Promise<Fields<ComponentProps>> | Fields<ComponentProps>;
|
177
|
-
resolveData?: (data: DataShape, params: {
|
178
|
-
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
179
|
-
lastData: DataShape;
|
180
|
-
}) => Promise<{
|
181
|
-
props?: Partial<ComponentProps>;
|
182
|
-
readOnly?: Partial<Record<keyof ComponentProps, boolean>>;
|
183
|
-
}> | {
|
184
|
-
props?: Partial<ComponentProps>;
|
185
|
-
readOnly?: Partial<Record<keyof ComponentProps, boolean>>;
|
186
|
-
};
|
187
|
-
};
|
188
|
-
type Category<ComponentName> = {
|
189
|
-
components?: ComponentName[];
|
190
|
-
title?: string;
|
191
|
-
visible?: boolean;
|
192
|
-
defaultExpanded?: boolean;
|
193
|
-
};
|
194
|
-
type Config<Props extends Record<string, any> = Record<string, any>, RootProps extends DefaultRootProps = DefaultRootProps, CategoryName extends string = string> = {
|
195
|
-
categories?: Record<CategoryName, Category<keyof Props>> & {
|
196
|
-
other?: Category<keyof Props>;
|
197
|
-
};
|
198
|
-
components: {
|
199
|
-
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
200
|
-
};
|
201
|
-
root?: Partial<ComponentConfig<RootProps & {
|
202
|
-
children?: ReactNode;
|
203
|
-
}, Partial<RootProps & {
|
204
|
-
children?: ReactNode;
|
205
|
-
}>, RootData>>;
|
206
|
-
};
|
207
|
-
type BaseData<Props extends {
|
208
|
-
[key: string]: any;
|
209
|
-
} = {
|
210
|
-
[key: string]: any;
|
211
|
-
}> = {
|
212
|
-
readOnly?: Partial<Record<keyof Props, boolean>>;
|
213
|
-
};
|
214
|
-
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps> = {
|
215
|
-
type: keyof Props;
|
216
|
-
props: WithPuckProps<Props>;
|
217
|
-
} & BaseData<Props>;
|
218
|
-
type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & {
|
219
|
-
props: Props;
|
220
|
-
};
|
221
|
-
type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
|
222
|
-
type RootData<Props extends DefaultRootProps = DefaultRootProps> = Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
|
223
|
-
type MappedItem = ComponentData;
|
224
|
-
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
225
|
-
root: RootData<RootProps>;
|
226
|
-
content: Content<WithPuckProps<Props>>;
|
227
|
-
zones?: Record<string, Content<WithPuckProps<Props>>>;
|
228
|
-
};
|
229
|
-
type ItemWithId = {
|
230
|
-
_arrayId: string;
|
231
|
-
_originalIndex: number;
|
232
|
-
};
|
233
|
-
type ArrayState = {
|
234
|
-
items: ItemWithId[];
|
235
|
-
openId: string;
|
236
|
-
};
|
237
|
-
type UiState = {
|
238
|
-
leftSideBarVisible: boolean;
|
239
|
-
rightSideBarVisible: boolean;
|
240
|
-
itemSelector: ItemSelector | null;
|
241
|
-
arrayState: Record<string, ArrayState | undefined>;
|
242
|
-
componentList: Record<string, {
|
243
|
-
components?: string[];
|
244
|
-
title?: string;
|
245
|
-
visible?: boolean;
|
246
|
-
expanded?: boolean;
|
247
|
-
}>;
|
248
|
-
isDragging: boolean;
|
249
|
-
viewports: {
|
250
|
-
current: {
|
251
|
-
width: number;
|
252
|
-
height: number | "auto";
|
253
|
-
};
|
254
|
-
controlsVisible: boolean;
|
255
|
-
options: Viewport[];
|
256
|
-
};
|
257
|
-
};
|
258
|
-
type AppState = {
|
259
|
-
data: Data;
|
260
|
-
ui: UiState;
|
261
|
-
};
|
262
|
-
type Permissions = {
|
263
|
-
drag: boolean;
|
264
|
-
duplicate: boolean;
|
265
|
-
delete: boolean;
|
266
|
-
} & Record<string, boolean>;
|
267
|
-
|
268
|
-
export type { AppState as A, BaseData 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, Permissions as P, RootData as R, SelectField as S, TextField as T, UiState as U, Viewports as V, FieldProps as a, DropZoneProps as b, DefaultComponentProps as c, DefaultRootProps as d, RootDataWithProps as e, ComponentData as f, Content as g, PuckComponent as h, PuckContext as i, ComponentConfig as j, RootDataWithoutProps as k, ItemWithId as l, ArrayState as m, BaseField as n, TextareaField as o, RadioField as p, ArrayField as q, Adaptor as r, ExternalField as s, CustomField as t, Fields as u };
|