@measured/puck 0.18.0-canary.63b8b9a → 0.18.0-canary.88863c3
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 +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +196 -137
- package/dist/index.mjs +187 -128
- package/package.json +1 -1
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 {
|
@@ -1504,12 +1504,13 @@ var DefaultField = ({
|
|
1504
1504
|
field,
|
1505
1505
|
onChange,
|
1506
1506
|
readOnly,
|
1507
|
-
value,
|
1507
|
+
value: _value,
|
1508
1508
|
name,
|
1509
1509
|
label,
|
1510
1510
|
Label: Label2,
|
1511
1511
|
id
|
1512
1512
|
}) => {
|
1513
|
+
const value = _value;
|
1513
1514
|
return /* @__PURE__ */ jsx9(
|
1514
1515
|
Label2,
|
1515
1516
|
{
|
@@ -1527,7 +1528,7 @@ var DefaultField = ({
|
|
1527
1528
|
type: field.type,
|
1528
1529
|
title: label || name,
|
1529
1530
|
name,
|
1530
|
-
value:
|
1531
|
+
value: (value == null ? void 0 : value.toString) ? value.toString() : "",
|
1531
1532
|
onChange: (e) => {
|
1532
1533
|
if (field.type === "number") {
|
1533
1534
|
const numberValue = Number(e.currentTarget.value);
|
@@ -2436,7 +2437,7 @@ import {
|
|
2436
2437
|
useContext as useContext7,
|
2437
2438
|
useEffect as useEffect15,
|
2438
2439
|
useId,
|
2439
|
-
useRef as
|
2440
|
+
useRef as useRef3,
|
2440
2441
|
useState as useState17
|
2441
2442
|
} from "react";
|
2442
2443
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
@@ -2449,7 +2450,7 @@ import {
|
|
2449
2450
|
useContext as useContext6,
|
2450
2451
|
useEffect as useEffect14,
|
2451
2452
|
useMemo as useMemo8,
|
2452
|
-
useRef as
|
2453
|
+
useRef as useRef2
|
2453
2454
|
} from "react";
|
2454
2455
|
|
2455
2456
|
// components/DraggableComponent/index.tsx
|
@@ -2459,7 +2460,7 @@ import {
|
|
2459
2460
|
useContext as useContext5,
|
2460
2461
|
useEffect as useEffect10,
|
2461
2462
|
useMemo as useMemo7,
|
2462
|
-
useRef
|
2463
|
+
useRef,
|
2463
2464
|
useState as useState13
|
2464
2465
|
} from "react";
|
2465
2466
|
|
@@ -3047,7 +3048,7 @@ var DraggableComponent = ({
|
|
3047
3048
|
}
|
3048
3049
|
});
|
3049
3050
|
const thisIsDragging = status === "dragging";
|
3050
|
-
const ref =
|
3051
|
+
const ref = useRef(null);
|
3051
3052
|
const refSetter = useCallback7(
|
3052
3053
|
(el) => {
|
3053
3054
|
sortableRef(el);
|
@@ -3098,13 +3099,19 @@ var DraggableComponent = ({
|
|
3098
3099
|
}
|
3099
3100
|
}, [ref.current]);
|
3100
3101
|
useEffect10(() => {
|
3101
|
-
|
3102
|
-
|
3102
|
+
ctx == null ? void 0 : ctx.registerPath(
|
3103
|
+
id,
|
3104
|
+
{
|
3103
3105
|
index,
|
3104
3106
|
zone: zoneCompound
|
3105
|
-
}
|
3106
|
-
|
3107
|
-
|
3107
|
+
},
|
3108
|
+
componentType
|
3109
|
+
);
|
3110
|
+
return () => {
|
3111
|
+
var _a;
|
3112
|
+
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3113
|
+
};
|
3114
|
+
}, [id, zoneCompound, index, componentType]);
|
3108
3115
|
const CustomActionBar = useMemo7(
|
3109
3116
|
() => overrides.actionBar || DefaultActionBar,
|
3110
3117
|
[overrides.actionBar]
|
@@ -3577,7 +3584,7 @@ var DropZoneEdit = forwardRef3(
|
|
3577
3584
|
}
|
3578
3585
|
return data.content || [];
|
3579
3586
|
}, [data, zoneCompound]);
|
3580
|
-
const ref =
|
3587
|
+
const ref = useRef2(null);
|
3581
3588
|
const acceptsTarget = useCallback10(
|
3582
3589
|
(componentType) => {
|
3583
3590
|
if (!componentType) {
|
@@ -3666,7 +3673,7 @@ var DropZoneEdit = forwardRef3(
|
|
3666
3673
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3667
3674
|
}),
|
3668
3675
|
children: contentWithPreview.map((item, i) => {
|
3669
|
-
var _a, _b, _c, _d, _e;
|
3676
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3670
3677
|
const componentId = item.props.id;
|
3671
3678
|
const puckProps = {
|
3672
3679
|
renderDropZone: DropZoneEditPure,
|
@@ -3686,13 +3693,13 @@ var DropZoneEdit = forwardRef3(
|
|
3686
3693
|
const componentConfig = config.components[item.type];
|
3687
3694
|
let componentType = item.type;
|
3688
3695
|
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3689
|
-
if (item.type === "preview"
|
3696
|
+
if (item.type === "preview") {
|
3690
3697
|
let Preview4 = function() {
|
3691
3698
|
return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3692
3699
|
};
|
3693
3700
|
var Preview3 = Preview4;
|
3694
|
-
componentType = preview.componentType;
|
3695
|
-
label = (
|
3701
|
+
componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
|
3702
|
+
label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
|
3696
3703
|
Render2 = Preview4;
|
3697
3704
|
}
|
3698
3705
|
return /* @__PURE__ */ jsx22(
|
@@ -3707,7 +3714,7 @@ var DropZoneEdit = forwardRef3(
|
|
3707
3714
|
zoneCompound,
|
3708
3715
|
depth: depth + 1,
|
3709
3716
|
index: i,
|
3710
|
-
isLoading: ((
|
3717
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3711
3718
|
isSelected,
|
3712
3719
|
label,
|
3713
3720
|
isEnabled,
|
@@ -4350,6 +4357,11 @@ var reduceUi = (ui, action) => {
|
|
4350
4357
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4351
4358
|
});
|
4352
4359
|
}
|
4360
|
+
if (action.type === "remove") {
|
4361
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4362
|
+
itemSelector: null
|
4363
|
+
});
|
4364
|
+
}
|
4353
4365
|
return ui;
|
4354
4366
|
};
|
4355
4367
|
|
@@ -4729,7 +4741,7 @@ function useDragListener(type, fn, deps = []) {
|
|
4729
4741
|
}
|
4730
4742
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4731
4743
|
var useTempDisableFallback = (timeout3) => {
|
4732
|
-
const lastFallbackDisable =
|
4744
|
+
const lastFallbackDisable = useRef3(null);
|
4733
4745
|
return useCallback11((manager) => {
|
4734
4746
|
collisionStore.setState({ fallbackEnabled: false });
|
4735
4747
|
const fallbackId = generateId();
|
@@ -4749,7 +4761,7 @@ var DragDropContextClient = ({
|
|
4749
4761
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4750
4762
|
const id = useId();
|
4751
4763
|
const { data } = state;
|
4752
|
-
const debouncedParamsRef =
|
4764
|
+
const debouncedParamsRef = useRef3(null);
|
4753
4765
|
const tempDisableFallback = useTempDisableFallback(100);
|
4754
4766
|
const [zoneStore] = useState17(
|
4755
4767
|
() => createStore3(() => ({
|
@@ -4888,30 +4900,36 @@ var DragDropContextClient = ({
|
|
4888
4900
|
]);
|
4889
4901
|
const [dragListeners, setDragListeners] = useState17({});
|
4890
4902
|
const [pathData, setPathData] = useState17();
|
4891
|
-
const dragMode =
|
4903
|
+
const dragMode = useRef3(null);
|
4892
4904
|
const registerPath = useCallback11(
|
4893
|
-
(selector) => {
|
4894
|
-
const item = getItem(selector, data);
|
4895
|
-
if (!item) {
|
4896
|
-
return;
|
4897
|
-
}
|
4905
|
+
(id2, selector, label) => {
|
4898
4906
|
const [area] = getZoneId(selector.zone);
|
4899
4907
|
setPathData((latestPathData = {}) => {
|
4900
4908
|
const parentPathData = latestPathData[area] || { path: [] };
|
4901
4909
|
return __spreadProps(__spreadValues({}, latestPathData), {
|
4902
|
-
[
|
4910
|
+
[id2]: {
|
4903
4911
|
path: [
|
4904
4912
|
...parentPathData.path,
|
4905
4913
|
...selector.zone ? [selector.zone] : []
|
4906
4914
|
],
|
4907
|
-
label
|
4915
|
+
label
|
4908
4916
|
}
|
4909
4917
|
});
|
4910
4918
|
});
|
4911
4919
|
},
|
4912
4920
|
[data, setPathData]
|
4913
4921
|
);
|
4914
|
-
const
|
4922
|
+
const unregisterPath = useCallback11(
|
4923
|
+
(id2) => {
|
4924
|
+
setPathData((latestPathData = {}) => {
|
4925
|
+
const newPathData = __spreadValues({}, latestPathData);
|
4926
|
+
delete newPathData[id2];
|
4927
|
+
return newPathData;
|
4928
|
+
});
|
4929
|
+
},
|
4930
|
+
[data, setPathData]
|
4931
|
+
);
|
4932
|
+
const initialSelector = useRef3(void 0);
|
4915
4933
|
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
4916
4934
|
dragListenerContext.Provider,
|
4917
4935
|
{
|
@@ -5107,6 +5125,7 @@ var DragDropContextClient = ({
|
|
5107
5125
|
areaId: "root",
|
5108
5126
|
depth: 0,
|
5109
5127
|
registerPath,
|
5128
|
+
unregisterPath,
|
5110
5129
|
pathData,
|
5111
5130
|
path: []
|
5112
5131
|
},
|
@@ -5256,9 +5275,9 @@ Drawer.Item = DrawerItem;
|
|
5256
5275
|
// components/Puck/index.tsx
|
5257
5276
|
init_react_import();
|
5258
5277
|
import {
|
5259
|
-
useCallback as
|
5260
|
-
useEffect as
|
5261
|
-
useMemo as
|
5278
|
+
useCallback as useCallback18,
|
5279
|
+
useEffect as useEffect24,
|
5280
|
+
useMemo as useMemo19,
|
5262
5281
|
useReducer,
|
5263
5282
|
useState as useState26
|
5264
5283
|
} from "react";
|
@@ -5454,36 +5473,61 @@ init_react_import();
|
|
5454
5473
|
|
5455
5474
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5456
5475
|
init_react_import();
|
5457
|
-
var styles_module_default16 = { "PuckFields": "
|
5476
|
+
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" };
|
5458
5477
|
|
5459
5478
|
// components/Puck/components/Fields/index.tsx
|
5460
|
-
import {
|
5479
|
+
import { useMemo as useMemo12 } from "react";
|
5480
|
+
|
5481
|
+
// lib/use-resolved-fields.ts
|
5482
|
+
init_react_import();
|
5483
|
+
import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
|
5461
5484
|
|
5462
5485
|
// lib/use-parent.ts
|
5463
5486
|
init_react_import();
|
5464
|
-
import { useContext as useContext9 } from "react";
|
5465
|
-
var
|
5487
|
+
import { useCallback as useCallback12, useContext as useContext9 } from "react";
|
5488
|
+
var getParent = (itemSelector, pathData, data) => {
|
5466
5489
|
var _a;
|
5467
|
-
|
5468
|
-
const
|
5469
|
-
const
|
5470
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5490
|
+
if (!itemSelector) return null;
|
5491
|
+
const item = getItem(itemSelector, data);
|
5492
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5471
5493
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5472
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5494
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5473
5495
|
return parent || null;
|
5474
5496
|
};
|
5497
|
+
var useGetParent = () => {
|
5498
|
+
const { state } = useAppContext();
|
5499
|
+
const { pathData } = useContext9(dropZoneContext) || {};
|
5500
|
+
return useCallback12(
|
5501
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5502
|
+
[state.ui.itemSelector, pathData, state.data]
|
5503
|
+
);
|
5504
|
+
};
|
5505
|
+
var useParent = () => {
|
5506
|
+
return useGetParent()();
|
5507
|
+
};
|
5475
5508
|
|
5476
|
-
//
|
5477
|
-
|
5478
|
-
|
5509
|
+
// lib/use-on-value-change.ts
|
5510
|
+
init_react_import();
|
5511
|
+
import { useRef as useRef4, useEffect as useEffect16 } from "react";
|
5512
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5513
|
+
const tracked = useRef4(value);
|
5514
|
+
useEffect16(() => {
|
5515
|
+
const oldValue = tracked.current;
|
5516
|
+
if (!compare(value, oldValue)) {
|
5517
|
+
tracked.current = value;
|
5518
|
+
onChange(value, oldValue);
|
5519
|
+
}
|
5520
|
+
}, [onChange, compare, value, ...deps]);
|
5521
|
+
}
|
5522
|
+
|
5523
|
+
// lib/selector-is.ts
|
5524
|
+
init_react_import();
|
5525
|
+
var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
|
5526
|
+
|
5527
|
+
// lib/use-resolved-fields.ts
|
5479
5528
|
var defaultPageFields = {
|
5480
5529
|
title: { type: "text" }
|
5481
5530
|
};
|
5482
|
-
var DefaultFields = ({
|
5483
|
-
children
|
5484
|
-
}) => {
|
5485
|
-
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5486
|
-
};
|
5487
5531
|
var useResolvedFields = () => {
|
5488
5532
|
var _a, _b;
|
5489
5533
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5499,12 +5543,13 @@ var useResolvedFields = () => {
|
|
5499
5543
|
const [lastSelectedData, setLastSelectedData] = useState19({});
|
5500
5544
|
const [resolvedFields, setResolvedFields] = useState19(defaultFields);
|
5501
5545
|
const [fieldsLoading, setFieldsLoading] = useState19(false);
|
5546
|
+
const lastFields = useRef5(defaultFields);
|
5502
5547
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5503
5548
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5504
5549
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5505
5550
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5506
5551
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5507
|
-
const resolveFields =
|
5552
|
+
const resolveFields = useCallback13(
|
5508
5553
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5509
5554
|
var _a2;
|
5510
5555
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5516,7 +5561,7 @@ var useResolvedFields = () => {
|
|
5516
5561
|
{
|
5517
5562
|
changed,
|
5518
5563
|
fields,
|
5519
|
-
lastFields:
|
5564
|
+
lastFields: lastFields.current,
|
5520
5565
|
lastData,
|
5521
5566
|
appState: state,
|
5522
5567
|
parent
|
@@ -5527,7 +5572,7 @@ var useResolvedFields = () => {
|
|
5527
5572
|
return yield config.root.resolveFields(componentData, {
|
5528
5573
|
changed,
|
5529
5574
|
fields,
|
5530
|
-
lastFields:
|
5575
|
+
lastFields: lastFields.current,
|
5531
5576
|
lastData,
|
5532
5577
|
appState: state,
|
5533
5578
|
parent
|
@@ -5536,40 +5581,56 @@ var useResolvedFields = () => {
|
|
5536
5581
|
return defaultResolveFields(componentData, {
|
5537
5582
|
changed,
|
5538
5583
|
fields,
|
5539
|
-
lastFields:
|
5584
|
+
lastFields: lastFields.current,
|
5540
5585
|
lastData
|
5541
5586
|
});
|
5542
5587
|
}),
|
5543
|
-
[data, config, componentData, selectedItem,
|
5588
|
+
[data, config, componentData, selectedItem, state, parent]
|
5544
5589
|
);
|
5545
|
-
const
|
5546
|
-
useEffect16(() => {
|
5547
|
-
setHasParent(!!parent);
|
5548
|
-
}, [parent]);
|
5549
|
-
useEffect16(() => {
|
5590
|
+
const triggerResolver = useCallback13(() => {
|
5550
5591
|
var _a2, _b2;
|
5551
|
-
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" ||
|
5592
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5552
5593
|
if (hasResolver) {
|
5553
5594
|
setFieldsLoading(true);
|
5554
5595
|
resolveFields(defaultFields).then((fields) => {
|
5555
5596
|
setResolvedFields(fields || {});
|
5597
|
+
lastFields.current = fields;
|
5556
5598
|
setFieldsLoading(false);
|
5557
5599
|
});
|
5558
|
-
|
5559
|
-
setResolvedFields(defaultFields);
|
5600
|
+
return;
|
5560
5601
|
}
|
5561
5602
|
}
|
5562
|
-
|
5563
|
-
|
5564
|
-
|
5603
|
+
setResolvedFields(defaultFields);
|
5604
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5605
|
+
useOnValueChange(
|
5565
5606
|
state.ui.itemSelector,
|
5566
|
-
|
5567
|
-
|
5568
|
-
|
5569
|
-
|
5607
|
+
() => {
|
5608
|
+
lastFields.current = defaultFields;
|
5609
|
+
},
|
5610
|
+
selectorIs
|
5611
|
+
);
|
5612
|
+
useOnValueChange(
|
5613
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5614
|
+
() => {
|
5615
|
+
triggerResolver();
|
5616
|
+
},
|
5617
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5618
|
+
);
|
5619
|
+
useEffect17(() => {
|
5620
|
+
triggerResolver();
|
5621
|
+
}, []);
|
5570
5622
|
return [resolvedFields, fieldsLoading];
|
5571
5623
|
};
|
5572
|
-
|
5624
|
+
|
5625
|
+
// components/Puck/components/Fields/index.tsx
|
5626
|
+
import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
5627
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5628
|
+
var DefaultFields = ({
|
5629
|
+
children
|
5630
|
+
}) => {
|
5631
|
+
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5632
|
+
};
|
5633
|
+
var Fields = ({ wrapFields = true }) => {
|
5573
5634
|
var _a, _b;
|
5574
5635
|
const {
|
5575
5636
|
selectedItem,
|
@@ -5587,11 +5648,11 @@ var Fields = () => {
|
|
5587
5648
|
const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
|
5588
5649
|
const isLoading = fieldsResolving || componentResolving;
|
5589
5650
|
const rootProps = data.root.props || data.root;
|
5590
|
-
const Wrapper =
|
5651
|
+
const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
|
5591
5652
|
return /* @__PURE__ */ jsxs14(
|
5592
5653
|
"form",
|
5593
5654
|
{
|
5594
|
-
className: getClassName21(),
|
5655
|
+
className: getClassName21({ wrapFields }),
|
5595
5656
|
onSubmit: (e) => {
|
5596
5657
|
e.preventDefault();
|
5597
5658
|
},
|
@@ -5667,7 +5728,7 @@ var Fields = () => {
|
|
5667
5728
|
item: selectedItem
|
5668
5729
|
});
|
5669
5730
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5670
|
-
return /* @__PURE__ */ jsx27(
|
5731
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
|
5671
5732
|
AutoFieldPrivate,
|
5672
5733
|
{
|
5673
5734
|
field,
|
@@ -5676,16 +5737,15 @@ var Fields = () => {
|
|
5676
5737
|
readOnly: !edit || readOnly[fieldName],
|
5677
5738
|
value: selectedItem.props[fieldName],
|
5678
5739
|
onChange
|
5679
|
-
}
|
5680
|
-
|
5681
|
-
);
|
5740
|
+
}
|
5741
|
+
) }, id);
|
5682
5742
|
} else {
|
5683
5743
|
const readOnly = data.root.readOnly || {};
|
5684
5744
|
const { edit } = getPermissions({
|
5685
5745
|
root: true
|
5686
5746
|
});
|
5687
5747
|
const id = `root_${field.type}_${fieldName}`;
|
5688
|
-
return /* @__PURE__ */ jsx27(
|
5748
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
|
5689
5749
|
AutoFieldPrivate,
|
5690
5750
|
{
|
5691
5751
|
field,
|
@@ -5694,9 +5754,8 @@ var Fields = () => {
|
|
5694
5754
|
readOnly: !edit || readOnly[fieldName],
|
5695
5755
|
value: rootProps[fieldName],
|
5696
5756
|
onChange
|
5697
|
-
}
|
5698
|
-
|
5699
|
-
);
|
5757
|
+
}
|
5758
|
+
) }, id);
|
5700
5759
|
}
|
5701
5760
|
}) }),
|
5702
5761
|
isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
|
@@ -5710,7 +5769,7 @@ init_react_import();
|
|
5710
5769
|
|
5711
5770
|
// lib/use-component-list.tsx
|
5712
5771
|
init_react_import();
|
5713
|
-
import { useEffect as
|
5772
|
+
import { useEffect as useEffect18, useState as useState20 } from "react";
|
5714
5773
|
|
5715
5774
|
// components/ComponentList/index.tsx
|
5716
5775
|
init_react_import();
|
@@ -5778,7 +5837,7 @@ ComponentList.Item = ComponentListItem;
|
|
5778
5837
|
import { jsx as jsx29 } from "react/jsx-runtime";
|
5779
5838
|
var useComponentList = (config, ui) => {
|
5780
5839
|
const [componentList, setComponentList] = useState20();
|
5781
|
-
|
5840
|
+
useEffect18(() => {
|
5782
5841
|
var _a, _b, _c;
|
5783
5842
|
if (Object.keys(ui.componentList).length > 0) {
|
5784
5843
|
const matchedComponents = [];
|
@@ -5847,25 +5906,25 @@ var useComponentList = (config, ui) => {
|
|
5847
5906
|
};
|
5848
5907
|
|
5849
5908
|
// components/Puck/components/Components/index.tsx
|
5850
|
-
import { useMemo as
|
5909
|
+
import { useMemo as useMemo13 } from "react";
|
5851
5910
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
5852
5911
|
var Components = () => {
|
5853
5912
|
const { config, state, overrides } = useAppContext();
|
5854
5913
|
const componentList = useComponentList(config, state.ui);
|
5855
|
-
const Wrapper =
|
5914
|
+
const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
|
5856
5915
|
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
5857
5916
|
};
|
5858
5917
|
|
5859
5918
|
// components/Puck/components/Preview/index.tsx
|
5860
5919
|
init_react_import();
|
5861
|
-
import { useCallback as
|
5920
|
+
import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
|
5862
5921
|
|
5863
5922
|
// components/AutoFrame/index.tsx
|
5864
5923
|
init_react_import();
|
5865
5924
|
import {
|
5866
5925
|
createContext as createContext5,
|
5867
5926
|
useContext as useContext10,
|
5868
|
-
useEffect as
|
5927
|
+
useEffect as useEffect19,
|
5869
5928
|
useState as useState21
|
5870
5929
|
} from "react";
|
5871
5930
|
import hash from "object-hash";
|
@@ -5913,7 +5972,7 @@ var CopyHostStyles = ({
|
|
5913
5972
|
onStylesLoaded = () => null
|
5914
5973
|
}) => {
|
5915
5974
|
const { document: doc, window: win } = useFrame();
|
5916
|
-
|
5975
|
+
useEffect19(() => {
|
5917
5976
|
if (!win || !doc) {
|
5918
5977
|
return () => {
|
5919
5978
|
};
|
@@ -6093,7 +6152,7 @@ function AutoFrame(_a) {
|
|
6093
6152
|
const [loaded, setLoaded] = useState21(false);
|
6094
6153
|
const [ctx, setCtx] = useState21({});
|
6095
6154
|
const [mountTarget, setMountTarget] = useState21();
|
6096
|
-
|
6155
|
+
useEffect19(() => {
|
6097
6156
|
var _a2;
|
6098
6157
|
if (frameRef.current) {
|
6099
6158
|
setCtx({
|
@@ -6187,7 +6246,7 @@ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
|
|
6187
6246
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6188
6247
|
var useBubbleIframeEvents = (ref) => {
|
6189
6248
|
const { status } = useAppContext();
|
6190
|
-
|
6249
|
+
useEffect20(() => {
|
6191
6250
|
var _a;
|
6192
6251
|
if (ref.current && status === "READY") {
|
6193
6252
|
const iframe = ref.current;
|
@@ -6226,7 +6285,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6226
6285
|
};
|
6227
6286
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6228
6287
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6229
|
-
const Page =
|
6288
|
+
const Page = useCallback14(
|
6230
6289
|
(pageProps) => {
|
6231
6290
|
var _a, _b;
|
6232
6291
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6235,9 +6294,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6235
6294
|
},
|
6236
6295
|
[config.root]
|
6237
6296
|
);
|
6238
|
-
const Frame =
|
6297
|
+
const Frame = useMemo14(() => overrides.iframe, [overrides]);
|
6239
6298
|
const rootProps = state.data.root.props || state.data.root;
|
6240
|
-
const ref =
|
6299
|
+
const ref = useRef7(null);
|
6241
6300
|
useBubbleIframeEvents(ref);
|
6242
6301
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
|
6243
6302
|
Page,
|
@@ -6487,13 +6546,13 @@ var LayerTree = ({
|
|
6487
6546
|
};
|
6488
6547
|
|
6489
6548
|
// components/Puck/components/Outline/index.tsx
|
6490
|
-
import { useCallback as
|
6549
|
+
import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
|
6491
6550
|
import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
|
6492
6551
|
var Outline = () => {
|
6493
6552
|
const { dispatch, state, overrides, config } = useAppContext();
|
6494
6553
|
const { data, ui } = state;
|
6495
6554
|
const { itemSelector } = ui;
|
6496
|
-
const setItemSelector =
|
6555
|
+
const setItemSelector = useCallback15(
|
6497
6556
|
(newItemSelector) => {
|
6498
6557
|
dispatch({
|
6499
6558
|
type: "setUi",
|
@@ -6502,7 +6561,7 @@ var Outline = () => {
|
|
6502
6561
|
},
|
6503
6562
|
[]
|
6504
6563
|
);
|
6505
|
-
const Wrapper =
|
6564
|
+
const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
|
6506
6565
|
return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
|
6507
6566
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
|
6508
6567
|
LayerTree,
|
@@ -6789,16 +6848,16 @@ var getBox = function getBox2(el) {
|
|
6789
6848
|
|
6790
6849
|
// components/Puck/components/Canvas/index.tsx
|
6791
6850
|
import {
|
6792
|
-
useCallback as
|
6793
|
-
useEffect as
|
6794
|
-
useMemo as
|
6795
|
-
useRef as
|
6851
|
+
useCallback as useCallback16,
|
6852
|
+
useEffect as useEffect22,
|
6853
|
+
useMemo as useMemo17,
|
6854
|
+
useRef as useRef8,
|
6796
6855
|
useState as useState24
|
6797
6856
|
} from "react";
|
6798
6857
|
|
6799
6858
|
// components/ViewportControls/index.tsx
|
6800
6859
|
init_react_import();
|
6801
|
-
import { useEffect as
|
6860
|
+
import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
|
6802
6861
|
|
6803
6862
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6804
6863
|
init_react_import();
|
@@ -6822,7 +6881,7 @@ var ViewportButton = ({
|
|
6822
6881
|
}) => {
|
6823
6882
|
const { state } = useAppContext();
|
6824
6883
|
const [isActive, setIsActive] = useState23(false);
|
6825
|
-
|
6884
|
+
useEffect21(() => {
|
6826
6885
|
setIsActive(width === state.ui.viewports.current.width);
|
6827
6886
|
}, [width, state.ui.viewports.current.width]);
|
6828
6887
|
return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
|
@@ -6858,7 +6917,7 @@ var ViewportControls = ({
|
|
6858
6917
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6859
6918
|
(option) => option.value === autoZoom
|
6860
6919
|
);
|
6861
|
-
const zoomOptions =
|
6920
|
+
const zoomOptions = useMemo16(
|
6862
6921
|
() => [
|
6863
6922
|
...defaultZoomOptions,
|
6864
6923
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6981,17 +7040,17 @@ var Canvas = () => {
|
|
6981
7040
|
const { status, iframe } = useAppContext();
|
6982
7041
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6983
7042
|
const { ui } = state;
|
6984
|
-
const frameRef =
|
7043
|
+
const frameRef = useRef8(null);
|
6985
7044
|
const [showTransition, setShowTransition] = useState24(false);
|
6986
|
-
const defaultRender =
|
7045
|
+
const defaultRender = useMemo17(() => {
|
6987
7046
|
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
|
6988
7047
|
return PuckDefault;
|
6989
7048
|
}, []);
|
6990
|
-
const CustomPreview =
|
7049
|
+
const CustomPreview = useMemo17(
|
6991
7050
|
() => overrides.preview || defaultRender,
|
6992
7051
|
[overrides]
|
6993
7052
|
);
|
6994
|
-
const getFrameDimensions =
|
7053
|
+
const getFrameDimensions = useCallback16(() => {
|
6995
7054
|
if (frameRef.current) {
|
6996
7055
|
const frame = frameRef.current;
|
6997
7056
|
const box = getBox(frame);
|
@@ -6999,7 +7058,7 @@ var Canvas = () => {
|
|
6999
7058
|
}
|
7000
7059
|
return { width: 0, height: 0 };
|
7001
7060
|
}, [frameRef]);
|
7002
|
-
const resetAutoZoom =
|
7061
|
+
const resetAutoZoom = useCallback16(
|
7003
7062
|
(ui2 = state.ui) => {
|
7004
7063
|
if (frameRef.current) {
|
7005
7064
|
setZoomConfig(
|
@@ -7009,11 +7068,11 @@ var Canvas = () => {
|
|
7009
7068
|
},
|
7010
7069
|
[frameRef, zoomConfig, state.ui]
|
7011
7070
|
);
|
7012
|
-
|
7071
|
+
useEffect22(() => {
|
7013
7072
|
setShowTransition(false);
|
7014
7073
|
resetAutoZoom();
|
7015
7074
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7016
|
-
|
7075
|
+
useEffect22(() => {
|
7017
7076
|
const { height: frameHeight } = getFrameDimensions();
|
7018
7077
|
if (ui.viewports.current.height === "auto") {
|
7019
7078
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7021,13 +7080,13 @@ var Canvas = () => {
|
|
7021
7080
|
}));
|
7022
7081
|
}
|
7023
7082
|
}, [zoomConfig.zoom]);
|
7024
|
-
|
7083
|
+
useEffect22(() => {
|
7025
7084
|
if (ZOOM_ON_CHANGE) {
|
7026
7085
|
setShowTransition(true);
|
7027
7086
|
resetAutoZoom(ui);
|
7028
7087
|
}
|
7029
7088
|
}, [ui.viewports.current.width]);
|
7030
|
-
|
7089
|
+
useEffect22(() => {
|
7031
7090
|
const cb = () => {
|
7032
7091
|
setShowTransition(false);
|
7033
7092
|
resetAutoZoom();
|
@@ -7038,7 +7097,7 @@ var Canvas = () => {
|
|
7038
7097
|
};
|
7039
7098
|
}, []);
|
7040
7099
|
const [showLoader, setShowLoader] = useState24(false);
|
7041
|
-
|
7100
|
+
useEffect22(() => {
|
7042
7101
|
setTimeout(() => {
|
7043
7102
|
setShowLoader(true);
|
7044
7103
|
}, 500);
|
@@ -7116,7 +7175,7 @@ var Canvas = () => {
|
|
7116
7175
|
|
7117
7176
|
// lib/use-loaded-overrides.ts
|
7118
7177
|
init_react_import();
|
7119
|
-
import { useMemo as
|
7178
|
+
import { useMemo as useMemo18 } from "react";
|
7120
7179
|
|
7121
7180
|
// lib/load-overrides.ts
|
7122
7181
|
init_react_import();
|
@@ -7155,7 +7214,7 @@ var useLoadedOverrides = ({
|
|
7155
7214
|
overrides,
|
7156
7215
|
plugins
|
7157
7216
|
}) => {
|
7158
|
-
return
|
7217
|
+
return useMemo18(() => {
|
7159
7218
|
return loadOverrides({ overrides, plugins });
|
7160
7219
|
}, [plugins, overrides]);
|
7161
7220
|
};
|
@@ -7167,14 +7226,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { chil
|
|
7167
7226
|
|
7168
7227
|
// lib/use-inject-css.ts
|
7169
7228
|
init_react_import();
|
7170
|
-
import { useEffect as
|
7229
|
+
import { useEffect as useEffect23, useState as useState25 } from "react";
|
7171
7230
|
var styles = ``;
|
7172
7231
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7173
7232
|
const [el, setEl] = useState25();
|
7174
|
-
|
7233
|
+
useEffect23(() => {
|
7175
7234
|
setEl(document.createElement("style"));
|
7176
7235
|
}, []);
|
7177
|
-
|
7236
|
+
useEffect23(() => {
|
7178
7237
|
var _a;
|
7179
7238
|
if (!el || typeof window === "undefined") {
|
7180
7239
|
return;
|
@@ -7194,10 +7253,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7194
7253
|
|
7195
7254
|
// lib/use-preview-mode-hotkeys.ts
|
7196
7255
|
init_react_import();
|
7197
|
-
import { useCallback as
|
7256
|
+
import { useCallback as useCallback17 } from "react";
|
7198
7257
|
import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
|
7199
7258
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7200
|
-
const toggleInteractive =
|
7259
|
+
const toggleInteractive = useCallback17(() => {
|
7201
7260
|
dispatch({
|
7202
7261
|
type: "setUi",
|
7203
7262
|
ui: (ui) => ({
|
@@ -7342,11 +7401,11 @@ function Puck({
|
|
7342
7401
|
const [menuOpen, setMenuOpen] = useState26(false);
|
7343
7402
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7344
7403
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7345
|
-
|
7404
|
+
useEffect24(() => {
|
7346
7405
|
if (onChange) onChange(data);
|
7347
7406
|
}, [data]);
|
7348
7407
|
const rootProps = data.root.props || data.root;
|
7349
|
-
const toggleSidebars =
|
7408
|
+
const toggleSidebars = useCallback18(
|
7350
7409
|
(sidebar) => {
|
7351
7410
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7352
7411
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7360,7 +7419,7 @@ function Puck({
|
|
7360
7419
|
},
|
7361
7420
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7362
7421
|
);
|
7363
|
-
|
7422
|
+
useEffect24(() => {
|
7364
7423
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7365
7424
|
dispatch({
|
7366
7425
|
type: "setUi",
|
@@ -7383,7 +7442,7 @@ function Puck({
|
|
7383
7442
|
window.removeEventListener("resize", handleResize);
|
7384
7443
|
};
|
7385
7444
|
}, []);
|
7386
|
-
const defaultHeaderRender =
|
7445
|
+
const defaultHeaderRender = useMemo19(() => {
|
7387
7446
|
if (renderHeader) {
|
7388
7447
|
console.warn(
|
7389
7448
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7397,7 +7456,7 @@ function Puck({
|
|
7397
7456
|
}
|
7398
7457
|
return DefaultOverride;
|
7399
7458
|
}, [renderHeader]);
|
7400
|
-
const defaultHeaderActionsRender =
|
7459
|
+
const defaultHeaderActionsRender = useMemo19(() => {
|
7401
7460
|
if (renderHeaderActions) {
|
7402
7461
|
console.warn(
|
7403
7462
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7414,20 +7473,20 @@ function Puck({
|
|
7414
7473
|
overrides,
|
7415
7474
|
plugins
|
7416
7475
|
});
|
7417
|
-
const CustomPuck =
|
7476
|
+
const CustomPuck = useMemo19(
|
7418
7477
|
() => loadedOverrides.puck || DefaultOverride,
|
7419
7478
|
[loadedOverrides]
|
7420
7479
|
);
|
7421
|
-
const CustomHeader =
|
7480
|
+
const CustomHeader = useMemo19(
|
7422
7481
|
() => loadedOverrides.header || defaultHeaderRender,
|
7423
7482
|
[loadedOverrides]
|
7424
7483
|
);
|
7425
|
-
const CustomHeaderActions =
|
7484
|
+
const CustomHeaderActions = useMemo19(
|
7426
7485
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7427
7486
|
[loadedOverrides]
|
7428
7487
|
);
|
7429
7488
|
const [mounted, setMounted] = useState26(false);
|
7430
|
-
|
7489
|
+
useEffect24(() => {
|
7431
7490
|
setMounted(true);
|
7432
7491
|
}, []);
|
7433
7492
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|