@measured/puck 0.16.1-canary.8fcf0d8 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- 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.mjs
CHANGED
@@ -138,7 +138,7 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
138
138
|
|
139
139
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
140
140
|
init_react_import();
|
141
|
-
var styles_module_default = { "ActionBar": "
|
141
|
+
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" };
|
142
142
|
|
143
143
|
// components/ActionBar/index.tsx
|
144
144
|
import { jsx, jsxs } from "react/jsx-runtime";
|
@@ -180,6 +180,7 @@ import {
|
|
180
180
|
useCallback as useCallback5,
|
181
181
|
useEffect as useEffect9,
|
182
182
|
useMemo as useMemo2,
|
183
|
+
useRef as useRef2,
|
183
184
|
useState as useState10
|
184
185
|
} from "react";
|
185
186
|
|
@@ -652,16 +653,15 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
652
653
|
const resolveDataForItem = useCallback(
|
653
654
|
(item, force = false) => __async(void 0, null, function* () {
|
654
655
|
var _a, _b, _c;
|
655
|
-
setComponentLoading == null ? void 0 : setComponentLoading(item.props.id);
|
656
656
|
const componentConfig = item.type === "root" ? config.root : config.components[item.type];
|
657
657
|
if (!componentConfig) {
|
658
|
-
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
659
658
|
return;
|
660
659
|
}
|
661
660
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
662
661
|
if (componentConfig.resolvePermissions) {
|
663
662
|
const changed = getChanged(item, (_a = cache3[item.props.id]) == null ? void 0 : _a.lastData);
|
664
663
|
if (Object.values(changed).some((el) => el === true) || force) {
|
664
|
+
setComponentLoading == null ? void 0 : setComponentLoading(item.props.id);
|
665
665
|
const resolvedPermissions2 = yield componentConfig.resolvePermissions(
|
666
666
|
item,
|
667
667
|
{
|
@@ -681,9 +681,9 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
681
681
|
setResolvedPermissions((p) => __spreadProps(__spreadValues({}, p), {
|
682
682
|
[item.props.id]: resolvedPermissions2
|
683
683
|
}));
|
684
|
+
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
684
685
|
}
|
685
686
|
}
|
686
|
-
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
687
687
|
}),
|
688
688
|
[config, globalPermissions, appState, cache3]
|
689
689
|
);
|
@@ -1339,6 +1339,9 @@ var ArrayField = ({
|
|
1339
1339
|
e.stopPropagation();
|
1340
1340
|
setHovering(false);
|
1341
1341
|
},
|
1342
|
+
onClick: (e) => {
|
1343
|
+
e.preventDefault();
|
1344
|
+
},
|
1342
1345
|
children: [
|
1343
1346
|
localState.arrayState.items.map((item, i) => {
|
1344
1347
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
@@ -2217,9 +2220,12 @@ function AutoFieldInternal(props) {
|
|
2217
2220
|
const Render2 = render[field.type];
|
2218
2221
|
return /* @__PURE__ */ jsx20(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }));
|
2219
2222
|
}
|
2223
|
+
var RECENT_CHANGE_TIMEOUT = 200;
|
2220
2224
|
function AutoFieldPrivate(props) {
|
2221
2225
|
const { value, onChange } = props;
|
2222
2226
|
const [localValue, setLocalValue] = useState10(value);
|
2227
|
+
const [recentlyChanged, setRecentlyChanged] = useState10(false);
|
2228
|
+
const timeoutRef = useRef2();
|
2223
2229
|
const onChangeDb = useDebouncedCallback(
|
2224
2230
|
(val, ui) => {
|
2225
2231
|
onChange(val, ui);
|
@@ -2229,10 +2235,17 @@ function AutoFieldPrivate(props) {
|
|
2229
2235
|
);
|
2230
2236
|
const onChangeLocal = useCallback5((val, ui) => {
|
2231
2237
|
setLocalValue(val);
|
2238
|
+
setRecentlyChanged(true);
|
2239
|
+
clearTimeout(timeoutRef.current);
|
2240
|
+
timeoutRef.current = setTimeout(() => {
|
2241
|
+
setRecentlyChanged(false);
|
2242
|
+
}, RECENT_CHANGE_TIMEOUT);
|
2232
2243
|
onChangeDb(val, ui);
|
2233
2244
|
}, []);
|
2234
2245
|
useEffect9(() => {
|
2235
|
-
|
2246
|
+
if (!recentlyChanged) {
|
2247
|
+
setLocalValue(value);
|
2248
|
+
}
|
2236
2249
|
}, [value]);
|
2237
2250
|
const localProps = {
|
2238
2251
|
value: localValue,
|
@@ -2240,8 +2253,16 @@ function AutoFieldPrivate(props) {
|
|
2240
2253
|
};
|
2241
2254
|
return /* @__PURE__ */ jsx20(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
2242
2255
|
}
|
2243
|
-
var DefaultLabel = (props) => /* @__PURE__ */ jsx20("div", __spreadValues({}, props));
|
2244
2256
|
function AutoField(props) {
|
2257
|
+
const DefaultLabel = useMemo2(() => {
|
2258
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx20(
|
2259
|
+
"div",
|
2260
|
+
__spreadProps(__spreadValues({}, labelProps), {
|
2261
|
+
className: getClassName15({ readOnly: props.readOnly })
|
2262
|
+
})
|
2263
|
+
);
|
2264
|
+
return DefaultLabel2;
|
2265
|
+
}, [props.readOnly]);
|
2245
2266
|
return /* @__PURE__ */ jsx20(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
2246
2267
|
}
|
2247
2268
|
|
@@ -2388,13 +2409,8 @@ var isIos = () => [
|
|
2388
2409
|
].includes(navigator.platform) || // iPad on iOS 13 detection
|
2389
2410
|
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
2390
2411
|
|
2391
|
-
// components/DefaultOverride/index.tsx
|
2392
|
-
init_react_import();
|
2393
|
-
import { Fragment as Fragment9, jsx as jsx22 } from "react/jsx-runtime";
|
2394
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx22(Fragment9, { children });
|
2395
|
-
|
2396
2412
|
// components/DraggableComponent/index.tsx
|
2397
|
-
import { jsx as
|
2413
|
+
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
2398
2414
|
var getClassName17 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2399
2415
|
var space = 8;
|
2400
2416
|
var actionsOverlayTop = space * 6.5;
|
@@ -2403,7 +2419,7 @@ var actionsRight = space;
|
|
2403
2419
|
var DefaultActionBar = ({
|
2404
2420
|
label,
|
2405
2421
|
children
|
2406
|
-
}) => /* @__PURE__ */
|
2422
|
+
}) => /* @__PURE__ */ jsx22(ActionBar, { label, children: /* @__PURE__ */ jsx22(ActionBar.Group, { children }) });
|
2407
2423
|
var DraggableComponent = ({
|
2408
2424
|
children,
|
2409
2425
|
id,
|
@@ -2443,7 +2459,7 @@ var DraggableComponent = ({
|
|
2443
2459
|
const permissions = getPermissions({
|
2444
2460
|
item: selectedItem
|
2445
2461
|
});
|
2446
|
-
return /* @__PURE__ */
|
2462
|
+
return /* @__PURE__ */ jsx22(
|
2447
2463
|
El,
|
2448
2464
|
{
|
2449
2465
|
draggableId: id,
|
@@ -2473,15 +2489,15 @@ var DraggableComponent = ({
|
|
2473
2489
|
onClick,
|
2474
2490
|
children: [
|
2475
2491
|
debug,
|
2476
|
-
isLoading && /* @__PURE__ */
|
2477
|
-
isSelected && /* @__PURE__ */
|
2492
|
+
isLoading && /* @__PURE__ */ jsx22("div", { className: getClassName17("loadingOverlay"), children: /* @__PURE__ */ jsx22(Loader, {}) }),
|
2493
|
+
isSelected && /* @__PURE__ */ jsx22(
|
2478
2494
|
"div",
|
2479
2495
|
{
|
2480
2496
|
className: getClassName17("actionsOverlay"),
|
2481
2497
|
style: {
|
2482
2498
|
top: actionsOverlayTop / zoomConfig.zoom
|
2483
2499
|
},
|
2484
|
-
children: /* @__PURE__ */
|
2500
|
+
children: /* @__PURE__ */ jsx22(
|
2485
2501
|
"div",
|
2486
2502
|
{
|
2487
2503
|
className: getClassName17("actions"),
|
@@ -2491,15 +2507,15 @@ var DraggableComponent = ({
|
|
2491
2507
|
right: actionsRight / zoomConfig.zoom
|
2492
2508
|
},
|
2493
2509
|
children: /* @__PURE__ */ jsxs11(CustomActionBar, { label, children: [
|
2494
|
-
permissions.duplicate && /* @__PURE__ */
|
2495
|
-
permissions.delete && /* @__PURE__ */
|
2510
|
+
permissions.duplicate && /* @__PURE__ */ jsx22(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx22(Copy, { size: 16 }) }),
|
2511
|
+
permissions.delete && /* @__PURE__ */ jsx22(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx22(Trash, { size: 16 }) })
|
2496
2512
|
] })
|
2497
2513
|
}
|
2498
2514
|
)
|
2499
2515
|
}
|
2500
2516
|
),
|
2501
|
-
/* @__PURE__ */
|
2502
|
-
/* @__PURE__ */
|
2517
|
+
/* @__PURE__ */ jsx22("div", { className: getClassName17("overlay") }),
|
2518
|
+
/* @__PURE__ */ jsx22("div", { className: getClassName17("contents"), children })
|
2503
2519
|
]
|
2504
2520
|
})
|
2505
2521
|
)
|
@@ -2534,7 +2550,7 @@ var getZoneId = (zoneCompound) => {
|
|
2534
2550
|
};
|
2535
2551
|
|
2536
2552
|
// components/DropZone/context.tsx
|
2537
|
-
import { Fragment as
|
2553
|
+
import { Fragment as Fragment9, jsx as jsx23 } from "react/jsx-runtime";
|
2538
2554
|
var dropZoneContext = createContext3(null);
|
2539
2555
|
var DropZoneProvider = ({
|
2540
2556
|
children,
|
@@ -2612,7 +2628,7 @@ var DropZoneProvider = ({
|
|
2612
2628
|
[value, setPathData]
|
2613
2629
|
);
|
2614
2630
|
const [zoneWillDrag, setZoneWillDrag] = useState13("");
|
2615
|
-
return /* @__PURE__ */
|
2631
|
+
return /* @__PURE__ */ jsx23(Fragment9, { children: value && /* @__PURE__ */ jsx23(
|
2616
2632
|
dropZoneContext.Provider,
|
2617
2633
|
{
|
2618
2634
|
value: __spreadValues({
|
@@ -2638,7 +2654,7 @@ var DropZoneProvider = ({
|
|
2638
2654
|
};
|
2639
2655
|
|
2640
2656
|
// components/DropZone/index.tsx
|
2641
|
-
import { Fragment as
|
2657
|
+
import { Fragment as Fragment10, jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
|
2642
2658
|
var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
|
2643
2659
|
function DropZoneEdit({ zone, allow, disallow, style }) {
|
2644
2660
|
var _a;
|
@@ -2693,7 +2709,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2693
2709
|
const draggingOverArea = userIsDragging && zoneArea === draggedSourceArea;
|
2694
2710
|
const draggingNewComponent = draggedSourceId == null ? void 0 : draggedSourceId.startsWith("component-list");
|
2695
2711
|
if (!(ctx == null ? void 0 : ctx.config) || !ctx.setHoveringArea || !ctx.setHoveringZone || !ctx.setHoveringComponent || !ctx.setItemSelector || !ctx.registerPath || !ctx.dispatch) {
|
2696
|
-
return /* @__PURE__ */
|
2712
|
+
return /* @__PURE__ */ jsx24("div", { children: "DropZone requires context to work." });
|
2697
2713
|
}
|
2698
2714
|
const {
|
2699
2715
|
hoveringArea = "root",
|
@@ -2734,7 +2750,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2734
2750
|
}
|
2735
2751
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
2736
2752
|
const isAreaSelected = selectedItem && zoneArea === selectedItem.props.id;
|
2737
|
-
return /* @__PURE__ */
|
2753
|
+
return /* @__PURE__ */ jsx24(
|
2738
2754
|
"div",
|
2739
2755
|
{
|
2740
2756
|
className: getClassName18({
|
@@ -2751,7 +2767,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2751
2767
|
onMouseUp: () => {
|
2752
2768
|
setZoneWillDrag("");
|
2753
2769
|
},
|
2754
|
-
children: /* @__PURE__ */
|
2770
|
+
children: /* @__PURE__ */ jsx24(
|
2755
2771
|
Droppable,
|
2756
2772
|
{
|
2757
2773
|
droppableId: zoneCompound,
|
@@ -2806,13 +2822,13 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2806
2822
|
className: getClassName18("item"),
|
2807
2823
|
style: { zIndex: isDragging ? 1 : void 0 },
|
2808
2824
|
children: [
|
2809
|
-
/* @__PURE__ */
|
2825
|
+
/* @__PURE__ */ jsx24(
|
2810
2826
|
DropZoneProvider,
|
2811
2827
|
{
|
2812
2828
|
value: __spreadProps(__spreadValues({}, ctx), {
|
2813
2829
|
areaId: componentId
|
2814
2830
|
}),
|
2815
|
-
children: /* @__PURE__ */
|
2831
|
+
children: /* @__PURE__ */ jsx24(
|
2816
2832
|
DraggableComponent,
|
2817
2833
|
{
|
2818
2834
|
label,
|
@@ -2880,12 +2896,12 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2880
2896
|
style: {
|
2881
2897
|
pointerEvents: userIsDragging && draggingNewComponent ? "all" : void 0
|
2882
2898
|
},
|
2883
|
-
children: /* @__PURE__ */
|
2899
|
+
children: /* @__PURE__ */ jsx24("div", { className: getClassName18("renderWrapper"), children: /* @__PURE__ */ jsx24(Render2, __spreadValues({}, defaultedProps)) })
|
2884
2900
|
}
|
2885
2901
|
)
|
2886
2902
|
}
|
2887
2903
|
),
|
2888
|
-
userIsDragging && /* @__PURE__ */
|
2904
|
+
userIsDragging && /* @__PURE__ */ jsx24(
|
2889
2905
|
"div",
|
2890
2906
|
{
|
2891
2907
|
className: getClassName18("hitbox"),
|
@@ -2902,7 +2918,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2902
2918
|
);
|
2903
2919
|
}),
|
2904
2920
|
provided == null ? void 0 : provided.placeholder,
|
2905
|
-
(snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */
|
2921
|
+
(snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ jsx24(
|
2906
2922
|
"div",
|
2907
2923
|
{
|
2908
2924
|
"data-puck-placeholder": true,
|
@@ -2934,14 +2950,14 @@ function DropZoneRender({ zone }) {
|
|
2934
2950
|
zoneCompound = `${areaId}:${zone}`;
|
2935
2951
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
2936
2952
|
}
|
2937
|
-
return /* @__PURE__ */
|
2953
|
+
return /* @__PURE__ */ jsx24(Fragment10, { children: content.map((item) => {
|
2938
2954
|
const Component = config.components[item.type];
|
2939
2955
|
if (Component) {
|
2940
|
-
return /* @__PURE__ */
|
2956
|
+
return /* @__PURE__ */ jsx24(
|
2941
2957
|
DropZoneProvider,
|
2942
2958
|
{
|
2943
2959
|
value: { data, config, areaId: item.props.id },
|
2944
|
-
children: /* @__PURE__ */
|
2960
|
+
children: /* @__PURE__ */ jsx24(
|
2945
2961
|
Component.render,
|
2946
2962
|
__spreadProps(__spreadValues({}, item.props), {
|
2947
2963
|
puck: { renderDropZone: DropZone }
|
@@ -2957,9 +2973,9 @@ function DropZoneRender({ zone }) {
|
|
2957
2973
|
function DropZone(props) {
|
2958
2974
|
const ctx = useContext3(dropZoneContext);
|
2959
2975
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
2960
|
-
return /* @__PURE__ */
|
2976
|
+
return /* @__PURE__ */ jsx24(DropZoneEdit, __spreadValues({}, props));
|
2961
2977
|
}
|
2962
|
-
return /* @__PURE__ */
|
2978
|
+
return /* @__PURE__ */ jsx24(DropZoneRender, __spreadValues({}, props));
|
2963
2979
|
}
|
2964
2980
|
|
2965
2981
|
// components/Puck/index.tsx
|
@@ -3107,7 +3123,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
3107
3123
|
};
|
3108
3124
|
|
3109
3125
|
// components/SidebarSection/index.tsx
|
3110
|
-
import { jsx as
|
3126
|
+
import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
|
3111
3127
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
3112
3128
|
var SidebarSection = ({
|
3113
3129
|
children,
|
@@ -3126,9 +3142,9 @@ var SidebarSection = ({
|
|
3126
3142
|
className: getClassName19({ noBorderTop, noPadding }),
|
3127
3143
|
style: { background },
|
3128
3144
|
children: [
|
3129
|
-
/* @__PURE__ */
|
3145
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs13("div", { className: getClassName19("breadcrumbs"), children: [
|
3130
3146
|
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs13("div", { className: getClassName19("breadcrumb"), children: [
|
3131
|
-
/* @__PURE__ */
|
3147
|
+
/* @__PURE__ */ jsx25(
|
3132
3148
|
"button",
|
3133
3149
|
{
|
3134
3150
|
type: "button",
|
@@ -3137,12 +3153,12 @@ var SidebarSection = ({
|
|
3137
3153
|
children: breadcrumb.label
|
3138
3154
|
}
|
3139
3155
|
),
|
3140
|
-
/* @__PURE__ */
|
3156
|
+
/* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
|
3141
3157
|
] }, i)) : null,
|
3142
|
-
/* @__PURE__ */
|
3158
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
|
3143
3159
|
] }) }),
|
3144
|
-
/* @__PURE__ */
|
3145
|
-
isLoading && /* @__PURE__ */
|
3160
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
|
3161
|
+
isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
|
3146
3162
|
]
|
3147
3163
|
}
|
3148
3164
|
);
|
@@ -3523,7 +3539,7 @@ init_react_import();
|
|
3523
3539
|
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" };
|
3524
3540
|
|
3525
3541
|
// components/MenuBar/index.tsx
|
3526
|
-
import { Fragment as
|
3542
|
+
import { Fragment as Fragment11, jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
|
3527
3543
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
3528
3544
|
function MenuBar({
|
3529
3545
|
appState,
|
@@ -3537,7 +3553,7 @@ function MenuBar({
|
|
3537
3553
|
history: { back, forward, historyStore }
|
3538
3554
|
} = useAppContext();
|
3539
3555
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
3540
|
-
return /* @__PURE__ */
|
3556
|
+
return /* @__PURE__ */ jsx26(
|
3541
3557
|
"div",
|
3542
3558
|
{
|
3543
3559
|
className: getClassName20({ menuOpen }),
|
@@ -3553,10 +3569,10 @@ function MenuBar({
|
|
3553
3569
|
},
|
3554
3570
|
children: /* @__PURE__ */ jsxs14("div", { className: getClassName20("inner"), children: [
|
3555
3571
|
/* @__PURE__ */ jsxs14("div", { className: getClassName20("history"), children: [
|
3556
|
-
/* @__PURE__ */
|
3557
|
-
/* @__PURE__ */
|
3572
|
+
/* @__PURE__ */ jsx26(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx26(Undo2, { size: 21 }) }),
|
3573
|
+
/* @__PURE__ */ jsx26(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx26(Redo2, { size: 21 }) })
|
3558
3574
|
] }),
|
3559
|
-
/* @__PURE__ */
|
3575
|
+
/* @__PURE__ */ jsx26(Fragment11, { children: renderHeaderActions && renderHeaderActions({
|
3560
3576
|
state: appState,
|
3561
3577
|
dispatch
|
3562
3578
|
}) })
|
@@ -3578,7 +3594,7 @@ var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields
|
|
3578
3594
|
|
3579
3595
|
// components/Puck/components/Fields/index.tsx
|
3580
3596
|
import { useCallback as useCallback7, useEffect as useEffect13, useMemo as useMemo6, useState as useState15 } from "react";
|
3581
|
-
import { Fragment as
|
3597
|
+
import { Fragment as Fragment12, jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
|
3582
3598
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
3583
3599
|
var defaultPageFields = {
|
3584
3600
|
title: { type: "text" }
|
@@ -3586,10 +3602,10 @@ var defaultPageFields = {
|
|
3586
3602
|
var DefaultFields = ({
|
3587
3603
|
children
|
3588
3604
|
}) => {
|
3589
|
-
return /* @__PURE__ */
|
3605
|
+
return /* @__PURE__ */ jsx27(Fragment12, { children });
|
3590
3606
|
};
|
3591
3607
|
var useResolvedFields = () => {
|
3592
|
-
var _a;
|
3608
|
+
var _a, _b;
|
3593
3609
|
const { selectedItem, state, config } = useAppContext();
|
3594
3610
|
const { data } = state;
|
3595
3611
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
@@ -3601,14 +3617,17 @@ var useResolvedFields = () => {
|
|
3601
3617
|
const [fieldsLoading, setFieldsLoading] = useState15(false);
|
3602
3618
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
3603
3619
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
3620
|
+
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
3621
|
+
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
3622
|
+
const hasResolver = hasComponentResolver || hasRootResolver;
|
3604
3623
|
const resolveFields = useCallback7(
|
3605
3624
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
3606
|
-
var _a2
|
3625
|
+
var _a2;
|
3607
3626
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
3608
3627
|
const changed = getChanged(componentData, lastData);
|
3609
3628
|
setLastSelectedData(componentData);
|
3610
|
-
if (
|
3611
|
-
return yield componentConfig
|
3629
|
+
if (hasComponentResolver) {
|
3630
|
+
return yield componentConfig.resolveFields(
|
3612
3631
|
componentData,
|
3613
3632
|
{
|
3614
3633
|
changed,
|
@@ -3619,8 +3638,8 @@ var useResolvedFields = () => {
|
|
3619
3638
|
}
|
3620
3639
|
);
|
3621
3640
|
}
|
3622
|
-
if (
|
3623
|
-
return yield
|
3641
|
+
if (hasRootResolver) {
|
3642
|
+
return yield config.root.resolveFields(componentData, {
|
3624
3643
|
changed,
|
3625
3644
|
fields,
|
3626
3645
|
lastFields: resolvedFields,
|
@@ -3638,12 +3657,16 @@ var useResolvedFields = () => {
|
|
3638
3657
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
3639
3658
|
);
|
3640
3659
|
useEffect13(() => {
|
3641
|
-
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3660
|
+
if (hasResolver) {
|
3661
|
+
setFieldsLoading(true);
|
3662
|
+
resolveFields(defaultFields).then((fields) => {
|
3663
|
+
setResolvedFields(fields || {});
|
3664
|
+
setFieldsLoading(false);
|
3665
|
+
});
|
3666
|
+
} else {
|
3667
|
+
setResolvedFields(defaultFields);
|
3668
|
+
}
|
3669
|
+
}, [data, defaultFields, state.ui.itemSelector, hasResolver]);
|
3647
3670
|
return [resolvedFields, fieldsLoading];
|
3648
3671
|
};
|
3649
3672
|
var Fields = () => {
|
@@ -3673,7 +3696,7 @@ var Fields = () => {
|
|
3673
3696
|
e.preventDefault();
|
3674
3697
|
},
|
3675
3698
|
children: [
|
3676
|
-
/* @__PURE__ */
|
3699
|
+
/* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
3677
3700
|
const field = fields[fieldName];
|
3678
3701
|
if (!(field == null ? void 0 : field.type)) return null;
|
3679
3702
|
const onChange = (value, updatedUi) => {
|
@@ -3743,7 +3766,7 @@ var Fields = () => {
|
|
3743
3766
|
const { edit } = getPermissions({
|
3744
3767
|
item: selectedItem
|
3745
3768
|
});
|
3746
|
-
return /* @__PURE__ */
|
3769
|
+
return /* @__PURE__ */ jsx27(
|
3747
3770
|
AutoFieldPrivate,
|
3748
3771
|
{
|
3749
3772
|
field,
|
@@ -3760,7 +3783,7 @@ var Fields = () => {
|
|
3760
3783
|
const { edit } = getPermissions({
|
3761
3784
|
root: true
|
3762
3785
|
});
|
3763
|
-
return /* @__PURE__ */
|
3786
|
+
return /* @__PURE__ */ jsx27(
|
3764
3787
|
AutoFieldPrivate,
|
3765
3788
|
{
|
3766
3789
|
field,
|
@@ -3774,7 +3797,7 @@ var Fields = () => {
|
|
3774
3797
|
);
|
3775
3798
|
}
|
3776
3799
|
}) }),
|
3777
|
-
isLoading && /* @__PURE__ */
|
3800
|
+
isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
|
3778
3801
|
]
|
3779
3802
|
}
|
3780
3803
|
);
|
@@ -3795,7 +3818,7 @@ init_react_import();
|
|
3795
3818
|
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" };
|
3796
3819
|
|
3797
3820
|
// components/ComponentList/index.tsx
|
3798
|
-
import { jsx as
|
3821
|
+
import { jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
|
3799
3822
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
3800
3823
|
var ComponentListItem = ({
|
3801
3824
|
name,
|
@@ -3806,7 +3829,7 @@ var ComponentListItem = ({
|
|
3806
3829
|
const canInsert = getPermissions({
|
3807
3830
|
type: name
|
3808
3831
|
}).insert;
|
3809
|
-
return /* @__PURE__ */
|
3832
|
+
return /* @__PURE__ */ jsx28(
|
3810
3833
|
Drawer.Item,
|
3811
3834
|
{
|
3812
3835
|
label,
|
@@ -3839,14 +3862,14 @@ var ComponentList = ({
|
|
3839
3862
|
}),
|
3840
3863
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
3841
3864
|
children: [
|
3842
|
-
/* @__PURE__ */
|
3843
|
-
/* @__PURE__ */
|
3865
|
+
/* @__PURE__ */ jsx28("div", { children: title }),
|
3866
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
|
3844
3867
|
]
|
3845
3868
|
}
|
3846
3869
|
),
|
3847
|
-
/* @__PURE__ */
|
3870
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx28(Drawer, { droppableId: title, children: children || Object.keys(config.components).map((componentKey, i) => {
|
3848
3871
|
var _a;
|
3849
|
-
return /* @__PURE__ */
|
3872
|
+
return /* @__PURE__ */ jsx28(
|
3850
3873
|
ComponentListItem,
|
3851
3874
|
{
|
3852
3875
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -3861,7 +3884,7 @@ var ComponentList = ({
|
|
3861
3884
|
ComponentList.Item = ComponentListItem;
|
3862
3885
|
|
3863
3886
|
// lib/use-component-list.tsx
|
3864
|
-
import { jsx as
|
3887
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
3865
3888
|
var useComponentList = (config, ui) => {
|
3866
3889
|
const [componentList, setComponentList] = useState16();
|
3867
3890
|
useEffect14(() => {
|
@@ -3874,7 +3897,7 @@ var useComponentList = (config, ui) => {
|
|
3874
3897
|
if (category.visible === false || !category.components) {
|
3875
3898
|
return null;
|
3876
3899
|
}
|
3877
|
-
return /* @__PURE__ */
|
3900
|
+
return /* @__PURE__ */ jsx29(
|
3878
3901
|
ComponentList,
|
3879
3902
|
{
|
3880
3903
|
id: categoryKey,
|
@@ -3883,7 +3906,7 @@ var useComponentList = (config, ui) => {
|
|
3883
3906
|
var _a2;
|
3884
3907
|
matchedComponents.push(componentName);
|
3885
3908
|
const componentConf = config.components[componentName] || {};
|
3886
|
-
return /* @__PURE__ */
|
3909
|
+
return /* @__PURE__ */ jsx29(
|
3887
3910
|
ComponentList.Item,
|
3888
3911
|
{
|
3889
3912
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -3903,7 +3926,7 @@ var useComponentList = (config, ui) => {
|
|
3903
3926
|
);
|
3904
3927
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
3905
3928
|
_componentList.push(
|
3906
|
-
/* @__PURE__ */
|
3929
|
+
/* @__PURE__ */ jsx29(
|
3907
3930
|
ComponentList,
|
3908
3931
|
{
|
3909
3932
|
id: "other",
|
@@ -3911,7 +3934,7 @@ var useComponentList = (config, ui) => {
|
|
3911
3934
|
children: remainingComponents.map((componentName, i) => {
|
3912
3935
|
var _a2;
|
3913
3936
|
const componentConf = config.components[componentName] || {};
|
3914
|
-
return /* @__PURE__ */
|
3937
|
+
return /* @__PURE__ */ jsx29(
|
3915
3938
|
ComponentList.Item,
|
3916
3939
|
{
|
3917
3940
|
name: componentName,
|
@@ -3934,12 +3957,12 @@ var useComponentList = (config, ui) => {
|
|
3934
3957
|
|
3935
3958
|
// components/Puck/components/Components/index.tsx
|
3936
3959
|
import { useMemo as useMemo7 } from "react";
|
3937
|
-
import { jsx as
|
3960
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
3938
3961
|
var Components = () => {
|
3939
3962
|
const { config, state, overrides } = useAppContext();
|
3940
3963
|
const componentList = useComponentList(config, state.ui);
|
3941
3964
|
const Wrapper = useMemo7(() => overrides.components || "div", [overrides]);
|
3942
|
-
return /* @__PURE__ */
|
3965
|
+
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
3943
3966
|
};
|
3944
3967
|
|
3945
3968
|
// components/Puck/components/Preview/index.tsx
|
@@ -3952,12 +3975,12 @@ import {
|
|
3952
3975
|
createContext as createContext4,
|
3953
3976
|
useContext as useContext5,
|
3954
3977
|
useEffect as useEffect15,
|
3955
|
-
useRef as
|
3978
|
+
useRef as useRef3,
|
3956
3979
|
useState as useState17
|
3957
3980
|
} from "react";
|
3958
3981
|
import hash from "object-hash";
|
3959
3982
|
import { createPortal as createPortal2 } from "react-dom";
|
3960
|
-
import { Fragment as
|
3983
|
+
import { Fragment as Fragment13, jsx as jsx31 } from "react/jsx-runtime";
|
3961
3984
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
3962
3985
|
var collectStyles = (doc) => {
|
3963
3986
|
const collected = [];
|
@@ -4157,7 +4180,7 @@ var CopyHostStyles = ({
|
|
4157
4180
|
observer.disconnect();
|
4158
4181
|
};
|
4159
4182
|
}, []);
|
4160
|
-
return /* @__PURE__ */
|
4183
|
+
return /* @__PURE__ */ jsx31(Fragment13, { children });
|
4161
4184
|
};
|
4162
4185
|
var autoFrameContext = createContext4({});
|
4163
4186
|
var useFrame = () => useContext5(autoFrameContext);
|
@@ -4177,7 +4200,7 @@ function AutoFrame(_a) {
|
|
4177
4200
|
]);
|
4178
4201
|
const [loaded, setLoaded] = useState17(false);
|
4179
4202
|
const [ctx, setCtx] = useState17({});
|
4180
|
-
const ref =
|
4203
|
+
const ref = useRef3(null);
|
4181
4204
|
const [mountTarget, setMountTarget] = useState17();
|
4182
4205
|
useEffect15(() => {
|
4183
4206
|
var _a2;
|
@@ -4189,7 +4212,7 @@ function AutoFrame(_a) {
|
|
4189
4212
|
setMountTarget((_a2 = ref.current.contentDocument) == null ? void 0 : _a2.getElementById("frame-root"));
|
4190
4213
|
}
|
4191
4214
|
}, [ref, loaded]);
|
4192
|
-
return /* @__PURE__ */
|
4215
|
+
return /* @__PURE__ */ jsx31(
|
4193
4216
|
"iframe",
|
4194
4217
|
__spreadProps(__spreadValues({}, props), {
|
4195
4218
|
className,
|
@@ -4199,7 +4222,7 @@ function AutoFrame(_a) {
|
|
4199
4222
|
onLoad: () => {
|
4200
4223
|
setLoaded(true);
|
4201
4224
|
},
|
4202
|
-
children: /* @__PURE__ */
|
4225
|
+
children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(CopyHostStyles, { debug, onStylesLoaded, children: createPortal2(children, mountTarget) }) })
|
4203
4226
|
})
|
4204
4227
|
);
|
4205
4228
|
}
|
@@ -4211,7 +4234,7 @@ init_react_import();
|
|
4211
4234
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
|
4212
4235
|
|
4213
4236
|
// components/Puck/components/Preview/index.tsx
|
4214
|
-
import { Fragment as
|
4237
|
+
import { Fragment as Fragment14, jsx as jsx32 } from "react/jsx-runtime";
|
4215
4238
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
4216
4239
|
var Preview = ({ id = "puck-preview" }) => {
|
4217
4240
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
@@ -4220,13 +4243,13 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4220
4243
|
var _a, _b;
|
4221
4244
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
4222
4245
|
id: "puck-root"
|
4223
|
-
}, pageProps)) : /* @__PURE__ */
|
4246
|
+
}, pageProps)) : /* @__PURE__ */ jsx32(Fragment14, { children: pageProps.children });
|
4224
4247
|
},
|
4225
4248
|
[config.root]
|
4226
4249
|
);
|
4227
4250
|
const Frame = useMemo8(() => overrides.iframe, [overrides]);
|
4228
4251
|
const rootProps = state.data.root.props || state.data.root;
|
4229
|
-
return /* @__PURE__ */
|
4252
|
+
return /* @__PURE__ */ jsx32(
|
4230
4253
|
"div",
|
4231
4254
|
{
|
4232
4255
|
className: getClassName23(),
|
@@ -4234,7 +4257,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4234
4257
|
onClick: () => {
|
4235
4258
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
4236
4259
|
},
|
4237
|
-
children: iframe.enabled ? /* @__PURE__ */
|
4260
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx32(
|
4238
4261
|
AutoFrame_default,
|
4239
4262
|
{
|
4240
4263
|
id: "preview-frame",
|
@@ -4243,27 +4266,27 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4243
4266
|
onStylesLoaded: () => {
|
4244
4267
|
setStatus("READY");
|
4245
4268
|
},
|
4246
|
-
children: /* @__PURE__ */
|
4247
|
-
const inner = /* @__PURE__ */
|
4269
|
+
children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
4270
|
+
const inner = /* @__PURE__ */ jsx32(
|
4248
4271
|
Page,
|
4249
4272
|
__spreadProps(__spreadValues({}, rootProps), {
|
4250
4273
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4251
4274
|
editMode: true,
|
4252
|
-
children: /* @__PURE__ */
|
4275
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
4253
4276
|
})
|
4254
4277
|
);
|
4255
4278
|
if (Frame) {
|
4256
|
-
return /* @__PURE__ */
|
4279
|
+
return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
|
4257
4280
|
}
|
4258
4281
|
return inner;
|
4259
4282
|
} })
|
4260
4283
|
}
|
4261
|
-
) : /* @__PURE__ */
|
4284
|
+
) : /* @__PURE__ */ jsx32("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ jsx32(
|
4262
4285
|
Page,
|
4263
4286
|
__spreadProps(__spreadValues({}, rootProps), {
|
4264
4287
|
puck: { renderDropZone: DropZone, isEditing: true },
|
4265
4288
|
editMode: true,
|
4266
|
-
children: /* @__PURE__ */
|
4289
|
+
children: /* @__PURE__ */ jsx32(DropZone, { zone: rootDroppableId })
|
4267
4290
|
})
|
4268
4291
|
) })
|
4269
4292
|
}
|
@@ -4327,7 +4350,7 @@ var isChildOfZone = (item, maybeChild, ctx) => {
|
|
4327
4350
|
};
|
4328
4351
|
|
4329
4352
|
// components/LayerTree/index.tsx
|
4330
|
-
import { Fragment as
|
4353
|
+
import { Fragment as Fragment15, jsx as jsx33, jsxs as jsxs17 } from "react/jsx-runtime";
|
4331
4354
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
4332
4355
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
4333
4356
|
var LayerTree = ({
|
@@ -4341,14 +4364,14 @@ var LayerTree = ({
|
|
4341
4364
|
}) => {
|
4342
4365
|
const zones = data.zones || {};
|
4343
4366
|
const ctx = useContext6(dropZoneContext);
|
4344
|
-
return /* @__PURE__ */ jsxs17(
|
4367
|
+
return /* @__PURE__ */ jsxs17(Fragment15, { children: [
|
4345
4368
|
label && /* @__PURE__ */ jsxs17("div", { className: getClassName24("zoneTitle"), children: [
|
4346
|
-
/* @__PURE__ */
|
4369
|
+
/* @__PURE__ */ jsx33("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
|
4347
4370
|
" ",
|
4348
4371
|
label
|
4349
4372
|
] }),
|
4350
4373
|
/* @__PURE__ */ jsxs17("ul", { className: getClassName24(), children: [
|
4351
|
-
zoneContent.length === 0 && /* @__PURE__ */
|
4374
|
+
zoneContent.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName24("helper"), children: "No items" }),
|
4352
4375
|
zoneContent.map((item, i) => {
|
4353
4376
|
var _a;
|
4354
4377
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -4376,7 +4399,7 @@ var LayerTree = ({
|
|
4376
4399
|
childIsSelected
|
4377
4400
|
}),
|
4378
4401
|
children: [
|
4379
|
-
/* @__PURE__ */
|
4402
|
+
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs17(
|
4380
4403
|
"button",
|
4381
4404
|
{
|
4382
4405
|
type: "button",
|
@@ -4409,22 +4432,22 @@ var LayerTree = ({
|
|
4409
4432
|
setHoveringComponent(null);
|
4410
4433
|
},
|
4411
4434
|
children: [
|
4412
|
-
containsZone && /* @__PURE__ */
|
4435
|
+
containsZone && /* @__PURE__ */ jsx33(
|
4413
4436
|
"div",
|
4414
4437
|
{
|
4415
4438
|
className: getClassNameLayer("chevron"),
|
4416
4439
|
title: isSelected ? "Collapse" : "Expand",
|
4417
|
-
children: /* @__PURE__ */
|
4440
|
+
children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
|
4418
4441
|
}
|
4419
4442
|
),
|
4420
4443
|
/* @__PURE__ */ jsxs17("div", { className: getClassNameLayer("title"), children: [
|
4421
|
-
/* @__PURE__ */
|
4422
|
-
/* @__PURE__ */
|
4444
|
+
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
|
4445
|
+
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label2 })
|
4423
4446
|
] })
|
4424
4447
|
]
|
4425
4448
|
}
|
4426
4449
|
) }),
|
4427
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */
|
4450
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(
|
4428
4451
|
LayerTree,
|
4429
4452
|
{
|
4430
4453
|
config,
|
@@ -4447,7 +4470,7 @@ var LayerTree = ({
|
|
4447
4470
|
|
4448
4471
|
// components/Puck/components/Outline/index.tsx
|
4449
4472
|
import { useCallback as useCallback9, useMemo as useMemo9 } from "react";
|
4450
|
-
import { Fragment as
|
4473
|
+
import { Fragment as Fragment16, jsx as jsx34, jsxs as jsxs18 } from "react/jsx-runtime";
|
4451
4474
|
var Outline = () => {
|
4452
4475
|
const { dispatch, state, overrides, config } = useAppContext();
|
4453
4476
|
const { data, ui } = state;
|
@@ -4462,8 +4485,8 @@ var Outline = () => {
|
|
4462
4485
|
[]
|
4463
4486
|
);
|
4464
4487
|
const Wrapper = useMemo9(() => overrides.outline || "div", [overrides]);
|
4465
|
-
return /* @__PURE__ */
|
4466
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */
|
4488
|
+
return /* @__PURE__ */ jsx34(Wrapper, { children: /* @__PURE__ */ jsx34(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs18(Fragment16, { children: [
|
4489
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx34(
|
4467
4490
|
LayerTree,
|
4468
4491
|
{
|
4469
4492
|
config,
|
@@ -4476,7 +4499,7 @@ var Outline = () => {
|
|
4476
4499
|
),
|
4477
4500
|
Object.entries(findZonesForArea(data, "root")).map(
|
4478
4501
|
([zoneKey, zone]) => {
|
4479
|
-
return /* @__PURE__ */
|
4502
|
+
return /* @__PURE__ */ jsx34(
|
4480
4503
|
LayerTree,
|
4481
4504
|
{
|
4482
4505
|
config,
|
@@ -4726,7 +4749,7 @@ import {
|
|
4726
4749
|
useCallback as useCallback10,
|
4727
4750
|
useEffect as useEffect17,
|
4728
4751
|
useMemo as useMemo11,
|
4729
|
-
useRef as
|
4752
|
+
useRef as useRef4,
|
4730
4753
|
useState as useState20
|
4731
4754
|
} from "react";
|
4732
4755
|
|
@@ -4739,11 +4762,11 @@ init_react_import();
|
|
4739
4762
|
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" };
|
4740
4763
|
|
4741
4764
|
// components/ViewportControls/index.tsx
|
4742
|
-
import { jsx as
|
4765
|
+
import { jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
|
4743
4766
|
var icons = {
|
4744
|
-
Smartphone: /* @__PURE__ */
|
4745
|
-
Tablet: /* @__PURE__ */
|
4746
|
-
Monitor: /* @__PURE__ */
|
4767
|
+
Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
|
4768
|
+
Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
|
4769
|
+
Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
|
4747
4770
|
};
|
4748
4771
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
4749
4772
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -4759,7 +4782,7 @@ var ViewportButton = ({
|
|
4759
4782
|
useEffect16(() => {
|
4760
4783
|
setIsActive(width === state.ui.viewports.current.width);
|
4761
4784
|
}, [width, state.ui.viewports.current.width]);
|
4762
|
-
return /* @__PURE__ */
|
4785
|
+
return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
|
4763
4786
|
IconButton,
|
4764
4787
|
{
|
4765
4788
|
title,
|
@@ -4768,7 +4791,7 @@ var ViewportButton = ({
|
|
4768
4791
|
e.stopPropagation();
|
4769
4792
|
onClick({ width, height });
|
4770
4793
|
},
|
4771
|
-
children: /* @__PURE__ */
|
4794
|
+
children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
|
4772
4795
|
}
|
4773
4796
|
) });
|
4774
4797
|
};
|
@@ -4805,7 +4828,7 @@ var ViewportControls = ({
|
|
4805
4828
|
[autoZoom]
|
4806
4829
|
);
|
4807
4830
|
return /* @__PURE__ */ jsxs19("div", { className: getClassName25(), children: [
|
4808
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
4831
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
|
4809
4832
|
ViewportButton,
|
4810
4833
|
{
|
4811
4834
|
height: viewport.height,
|
@@ -4816,8 +4839,8 @@ var ViewportControls = ({
|
|
4816
4839
|
},
|
4817
4840
|
i
|
4818
4841
|
)),
|
4819
|
-
/* @__PURE__ */
|
4820
|
-
/* @__PURE__ */
|
4842
|
+
/* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
|
4843
|
+
/* @__PURE__ */ jsx35(
|
4821
4844
|
IconButton,
|
4822
4845
|
{
|
4823
4846
|
title: "Zoom viewport out",
|
@@ -4831,10 +4854,10 @@ var ViewportControls = ({
|
|
4831
4854
|
)].value
|
4832
4855
|
);
|
4833
4856
|
},
|
4834
|
-
children: /* @__PURE__ */
|
4857
|
+
children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
|
4835
4858
|
}
|
4836
4859
|
),
|
4837
|
-
/* @__PURE__ */
|
4860
|
+
/* @__PURE__ */ jsx35(
|
4838
4861
|
IconButton,
|
4839
4862
|
{
|
4840
4863
|
title: "Zoom viewport in",
|
@@ -4848,11 +4871,11 @@ var ViewportControls = ({
|
|
4848
4871
|
)].value
|
4849
4872
|
);
|
4850
4873
|
},
|
4851
|
-
children: /* @__PURE__ */
|
4874
|
+
children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
|
4852
4875
|
}
|
4853
4876
|
),
|
4854
|
-
/* @__PURE__ */
|
4855
|
-
/* @__PURE__ */
|
4877
|
+
/* @__PURE__ */ jsx35("div", { className: getClassName25("divider") }),
|
4878
|
+
/* @__PURE__ */ jsx35(
|
4856
4879
|
"select",
|
4857
4880
|
{
|
4858
4881
|
className: getClassName25("zoomSelect"),
|
@@ -4860,7 +4883,7 @@ var ViewportControls = ({
|
|
4860
4883
|
onChange: (e) => {
|
4861
4884
|
onZoom(parseFloat(e.currentTarget.value));
|
4862
4885
|
},
|
4863
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
4886
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
|
4864
4887
|
"option",
|
4865
4888
|
{
|
4866
4889
|
value: option.value,
|
@@ -4875,7 +4898,7 @@ var ViewportControls = ({
|
|
4875
4898
|
|
4876
4899
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
4877
4900
|
init_react_import();
|
4878
|
-
var styles_module_default21 = { "PuckCanvas": "
|
4901
|
+
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" };
|
4879
4902
|
|
4880
4903
|
// lib/get-zoom-config.ts
|
4881
4904
|
init_react_import();
|
@@ -4908,17 +4931,17 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
4908
4931
|
};
|
4909
4932
|
|
4910
4933
|
// components/Puck/components/Canvas/index.tsx
|
4911
|
-
import { Fragment as
|
4934
|
+
import { Fragment as Fragment17, jsx as jsx36, jsxs as jsxs20 } from "react/jsx-runtime";
|
4912
4935
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
4913
4936
|
var ZOOM_ON_CHANGE = true;
|
4914
4937
|
var Canvas = () => {
|
4915
4938
|
const { status, iframe } = useAppContext();
|
4916
4939
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
4917
4940
|
const { ui } = state;
|
4918
|
-
const frameRef =
|
4941
|
+
const frameRef = useRef4(null);
|
4919
4942
|
const [showTransition, setShowTransition] = useState20(false);
|
4920
4943
|
const defaultRender = useMemo11(() => {
|
4921
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
4944
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment17, { children });
|
4922
4945
|
return PuckDefault;
|
4923
4946
|
}, []);
|
4924
4947
|
const CustomPreview = useMemo11(
|
@@ -4992,7 +5015,7 @@ var Canvas = () => {
|
|
4992
5015
|
recordHistory: true
|
4993
5016
|
}),
|
4994
5017
|
children: [
|
4995
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
5018
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx36(
|
4996
5019
|
ViewportControls,
|
4997
5020
|
{
|
4998
5021
|
autoZoom: zoomConfig.autoZoom,
|
@@ -5018,7 +5041,7 @@ var Canvas = () => {
|
|
5018
5041
|
}
|
5019
5042
|
) }),
|
5020
5043
|
/* @__PURE__ */ jsxs20("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
5021
|
-
/* @__PURE__ */
|
5044
|
+
/* @__PURE__ */ jsx36(
|
5022
5045
|
"div",
|
5023
5046
|
{
|
5024
5047
|
className: getClassName26("root"),
|
@@ -5030,10 +5053,10 @@ var Canvas = () => {
|
|
5030
5053
|
overflow: iframe.enabled ? void 0 : "auto"
|
5031
5054
|
},
|
5032
5055
|
suppressHydrationWarning: true,
|
5033
|
-
children: /* @__PURE__ */
|
5056
|
+
children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview, {}) })
|
5034
5057
|
}
|
5035
5058
|
),
|
5036
|
-
/* @__PURE__ */
|
5059
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
|
5037
5060
|
] })
|
5038
5061
|
]
|
5039
5062
|
}
|
@@ -5121,6 +5144,11 @@ var useLoadedOverrides = ({
|
|
5121
5144
|
}, [plugins, overrides]);
|
5122
5145
|
};
|
5123
5146
|
|
5147
|
+
// components/DefaultOverride/index.tsx
|
5148
|
+
init_react_import();
|
5149
|
+
import { Fragment as Fragment18, jsx as jsx37 } from "react/jsx-runtime";
|
5150
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment18, { children });
|
5151
|
+
|
5124
5152
|
// components/Puck/index.tsx
|
5125
5153
|
import { Fragment as Fragment19, jsx as jsx38, jsxs as jsxs21 } from "react/jsx-runtime";
|
5126
5154
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|