@measured/puck 0.16.1-canary.1a6216d → 0.16.1-canary.20d7309
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/dist/index.css +27 -19
- package/dist/index.js +176 -149
- package/dist/index.mjs +162 -134
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -243,7 +243,7 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
243
243
|
|
244
244
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
245
245
|
init_react_import();
|
246
|
-
var styles_module_default = { "ActionBar": "
|
246
|
+
var styles_module_default = { "ActionBar": "_ActionBar_1xlbj_1", "ActionBar-actionsLabel": "_ActionBar-actionsLabel_1xlbj_16", "ActionBar-group": "_ActionBar-group_1xlbj_29", "ActionBar-action": "_ActionBar-action_1xlbj_16" };
|
247
247
|
|
248
248
|
// components/ActionBar/index.tsx
|
249
249
|
var import_jsx_runtime = require("react/jsx-runtime");
|
@@ -764,16 +764,15 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
764
764
|
const resolveDataForItem = (0, import_react4.useCallback)(
|
765
765
|
(item, force = false) => __async(void 0, null, function* () {
|
766
766
|
var _a, _b, _c;
|
767
|
-
setComponentLoading == null ? void 0 : setComponentLoading(item.props.id);
|
768
767
|
const componentConfig = item.type === "root" ? config.root : config.components[item.type];
|
769
768
|
if (!componentConfig) {
|
770
|
-
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
771
769
|
return;
|
772
770
|
}
|
773
771
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
774
772
|
if (componentConfig.resolvePermissions) {
|
775
773
|
const changed = getChanged(item, (_a = cache3[item.props.id]) == null ? void 0 : _a.lastData);
|
776
774
|
if (Object.values(changed).some((el) => el === true) || force) {
|
775
|
+
setComponentLoading == null ? void 0 : setComponentLoading(item.props.id);
|
777
776
|
const resolvedPermissions2 = yield componentConfig.resolvePermissions(
|
778
777
|
item,
|
779
778
|
{
|
@@ -793,9 +792,9 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
793
792
|
setResolvedPermissions((p) => __spreadProps(__spreadValues({}, p), {
|
794
793
|
[item.props.id]: resolvedPermissions2
|
795
794
|
}));
|
795
|
+
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
796
796
|
}
|
797
797
|
}
|
798
|
-
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
799
798
|
}),
|
800
799
|
[config, globalPermissions, appState, cache3]
|
801
800
|
);
|
@@ -1447,6 +1446,9 @@ var ArrayField = ({
|
|
1447
1446
|
e.stopPropagation();
|
1448
1447
|
setHovering(false);
|
1449
1448
|
},
|
1449
|
+
onClick: (e) => {
|
1450
|
+
e.preventDefault();
|
1451
|
+
},
|
1450
1452
|
children: [
|
1451
1453
|
localState.arrayState.items.map((item, i) => {
|
1452
1454
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
@@ -2325,9 +2327,12 @@ function AutoFieldInternal(props) {
|
|
2325
2327
|
const Render2 = render[field.type];
|
2326
2328
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }));
|
2327
2329
|
}
|
2330
|
+
var RECENT_CHANGE_TIMEOUT = 200;
|
2328
2331
|
function AutoFieldPrivate(props) {
|
2329
2332
|
const { value, onChange } = props;
|
2330
2333
|
const [localValue, setLocalValue] = (0, import_react13.useState)(value);
|
2334
|
+
const [recentlyChanged, setRecentlyChanged] = (0, import_react13.useState)(false);
|
2335
|
+
const timeoutRef = (0, import_react13.useRef)();
|
2331
2336
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
2332
2337
|
(val, ui) => {
|
2333
2338
|
onChange(val, ui);
|
@@ -2337,10 +2342,17 @@ function AutoFieldPrivate(props) {
|
|
2337
2342
|
);
|
2338
2343
|
const onChangeLocal = (0, import_react13.useCallback)((val, ui) => {
|
2339
2344
|
setLocalValue(val);
|
2345
|
+
setRecentlyChanged(true);
|
2346
|
+
clearTimeout(timeoutRef.current);
|
2347
|
+
timeoutRef.current = setTimeout(() => {
|
2348
|
+
setRecentlyChanged(false);
|
2349
|
+
}, RECENT_CHANGE_TIMEOUT);
|
2340
2350
|
onChangeDb(val, ui);
|
2341
2351
|
}, []);
|
2342
2352
|
(0, import_react13.useEffect)(() => {
|
2343
|
-
|
2353
|
+
if (!recentlyChanged) {
|
2354
|
+
setLocalValue(value);
|
2355
|
+
}
|
2344
2356
|
}, [value]);
|
2345
2357
|
const localProps = {
|
2346
2358
|
value: localValue,
|
@@ -2348,8 +2360,16 @@ function AutoFieldPrivate(props) {
|
|
2348
2360
|
};
|
2349
2361
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2350
2362
|
}
|
2351
|
-
var DefaultLabel = (props) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", __spreadValues({}, props));
|
2352
2363
|
function AutoField(props) {
|
2364
|
+
const DefaultLabel = (0, import_react13.useMemo)(() => {
|
2365
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
2366
|
+
"div",
|
2367
|
+
__spreadProps(__spreadValues({}, labelProps), {
|
2368
|
+
className: getClassName15({ readOnly: props.readOnly })
|
2369
|
+
})
|
2370
|
+
);
|
2371
|
+
return DefaultLabel2;
|
2372
|
+
}, [props.readOnly]);
|
2353
2373
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2354
2374
|
}
|
2355
2375
|
|
@@ -2488,13 +2508,8 @@ var isIos = () => [
|
|
2488
2508
|
].includes(navigator.platform) || // iPad on iOS 13 detection
|
2489
2509
|
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
2490
2510
|
|
2491
|
-
// components/DefaultOverride/index.tsx
|
2492
|
-
init_react_import();
|
2493
|
-
var import_jsx_runtime22 = require("react/jsx-runtime");
|
2494
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children });
|
2495
|
-
|
2496
2511
|
// components/DraggableComponent/index.tsx
|
2497
|
-
var
|
2512
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
2498
2513
|
var getClassName17 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2499
2514
|
var space = 8;
|
2500
2515
|
var actionsOverlayTop = space * 6.5;
|
@@ -2503,7 +2518,7 @@ var actionsRight = space;
|
|
2503
2518
|
var DefaultActionBar = ({
|
2504
2519
|
label,
|
2505
2520
|
children
|
2506
|
-
}) => /* @__PURE__ */ (0,
|
2521
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar, { label, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Group, { children }) });
|
2507
2522
|
var DraggableComponent = ({
|
2508
2523
|
children,
|
2509
2524
|
id,
|
@@ -2543,14 +2558,14 @@ var DraggableComponent = ({
|
|
2543
2558
|
const permissions = getPermissions({
|
2544
2559
|
item: selectedItem
|
2545
2560
|
});
|
2546
|
-
return /* @__PURE__ */ (0,
|
2561
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
2547
2562
|
El,
|
2548
2563
|
{
|
2549
2564
|
draggableId: id,
|
2550
2565
|
index,
|
2551
2566
|
isDragDisabled,
|
2552
2567
|
disableSecondaryAnimation,
|
2553
|
-
children: (provided, snapshot) => /* @__PURE__ */ (0,
|
2568
|
+
children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
2554
2569
|
"div",
|
2555
2570
|
__spreadProps(__spreadValues(__spreadValues({
|
2556
2571
|
ref: provided.innerRef
|
@@ -2573,15 +2588,15 @@ var DraggableComponent = ({
|
|
2573
2588
|
onClick,
|
2574
2589
|
children: [
|
2575
2590
|
debug,
|
2576
|
-
isLoading && /* @__PURE__ */ (0,
|
2577
|
-
isSelected && /* @__PURE__ */ (0,
|
2591
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassName17("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Loader, {}) }),
|
2592
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
2578
2593
|
"div",
|
2579
2594
|
{
|
2580
2595
|
className: getClassName17("actionsOverlay"),
|
2581
2596
|
style: {
|
2582
2597
|
top: actionsOverlayTop / zoomConfig.zoom
|
2583
2598
|
},
|
2584
|
-
children: /* @__PURE__ */ (0,
|
2599
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
2585
2600
|
"div",
|
2586
2601
|
{
|
2587
2602
|
className: getClassName17("actions"),
|
@@ -2590,16 +2605,16 @@ var DraggableComponent = ({
|
|
2590
2605
|
top: actionsTop / zoomConfig.zoom,
|
2591
2606
|
right: actionsRight / zoomConfig.zoom
|
2592
2607
|
},
|
2593
|
-
children: /* @__PURE__ */ (0,
|
2594
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
2595
|
-
permissions.delete && /* @__PURE__ */ (0,
|
2608
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(CustomActionBar, { label, children: [
|
2609
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Copy, { size: 16 }) }),
|
2610
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Trash, { size: 16 }) })
|
2596
2611
|
] })
|
2597
2612
|
}
|
2598
2613
|
)
|
2599
2614
|
}
|
2600
2615
|
),
|
2601
|
-
/* @__PURE__ */ (0,
|
2602
|
-
/* @__PURE__ */ (0,
|
2616
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassName17("overlay") }),
|
2617
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassName17("contents"), children })
|
2603
2618
|
]
|
2604
2619
|
})
|
2605
2620
|
)
|
@@ -2630,7 +2645,7 @@ var getZoneId = (zoneCompound) => {
|
|
2630
2645
|
};
|
2631
2646
|
|
2632
2647
|
// components/DropZone/context.tsx
|
2633
|
-
var
|
2648
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
2634
2649
|
var dropZoneContext = (0, import_react17.createContext)(null);
|
2635
2650
|
var DropZoneProvider = ({
|
2636
2651
|
children,
|
@@ -2708,7 +2723,7 @@ var DropZoneProvider = ({
|
|
2708
2723
|
[value, setPathData]
|
2709
2724
|
);
|
2710
2725
|
const [zoneWillDrag, setZoneWillDrag] = (0, import_react17.useState)("");
|
2711
|
-
return /* @__PURE__ */ (0,
|
2726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: value && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
2712
2727
|
dropZoneContext.Provider,
|
2713
2728
|
{
|
2714
2729
|
value: __spreadValues({
|
@@ -2734,7 +2749,7 @@ var DropZoneProvider = ({
|
|
2734
2749
|
};
|
2735
2750
|
|
2736
2751
|
// components/DropZone/index.tsx
|
2737
|
-
var
|
2752
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
2738
2753
|
var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
|
2739
2754
|
function DropZoneEdit({ zone, allow, disallow, style }) {
|
2740
2755
|
var _a;
|
@@ -2789,7 +2804,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2789
2804
|
const draggingOverArea = userIsDragging && zoneArea === draggedSourceArea;
|
2790
2805
|
const draggingNewComponent = draggedSourceId == null ? void 0 : draggedSourceId.startsWith("component-list");
|
2791
2806
|
if (!(ctx == null ? void 0 : ctx.config) || !ctx.setHoveringArea || !ctx.setHoveringZone || !ctx.setHoveringComponent || !ctx.setItemSelector || !ctx.registerPath || !ctx.dispatch) {
|
2792
|
-
return /* @__PURE__ */ (0,
|
2807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: "DropZone requires context to work." });
|
2793
2808
|
}
|
2794
2809
|
const {
|
2795
2810
|
hoveringArea = "root",
|
@@ -2830,7 +2845,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2830
2845
|
}
|
2831
2846
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
2832
2847
|
const isAreaSelected = selectedItem && zoneArea === selectedItem.props.id;
|
2833
|
-
return /* @__PURE__ */ (0,
|
2848
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
2834
2849
|
"div",
|
2835
2850
|
{
|
2836
2851
|
className: getClassName18({
|
@@ -2847,14 +2862,14 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2847
2862
|
onMouseUp: () => {
|
2848
2863
|
setZoneWillDrag("");
|
2849
2864
|
},
|
2850
|
-
children: /* @__PURE__ */ (0,
|
2865
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
2851
2866
|
Droppable,
|
2852
2867
|
{
|
2853
2868
|
droppableId: zoneCompound,
|
2854
2869
|
direction: "vertical",
|
2855
2870
|
isDropDisabled: !isEnabled,
|
2856
2871
|
children: (provided, snapshot) => {
|
2857
|
-
return /* @__PURE__ */ (0,
|
2872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
2858
2873
|
"div",
|
2859
2874
|
__spreadProps(__spreadValues({}, (provided || { droppableProps: {} }).droppableProps), {
|
2860
2875
|
className: getClassName18("content"),
|
@@ -2884,7 +2899,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2884
2899
|
"draggable-"
|
2885
2900
|
)[1] === componentId;
|
2886
2901
|
const containsZone = areasWithZones ? areasWithZones[componentId] : false;
|
2887
|
-
const Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ (0,
|
2902
|
+
const Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
2888
2903
|
"No configuration for ",
|
2889
2904
|
item.type
|
2890
2905
|
] });
|
@@ -2896,19 +2911,19 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2896
2911
|
appContext2.state.data
|
2897
2912
|
)
|
2898
2913
|
}).drag;
|
2899
|
-
return /* @__PURE__ */ (0,
|
2914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
2900
2915
|
"div",
|
2901
2916
|
{
|
2902
2917
|
className: getClassName18("item"),
|
2903
2918
|
style: { zIndex: isDragging ? 1 : void 0 },
|
2904
2919
|
children: [
|
2905
|
-
/* @__PURE__ */ (0,
|
2920
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
2906
2921
|
DropZoneProvider,
|
2907
2922
|
{
|
2908
2923
|
value: __spreadProps(__spreadValues({}, ctx), {
|
2909
2924
|
areaId: componentId
|
2910
2925
|
}),
|
2911
|
-
children: /* @__PURE__ */ (0,
|
2926
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
2912
2927
|
DraggableComponent,
|
2913
2928
|
{
|
2914
2929
|
label,
|
@@ -2976,12 +2991,12 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2976
2991
|
style: {
|
2977
2992
|
pointerEvents: userIsDragging && draggingNewComponent ? "all" : void 0
|
2978
2993
|
},
|
2979
|
-
children: /* @__PURE__ */ (0,
|
2994
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName18("renderWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
2980
2995
|
}
|
2981
2996
|
)
|
2982
2997
|
}
|
2983
2998
|
),
|
2984
|
-
userIsDragging && /* @__PURE__ */ (0,
|
2999
|
+
userIsDragging && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
2985
3000
|
"div",
|
2986
3001
|
{
|
2987
3002
|
className: getClassName18("hitbox"),
|
@@ -2998,7 +3013,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2998
3013
|
);
|
2999
3014
|
}),
|
3000
3015
|
provided == null ? void 0 : provided.placeholder,
|
3001
|
-
(snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ (0,
|
3016
|
+
(snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
3002
3017
|
"div",
|
3003
3018
|
{
|
3004
3019
|
"data-puck-placeholder": true,
|
@@ -3030,14 +3045,14 @@ function DropZoneRender({ zone }) {
|
|
3030
3045
|
zoneCompound = `${areaId}:${zone}`;
|
3031
3046
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
3032
3047
|
}
|
3033
|
-
return /* @__PURE__ */ (0,
|
3048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: content.map((item) => {
|
3034
3049
|
const Component = config.components[item.type];
|
3035
3050
|
if (Component) {
|
3036
|
-
return /* @__PURE__ */ (0,
|
3051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
3037
3052
|
DropZoneProvider,
|
3038
3053
|
{
|
3039
3054
|
value: { data, config, areaId: item.props.id },
|
3040
|
-
children: /* @__PURE__ */ (0,
|
3055
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
3041
3056
|
Component.render,
|
3042
3057
|
__spreadProps(__spreadValues({}, item.props), {
|
3043
3058
|
puck: { renderDropZone: DropZone }
|
@@ -3053,9 +3068,9 @@ function DropZoneRender({ zone }) {
|
|
3053
3068
|
function DropZone(props) {
|
3054
3069
|
const ctx = (0, import_react18.useContext)(dropZoneContext);
|
3055
3070
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3056
|
-
return /* @__PURE__ */ (0,
|
3071
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneEdit, __spreadValues({}, props));
|
3057
3072
|
}
|
3058
|
-
return /* @__PURE__ */ (0,
|
3073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneRender, __spreadValues({}, props));
|
3059
3074
|
}
|
3060
3075
|
|
3061
3076
|
// components/Puck/index.tsx
|
@@ -3197,7 +3212,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
3197
3212
|
};
|
3198
3213
|
|
3199
3214
|
// components/SidebarSection/index.tsx
|
3200
|
-
var
|
3215
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
3201
3216
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
3202
3217
|
var SidebarSection = ({
|
3203
3218
|
children,
|
@@ -3210,15 +3225,15 @@ var SidebarSection = ({
|
|
3210
3225
|
}) => {
|
3211
3226
|
const { setUi } = useAppContext();
|
3212
3227
|
const breadcrumbs = useBreadcrumbs(1);
|
3213
|
-
return /* @__PURE__ */ (0,
|
3228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
3214
3229
|
"div",
|
3215
3230
|
{
|
3216
3231
|
className: getClassName19({ noBorderTop, noPadding }),
|
3217
3232
|
style: { background },
|
3218
3233
|
children: [
|
3219
|
-
/* @__PURE__ */ (0,
|
3220
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
3221
|
-
/* @__PURE__ */ (0,
|
3234
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
3235
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
3236
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
3222
3237
|
"button",
|
3223
3238
|
{
|
3224
3239
|
type: "button",
|
@@ -3227,12 +3242,12 @@ var SidebarSection = ({
|
|
3227
3242
|
children: breadcrumb.label
|
3228
3243
|
}
|
3229
3244
|
),
|
3230
|
-
/* @__PURE__ */ (0,
|
3245
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronRight, { size: 16 })
|
3231
3246
|
] }, i)) : null,
|
3232
|
-
/* @__PURE__ */ (0,
|
3247
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
3233
3248
|
] }) }),
|
3234
|
-
/* @__PURE__ */ (0,
|
3235
|
-
isLoading && /* @__PURE__ */ (0,
|
3249
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("content"), children }),
|
3250
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: 32 }) })
|
3236
3251
|
]
|
3237
3252
|
}
|
3238
3253
|
);
|
@@ -3613,7 +3628,7 @@ init_react_import();
|
|
3613
3628
|
var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
3614
3629
|
|
3615
3630
|
// components/MenuBar/index.tsx
|
3616
|
-
var
|
3631
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
3617
3632
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
3618
3633
|
function MenuBar({
|
3619
3634
|
appState,
|
@@ -3627,7 +3642,7 @@ function MenuBar({
|
|
3627
3642
|
history: { back, forward, historyStore }
|
3628
3643
|
} = useAppContext();
|
3629
3644
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
3630
|
-
return /* @__PURE__ */ (0,
|
3645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
3631
3646
|
"div",
|
3632
3647
|
{
|
3633
3648
|
className: getClassName20({ menuOpen }),
|
@@ -3641,12 +3656,12 @@ function MenuBar({
|
|
3641
3656
|
setMenuOpen(false);
|
3642
3657
|
}
|
3643
3658
|
},
|
3644
|
-
children: /* @__PURE__ */ (0,
|
3645
|
-
/* @__PURE__ */ (0,
|
3646
|
-
/* @__PURE__ */ (0,
|
3647
|
-
/* @__PURE__ */ (0,
|
3659
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("inner"), children: [
|
3660
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: getClassName20("history"), children: [
|
3661
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Undo2, { size: 21 }) }),
|
3662
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Redo2, { size: 21 }) })
|
3648
3663
|
] }),
|
3649
|
-
/* @__PURE__ */ (0,
|
3664
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
3650
3665
|
state: appState,
|
3651
3666
|
dispatch
|
3652
3667
|
}) })
|
@@ -3668,7 +3683,7 @@ var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields
|
|
3668
3683
|
|
3669
3684
|
// components/Puck/components/Fields/index.tsx
|
3670
3685
|
var import_react21 = require("react");
|
3671
|
-
var
|
3686
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
3672
3687
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
3673
3688
|
var defaultPageFields = {
|
3674
3689
|
title: { type: "text" }
|
@@ -3676,10 +3691,10 @@ var defaultPageFields = {
|
|
3676
3691
|
var DefaultFields = ({
|
3677
3692
|
children
|
3678
3693
|
}) => {
|
3679
|
-
return /* @__PURE__ */ (0,
|
3694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
3680
3695
|
};
|
3681
3696
|
var useResolvedFields = () => {
|
3682
|
-
var _a;
|
3697
|
+
var _a, _b;
|
3683
3698
|
const { selectedItem, state, config } = useAppContext();
|
3684
3699
|
const { data } = state;
|
3685
3700
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
@@ -3691,14 +3706,17 @@ var useResolvedFields = () => {
|
|
3691
3706
|
const [fieldsLoading, setFieldsLoading] = (0, import_react21.useState)(false);
|
3692
3707
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
3693
3708
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
3709
|
+
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
3710
|
+
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
3711
|
+
const hasResolver = hasComponentResolver || hasRootResolver;
|
3694
3712
|
const resolveFields = (0, import_react21.useCallback)(
|
3695
3713
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
3696
|
-
var _a2
|
3714
|
+
var _a2;
|
3697
3715
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
3698
3716
|
const changed = getChanged(componentData, lastData);
|
3699
3717
|
setLastSelectedData(componentData);
|
3700
|
-
if (
|
3701
|
-
return yield componentConfig
|
3718
|
+
if (hasComponentResolver) {
|
3719
|
+
return yield componentConfig.resolveFields(
|
3702
3720
|
componentData,
|
3703
3721
|
{
|
3704
3722
|
changed,
|
@@ -3709,8 +3727,8 @@ var useResolvedFields = () => {
|
|
3709
3727
|
}
|
3710
3728
|
);
|
3711
3729
|
}
|
3712
|
-
if (
|
3713
|
-
return yield
|
3730
|
+
if (hasRootResolver) {
|
3731
|
+
return yield config.root.resolveFields(componentData, {
|
3714
3732
|
changed,
|
3715
3733
|
fields,
|
3716
3734
|
lastFields: resolvedFields,
|
@@ -3728,12 +3746,16 @@ var useResolvedFields = () => {
|
|
3728
3746
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
3729
3747
|
);
|
3730
3748
|
(0, import_react21.useEffect)(() => {
|
3731
|
-
|
3732
|
-
|
3733
|
-
|
3734
|
-
|
3735
|
-
|
3736
|
-
|
3749
|
+
if (hasResolver) {
|
3750
|
+
setFieldsLoading(true);
|
3751
|
+
resolveFields(defaultFields).then((fields) => {
|
3752
|
+
setResolvedFields(fields || {});
|
3753
|
+
setFieldsLoading(false);
|
3754
|
+
});
|
3755
|
+
} else {
|
3756
|
+
setResolvedFields(defaultFields);
|
3757
|
+
}
|
3758
|
+
}, [data, defaultFields, state.ui.itemSelector, hasResolver]);
|
3737
3759
|
return [resolvedFields, fieldsLoading];
|
3738
3760
|
};
|
3739
3761
|
var Fields = () => {
|
@@ -3755,7 +3777,7 @@ var Fields = () => {
|
|
3755
3777
|
const isLoading = fieldsResolving || componentResolving;
|
3756
3778
|
const rootProps = data.root.props || data.root;
|
3757
3779
|
const Wrapper = (0, import_react21.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
3758
|
-
return /* @__PURE__ */ (0,
|
3780
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
3759
3781
|
"form",
|
3760
3782
|
{
|
3761
3783
|
className: getClassName21(),
|
@@ -3763,7 +3785,7 @@ var Fields = () => {
|
|
3763
3785
|
e.preventDefault();
|
3764
3786
|
},
|
3765
3787
|
children: [
|
3766
|
-
/* @__PURE__ */ (0,
|
3788
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
3767
3789
|
const field = fields[fieldName];
|
3768
3790
|
if (!(field == null ? void 0 : field.type)) return null;
|
3769
3791
|
const onChange = (value, updatedUi) => {
|
@@ -3833,7 +3855,7 @@ var Fields = () => {
|
|
3833
3855
|
const { edit } = getPermissions({
|
3834
3856
|
item: selectedItem
|
3835
3857
|
});
|
3836
|
-
return /* @__PURE__ */ (0,
|
3858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
3837
3859
|
AutoFieldPrivate,
|
3838
3860
|
{
|
3839
3861
|
field,
|
@@ -3850,7 +3872,7 @@ var Fields = () => {
|
|
3850
3872
|
const { edit } = getPermissions({
|
3851
3873
|
root: true
|
3852
3874
|
});
|
3853
|
-
return /* @__PURE__ */ (0,
|
3875
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
3854
3876
|
AutoFieldPrivate,
|
3855
3877
|
{
|
3856
3878
|
field,
|
@@ -3864,7 +3886,7 @@ var Fields = () => {
|
|
3864
3886
|
);
|
3865
3887
|
}
|
3866
3888
|
}) }),
|
3867
|
-
isLoading && /* @__PURE__ */ (0,
|
3889
|
+
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 }) }) })
|
3868
3890
|
]
|
3869
3891
|
}
|
3870
3892
|
);
|
@@ -3885,7 +3907,7 @@ init_react_import();
|
|
3885
3907
|
var styles_module_default17 = { "ComponentList": "_ComponentList_odh9d_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_odh9d_5", "ComponentList-content": "_ComponentList-content_odh9d_9", "ComponentList-title": "_ComponentList-title_odh9d_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_odh9d_53" };
|
3886
3908
|
|
3887
3909
|
// components/ComponentList/index.tsx
|
3888
|
-
var
|
3910
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
3889
3911
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
3890
3912
|
var ComponentListItem = ({
|
3891
3913
|
name,
|
@@ -3896,7 +3918,7 @@ var ComponentListItem = ({
|
|
3896
3918
|
const canInsert = getPermissions({
|
3897
3919
|
type: name
|
3898
3920
|
}).insert;
|
3899
|
-
return /* @__PURE__ */ (0,
|
3921
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
3900
3922
|
Drawer.Item,
|
3901
3923
|
{
|
3902
3924
|
label,
|
@@ -3914,8 +3936,8 @@ var ComponentList = ({
|
|
3914
3936
|
}) => {
|
3915
3937
|
const { config, state, setUi } = useAppContext();
|
3916
3938
|
const { expanded = true } = state.ui.componentList[id] || {};
|
3917
|
-
return /* @__PURE__ */ (0,
|
3918
|
-
title && /* @__PURE__ */ (0,
|
3939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
3940
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
3919
3941
|
"button",
|
3920
3942
|
{
|
3921
3943
|
type: "button",
|
@@ -3929,14 +3951,14 @@ var ComponentList = ({
|
|
3929
3951
|
}),
|
3930
3952
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
3931
3953
|
children: [
|
3932
|
-
/* @__PURE__ */ (0,
|
3933
|
-
/* @__PURE__ */ (0,
|
3954
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: title }),
|
3955
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronDown, { size: 12 }) })
|
3934
3956
|
]
|
3935
3957
|
}
|
3936
3958
|
),
|
3937
|
-
/* @__PURE__ */ (0,
|
3959
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Drawer, { droppableId: title, children: children || Object.keys(config.components).map((componentKey, i) => {
|
3938
3960
|
var _a;
|
3939
|
-
return /* @__PURE__ */ (0,
|
3961
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
3940
3962
|
ComponentListItem,
|
3941
3963
|
{
|
3942
3964
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -3951,7 +3973,7 @@ var ComponentList = ({
|
|
3951
3973
|
ComponentList.Item = ComponentListItem;
|
3952
3974
|
|
3953
3975
|
// lib/use-component-list.tsx
|
3954
|
-
var
|
3976
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
3955
3977
|
var useComponentList = (config, ui) => {
|
3956
3978
|
const [componentList, setComponentList] = (0, import_react22.useState)();
|
3957
3979
|
(0, import_react22.useEffect)(() => {
|
@@ -3964,7 +3986,7 @@ var useComponentList = (config, ui) => {
|
|
3964
3986
|
if (category.visible === false || !category.components) {
|
3965
3987
|
return null;
|
3966
3988
|
}
|
3967
|
-
return /* @__PURE__ */ (0,
|
3989
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
3968
3990
|
ComponentList,
|
3969
3991
|
{
|
3970
3992
|
id: categoryKey,
|
@@ -3973,7 +3995,7 @@ var useComponentList = (config, ui) => {
|
|
3973
3995
|
var _a2;
|
3974
3996
|
matchedComponents.push(componentName);
|
3975
3997
|
const componentConf = config.components[componentName] || {};
|
3976
|
-
return /* @__PURE__ */ (0,
|
3998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
3977
3999
|
ComponentList.Item,
|
3978
4000
|
{
|
3979
4001
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -3993,7 +4015,7 @@ var useComponentList = (config, ui) => {
|
|
3993
4015
|
);
|
3994
4016
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
3995
4017
|
_componentList.push(
|
3996
|
-
/* @__PURE__ */ (0,
|
4018
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
3997
4019
|
ComponentList,
|
3998
4020
|
{
|
3999
4021
|
id: "other",
|
@@ -4001,7 +4023,7 @@ var useComponentList = (config, ui) => {
|
|
4001
4023
|
children: remainingComponents.map((componentName, i) => {
|
4002
4024
|
var _a2;
|
4003
4025
|
const componentConf = config.components[componentName] || {};
|
4004
|
-
return /* @__PURE__ */ (0,
|
4026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
4005
4027
|
ComponentList.Item,
|
4006
4028
|
{
|
4007
4029
|
name: componentName,
|
@@ -4024,12 +4046,12 @@ var useComponentList = (config, ui) => {
|
|
4024
4046
|
|
4025
4047
|
// components/Puck/components/Components/index.tsx
|
4026
4048
|
var import_react23 = require("react");
|
4027
|
-
var
|
4049
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
4028
4050
|
var Components = () => {
|
4029
4051
|
const { config, state, overrides } = useAppContext();
|
4030
4052
|
const componentList = useComponentList(config, state.ui);
|
4031
4053
|
const Wrapper = (0, import_react23.useMemo)(() => overrides.components || "div", [overrides]);
|
4032
|
-
return /* @__PURE__ */ (0,
|
4054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
4033
4055
|
};
|
4034
4056
|
|
4035
4057
|
// components/Puck/components/Preview/index.tsx
|
@@ -4041,7 +4063,7 @@ init_react_import();
|
|
4041
4063
|
var import_react24 = require("react");
|
4042
4064
|
var import_object_hash = __toESM(require("object-hash"));
|
4043
4065
|
var import_react_dom2 = require("react-dom");
|
4044
|
-
var
|
4066
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
4045
4067
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
4046
4068
|
var collectStyles = (doc) => {
|
4047
4069
|
const collected = [];
|
@@ -4241,7 +4263,7 @@ var CopyHostStyles = ({
|
|
4241
4263
|
observer.disconnect();
|
4242
4264
|
};
|
4243
4265
|
}, []);
|
4244
|
-
return /* @__PURE__ */ (0,
|
4266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
4245
4267
|
};
|
4246
4268
|
var autoFrameContext = (0, import_react24.createContext)({});
|
4247
4269
|
var useFrame = () => (0, import_react24.useContext)(autoFrameContext);
|
@@ -4273,7 +4295,7 @@ function AutoFrame(_a) {
|
|
4273
4295
|
setMountTarget((_a2 = ref.current.contentDocument) == null ? void 0 : _a2.getElementById("frame-root"));
|
4274
4296
|
}
|
4275
4297
|
}, [ref, loaded]);
|
4276
|
-
return /* @__PURE__ */ (0,
|
4298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
4277
4299
|
"iframe",
|
4278
4300
|
__spreadProps(__spreadValues({}, props), {
|
4279
4301
|
className,
|
@@ -4283,7 +4305,7 @@ function AutoFrame(_a) {
|
|
4283
4305
|
onLoad: () => {
|
4284
4306
|
setLoaded(true);
|
4285
4307
|
},
|
4286
|
-
children: /* @__PURE__ */ (0,
|
4308
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CopyHostStyles, { debug, onStylesLoaded, children: (0, import_react_dom2.createPortal)(children, mountTarget) }) })
|
4287
4309
|
})
|
4288
4310
|
);
|
4289
4311
|
}
|
@@ -4295,7 +4317,7 @@ init_react_import();
|
|
4295
4317
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
|
4296
4318
|
|
4297
4319
|
// components/Puck/components/Preview/index.tsx
|
4298
|
-
var
|
4320
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
4299
4321
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
4300
4322
|
var Preview = ({ id = "puck-preview" }) => {
|
4301
4323
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
@@ -4304,13 +4326,13 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4304
4326
|
var _a, _b;
|
4305
4327
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
4306
4328
|
id: "puck-root"
|
4307
|
-
}, pageProps)) : /* @__PURE__ */ (0,
|
4329
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: pageProps.children });
|
4308
4330
|
},
|
4309
4331
|
[config.root]
|
4310
4332
|
);
|
4311
4333
|
const Frame = (0, import_react25.useMemo)(() => overrides.iframe, [overrides]);
|
4312
4334
|
const rootProps = state.data.root.props || state.data.root;
|
4313
|
-
return /* @__PURE__ */ (0,
|
4335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
4314
4336
|
"div",
|
4315
4337
|
{
|
4316
4338
|
className: getClassName23(),
|
@@ -4318,7 +4340,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4318
4340
|
onClick: () => {
|
4319
4341
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
4320
4342
|
},
|
4321
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
4343
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
4322
4344
|
AutoFrame_default,
|
4323
4345
|
{
|
4324
4346
|
id: "preview-frame",
|
@@ -4327,27 +4349,27 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4327
4349
|
onStylesLoaded: () => {
|
4328
4350
|
setStatus("READY");
|
4329
4351
|
},
|
4330
|
-
children: /* @__PURE__ */ (0,
|
4331
|
-
const inner = /* @__PURE__ */ (0,
|
4352
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
4353
|
+
const inner = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
4332
4354
|
Page,
|
4333
4355
|
__spreadProps(__spreadValues({}, rootProps), {
|
4334
4356
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4335
4357
|
editMode: true,
|
4336
|
-
children: /* @__PURE__ */ (0,
|
4358
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
4337
4359
|
})
|
4338
4360
|
);
|
4339
4361
|
if (Frame) {
|
4340
|
-
return /* @__PURE__ */ (0,
|
4362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Frame, { document: document2, children: inner });
|
4341
4363
|
}
|
4342
4364
|
return inner;
|
4343
4365
|
} })
|
4344
4366
|
}
|
4345
|
-
) : /* @__PURE__ */ (0,
|
4367
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
4346
4368
|
Page,
|
4347
4369
|
__spreadProps(__spreadValues({}, rootProps), {
|
4348
4370
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4349
4371
|
editMode: true,
|
4350
|
-
children: /* @__PURE__ */ (0,
|
4372
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZone, { zone: rootDroppableId })
|
4351
4373
|
})
|
4352
4374
|
) })
|
4353
4375
|
}
|
@@ -4411,7 +4433,7 @@ var isChildOfZone = (item, maybeChild, ctx) => {
|
|
4411
4433
|
};
|
4412
4434
|
|
4413
4435
|
// components/LayerTree/index.tsx
|
4414
|
-
var
|
4436
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
4415
4437
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
4416
4438
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
4417
4439
|
var LayerTree = ({
|
@@ -4425,14 +4447,14 @@ var LayerTree = ({
|
|
4425
4447
|
}) => {
|
4426
4448
|
const zones = data.zones || {};
|
4427
4449
|
const ctx = (0, import_react26.useContext)(dropZoneContext);
|
4428
|
-
return /* @__PURE__ */ (0,
|
4429
|
-
label && /* @__PURE__ */ (0,
|
4430
|
-
/* @__PURE__ */ (0,
|
4450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
4451
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
4452
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Layers, { size: "16" }) }),
|
4431
4453
|
" ",
|
4432
4454
|
label
|
4433
4455
|
] }),
|
4434
|
-
/* @__PURE__ */ (0,
|
4435
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
4456
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("ul", { className: getClassName24(), children: [
|
4457
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
4436
4458
|
zoneContent.map((item, i) => {
|
4437
4459
|
var _a;
|
4438
4460
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -4450,7 +4472,7 @@ var LayerTree = ({
|
|
4450
4472
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
4451
4473
|
const componentConfig = config.components[item.type];
|
4452
4474
|
const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
|
4453
|
-
return /* @__PURE__ */ (0,
|
4475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
4454
4476
|
"li",
|
4455
4477
|
{
|
4456
4478
|
className: getClassNameLayer({
|
@@ -4460,7 +4482,7 @@ var LayerTree = ({
|
|
4460
4482
|
childIsSelected
|
4461
4483
|
}),
|
4462
4484
|
children: [
|
4463
|
-
/* @__PURE__ */ (0,
|
4485
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
4464
4486
|
"button",
|
4465
4487
|
{
|
4466
4488
|
type: "button",
|
@@ -4493,22 +4515,22 @@ var LayerTree = ({
|
|
4493
4515
|
setHoveringComponent(null);
|
4494
4516
|
},
|
4495
4517
|
children: [
|
4496
|
-
containsZone && /* @__PURE__ */ (0,
|
4518
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4497
4519
|
"div",
|
4498
4520
|
{
|
4499
4521
|
className: getClassNameLayer("chevron"),
|
4500
4522
|
title: isSelected ? "Collapse" : "Expand",
|
4501
|
-
children: /* @__PURE__ */ (0,
|
4523
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ChevronDown, { size: "12" })
|
4502
4524
|
}
|
4503
4525
|
),
|
4504
|
-
/* @__PURE__ */ (0,
|
4505
|
-
/* @__PURE__ */ (0,
|
4506
|
-
/* @__PURE__ */ (0,
|
4526
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
4527
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(LayoutGrid, { size: "16" }) }),
|
4528
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
|
4507
4529
|
] })
|
4508
4530
|
]
|
4509
4531
|
}
|
4510
4532
|
) }),
|
4511
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
4533
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4512
4534
|
LayerTree,
|
4513
4535
|
{
|
4514
4536
|
config,
|
@@ -4531,7 +4553,7 @@ var LayerTree = ({
|
|
4531
4553
|
|
4532
4554
|
// components/Puck/components/Outline/index.tsx
|
4533
4555
|
var import_react27 = require("react");
|
4534
|
-
var
|
4556
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
4535
4557
|
var Outline = () => {
|
4536
4558
|
const { dispatch, state, overrides, config } = useAppContext();
|
4537
4559
|
const { data, ui } = state;
|
@@ -4546,8 +4568,8 @@ var Outline = () => {
|
|
4546
4568
|
[]
|
4547
4569
|
);
|
4548
4570
|
const Wrapper = (0, import_react27.useMemo)(() => overrides.outline || "div", [overrides]);
|
4549
|
-
return /* @__PURE__ */ (0,
|
4550
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
4571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
4572
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
4551
4573
|
LayerTree,
|
4552
4574
|
{
|
4553
4575
|
config,
|
@@ -4560,7 +4582,7 @@ var Outline = () => {
|
|
4560
4582
|
),
|
4561
4583
|
Object.entries(findZonesForArea(data, "root")).map(
|
4562
4584
|
([zoneKey, zone]) => {
|
4563
|
-
return /* @__PURE__ */ (0,
|
4585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
4564
4586
|
LayerTree,
|
4565
4587
|
{
|
4566
4588
|
config,
|
@@ -4817,11 +4839,11 @@ init_react_import();
|
|
4817
4839
|
var styles_module_default20 = { "ViewportControls": "_ViewportControls_g1wgg_1", "ViewportControls-divider": "_ViewportControls-divider_g1wgg_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_g1wgg_21", "ViewportButton--isActive": "_ViewportButton--isActive_g1wgg_34", "ViewportButton-inner": "_ViewportButton-inner_g1wgg_34" };
|
4818
4840
|
|
4819
4841
|
// components/ViewportControls/index.tsx
|
4820
|
-
var
|
4842
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
4821
4843
|
var icons = {
|
4822
|
-
Smartphone: /* @__PURE__ */ (0,
|
4823
|
-
Tablet: /* @__PURE__ */ (0,
|
4824
|
-
Monitor: /* @__PURE__ */ (0,
|
4844
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Smartphone, { size: 16 }),
|
4845
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Tablet, { size: 16 }),
|
4846
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Monitor, { size: 16 })
|
4825
4847
|
};
|
4826
4848
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
4827
4849
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -4837,7 +4859,7 @@ var ViewportButton = ({
|
|
4837
4859
|
(0, import_react29.useEffect)(() => {
|
4838
4860
|
setIsActive(width === state.ui.viewports.current.width);
|
4839
4861
|
}, [width, state.ui.viewports.current.width]);
|
4840
|
-
return /* @__PURE__ */ (0,
|
4862
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4841
4863
|
IconButton,
|
4842
4864
|
{
|
4843
4865
|
title,
|
@@ -4846,7 +4868,7 @@ var ViewportButton = ({
|
|
4846
4868
|
e.stopPropagation();
|
4847
4869
|
onClick({ width, height });
|
4848
4870
|
},
|
4849
|
-
children: /* @__PURE__ */ (0,
|
4871
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton("inner"), children })
|
4850
4872
|
}
|
4851
4873
|
) });
|
4852
4874
|
};
|
@@ -4882,8 +4904,8 @@ var ViewportControls = ({
|
|
4882
4904
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
4883
4905
|
[autoZoom]
|
4884
4906
|
);
|
4885
|
-
return /* @__PURE__ */ (0,
|
4886
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
4907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25(), children: [
|
4908
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4887
4909
|
ViewportButton,
|
4888
4910
|
{
|
4889
4911
|
height: viewport.height,
|
@@ -4894,8 +4916,8 @@ var ViewportControls = ({
|
|
4894
4916
|
},
|
4895
4917
|
i
|
4896
4918
|
)),
|
4897
|
-
/* @__PURE__ */ (0,
|
4898
|
-
/* @__PURE__ */ (0,
|
4919
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("divider") }),
|
4920
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4899
4921
|
IconButton,
|
4900
4922
|
{
|
4901
4923
|
title: "Zoom viewport out",
|
@@ -4909,10 +4931,10 @@ var ViewportControls = ({
|
|
4909
4931
|
)].value
|
4910
4932
|
);
|
4911
4933
|
},
|
4912
|
-
children: /* @__PURE__ */ (0,
|
4934
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ZoomOut, { size: 16 })
|
4913
4935
|
}
|
4914
4936
|
),
|
4915
|
-
/* @__PURE__ */ (0,
|
4937
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4916
4938
|
IconButton,
|
4917
4939
|
{
|
4918
4940
|
title: "Zoom viewport in",
|
@@ -4926,11 +4948,11 @@ var ViewportControls = ({
|
|
4926
4948
|
)].value
|
4927
4949
|
);
|
4928
4950
|
},
|
4929
|
-
children: /* @__PURE__ */ (0,
|
4951
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ZoomIn, { size: 16 })
|
4930
4952
|
}
|
4931
4953
|
),
|
4932
|
-
/* @__PURE__ */ (0,
|
4933
|
-
/* @__PURE__ */ (0,
|
4954
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("divider") }),
|
4955
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4934
4956
|
"select",
|
4935
4957
|
{
|
4936
4958
|
className: getClassName25("zoomSelect"),
|
@@ -4938,7 +4960,7 @@ var ViewportControls = ({
|
|
4938
4960
|
onChange: (e) => {
|
4939
4961
|
onZoom(parseFloat(e.currentTarget.value));
|
4940
4962
|
},
|
4941
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
4963
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4942
4964
|
"option",
|
4943
4965
|
{
|
4944
4966
|
value: option.value,
|
@@ -4953,7 +4975,7 @@ var ViewportControls = ({
|
|
4953
4975
|
|
4954
4976
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
4955
4977
|
init_react_import();
|
4956
|
-
var styles_module_default21 = { "PuckCanvas": "
|
4978
|
+
var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_avf1c_1", "PuckCanvas-controls": "_PuckCanvas-controls_avf1c_16", "PuckCanvas-inner": "_PuckCanvas-inner_avf1c_21", "PuckCanvas-root": "_PuckCanvas-root_avf1c_32", "PuckCanvas--ready": "_PuckCanvas--ready_avf1c_57", "PuckCanvas-loader": "_PuckCanvas-loader_avf1c_62", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_avf1c_72" };
|
4957
4979
|
|
4958
4980
|
// lib/get-zoom-config.ts
|
4959
4981
|
init_react_import();
|
@@ -4986,7 +5008,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
4986
5008
|
};
|
4987
5009
|
|
4988
5010
|
// components/Puck/components/Canvas/index.tsx
|
4989
|
-
var
|
5011
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
4990
5012
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
4991
5013
|
var ZOOM_ON_CHANGE = true;
|
4992
5014
|
var Canvas = () => {
|
@@ -4996,7 +5018,7 @@ var Canvas = () => {
|
|
4996
5018
|
const frameRef = (0, import_react30.useRef)(null);
|
4997
5019
|
const [showTransition, setShowTransition] = (0, import_react30.useState)(false);
|
4998
5020
|
const defaultRender = (0, import_react30.useMemo)(() => {
|
4999
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
5021
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
|
5000
5022
|
return PuckDefault;
|
5001
5023
|
}, []);
|
5002
5024
|
const CustomPreview = (0, import_react30.useMemo)(
|
@@ -5057,7 +5079,7 @@ var Canvas = () => {
|
|
5057
5079
|
setShowLoader(true);
|
5058
5080
|
}, 500);
|
5059
5081
|
}, []);
|
5060
|
-
return /* @__PURE__ */ (0,
|
5082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
5061
5083
|
"div",
|
5062
5084
|
{
|
5063
5085
|
className: getClassName26({
|
@@ -5070,7 +5092,7 @@ var Canvas = () => {
|
|
5070
5092
|
recordHistory: true
|
5071
5093
|
}),
|
5072
5094
|
children: [
|
5073
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
5095
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5074
5096
|
ViewportControls,
|
5075
5097
|
{
|
5076
5098
|
autoZoom: zoomConfig.autoZoom,
|
@@ -5095,8 +5117,8 @@ var Canvas = () => {
|
|
5095
5117
|
}
|
5096
5118
|
}
|
5097
5119
|
) }),
|
5098
|
-
/* @__PURE__ */ (0,
|
5099
|
-
/* @__PURE__ */ (0,
|
5120
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
5121
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
5100
5122
|
"div",
|
5101
5123
|
{
|
5102
5124
|
className: getClassName26("root"),
|
@@ -5108,10 +5130,10 @@ var Canvas = () => {
|
|
5108
5130
|
overflow: iframe.enabled ? void 0 : "auto"
|
5109
5131
|
},
|
5110
5132
|
suppressHydrationWarning: true,
|
5111
|
-
children: /* @__PURE__ */ (0,
|
5133
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Preview, {}) })
|
5112
5134
|
}
|
5113
5135
|
),
|
5114
|
-
/* @__PURE__ */ (0,
|
5136
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Loader, { size: 24 }) })
|
5115
5137
|
] })
|
5116
5138
|
]
|
5117
5139
|
}
|
@@ -5199,6 +5221,11 @@ var useLoadedOverrides = ({
|
|
5199
5221
|
}, [plugins, overrides]);
|
5200
5222
|
};
|
5201
5223
|
|
5224
|
+
// components/DefaultOverride/index.tsx
|
5225
|
+
init_react_import();
|
5226
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
5227
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
5228
|
+
|
5202
5229
|
// components/Puck/index.tsx
|
5203
5230
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
5204
5231
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|