@measured/puck 0.16.0-canary.0c7fc83 → 0.16.0-canary.257e4be
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/actions-Dyg9ei4T.d.mts +433 -0
- package/dist/actions-Dyg9ei4T.d.ts +433 -0
- package/dist/chunk-LM7YWFFF.mjs +114 -0
- package/dist/index.css +120 -87
- package/dist/index.d.mts +245 -0
- package/dist/index.d.ts +99 -197
- package/dist/index.js +1090 -29747
- package/dist/index.mjs +5929 -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 +17 -9
- package/dist/Config-041c35a2.d.ts +0 -262
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-Dyg9ei4T.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-Dyg9ei4T.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.257e4be",
|
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,26 +51,27 @@
|
|
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": "*",
|
53
62
|
"jest": "^29.6.4",
|
54
63
|
"jest-environment-jsdom": "^29.6.4",
|
55
64
|
"lucide-react": "^0.298.0",
|
56
|
-
"ts-jest": "^29.
|
65
|
+
"ts-jest": "^29.2.4",
|
57
66
|
"tsconfig": "*",
|
58
|
-
"tsup": "^
|
67
|
+
"tsup": "^8.2.4",
|
59
68
|
"tsup-config": "*",
|
60
|
-
"typescript": "^
|
69
|
+
"typescript": "^5.5.4"
|
61
70
|
},
|
62
71
|
"dependencies": {
|
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,262 +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: {
|
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
|
-
resolveFields?: (data: DataShape, params: {
|
170
|
-
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
171
|
-
fields: Fields<ComponentProps>;
|
172
|
-
lastFields: Fields<ComponentProps>;
|
173
|
-
lastData: DataShape;
|
174
|
-
appState: AppState;
|
175
|
-
}) => Promise<Fields<ComponentProps>> | Fields<ComponentProps>;
|
176
|
-
resolveData?: (data: DataShape, params: {
|
177
|
-
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
178
|
-
lastData: DataShape;
|
179
|
-
}) => Promise<{
|
180
|
-
props?: Partial<ComponentProps>;
|
181
|
-
readOnly?: Partial<Record<keyof ComponentProps, boolean>>;
|
182
|
-
}> | {
|
183
|
-
props?: Partial<ComponentProps>;
|
184
|
-
readOnly?: Partial<Record<keyof ComponentProps, boolean>>;
|
185
|
-
};
|
186
|
-
};
|
187
|
-
type Category<ComponentName> = {
|
188
|
-
components?: ComponentName[];
|
189
|
-
title?: string;
|
190
|
-
visible?: boolean;
|
191
|
-
defaultExpanded?: boolean;
|
192
|
-
};
|
193
|
-
type Config<Props extends Record<string, any> = Record<string, any>, RootProps extends DefaultRootProps = DefaultRootProps, CategoryName extends string = string> = {
|
194
|
-
categories?: Record<CategoryName, Category<keyof Props>> & {
|
195
|
-
other?: Category<keyof Props>;
|
196
|
-
};
|
197
|
-
components: {
|
198
|
-
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
199
|
-
};
|
200
|
-
root?: Partial<ComponentConfig<RootProps & {
|
201
|
-
children?: ReactNode;
|
202
|
-
}, Partial<RootProps & {
|
203
|
-
children?: ReactNode;
|
204
|
-
}>, RootData>>;
|
205
|
-
};
|
206
|
-
type BaseData<Props extends {
|
207
|
-
[key: string]: any;
|
208
|
-
} = {
|
209
|
-
[key: string]: any;
|
210
|
-
}> = {
|
211
|
-
readOnly?: Partial<Record<keyof Props, boolean>>;
|
212
|
-
};
|
213
|
-
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps> = {
|
214
|
-
type: keyof Props;
|
215
|
-
props: WithPuckProps<Props>;
|
216
|
-
} & BaseData<Props>;
|
217
|
-
type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & {
|
218
|
-
props: Props;
|
219
|
-
};
|
220
|
-
type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
|
221
|
-
type RootData<Props extends DefaultRootProps = DefaultRootProps> = Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
|
222
|
-
type MappedItem = ComponentData;
|
223
|
-
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
224
|
-
root: RootData<RootProps>;
|
225
|
-
content: Content<WithPuckProps<Props>>;
|
226
|
-
zones?: Record<string, Content<WithPuckProps<Props>>>;
|
227
|
-
};
|
228
|
-
type ItemWithId = {
|
229
|
-
_arrayId: string;
|
230
|
-
_originalIndex: number;
|
231
|
-
};
|
232
|
-
type ArrayState = {
|
233
|
-
items: ItemWithId[];
|
234
|
-
openId: string;
|
235
|
-
};
|
236
|
-
type UiState = {
|
237
|
-
leftSideBarVisible: boolean;
|
238
|
-
rightSideBarVisible: boolean;
|
239
|
-
itemSelector: ItemSelector | null;
|
240
|
-
arrayState: Record<string, ArrayState | undefined>;
|
241
|
-
componentList: Record<string, {
|
242
|
-
components?: string[];
|
243
|
-
title?: string;
|
244
|
-
visible?: boolean;
|
245
|
-
expanded?: boolean;
|
246
|
-
}>;
|
247
|
-
isDragging: boolean;
|
248
|
-
viewports: {
|
249
|
-
current: {
|
250
|
-
width: number;
|
251
|
-
height: number | "auto";
|
252
|
-
};
|
253
|
-
controlsVisible: boolean;
|
254
|
-
options: Viewport[];
|
255
|
-
};
|
256
|
-
};
|
257
|
-
type AppState = {
|
258
|
-
data: Data;
|
259
|
-
ui: UiState;
|
260
|
-
};
|
261
|
-
|
262
|
-
export { 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, PuckComponent as P, RootDataWithProps as R, SelectField as S, TextField as T, UiState as U, Viewports as V, FieldProps as a, DefaultRootProps as b, DropZoneProps as c, DefaultComponentProps as d, RootData as e, ComponentData as f, Content as g, PuckContext as h, ComponentConfig as i, RootDataWithoutProps as j, ItemWithId as k, ArrayState as l, BaseField as m, TextareaField as n, RadioField as o, ArrayField as p, Adaptor as q, ExternalField as r, CustomField as s, Fields as t };
|