@measured/puck 0.18.0-canary.c6df5b2 → 0.18.0-canary.cfe4ca8
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 +3 -3
- package/dist/index.css +44 -47
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +123 -60
- package/dist/index.mjs +124 -61
- package/package.json +1 -1
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
|
-
##
|
104
|
+
## Get support
|
105
105
|
|
106
|
-
|
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
|
-
|
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
@@ -136,6 +136,7 @@
|
|
136
136
|
|
137
137
|
/* styles.css */
|
138
138
|
#frame-root {
|
139
|
+
height: 1px;
|
139
140
|
min-height: 100vh;
|
140
141
|
}
|
141
142
|
|
@@ -224,27 +225,10 @@
|
|
224
225
|
}
|
225
226
|
|
226
227
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css/#css-module-data */
|
227
|
-
.
|
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;
|
228
|
+
._InputWrapper_1h1p1_1 + ._InputWrapper_1h1p1_1 {
|
245
229
|
margin-top: 12px;
|
246
230
|
}
|
247
|
-
._Input-
|
231
|
+
._Input-label_1h1p1_5 {
|
248
232
|
align-items: center;
|
249
233
|
color: var(--puck-color-grey-04);
|
250
234
|
display: flex;
|
@@ -252,17 +236,17 @@
|
|
252
236
|
font-size: var(--puck-font-size-xxs);
|
253
237
|
font-weight: 600;
|
254
238
|
}
|
255
|
-
._Input-
|
239
|
+
._Input-labelIcon_1h1p1_14 {
|
256
240
|
color: var(--puck-color-grey-07);
|
257
241
|
display: flex;
|
258
242
|
margin-right: 4px;
|
259
243
|
padding-left: 4px;
|
260
244
|
}
|
261
|
-
._Input-
|
245
|
+
._Input-disabledIcon_1h1p1_21 {
|
262
246
|
color: var(--puck-color-grey-05);
|
263
247
|
margin-left: auto;
|
264
248
|
}
|
265
|
-
._Input-
|
249
|
+
._Input-input_1h1p1_26 {
|
266
250
|
background: var(--puck-color-white);
|
267
251
|
border-width: 1px;
|
268
252
|
border-style: solid;
|
@@ -274,7 +258,7 @@
|
|
274
258
|
transition: border-color 50ms ease-in;
|
275
259
|
width: 100%;
|
276
260
|
}
|
277
|
-
select._Input-
|
261
|
+
select._Input-input_1h1p1_26 {
|
278
262
|
appearance: none;
|
279
263
|
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
264
|
background-size: 12px;
|
@@ -284,25 +268,25 @@ select._Input-input_1l5m8_47 {
|
|
284
268
|
cursor: pointer;
|
285
269
|
}
|
286
270
|
@media (hover: hover) and (pointer: fine) {
|
287
|
-
.
|
288
|
-
.
|
271
|
+
._Input_1h1p1_1:has(> input):hover ._Input-input_1h1p1_26:not([readonly]),
|
272
|
+
._Input_1h1p1_1:has(> textarea):hover ._Input-input_1h1p1_26:not([readonly]) {
|
289
273
|
border-color: var(--puck-color-grey-05);
|
290
274
|
transition: none;
|
291
275
|
}
|
292
|
-
.
|
276
|
+
._Input_1h1p1_1:has(> select):hover ._Input-input_1h1p1_26:not([disabled]) {
|
293
277
|
background-color: var(--puck-color-azure-12);
|
294
278
|
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
279
|
border-color: var(--puck-color-grey-05);
|
296
280
|
transition: none;
|
297
281
|
}
|
298
282
|
}
|
299
|
-
._Input-
|
283
|
+
._Input-input_1h1p1_26:focus {
|
300
284
|
border-color: var(--puck-color-grey-05);
|
301
285
|
outline: 2px solid var(--puck-color-azure-05);
|
302
286
|
transition: none;
|
303
287
|
}
|
304
|
-
._Input--
|
305
|
-
._Input--
|
288
|
+
._Input--readOnly_1h1p1_70 > ._Input-input_1h1p1_26,
|
289
|
+
._Input--readOnly_1h1p1_70 > select._Input-input_1h1p1_26 {
|
306
290
|
background-color: var(--puck-color-grey-11);
|
307
291
|
border-color: var(--puck-color-grey-09);
|
308
292
|
color: var(--puck-color-grey-04);
|
@@ -311,34 +295,34 @@ select._Input-input_1l5m8_47 {
|
|
311
295
|
outline: 0;
|
312
296
|
transition: none;
|
313
297
|
}
|
314
|
-
._Input-
|
298
|
+
._Input-radioGroupItems_1h1p1_81 {
|
315
299
|
display: flex;
|
316
300
|
border: 1px solid var(--puck-color-grey-09);
|
317
301
|
border-radius: 4px;
|
318
302
|
flex-wrap: wrap;
|
319
303
|
}
|
320
|
-
._Input-
|
304
|
+
._Input-radio_1h1p1_81 {
|
321
305
|
border-right: 1px solid var(--puck-color-grey-09);
|
322
306
|
flex-grow: 1;
|
323
307
|
}
|
324
|
-
._Input-
|
308
|
+
._Input-radio_1h1p1_81:first-of-type {
|
325
309
|
border-bottom-left-radius: 4px;
|
326
310
|
border-top-left-radius: 4px;
|
327
311
|
}
|
328
|
-
._Input-
|
312
|
+
._Input-radio_1h1p1_81:first-of-type ._Input-radioInner_1h1p1_98 {
|
329
313
|
border-bottom-left-radius: 3px;
|
330
314
|
border-top-left-radius: 3px;
|
331
315
|
}
|
332
|
-
._Input-
|
316
|
+
._Input-radio_1h1p1_81:last-of-type {
|
333
317
|
border-bottom-right-radius: 4px;
|
334
318
|
border-right: 0;
|
335
319
|
border-top-right-radius: 4px;
|
336
320
|
}
|
337
|
-
._Input-
|
321
|
+
._Input-radio_1h1p1_81:last-of-type ._Input-radioInner_1h1p1_98 {
|
338
322
|
border-bottom-right-radius: 3px;
|
339
323
|
border-top-right-radius: 3px;
|
340
324
|
}
|
341
|
-
._Input-
|
325
|
+
._Input-radioInner_1h1p1_98 {
|
342
326
|
background-color: var(--puck-color-white);
|
343
327
|
color: var(--puck-color-grey-04);
|
344
328
|
cursor: pointer;
|
@@ -347,32 +331,32 @@ select._Input-input_1l5m8_47 {
|
|
347
331
|
text-align: center;
|
348
332
|
transition: background-color 50ms ease-in;
|
349
333
|
}
|
350
|
-
._Input-
|
334
|
+
._Input-radio_1h1p1_81:has(:focus-visible) {
|
351
335
|
outline: 2px solid var(--puck-color-azure-05);
|
352
336
|
outline-offset: 2px;
|
353
337
|
position: relative;
|
354
338
|
}
|
355
339
|
@media (hover: hover) and (pointer: fine) {
|
356
|
-
._Input-
|
340
|
+
._Input-radioInner_1h1p1_98:hover {
|
357
341
|
background-color: var(--puck-color-azure-12);
|
358
342
|
transition: none;
|
359
343
|
}
|
360
344
|
}
|
361
|
-
._Input--
|
345
|
+
._Input--readOnly_1h1p1_70 ._Input-radioInner_1h1p1_98 {
|
362
346
|
background-color: var(--puck-color-white);
|
363
347
|
color: var(--puck-color-grey-04);
|
364
348
|
cursor: default;
|
365
349
|
}
|
366
|
-
._Input-
|
350
|
+
._Input-radio_1h1p1_81 ._Input-radioInput_1h1p1_143:checked ~ ._Input-radioInner_1h1p1_98 {
|
367
351
|
background-color: var(--puck-color-azure-11);
|
368
352
|
color: var(--puck-color-azure-04);
|
369
353
|
font-weight: 500;
|
370
354
|
}
|
371
|
-
._Input--
|
355
|
+
._Input--readOnly_1h1p1_70 ._Input-radioInput_1h1p1_143:checked ~ ._Input-radioInner_1h1p1_98 {
|
372
356
|
background-color: var(--puck-color-grey-11);
|
373
357
|
color: var(--puck-color-grey-04);
|
374
358
|
}
|
375
|
-
._Input-
|
359
|
+
._Input-radio_1h1p1_81 ._Input-radioInput_1h1p1_143 {
|
376
360
|
clip: rect(0 0 0 0);
|
377
361
|
clip-path: inset(100%);
|
378
362
|
height: 1px;
|
@@ -381,7 +365,7 @@ select._Input-input_1l5m8_47 {
|
|
381
365
|
white-space: nowrap;
|
382
366
|
width: 1px;
|
383
367
|
}
|
384
|
-
textarea._Input-
|
368
|
+
textarea._Input-input_1h1p1_26 {
|
385
369
|
margin-bottom: -4px;
|
386
370
|
}
|
387
371
|
|
@@ -1567,14 +1551,14 @@ body:has(._DropZone--isAnimating_kmkdc_70:empty) [data-puck-overlay] {
|
|
1567
1551
|
}
|
1568
1552
|
|
1569
1553
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css/#css-module-data */
|
1570
|
-
.
|
1554
|
+
._PuckFields_10bh7_1 {
|
1571
1555
|
position: relative;
|
1572
1556
|
font-family: var(--puck-font-family);
|
1573
1557
|
}
|
1574
|
-
._PuckFields--
|
1558
|
+
._PuckFields--isLoading_10bh7_6 {
|
1575
1559
|
min-height: 48px;
|
1576
1560
|
}
|
1577
|
-
._PuckFields-
|
1561
|
+
._PuckFields-loadingOverlay_10bh7_10 {
|
1578
1562
|
background: var(--puck-color-white);
|
1579
1563
|
display: flex;
|
1580
1564
|
justify-content: flex-end;
|
@@ -1588,12 +1572,25 @@ body:has(._DropZone--isAnimating_kmkdc_70:empty) [data-puck-overlay] {
|
|
1588
1572
|
box-sizing: border-box;
|
1589
1573
|
opacity: 0.8;
|
1590
1574
|
}
|
1591
|
-
._PuckFields-
|
1575
|
+
._PuckFields-loadingOverlayInner_10bh7_25 {
|
1592
1576
|
display: flex;
|
1593
1577
|
padding: 16px;
|
1594
1578
|
position: sticky;
|
1595
1579
|
top: 0;
|
1596
1580
|
}
|
1581
|
+
._PuckFields-field_10bh7_32 * {
|
1582
|
+
box-sizing: border-box;
|
1583
|
+
}
|
1584
|
+
._PuckFields--wrapFields_10bh7_36 ._PuckFields-field_10bh7_32 {
|
1585
|
+
color: var(--puck-color-grey-04);
|
1586
|
+
padding: 16px;
|
1587
|
+
padding-bottom: 12px;
|
1588
|
+
display: block;
|
1589
|
+
}
|
1590
|
+
._PuckFields--wrapFields_10bh7_36 ._PuckFields-field_10bh7_32 + ._PuckFields-field_10bh7_32 {
|
1591
|
+
border-top: 1px solid var(--puck-color-grey-09);
|
1592
|
+
margin-top: 8px;
|
1593
|
+
}
|
1597
1594
|
|
1598
1595
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css/#css-module-data */
|
1599
1596
|
._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: (
|
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: (
|
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": "
|
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");
|
@@ -1723,7 +1723,14 @@ var DefaultField = ({
|
|
1723
1723
|
value: typeof value === "undefined" ? "" : value.toString(),
|
1724
1724
|
onChange: (e) => {
|
1725
1725
|
if (field.type === "number") {
|
1726
|
-
|
1726
|
+
const numberValue = Number(e.currentTarget.value);
|
1727
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
1728
|
+
return;
|
1729
|
+
}
|
1730
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
1731
|
+
return;
|
1732
|
+
}
|
1733
|
+
onChange(numberValue);
|
1727
1734
|
} else {
|
1728
1735
|
onChange(e.currentTarget.value);
|
1729
1736
|
}
|
@@ -2471,6 +2478,7 @@ var FieldLabelInternal = ({
|
|
2471
2478
|
function AutoFieldInternal(props) {
|
2472
2479
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2473
2480
|
const { dispatch, overrides, selectedItem } = useAppContext();
|
2481
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
2474
2482
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2475
2483
|
const field = props.field;
|
2476
2484
|
const label = field.label;
|
@@ -2535,7 +2543,6 @@ function AutoFieldInternal(props) {
|
|
2535
2543
|
}
|
2536
2544
|
const children = defaultFields[field.type](mergedProps);
|
2537
2545
|
const Render2 = render[field.type];
|
2538
|
-
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
2539
2546
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
2540
2547
|
NestedFieldContext.Provider,
|
2541
2548
|
{
|
@@ -3656,8 +3663,9 @@ var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3656
3663
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3657
3664
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3658
3665
|
var RENDER_DEBUG = false;
|
3666
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
3659
3667
|
var DropZoneEdit = (0, import_react29.forwardRef)(
|
3660
|
-
function
|
3668
|
+
function DropZoneEditInternal({
|
3661
3669
|
zone,
|
3662
3670
|
allow,
|
3663
3671
|
disallow,
|
@@ -3815,10 +3823,10 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3815
3823
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3816
3824
|
}),
|
3817
3825
|
children: contentWithPreview.map((item, i) => {
|
3818
|
-
var _a, _b, _c, _d, _e;
|
3826
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3819
3827
|
const componentId = item.props.id;
|
3820
3828
|
const puckProps = {
|
3821
|
-
renderDropZone:
|
3829
|
+
renderDropZone: DropZoneEditPure,
|
3822
3830
|
isEditing: true,
|
3823
3831
|
dragRef: null
|
3824
3832
|
};
|
@@ -3835,13 +3843,13 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3835
3843
|
const componentConfig = config.components[item.type];
|
3836
3844
|
let componentType = item.type;
|
3837
3845
|
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3838
|
-
if (item.type === "preview"
|
3846
|
+
if (item.type === "preview") {
|
3839
3847
|
let Preview4 = function() {
|
3840
3848
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3841
3849
|
};
|
3842
3850
|
var Preview3 = Preview4;
|
3843
|
-
componentType = preview.componentType;
|
3844
|
-
label = (
|
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";
|
3845
3853
|
Render2 = Preview4;
|
3846
3854
|
}
|
3847
3855
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
@@ -3856,7 +3864,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3856
3864
|
zoneCompound,
|
3857
3865
|
depth: depth + 1,
|
3858
3866
|
index: i,
|
3859
|
-
isLoading: ((
|
3867
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3860
3868
|
isSelected,
|
3861
3869
|
label,
|
3862
3870
|
isEnabled,
|
@@ -3881,8 +3889,9 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3881
3889
|
);
|
3882
3890
|
}
|
3883
3891
|
);
|
3892
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
3884
3893
|
var DropZoneRender = (0, import_react29.forwardRef)(
|
3885
|
-
function
|
3894
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3886
3895
|
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3887
3896
|
const { data, areaId = "root", config } = ctx || {};
|
3888
3897
|
let zoneCompound = rootDroppableId;
|
@@ -3920,7 +3929,9 @@ var DropZoneRender = (0, import_react29.forwardRef)(
|
|
3920
3929
|
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3921
3930
|
Component.render,
|
3922
3931
|
__spreadProps(__spreadValues({}, item.props), {
|
3923
|
-
puck: {
|
3932
|
+
puck: {
|
3933
|
+
renderDropZone: DropZoneRenderPure
|
3934
|
+
}
|
3924
3935
|
})
|
3925
3936
|
)
|
3926
3937
|
},
|
@@ -3995,6 +4006,48 @@ var getFrame = () => {
|
|
3995
4006
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3996
4007
|
};
|
3997
4008
|
|
4009
|
+
// lib/global-position.ts
|
4010
|
+
init_react_import();
|
4011
|
+
var GlobalPosition = class {
|
4012
|
+
constructor(target, original) {
|
4013
|
+
this.scaleFactor = 1;
|
4014
|
+
this.frameEl = null;
|
4015
|
+
this.frameRect = null;
|
4016
|
+
var _a;
|
4017
|
+
this.target = target;
|
4018
|
+
this.original = original;
|
4019
|
+
this.frameEl = document.querySelector("iframe");
|
4020
|
+
if (this.frameEl) {
|
4021
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
4022
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4023
|
+
}
|
4024
|
+
}
|
4025
|
+
get x() {
|
4026
|
+
return this.original.x;
|
4027
|
+
}
|
4028
|
+
get y() {
|
4029
|
+
return this.original.y;
|
4030
|
+
}
|
4031
|
+
get global() {
|
4032
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
4033
|
+
return {
|
4034
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
4035
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
4036
|
+
};
|
4037
|
+
}
|
4038
|
+
return this.original;
|
4039
|
+
}
|
4040
|
+
get frame() {
|
4041
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
4042
|
+
return {
|
4043
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
4044
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
4045
|
+
};
|
4046
|
+
}
|
4047
|
+
return this.original;
|
4048
|
+
}
|
4049
|
+
};
|
4050
|
+
|
3998
4051
|
// lib/dnd/NestedDroppablePlugin.ts
|
3999
4052
|
var depthSort = (candidates) => {
|
4000
4053
|
return candidates.sort((a, b) => {
|
@@ -4024,10 +4077,12 @@ var getZoneId2 = (candidate) => {
|
|
4024
4077
|
}
|
4025
4078
|
return id;
|
4026
4079
|
};
|
4027
|
-
var getPointerCollisions = (position, manager
|
4028
|
-
var _a;
|
4080
|
+
var getPointerCollisions = (position, manager) => {
|
4029
4081
|
const candidates = [];
|
4030
|
-
let elements = ownerDocument.elementsFromPoint(
|
4082
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
4083
|
+
position.x,
|
4084
|
+
position.y
|
4085
|
+
);
|
4031
4086
|
const previewFrame = elements.find(
|
4032
4087
|
(el) => el.getAttribute("data-puck-preview")
|
4033
4088
|
);
|
@@ -4036,17 +4091,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
4036
4091
|
elements = [drawer];
|
4037
4092
|
}
|
4038
4093
|
if (previewFrame) {
|
4039
|
-
const
|
4040
|
-
if (
|
4041
|
-
|
4042
|
-
const frame = getFrame();
|
4043
|
-
if (frame) {
|
4044
|
-
const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
4045
|
-
elements = frame.elementsFromPoint(
|
4046
|
-
(position.x - rect.left) / scaleFactor,
|
4047
|
-
(position.y - rect.top) / scaleFactor
|
4048
|
-
);
|
4049
|
-
}
|
4094
|
+
const frame = getFrame();
|
4095
|
+
if (frame) {
|
4096
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
4050
4097
|
}
|
4051
4098
|
}
|
4052
4099
|
if (elements) {
|
@@ -4063,9 +4110,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
4063
4110
|
}
|
4064
4111
|
return candidates;
|
4065
4112
|
};
|
4066
|
-
var findDeepestCandidate = (position, manager
|
4113
|
+
var findDeepestCandidate = (position, manager) => {
|
4067
4114
|
var _a;
|
4068
|
-
const candidates = getPointerCollisions(position, manager
|
4115
|
+
const candidates = getPointerCollisions(position, manager);
|
4069
4116
|
if (candidates.length > 0) {
|
4070
4117
|
const sortedCandidates = depthSort(candidates);
|
4071
4118
|
const draggable = manager.dragOperation.source;
|
@@ -4118,22 +4165,18 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
4118
4165
|
}
|
4119
4166
|
const cleanupEffect = (0, import_state.effects)(() => {
|
4120
4167
|
const handleMove = (event) => {
|
4121
|
-
const
|
4168
|
+
const target = event.originalTarget || event.target;
|
4169
|
+
const position = new GlobalPosition(target, {
|
4122
4170
|
x: event.clientX,
|
4123
4171
|
y: event.clientY
|
4124
|
-
};
|
4125
|
-
const target = event.originalTarget || event.target;
|
4126
|
-
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
4172
|
+
});
|
4127
4173
|
const elements = document.elementsFromPoint(
|
4128
|
-
|
4129
|
-
|
4174
|
+
position.global.x,
|
4175
|
+
position.global.y
|
4130
4176
|
);
|
4131
4177
|
const overEl = elements.some((el) => el.id === id);
|
4132
4178
|
if (overEl) {
|
4133
|
-
onChange(
|
4134
|
-
findDeepestCandidate(position, manager, ownerDocument),
|
4135
|
-
manager
|
4136
|
-
);
|
4179
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
4137
4180
|
}
|
4138
4181
|
};
|
4139
4182
|
const handleMoveThrottled = throttle(handleMove, 50);
|
@@ -4464,6 +4507,11 @@ var reduceUi = (ui, action) => {
|
|
4464
4507
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4465
4508
|
});
|
4466
4509
|
}
|
4510
|
+
if (action.type === "remove") {
|
4511
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4512
|
+
itemSelector: null
|
4513
|
+
});
|
4514
|
+
}
|
4467
4515
|
return ui;
|
4468
4516
|
};
|
4469
4517
|
|
@@ -4714,6 +4762,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
|
|
4714
4762
|
}
|
4715
4763
|
}
|
4716
4764
|
handlePointerUp(event) {
|
4765
|
+
if (!this.source) {
|
4766
|
+
return;
|
4767
|
+
}
|
4717
4768
|
event.preventDefault();
|
4718
4769
|
event.stopPropagation();
|
4719
4770
|
const { status } = this.manager.dragOperation;
|
@@ -5335,7 +5386,7 @@ var Drawer = ({
|
|
5335
5386
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5336
5387
|
);
|
5337
5388
|
}
|
5338
|
-
const
|
5389
|
+
const id = (0, import_react32.useId)();
|
5339
5390
|
const { ref } = useDroppableSafe({
|
5340
5391
|
id,
|
5341
5392
|
type: "void",
|
@@ -5550,7 +5601,7 @@ init_react_import();
|
|
5550
5601
|
|
5551
5602
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5552
5603
|
init_react_import();
|
5553
|
-
var styles_module_default16 = { "PuckFields": "
|
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" };
|
5554
5605
|
|
5555
5606
|
// components/Puck/components/Fields/index.tsx
|
5556
5607
|
var import_react35 = require("react");
|
@@ -5636,22 +5687,36 @@ var useResolvedFields = () => {
|
|
5636
5687
|
lastData
|
5637
5688
|
});
|
5638
5689
|
}),
|
5639
|
-
[data, config, componentData, selectedItem, resolvedFields, state]
|
5690
|
+
[data, config, componentData, selectedItem, resolvedFields, state, parent]
|
5640
5691
|
);
|
5692
|
+
const [hasParent, setHasParent] = (0, import_react35.useState)(false);
|
5641
5693
|
(0, import_react35.useEffect)(() => {
|
5642
|
-
|
5643
|
-
|
5644
|
-
|
5645
|
-
|
5646
|
-
|
5647
|
-
|
5648
|
-
|
5649
|
-
|
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
|
+
return;
|
5706
|
+
}
|
5650
5707
|
}
|
5651
|
-
|
5708
|
+
setResolvedFields(defaultFields);
|
5709
|
+
}, [
|
5710
|
+
data,
|
5711
|
+
defaultFields,
|
5712
|
+
state.ui.itemSelector,
|
5713
|
+
selectedItem,
|
5714
|
+
hasResolver,
|
5715
|
+
hasParent
|
5716
|
+
]);
|
5652
5717
|
return [resolvedFields, fieldsLoading];
|
5653
5718
|
};
|
5654
|
-
var Fields = () => {
|
5719
|
+
var Fields = ({ wrapFields = true }) => {
|
5655
5720
|
var _a, _b;
|
5656
5721
|
const {
|
5657
5722
|
selectedItem,
|
@@ -5673,7 +5738,7 @@ var Fields = () => {
|
|
5673
5738
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5674
5739
|
"form",
|
5675
5740
|
{
|
5676
|
-
className: getClassName21(),
|
5741
|
+
className: getClassName21({ wrapFields }),
|
5677
5742
|
onSubmit: (e) => {
|
5678
5743
|
e.preventDefault();
|
5679
5744
|
},
|
@@ -5749,7 +5814,7 @@ var Fields = () => {
|
|
5749
5814
|
item: selectedItem
|
5750
5815
|
});
|
5751
5816
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5752
|
-
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)(
|
5753
5818
|
AutoFieldPrivate,
|
5754
5819
|
{
|
5755
5820
|
field,
|
@@ -5758,16 +5823,15 @@ var Fields = () => {
|
|
5758
5823
|
readOnly: !edit || readOnly[fieldName],
|
5759
5824
|
value: selectedItem.props[fieldName],
|
5760
5825
|
onChange
|
5761
|
-
}
|
5762
|
-
|
5763
|
-
);
|
5826
|
+
}
|
5827
|
+
) }, id);
|
5764
5828
|
} else {
|
5765
5829
|
const readOnly = data.root.readOnly || {};
|
5766
5830
|
const { edit } = getPermissions({
|
5767
5831
|
root: true
|
5768
5832
|
});
|
5769
5833
|
const id = `root_${field.type}_${fieldName}`;
|
5770
|
-
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)(
|
5771
5835
|
AutoFieldPrivate,
|
5772
5836
|
{
|
5773
5837
|
field,
|
@@ -5776,9 +5840,8 @@ var Fields = () => {
|
|
5776
5840
|
readOnly: !edit || readOnly[fieldName],
|
5777
5841
|
value: rootProps[fieldName],
|
5778
5842
|
onChange
|
5779
|
-
}
|
5780
|
-
|
5781
|
-
);
|
5843
|
+
}
|
5844
|
+
) }, id);
|
5782
5845
|
}
|
5783
5846
|
}) }),
|
5784
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": "
|
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 {
|
@@ -1530,7 +1530,14 @@ var DefaultField = ({
|
|
1530
1530
|
value: typeof value === "undefined" ? "" : value.toString(),
|
1531
1531
|
onChange: (e) => {
|
1532
1532
|
if (field.type === "number") {
|
1533
|
-
|
1533
|
+
const numberValue = Number(e.currentTarget.value);
|
1534
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
1535
|
+
return;
|
1536
|
+
}
|
1537
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
1538
|
+
return;
|
1539
|
+
}
|
1540
|
+
onChange(numberValue);
|
1534
1541
|
} else {
|
1535
1542
|
onChange(e.currentTarget.value);
|
1536
1543
|
}
|
@@ -2284,6 +2291,7 @@ var FieldLabelInternal = ({
|
|
2284
2291
|
function AutoFieldInternal(props) {
|
2285
2292
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2286
2293
|
const { dispatch, overrides, selectedItem } = useAppContext();
|
2294
|
+
const nestedFieldContext = useContext3(NestedFieldContext);
|
2287
2295
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
2288
2296
|
const field = props.field;
|
2289
2297
|
const label = field.label;
|
@@ -2348,7 +2356,6 @@ function AutoFieldInternal(props) {
|
|
2348
2356
|
}
|
2349
2357
|
const children = defaultFields[field.type](mergedProps);
|
2350
2358
|
const Render2 = render[field.type];
|
2351
|
-
const nestedFieldContext = useContext3(NestedFieldContext);
|
2352
2359
|
return /* @__PURE__ */ jsx19(
|
2353
2360
|
NestedFieldContext.Provider,
|
2354
2361
|
{
|
@@ -2418,7 +2425,7 @@ init_react_import();
|
|
2418
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" };
|
2419
2426
|
|
2420
2427
|
// components/Drawer/index.tsx
|
2421
|
-
import { useMemo as useMemo9, useState as useState18 } from "react";
|
2428
|
+
import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
|
2422
2429
|
|
2423
2430
|
// components/DragDropContext/index.tsx
|
2424
2431
|
init_react_import();
|
@@ -3499,8 +3506,9 @@ import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-r
|
|
3499
3506
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3500
3507
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3501
3508
|
var RENDER_DEBUG = false;
|
3509
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
|
3502
3510
|
var DropZoneEdit = forwardRef3(
|
3503
|
-
function
|
3511
|
+
function DropZoneEditInternal({
|
3504
3512
|
zone,
|
3505
3513
|
allow,
|
3506
3514
|
disallow,
|
@@ -3658,10 +3666,10 @@ var DropZoneEdit = forwardRef3(
|
|
3658
3666
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3659
3667
|
}),
|
3660
3668
|
children: contentWithPreview.map((item, i) => {
|
3661
|
-
var _a, _b, _c, _d, _e;
|
3669
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3662
3670
|
const componentId = item.props.id;
|
3663
3671
|
const puckProps = {
|
3664
|
-
renderDropZone:
|
3672
|
+
renderDropZone: DropZoneEditPure,
|
3665
3673
|
isEditing: true,
|
3666
3674
|
dragRef: null
|
3667
3675
|
};
|
@@ -3678,13 +3686,13 @@ var DropZoneEdit = forwardRef3(
|
|
3678
3686
|
const componentConfig = config.components[item.type];
|
3679
3687
|
let componentType = item.type;
|
3680
3688
|
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3681
|
-
if (item.type === "preview"
|
3689
|
+
if (item.type === "preview") {
|
3682
3690
|
let Preview4 = function() {
|
3683
3691
|
return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3684
3692
|
};
|
3685
3693
|
var Preview3 = Preview4;
|
3686
|
-
componentType = preview.componentType;
|
3687
|
-
label = (
|
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";
|
3688
3696
|
Render2 = Preview4;
|
3689
3697
|
}
|
3690
3698
|
return /* @__PURE__ */ jsx22(
|
@@ -3699,7 +3707,7 @@ var DropZoneEdit = forwardRef3(
|
|
3699
3707
|
zoneCompound,
|
3700
3708
|
depth: depth + 1,
|
3701
3709
|
index: i,
|
3702
|
-
isLoading: ((
|
3710
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3703
3711
|
isSelected,
|
3704
3712
|
label,
|
3705
3713
|
isEnabled,
|
@@ -3724,8 +3732,9 @@ var DropZoneEdit = forwardRef3(
|
|
3724
3732
|
);
|
3725
3733
|
}
|
3726
3734
|
);
|
3735
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
|
3727
3736
|
var DropZoneRender = forwardRef3(
|
3728
|
-
function
|
3737
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3729
3738
|
const ctx = useContext6(dropZoneContext);
|
3730
3739
|
const { data, areaId = "root", config } = ctx || {};
|
3731
3740
|
let zoneCompound = rootDroppableId;
|
@@ -3763,7 +3772,9 @@ var DropZoneRender = forwardRef3(
|
|
3763
3772
|
children: /* @__PURE__ */ jsx22(
|
3764
3773
|
Component.render,
|
3765
3774
|
__spreadProps(__spreadValues({}, item.props), {
|
3766
|
-
puck: {
|
3775
|
+
puck: {
|
3776
|
+
renderDropZone: DropZoneRenderPure
|
3777
|
+
}
|
3767
3778
|
})
|
3768
3779
|
)
|
3769
3780
|
},
|
@@ -3838,6 +3849,48 @@ var getFrame = () => {
|
|
3838
3849
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3839
3850
|
};
|
3840
3851
|
|
3852
|
+
// lib/global-position.ts
|
3853
|
+
init_react_import();
|
3854
|
+
var GlobalPosition = class {
|
3855
|
+
constructor(target, original) {
|
3856
|
+
this.scaleFactor = 1;
|
3857
|
+
this.frameEl = null;
|
3858
|
+
this.frameRect = null;
|
3859
|
+
var _a;
|
3860
|
+
this.target = target;
|
3861
|
+
this.original = original;
|
3862
|
+
this.frameEl = document.querySelector("iframe");
|
3863
|
+
if (this.frameEl) {
|
3864
|
+
this.frameRect = this.frameEl.getBoundingClientRect();
|
3865
|
+
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
3866
|
+
}
|
3867
|
+
}
|
3868
|
+
get x() {
|
3869
|
+
return this.original.x;
|
3870
|
+
}
|
3871
|
+
get y() {
|
3872
|
+
return this.original.y;
|
3873
|
+
}
|
3874
|
+
get global() {
|
3875
|
+
if (document !== this.target.ownerDocument && this.frameRect) {
|
3876
|
+
return {
|
3877
|
+
x: this.x * this.scaleFactor + this.frameRect.left,
|
3878
|
+
y: this.y * this.scaleFactor + this.frameRect.top
|
3879
|
+
};
|
3880
|
+
}
|
3881
|
+
return this.original;
|
3882
|
+
}
|
3883
|
+
get frame() {
|
3884
|
+
if (document === this.target.ownerDocument && this.frameRect) {
|
3885
|
+
return {
|
3886
|
+
x: (this.x - this.frameRect.left) / this.scaleFactor,
|
3887
|
+
y: (this.y - this.frameRect.top) / this.scaleFactor
|
3888
|
+
};
|
3889
|
+
}
|
3890
|
+
return this.original;
|
3891
|
+
}
|
3892
|
+
};
|
3893
|
+
|
3841
3894
|
// lib/dnd/NestedDroppablePlugin.ts
|
3842
3895
|
var depthSort = (candidates) => {
|
3843
3896
|
return candidates.sort((a, b) => {
|
@@ -3867,10 +3920,12 @@ var getZoneId2 = (candidate) => {
|
|
3867
3920
|
}
|
3868
3921
|
return id;
|
3869
3922
|
};
|
3870
|
-
var getPointerCollisions = (position, manager
|
3871
|
-
var _a;
|
3923
|
+
var getPointerCollisions = (position, manager) => {
|
3872
3924
|
const candidates = [];
|
3873
|
-
let elements = ownerDocument.elementsFromPoint(
|
3925
|
+
let elements = position.target.ownerDocument.elementsFromPoint(
|
3926
|
+
position.x,
|
3927
|
+
position.y
|
3928
|
+
);
|
3874
3929
|
const previewFrame = elements.find(
|
3875
3930
|
(el) => el.getAttribute("data-puck-preview")
|
3876
3931
|
);
|
@@ -3879,17 +3934,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3879
3934
|
elements = [drawer];
|
3880
3935
|
}
|
3881
3936
|
if (previewFrame) {
|
3882
|
-
const
|
3883
|
-
if (
|
3884
|
-
|
3885
|
-
const frame = getFrame();
|
3886
|
-
if (frame) {
|
3887
|
-
const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
3888
|
-
elements = frame.elementsFromPoint(
|
3889
|
-
(position.x - rect.left) / scaleFactor,
|
3890
|
-
(position.y - rect.top) / scaleFactor
|
3891
|
-
);
|
3892
|
-
}
|
3937
|
+
const frame = getFrame();
|
3938
|
+
if (frame) {
|
3939
|
+
elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
|
3893
3940
|
}
|
3894
3941
|
}
|
3895
3942
|
if (elements) {
|
@@ -3906,9 +3953,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
|
|
3906
3953
|
}
|
3907
3954
|
return candidates;
|
3908
3955
|
};
|
3909
|
-
var findDeepestCandidate = (position, manager
|
3956
|
+
var findDeepestCandidate = (position, manager) => {
|
3910
3957
|
var _a;
|
3911
|
-
const candidates = getPointerCollisions(position, manager
|
3958
|
+
const candidates = getPointerCollisions(position, manager);
|
3912
3959
|
if (candidates.length > 0) {
|
3913
3960
|
const sortedCandidates = depthSort(candidates);
|
3914
3961
|
const draggable = manager.dragOperation.source;
|
@@ -3961,22 +4008,18 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
3961
4008
|
}
|
3962
4009
|
const cleanupEffect = effects(() => {
|
3963
4010
|
const handleMove = (event) => {
|
3964
|
-
const
|
4011
|
+
const target = event.originalTarget || event.target;
|
4012
|
+
const position = new GlobalPosition(target, {
|
3965
4013
|
x: event.clientX,
|
3966
4014
|
y: event.clientY
|
3967
|
-
};
|
3968
|
-
const target = event.originalTarget || event.target;
|
3969
|
-
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
4015
|
+
});
|
3970
4016
|
const elements = document.elementsFromPoint(
|
3971
|
-
|
3972
|
-
|
4017
|
+
position.global.x,
|
4018
|
+
position.global.y
|
3973
4019
|
);
|
3974
4020
|
const overEl = elements.some((el) => el.id === id);
|
3975
4021
|
if (overEl) {
|
3976
|
-
onChange(
|
3977
|
-
findDeepestCandidate(position, manager, ownerDocument),
|
3978
|
-
manager
|
3979
|
-
);
|
4022
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
3980
4023
|
}
|
3981
4024
|
};
|
3982
4025
|
const handleMoveThrottled = throttle(handleMove, 50);
|
@@ -4307,6 +4350,11 @@ var reduceUi = (ui, action) => {
|
|
4307
4350
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4308
4351
|
});
|
4309
4352
|
}
|
4353
|
+
if (action.type === "remove") {
|
4354
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4355
|
+
itemSelector: null
|
4356
|
+
});
|
4357
|
+
}
|
4310
4358
|
return ui;
|
4311
4359
|
};
|
4312
4360
|
|
@@ -4566,6 +4614,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
4566
4614
|
}
|
4567
4615
|
}
|
4568
4616
|
handlePointerUp(event) {
|
4617
|
+
if (!this.source) {
|
4618
|
+
return;
|
4619
|
+
}
|
4569
4620
|
event.preventDefault();
|
4570
4621
|
event.stopPropagation();
|
4571
4622
|
const { status } = this.manager.dragOperation;
|
@@ -5187,7 +5238,7 @@ var Drawer = ({
|
|
5187
5238
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5188
5239
|
);
|
5189
5240
|
}
|
5190
|
-
const
|
5241
|
+
const id = useId2();
|
5191
5242
|
const { ref } = useDroppableSafe({
|
5192
5243
|
id,
|
5193
5244
|
type: "void",
|
@@ -5408,7 +5459,7 @@ init_react_import();
|
|
5408
5459
|
|
5409
5460
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5410
5461
|
init_react_import();
|
5411
|
-
var styles_module_default16 = { "PuckFields": "
|
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" };
|
5412
5463
|
|
5413
5464
|
// components/Puck/components/Fields/index.tsx
|
5414
5465
|
import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo11, useState as useState19 } from "react";
|
@@ -5494,22 +5545,36 @@ var useResolvedFields = () => {
|
|
5494
5545
|
lastData
|
5495
5546
|
});
|
5496
5547
|
}),
|
5497
|
-
[data, config, componentData, selectedItem, resolvedFields, state]
|
5548
|
+
[data, config, componentData, selectedItem, resolvedFields, state, parent]
|
5498
5549
|
);
|
5550
|
+
const [hasParent, setHasParent] = useState19(false);
|
5499
5551
|
useEffect16(() => {
|
5500
|
-
|
5501
|
-
|
5502
|
-
|
5503
|
-
|
5504
|
-
|
5505
|
-
|
5506
|
-
|
5507
|
-
|
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
|
+
return;
|
5564
|
+
}
|
5508
5565
|
}
|
5509
|
-
|
5566
|
+
setResolvedFields(defaultFields);
|
5567
|
+
}, [
|
5568
|
+
data,
|
5569
|
+
defaultFields,
|
5570
|
+
state.ui.itemSelector,
|
5571
|
+
selectedItem,
|
5572
|
+
hasResolver,
|
5573
|
+
hasParent
|
5574
|
+
]);
|
5510
5575
|
return [resolvedFields, fieldsLoading];
|
5511
5576
|
};
|
5512
|
-
var Fields = () => {
|
5577
|
+
var Fields = ({ wrapFields = true }) => {
|
5513
5578
|
var _a, _b;
|
5514
5579
|
const {
|
5515
5580
|
selectedItem,
|
@@ -5531,7 +5596,7 @@ var Fields = () => {
|
|
5531
5596
|
return /* @__PURE__ */ jsxs14(
|
5532
5597
|
"form",
|
5533
5598
|
{
|
5534
|
-
className: getClassName21(),
|
5599
|
+
className: getClassName21({ wrapFields }),
|
5535
5600
|
onSubmit: (e) => {
|
5536
5601
|
e.preventDefault();
|
5537
5602
|
},
|
@@ -5607,7 +5672,7 @@ var Fields = () => {
|
|
5607
5672
|
item: selectedItem
|
5608
5673
|
});
|
5609
5674
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5610
|
-
return /* @__PURE__ */ jsx27(
|
5675
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
|
5611
5676
|
AutoFieldPrivate,
|
5612
5677
|
{
|
5613
5678
|
field,
|
@@ -5616,16 +5681,15 @@ var Fields = () => {
|
|
5616
5681
|
readOnly: !edit || readOnly[fieldName],
|
5617
5682
|
value: selectedItem.props[fieldName],
|
5618
5683
|
onChange
|
5619
|
-
}
|
5620
|
-
|
5621
|
-
);
|
5684
|
+
}
|
5685
|
+
) }, id);
|
5622
5686
|
} else {
|
5623
5687
|
const readOnly = data.root.readOnly || {};
|
5624
5688
|
const { edit } = getPermissions({
|
5625
5689
|
root: true
|
5626
5690
|
});
|
5627
5691
|
const id = `root_${field.type}_${fieldName}`;
|
5628
|
-
return /* @__PURE__ */ jsx27(
|
5692
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
|
5629
5693
|
AutoFieldPrivate,
|
5630
5694
|
{
|
5631
5695
|
field,
|
@@ -5634,9 +5698,8 @@ var Fields = () => {
|
|
5634
5698
|
readOnly: !edit || readOnly[fieldName],
|
5635
5699
|
value: rootProps[fieldName],
|
5636
5700
|
onChange
|
5637
|
-
}
|
5638
|
-
|
5639
|
-
);
|
5701
|
+
}
|
5702
|
+
) }, id);
|
5640
5703
|
}
|
5641
5704
|
}) }),
|
5642
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