@measured/puck 0.3.1 → 0.4.0
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 +70 -29
- package/dist/index.css +22 -21
- package/dist/index.d.ts +9 -9
- package/dist/index.js +24 -24
- package/package.json +1 -1
package/README.md
CHANGED
@@ -7,13 +7,14 @@ The self-hosted, drag and drop editor for React.
|
|
7
7
|
- ✍️ **Inline editing**: Author content directly via puck for convenience
|
8
8
|
- ⭐️ **No vendor lock-in**: Self-host or integrate with your existing application
|
9
9
|
|
10
|
-

|
11
|
-
|
12
10
|
[See demo](https://puck-demo-six.vercel.app/custom/edit)
|
13
11
|
|
14
12
|
## Example
|
15
13
|
|
14
|
+
Render the editor:
|
15
|
+
|
16
16
|
```jsx
|
17
|
+
// Editor.jsx
|
17
18
|
import { Puck } from "puck";
|
18
19
|
|
19
20
|
// Create puck component config
|
@@ -31,20 +32,25 @@ const config = {
|
|
31
32
|
};
|
32
33
|
|
33
34
|
// Describe the initial data
|
34
|
-
const
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
const initialData = {};
|
36
|
+
|
37
|
+
// Save the data to your database
|
38
|
+
const save = (data) => {};
|
39
|
+
|
40
|
+
// Render Puck editor
|
41
|
+
export function Editor() {
|
42
|
+
return <Puck config={config} data={data} onPublish={save} />;
|
43
|
+
}
|
44
|
+
```
|
45
|
+
|
46
|
+
Render the page:
|
47
|
+
|
48
|
+
```jsx
|
49
|
+
// Page.jsx
|
50
|
+
import { Render } from "puck";
|
44
51
|
|
45
|
-
// Render Puck
|
46
52
|
export function Page() {
|
47
|
-
return <
|
53
|
+
return <Render config={config} data={data} />;
|
48
54
|
}
|
49
55
|
```
|
50
56
|
|
@@ -80,21 +86,19 @@ Puck can be configured to work with plugins. Plugins can extend the functionalit
|
|
80
86
|
|
81
87
|
The plugin API follows a React paradigm. Each plugin passed to the Puck editor can provide three functions:
|
82
88
|
|
83
|
-
|
84
|
-
|
85
|
-
- `renderPage` (`Component`): Render the root node of the preview content
|
86
|
-
- `renderPageFields` (`Component`): Render the page fields
|
89
|
+
- `renderRoot` (`Component`): Render the root node of the preview content
|
90
|
+
- `renderRootFields` (`Component`): Render the root fields
|
87
91
|
- `renderFields` (`Component`): Render the fields for the currently selected component
|
88
92
|
|
89
|
-
Each render function receives the `children` prop, which you
|
93
|
+
Each render function receives the `children` prop, which you must render, and the `data` prop, which can be used to read the data model.
|
90
94
|
|
91
95
|
#### Example
|
92
96
|
|
93
|
-
Here's a basic plugin that renders a "My plugin" heading in the
|
97
|
+
Here's a basic plugin that renders a "My plugin" heading in the root field area:
|
94
98
|
|
95
99
|
```jsx
|
96
100
|
const myPlugin = {
|
97
|
-
|
101
|
+
renderRootFields: (props) => (
|
98
102
|
<div>
|
99
103
|
{props.children}
|
100
104
|
|
@@ -106,14 +110,32 @@ const myPlugin = {
|
|
106
110
|
|
107
111
|
## Reference
|
108
112
|
|
113
|
+
### `<Puck>`
|
114
|
+
|
115
|
+
The `<Puck>` component renders the Puck editor.
|
116
|
+
|
117
|
+
- **config** (`Config`): Puck component configuration
|
118
|
+
- **data** (`Data`): Initial data to render
|
119
|
+
- **onChange** (`(Data) => void` [optional]): Callback that triggers when the user makes a change
|
120
|
+
- **onPublish** (`(Data) => void` [optional]): Callback that triggers when the user hits the "Publish" button
|
121
|
+
- **renderHeader** (`Component` [optional]): Render function for overriding the Puck header component
|
122
|
+
- **plugins** (`Plugin[]` [optional]): Array of plugins that can be used to enhance Puck
|
123
|
+
|
124
|
+
### `<Render>`
|
125
|
+
|
126
|
+
The `<Render>` component renders user-facing UI using Puck data.
|
127
|
+
|
128
|
+
- **config** (`Config`): Puck component configuration
|
129
|
+
- **data** (`Data`): Data to render
|
130
|
+
|
109
131
|
### `Config`
|
110
132
|
|
111
133
|
The `Config` object describes which components Puck should render, how they should render and which inputs are available to them.
|
112
134
|
|
113
|
-
- **
|
135
|
+
- **root** (`object`)
|
114
136
|
- **fields** (`object`):
|
115
|
-
- **title** (`Field`):
|
116
|
-
- **[fieldName]** (`Field`): User defined fields, used to describe the input data stored in the `
|
137
|
+
- **title** (`Field`): Title of the content, typically used for the page title.
|
138
|
+
- **[fieldName]** (`Field`): User defined fields, used to describe the input data stored in the `root` key.
|
117
139
|
- **render** (`Component`): Render a React component at the root of your component tree. Useful for defining context providers.
|
118
140
|
- **components** (`object`): Definitions for each of the components you want to show in the visual editor
|
119
141
|
- **[componentName]** (`object`)
|
@@ -129,24 +151,43 @@ A `Field` represents a user input field shown in the Puck interface.
|
|
129
151
|
- **label** (`text` [optional]): A label for the input. Will use the key if not provided.
|
130
152
|
- **arrayFields** (`object`): Object describing sub-fields for items in an `array` input
|
131
153
|
- **[fieldName]** (`Field`): The Field objects describing the input data for each item
|
132
|
-
- **getItemSummary** (`(object, number) => string` [optional]): Function to get the name of each item when using
|
154
|
+
- **getItemSummary** (`(object, number) => string` [optional]): Function to get the name of each item when using the `array` or `external` field types
|
133
155
|
- **defaultItemProps** (`object` [optional]): Default props to pass to each new item added, when using a `array` field type
|
134
156
|
- **options** (`object[]`): array of items to render for select-type inputs
|
135
157
|
- **label** (`string`)
|
136
158
|
- **value** (`string`)
|
159
|
+
- **adaptor** (`Adaptor`): Content adaptor if using the `external` input type
|
160
|
+
- **adaptorParams** (`object`): Paramaters passed to the adaptor
|
137
161
|
|
138
162
|
### `Data`
|
139
163
|
|
140
|
-
The `Data` object stores the state
|
164
|
+
The `Data` object stores the puck state.
|
141
165
|
|
142
|
-
- **
|
143
|
-
- **title** (string):
|
144
|
-
- **[prop]** (string): User defined data from
|
166
|
+
- **root** (`object`):
|
167
|
+
- **title** (string): Title of the content, typically used for the page title
|
168
|
+
- **[prop]** (string): User defined data from `root` fields
|
145
169
|
- **content** (`object[]`):
|
146
170
|
- **type** (string): Component name
|
147
171
|
- **props** (object):
|
148
172
|
- **[prop]** (string): User defined data from component fields
|
149
173
|
|
174
|
+
### `Adaptor`
|
175
|
+
|
176
|
+
An `Adaptor` can be used to load content from an external content repository, like Strapi.js.
|
177
|
+
|
178
|
+
- **name** (`string`): The human-readable name of the adaptor
|
179
|
+
- **fetchList** (`(adaptorParams: object) => object`): Fetch a list of content and return an array
|
180
|
+
|
181
|
+
> NB Using an adaptor on the reserved field name `_data` will spread the resulting data over your object, and lock the overridden fields.
|
182
|
+
|
183
|
+
### `Plugin`
|
184
|
+
|
185
|
+
Plugins that can be used to enhance Puck.
|
186
|
+
|
187
|
+
- **renderRoot** (`Component`): Render the root node of the preview content
|
188
|
+
- **renderRootFields** (`Component`): Render the root fields
|
189
|
+
- **renderFields** (`Component`): Render the fields for the currently selected component
|
190
|
+
|
150
191
|
## License
|
151
192
|
|
152
193
|
MIT © [Measured Co.](https://github.com/measuredco)
|
package/dist/index.css
CHANGED
@@ -208,13 +208,13 @@
|
|
208
208
|
}
|
209
209
|
|
210
210
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css/#css-module-data */
|
211
|
-
.
|
211
|
+
._ExternalInput_1dp4v_1 {
|
212
212
|
font-family: var(--puck-font-stack);
|
213
213
|
}
|
214
|
-
._ExternalInput-
|
214
|
+
._ExternalInput-actions_1dp4v_5 {
|
215
215
|
display: flex;
|
216
216
|
}
|
217
|
-
._ExternalInput-
|
217
|
+
._ExternalInput-button_1dp4v_9 {
|
218
218
|
background-color: white;
|
219
219
|
border: 1px solid var(--puck-color-grey-8);
|
220
220
|
border-radius: 4px;
|
@@ -225,20 +225,21 @@
|
|
225
225
|
text-overflow: ellipsis;
|
226
226
|
position: relative;
|
227
227
|
overflow: hidden;
|
228
|
+
flex-grow: 1;
|
228
229
|
}
|
229
|
-
._ExternalInput-
|
230
|
-
._ExternalInput-
|
230
|
+
._ExternalInput-button_1dp4v_9:hover,
|
231
|
+
._ExternalInput-detachButton_1dp4v_24:hover {
|
231
232
|
cursor: pointer;
|
232
233
|
background: var(--puck-color-grey-10);
|
233
234
|
border-color: var(--puck-color-neutral-3);
|
234
235
|
z-index: 1;
|
235
236
|
}
|
236
|
-
._ExternalInput--
|
237
|
+
._ExternalInput--hasData_1dp4v_31 ._ExternalInput-button_1dp4v_9 {
|
237
238
|
color: var(--puck-color-neutral-4);
|
238
239
|
border-top-right-radius: 0px;
|
239
240
|
border-bottom-right-radius: 0px;
|
240
241
|
}
|
241
|
-
._ExternalInput-
|
242
|
+
._ExternalInput-detachButton_1dp4v_24 {
|
242
243
|
border: 1px solid var(--puck-color-grey-8);
|
243
244
|
border-top-right-radius: 4px;
|
244
245
|
border-bottom-right-radius: 4px;
|
@@ -246,7 +247,7 @@
|
|
246
247
|
padding: 8px 12px;
|
247
248
|
margin-left: -1px;
|
248
249
|
}
|
249
|
-
._ExternalInput-
|
250
|
+
._ExternalInput-modal_1dp4v_46 {
|
250
251
|
background: #00000099;
|
251
252
|
display: none;
|
252
253
|
justify-content: center;
|
@@ -259,10 +260,10 @@
|
|
259
260
|
z-index: 1;
|
260
261
|
padding: 64px;
|
261
262
|
}
|
262
|
-
._ExternalInput--
|
263
|
+
._ExternalInput--modalVisible_1dp4v_60 ._ExternalInput-modal_1dp4v_46 {
|
263
264
|
display: flex;
|
264
265
|
}
|
265
|
-
._ExternalInput-
|
266
|
+
._ExternalInput-modalInner_1dp4v_64 {
|
266
267
|
width: 100%;
|
267
268
|
max-width: 1024px;
|
268
269
|
border-radius: 16px;
|
@@ -272,51 +273,51 @@
|
|
272
273
|
flex-direction: column;
|
273
274
|
max-height: 90vh;
|
274
275
|
}
|
275
|
-
._ExternalInput-
|
276
|
+
._ExternalInput-modalHeading_1dp4v_75 {
|
276
277
|
background-color: white;
|
277
278
|
padding: 32px 24px;
|
278
279
|
}
|
279
|
-
._ExternalInput-
|
280
|
+
._ExternalInput-modalTableWrapper_1dp4v_80 {
|
280
281
|
overflow-x: scroll;
|
281
282
|
overflow-y: scroll;
|
282
283
|
flex-grow: 1;
|
283
284
|
}
|
284
|
-
.
|
285
|
+
._ExternalInput_1dp4v_1 table {
|
285
286
|
border-spacing: 0px;
|
286
287
|
color: var(--puck-color-neutral-4);
|
287
288
|
position: relative;
|
288
289
|
}
|
289
|
-
.
|
290
|
+
._ExternalInput_1dp4v_1 thead {
|
290
291
|
position: sticky;
|
291
292
|
top: 0;
|
292
293
|
}
|
293
|
-
.
|
294
|
+
._ExternalInput_1dp4v_1 th {
|
294
295
|
background-color: var(--puck-color-grey-1);
|
295
296
|
color: white;
|
296
297
|
font-weight: 700;
|
297
298
|
padding: 16px 24px;
|
298
299
|
opacity: 0.9;
|
299
300
|
}
|
300
|
-
.
|
301
|
+
._ExternalInput_1dp4v_1 td {
|
301
302
|
padding: 16px 24px;
|
302
303
|
}
|
303
|
-
.
|
304
|
+
._ExternalInput_1dp4v_1 tr:nth-of-type(n) {
|
304
305
|
background-color: white;
|
305
306
|
}
|
306
|
-
.
|
307
|
+
._ExternalInput_1dp4v_1 tr:nth-of-type(2n) {
|
307
308
|
background-color: var(--puck-color-grey-9);
|
308
309
|
}
|
309
|
-
.
|
310
|
+
._ExternalInput_1dp4v_1 tr td:first-of-type {
|
310
311
|
font-weight: 500;
|
311
312
|
}
|
312
|
-
.
|
313
|
+
._ExternalInput_1dp4v_1 tr:hover {
|
313
314
|
background: var(--puck-color-grey-10);
|
314
315
|
color: var(--puck-color-azure-4);
|
315
316
|
cursor: pointer;
|
316
317
|
position: relative;
|
317
318
|
margin-left: -5px;
|
318
319
|
}
|
319
|
-
.
|
320
|
+
._ExternalInput_1dp4v_1 tr:hover td:first-of-type {
|
320
321
|
border-left: 4px solid var(--puck-color-azure-4);
|
321
322
|
padding-left: 20px;
|
322
323
|
}
|
package/dist/index.d.ts
CHANGED
@@ -17,14 +17,14 @@ type Field<Props extends {
|
|
17
17
|
arrayFields?: {
|
18
18
|
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
19
19
|
};
|
20
|
-
getItemSummary?: (item: Props, index
|
20
|
+
getItemSummary?: (item: Props, index?: number) => string;
|
21
21
|
defaultItemProps?: Props;
|
22
22
|
options?: {
|
23
23
|
label: string;
|
24
24
|
value: string | number;
|
25
25
|
}[];
|
26
26
|
};
|
27
|
-
type
|
27
|
+
type DefaultRootProps = {
|
28
28
|
children: ReactNode;
|
29
29
|
title: string;
|
30
30
|
editMode: boolean;
|
@@ -46,11 +46,11 @@ type Config<Props extends {
|
|
46
46
|
[key: string]: any;
|
47
47
|
} = {
|
48
48
|
[key: string]: any;
|
49
|
-
},
|
49
|
+
}, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
50
50
|
components: {
|
51
51
|
[ComponentName in keyof Props]: ComponentConfig<Props[ComponentName]>;
|
52
52
|
};
|
53
|
-
|
53
|
+
root?: ComponentConfig<RootProps & {
|
54
54
|
children: ReactNode;
|
55
55
|
}>;
|
56
56
|
};
|
@@ -70,23 +70,23 @@ type Data<Props extends {
|
|
70
70
|
[key: string]: any;
|
71
71
|
} = {
|
72
72
|
[key: string]: any;
|
73
|
-
},
|
73
|
+
}, RootProps extends {
|
74
74
|
title: string;
|
75
75
|
[key: string]: any;
|
76
76
|
} = {
|
77
77
|
title: string;
|
78
78
|
[key: string]: any;
|
79
79
|
}> = {
|
80
|
-
|
80
|
+
root: RootProps;
|
81
81
|
content: MappedItem<Props>[];
|
82
82
|
};
|
83
83
|
|
84
84
|
type Plugin = {
|
85
|
-
|
85
|
+
renderRootFields?: (props: {
|
86
86
|
children: ReactNode;
|
87
87
|
data: Data;
|
88
88
|
}) => ReactElement<any>;
|
89
|
-
|
89
|
+
renderRoot?: (props: {
|
90
90
|
children: ReactNode;
|
91
91
|
data: Data;
|
92
92
|
}) => ReactElement<any>;
|
@@ -114,4 +114,4 @@ declare function Render({ config, data }: {
|
|
114
114
|
data: Data;
|
115
115
|
}): react_jsx_runtime.JSX.Element;
|
116
116
|
|
117
|
-
export { Adaptor, ComponentConfig, Config, Data, DefaultComponentProps,
|
117
|
+
export { Adaptor, ComponentConfig, Config, Data, DefaultComponentProps, DefaultRootProps, Field, Fields, Puck, Render };
|
package/dist/index.js
CHANGED
@@ -293,7 +293,7 @@ var import_react4 = require("react");
|
|
293
293
|
|
294
294
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
295
295
|
init_react_import();
|
296
|
-
var styles_module_default2 = { "ExternalInput": "
|
296
|
+
var styles_module_default2 = { "ExternalInput": "_ExternalInput_1dp4v_1", "ExternalInput-actions": "_ExternalInput-actions_1dp4v_5", "ExternalInput-button": "_ExternalInput-button_1dp4v_9", "ExternalInput-detachButton": "_ExternalInput-detachButton_1dp4v_24", "ExternalInput--hasData": "_ExternalInput--hasData_1dp4v_31", "ExternalInput-modal": "_ExternalInput-modal_1dp4v_46", "ExternalInput--modalVisible": "_ExternalInput--modalVisible_1dp4v_60", "ExternalInput-modalInner": "_ExternalInput-modalInner_1dp4v_64", "ExternalInput-modalHeading": "_ExternalInput-modalHeading_1dp4v_75", "ExternalInput-modalTableWrapper": "_ExternalInput-modalTableWrapper_1dp4v_80" };
|
297
297
|
|
298
298
|
// components/ExternalInput/index.tsx
|
299
299
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
@@ -333,7 +333,7 @@ var ExternalInput = ({
|
|
333
333
|
{
|
334
334
|
onClick: () => setOpen(true),
|
335
335
|
className: getClassName2("button"),
|
336
|
-
children: selectedData ? selectedData.
|
336
|
+
children: selectedData ? field.getItemSummary ? field.getItemSummary(selectedData) : `${field.adaptor.name} item` : `Select from ${field.adaptor.name}`
|
337
337
|
}
|
338
338
|
),
|
339
339
|
selectedData && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
@@ -356,8 +356,8 @@ var ExternalInput = ({
|
|
356
356
|
children: [
|
357
357
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: getClassName2("modalHeading"), children: "Select content" }),
|
358
358
|
data.length ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName2("modalTableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("table", { children: [
|
359
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: Object.keys(data[0]
|
360
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: data.map((item) => {
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: Object.keys(data[0]).map((key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { style: { textAlign: "left" }, children: key }, key)) }) }),
|
360
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: data.map((item, i) => {
|
361
361
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
362
362
|
"tr",
|
363
363
|
{
|
@@ -367,12 +367,12 @@ var ExternalInput = ({
|
|
367
367
|
setOpen(false);
|
368
368
|
setSelectedData(item);
|
369
369
|
},
|
370
|
-
children: Object.keys(item
|
370
|
+
children: Object.keys(item).map((key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: item[key] }, key))
|
371
371
|
},
|
372
|
-
|
372
|
+
i
|
373
373
|
);
|
374
374
|
}) })
|
375
|
-
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: "No content" })
|
375
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { padding: 24 }, children: "No content" })
|
376
376
|
]
|
377
377
|
}
|
378
378
|
) })
|
@@ -868,7 +868,7 @@ var PluginRenderer = ({
|
|
868
868
|
};
|
869
869
|
function Puck({
|
870
870
|
config,
|
871
|
-
data: initialData = { content: [],
|
871
|
+
data: initialData = { content: [], root: { title: "" } },
|
872
872
|
onChange,
|
873
873
|
onPublish,
|
874
874
|
plugins = [],
|
@@ -884,20 +884,20 @@ function Puck({
|
|
884
884
|
PluginRenderer,
|
885
885
|
{
|
886
886
|
plugins,
|
887
|
-
renderMethod: "
|
887
|
+
renderMethod: "renderRoot",
|
888
888
|
data: pageProps.data,
|
889
|
-
children: ((_a2 = config.
|
889
|
+
children: ((_a2 = config.root) == null ? void 0 : _a2.render) ? (_b2 = config.root) == null ? void 0 : _b2.render(__spreadProps(__spreadValues({}, pageProps), { editMode: true })) : pageProps.children
|
890
890
|
}
|
891
891
|
);
|
892
892
|
},
|
893
|
-
[config.
|
893
|
+
[config.root]
|
894
894
|
);
|
895
895
|
const PageFieldWrapper = (0, import_react7.useCallback)(
|
896
896
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
897
897
|
PluginRenderer,
|
898
898
|
{
|
899
899
|
plugins,
|
900
|
-
renderMethod: "
|
900
|
+
renderMethod: "renderRootFields",
|
901
901
|
data: props.data,
|
902
902
|
children: props.children
|
903
903
|
}
|
@@ -917,8 +917,8 @@ function Puck({
|
|
917
917
|
[]
|
918
918
|
);
|
919
919
|
const FieldWrapper = selectedIndex !== null ? ComponentFieldWrapper : PageFieldWrapper;
|
920
|
-
const
|
921
|
-
let fields = selectedIndex !== null ? ((_b = config.components[data.content[selectedIndex].type]) == null ? void 0 : _b.fields) || {} :
|
920
|
+
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
921
|
+
let fields = selectedIndex !== null ? ((_b = config.components[data.content[selectedIndex].type]) == null ? void 0 : _b.fields) || {} : rootFields;
|
922
922
|
(0, import_react7.useEffect)(() => {
|
923
923
|
if (onChange)
|
924
924
|
onChange(data);
|
@@ -1036,7 +1036,8 @@ function Puck({
|
|
1036
1036
|
{
|
1037
1037
|
style: {
|
1038
1038
|
textAlign: "center",
|
1039
|
-
color: "var(--puck-color-grey-6)"
|
1039
|
+
color: "var(--puck-color-grey-6)",
|
1040
|
+
fontFamily: "var(--puck-font-stack)"
|
1040
1041
|
},
|
1041
1042
|
children: "Add items to your page"
|
1042
1043
|
}
|
@@ -1083,7 +1084,7 @@ function Puck({
|
|
1083
1084
|
overflow: "hidden",
|
1084
1085
|
zoom: 0.75
|
1085
1086
|
},
|
1086
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Page, __spreadProps(__spreadValues({ data }, data.
|
1087
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Page, __spreadProps(__spreadValues({ data }, data.root), { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DroppableStrictMode_default, { droppableId: "droppable", children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
1087
1088
|
"div",
|
1088
1089
|
__spreadProps(__spreadValues({}, provided.droppableProps), {
|
1089
1090
|
ref: provided.innerRef,
|
@@ -1176,7 +1177,7 @@ function Puck({
|
|
1176
1177
|
if (selectedIndex !== null) {
|
1177
1178
|
currentProps = data.content[selectedIndex].props;
|
1178
1179
|
} else {
|
1179
|
-
currentProps = data.
|
1180
|
+
currentProps = data.root;
|
1180
1181
|
}
|
1181
1182
|
if (fieldName === "_data") {
|
1182
1183
|
if (!value) {
|
@@ -1188,8 +1189,7 @@ function Puck({
|
|
1188
1189
|
} else {
|
1189
1190
|
const changedFields = filter(
|
1190
1191
|
// filter out anything not supported by this component
|
1191
|
-
value
|
1192
|
-
// TODO type properly after getting proper state library
|
1192
|
+
value,
|
1193
1193
|
Object.keys(fields)
|
1194
1194
|
);
|
1195
1195
|
newProps = __spreadProps(__spreadValues(__spreadValues({}, currentProps), changedFields), {
|
@@ -1212,7 +1212,7 @@ function Puck({
|
|
1212
1212
|
}))
|
1213
1213
|
}));
|
1214
1214
|
} else {
|
1215
|
-
setData(__spreadProps(__spreadValues({}, data), {
|
1215
|
+
setData(__spreadProps(__spreadValues({}, data), { root: newProps }));
|
1216
1216
|
}
|
1217
1217
|
};
|
1218
1218
|
if (selectedIndex !== null) {
|
@@ -1235,8 +1235,8 @@ function Puck({
|
|
1235
1235
|
field,
|
1236
1236
|
name: fieldName,
|
1237
1237
|
label: field.label,
|
1238
|
-
readOnly: ((_d = (_c = data.
|
1239
|
-
value: data.
|
1238
|
+
readOnly: ((_d = (_c = data.root._meta) == null ? void 0 : _c.locked) == null ? void 0 : _d.indexOf(fieldName)) > -1,
|
1239
|
+
value: data.root[fieldName],
|
1240
1240
|
onChange: onChange2
|
1241
1241
|
},
|
1242
1242
|
`page_${fieldName}`
|
@@ -1262,8 +1262,8 @@ function Render({ config, data }) {
|
|
1262
1262
|
const Component = config.components[item.type].render;
|
1263
1263
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Component, __spreadValues({}, item.props), item.props.id);
|
1264
1264
|
});
|
1265
|
-
if (config.
|
1266
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(config.
|
1265
|
+
if (config.root) {
|
1266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(config.root.render, __spreadProps(__spreadValues({}, data.root), { editMode: false, children }));
|
1267
1267
|
}
|
1268
1268
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { children });
|
1269
1269
|
}
|