@measured/puck 0.18.0-canary.1ea6f98 → 0.18.0-canary.30f9a92

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 CHANGED
@@ -101,11 +101,11 @@ Available recipes include:
101
101
  - [Discord server](https://discord.gg/D9e4E3MQVZ) for discussions
102
102
  - [awesome-puck](https://github.com/measuredco/awesome-puck) community repo for plugins, custom fields & more
103
103
 
104
- ## Hire the Puck team
104
+ ## Get support
105
105
 
106
- 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.
106
+ If you have any questions about Puck, please open a [GitHub issue](https://github.com/measuredco/puck/issues) or join us on [Discord](https://discord.gg/D9e4E3MQVZ).
107
107
 
108
- If you need support integrating Puck or creating a beautiful component library, please reach out via the [Measured](https://measured.co) website.
108
+ Or [book a discovery call](https://app.cal.com/chrisvxd/puck-enquiry/) for hands-on support and consultancy.
109
109
 
110
110
  ## License
111
111
 
package/dist/index.css CHANGED
@@ -224,27 +224,10 @@
224
224
  }
225
225
 
226
226
  /* css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css/#css-module-data */
227
- ._InputWrapper_1l5m8_1 {
228
- color: var(--puck-color-grey-04);
229
- padding: 16px;
230
- padding-bottom: 12px;
231
- display: block;
232
- }
233
- ._InputWrapper_1l5m8_1 + ._InputWrapper_1l5m8_1 {
234
- border-top: 1px solid var(--puck-color-grey-09);
235
- margin-top: 8px;
236
- }
237
- ._Input_1l5m8_1 ._InputWrapper_1l5m8_1 {
238
- padding: 0px;
239
- }
240
- ._Input_1l5m8_1 * {
241
- box-sizing: border-box;
242
- }
243
- ._Input_1l5m8_1 ._InputWrapper_1l5m8_1 + ._InputWrapper_1l5m8_1 {
244
- border-top: 0px;
227
+ ._InputWrapper_1h1p1_1 + ._InputWrapper_1h1p1_1 {
245
228
  margin-top: 12px;
246
229
  }
247
- ._Input-label_1l5m8_26 {
230
+ ._Input-label_1h1p1_5 {
248
231
  align-items: center;
249
232
  color: var(--puck-color-grey-04);
250
233
  display: flex;
@@ -252,17 +235,17 @@
252
235
  font-size: var(--puck-font-size-xxs);
253
236
  font-weight: 600;
254
237
  }
255
- ._Input-labelIcon_1l5m8_35 {
238
+ ._Input-labelIcon_1h1p1_14 {
256
239
  color: var(--puck-color-grey-07);
257
240
  display: flex;
258
241
  margin-right: 4px;
259
242
  padding-left: 4px;
260
243
  }
261
- ._Input-disabledIcon_1l5m8_42 {
244
+ ._Input-disabledIcon_1h1p1_21 {
262
245
  color: var(--puck-color-grey-05);
263
246
  margin-left: auto;
264
247
  }
265
- ._Input-input_1l5m8_47 {
248
+ ._Input-input_1h1p1_26 {
266
249
  background: var(--puck-color-white);
267
250
  border-width: 1px;
268
251
  border-style: solid;
@@ -274,7 +257,7 @@
274
257
  transition: border-color 50ms ease-in;
275
258
  width: 100%;
276
259
  }
277
- select._Input-input_1l5m8_47 {
260
+ select._Input-input_1h1p1_26 {
278
261
  appearance: none;
279
262
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23c3c3c3'><polygon points='0,0 100,0 50,50'/></svg>") no-repeat;
280
263
  background-size: 12px;
@@ -284,25 +267,25 @@ select._Input-input_1l5m8_47 {
284
267
  cursor: pointer;
285
268
  }
286
269
  @media (hover: hover) and (pointer: fine) {
287
- ._Input_1l5m8_1:has(> input):hover ._Input-input_1l5m8_47:not([readonly]),
288
- ._Input_1l5m8_1:has(> textarea):hover ._Input-input_1l5m8_47:not([readonly]) {
270
+ ._Input_1h1p1_1:has(> input):hover ._Input-input_1h1p1_26:not([readonly]),
271
+ ._Input_1h1p1_1:has(> textarea):hover ._Input-input_1h1p1_26:not([readonly]) {
289
272
  border-color: var(--puck-color-grey-05);
290
273
  transition: none;
291
274
  }
292
- ._Input_1l5m8_1:has(> select):hover ._Input-input_1l5m8_47:not([disabled]) {
275
+ ._Input_1h1p1_1:has(> select):hover ._Input-input_1h1p1_26:not([disabled]) {
293
276
  background-color: var(--puck-color-azure-12);
294
277
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%235a5a5a'><polygon points='0,0 100,0 50,50'/></svg>");
295
278
  border-color: var(--puck-color-grey-05);
296
279
  transition: none;
297
280
  }
298
281
  }
299
- ._Input-input_1l5m8_47:focus {
282
+ ._Input-input_1h1p1_26:focus {
300
283
  border-color: var(--puck-color-grey-05);
301
284
  outline: 2px solid var(--puck-color-azure-05);
302
285
  transition: none;
303
286
  }
304
- ._Input--readOnly_1l5m8_91 > ._Input-input_1l5m8_47,
305
- ._Input--readOnly_1l5m8_91 > select._Input-input_1l5m8_47 {
287
+ ._Input--readOnly_1h1p1_70 > ._Input-input_1h1p1_26,
288
+ ._Input--readOnly_1h1p1_70 > select._Input-input_1h1p1_26 {
306
289
  background-color: var(--puck-color-grey-11);
307
290
  border-color: var(--puck-color-grey-09);
308
291
  color: var(--puck-color-grey-04);
@@ -311,34 +294,34 @@ select._Input-input_1l5m8_47 {
311
294
  outline: 0;
312
295
  transition: none;
313
296
  }
314
- ._Input-radioGroupItems_1l5m8_102 {
297
+ ._Input-radioGroupItems_1h1p1_81 {
315
298
  display: flex;
316
299
  border: 1px solid var(--puck-color-grey-09);
317
300
  border-radius: 4px;
318
301
  flex-wrap: wrap;
319
302
  }
320
- ._Input-radio_1l5m8_102 {
303
+ ._Input-radio_1h1p1_81 {
321
304
  border-right: 1px solid var(--puck-color-grey-09);
322
305
  flex-grow: 1;
323
306
  }
324
- ._Input-radio_1l5m8_102:first-of-type {
307
+ ._Input-radio_1h1p1_81:first-of-type {
325
308
  border-bottom-left-radius: 4px;
326
309
  border-top-left-radius: 4px;
327
310
  }
328
- ._Input-radio_1l5m8_102:first-of-type ._Input-radioInner_1l5m8_119 {
311
+ ._Input-radio_1h1p1_81:first-of-type ._Input-radioInner_1h1p1_98 {
329
312
  border-bottom-left-radius: 3px;
330
313
  border-top-left-radius: 3px;
331
314
  }
332
- ._Input-radio_1l5m8_102:last-of-type {
315
+ ._Input-radio_1h1p1_81:last-of-type {
333
316
  border-bottom-right-radius: 4px;
334
317
  border-right: 0;
335
318
  border-top-right-radius: 4px;
336
319
  }
337
- ._Input-radio_1l5m8_102:last-of-type ._Input-radioInner_1l5m8_119 {
320
+ ._Input-radio_1h1p1_81:last-of-type ._Input-radioInner_1h1p1_98 {
338
321
  border-bottom-right-radius: 3px;
339
322
  border-top-right-radius: 3px;
340
323
  }
341
- ._Input-radioInner_1l5m8_119 {
324
+ ._Input-radioInner_1h1p1_98 {
342
325
  background-color: var(--puck-color-white);
343
326
  color: var(--puck-color-grey-04);
344
327
  cursor: pointer;
@@ -347,32 +330,32 @@ select._Input-input_1l5m8_47 {
347
330
  text-align: center;
348
331
  transition: background-color 50ms ease-in;
349
332
  }
350
- ._Input-radio_1l5m8_102:has(:focus-visible) {
333
+ ._Input-radio_1h1p1_81:has(:focus-visible) {
351
334
  outline: 2px solid var(--puck-color-azure-05);
352
335
  outline-offset: 2px;
353
336
  position: relative;
354
337
  }
355
338
  @media (hover: hover) and (pointer: fine) {
356
- ._Input-radioInner_1l5m8_119:hover {
339
+ ._Input-radioInner_1h1p1_98:hover {
357
340
  background-color: var(--puck-color-azure-12);
358
341
  transition: none;
359
342
  }
360
343
  }
361
- ._Input--readOnly_1l5m8_91 ._Input-radioInner_1l5m8_119 {
344
+ ._Input--readOnly_1h1p1_70 ._Input-radioInner_1h1p1_98 {
362
345
  background-color: var(--puck-color-white);
363
346
  color: var(--puck-color-grey-04);
364
347
  cursor: default;
365
348
  }
366
- ._Input-radio_1l5m8_102 ._Input-radioInput_1l5m8_164:checked ~ ._Input-radioInner_1l5m8_119 {
349
+ ._Input-radio_1h1p1_81 ._Input-radioInput_1h1p1_143:checked ~ ._Input-radioInner_1h1p1_98 {
367
350
  background-color: var(--puck-color-azure-11);
368
351
  color: var(--puck-color-azure-04);
369
352
  font-weight: 500;
370
353
  }
371
- ._Input--readOnly_1l5m8_91 ._Input-radioInput_1l5m8_164:checked ~ ._Input-radioInner_1l5m8_119 {
354
+ ._Input--readOnly_1h1p1_70 ._Input-radioInput_1h1p1_143:checked ~ ._Input-radioInner_1h1p1_98 {
372
355
  background-color: var(--puck-color-grey-11);
373
356
  color: var(--puck-color-grey-04);
374
357
  }
375
- ._Input-radio_1l5m8_102 ._Input-radioInput_1l5m8_164 {
358
+ ._Input-radio_1h1p1_81 ._Input-radioInput_1h1p1_143 {
376
359
  clip: rect(0 0 0 0);
377
360
  clip-path: inset(100%);
378
361
  height: 1px;
@@ -381,7 +364,7 @@ select._Input-input_1l5m8_47 {
381
364
  white-space: nowrap;
382
365
  width: 1px;
383
366
  }
384
- textarea._Input-input_1l5m8_47 {
367
+ textarea._Input-input_1h1p1_26 {
385
368
  margin-bottom: -4px;
386
369
  }
387
370
 
@@ -1567,14 +1550,14 @@ body:has(._DropZone--isAnimating_kmkdc_70:empty) [data-puck-overlay] {
1567
1550
  }
1568
1551
 
1569
1552
  /* css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css/#css-module-data */
1570
- ._PuckFields_jp3lw_1 {
1553
+ ._PuckFields_10bh7_1 {
1571
1554
  position: relative;
1572
1555
  font-family: var(--puck-font-family);
1573
1556
  }
1574
- ._PuckFields--isLoading_jp3lw_6 {
1557
+ ._PuckFields--isLoading_10bh7_6 {
1575
1558
  min-height: 48px;
1576
1559
  }
1577
- ._PuckFields-loadingOverlay_jp3lw_10 {
1560
+ ._PuckFields-loadingOverlay_10bh7_10 {
1578
1561
  background: var(--puck-color-white);
1579
1562
  display: flex;
1580
1563
  justify-content: flex-end;
@@ -1588,12 +1571,25 @@ body:has(._DropZone--isAnimating_kmkdc_70:empty) [data-puck-overlay] {
1588
1571
  box-sizing: border-box;
1589
1572
  opacity: 0.8;
1590
1573
  }
1591
- ._PuckFields-loadingOverlayInner_jp3lw_25 {
1574
+ ._PuckFields-loadingOverlayInner_10bh7_25 {
1592
1575
  display: flex;
1593
1576
  padding: 16px;
1594
1577
  position: sticky;
1595
1578
  top: 0;
1596
1579
  }
1580
+ ._PuckFields-field_10bh7_32 * {
1581
+ box-sizing: border-box;
1582
+ }
1583
+ ._PuckFields--wrapFields_10bh7_36 ._PuckFields-field_10bh7_32 {
1584
+ color: var(--puck-color-grey-04);
1585
+ padding: 16px;
1586
+ padding-bottom: 12px;
1587
+ display: block;
1588
+ }
1589
+ ._PuckFields--wrapFields_10bh7_36 ._PuckFields-field_10bh7_32 + ._PuckFields-field_10bh7_32 {
1590
+ border-top: 1px solid var(--puck-color-grey-09);
1591
+ margin-top: 8px;
1592
+ }
1597
1593
 
1598
1594
  /* css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css/#css-module-data */
1599
1595
  ._ComponentList_odh9d_1 {
package/dist/index.d.mts CHANGED
@@ -165,7 +165,9 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
165
165
  }): react_jsx_runtime.JSX.Element;
166
166
  declare namespace Puck {
167
167
  var Components: () => react_jsx_runtime.JSX.Element;
168
- var Fields: () => react_jsx_runtime.JSX.Element;
168
+ var Fields: ({ wrapFields }: {
169
+ wrapFields?: boolean;
170
+ }) => react_jsx_runtime.JSX.Element;
169
171
  var Outline: () => react_jsx_runtime.JSX.Element;
170
172
  var Preview: ({ id }: {
171
173
  id?: string;
package/dist/index.d.ts CHANGED
@@ -165,7 +165,9 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
165
165
  }): react_jsx_runtime.JSX.Element;
166
166
  declare namespace Puck {
167
167
  var Components: () => react_jsx_runtime.JSX.Element;
168
- var Fields: () => react_jsx_runtime.JSX.Element;
168
+ var Fields: ({ wrapFields }: {
169
+ wrapFields?: boolean;
170
+ }) => react_jsx_runtime.JSX.Element;
169
171
  var Outline: () => react_jsx_runtime.JSX.Element;
170
172
  var Preview: ({ id }: {
171
173
  id?: string;
package/dist/index.js CHANGED
@@ -308,7 +308,7 @@ init_react_import();
308
308
 
309
309
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
310
310
  init_react_import();
311
- var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
311
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
312
312
 
313
313
  // components/AutoField/index.tsx
314
314
  var import_react20 = require("react");
@@ -3663,8 +3663,9 @@ var import_jsx_runtime22 = require("react/jsx-runtime");
3663
3663
  var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3664
3664
  var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3665
3665
  var RENDER_DEBUG = false;
3666
+ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
3666
3667
  var DropZoneEdit = (0, import_react29.forwardRef)(
3667
- function DropZoneEdit2({
3668
+ function DropZoneEditInternal({
3668
3669
  zone,
3669
3670
  allow,
3670
3671
  disallow,
@@ -3822,10 +3823,10 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3822
3823
  backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3823
3824
  }),
3824
3825
  children: contentWithPreview.map((item, i) => {
3825
- var _a, _b, _c, _d, _e;
3826
+ var _a, _b, _c, _d, _e, _f, _g;
3826
3827
  const componentId = item.props.id;
3827
3828
  const puckProps = {
3828
- renderDropZone: DropZone,
3829
+ renderDropZone: DropZoneEditPure,
3829
3830
  isEditing: true,
3830
3831
  dragRef: null
3831
3832
  };
@@ -3842,13 +3843,13 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3842
3843
  const componentConfig = config.components[item.type];
3843
3844
  let componentType = item.type;
3844
3845
  let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3845
- if (item.type === "preview" && preview) {
3846
+ if (item.type === "preview") {
3846
3847
  let Preview4 = function() {
3847
3848
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3848
3849
  };
3849
3850
  var Preview3 = Preview4;
3850
- componentType = preview.componentType;
3851
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3851
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3852
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3852
3853
  Render2 = Preview4;
3853
3854
  }
3854
3855
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
@@ -3863,7 +3864,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3863
3864
  zoneCompound,
3864
3865
  depth: depth + 1,
3865
3866
  index: i,
3866
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3867
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3867
3868
  isSelected,
3868
3869
  label,
3869
3870
  isEnabled,
@@ -3888,8 +3889,9 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3888
3889
  );
3889
3890
  }
3890
3891
  );
3892
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
3891
3893
  var DropZoneRender = (0, import_react29.forwardRef)(
3892
- function DropZoneRender2({ className, style, zone }, ref) {
3894
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3893
3895
  const ctx = (0, import_react29.useContext)(dropZoneContext);
3894
3896
  const { data, areaId = "root", config } = ctx || {};
3895
3897
  let zoneCompound = rootDroppableId;
@@ -3927,7 +3929,9 @@ var DropZoneRender = (0, import_react29.forwardRef)(
3927
3929
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3928
3930
  Component.render,
3929
3931
  __spreadProps(__spreadValues({}, item.props), {
3930
- puck: { renderDropZone: DropZoneRender2 }
3932
+ puck: {
3933
+ renderDropZone: DropZoneRenderPure
3934
+ }
3931
3935
  })
3932
3936
  )
3933
3937
  },
@@ -4503,6 +4507,11 @@ var reduceUi = (ui, action) => {
4503
4507
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4504
4508
  });
4505
4509
  }
4510
+ if (action.type === "remove") {
4511
+ return __spreadProps(__spreadValues({}, ui), {
4512
+ itemSelector: null
4513
+ });
4514
+ }
4506
4515
  return ui;
4507
4516
  };
4508
4517
 
@@ -4753,6 +4762,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
4753
4762
  }
4754
4763
  }
4755
4764
  handlePointerUp(event) {
4765
+ if (!this.source) {
4766
+ return;
4767
+ }
4756
4768
  event.preventDefault();
4757
4769
  event.stopPropagation();
4758
4770
  const { status } = this.manager.dragOperation;
@@ -5374,7 +5386,7 @@ var Drawer = ({
5374
5386
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5375
5387
  );
5376
5388
  }
5377
- const [id] = (0, import_react32.useState)(generateId());
5389
+ const id = (0, import_react32.useId)();
5378
5390
  const { ref } = useDroppableSafe({
5379
5391
  id,
5380
5392
  type: "void",
@@ -5589,7 +5601,7 @@ init_react_import();
5589
5601
 
5590
5602
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5591
5603
  init_react_import();
5592
- var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
5604
+ var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
5593
5605
 
5594
5606
  // components/Puck/components/Fields/index.tsx
5595
5607
  var import_react35 = require("react");
@@ -5675,22 +5687,36 @@ var useResolvedFields = () => {
5675
5687
  lastData
5676
5688
  });
5677
5689
  }),
5678
- [data, config, componentData, selectedItem, resolvedFields, state]
5690
+ [data, config, componentData, selectedItem, resolvedFields, state, parent]
5679
5691
  );
5692
+ const [hasParent, setHasParent] = (0, import_react35.useState)(false);
5680
5693
  (0, import_react35.useEffect)(() => {
5681
- if (hasResolver) {
5682
- setFieldsLoading(true);
5683
- resolveFields(defaultFields).then((fields) => {
5684
- setResolvedFields(fields || {});
5685
- setFieldsLoading(false);
5686
- });
5687
- } else {
5688
- setResolvedFields(defaultFields);
5694
+ setHasParent(!!parent);
5695
+ }, [parent]);
5696
+ (0, import_react35.useEffect)(() => {
5697
+ var _a2, _b2;
5698
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || hasParent) {
5699
+ if (hasResolver) {
5700
+ setFieldsLoading(true);
5701
+ resolveFields(defaultFields).then((fields) => {
5702
+ setResolvedFields(fields || {});
5703
+ setFieldsLoading(false);
5704
+ });
5705
+ } else {
5706
+ setResolvedFields(defaultFields);
5707
+ }
5689
5708
  }
5690
- }, [data, defaultFields, selectedItem, hasResolver]);
5709
+ }, [
5710
+ data,
5711
+ defaultFields,
5712
+ state.ui.itemSelector,
5713
+ selectedItem,
5714
+ hasResolver,
5715
+ hasParent
5716
+ ]);
5691
5717
  return [resolvedFields, fieldsLoading];
5692
5718
  };
5693
- var Fields = () => {
5719
+ var Fields = ({ wrapFields = true }) => {
5694
5720
  var _a, _b;
5695
5721
  const {
5696
5722
  selectedItem,
@@ -5712,7 +5738,7 @@ var Fields = () => {
5712
5738
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
5713
5739
  "form",
5714
5740
  {
5715
- className: getClassName21(),
5741
+ className: getClassName21({ wrapFields }),
5716
5742
  onSubmit: (e) => {
5717
5743
  e.preventDefault();
5718
5744
  },
@@ -5788,7 +5814,7 @@ var Fields = () => {
5788
5814
  item: selectedItem
5789
5815
  });
5790
5816
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5791
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5817
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5792
5818
  AutoFieldPrivate,
5793
5819
  {
5794
5820
  field,
@@ -5797,16 +5823,15 @@ var Fields = () => {
5797
5823
  readOnly: !edit || readOnly[fieldName],
5798
5824
  value: selectedItem.props[fieldName],
5799
5825
  onChange
5800
- },
5801
- id
5802
- );
5826
+ }
5827
+ ) }, id);
5803
5828
  } else {
5804
5829
  const readOnly = data.root.readOnly || {};
5805
5830
  const { edit } = getPermissions({
5806
5831
  root: true
5807
5832
  });
5808
5833
  const id = `root_${field.type}_${fieldName}`;
5809
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5834
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5810
5835
  AutoFieldPrivate,
5811
5836
  {
5812
5837
  field,
@@ -5815,9 +5840,8 @@ var Fields = () => {
5815
5840
  readOnly: !edit || readOnly[fieldName],
5816
5841
  value: rootProps[fieldName],
5817
5842
  onChange
5818
- },
5819
- id
5820
- );
5843
+ }
5844
+ ) }, id);
5821
5845
  }
5822
5846
  }) }),
5823
5847
  isLoading && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Loader, { size: 16 }) }) })
package/dist/index.mjs CHANGED
@@ -205,7 +205,7 @@ init_react_import();
205
205
 
206
206
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
207
207
  init_react_import();
208
- var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
208
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
209
209
 
210
210
  // components/AutoField/index.tsx
211
211
  import {
@@ -2425,7 +2425,7 @@ init_react_import();
2425
2425
  var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
2426
2426
 
2427
2427
  // components/Drawer/index.tsx
2428
- import { useMemo as useMemo9, useState as useState18 } from "react";
2428
+ import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
2429
2429
 
2430
2430
  // components/DragDropContext/index.tsx
2431
2431
  init_react_import();
@@ -3506,8 +3506,9 @@ import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-r
3506
3506
  var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3507
3507
  var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3508
3508
  var RENDER_DEBUG = false;
3509
+ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
3509
3510
  var DropZoneEdit = forwardRef3(
3510
- function DropZoneEdit2({
3511
+ function DropZoneEditInternal({
3511
3512
  zone,
3512
3513
  allow,
3513
3514
  disallow,
@@ -3665,10 +3666,10 @@ var DropZoneEdit = forwardRef3(
3665
3666
  backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3666
3667
  }),
3667
3668
  children: contentWithPreview.map((item, i) => {
3668
- var _a, _b, _c, _d, _e;
3669
+ var _a, _b, _c, _d, _e, _f, _g;
3669
3670
  const componentId = item.props.id;
3670
3671
  const puckProps = {
3671
- renderDropZone: DropZone,
3672
+ renderDropZone: DropZoneEditPure,
3672
3673
  isEditing: true,
3673
3674
  dragRef: null
3674
3675
  };
@@ -3685,13 +3686,13 @@ var DropZoneEdit = forwardRef3(
3685
3686
  const componentConfig = config.components[item.type];
3686
3687
  let componentType = item.type;
3687
3688
  let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3688
- if (item.type === "preview" && preview) {
3689
+ if (item.type === "preview") {
3689
3690
  let Preview4 = function() {
3690
3691
  return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3691
3692
  };
3692
3693
  var Preview3 = Preview4;
3693
- componentType = preview.componentType;
3694
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3694
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3695
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3695
3696
  Render2 = Preview4;
3696
3697
  }
3697
3698
  return /* @__PURE__ */ jsx22(
@@ -3706,7 +3707,7 @@ var DropZoneEdit = forwardRef3(
3706
3707
  zoneCompound,
3707
3708
  depth: depth + 1,
3708
3709
  index: i,
3709
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3710
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3710
3711
  isSelected,
3711
3712
  label,
3712
3713
  isEnabled,
@@ -3731,8 +3732,9 @@ var DropZoneEdit = forwardRef3(
3731
3732
  );
3732
3733
  }
3733
3734
  );
3735
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
3734
3736
  var DropZoneRender = forwardRef3(
3735
- function DropZoneRender2({ className, style, zone }, ref) {
3737
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3736
3738
  const ctx = useContext6(dropZoneContext);
3737
3739
  const { data, areaId = "root", config } = ctx || {};
3738
3740
  let zoneCompound = rootDroppableId;
@@ -3770,7 +3772,9 @@ var DropZoneRender = forwardRef3(
3770
3772
  children: /* @__PURE__ */ jsx22(
3771
3773
  Component.render,
3772
3774
  __spreadProps(__spreadValues({}, item.props), {
3773
- puck: { renderDropZone: DropZoneRender2 }
3775
+ puck: {
3776
+ renderDropZone: DropZoneRenderPure
3777
+ }
3774
3778
  })
3775
3779
  )
3776
3780
  },
@@ -4346,6 +4350,11 @@ var reduceUi = (ui, action) => {
4346
4350
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4347
4351
  });
4348
4352
  }
4353
+ if (action.type === "remove") {
4354
+ return __spreadProps(__spreadValues({}, ui), {
4355
+ itemSelector: null
4356
+ });
4357
+ }
4349
4358
  return ui;
4350
4359
  };
4351
4360
 
@@ -4605,6 +4614,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
4605
4614
  }
4606
4615
  }
4607
4616
  handlePointerUp(event) {
4617
+ if (!this.source) {
4618
+ return;
4619
+ }
4608
4620
  event.preventDefault();
4609
4621
  event.stopPropagation();
4610
4622
  const { status } = this.manager.dragOperation;
@@ -5226,7 +5238,7 @@ var Drawer = ({
5226
5238
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5227
5239
  );
5228
5240
  }
5229
- const [id] = useState18(generateId());
5241
+ const id = useId2();
5230
5242
  const { ref } = useDroppableSafe({
5231
5243
  id,
5232
5244
  type: "void",
@@ -5447,7 +5459,7 @@ init_react_import();
5447
5459
 
5448
5460
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5449
5461
  init_react_import();
5450
- var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
5462
+ var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
5451
5463
 
5452
5464
  // components/Puck/components/Fields/index.tsx
5453
5465
  import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo11, useState as useState19 } from "react";
@@ -5533,22 +5545,36 @@ var useResolvedFields = () => {
5533
5545
  lastData
5534
5546
  });
5535
5547
  }),
5536
- [data, config, componentData, selectedItem, resolvedFields, state]
5548
+ [data, config, componentData, selectedItem, resolvedFields, state, parent]
5537
5549
  );
5550
+ const [hasParent, setHasParent] = useState19(false);
5538
5551
  useEffect16(() => {
5539
- if (hasResolver) {
5540
- setFieldsLoading(true);
5541
- resolveFields(defaultFields).then((fields) => {
5542
- setResolvedFields(fields || {});
5543
- setFieldsLoading(false);
5544
- });
5545
- } else {
5546
- setResolvedFields(defaultFields);
5552
+ setHasParent(!!parent);
5553
+ }, [parent]);
5554
+ useEffect16(() => {
5555
+ var _a2, _b2;
5556
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || hasParent) {
5557
+ if (hasResolver) {
5558
+ setFieldsLoading(true);
5559
+ resolveFields(defaultFields).then((fields) => {
5560
+ setResolvedFields(fields || {});
5561
+ setFieldsLoading(false);
5562
+ });
5563
+ } else {
5564
+ setResolvedFields(defaultFields);
5565
+ }
5547
5566
  }
5548
- }, [data, defaultFields, selectedItem, hasResolver]);
5567
+ }, [
5568
+ data,
5569
+ defaultFields,
5570
+ state.ui.itemSelector,
5571
+ selectedItem,
5572
+ hasResolver,
5573
+ hasParent
5574
+ ]);
5549
5575
  return [resolvedFields, fieldsLoading];
5550
5576
  };
5551
- var Fields = () => {
5577
+ var Fields = ({ wrapFields = true }) => {
5552
5578
  var _a, _b;
5553
5579
  const {
5554
5580
  selectedItem,
@@ -5570,7 +5596,7 @@ var Fields = () => {
5570
5596
  return /* @__PURE__ */ jsxs14(
5571
5597
  "form",
5572
5598
  {
5573
- className: getClassName21(),
5599
+ className: getClassName21({ wrapFields }),
5574
5600
  onSubmit: (e) => {
5575
5601
  e.preventDefault();
5576
5602
  },
@@ -5646,7 +5672,7 @@ var Fields = () => {
5646
5672
  item: selectedItem
5647
5673
  });
5648
5674
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5649
- return /* @__PURE__ */ jsx27(
5675
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5650
5676
  AutoFieldPrivate,
5651
5677
  {
5652
5678
  field,
@@ -5655,16 +5681,15 @@ var Fields = () => {
5655
5681
  readOnly: !edit || readOnly[fieldName],
5656
5682
  value: selectedItem.props[fieldName],
5657
5683
  onChange
5658
- },
5659
- id
5660
- );
5684
+ }
5685
+ ) }, id);
5661
5686
  } else {
5662
5687
  const readOnly = data.root.readOnly || {};
5663
5688
  const { edit } = getPermissions({
5664
5689
  root: true
5665
5690
  });
5666
5691
  const id = `root_${field.type}_${fieldName}`;
5667
- return /* @__PURE__ */ jsx27(
5692
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5668
5693
  AutoFieldPrivate,
5669
5694
  {
5670
5695
  field,
@@ -5673,9 +5698,8 @@ var Fields = () => {
5673
5698
  readOnly: !edit || readOnly[fieldName],
5674
5699
  value: rootProps[fieldName],
5675
5700
  onChange
5676
- },
5677
- id
5678
- );
5701
+ }
5702
+ ) }, id);
5679
5703
  }
5680
5704
  }) }),
5681
5705
  isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.18.0-canary.1ea6f98",
3
+ "version": "0.18.0-canary.30f9a92",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",